Skip to content

feat: resume a partially-completed chain from its last good link #760

Closed

Description

@admarble

Context

The #604 forensics showed 3 of the 5 recorded chain failures (two rate-limit cascades, one QA API timeout) killed the whole chain even though earlier links had completed and checkpointed — a rerun the next day of one of them (f317530c → b9c08e29) succeeded. Chain mode already writes a checkpoint(#N): QA passed commit after each successful link (createCheckpointCommit, worktree-manager.ts) and describes it as a "recovery point if later issues fail", but nothing consumes it: on any link failure the loop does an unconditional break (run-orchestrator.ts) and a re-run redoes completed issues from scratch.

This is the highest-leverage chain improvement identified: it converts "chain dead, 1–3 hours wasted" into "re-run picks up at the failed link" for the dominant failure classes.

Proposal

Re-running sequant run A B C --chain after a partial failure should skip links that already completed (state.json status ready_for_merge + existing worktree/branch with checkpoint) and resume execution at the first incomplete link, re-establishing the successor rebase chain from the last good link's committed tip (the #748-fixed rebaseOntoLocalBranch path). Whether this is automatic on re-run or an explicit --resume-chain flag is a design decision for /spec — automatic detection must not silently skip an issue the user intended to redo.

Acceptance Criteria

  • Re-running the same --chain invocation after a mid-chain failure does not re-execute links whose issues are ready_for_merge with an intact worktree; execution resumes at the first incomplete link, rebased onto the last completed link's local committed tip.
  • Skipped links are reported explicitly in output (issue number, why it was skipped, which commit the resume point is).
  • A completed link whose worktree/branch has been destroyed (e.g. merged + cleaned mid-way) is handled: either re-established from the merged base or the chain fails fast with a clear message — no silent wrong-base execution.
  • createCheckpointCommit failure is no longer silent (currently warns and continues, worktree-manager.ts ~1094-1102): if the recovery point can't be written, the run says so prominently, since resume depends on it.
  • Integration test with real git: run a 3-link chain, force link 2 to fail, re-run, assert link 1 is skipped and link 2 branches from link 1's tip (merge-base --is-ancestor, same pattern as the fix(#748): --chain successors branch from predecessor's committed work, not main #752 test).

Out of scope

Automatic retry within the same run (separate concern), rate-limit detection/backoff (companion issue), --stacked PR-base rewriting on resume beyond what the normal path already does.

References

