Repository navigation
Description
Problem
--chain already builds a stack of branches: each issue's worktree branches from the previous issue's branch, and only the final branch rebases onto main (src/lib/workflow/batch-executor.ts:1000-1017).
But every PR --chain creates still targets main. Reviewers see each PR's diff layered on top of whatever main looks like, not the incremental change vs. its predecessor. For a 3-issue chain that touches the same area, this means:
- PR docs: Add pre-release checklist #2 shows diff = (issue 1's changes) + (issue 2's changes) — reviewer can't isolate issue 2.
- The first reviewable diff is effectively the whole feature.
This is the missing 20% of stacked-PR review surface that --chain already enables structurally.
Approach
Add --stacked (implies --chain). Only behavior change: PR creation uses the predecessor branch as base instead of main, except for the final issue (which still targets main).
sequant run 100 101 102 --stacked
→ PR for #100 → base: main
→ PR for #101 → base: feature/100-...
→ PR for #102 → base: feature/101-... (final stays main? — see open question)
GitHub auto-updates a PR's base when the previous base merges, so landing in order works without manual intervention.
Acceptance Criteria
- AC-1: Add
--stackedflag inbin/cli.tsthat implies--chain(error if both--stackedand--no-chainare given). - AC-2: When
--stackedis set,createPR(inbatch-executor.ts) uses the predecessor branch as the PR base for non-first issues. - AC-3: First issue in the stack still targets
main. - AC-4: PR body includes a stack manifest (
Part of stack: #N1 → #N2 → #N3 (this)) so reviewers see the chain. - AC-5: Documented in the chain-mode docs (
docs/features/run-orchestrator.mdor wherever--chainis described). - AC-6:
mergerskill is aware that--stackedPRs must merge in order; document or warn if invoked out of order.
Open Questions
- Final-PR base: should the last PR target
main(current proposal) or its predecessor (more "pure" stack, but means landing the whole stack atomically)? Default tomain— easier to land partial progress. - Force-push interaction: intermediate branches in
--chainalready stay based on predecessor (no rebase cascade today), so the existing force-push hook policy (feedback_merge_not_rebase.md) is preserved. Confirm this still holds when an intermediate PR has review feedback that requires fixup.
Non-Goals
- Native
gh-stackintegration. GitHub shipped private preview April 2026; if/when GA lands with first-party stack support we can revisit. This issue is the cheap interim that requires only a flag and a base argument. - Cascade rebase / amend tooling à la Graphite. Out of scope and incompatible with the force-push hook.
- Auto-detect stacking from chain mode. Opt-in only — keeps existing
--chainbehavior unchanged.
Risks
- Could be obsoleted by
gh-stackGA. Mitigation: implementation is small (~base-arg change + manifest text) and the UX (--stacked) is cheap to keep as a wrapper later. mergerskill currently assumes squash-merge intomain. Squash-merging an intermediate PR creates a new commit onmain; GitHub then re-bases the dependent PR's diff against the new tip. Verify this works in dry-run before relying on it.
References
src/lib/workflow/batch-executor.ts:1000-1017— final-issue rebase logicsrc/lib/workflow/worktree-manager.ts:579-640— chain-mode rebase of existing worktrees- feat: Add --chain flag for dependent sequential issues #88, feat(#88): add --chain flag for dependent sequential issues #110 — original
--chaindesign - investigate(metrics): chain mode 29% success rate vs 92% single-issue — failure forensics #604 — chain-mode success-rate forensics (file this only after investigate(metrics): chain mode 29% success rate vs 92% single-issue — failure forensics #604 says
--chainis worth investing in)
Activity
admarble commentedon May 9, 2026
→ PARK — Body's References section explicitly conditions filing/work on #604 outcome: "file this only after #604 says
--chainis worth investing in." If chain-mode is structurally low-success, building stacked PRs on top of it would compound the risk.Resume after: #604 reports its keep/deprecate/restrict recommendation (its AC-5/AC-6).
admarble commentedon May 10, 2026
Supersedes prior assess from 2026-05-09 (PARK)
→ PARK — Body's References section explicitly conditions filing/work on #604 outcome: "file this only after #604 says
--chainis worth investing in." If chain-mode is structurally low-success, building stacked PRs on top of it would compound the risk.Resume after: #604 reports its keep/deprecate/restrict recommendation (its AC-5/AC-6).
admarble commentedon May 11, 2026
Supersedes 2 prior assessments (most recent: 2026-05-10)
→ PARK — #604 has now merged (df6277c) documenting a 29% chain-mode success rate. The PARK condition was "file this only after #604 says `--chain` is worth investing in" — the forensics document failures rather than endorse investment. #625 was filed to fix one of #604's failure modes (concurrent-session lock); stacked-PRs on top of chain-mode would compound risk until at least #625 lands.
Resume after: chain-mode success rate improves to a workable level (post-#625), or a clear keep/deprecate verdict is recorded on #604.
admarble commentedon May 11, 2026
/exec progress update
Implementation: COMPLETE → PR #630
Status note: This issue was PARKED 3× by
/assesspending chain-mode reliability improvement (#604 reported 29% whole-chain success). The user explicitly invoked/exec 605, so this implements the feature as specified.--stackedis opt-in and inherits chain-mode's reliability profile; docs explicitly flag the caveat with a link tochain-mode-analysis-2026-05.md.Pre-PR AC Verification
--stackedflag inbin/cli.ts, implies--chain, errors on--no-chainbin/cli.ts(.option("--stacked", …)) +src/commands/run.tsvalidationcreatePRuses predecessor branch for non-first issuesbatch-executor.ts:991passesstackOptions.prBase→worktree-manager.ts→createPRCliSync(... base)mainexecuteSequentialonly setspredecessorBranchwheni > 0 && i < lastIndexPart of stack: …manifestbuildStackManifest+ body construction increatePRdocs/reference/run-command.md— new "Stacked PRs" sectionmergerskill aware of stack merge order.claude/skills/merger/SKILL.md— new "Stacked PR Detection" subsection with warning templateOpen-question resolution: Final-PR base =
main(spec's preferred option — easier to land partial progress).Quality Plan Alignment
N/A — no
/specquality plan in issue comments.Test/Build/Lint Results
npm run buildnpm run lintnpx vitest run __tests__/npx vitest run src/lib/workflow/npx vitest run src/commands/run.test.tsbin/cli.ts run --help--stackedflag visibleNew tests added:
__tests__/run-orchestrator-resolve.test.ts— 5buildStackManifestcases (first / middle / last / single-issue / two-issue)__tests__/run-orchestrator.test.ts— 2 chain-context plumbing cases (--stackedsets predecessor + manifest only for middle issues; plain--chainleaves them undefined)src/commands/run.test.ts— 4createPRstacked-mode cases (--basepassed, omitted on final, manifest embedded, manifest absent without options)CLI Wiring Self-Check
stacked--stackedPre-PR Confidence Check
gh pr createarg list, but the actualghcall hitting the GitHub API is mocked.batch-executor.ts:972(!chainMode || isLastInChain) is reused unchanged for stacked mode, so it inherits its existing test coverage.PR Status
feature/605-feat-cli-stacked-flag-set-chain-mode-pr-base-to-prNext Steps
/qa 605to review the implementation./exec; recommend during merger phase).admarble commentedon May 12, 2026
QA Review for Issue #605
AC Coverage
--stackedflag inbin/cli.ts, implies--chain, errors on--no-chaincombobin/cli.ts:220-227; validation atsrc/commands/run.ts:52-58rejects--stacked --no-chainand forceschain=truebefore downstream constraint checks. Verifiednpx sequant run --helpshows the flag.createPRuses predecessor branch as base for non-first issuesmain" (spec's preferred option for partial landings). Implementation matches the resolved spec intent.run-orchestrator.ts:814-832+batch-executor.ts:994-1009+worktree-manager.ts:1402-1409+platforms/github.ts:227-251.mainrun-orchestrator.ts:820-822—predecessorBranchonly set wheni > 0 && i < lastIndex. First issue's--baseis omitted;gh pr createdefaults to repo default branch (main).Part of stack: #N1 → #N2 (this)manifestbuildStackManifest()atrun-orchestrator.ts:64-72. Manifest emitted before the trailer (worktree-manager.ts:1394-1399). Renders for every PR in the stack (first, middle, last). 5 unit cases cover edge shapes (first/middle/last/single/two).docs/reference/run-command.md:54(flag table) and new "Stacked PRs" section at line 242-291 with example, requirements, performance caveat (~29% chain success), and merge-order callout.mergerskill aware of--stackedmerge order.claude/skills/merger/SKILL.md:479-510— new "Stacked PR Detection" subsection with detection command, ordering enforcement, and warning template. Note: Merger skill is missing fromtemplates/skills/andskills/mirrors (pre-existing — verified absent on origin/main), so it does not deploy viasequant init. Not a regression from this PR, but worth a follow-up.Coverage: 6/6 ACs met (AC-2 with note about open-question resolution)
Precheck Findings
buildStackManifest); no sibling sites insrc/,scripts/,bin/.Source:
.sequant/gap-precheck.json(schemaVersion 1)CI Status
build (20.x)build (22.x)validate-skillstypecheckvalidate-pluginCI Summary: 3 passed, 2 pending, 0 failed.
Diff is not markdown-only (8 .ts/.tsx files changed) — build-matrix relaxation does NOT apply. Build checks remain gating until they complete.
Quality Metrics
any)Test Coverage Analysis
bin/cli.tsrun --helpsmoke check executed)src/commands/run.ts--stacked --no-chainreject branchsrc/lib/workflow/types.tssrc/lib/workflow/batch-executor.tsrun.test.tsstacked-mode createPR tests (4 cases)src/lib/workflow/platforms/github.tsspawnSyncsrc/lib/workflow/worktree-manager.tssrc/commands/run.test.ts:2192-2316(4 new cases)src/lib/workflow/run-orchestrator.ts__tests__/run-orchestrator.test.ts:309-422(2 chain-context cases) +__tests__/run-orchestrator-resolve.test.ts(5 manifest cases).claude/skills/merger/SKILL.mddocs/reference/run-command.mdCHANGELOG.mdCoverage: 11 new test cases (5 manifest + 2 orchestrator plumbing + 4 createPR). Targeted vitest run: 181/181 passed.
Gap: No unit test for
runCommand's--stacked --no-chainrejection branch (src/commands/run.ts:52-55). The branch is 3 lines and mirrors the existingqa-gate requires --chainvalidation pattern, so the gap is low-risk.Code Review
Strengths:
RunOptions.stacked→IssueExecutionContext.chain.{predecessorBranch, stackManifest}→createPR(... stackOptions)→createPRCliSync(... base?). Each layer documents its(#605)provenance.--baseis conditionally appended to thegh pr createargs array (platforms/github.ts:240-242) rather than passed asundefined/empty — correct ergonomics forgh.worktree-manager.ts:1393-1402), so it's visible at the top of the body instead of being buried after the bot signature.--chainsemantics (run.ts:50-58), correctly handling--stacked --batch(rejects via the existingchain + batchcheck afterchain=trueis set) and--stacked --qa-gate(passes sincechain=true).batch-executor.ts:972-976(!chainMode || isLastInChain) is unchanged — intermediate branches still don't rebase ontomain, preserving stack structure for middle PRs.buildStackManifestis@internalexported, well-tested with degenerate cases (single-issue, two-issue).any/as anyintroductions).Issues:
run 100 101 --stacked: feat(#99): Add adversarial self-questioning to workflow phases #100 is first (base=main), test(#86): Add CLI integration test for version output #101 is both non-first AND last → falls into theelse if (i > 0)branch with intentionally-undefined predecessor → both PRs base onmain. Only the manifest changes. The docs table atrun-command.md:255-259only shows a 3-issue example, so users running a 2-issue stack may be surprised. Worth a one-line caveat in the docs.GitHubProvider.createPR(opts)(line 611-612) silently dropsopts.base— pre-existing latent gap; the async method callsthis.createPRCliSync(opts.title, opts.body, opts.head)without forwardingopts.baseeven thoughCreatePROptions.baseis a required field. The newbase?parameter oncreatePRCliSyncmakes plumbing this trivially possible. No current call sites use the async path, but the interface contract is violated. Sibling-site finding (not introduced by feat(cli): --stacked flag — set chain-mode PR base to predecessor branch #605, but adjacent).Suggestions:
opts.basethroughGitHubProvider.createPR(opts)async method to honor theCreatePROptionscontract (separate follow-up).Test Quality Review
gh pr createarg list (observable contract), not on internal state.prBasepaths (set / undefined). Manifest position relative to trailer asserted.spawnSyncmocked (external boundary).mockHappyPathToCreatehelper reuses the existing 3-call mock pattern in the file.Issues Found: None.
Anti-Pattern Detection
Dependency Audit
N/A —
package.jsonunchanged.Code Patterns
No anti-patterns introduced. No
eval, noinnerHTML, no SQL concatenation, no hardcoded secrets, noawait-in-loop hot paths, no uncleared timers.Call-Site Review
New exported functions detected: 1 (
buildStackManifest)buildStackManifestrun-orchestrator.ts:832forloop over issues)if (options.chain && options.stacked)--stacked, once per issue in the loop.Findings: None. Call site correctly gates manifest rendering behind
--stackedand indexes by loop position.Execution Evidence
npx sequant run --help--stackedflag visible with correct help textnpx tsc --noEmitnpx vitest run __tests__/run-orchestrator-resolve.test.ts __tests__/run-orchestrator.test.ts src/commands/run.test.tsEvidence status: Complete (CLI/script changes verified via help + typecheck + targeted tests).
Live end-to-end run with a real 2-issue chain hitting the GitHub API was not performed (call to
gh pr createis mocked at thespawnSyncboundary in the unit tests, and the user-flagged this as a known coverage gap in the /exec progress comment). Recommend during merger phase.Skill Command Verification
.claude/skills/merger/SKILL.mdmodified — extracted commands:gh pr view <PR_NUMBER> --json baseRefName,bodybaseRefNameandbodyare validgh pr viewJSON fields (verified viagh pr view --help).Verification Status: Passed.
Detection Pattern Verification
N/A — the
.claude/skills/merger/SKILL.mddiff adds agh pr view ... | jqsnippet for skill operator instructions, not a runtime detection pattern with a corpus to validate. The §6c hard precondition (grep -E '^\+[^+]' ... grep -qE '\b(grep|awk|jq|sed)\b|/[^/]+/[gim]?') does trigger on thejqliteral, but the surrounding prose describes operator-facing detection (a human runs the command on a specific PR), not an automated pipeline pattern that needs ≥5-sample corpus validation. Treating as documentation-style usage; no detection-corpus check applicable.CLI Registration Verification
stackedoptions.stacked(run.ts:52, 56)--stackedinbin/cli.ts:221-224Verification Status: Passed.
Skill Change Review
gh pr view --json baseRefName,body— both fields exist.gh pr view --help.baseRefName != "main" AND body contains "Part of stack:"— matches the manifest format frombuildStackManifest.gh+jq—ghis implicit (already used elsewhere in the skill),jqis not explicitly called out. Minor.CHANGELOG Verification
--stackedflag)(#605), starts under### Added, action-verb format)Result: CHANGELOG requirements met.
Manual Test ACs
N/A — no AC in the issue body specifies Manual Test verification. The /exec progress comment notes "Live end-to-end run with a real 2-issue chain wasn't performed" as a known gap, but this is a quality concern, not a manual-test AC.
Risk Assessment
run 100 101 --stackedproduces two PRs both targetingmain(because test(#86): Add CLI integration test for version output #101 is the "last" and falls into the open-question default), so users may not see the benefit they expect. Documented behavior, but the docs table only illustrates a 3-issue example.gh pr createis mocked at thespawnSyncboundary; the actual argv passed toghis asserted but no real PR is created. The--baseflag landing onghcorrectly is implicit ongh's own contract.GitHubProvider.createPR(opts)async method atplatforms/github.ts:611-612silently dropsopts.base— pre-existing latent gap, not introduced by feat(cli): --stacked flag — set chain-mode PR base to predecessor branch #605, no current call sites use this path. Worth a follow-up.createPRinworktree-manager.tsis the only PR-creation path used in production. Existing rebase logic (!chainMode || isLastInChain) is correctly preserved.Adversarial Re-Read
Findings:
docs/reference/run-command.md"Stacked PRs" section so users running a 2-issue stack know to expect manifest-only behavior, not predecessor-targeting.rebaseBeforePRon the last branch ontomain) means the last PR under--stackedshows cumulative changes of the whole chain, not its own incremental diff. This is by design per the open question resolution (last PR targets main → must show what would land on main), and matches the existing--chainbehavior. Worth noting in the docs as part of "Stacked PRs" so reviewers expect cumulative diff on the final PR./assesspending chain-mode reliability work; user explicitly opted into/exec. The docs caveat (~29% chain success rate, link to forensics) correctly surfaces this risk to users.platforms/github.ts:612is pre-existing dead code; the newbase?param now exists to plumb through if a future call site emerges.Status: Gaps Found (non-blocking documentation gaps and one pre-existing latent sibling-site issue — fold into a follow-up or address in the same PR via a 2-line docs addition).
Verdict: NEEDS_VERIFICATION
Primary reason: Build matrix CI checks (
build (20.x),build (22.x)) are stillIN_PROGRESS. The diff is not markdown-only (13 files changed including 8.tsfiles), so the build-matrix relaxation does not apply — these checks remain gating per the QA skill's CI gate.typecheck,validate-skills, andvalidate-pluginhave all passed locally and in CI.Secondary signals (would otherwise yield AC_MET_BUT_NOT_A_PLUS):
GitHubProvider.createPR(opts)async method — file as a follow-up; no caller exercises the path today.Re-run after CI completes: Once the build matrix passes, the verdict should revert to
AC_MET_BUT_NOT_A_PLUS(pending the two-issue-stack doc caveat) orREADY_FOR_MERGE(if the caveat is folded in).Documentation
docs/reference/run-command.mdupdated — new "Stacked PRs" section[Unreleased]line 12, includes(#605).claude/skills/merger/SKILL.mdupdated — "Stacked PR Detection" subsectionNext Steps
build (20.x),build (22.x)) to complete; re-run/qa 605or checkgh pr checks 630after they land.opts.basethroughGitHubProvider.createPR(opts)async method (platforms/github.ts:612) to honor theCreatePROptionscontract. Not introduced by feat(cli): --stacked flag — set chain-mode PR base to predecessor branch #605; pre-existing..claude/skills/merger/SKILL.mdintotemplates/skills/merger/andskills/merger/so the new "Stacked PR Detection" content deploys viasequant init(pre-existing missing-mirror gap; not introduced by this PR).admarble commentedon May 12, 2026
QA Review for Issue #605 — CI Re-check
Same commit (
938b991d) as prior QA; only the external CI gate has changed. Re-running the verdict synthesis with the new CI state — non-CI analysis stands.CI Status (updated)
build (20.x)build (22.x)validate-skillstypecheckvalidate-pluginCI Summary: 5 passed, 0 pending, 0 failed. Build matrix gate cleared.
Verdict synthesis (re-run)
GitHubProvider.createPR(opts)sibling-site)Per §7 algorithm:
not_met_count=0,partial_count=0,pending_count=0, allFailed/Survivorsgates clean,adversarial_reread_status=Gaps Found→ demotes from READY_FOR_MERGE to:Verdict: AC_MET_BUT_NOT_A_PLUS
All ACs met and CI green. Non-blocking gaps documented in the prior QA's Adversarial Re-Read remain. Two ways to land:
docs/reference/run-command.mdcovering: (a) 2-issue stacks produce manifest-only behavior (both PRs targetmain), and (b) the final PR shows cumulative diff because rebase-onto-main is preserved. That upgrades to READY_FOR_MERGE.Next Steps
opts.basethroughGitHubProvider.createPR(opts)async atsrc/lib/workflow/platforms/github.ts:612— pre-existing latent gap, no current caller..claude/skills/merger/intotemplates/skills/andskills/so the new "Stacked PR Detection" content deploys viasequant init.feat(#605): address QA gaps — help text, async createPR base, docs ca…
admarble commentedon May 13, 2026
QA Review for Issue #605 — Gap Fixes Folded In
New HEAD
5973f03(was938b991don prior QA). One follow-up commit lands every gap surfaced in the prior QA's Adversarial Re-Read.Changes in this commit
--helptextbin/cli.ts: "middle PRs target predecessor; first/last target main"docs/reference/run-command.md: new Caveats subsectionGitHubProvider.createPR(opts)async droppedopts.basesrc/lib/workflow/platforms/github.ts: forwardopts.base(+1 unit test)worktreeMap.get()invariant undocumentedsrc/lib/workflow/run-orchestrator.ts: invariant commentmerger/skill not mirroredtemplates/skills/merger/SKILL.md,skills/merger/SKILL.mdCI Status
build (20.x)build (22.x)typecheckvalidate-skillsvalidate-pluginPlugin Structure ValidationHooks ValidationSetup Directory Creation8/8 pass. First build run hit a non-deterministic failure in
locks-cli.integration.test.ts:201(the lock-takeover test added in #626,result.status === nullfromspawnSync— classic process-group race); the re-run passed both build matrix jobs. Unrelated to this PR's diff. Recommend filing a follow-up to deflake that test before it bites another PR.Verdict synthesis (re-run)
5973f03--stackedflag verification (smoke)npx sequant run --helpshows updated textnpm run lintclean,npm run buildclean, 207/207 targeted tests passNo remaining blockers. No
Failed/Survivors/Severe Gapstates.Verdict: READY_FOR_MERGE
All ACs met, CI green, all prior non-blocking gaps closed, sibling-site issue (
createPR(opts)async) plumbed.Next Steps
locks-cli.integration.test.ts:201is flaky (result.statusreturnsnullunder CI process-group pressure). Unrelated to feat(cli): --stacked flag — set chain-mode PR base to predecessor branch #605.feat(#605): --stacked flag — chain-mode PR base to predecessor branch (…
admarble commentedon May 13, 2026
Documentation Generated
File:
docs/features/stacked-prs.mdSections Included:
--chain, conflicts with--no-chain)--chain)--stacked,--chain,--no-chain)docs/reference/run-command.md§ Stacked PRs (existing AC-5 deep reference)Next Steps:
Ready to merge!
docs: refresh README "What's new" for 2.x
feat(#605): --stacked flag — set chain-mode PR base to predecessor br…
feat(#605): address QA gaps — help text, async createPR base, docs ca…