Repository navigation
Closed
Labels
bugSomething isn't workinggraph-2026-10-freeze-bFreeze-safe bug graph, second batch (tracker: see docs/internal/graph-2026-10-freeze-b)plannedImplementation plan approved
Description
Epic: graph-2026-10-freeze-b Tier: mechanical Execution: sequant_run
Follow-up from #1380 (PR #1403; spec Open Question 3, the answer to graph-2026-10-freeze OQ-2). Same class as #1234 and #1386: one base value, consumers that disagree.
Problem
For a non-default bare base (--base release or settings.run.defaultBase: "release", where the repo default is main):
- Worktree creation cuts from local
release:computeWorktreeBaseRef(worktree-manager.ts:826) returns the bare name unchanged when it isn't the detected default. - Staleness (
countCommitsBehind,:244) and the recorded base compare againstorigin/release.
Local release can lag origin/release or not exist at all. In the first case a new worktree starts from an old commit while freshness reads as current. In the second, worktree creation fails or picks up an unrelated local ref.
Acceptance Criteria
- AC-1: For a non-default bare base, worktree creation, staleness and the recorded
sequantBaseRefall use the same ref (origin/<base>after a fetch, unless the base is explicitly local-only). Evidence: a temp-repo test where localreleaselagsorigin/release, asserting the new worktree's HEAD equalsorigin/release, mutation-verified by restoring the bare return incomputeWorktreeBaseRef. - AC-2: A base that exists only locally (no
origin/<base>) still works, as today. Evidence: a test with a local-only base branch. - AC-3:
--stackedpredecessor refs (local branches by design) are unaffected. 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 (the base ref): feat(cli): --stacked flag — set chain-mode PR base to predecessor branch #605 (stacked PR base), bug(exec): sequant run worktrees never record sequantBase, so the zero-diff/uncommitted guard compares against origin/main and a --base ahead of main disables it #1234 (PR fix(#1234): sequant run worktrees record their exact base ref; the exec guard and pre-PR rebase read it #1242: worktrees record their exact base ref), fix(run): --base creates the worktree from the branch but opens the PR against the repo default branch #1386 (PR fix(#1386): --base creates the worktree from the branch but opens the PR against the repo default branch #1394: PR base), ensureWorktree "recreating fresh" rebuilds a PR branch from base and drops its commits; qa re-run reviews the wrong tree #1380 (PR feat(#1380): ensureWorktree "recreating fresh" rebuilds a PR branch from base and drops its commits; qa re-run reviews the wrong tree #1403: recreate base). Four fixes in one class.
- Producer of the base value:
ResolvedRun.baseBranch(run-orchestrator.ts:721). Consumers that turn it into a ref:computeWorktreeBaseRef(creation),countCommitsBehind(staleness), thesequantBaseRefrecord. The ACs state the outcome for all three ("the same ref"), so the fix converges them on one resolution rather than patching one.
May touch
src/lib/workflow/worktree-manager.ts (computeWorktreeBaseRef, countCommitsBehind), its tests, CHANGELOG.md.
Non-Goals
- How the base is resolved (flag, then setting, then detected default).
ensureWorktree's branch-existence check (fix(worktree): first creation on a fresh machine ignores origin/<branch>, and a recreated PR worktree is recreated again on every run (#1380 follow-up) #1405).- Any edit under
plugin/,.claude/skills/ortemplates/skills/(plugin freeze).
Metadata
Metadata
Assignees
Labels
bugSomething isn't workinggraph-2026-10-freeze-bFreeze-safe bug graph, second batch (tracker: see docs/internal/graph-2026-10-freeze-b)plannedImplementation plan approved
Activity
docs(graph): add #1460 to graph-2026-10-freeze-b as a wave-3 node blo…
docs(graph): add #1456 and #1460 to graph-2026-10-freeze-b (#1462)
admarble commentedon Oct 16, 2026
Runner context (graph-2026-10-freeze-b, wave 2)
Wave 1 merged on 2026-10-16.
mainis at 9f1fb3f and includes #1440, #1396, #1305, #1325, #1405 and #1409. These notes are for both the exec phase and the qa phase:npm test(the full suite) in exec or qa. Each phase stops after 30 minutes with no progress, and these phases run the published sequant 2.19.0, which has no affected-tests mode. Run the test files you change or name withnpx vitest run <file>. CI runs the full suite on the PR.mainbut not released). Keep braces out of themutationandfailedTesttext.plugin/,.claude/skills/ortemplates/skills/.ensureWorktreein the same file. Build onmainas it is now. fix(run): phase agents never get SEQUANT_BASE_BRANCH — skills fall back to main on master-default repos #1460 follows this issue inworktree-manager.ts(D-9).admarble commentedon Oct 16, 2026
Complexity: Standard (3 ACs, 1 directory)
AC Quality Check
origin/<base>after a fetch. A literal reading would need a new flag.<base>andsequantBaseRefis<base>.origin/releaseahead of localrelease.Scope Assessment
Non-Goals: present (base resolution,
ensureWorktree's branch-existence check, plugin/skill dirs).Verdict: ✅ SCOPE_OK
Acceptance Criteria
AC-1: One ref for creation, staleness and the record
Verification: Integration Test (temp repos)
Scenario: Given a bare origin with
mainandrelease, and a clone whose localreleaselagsorigin/release→ WhenensureWorktree(..., baseBranch="release", chainMode=false)→ Then the worktree HEAD equalsorigin/release,sequantBaseRefisorigin/release, andcountCommitsBehind(wt, "release")is 0.Assumptions: The fetch of
origin releasehas already run before the ref is chosen. It does atworktree-manager.ts:1169, but only when!isLocalBranch, so that gate must change too.AC-2: A local-only base still works
Verification: Integration Test
Scenario: Given a base branch that exists locally with no
origin/<base>→ When the worktree is created → Then it is cut from local<base>and the record is<base>. The failed fetch must not error.AC-3:
--stackedis unaffectedVerification: Integration Test (existing #605/#1234 tests plus one new case)
Scenario: Given chain mode and a predecessor that also exists on origin → Then the worktree is cut from the local predecessor.
Implementation Plan
Phase 1: One resolver (
worktree-manager.ts)computeWorktreeBaseRef(:826) is pure and cannot tell a stacked predecessor from a non-default bare base. Both arrive as a bare name. Add the distinguishing input rather than guessing.chainModeis already known inensureWorktree(:947), andensureWorktreespassesfalse(:1366). The new signature takes{ chainMode, hasRemote }, wherehasRemoteis a localgit rev-parse --verify --quiet refs/remotes/origin/<base>check, injected so the function stays unit-testable.origin/<default>;origin/…→ as-is; chain mode → bare local; non-default bare with a remote ref →origin/<base>; otherwise bare (local-only).ensureWorktree(:1157-1180) dropisLocalBranchand fetchorigin <base>whenever not in chain mode. A failed fetch is already tolerated, which covers AC-2. Do the fetch before resolving the ref.:1005,:1074, and the reuse and recreate paths) go through the same helper so creation, recreate and the record agree.countCommitsBehindalready comparesorigin/<base>, so it needs no change once the others converge.Phase 2: Tests and changelog
Mutation-verified: AC-1 — …in the PR body. Keep braces out of the marker text (2.19.0 parser).CHANGELOG.mdentry. Runnpx vitest run src/lib/workflow/worktree-manager.test.tsand the run-base-parity integration test. Do not run the full suite.Design Review
computeWorktreeBaseRefalone. Every consumer already routes through it.origin/<base>. Rejected: probing fororigin/<base>inside the function with no chain flag. A stacked predecessor that was pushed would then silently switch to the remote ref and break feat(cli): --stacked flag — set chain-mode PR base to predecessor branch #605.origin/<base>?" Because local-only bases (AC-2) and stacked predecessors must stay local.ResolvedRun.baseBranch(run-orchestrator.ts:721). Consumers arecomputeWorktreeBaseRef×4 call sites,countCommitsBehind(worktree-manager.ts:312,run-orchestrator.ts:1351) andrecordWorktreeBaseRef/readRecordedBaseRef(phase-executor.ts:821). One producer, so no divergence.No SPEC_DIVERGENCE: the plan agrees with the issue's prescription.
Feature Quality Planning
All standard checks pass. Notable items:
releaseare not re-pointed. Document this in the changelog.origin/releasetracking ref is used. That is acceptable and matches the default-branch path.Open Questions
origin/<base>after the fetch, with no new flag. Impact if wrong: a user who wants a local ref over an existing remote one has no option, but that case is not in the ACs.Recommended Workflow
Phases: exec → qa
Quality Loop: disabled
Reasoning: A single-file bug fix. AC-1 declares evidence (a temp-repo test) but this is a bug label, so testgen is skipped. No UI.
Label Review
Current: bug, graph-2026-10-freeze-b
Recommended: add
plannedQuality Loop: won't auto-enable (SCOPE_OK)
admarble commentedon Oct 16, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 3/3 met
Gaps:
fix(#1406): a non-default bare --base is cut from local <base> but co…