Activity

  1. added
    enhancement
    cli
    on Jul 14, 2026
  2. admarble commented on Jul 15, 2026

    @admarble
    ContributorAuthor

    📋 /spec Plan — #760 Resume a partially-completed chain

    Complexity: Standard (5 ACs, 1 primary directory: src/lib/workflow)

    AC Quality Check

    The 5 ACs are unlabeled checkboxes (no AC-N: IDs) — the parser returns 0, so downstream state storage will need IDs. All 5 are measurable and testable (each names a concrete file, state, or git assertion). No vague/unmeasurable language. Recommend adding AC-1…AC-5 labels so /exec and /qa can track them individually.


    Scope Assessment

    Non-Goals: ✅ Present ("Out of scope" section: intra-run retry, rate-limit backoff, --stacked base rewriting beyond the normal path).

    Metric Value Status
    Feature count 1 (chain resume) ✅
    AC items 5 ✅
    Directory spread 1 (src/lib/workflow) ✅

    Verdict: ✅ SCOPE_OK — focused, single-module change with clean boundaries.


    Key Finding (read before implementing)

    The skip-detection this issue asks for already exists — the pre-flight state guard at run-orchestrator.ts:635 filters any issue that is ready_for_merge/merged out of issueNumbers (unless --force) and even prints already ready_for_merge — skipping. But that guard is chain-unaware and actively breaks the chain contract on resume:

    1. Filtering happens at line ~635, before ensureWorktreesChain (line ~770). So a completed link is dropped from the list the chain is provisioned from → the first incomplete link is provisioned from baseBranch/main, not the completed predecessor's committed tip.
    2. In executeSequential, the fix(chain): --chain successors branch from main, not predecessor's committed work (up-front worktree provisioning) #748 successor-rebase only fires for i > 0. Once the completed prefix is dropped, the first-incomplete link sits at index 0, so it never rebases onto the predecessor's tip — it silently builds on main, missing the completed link's work (exactly the fix(chain): --chain successors branch from main, not predecessor's committed work (up-front worktree provisioning) #748 failure mode).

    So the real work is not "add skip logic" — it's making the existing skip chain-correct: preserve the completed prefix as chain context and rebase the first-incomplete link onto the last completed link's local checkpoint tip.


    Acceptance Criteria + Verification

    AC-1 — Re-run skips completed links; resumes at first incomplete, rebased onto last-completed tip.

    • Verification: Integration Test (real git)
    • Scenario: Given links #A→#B→#C where #A is ready_for_merge with an intact worktree/checkpoint → When re-running run A B C --chain → Then #A is not re-executed and #B's branch has #A's checkpoint tip as an ancestor (merge-base --is-ancestor).

    AC-2 — Skipped links reported explicitly (issue #, why, resume commit).

    • Verification: Integration Test (assert stdout)
    • Scenario: Given #A skipped → When resuming → Then output names #A, reason (ready_for_merge), and the commit #B resumes from.

    AC-3 — Completed link with destroyed worktree/branch: re-establish from merged base OR fail fast — no silent wrong-base.

    • Verification: Integration Test + Unit Test
    • Scenario A (merged): predecessor merged, worktree gone → successor rebases onto origin/main (work is there). Scenario B (ready_for_merge but worktree/checkpoint gone): tip is unreconstructable → fail fast with a clear message, do not run the successor.

    AC-4 — createCheckpointCommit failure is loud (not verbose-gated).

    • Verification: Integration Test
    • Scenario: Given commit step fails → When link finishes QA in chain mode → Then a prominent (non-verbose) warning fires and the run outcome reflects that the recovery point is missing.

    AC-5 — Integration test: 3-link chain, force link 2 to fail, re-run, assert link 1 skipped & link 2 branches from link 1's tip.

    • Verification: Integration Test — extend chain-rebase.integration.test.ts pattern (real worktrees, isAncestor helper).

    Implementation Plan

    Phase 1 — Chain-aware resume base

    1. In the pre-flight guard (run-orchestrator.ts:635), when options.chain: instead of silently dropping completed links, record them as skipped-but-part-of-chain (issue → branch, checkpoint tip). Keep them out of execution but keep them in chain topology.
    2. Compute resumeBase = the last completed link's local branch tip (checkpoint commit). Provision the first-incomplete link from resumeBase rather than baseBranch (feed the completed prefix's tail branch into ensureWorktreesChain as its baseBranch, or splice the completed branch into worktreeMap so the existing i>0 rebase path finds a predecessor).

    Phase 2 — Rebase correctness + integrity (AC-1, AC-3)
    3. Ensure executeSequential's successor-rebase (rebaseOntoLocalBranch, #748 path) fires for the first-incomplete link against the last-completed predecessor's tip — even though the predecessor didn't execute this run. Reuse the existing "chain link broken → stop" handling for failures.
    4. Add the AC-3 integrity check: before trusting a completed link as the resume base, verify its worktree/branch + checkpoint commit exist. merged → rebase successor onto origin/main. ready_for_merge but tip gone → fail fast (clear message), no wrong-base execution.

    Phase 3 — Reporting + checkpoint hardening (AC-2, AC-4)
    5. Upgrade the skip message to name each skipped link, its reason, and the resume commit the next link branches from.
    6. In batch-executor.ts:1129, capture createCheckpointCommit's return value (currently discarded); on false, emit a prominent warning regardless of config.verbose and reflect it in the issue result (resume depends on this commit). Consider promoting the internal verbose-only warnings in createCheckpointCommit (worktree-manager.ts:1076/1099) to always-on for chain mode.

    Phase 4 — Tests (AC-5)
    7. Extend chain-rebase.integration.test.ts (or a new chain-resume.integration.test.ts): 3-link chain, complete link 1 (checkpoint), simulate link 2 failure, re-run, assert link 1 skipped + link 2's base is link 1's tip via merge-base --is-ancestor. Add AC-3 destroyed-worktree cases and an AC-4 checkpoint-failure case.


    Design Review

    1. Where does this logic belong? Resume detection/skip in the pre-flight guard region of run-orchestrator.ts; resume-base wiring in ensureWorktreesChain / executeSequential; checkpoint hardening in batch-executor.ts + worktree-manager.ts. No new module needed.
    2. Simplest correct approach? Reuse the existing skip guard and the existing fix(chain): --chain successors branch from main, not predecessor's committed work (up-front worktree provisioning) #748 rebaseOntoLocalBranch path — the only new mechanism is preserving the completed prefix's tail branch as the resume base. Reject: a brand-new --resume-chain flag with a parallel code path (duplicates the guard + rebase logic already present).
    3. Existing pattern followed? fix(chain): --chain successors branch from main, not predecessor's committed work (up-front worktree provisioning) #748/fix(#748): --chain successors branch from predecessor's committed work, not main #752 successor-rebase-onto-local-tip; the pre-flight ready_for_merge skip guard; the "chain link broken → stop, don't wrong-base" handling already in executeSequential.
    4. What a senior reviewer would challenge? "Why no new flag?" → because automatic skip is already the shipped default and --force is the existing, tested 'redo everything' escape hatch (satisfies the issue's 'must not silently skip an issue the user intended to redo'). "Does squash-merge break the ancestor assertion?" → yes for AC-3 merged-case; that's why merged links resume onto origin/main, not the (gone) local tip.

    Feature Quality Planning

    Notable items:

    • AC-3 is the sharp edge. Distinguish merged (resume onto origin/main) from ready_for_merge-but-worktree-gone (fail fast). Squash-merge means the local checkpoint tip is not an ancestor of origin/main, so never rebase a successor onto a stale local tip after merge.
    • --force interaction: --force bypasses the guard → re-runs the whole chain from scratch. Confirm resume logic sits inside the !mergedOptions.force branch so force still means "redo everything."
    • Companion worktree feat: lightweight content pre-flight for --chain (AC presence, dependency-order sanity) #762 (content pre-flight for chain) is in-flight but touches a different concern (AC pre-flight, not resume/rebase). No file overlap expected — both branch from main at the same commit. Low conflict risk; coordinate final merge order via /merger if both land together.

    Open Questions

    1. Automatic-on-rerun vs explicit --resume-chain flag? — Recommendation: automatic (reuse the existing skip guard); --force remains the "redo everything" override. Impact if wrong: a user re-running to redo a completed link would need --force — acceptable and already the documented behavior for non-chain runs.
    2. AC-3 destroyed-worktree default when status is ready_for_merge (not merged)? — Recommendation: fail fast with a clear message (tip is unreconstructable; wrong-base is worse than stopping). Impact if wrong: user re-provisions manually; safe.
    3. Should checkpoint-commit failure abort the link, or just warn loudly? — Recommendation: warn prominently + continue (the link's work is done; only future resume is impaired). AC-4 says "says so prominently," not "abort." Impact if wrong: a later resume of a downstream link fails fast (AC-3 path), which is acceptable.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: enabled (chain/git-mechanics change with real-git integration tests — worth the extra QA pass)
    testgen: optional — the ACs are integration/real-git verified, not unit-pure; skip auto-testgen and hand-author the integration test in Phase 4.
    Reasoning: CLI/git-mechanics enhancement, single module, no UI (no-browser-test not needed — no components). Not security-sensitive.


    Label Review

    Current: enhancement, cli
    Recommended: add planned; consider chain if that label exists for grouping.
    Quality Loop: will auto-enable via recommendation above (git-mechanics risk), independent of scope verdict (SCOPE_OK).

  3. added
    planned
    on Jul 15, 2026
  4. admarble commented on Jul 15, 2026

    @admarble
    ContributorAuthor

    ✅ /exec complete — #760 chain resume

    PR: #765 · Branch: feature/760-feat-resume-a-partially-completed-chain-from-its-l

    AC Coverage

    AC Status Evidence
    AC-1 — resume at first incomplete, rebased onto last-completed tip ✅ chain-resume.ts plan + executeSequential first-active-link rebase; integration test asserts merge-base --is-ancestor
    AC-2 — skipped links reported (issue #, reason, resume commit) ✅ ↻ Resuming chain at #N from <sha> (<branch>) + per-link skip lines
    AC-3 — destroyed link: merged→base, ready_for_merge-gone→fail fast ✅ computeChainResumePlan branches; unit + integration coverage (destroyed branch, merged)
    AC-4 — checkpoint failure loud + reflected in result ✅ Always-on warning in createCheckpointCommit + call-site warning + checkpointFailed on IssueResult; test forces commit failure via pre-commit hook
    AC-5 — 3-link integration test (force link 2 fail, re-run, assert) ✅ chain-resume.integration.test.ts (#752 real-git pattern)

    Key implementation

    The skip already existed but was chain-unaware (the exact finding in the /spec plan): dropping completed links before provisioning left the first incomplete link at index 0, where the #748 successor-rebase never fires → it silently rebuilt on main. Fix = make the skip chain-correct:

    • chain-resume.ts — pure computeChainResumePlan(): peels the contiguous completed prefix, computes resumeBase (last completed link's local branch for ready_for_merge; base branch for merged), fails fast when a ready_for_merge link's branch is destroyed.
    • run-orchestrator.ts — chain-aware pre-flight guard reports skips + resume commit, provisions the incomplete tail from resumeBase, and executeSequential explicitly rebases the first active link onto resumeBase with fail-fast (the authoritative correctness gate — provisioning-time rebase only warns).
    • batch-executor.ts + worktree-manager.ts — capture createCheckpointCommit result, warn prominently (non-verbose), record checkpointFailed.

    --force still bypasses resume (redo whole chain). Non-chain skip guard unchanged.

    Files changed

    chain-resume.ts (new), chain-resume.test.ts (new), chain-resume.integration.test.ts (new), run-orchestrator.ts, batch-executor.ts, worktree-manager.ts, types.ts, checkpoint.integration.test.ts, CHANGELOG.md

    Checks

    • npm run build ✅ · npm run lint ✅ (0 warnings) · npx vitest run src/lib/workflow/ → 972 passed, 2 skipped, 0 failures

    Recommended next step

    /qa 760 — quality loop enabled per the /spec recommendation (git-mechanics change with real-git integration tests).

  5. admarble commented on Jul 15, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #760

    Note: prior QA passes completed all checks but timed out at the comment-post step (1800s wall-clock). This is the synthesized verdict at commit 8249128 — all checks green, no code changes since.

    AC Coverage

    AC Description Status Evidence
    AC-1 Re-run skips completed links; resumes at first incomplete, rebased onto last-completed tip MET computeChainResumePlan (chain-resume.ts) + executeSequential i===0 rebase (run-orchestrator.ts:1112). Integration test asserts merge-base --is-ancestor(link1Checkpoint, link2HEAD) after resume rebase
    AC-2 Skipped links reported (issue #, reason, resume commit) MET Per-link already <status> — skipping lines + ↻ Resuming chain at #N from <sha8> (<branch>) (run-orchestrator.ts:744-761); asserted in integration test (skipped, resumeBaseCommit)
    AC-3 Destroyed link: merged→resume from base; ready_for_merge-but-gone→fail fast MET computeChainResumePlan merged branch (resumeBase=baseBranch) vs fail-fast on unresolvable branch tip; unit tests (destroyed branch, no-branch-recorded, merged) + integration tests (branch -D, merged-to-main)
    AC-4 createCheckpointCommit failure loud + reflected in result MET Commit-failure log de-gated from verbose (worktree-manager.ts:1096-1104) + always-on call-site warning (batch-executor.ts:1139) + checkpointFailed on IssueResult; integration test forces failure via pre-commit hook and asserts the non-verbose warning
    AC-5 Integration test: 3-link chain, force link 2 fail, re-run, assert link 1 skipped + link 2 from link 1's tip MET chain-resume.integration.test.ts — real git, #752 isAncestor pattern

    Coverage: 5/5 AC items fully met. Original ACs: 5/5. Derived ACs: none in spec.


    CI Status

    Check State Impact
    build (22.x) SUCCESS ✅ MET
    node-floor-guard SUCCESS ✅ MET
    typecheck SUCCESS ✅ MET
    validate-skills SUCCESS ✅ MET
    validate-plugin SUCCESS ✅ MET

    CI Summary: 5 passed, 0 pending, 0 failed.


    Quality Metrics

    Metric Value Status
    Type issues (any/as any/@ts-ignore) 0 OK
    Deleted tests 0 OK
    Files changed 9 (all in src/lib/workflow/ + CHANGELOG) OK
    Lines added / deleted +853 / −36 —
    Production LOC ~426 Large but single-feature

    Sub-agent checks (type-safety, scope, security) all returned PASS.


    Test Coverage Analysis

    Changed source file Tier Has Tests?
    chain-resume.ts Standard ✅ chain-resume.test.ts (unit, 7) + chain-resume.integration.test.ts (real git, 5)
    worktree-manager.ts (checkpoint warning) Standard ✅ checkpoint.integration.test.ts (AC-4 pre-commit-hook case)
    batch-executor.ts (checkpointFailed) Standard ⚠️ field set, not directly asserted (existing batch-executor.test.ts green)
    run-orchestrator.ts (resume wiring) Standard ⚠️ indirect — plan + rebase mechanism covered by integration test; no direct orchestrator harness (repo has none)
    types.ts Optional — (types only)

    Full workflow suite: 972 passed, 2 skipped, 0 failed. Lint clean.


    Code Review

    Strengths:

    • Correctly diagnoses and fixes the chain-unaware skip: computeChainResumePlan is a pure, injected-resolver function (unit-testable without git); the real rebase reuses the fix(chain): --chain successors branch from main, not predecessor's committed work (up-front worktree provisioning) #748 rebaseOntoLocalBranch path rather than duplicating logic.
    • executeSequential's i===0 resume rebase is the authoritative fail-fast gate (provisioning-time rebase only warns) — directly satisfies "no silent wrong-base execution."
    • Only a contiguous completed prefix is peeled; a completed link after an incomplete one is re-executed (never silently drops a redo). --force still bypasses resume — resume sits inside the !force branch.
    • Security clean: all git calls use spawnSync("git", [array]) form; no shell-string interpolation of branch names.

    Minor (non-blocking) observations:

    • checkpointFailed is set on IssueResult (satisfies AC-4's "reflect it in the result") but has no downstream consumer yet — user-facing prominence comes from the always-on warnings. Surfacing it in the final run summary would be a natural follow-up.
    • The run-orchestrator.ts resume wiring (pre-flight guard + i===0 rebase) is exercised indirectly via the integration test's plan+rebase path rather than a direct orchestrator test (the repo has no orchestrator test harness).

    Risk Assessment

    • Likely failure mode: merged-prefix resume rebases the first active link onto local baseBranch (main); if local main lags origin/main the successor could branch from stale main. Mitigated — reconcileStateAtStartup runs first, and this is the same base a fresh first link uses. Documented in chain-resume.ts.
    • Not tested: direct unit coverage of the orchestrator pre-flight guard / executeSequential i===0 branch (thin wiring over already-tested functions).
    • Sibling sites considered: none — the resume rebase is the cross-file complement to the fix(chain): --chain successors branch from main, not predecessor's committed work (up-front worktree provisioning) #748 successor-rebase, which already exists and is reused rather than re-implemented.
    • Sibling-line audit: the i===0 resume block mirrors the existing i>0 rebase block in the same loop; both fail-fast identically on rebase failure/missing worktree.

    Adversarial Re-Read

    Findings: Traced the resume path end-to-end: (1) fresh runs are unaffected — chainResume is only set when skipped.length > 0, so the i===0 block is skipped; (2) fail-fast path mirrors the existing allComplete early-return (shutdown.dispose() + return), no new leak; (3) state is read after reconcileStateAtStartup, so a just-merged link is correctly treated as merged; (4) locks/issueInfo operate on the narrowed active tail — completed links don't claim locks. Two minor improvement opportunities surfaced (checkpointFailed summary surfacing; direct orchestrator-wiring test), both beyond the literal ACs. No verbatim motivating-example fixture unrun, no bug-repro-as-evidence, no Non-Goal scope creep.

    Status: Gaps Found (minor, non-blocking → verdict floors at AC_MET_BUT_NOT_A_PLUS)


    Verdict: AC_MET_BUT_NOT_A_PLUS

    All 5 acceptance criteria are literally MET, all CI checks pass, security/type/scope checks are clean, and the change is well-tested (pure-logic unit tests + real-git integration tests). Two minor, optional improvements keep it from a strict A+: surface checkpointFailed in the run summary, and add a direct orchestrator-wiring test if a harness is introduced. Neither blocks merge — this breaks to PR for the human merge gate (no quality loop needed).

    Documentation

    Next Steps

    1. Merge PR feat(#760): resume a partially-completed chain from its last good link #765 at reviewer discretion (all ACs met, CI green).
    2. (Optional) Follow-up: surface checkpointFailed in the run summary output.
  6. added
    needs-improvement
    on Jul 15, 2026
  7. admarble commented on Jul 15, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #760 (PR #765)

    AC Coverage

    AC Source Description Status Notes
    AC-1 Original Re-run skips completed links; resumes at first incomplete, rebased onto last-completed tip MET computeChainResumePlan peels the contiguous completed prefix; run-orchestrator.ts sets issueNumbers = plan.active, passes resumeBase as chainBase to ensureWorktreesChain, and adds an explicit i === 0 rebase in executeSequential. Integration test asserts merge-base --is-ancestor.
    AC-2 Original Skipped links reported (issue #, reason, resume commit) MET Per-link already <status> — skipping lines plus ↻ Resuming chain at #N from <sha> (<branch>).
    AC-3 Original Destroyed completed link: re-establish from merged base OR fail fast MET merged → resumeBase = baseBranch; ready_for_merge with missing/unrecorded branch → failFast, orchestrator aborts with exit 1 before any execution. Both covered by unit + real-git integration tests.
    AC-4 Original createCheckpointCommit failure no longer silent MET Verbose gate removed in worktree-manager.ts:1094-1105; call-site warning + checkpointFailed on IssueResult. Tested via a failing pre-commit hook with verbose=false. See finding #1 — the AC is met, but the warning's content is wrong.
    AC-5 Original Integration test: 3-link chain, link 2 fails, re-run, link 1 skipped + link 2 branches from link 1's tip MET chain-resume.integration.test.ts — real git worktrees, merge-base --is-ancestor, the #752 pattern the AC explicitly names.

    Coverage: 5/5 AC items fully met
    Original ACs: 5/5 met · Derived ACs: None found


    CI Status

    Check State Conclusion Impact
    build (22.x) COMPLETED success ✅ MET
    typecheck COMPLETED success ✅ MET
    node-floor-guard COMPLETED success ✅ MET
    validate-plugin COMPLETED success ✅ MET
    validate-skills COMPLETED success ✅ MET

    CI Summary: 5 passed, 0 pending, 0 failed. mergeable: MERGEABLE, 0 commits behind origin/main.


    Quality Metrics

    Metric Value Status
    Type issues (any) 0 OK
    Deleted tests 0 OK
    Files changed 9 OK
    Lines added +653 -
    Lines deleted -36 -

    Of +653 added, 425 lines (65%) are tests. Production change is ~228 lines across 5 files, confined to src/lib/workflow/ — matches the spec's SCOPE_OK assessment.


    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    chain-resume.ts Critical ✅ Yes chain-resume.test.ts (8), chain-resume.integration.test.ts (4)
    run-orchestrator.ts Critical ⚠️ No Resume wiring has no direct coverage — see finding #3
    batch-executor.ts Critical ⚠️ Indirect checkpoint.integration.test.ts covers createCheckpointCommit, not the call site
    worktree-manager.ts Critical ✅ Yes checkpoint.integration.test.ts AC-4 case
    types.ts Optional N/A Type-only

    Coverage: 3/5 changed source files have direct tests. Local run: 17/17 passed in the three touched test files.


    Code Review

    Strengths:

    • The root-cause framing is right, and it's the hard part. The issue asked to "add skip logic"; the spec found skip logic already existed but was chain-unaware, and the implementation fixes that instead of bolting on a parallel --resume-chain path. Preserving the completed prefix as chain topology (rather than dropping it) is exactly what prevents the fix(chain): --chain successors branch from main, not predecessor's committed work (up-front worktree provisioning) #748 wrong-base regression from reappearing on resume.
    • Fail-fast is placed at the authoritative gate. The i === 0 rebase in executeSequential is correctly justified in the comment: provisioning-time rebase only warns, so putting the hard gate here means a link can never silently execute on the wrong base. The non-chain guard is left byte-identical, so blast radius is contained to --chain.
    • The merged-vs-ready_for_merge split is the sharp edge, and it's handled correctly. Resuming a merged prefix from baseBranch rather than the local tip is the right call — squash-merge orphans the local checkpoint, and rebasing onto it would be the silent wrong-base AC-3 forbids.
    • Planner is pure over an injected resolver, so the AC-3 state machine is unit-testable without git, while the rebase contract is proven against real worktrees. Good separation.
    • --force correctly sits outside the resume branch, preserving "redo everything" semantics.

    Issues:

    1. The AC-4 warning tells the user the opposite of what happens (batch-executor.ts:1141-1147 — medium). The message reads "chain resume from this link is unavailable. Re-running the chain will redo #N." Both clauses are false. updateIssueStatus(issueNumber, "ready_for_merge") runs at line 1121, before the checkpoint attempt at 1132. So on re-run, computeChainResumePlan sees status: "ready_for_merge" with an existing branch, skips #N, and sets resumeBase to its branch tip. Resume is not unavailable and #N is not redone.

      The consequence is more than cosmetic: createCheckpointCommit only returns false when there is in-scope dirty work it failed to commit (it returns true when there's nothing to checkpoint). So the successor gets rebased onto a tip that is missing exactly the work the checkpoint would have captured — and the warning tells the user a re-run will take care of it, so they take no action. Two possible fixes:

      • Message-only: say that #N will be skipped on re-run and resumed from its last commit, which is missing the uncommitted work — recommend --force or a manual commit.
      • Behavioral: write ready_for_merge only after a successful checkpoint in chain mode, so a failed checkpoint leaves #N in_progress and the re-run genuinely redoes it — which is what the message already promises.

      The second is truer to AC-4's intent ("resume depends on it"), but it changes status semantics and deserves its own discussion rather than a drive-by change.

    2. checkpointFailed is written but never read (types.ts:276, batch-executor.ts:1241 — low). Nothing consumes the field: it doesn't reach the run summary, the PR body, or the exit code. AC-4 is satisfied by the console warning, so this isn't a gap in the AC — but as shipped it's a dead field. Either surface it in the run summary or drop it.

    Suggestions:

    1. The orchestrator resume wiring has no test coverage (low). The planner is well covered and the rebase contract is proven with real git, but the glue — issueNumbers = plan.active, chainBase = chainResume?.resumeBase ?? baseBranch, the i === 0 rebase block, and the fail-fast early return — is untested. This is the layer where the original fix(chain): --chain successors branch from main, not predecessor's committed work (up-front worktree provisioning) #748 bug lived. AC-5 explicitly blesses the fix(#748): --chain successors branch from predecessor's committed work, not main #752 reconstruction pattern, so this is not an AC failure, but a mocked-stateManager test over the guard would cheaply lock the plan.active/chainBase handoff.

    2. A completed link after an incomplete one is now re-executed (low). Previously the flat guard skipped any ready_for_merge issue regardless of position; the prefix-only rule means a mid-chain completed link gets re-run. The PR documents this as the conservative choice and chain-breaks-on-first-failure makes it rare (it needs manual completion or reordered args). Worth a line in the docs so re-execution of a ready_for_merge link doesn't read as a bug.


    Anti-Pattern Detection

    No any types, no empty catches, no hardcoded secrets, no await-in-loop introduced (the state lookup loop is pre-existing shape). No package.json changes.

    revParseRef uses spawnSync without cwd, resolving refs from the process cwd. Correct here — refs are shared across worktrees, and sequant run executes from the main repo — but it is the one spot that would break if the resolver were ever reused from a worktree-relative context.


    Call-Site Review

    New exported functions: 1

    Function Call Sites Loop? Conditions AC Match
    computeChainResumePlan run-orchestrator.ts:696 No Inside stateManager && !dryRun && !force → if (mergedOptions.chain) ✅ Matches AC-1; --force correctly bypasses resume

    The i === 0 guard on the resume rebase is the correct iteration scope: the completed prefix is already removed from issueNumbers, so index 0 is the resume point, and links at i > 0 are handled by the pre-existing #748 successor-rebase.


    Execution Evidence

    Test Type Command Exit Code Result
    Unit + integration npx vitest run src/lib/workflow/chain-resume.test.ts chain-resume.integration.test.ts checkpoint.integration.test.ts 0 17/17 passed (3 files)
    CI build/typecheck GitHub Actions run 29391793456 0 5/5 checks green

    Evidence status: Complete. No scripts/ changes → /verify not required.


    Skill Command Verification

    N/A — no .claude/skills/**/*.md files changed.

    CLI Registration Verification

    N/A — no RunOptions fields added. chainResume is on OrchestratorConfig (internal, populated by the orchestrator, never user-supplied), so it correctly requires no bin/cli.ts registration.


    Self-Evaluation

    • Verified working: Yes for the planner and the rebase contract — ran the tests, read the real-git assertions, and traced the status-write ordering in source to confirm finding feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 rather than inferring it. No for the end-to-end orchestrator path: no live --chain run was performed (it needs GitHub + dep installs), so the plan.active → ensureWorktreesChain → executeSequential handoff is verified by reading, not by execution.
    • Test efficacy: High for chain-resume.ts (fail-fast, merged, prefix, and fresh-run branches all asserted with real git). Low for the orchestrator glue — a regression in the chainBase handoff would not fail any test.
    • Likely failure mode: A checkpoint failure leaving #N ready_for_merge with uncommitted work, so resume bases the successor on an incomplete tip while the warning claims the opposite (finding feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1). Second most likely: stale local main in the merged-resume path — though that matches how the rest of the system already provisions from baseBranch, so it's not new here.
    • Verdict confidence: High. All five ACs verified literally against source, not against the PR body's claims; CI is green and the branch is current with origin/main.

    Verdict: AC_MET_BUT_NOT_A_PLUS

    All 5 ACs are literally met, CI is fully green, and the core design is right — the implementation correctly identified that the real work was making the existing skip chain-correct rather than adding parallel resume machinery, and the AC-3 merged-vs-local-tip distinction is handled properly.

    Held back from READY_FOR_MERGE by finding #1: the AC-4 warning states that resume is unavailable and that #N will be redone, when the code does neither — status is already ready_for_merge by the time the checkpoint is attempted, so resume skips #N and bases the successor on a tip missing the uncommitted work. AC-4's letter ("no longer silent") is satisfied, but a warning that misdescribes the recovery path undercuts its purpose. Finding #2 (dead checkpointFailed field) is a small loose end in the same area.

    Neither blocks merge — the message can be corrected in this PR, or the status-ordering change tracked as a follow-up if it warrants its own discussion.

    Documentation

    • CHANGELOG entry added under [Unreleased] → Added with issue number
    • N/A — internal chain behavior; no README/docs surface for --chain resume beyond the CHANGELOG

    Next Steps

    1. Fix the AC-4 warning text in batch-executor.ts:1141-1147 to describe what actually happens on re-run (#N skipped, resumed from a tip missing the uncommitted work), or gate the ready_for_merge status write on checkpoint success so the existing message becomes true.
    2. Surface checkpointFailed in the run summary, or remove the field.
    3. Optional: lock the plan.active / chainBase handoff with a mocked-stateManager orchestrator test.
    4. Merge — coordinate order with feat: lightweight content pre-flight for --chain (AC presence, dependency-order sanity) #762 via /merger if both land together (spec flagged low conflict risk, no file overlap).
  8. added a commit that references this issue on Jul 15, 2026
  9. admarble commented on Jul 15, 2026

    @admarble
    ContributorAuthor

    QA Gap Fixes — #760 (PR #765, commit 33bd40e)

    All four findings from the previous QA review are addressed.

    1. AC-4 warning stated the opposite of what happens → fixed (message + guard)

    Was: "chain resume from this link is unavailable. Re-running the chain will redo #N." Both clauses false — updateIssueStatus(…, "ready_for_merge") runs at batch-executor.ts:1121, before the checkpoint attempt, so a re-run skips #N and takes its branch tip as the resume base. And because createCheckpointCommit only returns false when it has in-scope dirty work it couldn't commit, that tip is missing exactly the work the checkpoint would have captured — while the warning told the user a re-run would handle it.

    Now, per the agreed design (truthful message + dirty-tip fail-fast):

    • The message states the real outcome: the work is off-branch, #N stays ready_for_merge, and resume will stop here until it's committed (or --force).
    • computeChainResumePlan no longer trusts the tip: a ready_for_merge resume base whose worktree is dirty now fails fast, symmetric with the existing destroyed-branch fail-fast. No silent wrong-base execution.

    Scoping decisions worth noting, each locked by a test:

    Case Behaviour Why
    Resume base dirty Fail fast Its tip is missing work
    Earlier prefix link dirty Proceed The chain rebases onto the last link's tip alone; #1's tip is never a base
    Merged prefix link dirty Proceed Resumes from the base branch; local worktree state is irrelevant
    No worktree recorded Proceed Nothing to inspect; branch-tip check governs

    Known trade-off: a benignly-dirty worktree (stray edits) now stops a resume until committed or --force. Deliberate — an incomplete resume base is the exact failure this issue exists to prevent, and the message names the file and both ways out.

    2. Dead checkpointFailed field → now consumed

    Restated in the run summary (displaySummary), where the user is actually looking by the time a multi-hour chain ends and the per-issue warning has scrolled away. New run-display.test.ts (3 tests) locks the consumption so it can't silently go dead again.

    3. Untested orchestrator seam → made testable, then tested

    There were no orchestrator tests at all — which is why the layer the original #748 bug lived in went uncovered. Rather than stand up a full orchestrator harness to lock three assignments, I extracted planChainResumeFromState (the state→plan step) into chain-resume.ts and covered it directly, including the previously untested rule that a failed state lookup treats a link as incomplete rather than skipping it. What's left in the orchestrator is three trivial assignments.

    4. Contiguous-prefix-only rule → documented

    CHANGELOG now states that a completed link sitting after an incomplete one is re-executed rather than silently dropped, and why.


    Verification

    Check Result
    npm run build ✅ Clean
    npm run lint ✅ Clean (0 warnings)
    Full suite (npx vitest run) ✅ 185 files, 3777 passed, 1 expected fail, 2 skipped
    Touched-file tests ✅ 30 passed (was 17)
    CI on PR #765 ✅ Green

    Ran the full suite rather than targeted runs because CompletedLinkResolver is an exported interface and gained a method.

    Self-Evaluation

    • Verified working: Yes for the planner changes — the dirty fail-fast is proven against real git (a genuinely uncommitted file in a real worktree, plus the clean-worktree counter-case), not a fake resolver alone. The summary notice is asserted through displaySummary itself. Still not verified end-to-end: no live --chain run (needs GitHub + dep installs).
    • Test efficacy: High. Every new branch has both a positive and a negative case, so an over-broad dirty check (firing on merged/earlier links) fails a test rather than passing silently.
    • Likely failure mode: The false-positive path — a user with stray edits in a completed link's worktree hits a fail-fast they didn't expect. Bounded: the message names the worktree and offers --force.
    • Verdict confidence: High.

    Verdict: READY_FOR_MERGE

    All 5 ACs met, all 4 QA findings closed, CI green, branch current with origin/main.

  10. added
    ready-for-review
    and removed
    needs-improvement
    on Jul 15, 2026
  11. added 5 commits that reference this issue on Jul 15, 2026
  12. added 4 commits that reference this issue on Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    clienhancementplannedready-for-review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions