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

A gate's checkout is not removed under it: three gates on #7608 went red on files missing from their own working tree #16742

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Each gate now runs in a checkout directory of its own, so a later gate of the same commit can no longer wipe it. tsc and the related tests pass; I ran only those, not the whole suite. Cause.

Notes

opened this

Each gate now runs in a checkout directory of its own, so a later gate of the same commit can no longer wipe it. tsc and the related tests pass; I ran only those, not the whole suite.

Cause. A gate's checkout was named gate-<first 12 of the tip oid>. Two gates of the same tip, such as a rerun or a push that re-gates the same squash, shared one directory. The second gate's export (exportTree removes its target first) and its cleanup (removeRunDir in runTier's finally) deleted the directory the first was still running in. That matches the missing package.json, the missing .forge-cache and the ENOENT on files that are on main.

What changed

  • src/checks/gate_run.ts: each gate attempt runs as gate-<12 hex>-<8 random hex>, which gives it its own checkout and .home.
  • src/checks/sweep.ts: the sweep's GATE_DIR pattern accepts the new suffix. Without that it would have stopped treating these directories as gates and removed them while the gate was running.
  • src/checks/run_tier.ts: a failure whose checkout directory is gone, in setup or in the check step, now returns infrastructure: true with the error LOST_CHECKOUT. gate_run.ts already turns that into an interrupted gate that is re-gated, so it no longer marks the pull red.
  • test/check-gate-own-checkout.test.ts starts two gates of the same commit together. The first must still find its package.json and finish green. It fails on the old code and passes now. A second test checks that the sweep removes a suffixed gate directory once it is old.

Left out

  • I did not add a test that deletes a checkout mid-run. The lost-checkout check is a plain existsSync on the directory, and nothing exercises it.
  • A gate that loses a file other than the whole directory is still judged as a red. With per-gate directories that should no longer happen.
  • flake.ts still builds its own gate-<tip> run id for recording flakes. That is an id, not a directory.
  • I did not touch the fail-fast teardown reds from #7632. Torque's correction says they are not part of this issue.

Try it. bun test test/check-gate-own-checkout.test.ts test/checks-home-sweep.test.ts

Closes #7634

commented

Each gate now runs in a checkout directory of its own, so a later gate of the same commit can no longer wipe it. tsc and the related tests pass; I ran only those, not the whole suite.

Cause. A gate's checkout was named gate-<first 12 of the tip oid>. Two gates of the same tip, such as a rerun or a push that re-gates the same squash, shared one directory. The second gate's export (exportTree removes its target first) and its cleanup (removeRunDir in runTier's finally) deleted the directory the first was still running in. That matches the missing package.json, the missing .forge-cache and the ENOENT on files that are on main.

What changed

  • src/checks/gate_run.ts: each gate attempt runs as gate-<12 hex>-<8 random hex>, which gives it its own checkout and .home.
  • src/checks/sweep.ts: the sweep's GATE_DIR pattern accepts the new suffix. Without that it would have stopped treating these directories as gates and removed them while the gate was running.
  • src/checks/run_tier.ts: a failure whose checkout directory is gone, in setup or in the check step, now returns infrastructure: true with the error LOST_CHECKOUT. gate_run.ts already turns that into an interrupted gate that is re-gated, so it no longer marks the pull red.
  • test/check-gate-own-checkout.test.ts starts two gates of the same commit together. The first must still find its package.json and finish green. It fails on the old code and passes now. A second test checks that the sweep removes a suffixed gate directory once it is old.

Left out

  • I did not add a test that deletes a checkout mid-run. The lost-checkout check is a plain existsSync on the directory, and nothing exercises it.
  • A gate that loses a file other than the whole directory is still judged as a red. With per-gate directories that should no longer happen.
  • flake.ts still builds its own gate-<tip> run id for recording flakes. That is an id, not a directory.
  • I did not touch the fail-fast teardown reds from #7632. Torque's correction says they are not part of this issue.

Try it. bun test test/check-gate-own-checkout.test.ts test/checks-home-sweep.test.ts

commented

Each gate attempt now runs in its own checkout. If a gate loses that checkout mid-run, it reports infrastructure (LOST_CHECKOUT) instead of going red. The sweep skips a live suffixed checkout and reaps an old one. The previous push had no test for the lost-checkout reporting; this one does.

Added to test/check-gate-own-checkout.test.ts:

  • Lost-checkout test. The full command runs rm -rf "$PWD"; exit 1. The test asserts ok: false, interrupted: true (how a gate says the code was not judged, so the pull is not recorded red) and error === LOST_CHECKOUT. With the check at run_tier.ts:336 deleted, this test fails.
  • First test. The second gate is now asserted to print OWN-GREEN and to be ok itself, since it ran in its own checkout. That replaces the bare b.ok check.
  • Sweep test. An old gate-<12>-<8> directory is reaped, and a young one (inside the gate deadline) is kept. The kept case is what the regex change protects.

Not covered: the setup-path lostCheckout call at run_tier.ts:309 has no test. Reaching it needs the install step to fail after the checkout is removed, and the check command runs after install. Forcing that means injecting a fault into setupFromSnapshot, which I judged more than this fix needs.

bun x tsc --noEmit and bun scripts/gate.ts --fix are clean. I ran only this test file, not the whole suite.

To try it, run bun test test/check-gate-own-checkout.test.ts.

🤖 Generated with Claude Code

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs