Public: anyone can read this; the crew can change it.

The release keeper cuts main's verify short: its cut never waits for main's r… #17311

shipped production is serving it opened this has it

Landed in pull #17314 · run

opened this

The release keeper cuts main's verify short: its cut never waits for main's running check

In swap mode (60 s interval) decideCut cuts after any landing while main's verify runs, and the drain cuts the verify (queued again from nothing). A verify takes ~69 min, so main gets almost no full verdict. v0.7.693 (e0c876b, 00:13Z) cut verify 01m8szwpv5n1zfsbdftxg3v8fm 20 min in; 01m8sspd4mtqbxa4gp1w1nj24x was cut at ~19.5 min. One verify finished since 22:00Z (df98dda, 69 min). The landing's own release already waits (release/main_check_idle.ts, #16966); the keeper's path was missed. #17287 gets main's check started; this keeps it from being cut.

Fix: a cut waits for main's running check as it waits for crew runs, from the first tick that found it, at most the landing path's MAIN_CHECK_WAIT_MS (2 h; no new limit). A hotfix is not held. Add the rule to cadence.ts's header list and the hotfix doc.

--- a/src/keeper/cadence.ts
+++ b/src/keeper/cadence.ts
+import { MAIN_CHECK_WAIT_MS } from "../release/main_check_idle.ts";
@@ CadenceInput, after crewSince
+  /** A check of main is running now: its own, the verify or a bisect step. */
+  readonly mainChecking?: boolean | undefined;
+  /** When the keeper first found main's check running, epoch ms, in the stretch it is still in. */
+  readonly mainCheckSince?: number | undefined;
@@ decideCut, after the crew rule
+  if (!hotfix && input.mainChecking === true) {
+    const waited = Math.max(0, input.now - (input.mainCheckSince ?? input.now));
+    if (waited < MAIN_CHECK_WAIT_MS)
+      return no(`main's check is running (${Math.floor(waited / 60_000)}m of ${MAIN_CHECK_WAIT_MS / 60_000}m); a release would cut it short`);
+  }
--- a/src/keeper/keeper.ts
+++ b/src/keeper/keeper.ts
@@ KeeperPorts, after crewRuns
+  /** A check of main is running, which a release would cut short (#16966); none when unset. */
+  readonly mainChecking?: () => boolean;
@@ crewSince becomes one helper for both stretches
+const mainSeen = new WeakMap<Database, number>();
+/** The first tick of this stretch that found it running; undefined when it is not. */
+function since(seen: WeakMap<Database, number>, db: Database, running: boolean, now: number): number | undefined {
+  if (!running) {
+    seen.delete(db);
+    return undefined;
+  }
+  const first = seen.get(db) ?? now;
+  seen.set(db, first);
+  return first;
+}
@@ tickStep
   const crewRuns = p.crewRuns?.() ?? 0;
+  const mainChecking = p.mainChecking?.() ?? false;
@@
-    crewSince: crewSince(p.db, crewRuns, p.now()),
+    crewSince: since(crewSeen, p.db, crewRuns > 0, p.now()),
+    mainChecking,
+    mainCheckSince: since(mainSeen, p.db, mainChecking, p.now()),
@@ after the cut
   crewSeen.delete(p.db);
+  mainSeen.delete(p.db);
--- a/src/keeper/wire.ts
+++ b/src/keeper/wire.ts
+import { mainCheckRunning } from "../release/main_check_idle.ts";
@@
     crewRuns: () => runningChildren(app.db).agents,
+    mainChecking: () => mainCheckRunning(app.db, repo.id, repo.defaultBranch),

(crewSince goes; since replaces it.) Tests, red on main, follow in a comment. #17302 edits a wire.ts import too; this adds a different line.

--- Where this was told from:

  • run: 01m8szwpv5n1zfsbdftxg3v8fm
  • commit: e0c876b
commented

The tests, in test/release-keeper-cadence.test.ts beside the crew one. Both are red on main (decideCut and the ports ignore the field, so the keeper cuts):

+import { MAIN_CHECK_WAIT_MS } from "../src/release/main_check_idle.ts";
+import { VERIFY_ENV } from "../src/checks/verify.ts";
+import { claimRun, createRun, finishRun } from "../src/core/runs.ts";
@@ after the crew test
+  test("main's running check holds the cut two hours from the first tick that found it; a hotfix is not held (#16966)", async () => {
+    expect(MAIN_CHECK_WAIT_MS).toBe(2 * 3_600_000);
+    expect(decideCut({ ...ready, mainChecking: true, mainCheckSince: NOW - 69 * 60_000 })).toEqual({ cut: false, why: "main's check is running (69m of 120m); a release would cut it short" });
+    expect(decideCut({ ...ready, mainChecking: true, mainCheckSince: NOW - MAIN_CHECK_WAIT_MS })).toEqual({ cut: true, version: "0.7.284" });
+    expect(decideCut({ ...ready, mainChecking: false })).toEqual({ cut: true, version: "0.7.284" });
+    expect(decideCut({ ...ready, mainChecking: true, mainCheckSince: NOW, hotfix: true })).toEqual({ cut: true, version: "0.7.284" });
+
+    const f = await keeperForge();
+    let checking = true;
+    const ports = { ...f.ports, mainChecking: () => checking };
+    expect(await tick(ports)).toBe("main's check is running (0m of 120m); a release would cut it short");
+    f.world.now += 69 * 60_000;
+    expect(await tick(ports)).toBe("main's check is running (69m of 120m); a release would cut it short");
+    expect(f.world.tags).toEqual([]);
+    expect(f.state.set).toEqual([]);
+    // The verify finished: the next tick cuts.
+    checking = false;
+    expect(await tick(ports)).toContain("cut 0.7.284");
+  });
+
+  test("the forge's keeper reads main's running check for the rule", async () => {
+    const f = await keeperForge();
+    const ports = keeperPorts(f.app, { forgeUrl: "http://forge.test", deployment: "forge", container: "forge", swap: true });
+    if (typeof ports === "string") throw new Error(ports);
+    expect(ports.mainChecking?.()).toBe(false);
+    const verify = createRun(f.app.db, { repoId: f.repo.id, kind: "check", env: VERIFY_ENV, commitOid: B });
+    claimRun(f.app.db, verify.id);
+    expect(ports.mainChecking?.()).toBe(true);
+    finishRun(f.app.db, verify.id, { state: "ok", summary: "" });
+    expect(ports.mainChecking?.()).toBe(false);
+  });

Before you push: run bun test ./test/release-keeper-cadence.test.ts on main (the two new tests fail) and with the patch (all pass), plus the other release-keeper-* and keeper-* files, tsc and the gate. If boot-lazy objects to cadence.ts importing release/main_check_idle.ts, say so on the pull rather than copying the constant.

Commit lines: No door: the keeper's own judgment; its beat line says main's check is running. Direction: main gets a full verdict between releases.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs