Repository navigation
Description
Epic: graph-2026-10-freeze Tier: mechanical Execution: sequant_run
Problem
sequant run <N> --base <branch> creates the worktree from <branch> and rebases onto origin/<branch> before the PR, but opens the PR against the repository's default branch. The PR's diff then includes everything that differs between <branch> and the default branch, not just the issue's change.
Seen: stranger smoke test, 2026-10-09, sequant 2.19.0 (npm), Claude Code 2.1.295. sequant run 21 --base smoke/stranger-2026-10-09 on a private fixture repo: the log says "Preparing worktrees from smoke/stranger-2026-10-09" and "Branch merged origin/smoke/stranger-2026-10-09", but the PR was created with base=main. Against its real base the change is 2 files, +161 lines. Against main the PR shows 37 files, +6,354/−440, because the base branch held a fresh sequant init that main did not.
Cause: createPR sets fields.base only from stackOptions.prBase (src/lib/workflow/worktree-manager.ts:2342). stackOptions is built only under --stacked / chain mode (src/lib/workflow/batch-executor.ts:1213, #605). A plain --base (or settings.run.defaultBase) never reaches gh pr create, which then uses the repo default. #605 and #748 fixed the chain and stacked variants of this class; the non-chain path was not covered.
Acceptance Criteria
- AC-1: With
--base <branch>and no--stacked, the PR is opened withbase: <branch>, and worktree creation,rebaseBeforePRandcreatePRall receive the sameResolvedRun.baseBranchvalue. Evidence: a test that runs the issue path with a non-default base and asserts the three consumers got one identical value, mutation-verified by dropping the base from thecreatePRcall. - AC-2:
settings.run.defaultBaseset to a non-default branch has the same effect as--base. Evidence: a test with the setting set and no CLI option. - AC-3: With neither
--basenordefaultBase, the PR base is unchanged (the repo default). Evidence: an existing or added test. - AC-4:
--stackedstill targets the predecessor branch and takes precedence over--basefor non-last links. Evidence: the existing feat(cli): --stacked flag — set chain-mode PR base to predecessor branch #605 tests pass.
Prior fixes / producers
- Prior fixes on this artifact: feat(cli): --stacked flag — set chain-mode PR base to predecessor branch #605 (
--stackedPR base, 2026-05-12) and fix(run): sequant run has two PR producers — exec opens the PR itself and createPR returns it untouched, dropping the QA note, ready-gate report and summary #1247 (one PR producer, 2026-09-30). Neither covered a plain--base. - Producer of the base: one,
ResolvedRun.baseBranch(run-orchestrator.ts:721). Consumers: worktree creation,rebaseBeforePR(batch-executor.ts:2586),createPR(worktree-manager.ts:2342, onlystackOptions.prBasetoday). The fix passes the existing value through; it adds no second resolver (graph doc D-2).
May touch
src/lib/workflow/batch-executor.ts, src/lib/workflow/worktree-manager.ts (createPR only), their tests. Serialize with #1380 (same file, disjoint functions, graph doc D-5).
Non-Goals
- Changing how the base is resolved (flag → setting → detected default stays as is).
--stackedbehaviour beyond AC-4.- Any edit under
plugin/,.claude/skills/ortemplates/skills/(plugin freeze, I-1 of the graph doc).
Activity
admarble commentedon Oct 9, 2026
Constraint for the fix: resolve the base once. The 2026-09-30 re-patch retrospective named "base ref / two worktree producers" as a cluster patched site by site, and this issue and #1380 arrived the same week. Today the base is resolved separately for worktree creation, for
rebaseBeforePR(…, baseBranch)and forcreatePR(which only seesstackOptions.prBase).Resolve it in one place (
--base→settings.run.defaultBase→ repo default, with--stackedoverriding for non-last links) and pass that one value to all three. The fix isn't done ifcreatePRlearns about--basewhile the other two keep their own resolution. Add a test that asserts the three consumers receive the same value. That's the parity gate the constitution's "one producer per artifact" row asks for (#1250).Related: #1380 (worktree re-creation rebuilds from base and drops commits), which touches the same resolution.
docs(#1390): graph-2026-10-freeze founding doc, issue graph and as-fi…
admarble commentedon Oct 10, 2026
Runner context for the phase agents (graph-2026-10-freeze, wave 1). This applies to the exec phase and the qa phase by name.
npm testin the worktree, in exec or in qa. Three phases run in parallel in this wave, and a full-suite run (10–13 min) under that load crosses the 30-minute phase wall and kills the phase. Run only the test files you touch or add (npx vitest run <file>…), in the foreground, with atimeout, after a WIP commit. The runner session runs the full suite on the PR branch after the PR opens.plugin/,.claude/skills/ortemplates/skills/. The runner checks this before any merge.CHANGELOG.md[Unreleased]: add your line; conflicts with sibling PRs are expected and the runner resolves them.failedTestfield starts with the test file path.admarble commentedon Oct 10, 2026
Complexity: Standard (4 ACs, 2 directories)
AC Quality Check
--basestring reaches worktree creation,rebaseBeforePR, and thecreatePR/gh pr create --baseargument.Scope Assessment
Non-Goals: present (no change to resolution order, no
--stackedwork beyond AC-4, no plugin/skills edits).src/lib/workflow)Verdict: ✅ SCOPE_OK
Acceptance Criteria
AC-1:
--base <branch>without--stackedopens the PR against<branch>; all three consumers get one valueVerification: Unit/Integration Test
Scenario: Given
--base feat/x(detected defaultmain) → When the issue path runs through worktree creation,rebaseBeforePR,createPR→ Then all three receivefeat/xandgh pr creategets--base feat/x.Assumptions: The base reaching
executeBatch/runIssueWithLoggingisResolvedRun.baseBranch, not the separatecfg.baseBranch(see Design Review Q5).AC-2:
settings.run.defaultBasebehaves like--baseVerification: Unit Test (
resolveRunOptions/ orchestrator resolve with setting, no CLI option, then the same createPR assertion)AC-3: Neither set → PR base unchanged
Verification: Unit Test (
createPRcalled with base equal to the detected default passes no--base)AC-4:
--stackedprecedence unchangedVerification: Existing #605 tests (
worktree-manager.test.ts,batch-executor.test.ts) plus one added case: non-last link with--baseset still getspredecessorBranch.Implementation Plan
Phase 1: One resolver for the PR base
src/lib/workflow/worktree-manager.ts: add an exportedresolvePrBase(stackPrBase, baseBranch, detectedDefault)next tocomputeWorktreeBaseRef(~line 827), same semantics:stackPrBasewins; elsebaseBranchwith anyorigin/prefix stripped when it differs from the detected default; elseundefined(gh uses the repo default).createPR(line 2266): add the resolved base to its inputs and useresolvePrBase(...)for bothcreatePRCliSync(..., base)(line ~2342) andupdateExisting'sfields.base. Prefer extending the existingstackOptionsshape or the trailingoptsobject over a 13th positional parameter.Phase 2: Thread the value
src/lib/workflow/batch-executor.ts(~line 1213): passbaseBranch(already destructured fromctxat line 1117) into thecreatePRcall at ~line 1272. Do not build a second resolution here.baseBranchinBatchExecutionContextis the resolvedResolvedRun.baseBranchon every entry path:run-orchestrator.ts:1627passesthis.cfg.baseBranch, which is a separate field from theResolvedRun.baseBranchcomputed at line 721. If it can be unset when onlysettings.run.defaultBaseis given, populate it from the resolved value (this is the AC-2 failure mode).Phase 3: Tests (mutation-verified for AC-1)
--base feat/x, spy onensureWorktrees,rebaseBeforePR,createPR; assert one identical value. AC-2, AC-3, AC-4 cases alongside.createPRcall; confirm the AC-1 test fails; restore. Record with theMutation-verified:marker,failedTeststarting with the test file path.Design Review
worktree-manager.ts, besidecomputeWorktreeBaseRef; both turn "base option + detected default" into a ref/branch.detectDefaultBranchinbatch-executor(extra git call, disturbs ordered mocks); always passing--base <detected default>(if detection falls back to"main"on a repo whose default is something else,gh pr createwould break where it works today).--stacked) and fix(run): sequant run has two PR producers — exec opens the PR itself and createPR returns it untouched, dropping the QA note, ready-gate report and summary #1247 (one PR producer); fix(chain): --chain successors branch from main, not predecessor's committed work (up-front worktree provisioning) #748 covered chain. This is the third site-by-site patch, so the fix is the single helper plus the three-consumer parity test, per the issue's constraint, not another local patch.--base?" See Q2. "Why retarget an existing PR inupdateExisting?" It already does so forprBase; same value, same rule.run-orchestrator.ts:721(ResolvedRun.baseBranch). Possible second producer:OrchestratorConfig.baseBranch(run-orchestrator.ts:207/238, used at 448 and 1627 with a?? "main"fallback). Consumers:ensureWorktrees/ensureWorktreesChain,rebaseBeforePR,createCheckpointCommit,resolveDiffBase(batch-executor 2036/2059),createPR. No divergence from the prescribed lever, so no halt.Feature Quality Planning
All standard checks pass. Notable items:
origin/<x>bases:gh --baseneeds the bare name; strip the prefix.gh pr create --basefails if it is not pushed. Today's behavior with--baseis already to rebase onto the local branch (worktree-manager ~1668), so surface a clear error, not a silent fallback. Decide in Open Questions.plugin/,.claude/skills/,templates/skills/.CHANGELOG.md[Unreleased]line required.Open Questions
prBasebehavior). Impact: a hand-retargeted PR gets moved back.ghfail and surface its error (already a failed PR step per fix(run): exec that leaves work uncommitted reports success and the run passes with no PR — #534's empty-branch escape, reopened via a new route #879). Impact: run marked failed instead of opening a PR against the wrong base.Recommended Workflow
Phases: exec → qa
Quality Loop: disabled
Reasoning: Small, mechanical fix with a parity test. Tests are written alongside exec (unit-test ACs, but a bug-fix with targeted tests, so no testgen). No UI. Runner context: no full
npm testin exec or qa (per the wave comment).Label Review
Current: bug, graph-2026-10-freeze
Recommended: bug, graph-2026-10-freeze, planned
Quality Loop: Won't auto-enable (SCOPE_OK, no complex labels)
admarble commentedon Oct 10, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 4/4 met
Gaps:
batch-executor.ts:1211still says "Last PR keepsmain". With--base Xand--stacked, the last PR now targets X. That is consistent, because the last link is rebased onto X, but the comment no longer matches.Suggestions:
upstream/foo) is not prefix-stripped. This is an edge case and not required by any AC.docs(#1386): the last stacked PR targets the run's base, not main
fix(#1386): --base opens the PR against the run's base branch, not th…
fix(#1406): a non-default bare --base is cut from local <base> but co…