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

The checkouts sweep leaves a running check's own TMPDIR (<run>.tmp) alone (su… #17875

shipped production is serving it opened this has it

Landed in pull #17876 · run

opened this

The checkouts sweep leaves a running check's own TMPDIR (<run>.tmp) alone (supersedes stuck #17614)

The bug is still on main: src/checks/floor.ts gives a check with no cell ${dir}.tmp as its writable TMPDIR, but sweepCheckouts in src/checks/sweep.ts strips only .home/.seeds/.hands before looking up the run. So <run>.tmp is read as run "<run>.tmp", none is found, and the directory is removed under the running check on the 30-second timer; its tests' mkdtemp then fail ENOENT (grokbot saw 40/134, 21/148 and 94/148 red on a child forge, each green rerun alone). grokbot's #17614 has the fix and has been green and approved for 18 hours, but it is a cross-repo pull whose check and approval are now stale, so it sits in the landing queue. Please land the same change from this repo, crediting #17614, and close #17614 as superseded once it is on main.

src/checks/sweep.ts, in sweepCheckouts, replace the comment and the const id = ... line with:

    // `<id>.home` is the home of run `<id>`, `<id>.tmp` its TMPDIR under the floor (`floor.ts`),
    // `<id>.seeds` what its runner is seeded with (`runner_seeds.ts`) and `<id>.hands` what its
    // runner handed back (`runner_hands.ts`): each lives and dies with it.
    const id = name.replace(/\.(home|tmp|seeds|hands)$/, "");

test/checks-home-sweep.test.ts, after the test "a finished run's home is removed, a live run's survives" (every import it needs is already there):

test("a live run's own temp directory (`<id>.tmp`, its TMPDIR under the floor) survives the sweep; a finished run's goes", async () => {
  // The floor (#16856) gives a check `<id>.tmp` as TMPDIR. The sweep read it as run `<id>.tmp`,
  // found no such run and removed it under the running check every 30 seconds: its tests' mkdtemp
  // failed ENOENT, more often the longer the check ran (several at once).
  const live = run();
  claimRun(app.db, live.id);
  const done = run();
  claimRun(app.db, done.id);
  finishRun(app.db, done.id, { state: "ok", summary: "ok" });
  const tmp = (id: string): string => join(dataDir, "checks", `${id}.tmp`);
  for (const id of [live.id, done.id]) mkdirSync(join(tmp(id), "forge-test-x"), { recursive: true });
  await sweepCheckouts(app);
  expect(existsSync(tmp(live.id))).toBe(true);
  expect(existsSync(tmp(done.id))).toBe(false);
  // A gate's temp directory is held by its open row, as its checkout and home are.
  const oid = "d".repeat(40);
  const open = beginGate(app.db, repoId, undefined, oid);
  mkdirSync(tmp(gateRunId(oid)), { recursive: true });
  await sweepCheckouts(app, Date.now() + GATE_DEADLINE_MS + 60_000);
  expect(existsSync(tmp(gateRunId(oid)))).toBe(true);
  endGate(app.db, open);
  await sweepCheckouts(app, Date.now() + GATE_DEADLINE_MS + 60_000);
  expect(existsSync(tmp(gateRunId(oid)))).toBe(false);
});

On main the new test fails at expect(existsSync(tmp(live.id))).toBe(true) (the live run's .tmp is swept); with the one-word regex change it passes. Checked against main's sweep.ts, floor.ts and the test file today: the patch applies as is.

Files: src/checks/sweep.ts, test/checks-home-sweep.test.ts. Risk: none; a finished or unknown run's .tmp is still removed.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs