Repository navigation
fix(#837): --ready-gate resume no longer re-executes already-gated issues (chain and non-chain) - #839
Merged
admarble merged 5 commits intoJul 28, 2026
Conversation
#817's `--ready-gate` terminates a gated issue in `waiting_for_human_merge` (threshold reached) or `blocked` (guard halt) rather than `ready_for_merge`, which would read as auto-merge-ready and defeat the human merge gate. Chain resume was never updated for those statuses, so `computeChainResumePlan`'s prefix-peel did not recognise an already-gated link as complete: resuming a halted `--chain --ready-gate` run silently re-ran each gated link from phase 0 — a full spec/exec/qa pipeline plus another full-weight gate. Add `waiting_for_human_merge` to COMPLETED_STATUSES. Deliberately do NOT add `blocked`: it is a generic member of IssueStatusSchema rather than a gate-exclusive terminal, and a guard halt is precisely the human-attention signal, so skipping it would report a link as passed when it did not. A `blocked` link therefore stays in `active` and is re-executed — the same conservative rule already applied to failed state lookups. The reasoning is recorded at the constant. COMPLETED_STATUSES becomes a `const` array that derives both the runtime set and the new `CompletedStatus` type, so `ChainResumeSkip.status` widens structurally instead of drifting from the set it mirrors. The dirty-worktree fail-fast needed no control-flow change (it already sits in the non-`merged` branch that gated links reach), but its three messages hardcoded "is ready_for_merge" — factually wrong for a gated link. They now interpolate the actual status. Comment corrections: the `chain-resume.ts` dirty-worktree explanation whose "already written as ready_for_merge" premise no longer holds for gated runs, plus the module header and the else-branch lead-in. Beyond the literal ACs: `batch-executor.ts` carried the same stale premise in a comment AND in the user-facing checkpoint-failure warning, which told users the issue "stays ready_for_merge" when a gated run had persisted `waiting_for_human_merge`. `finalStatus` is hoisted so the warning names the status actually written. Fixes #837
6 tasks
…anup sweep The chain resume fix covered `--chain`, but the same "status vocabulary was extended and consumers did not follow" bug existed at two more sites. Rather than patch each inline, the predicate becomes a single source of truth. New `completed-status.ts` owns `isCompletedIssueStatus`, with the `waiting_for_human_merge` inclusion and the `blocked` exclusion rationale recorded once instead of per call site. 1. `run-orchestrator.ts` non-chain pre-flight guard tested `status === "ready_for_merge" || status === "merged"` inline, so `sequant run <gated-issue>` without `--chain` still re-ran an issue the ready gate had already cleared — the same waste the chain fix removed, and asymmetric with chain mode once that landed. 2. `state-cleanup.ts`'s merge-detection sweep skipped `waiting_for_human_merge`, so a gated issue whose PR a human then merged never advanced to `merged` and rotted in state. That sweep has now been patched three times for exactly this omission (#592 in_progress, #606 waiting_for_qa_gate, #837 waiting_for_human_merge), so its list carries an explicit note that it is deliberately WIDER than `isCompletedIssueStatus` — it asks "might this have a merged PR?", not "is this done?" — to stop a future reader unifying the two. `chain-resume.ts` now consumes the shared predicate; the type guard narrows `link.status` directly, so the `as CompletedStatus` cast is gone. Comments invalidated by the guard change are corrected in the same pass: `types.ts`'s `--force` doc, the `chain-resume.ts` module header, and `state-cleanup.test.ts`'s header, which asserted the old inline pair. Tests: new `completed-status.test.ts` pins both directions of the predicate plus a schema cross-check that every entry is a real `IssueStatusSchema` member; `state-cleanup.test.ts` gains the gated-advance case and a `blocked` exclusion case.
Mutation-testing the previous commit found the non-chain guard fix was unpinned: reverting `isCompletedIssueStatus(...)` back to the pre-#837 inline `ready_for_merge || merged` pair compiled clean and failed nothing in the suite. `completed-status.test.ts` proves the predicate is correct but not that the orchestrator calls it — a correct predicate nobody consults is the inert surface this repo has already been bitten by twice (#795 `--qa-gate`, #810 `reuseWorktrees`). The guard is an inline branch inside `RunOrchestrator.run()` and cannot be reached without standing up a state manager, worktrees, GitHub and locks, so this follows the existing source-text guard pattern (`run-options-dead-surface.test.ts`) rather than adding an orchestrator harness. Scoped to the guard region between its marker comment and the state-lookup catch, per the repo rule that file-reading gate tests assert on a region rather than a whole file — run-orchestrator.ts is ~1,700 lines and a whole-file assertion would pass or fail for unrelated reasons. `@tautology-skip` is claimed with its justification: the file calls no production function by design, and the exemption is earned by the mutation above failing exactly these assertions and nothing else.
admarble
deleted the
feature/837-fix-chain-chain-ready-gate-resume-re-executes-
branch
July 28, 2026 16:12
This was referenced Jul 29, 2026
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.
Fixes #837.
Problem
#817's
--ready-gateterminates a gated issue inwaiting_for_human_merge(threshold reached) orblocked(guard halt) rather thanready_for_merge— deliberately, sinceready_for_mergewould read as auto-merge-ready and defeat the human merge gate the feature exists to preserve.chain-resume.tswas never updated for those statuses:computeChainResumePlanpeels the contiguous completed prefix using that set. A gated link is not in it, so resuming a halted--chain --ready-gaterun re-executed every already-gated link from phase 0 — a full spec/exec/qa pipeline plus another full-weight ready gate, silently, on exactly the runs a user opted into for extra rigor.Change
waiting_for_human_mergeis added.blockedis deliberately not.Rationale, recorded at the constant:
blockedis a generic member ofIssueStatusSchema("waiting on external input or dependency"), not a ready-gate-exclusive terminal. Admitting it would silently apply to every other writer of that status, present and future.So a
blockedlink stays inactiveand is re-executed — the same conservative rule already applied to links whose state lookup fails. Re-running wastes tokens; silently dropping an issue the user must look at is the worse failure. Once the user clears the blocker, the re-run is what lets the chain make progress.COMPLETED_STATUSESbecomes aconstarray deriving both the runtime set and a newCompletedStatustype, soChainResumeSkip.statuswidens structurally instead of drifting from the set it mirrors.The dirty-worktree fail-fast needed no control-flow change — it already sits in the non-
mergedbranch that gated links reach. But its three messages hardcoded"is ready_for_merge", which is factually wrong for a gated link; they now interpolate the actual status.AC coverage
chain-resume.ts:50-55; 3 testsblockeddistinguished + documentedchain-resume.ts:24-49; 2 testsstatus: CompletedStatus; 3 fail-fast tests assert the gated status is namedwaiting_for_human_merge ... skipped, NOT re-executed:175-181comment correctedAC-6 mutation verification
Mutation A — revert to
["ready_for_merge", "merged"]:All 8 failures are the new #837 tests. All 17 pre-existing tests pass.
Mutation B — add
"blocked"to the array:Exactly the 3 tests asserting
blockedis excluded.Every new test is sensitive to at least one direction — no tautologies. Restored: 25/25 pass.
Scope beyond the literal ACs
batch-executor.tscarried the same stale premise in two places. AC-5 names only thechain-resume.tscomment; these are flagged for explicit review::1506) asserting "the status above is alreadyready_for_merge".:1525) telling users the issue "staysready_for_merge" when a gated run had persistedwaiting_for_human_merge. This one is visible output, not just a comment — it would have misdirected a user debugging a failed checkpoint.finalStatusis hoisted so the warning names the status actually written.Verification
chain-resume.test.ts: 25/25 (17 pre-existing + 8 new)npm run build: cleansrc/lib/workflow+src/commands: 82 files, 1616 passed, 2 skipped (main baseline: 1607 + 9 new)ChainResumeSkip/CompletedStatusoutsidechain-resume.tsAn earlier run in the fresh worktree showed 6 failures in subprocess-spawning integration tests; all were cold-
tsx-cache spawn timeouts against a 5s limit. Confirmed by re-running warm (all green) and by the same 82-file run on unmodifiedmain(all green).Out of scope
Per the issue: #817's terminal-status choice, auto-merging gated links, and non-chain
--ready-gatebehavior. The non-chain skip guard atrun-orchestrator.ts:844still filters onlyready_for_merge/merged; in chain mode that branch is mutually exclusive with the chain-resume path, so it does not affect this fix.🤖 Generated with Claude Code
Follow-up: scope widened to all gated-status gaps
The maintainer asked to fix all gaps, which lifts this issue's Non-Goal on non-chain behavior. A sweep of every consumer of the completed-status concept found two more instances of the same omission, so the predicate is now a single source of truth (
completed-status.ts) rather than three inline copies with three different lists.run-orchestrator.ts:842(non-chain guard)ready_for_merge || mergedsequant run <gated-issue>without--chainre-ran an issue the gate had clearedstate-cleanup.ts:303(merge sweep)waiting_for_human_mergemerged; state rottedThe cleanup sweep has now been patched three times for this same omission (#592, #606, #837), so its list carries an explicit note that it is deliberately wider than
isCompletedIssueStatus— "might this have a merged PR?" vs "is this done?" — to stop a future reader unifying them.Also corrected the comments this invalidated:
types.ts's--forcedoc, thechain-resume.tsheader, andstate-cleanup.test.ts's header.Investigated and cleared:
isTerminalStatuscorrectly excludes gated statuses (including it would make--cleanupdelete gated state);getReadyForMergeIssues()is dead surface with zero callers, left alone.Mutation C — the finding worth flagging
Reverting the non-chain guard to its inline pair compiled clean and failed nothing.
completed-status.test.tsproved the predicate correct but not that the orchestrator calls it — the inert-surface class this repo has hit twice (#795, #810).Closed with
non-chain-skip-guard.test.ts, following the existingrun-options-dead-surface.test.tssource-text pattern (the guard is an inline branch inRunOrchestrator.run(), unreachable without standing up state/worktrees/GitHub/locks), scoped to the guard region rather than the 1,700-line file.@tautology-skipclaimed with mutation justification; re-running Mutation C fails exactly its 2 assertions.Suite: 84 files, 1627 passed, 2 skipped (was 82/1616; main baseline 1607).