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

A failure deferred while a builder run is at work is forgotten by a restart; re-derive it #16961

Merged opened this

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

Merged

A failed check or deploy that a restart made the crew forget is now found again and decided. I ran tsc, gate.ts, and the new test plus the existing crew-check-failed and crew-parks tests, and all passed. I did not run the full suite, so the forge's check will be the first to run it.

Notes

opened this

A failed check or deploy that a restart made the crew forget is now found again and decided. I ran tsc, gate.ts, and the new test plus the existing crew-check-failed and crew-parks tests, and all passed. I did not run the full suite, so the forge's check will be the first to run it.

What changed

  • In src/crew/dispatch.ts, decideStranded(app, repo) looks at each open pull from the run table alone. A pull is routed when all of these hold:
    • no builder run is queued or running on it;
    • the newest check or deploy at its head failed;
    • no agent run on the pull is newer than that failure.
  • It goes through the same route path as a live failed check. Main's shared reds, a red outside the diff, the "same red twice" stop, the decider and the rework all apply unchanged.
  • decideStranded runs for the repo when an agent run ends, after decideDeferred.
  • decideStrandedAtBoot(app) runs it for every repo with an open pull on the first crew pass at startup. That boot call is also what keeps the export from counting as dead code.
  • The in-memory deferredFailures map stays as it was. Only its comment changed, to say the run table now backs it up.

Test test/crew-stranded-failure.test.ts: the stand-in crew opens a pull, then the test writes a failed check at its head with no later agent run. decideStrandedAtBoot queues exactly one check_failed rework, and a second boot queues nothing more. The test calls the boot function directly rather than restarting the process, so it exercises the re-derivation, not a real restart. It would fail without the change.

Not done

  • Waiting-on-main and waiting-on-disk are also memory-only. Their pulls are re-routed by this sweep and re-wait on their own, so I added no separate persistence.
  • When a run ends, the sweep covers every open pull in that repo, not just the finished run's pull. That keeps the code to one path. The cost is a few cheap re-routes of reds already parked or waiting. They do no LLM call, because the "same red twice" and main-wait checks return first.

Reused verdictForHead, newestAgentRun, builderAtWork and route. I did not run scripts/similar.ts.

Try it bun test test/crew-stranded-failure.test.ts

No door: this is crew-internal routing, so there is no page, action, route or tool change.

🤖 Generated with Claude Code

Closes #6594

2 earlier comments
commented

A failed check or deploy that a restart made the crew forget is now found again and decided. I ran tsc, gate.ts, and the new test plus the existing crew-check-failed and crew-parks tests, and all passed. I did not run the full suite, so the forge's check will be the first to run it.

What changed

  • In src/crew/dispatch.ts, decideStranded(app, repo) looks at each open pull from the run table alone. A pull is routed when all of these hold:
    • no builder run is queued or running on it;
    • the newest check or deploy at its head failed;
    • no agent run on the pull is newer than that failure.
  • It goes through the same route path as a live failed check. Main's shared reds, a red outside the diff, the "same red twice" stop, the decider and the rework all apply unchanged.
  • decideStranded runs for the repo when an agent run ends, after decideDeferred.
  • decideStrandedAtBoot(app) runs it for every repo with an open pull on the first crew pass at startup. That boot call is also what keeps the export from counting as dead code.
  • The in-memory deferredFailures map stays as it was. Only its comment changed, to say the run table now backs it up.

Test test/crew-stranded-failure.test.ts: the stand-in crew opens a pull, then the test writes a failed check at its head with no later agent run. decideStrandedAtBoot queues exactly one check_failed rework, and a second boot queues nothing more. The test calls the boot function directly rather than restarting the process, so it exercises the re-derivation, not a real restart. It would fail without the change.

Not done

  • Waiting-on-main and waiting-on-disk are also memory-only. Their pulls are re-routed by this sweep and re-wait on their own, so I added no separate persistence.
  • When a run ends, the sweep covers every open pull in that repo, not just the finished run's pull. That keeps the code to one path. The cost is a few cheap re-routes of reds already parked or waiting. They do no LLM call, because the "same red twice" and main-wait checks return first.

Reused verdictForHead, newestAgentRun, builderAtWork and route. I did not run scripts/similar.ts.

Try it bun test test/crew-stranded-failure.test.ts

No door: this is crew-internal routing, so there is no page, action, route or tool change.

🤖 Generated with Claude Code

commented

A failure deferred while a builder run is at work is now found again from the run table, at boot and whenever an agent run ends. Before, a restart forgot it and the pull sat undecided.

  • Change (src/crew/dispatch.ts): decideStranded looks at each open pull. If the newest check or deploy at its head failed, no builder is at work, and no agent run has been made since that red, it routes that red as the failed check it is. decideStrandedAtBoot runs it once on startup, and route runs it after every agent run finishes. A new test in test/crew-stranded-failure.test.ts covers it.
  • Check failure fixed: the check failed on "a pull pushed, closed or merged meanwhile is not checked again" in test/crew-red-main.test.ts. That test's earlier tests leave pulls open and red at their head. The stand-in crew never makes a new check run when it retries, so a stranded red correctly found one of those pulls again and queued a retry the test didn't expect. The test was wrong, not the code. It now closes the earlier pulls first. It passes along with crew-stranded-failure.test.ts.
  • Checks run: bun x tsc --noEmit is clean. The gate's duplicate scan stopped after 8000 ms and compared only part of the tree, so that rule was only partly checked. I did not run the full suite; the forge runs it on the push.
  • No door: this is crew-internal routing, with no page, action, API route or tool change.
  • Not done: I did not persist deferred failures. Re-deriving them from the run table needs no new state.
commented

A failed check or deploy that landed while the builder was at work is now re-derived from the run table at boot and when an agent run ends, and each red is decided once. Four of the stranded-failure tests and the crew-red-main tests pass. tsc and the gate's wrap fix are clean. I did not run the dead-code or during-timing checks, so the forge's check may still flag them.

What changed

  • Durable decision: src/crew/red_routed.ts records, in the existing decision ledger, that the crew decided a given failed run. It uses a guard row with answer routed and the run id in its state, so there is no new table. route writes it once the builder is no longer at work and before the decision paths:
    • a rework;
    • a park;
    • a wait on main;
    • a red outside the diff;
    • a no from the decider.

    A red that is still deferred is not marked. decideStranded skips any red already marked, so the sweep no longer re-decides parked or waiting reds on each boot or run end.

  • crew-red-main: I removed the UPDATE issue SET state = 'closed' line. That test passes without it.
  • Mixed case: verdictForHead returns the newest run per kind and environment, so a red deploy stays the verdict next to an ok check. The live event path already treats it that way. I kept .find(failed) and said so in a comment. Tested with a red deploy and an ok check.
  • Run-end path: a new test has a red land unannounced while an agent run is running. The run's end queues the rework. With the decideStranded call in route removed, the test fails.
  • Parked red: the test parks a red after a repeat failure, then boots twice and checks that no run is queued and the red is marked as routed.
  • Fixed waits: I removed the sleeps so the gate's fixed-wait rule passes. This relies on the stand-in having no decider, so the rework queues synchronously.

What I chose not to do

  • One-time sweep after deploy: reds from before this change have no routed row. The first boot after deploy will decide each such open red once. I left that as is, since that is the stranded case.
  • No door change: this is crew-internal and there are no page changes, so there is no review block.

Try it: bun test test/crew-stranded-failure.test.ts test/crew-red-main.test.ts

Sign in to join this conversation.

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

Keyboard shortcuts

Docs