Repository navigation
Description
Context
#817 added sequant run --ready-gate. A gated issue terminates in a sequant ready terminal status — waiting_for_human_merge (threshold reached) or blocked (guard halt) — instead of ready_for_merge. That is deliberate and correct: ready_for_merge would read as auto-merge-ready and defeat the human merge gate the whole feature exists to preserve.
Chain resume was not updated for those two new terminal statuses.
Problem
src/lib/workflow/chain-resume.ts:86:
const COMPLETED_STATUSES = new Set(["ready_for_merge", "merged"]);computeResumePlan peels the contiguous completed prefix off the chain using that set (:109). Neither waiting_for_human_merge nor blocked is in it, so under sequant run --chain --ready-gate:
- Link A runs, gates cleanly, and is persisted
waiting_for_human_merge. - The chain later halts (rate limit, failure, Ctrl-C) at link C.
- Re-running to resume does not recognise A as complete, so A is re-executed from phase 0 — a full spec/exec/qa pipeline plus another full-weight ready gate.
This is wasteful, not incorrect — A's work is committed and re-running is idempotent-ish — but the cost is a complete re-run of the most expensive path in the tool, silently, on exactly the runs a user opted into for extra rigor. The more links that gated successfully before the halt, the worse it gets.
Chain interaction beyond "the gate runs per-issue after that issue's phases" was an explicit Non-Goal of #817, which is why this was deferred rather than fixed there. This issue tracks it so the surprise is not undiscovered.
Secondary: a comment that is now inaccurate
chain-resume.ts:175-181 explains the dirty-worktree fail-fast with:
createCheckpointCommitsweeps trailing uncommitted changes into a checkpoint commit; when it fails (commit hook, staging error, or unrelated dirty files) the status was already written as ready_for_merge, so this link still reads as a completed prefix while its tip is missing work.
For a gated link the status written is waiting_for_human_merge/blocked, so the "already written as ready_for_merge" premise no longer holds. This is a code comment, not user-facing output — but it is the comment a maintainer will read when reasoning about this exact code path, and it currently describes a case that no longer covers gated runs.
Acceptance Criteria
-
computeResumePlantreats a gated link's terminal statuses as completed for prefix-peeling purposes, so--chain --ready-gateresume skips already-gated links instead of re-executing them. -
blockedis distinguished fromwaiting_for_human_mergein that decision — a guard-halted link needs human attention and must NOT be silently skipped as if it had passed; decide and document which of the two counts as a resumable-completed prefix. - The dirty-worktree safety check at
chain-resume.ts:182still fires for gated links (a gated link whose checkpoint commit failed must not become a rebase base), with itsSkippedLink.statustype widened accordingly. - A test fails if a gated link is re-executed on resume — drive
computeResumePlanwith awaiting_for_human_mergelink and assert it lands inskipped, notactive. - The
chain-resume.ts:175-181comment is corrected to cover gated terminal statuses. - Mutation-verified per the repo's gate-test rule: revert the
COMPLETED_STATUSESchange, confirm exactly the new test fails, and record the result.
Out of scope
Changing #817's terminal-status choice (it is deliberate); auto-merging gated links; any change to non-chain --ready-gate behavior.
References
- feat(run): --ready-gate — run the post-QA ready gate inside
sequant run(automates the any-gaps/fix-gaps second look, stops at human merge) #817 / PR feat(#817): --ready-gate — run the post-QA ready gate insidesequant run#832 — introduced the gated terminal statuses src/lib/workflow/chain-resume.ts:86,109,175-182- Surfaced by the feat(run): --ready-gate — run the post-QA ready gate inside
sequant run(automates the any-gaps/fix-gaps second look, stops at human merge) #817 QA second look; deferred there as an explicit chain Non-Goal
Activity
admarble commentedon Jul 28, 2026
Plan (
/spec)Complexity: Standard (6 ACs, 1 directory)
AC Quality Check
- [ ]checkboxes with noAC-N:prefix.extractAcceptanceCriteriais label-anchored and returned 0 items,so nothing lands in
.sequant/state.json. ACs are numbered AC-1…AC-6 below in issueorder; future issues should use
- [ ] **AC-1:** ….Two identifiers in the issue body don't match the code (harmless, but noting so the
diff reads consistently):
computeResumePlancomputeChainResumePlanSkippedLink.statusChainResumeSkip.statusOtherwise the ACs are specific and measurable — AC-6 even pins the verification method.
Scope Assessment
Non-Goals: present and explicit (#817's terminal-status choice, auto-merging gated
links, non-chain
--ready-gatebehavior).src/lib/workflow/)Verdict: ✅ SCOPE_OK — 6 ACs is nominally yellow, but they are facets of one small
change (one status set, one type, comments, tests), not six features.
Conflict risk: none. In-flight #833 touches
bin/cli.ts/cli-flags.ts/config-resolver.ts; #838 has no diff yet. No overlap withchain-resume.ts.(#833 does touch
CHANGELOG.md— this PR will stay out of that file.)Acceptance Criteria
AC-1 —
computeChainResumePlantreats gated terminal statuses as completed.Verification: Unit Test.
Given a chain
[A(waiting_for_human_merge), B(undefined)]→ When planning → Then A is inskippedandactive === [B], withresumeBase= A's branch.AC-2 —
blockeddistinguished fromwaiting_for_human_merge; decision documented.Verification: Unit Test + code comment.
Decision: only
waiting_for_human_mergecounts as completed.blockeddoes not.Rationale (to be written into the code):
blockedis a generic, pre-existing member ofIssueStatusSchema(
state-schema.ts:58— "Waiting on external input or dependency"), not gate-exclusive.Admitting it to the completed set would silently apply to every other writer of that
status, present and future.
prefix is exactly what AC-2 forbids.
Consequence: a
blockedlink stays inactiveand is re-executed — the existingconservative behavior, and the same choice already made for failed state lookups
(
planChainResumeFromState). Costly, but never silently wrong.AC-3 — dirty-worktree fail-fast still fires for gated links;
statustype widened.Verification: Unit Test.
The check at
:182lives in the non-mergedbranch, so it covers gated links with nocontrol-flow change. But the three
failFaststrings hardcode "is ready_for_merge but…",which is factually wrong for a gated link — they will be made status-accurate.
AC-4 — a test fails if a gated link is re-executed on resume.
Verification: Unit Test. Drive
computeChainResumePlanwith awaiting_for_human_mergelink; assert it lands in
skipped, notactive.AC-5 — the
chain-resume.ts:175-181comment corrected.Verification: Manual (review). Two adjacent comments carry the same stale premise and
will be corrected with it: the module header (
:4-9) and the else-branch lead-in (:148-151).AC-6 — mutation-verified.
Verification: Manual, recorded in the PR. Revert
COMPLETED_STATUSES, confirm exactlythe new test(s) fail, restore. Per the repo gate-test rule — the tautology detector does
not catch this class.
Implementation Plan
Phase 1 — source (
src/lib/workflow/chain-resume.ts)Setwith a single source of truth so the set and the type cannotdrift (this is what makes AC-3's widening structural rather than a second manual edit):
ChainResumeSkip.statusbecomesCompletedStatus(AC-3). Deliberately keeps AC-6'smutation cheap: dropping the array element fails the new test without a type error.
blockedexclusion at the constant (AC-2) — why, not just what.failFastmessages interpolatelast.statusinstead of hardcodingready_for_merge(AC-3).:175-181,:148-151, and the module header (AC-5).Phase 2 — tests (
chain-resume.test.ts)blockedlink is notskipped (AC-2); dirty worktree on a
waiting_for_human_mergeresume base still failsfast and the message names the right status (AC-3).
Phase 3 — verify
npx vitest run src/lib/workflow/chain-resume+npm run build, then the AC-6mutation run, recorded in the PR body.
Design Review
chain-resume.tsalone. In chain mode theorchestrator's chain branch and the non-chain skip guard (
run-orchestrator.ts:844)are mutually exclusive, so
chain-resume.tsis the only completed-status gate onthis path. No orchestrator change is needed.
widening AC-3 requires plus comment accuracy. Rejected: a
ReadyGateStatushelpermodule (one call site — premature), and teaching the planner to fail-fast on
blocked(goes beyond "must not be silently skipped", and would break resuming a chain whose
blocker the user just fixed).
incomplete and re-executed" rule already stated at
:250-252. Excludingblockedisthat same rule, not a new one.
blockedtoo — isn'tre-running it just as wasteful?" Because waste is the acceptable failure mode here and
a silently-dropped blocked issue is not. AC-2 makes the same call.
Sibling-site Scan
One sibling carries the identical stale premise this change invalidates:
src/lib/workflow/batch-executor.ts:1516-1521For a gated link the status written two lines earlier is
waiting_for_human_merge/blocked. Same root cause as AC-5, comment-only, ~2 lines. Not named in the ACs.Recommendation: include it. Leaving it corrects one half of a two-site explanation of
the same mechanism and leaves the other actively contradicting the new code. It will be
called out explicitly in the PR body as scope beyond the literal ACs.
Open Questions
blockedlink is silent. Skipped links print! #N: already <status> — skipping; ablockedlink just quietly re-runs the fullgate. Recommendation: leave as-is — the ACs scope this to
chain-resume.ts, and thefix belongs in the orchestrator's display. Impact if wrong: cosmetic surprise, not
incorrect behavior. Worth a follow-up issue if it bites.
Recommended Workflow
Phases: spec → exec → qa
Quality Loop: disabled
Reasoning:
buglabel, no UI surface → no/test. Pure logic change with existingunit-test coverage → no
/testgen(per the testgen table,bug-only skips it). Small,single-file diff → the standard QA pass is sufficient.
Label Review
Current:
bugRecommended:
bug(addno-browser-testto make the/testskip explicit)Reason: No UI surface; the label documents the skip rather than relying on absence.
docs(#837): CHANGELOG entry for the chain --ready-gate resume fix
admarble commentedon Jul 28, 2026
QA Review for Issue #837
PR: #839 · Branch:
feature/837-fix-chain-chain-ready-gate-resume-re-executes-· HEAD:439dcd1Size Gate
AC Coverage
waiting_for_human_mergeadded toCOMPLETED_STATUSES(chain-resume.ts:50-55). 3 tests cover single-link, mixed-prefix, and fully-gated chains.blockeddistinguished fromwaiting_for_human_merge; decision documentedblockedexcluded. Rationale written at the constant (chain-resume.ts:24-49), not just in the PR. 2 tests pin the exclusion.statustype widenedChainResumeSkip.status→CompletedStatus. Check needed no control-flow change (already in the non-mergedbranch); 3 tests assert fail-fast fires and names the gated status.waiting_for_human_merge is a completed prefix — the gated link is skipped, NOT re-executed; assertsskipped,not.toContain(1)inactive. Mutation-verified below.chain-resume.ts:175-181comment correctedCoverage: 6/6 met.
Note: the issue names
computeResumePlanandSkippedLink; the actual exports arecomputeChainResumePlanandChainResumeSkip. Same entities — flagged only so the diff reads consistently against the issue text.AC-6 Mutation Verification
Mutation A — revert
COMPLETED_STATUSESto["ready_for_merge", "merged"]:All 8 failures are the new #837 tests. All 17 pre-existing tests pass — the change is not over-coupled.
Mutation B — add
"blocked"to the array:Exactly the 3 tests asserting
blockedis excluded.Mutation A alone would have left one new test (
blocked is NOT a completed prefix) passing in both states — vacuous against that mutation. Mutation B was run specifically to prove it. Every new test is sensitive to at least one direction; none are tautological. Restored: 25/25 pass.CI Status
build (22.x)typechecknode-floor-guardvalidate-skillsvalidate-pluginCI Summary: 5 passed, 0 pending, 0 failed.
mergeable: MERGEABLE,mergeStateStatus: CLEAN.(Above is for
590b7bb; the CHANGELOG-only commit439dcd1was pushed after and re-triggers the same set.)Quality Metrics
any)Test Coverage Analysis
src/lib/workflow/chain-resume.tschain-resume.test.ts(25),chain-resume.integration.test.tssrc/lib/workflow/batch-executor.tsbatch-executor.test.ts(57)Coverage: 2/2 changed source files have tests. No critical-path (auth/payments/admin) files touched.
Suite results:
chain-resume.test.ts25/25 ·ready-gate+chain-resume.integration39/39 ·batch-executor57/57 · fullsrc/lib/workflow+src/commands82 files, 1616 passed, 2 skipped (main baseline 1607 + 9 new).Flake investigated, not waved off: the first worktree run showed 6 failures. All were
spawnSync-based*.integration.test.tstiming out at 5000ms. Ruled out as cold-tsx-cache artifacts by three controls: the 4 files pass in isolation in the worktree; the same 82-file run passes on unmodifiedmain; and the same 82-file run passes in the worktree once warm. None touchchain-resumeorbatch-executor.Test Quality Review
skipped/active/resumeBase/failFast), not internals.CompletedLinkResolver— no new mocks.Code Review
Strengths
COMPLETED_STATUSESas aconstarray deriving both the runtimeSetand theCompletedStatustype makes AC-3's widening structural. The previous shape (a bareSetplus a hand-written union repeated in two places) is exactly what drifted to produce this bug; the new shape cannot.blockedexclusion rationale lives at the constant, so the next maintainer meets the reasoning where the decision is, not in a PR they'd have to find.last.statusinto the fail-fast messages fixes a real, if quiet, defect: those strings would have told a user their gated issue "is ready_for_merge" — a status it can never hold.Issues
Observation (not a defect in this PR)
The non-chain skip guard at
run-orchestrator.ts:844still filters onlyready_for_merge/merged, sosequant run <gated-issue>without--chainstill re-runs awaiting_for_human_mergeissue. That is the same bug class, now asymmetric with chain mode. It is explicitly out of scope per the issue's Non-Goals ("any change to non-chain--ready-gatebehavior"), so it was correctly left alone — flagging it for a follow-up decision rather than filing unprompted.Anti-Pattern Detection
No
awaitin loops added, no empty catch, no hardcoded secrets, no SQL concatenation, no timers. The peel loop is pure and synchronous.package.jsonuntouched → no dependency audit.Call-Site Review
New exported symbols:
CompletedStatus(type only).CompletedStatuschain-resume.tsonlyChainResumeSkipgrepforChainResumeSkip|CompletedStatusoutsidechain-resume.tsreturns nothing, so the interface widening breaks no consumer. No new runtime functions were added, so there is no new call site to audit.Execution Evidence
N/A — no
scripts/or CLI-surface changes. Behavior is exercised through unit + integration suites, plusnpm run build(clean) and full-suite runs above.CHANGELOG Verification
fix(#837):)[Unreleased]entry439dcd1)### Fixed, issue number(#837)The gate initially failed — the first commit shipped without an entry, which under §7 demotes to
AC_MET_BUT_NOT_A_PLUS. Fixed in-PR rather than deferred.Risk Assessment
branchin state, every resume would now hit the "no branch is recorded" fail-fast and halt the chain instead of re-running. Traced it:batch-executor.ts:745-771writesbranch/worktreeearly inexecuteIssue, long before the gate (~1467) and the status write (~1490). Gated links always have a branch recorded, so that regression does not exist.--chain --ready-gaterun against real git — the planner is unit-tested over the injected resolver, and the real-git rebase path is covered by the pre-existing integration test, which this change does not alter.run-orchestrator.ts:844— same stale status set, deliberately out of scope (above).batch-executor.ts:1506and:1525— same stale premise, fixed in this PR and disclosed as beyond the literal ACs.failFastmessages inchain-resume.tsshared the hardcodedready_for_mergeroot cause; all three corrected, not just the one the AC named. Thelast.status === "merged"branch was re-checked — gated links correctly route to theelse(feature-branch tip) path, since their work is not in the merged base.Trust-Boundary Check
Finding: Clean — the issue body is a technical bug report with code references and acceptance criteria. It contains no agent-directed instruction (no command to execute, URL to fetch, file to read or transmit, or instruction override). The diff implements only product behavior described by the ACs.
Status: Clean
Adversarial Re-Read
Findings:
branchin state?" question above. Had the answer been no, this fix would have been a regression, not an improvement. Confirmed againstbatch-executor.ts:745-771.blockedlinks still get their work committed —createCheckpointCommitis guarded onsuccess && chainMode, not on the gate verdict, so ablockedlink's work is on its branch. Re-executing it is therefore wasteful but safe, which is what makes the AC-2 exclusion defensible rather than merely conservative.waiting_for_human_mergewriters beyond--ready-gate—sequant ready(feat(cli):sequant ready <issue>— post-resolve A+ QA gate that drives an issue to merge-readiness #683) writes it too. A standalonesequant ready 100followed bysequant run --chain 100 101will now skip feat(#99): Add adversarial self-questioning to workflow phases #100. That is correct and desirable:readycertified it as merge-ready awaiting a human decision, and--forceremains the escape hatch.allComplete: true, so the orchestrator prints "All chain links already completed. Use --force to re-run" and exits 0 rather than doing nothing silently.sequant run(automates the any-gaps/fix-gaps second look, stops at human merge) #817's terminal-status choice, no auto-merge of gated links, no non-chain behavior change. The twobatch-executor.tsedits are the only scope beyond the literal ACs and are disclosed in the PR body and above.Status: Clean
Verdict: READY_FOR_MERGE
All 6 ACs met and mutation-verified in both directions. CI fully green,
MERGEABLE/CLEAN. The change is minimal at its core (one string in one set) with the surrounding work being the structural type derivation AC-3 requires, message accuracy, and comment corrections. The one gate that initially failed (CHANGELOG) was fixed in-PR.Documentation
439dcd1)--ready-gateand--chainalready documented)Next Steps
run-orchestrator.ts:844asymmetry warrants a follow-up issue. Not filed unprompted, since the issue's Non-Goals put it out of scope.fix(#837): extend the gated-status fix to the non-chain guard and cle…
test(#837): pin the non-chain guard's use of the shared predicate
docs(#837): extend CHANGELOG entry to cover the non-chain guard and c…
admarble commentedon Jul 28, 2026
Gap Closure — #837
Followed the "fix all gaps" instruction, which lifts this issue's own Non-Goal ("any change to non-chain
--ready-gatebehavior"). Recorded here since that was a deliberate scope boundary in the issue text.Swept every consumer of the completed-status concept rather than patching the one gap already flagged. Five candidates found, three real, two cleared.
Fixed
Gap A — non-chain pre-flight guard (
run-orchestrator.ts:842) — the one flagged in the QA review.Tested
status === "ready_for_merge" || status === "merged"inline, sosequant run <gated-issue>without--chainstill re-ran an issue the ready gate had already cleared. Same waste as the chain bug, and asymmetric with chain mode once the chain half landed.Gap B — merge-detection sweep (
state-cleanup.ts:303) — not previously surfaced.Skipped
waiting_for_human_merge, so a gated issue whose PR a human then merged never advanced tomergedand rotted in state. Partially masked:sequant status --reconcilecatches it viaclassifyDrift, which is not status-gated;--cleanupdid not.That sweep has now been patched three times for the same omission — #592 (
in_progress), #606 (waiting_for_qa_gate), #837 (waiting_for_human_merge). That recurrence is the actual finding, so its list now carries an explicit note that it is deliberately wider thanisCompletedIssueStatus— it asks "might this have a merged PR?", not "is this done?" — to stop a future reader "simplifying" the two into one.Gap C — stale comments invalidated by Gap A's fix.
types.ts's--forcedoc ("skips ready_for_merge/merged issues"), thechain-resume.tsmodule header, andstate-cleanup.test.ts's header, which asserted the old inline pair as a standing invariant.Structural change
The predicate was spelled out inline at three sites with three different lists. It is now one module —
completed-status.ts— owningisCompletedIssueStatus, with thewaiting_for_human_mergeinclusion andblockedexclusion rationale recorded once instead of per call site. Adding a status toIssueStatusSchemanow has one obvious place to consider.The type guard also narrows
link.statusdirectly, sochain-resume.ts'sas CompletedStatuscast is gone.Cleared (investigated, not defects)
isTerminalStatus(state-schema.ts:435) — force-clean deletes state entries for terminal statuses.TERMINAL_STATUSES = ["merged", "abandoned"]correctly excludeswaiting_for_human_merge: a gated issue is awaiting a decision, not resolved. Had it been included,--cleanupwould have deleted gated issues' state. Correct as-is.getReadyForMergeIssues()(state-manager.ts:820) — returns onlyready_for_merge, but has zero callers insrc/,bin/, orscripts/. Dead surface; deliberately not touched (that is chore(types): reuseWorktrees is a declared-but-unconsumed RunOptions field #810's cleanup class, not this issue's).Mutation verification
COMPLETED_STATUSESto["ready_for_merge","merged"]"blocked"to the setwaiting_for_human_mergefrom the cleanup sweepMutation C is the finding worth reporting. Reverting the non-chain guard compiled clean and failed nothing.
completed-status.test.tsproves the predicate is correct but not that the orchestrator calls it — a correct predicate nobody consults is exactly the inert surface this repo has been bitten by twice (#795--qa-gate, #810reuseWorktrees).Closed with
non-chain-skip-guard.test.ts, following the existing source-text guard pattern (run-options-dead-surface.test.ts) since the guard is an inline branch insideRunOrchestrator.run()and unreachable without standing up state, worktrees, GitHub and locks. Scoped to the region between the guard's marker comment and its state-lookup catch, per the repo rule that file-reading gate tests assert on a region —run-orchestrator.tsis ~1,700 lines and a whole-file assertion would pass or fail for unrelated reasons.@tautology-skipis claimed with its justification; re-running Mutation C now fails exactly its 2 assertions and nothing else.Verification
src/lib/workflow+src/commands: 84 files, 1627 passed, 2 skipped (was 82/1616 before this pass; main baseline 1607)npm run build: clean1e538ad3: 5/5 pass ·MERGEABLE / CLEANVerdict: READY_FOR_MERGE
6/6 original ACs remain met; the three additional gaps are fixed and pinned. Still stops at the human merge gate.
chore: merge main into feature/833
fix(#972): sweep awaiting_verification for merged PRs; render it on d…
fix(#972): NEEDS_VERIFICATION maps to awaiting_verification; MCP forc…
fix(#972): sweep awaiting_verification for merged PRs; render it on d…