feat(01KVS13C): On a red PR CI the run drives a bounded fix-and-recheck round before blocking#439
Merged
Merged
Conversation
…e blocking On a `ci-not-green` auto-merge gate outcome for a READY-FOR-MERGE story, the run now drives a bounded dev fix-and-recheck round before routing to blocked/: it re-spawns the SAME builder seeded with the failing-check context (the gate's chatLog), the dev pushes to the SAME existing PR branch, then the gate is re-run to re-poll CI. The round is bounded by a new MAX_CI_FIX_ROUNDS cap (default 1), independent of MAX_REWORK, so the dev re-spawn can never spin forever on a CI that never goes green. - Extracted the long dev-spawn block into a reusable `runDevRound` closure that returns a discriminated outcome; both the reviewer-rework loop and the CI-fix round share it (and the shared `handleDevFailure` blocking semantics), so no duplication and identical block-on-dev-failure behaviour. - Wrapped the gate call + not-confirmed-green handling in a `for (;;)` loop; only `ci-not-green` with a round remaining triggers a fix round and `continue`s to re-poll. ci-status-unreadable, verdict-failed/garbled gate, complete-failed, and the confirmed-green path are all unchanged. - run.workflow.js is shipped as-is (not bundled into dist) — no dist rebuild needed. Claude-Session: https://claude.ai/code/session_01E5VyKQMGJSL6fRfRmCzuvs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
On a red PR CI,
/flow:runnow drives a bounded dev fix-and-recheck round before giving up, instead of routing straight to blocked/ on the first red.When the auto-merge gate returns
ci-not-greenfor a story whose reviewer verdict was READY FOR MERGE and a CI-fix round still remains, the run:chatLog),runDevTerminalAction),runAutoMergeGateto re-poll CI.On green it proceeds to
completeStory/done as today; on exhausted-still-red it blocksci-not-greenexactly as today.How each AC is met
for (;;)loop. OngateReason === 'ci-not-green' && ciFixRoundsLeft > 0, the run drives a fix round via the extractedrunDevRoundclosure (seeded with the gate'schatLogfailing-check context, pushing to the same PR branch) andcontinues to re-run the gate — all before routing to blocked/.MAX_CI_FIX_ROUNDSis exhausted and the gate is stillci-not-green, the loop breaks and the existing not-confirmed-green handler blocks the story with reasonci-not-green.completeStory(the done/ move) runs only after that guard, so a still-red story never reaches done/.ci-not-greenexactly. A confirmed-green outcome (auto-merge / pause on green CI), anci-status-unreadableblock, or averdict-failed/garbled gate all break out of the loop immediately and route exactly as before — no fix round.Safety
The new
MAX_CI_FIX_ROUNDScap (default 1, fromA.maxCiFixRounds) is independent ofMAX_REWORKand bounds the re-spawn loop — the story's highest risk (an unbounded dev re-spawn loop) cannot occur.ciFixRoundsLeftis decremented each round and gates the re-spawn.Structure
The long dev-spawn block was extracted into a reusable
runDevRoundclosure that returns a discriminated outcome (spawn-reviewer/needs-human/no-handoff/pd-failed); both the reviewer-rework loop and the CI-fix round call it, and a sharedhandleDevFailurekeeps the block-on-dev-failure semantics identical regardless of which path spawned the dev. Faithful to the original:isolation:'worktree', therunDevTerminalActionhandoff path, and the parse/blocking behaviour all live inside the closure.Build & tests
run.workflow.jsis shipped as-is (NOT bundled into dist) andrun-auto-merge-gate.tswas left unchanged (the gate already returns the failing-check detail inchatLog), so no dist rebuild was needed — no dist drift.tests/run-workflow.test.ts: 61 passed (8 new structural anchors for this story's ACs + the bound).https://claude.ai/code/session_01E5VyKQMGJSL6fRfRmCzuvs