Repository navigation
Description
Summary
sequant run <a> <b> --chain does not make successor issues branch from their predecessor's committed work on a fresh run. Each successor branches from main, contradicting the flag's help text ("Chain issues: each branches from previous") and the code's own intent comment.
Repro
sequant run 125 126 --chain --qa-gate -Q --testgen
Banner printed Chain: main → #125 → #126, but git ancestry afterward:
merge-base(#125, #126) = b5a61c4 # == run startCommit (main)
#125's exec commit c520341 is NOT an ancestor of #126
So #126 was built on plain main, missing all of #125's work.
Root cause
ensureWorktreesChain (src/lib/workflow/worktree-manager.ts:905-942) is called once at src/lib/workflow/run-orchestrator.ts:769 — before any issue executes. It loops over all issues up front, branching each successor from the predecessor's branch name. At provisioning time the predecessor branch still points at main (it hasn't committed yet), so every successor effectively branches from main.
There is no re-rebase of a successor onto its predecessor's completed tip on a fresh run:
- The chain-rebase inside
ensureWorktree(worktree-manager.ts:580-651) only fires when a branch already exists (re-run path only). rebaseBeforePR(src/lib/workflow/batch-executor.ts:1142-1155) rebases the last chain issue ontoorigin/main, not onto its predecessor; intermediate issues skip it.- The AC-1/AC-2 comment at
batch-executor.ts:1139-1141says intermediate branches "must stay based on their predecessor" — but the code never achieves this on a fresh run.
--stacked does not fix this: it only sets the GitHub PR base (predecessorBranch/stackManifest → createPR, run-orchestrator.ts:973-986). There is no execution-time rebase, so --stacked would produce a PR targeting the predecessor whose branch still doesn't contain the predecessor's commits.
Why tests didn't catch it
__tests__/run-orchestrator.test.tsmocksensureWorktreesChainentirely — real ancestry is never exercised.src/commands/run.test.ts:836-855("chain branch naming") is tautological:expect(baseBranch).toBe(issues[i-1].branch).src/commands/run.test.ts:857-893only tests the re-run rebase guard — the one path where rebase actually fires.
No test does real git on a fresh run asserting git merge-base --is-ancestor <predecessor-tip> <successor>.
Fix options
- Lazy per-issue worktree creation — provision each successor's worktree just-in-time inside the sequential loop, after the predecessor completes/commits. Most correct; honors the contract directly. Larger refactor (worktree creation, cleanup registration, and chain-break detection move out of setup into the execution loop; loses the up-front "all worktrees ready" UX).
- Re-rebase successor onto predecessor tip immediately before it executes — keep up-front provisioning, but
git rebase <predecessorBranch>at the top ofexecuteOneIssuefor chain issues. Smaller; reuses existing conflict/abort machinery. Must target the local predecessor branch, not origin/main. - Fix help text only (
bin/cli.ts:292) — documentation retreat; leaves users with no working code-stacking path.
Recommend option 1 or 2 (option 2 is lower-risk).
Acceptance criteria
- On a fresh
--chainrun, a successor's branch contains its predecessor's committed work (or the help text + docs are corrected to describe actual behavior, if WONTFIX-by-design). - A real-git integration test asserts
git merge-base --is-ancestor <predecessor-exec-commit> <successor-HEAD>on a fresh chain run. -
bin/cli.ts:292help text accurately reflects final behavior.
Related
Cross-references #289, #126, #133, #604, #605. #289 and #126 (closed) addressed only the pre-existing-worktree rebase path; #133 added --qa-gate for staleness. None covers the up-front-provisioning timing on a fresh run.
Activity
admarble commentedon Jun 28, 2026
→ PROCEED —
--chainsuccessors branch frommainnot predecessor; root cause + fix options identified, clear ACs.Workflow:
exec → qa(skip spec — bug label, root cause pinned toensureWorktreesChaintiming; issue already recommends option 2 / re-rebase). Quality loop on (real-git integration test required).⚠ Overlaps #749 on
batch-executor.ts+run-orchestrator.ts— run sequentially, not parallel.admarble commentedon Jun 28, 2026
/spec Plan — #748
Approach: Option 2 (re-rebase each chain successor onto its predecessor's local committed tip, just before the successor executes). Lower-risk than lazy provisioning; reuses existing conflict/abort machinery.
Plan
executeOneIssue(run-orchestrator.ts:1059): for chain issues withi>0, resolve the local predecessor branch fromworktreeMap(independent of--stacked) and rebase the successor's worktree onto it before its phases run.feature/<predecessor>ref (NOTorigin/main). Extract arebaseOntoLocalBranchhelper from the existing chain-rebase block (worktree-manager.ts:580-651); do not reuserebaseBeforePR(origin-targeted, PR-time).--chainhelp text (bin/cli.ts:292) to match (AC-3).Verification
--chainrun — successor branch contains predecessor's committed work (Integration / real git)git merge-base --is-ancestor <predecessor-exec-commit> <successor-HEAD>, with no mock ofensureWorktreesChainor the rebase step (Integration)bin/cli.ts:292help text accurate (Unit / grep)Open questions
batch-executor.ts/run-orchestrator.ts— sequence the merges, don't run in parallel.Workflow: exec → qa, quality loop on.
admarble commentedon Jun 28, 2026
/exec Progress Update — #748
Approach: Option 2 (re-rebase each chain successor onto its predecessor's local committed tip just before it runs). Implemented per /spec plan.
AC Coverage
--chainrun: successor contains predecessor's committed workexecuteSequentialrebase step inrun-orchestrator.ts; integration testgit merge-base --is-ancestor <pred-exec-commit> <succ-HEAD>on a fresh run, no mock ofensureWorktreesChain/rebasesrc/lib/workflow/chain-rebase.integration.test.tsbin/cli.ts:292--chainhelp text accurateKey files changed
src/lib/workflow/worktree-manager.ts— new exportedrebaseOntoLocalBranchhelper (+LocalRebaseResulttype); existing chain-rebase block (re-run path) refactored to reuse it (de-dup).src/lib/workflow/run-orchestrator.ts—executeSequentialrebases each chain successor (i>0) onto predecessor's local branch before execution; conflict → abort + warn (don't silently green a broken link).bin/cli.ts—--chainhelp text (AC-3).src/lib/workflow/chain-rebase.integration.test.ts(new) — 3 real-git tests: re-chain success, successor's own commits carried forward, conflict abort+restore. Reproduces the pre-fix BUG state (is-ancestorfalse) before asserting the fix.__tests__/run-orchestrator.test.ts— wiring tests (rebases each successor onto predecessor's local branch; no rebase when chain off) + mock export.Open questions resolved
predecessorBranch/stackManifest) is computed at PR-creation time, and the rebase runs at the top of the loop iteration before phases. Safe.Checks
npm run build✅ ·npm run lint✅chain-rebase.integration.test.ts✅ 3/3 ·run-orchestrator.test.ts✅ 22/22phase-registry.integration.test.tstsx-spawn timeout flake (passes in isolation).PR
✅ Created: #752
batch-executor.ts/run-orchestrator.ts— merge sequentially, not in parallel.docs(chain): restore rebaseBeforePR JSDoc adjacency after #748 insert
admarble commentedon Jun 28, 2026
/qa Review for Issue #748
Verdict: READY_FOR_MERGE ✅
Focused, well-scoped bug fix for the
--chainup-front-provisioning timing bug. All 3 ACs MET, CI green (5/5), quality checks clean. One documentation defect found during adversarial re-read and fixed in-PR (commit29bf48c).AC Coverage
--chainrun: successor branch contains predecessor's committed workexecuteSequentialrebases each successor (i>0) onto predecessor's local branch before it runs (run-orchestrator.ts:976-998); proven by integration testgit merge-base --is-ancestor <pred-exec-commit> <succ-HEAD>on a fresh run, no mock of rebase stepchain-rebase.integration.test.ts:43,98,107— real git, assertsfalsepre-rebase (bug repro) +truepost-rebase; zero mocksbin/cli.ts--chainhelp text accuratebin/cli.ts:291)Coverage: 3/3 ACs fully met.
Quality Plan Verification
N/A — spec had no Feature Quality Planning section (bug fix, root cause pinned; no derived ACs).
CI Status (PR #752, commit
29bf48c)CI Summary: 5 passed, 0 pending, 0 failed.
Quality Metrics
any/as any/@ts-ignore)Test Coverage Analysis
src/lib/workflow/worktree-manager.tschain-rebase.integration.test.ts(real-gitrebaseOntoLocalBranch) +checkpoint.integration.test.tssrc/lib/workflow/run-orchestrator.tsrun-orchestrator.test.ts(#748 wiring: rebases each successor onto predecessor's local branch; not rebased when chain off)bin/cli.tsCoverage: All changed source files covered. No critical-path (auth/payment/etc.) changes.
Code Review
Strengths:
i, after predecessori-1has executed + committed (the loopbreaks on predecessor failure, so a reached successor always has a committed predecessor). This is exactly what makes the chain contract hold.feature/<predecessor>branch (notorigin/main) and is independent of--stacked— precisely the issue's Option 2.rebaseOntoLocalBranchis reused by the pre-existing re-run rebase path inensureWorktree, removing duplicated conflict/abort logic.spawnSyncarray form (noshell:true) — no injection surface for the branch-name arg.Issues (fixed in-PR):
rebaseBeforePR's JSDoc and its declaration, orphaning the doc block (rebaseBeforePRlost its tooltip/@returns/@internaldoc). Fixed in29bf48cby relocatingrebaseOntoLocalBranchaboverebaseBeforePR's JSDoc — no behavior change.Suggestions (non-blocking, no action required):
LocalRebaseResult.performedis alwaystrueand unused by callers (mirrorsRebaseResultshape) — harmless.ensureWorktreesChain, once inexecuteSequential) — idempotent no-op, acceptable.Call-Site Review
New exported function:
rebaseOntoLocalBranch— 2 non-test call sites:worktree-manager.ts:603(re-run path)if chainMode && baseBranchrun-orchestrator.ts:982(chain successor)if options.chain && i > 0i>0Unlike the #295 precedent (where
rebaseBeforePRshould fire only for the last chain link), AC-1 here genuinely wants every successor rebased — so the unconditional-in-loop call (moduloi>0) is correct, not a missing guard. Function is used (not dead).Execution Evidence
bin/cli.ts (CLI) changed, but the change is a static help-text string (Risk: None). Runtime
run --helpcould not render in this worktree (Node 20.17 < 22.12 engine floor #734 exits early) — Waived; verified via source grep + green CI typecheck/build.scripts/not touched, so/verifynot required.Risk Assessment
git rebasefail (not a conflict) → caught assuccess:false, conflict:false→ loud "Chain link broken" warning, successor proceeds on its existing base. Loud, not silent — acceptable.ensureWorktreesChainalready guards dirty re-run worktrees upstream.rebaseBeforePR(origin/main, PR-time) andensureWorktreesChain(up-front provisioning, the root cause now compensated) are distinct concerns, not siblings with the same root cause.--stackedpredecessorBranchblock computes a PR base, not an execution-time rebase — different purpose, no shared root cause. Single logical fix site.Adversarial Re-Read
Findings: Walked the 5 checks. (1) The integration test operationalizes the issue body's verbatim repro (
merge-base(#125,#126)ancestry) — predecessor commits, successor rebased, ancestry asserted. (2) The "evidence" is honest: it asserts the pre-fix BUG state (is-ancestor == false) and the post-fix validation (== true), not a repro masquerading as validation. (3) Process state inspected — the uncommittedpackage-lock.jsonis pre-existing npmlibc-field drift, unrelated and correctly left out of the PR; branch is 4 behind main (below threshold 5, MERGEABLE). (4) Sibling sites cited above. (5) No Non-Goals expanded — fix stayed on Option 2, did not drift into Option 1 (lazy provisioning). The single doc-orphan gap surfaced was fixed in-PR.Status: Clean
CHANGELOG Verification
fix:)[Unreleased]entry for #748Documentation
[Unreleased]entry added--chainhelp text updatedNext Steps
run-orchestrator.ts/batch-executor.ts) — merge one, rebase the other.admarble commentedon Jun 28, 2026
QA Review for Issue #748 (PR #752)
Verdict: READY_FOR_MERGE ✅
--chainOption 2 fix:executeSequentialnow re-rebases each chain successor's worktree onto its predecessor's local committed tip just before the successor runs, via an extractedrebaseOntoLocalBranchhelper (reused by the re-run path). All 3 ACs met.AC Coverage
--chainrun: successor branch contains predecessor's committed workrun-orchestrator.ts:972-998rebases successor onto local predecessor branch at top of sequential loop iterationi(after predecessori-1has executed/committed). Verified by integration + wiring tests.merge-base --is-ancestor <pred-exec-commit> <succ-HEAD>on a fresh run, no mock of rebase stepchain-rebase.integration.test.ts— real git, asserts pre-fix BUG state (isAncestor === false) → fix →isAncestor === true; plus conflict-abort and carry-forward cases.bin/cli.ts--chainhelp text accurateCoverage: 3/3 ACs fully met.
Quality Metrics
any)CI Status
All 5 checks pass:
build (22.x),node-floor-guard,typecheck,validate-plugin,validate-skills. Mergeable: MERGEABLE.Tests
Targeted run green locally:
chain-rebase.integration.test.ts+run-orchestrator.test.ts→ 25/25 pass.Code Review
Strengths:
rebaseOntoLocalBranch) consolidates conflict/abort logic; the pre-existing re-run path now reuses it (DRY, removes duplicated CONFLICT-detection block).i, so predecessori-1has already committed. Targets the local predecessor branch, notorigin/main— exactly the issue's root cause.--stacked(the PR-targeting half stays separate, as designed).Notes (non-blocking):
ensureWorktreesChainend-to-end (justified: that path installs deps + mutates process cwd). TheensureWorktreesChain → executeSequentialseam is covered via the wiring test'sworktreeMapbranch values rather than a true E2E run — acceptable, minor residual gap.Risk Assessment
ensureWorktreesChain; predecessor-with-zero-commits case not explicitly tested.ensureWorktree.--stackedblock (worktreeMap.get(i-1).branch) is the complementary PR-base half, not a sibling of this root cause — correct as-is.Adversarial Re-Read
Findings: Verified the rebase fires after predecessor commit (sequential loop +⚠️ Process-state note: the worktree has an uncommitted
break-on-failure means predecessor succeeded when successor is reached); confirmed local-branch target (not origin); confirmed conflict-abort restores HEAD + clean tree (integration test asserts both); help text and CHANGELOG match actual behavior; JSDoc adjacency forrebaseBeforePRcorrectly restored by the follow-up commit.package-lock.jsondeletion (−42 lines) not part of this PR'sorigin/main...HEADdiff — ensure it is not accidentally committed into this branch before merge.Status: Clean
Documentation
[Unreleased] → Fixedentry present and accurate (fix(chain): --chain successors branch from main, not predecessor's committed work (up-front worktree provisioning) #748).--chainhelp text updated.Next Steps
run-orchestrator.ts/worktree-manager.ts) — merge sequentially, not in parallel.package-lock.jsondeletion in the worktree before merge.origin/main(under threshold) — optional rebase before merge.fix(chain): break the chain on rebase conflict instead of building su…
fix(chain): break the chain on missing worktree-map entry too, and do…
fix(#748): --chain successors branch from predecessor's committed wor…
fix(#760): close QA gaps — honest checkpoint warning + dirty-tip fail…
feat(#760): resume a partially-completed chain from its last good link (
chore(assess): drop dead --qa-gate from chain suggestions; date the 1…
docs(#761): document failureCategory in analytics.md and the rate-lim…
fix(#761): classify rate limits mid-phase — skip doomed retries, labe…
chore(assess): sync chain flag references and add chain-resume rule (#…
fix: close three pre-2.10.0 gaps found by release verification (#851)
fix(chain): rebase successors onto predecessor's committed tip before…
docs(chain): restore rebaseBeforePR JSDoc adjacency after #748 insert
fix(chain): break the chain on rebase conflict instead of building su…
fix(chain): break the chain on missing worktree-map entry too, and do…
feat(#760): resume a partially-completed chain from its last good link
fix(#760): close QA gaps — honest checkpoint warning + dirty-tip fail…