Repository navigation
Description
Epic: graph-2026-10-freeze-c Tier: judgment Execution: sequant_run
- Blocked by: fix(worktree): a non-default bare --base is cut from local <base> but counted against origin/<base> (#1380 follow-up, #1234/#1386 class) #1406
- Blocked by: fix(run): phase agents never get SEQUANT_BASE_BRANCH — skills fall back to main on master-default repos #1460
Problem
sequant run finds an issue's existing worktree by a branch name rebuilt from the issue title. If the title differs from the one the branch was cut with, it misses the branch and creates a second one from the base:
ensureWorktreebuildsfeature/${issueNumber}-${slugify(title)}(src/lib/workflow/worktree-manager.ts:987-988).- It looks that exact name up (
findExistingWorktree(branch),:148, a substring match ongit worktree list --porcelain).
Two triggers:
- A failed
gh issue view.getIssueInfo(src/lib/workflow/batch-executor.ts:318-351) returns the titleIssue #Nfor everyghfailure except "Could not resolve to an issue" (offline, auth, rate limit, 5xx, unparseable JSON). This is the silent default fix(doctor/run):doctorandrun --dry-runreport success when nothing would work #1257 kept on purpose. The orchestrator passes it straight toensureWorktree(run-orchestrator.ts:1161-1163,:1294). - A retitled issue. Any title edit after the branch exists changes the slug.
Then:
- The phase runs in a fresh worktree at the base.
batch-executor.ts:1164-1170overwrites state.json'sbranch/worktreerecord with the new branch.sequant worktree resolve Nnow reportsWORKTREE_AMBIGUOUS.
Seen: 2026-10-16, a qa-only re-run of #1305 (MCP sequant_run, phases qa) whose gh issue view failed. It created feature/1305-issue-1305 from main next to the PR branch feature/1305-fix-qa-a-sequant-mutation-marker-whose-text-contai, and QA recorded commit: null.
Reproduced on main (0857484), in a temp clone using the #1380 harness shape:
ensureWorktree(1305, "fix(qa): a SEQUANT_MUTATION marker whose text contains }"), then a commit pushed with-u.ensureWorktree(1305, "Issue #1305")returned{ branch: "feature/1305-issue-1305", existed: false }, at theinitcommit. The PR worktree still heldpr commit.
Everything else in src already treats the issue number as a branch's identity:
listWorktrees(parsesissuefrom the branch) andresolveIssueWorktree(worktree-resolver.ts:67, bug(fullsolve/exec): the worktree is never created and never verified — skill-driven runs execute in the main checkout, or in another repo's worktree #899/bug(worktree): ../worktrees/ is one namespace shared by every sibling repo, and lookup globs on issue number alone #900)parseIssueNumberFromBranch(worktree-discovery.ts:75)merge-check/index.ts:143(^feature/${n}-)pr-status.ts:132
Only the code that creates worktrees keys on the title.
Acceptance Criteria
- AC-1: When exactly one branch for issue N exists (a worktree of this repo, a local
refs/heads/feature/N-*, orrefs/remotes/origin/feature/N-*),ensureWorktreereuses that branch whatever title it is given, including the fallbackIssue #Nand a changed title, and creates no new branch. Evidence:npx vitest run src/lib/workflow/worktree-manager.test.ts -t "reuses the issue's branch"reports ≥ 4 passed, 0 failed. The temp-repo tests cover (a) an existing pushed worktree called again with titleIssue #N, (b) the same with a different real title, and (c) a fresh clone where onlyorigin/feature/N-<slug>exists, called with titleIssue #N, and (d) issue 1 beside an existingfeature/12-otherbranch, which must not be taken as issue 1's branch (the prefix match includes the dash). Each asserts the returned branch equals the original andgit branch --list 'feature/N-issue-n'is empty. Mutation-verified by restoring the title-only lookup (findExistingWorktree(\feature/${issueNumber}-${slug}`)`). - AC-2: When two or more branches for issue N exist,
ensureWorktreecreates no new branch. It uses the one whose name equals the title-derived name if there is one. Otherwise it returns no worktree and prints every candidate branch, and the issue fails rather than running in another checkout. Evidence:npx vitest run src/lib/workflow/worktree-manager.test.ts -t "several branches for one issue"reports ≥ 1 passed, 0 failed: a temp-repo test withfeature/N-aandfeature/N-band titleIssue #Nasserting no third branch, a null result and both names in the output; mutation-verified by making the multi-match case pick the first candidate. - AC-3: A non-dry run that could not read an issue's title (a
ghfailure other than not-found) prints a warning naming the issue and thegherror before worktree setup. A run that read the title prints no such warning. Evidence:npx vitest run src/lib/workflow/get-issue-info.test.ts -t "title unreadable warning"reports ≥ 2 passed, 0 failed: a test that stubsspawnSyncto fail withHTTP 502and asserts the warning names#N, plus a passing-ghcase that asserts no warning; mutation-verified by removing the warning. - AC-4: With no branch for issue N anywhere, first creation is unchanged:
feature/N-<slugify(title)>from the run's base, or fromorigin/<branch>on a fresh machine (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). Evidence:npx vitest run src/lib/workflow/worktree-manager.test.ts -t "1380|1405"reports 0 failed, with no test edited.
Prior fixes / producers
- Prior fixes in the class (branch identity for an issue):
- bug(worktree): new-feature.sh and sequant run derive different branch names for the same issue #1145:
new-feature.shandsequant runderived different names for the same title. It was fixed by matching the slug rules, which doesn't help when the title itself differs. - bug(fullsolve/exec): the worktree is never created and never verified — skill-driven runs execute in the main checkout, or in another repo's worktree #899 and bug(worktree): ../worktrees/ is one namespace shared by every sibling repo, and lookup globs on issue number alone #900: worktree lookup by directory glob was replaced by branch-by-issue-number in
resolveIssueWorktree. - feat(exec/qa): explicit in-place checkout mode — run a phase on a branch in the current clone without creating or resolving a worktree #1136: in-place mode's slug parity.
- ensureWorktree "recreating fresh" rebuilds a PR branch from base and drops its commits; qa re-run reviews the wrong tree #1380 and 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: start refs for an existing branch.
git log -S 'getIssueInfo': fix(doctor/run):doctorandrun --dry-runreport success when nothing would work #1257 (PR fix(#1257): doctor warns on a missing GitHub remote and uncommitted core skills; dry run errors on a missing issue #1268) addednotFoundand kept every otherghfailure silent.
- bug(worktree): new-feature.sh and sequant run derive different branch names for the same issue #1145:
- Producers of the branch name:
ensureWorktree(worktree-manager.ts:988,slugify)templates/scripts/new-feature.sh(node C of this graph)- the
/execin-place block in the skill prose (feat(exec/qa): explicit in-place checkout mode — run a phase on a branch in the current clone without creating or resolving a worktree #1136, frozen)
- Consumers that key on the issue number:
resolveIssueWorktree,listWorktrees,worktree-discovery,merge-check,pr-status,checkout-lock.ts:182,cleanup-worktree.sh. - The ACs state the outcome (one branch per issue is reused whatever the title) rather than patching the fallback title, so the gh blip and the retitle are both closed.
- Source of truth: a git ref for the issue number, because it is local, needs no network and is present on a fresh machine once fetched. Not state.json, whose
branchrecord is per-checkout and is overwritten by the stray branch (batch-executor.ts:1166). Not the PR'sheadRefName, which needs theghcall that just failed.
May touch
src/lib/workflow/worktree-manager.ts (ensureWorktree's existing-branch lookup, findExistingWorktree), src/lib/workflow/batch-executor.ts (getIssueInfo may report the gh error), src/lib/workflow/run-orchestrator.ts (the warning at the issue-info loop, :1158-1164), their tests (worktree-manager.test.ts, get-issue-info.test.ts), CHANGELOG.md.
Non-Goals
- Retrying or caching
gh issue view. - Renaming or deleting a stray
feature/N-issue-nbranch left by an earlier run. Report it in the AC-2 candidate list instead. new-feature.sh's own branch lookup (node C).ensureWorktree's failure path whengit worktree addfails (fix(run): a failed git worktree add must fail the issue, not run its phases in the main checkout (two CLIs race on .git/config) #1469).- Any change to how the start ref is resolved (ensureWorktree "recreating fresh" rebuilds a PR branch from base and drops its commits; qa re-run reviews the wrong tree #1380, 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, fix(worktree): a non-default bare --base is cut from local <base> but counted against origin/<base> (#1380 follow-up, #1234/#1386 class) #1406).
- Any edit under
plugin/,.claude/skills/ortemplates/skills/(plugin freeze).
Activity
admarble commentedon Oct 17, 2026
QA Review for Issue #1487
AC Coverage
findIssueBranches+selectIssueBranch(worktree-manager.ts). Evidence command: 4 passed, 0 failed. Covers (a)–(d), includingfeature/12-othernot taken as issue 1's branch.ensureWorktreesskips a null entry,runIssueWithLogginggetsworktree: undefined, andphase-executor.ts:1642-1643setscwd = process.cwd(). So in non-chain mode the issue's phases run in the main checkout, which is the failure #1487 describes (QA reviews main). Chain mode does stop ("Chain broken"). No test covers the "issue fails" half.issueTitleWarningis wired atrun-orchestrator.ts:1164-1170. Evidence command: 4 passed.run-orchestrator.test.tscovers both the real run and the dry run.-t "1380|1405": 12 passed, 0 failed. No removed lines inworktree-manager.test.ts.Coverage: 3/4 met
CI Status (PR #1497)
testis IN_PROGRESS. Gitleaks, canary, node-floor-guard, validate-skills, typecheck, validate-plugin and tautology-advisory pass.Quality Checks
any, 0 deleted testsrun-orchestrator.test.tsis the only file outside "May touch", and it is the sibling test.spawnSyncpasses an args array with no shellLocal run: the 3 changed test files ran 99/99 passed. Build: typecheck passes in CI.
Code Review
Strengths:
resolveIssueWorktree,merge-checkandpr-status.findExistingWorktreechanged from substring to exact match, which also closes a latent bug wherefeature/1-matchedfeature/12-.bracketedConsoleLog, so it also appears in parallel and MCP runs.Issues:
run-orchestrator.ts, after provisioning with isolation on, give each issue that has noworktreeMapentry a failedIssueResult(with an abort reason) instead of running it. Add a test for that.Suggestions:
origin/feature/N-*ref from a merged and deleted PR counts as a candidate untilfetch --prune. A reopened issue would reuse it or become ambiguous. This is by design per the ACs, but the CHANGELOG could say so.Mutation Verification
Status: Missing. The PR body is the auto-generated stub and has no
SEQUANT_MUTATIONmarkers.Declared-Evidence Execution
-t "reuses the issue's branch"-t "several branches for one issue"-t "title unreadable warning"-t "1380|1405"Status: Complete
Trust-Boundary Check
Finding: Clean. The diff implements only product requirements, and no agent-directed instruction from external text was acted on.
Status: Clean
Behavior-Rule Survival Check
Status: N/A. No AC triggers the behavior-rule heuristic, and the title-only lookup
feature/${issueNumber}-${slug}survives only as the title-match fallback the ACs intend.CHANGELOG Verification
Result: Met. An
[Unreleased]→ Fixed entry with (#1487) is present.Risk Assessment
feature/N-issue-nbeside the PR branch (the fix(qa): a SEQUANT_MUTATION marker whose text contains "}" parses to nothing — renderMutationMarker and the parser do not round-trip #1305 shape after one bad run), called with a non-matching title. It prints the candidates and then runs its phases in the main checkout.ensureWorktreeresult, in either mode.worktreeMapentry into theprocess.cwd()fallback (run-orchestrator.ts:1904,batch-executor.ts:635,phase-executor.ts:1643). The same fallback applies whengit worktree addfails (fix(run): a failed git worktree add must fail the issue, not run its phases in the main checkout (two CLIs race on .git/config) #1469, a Non-Goal), so a single guard at the orchestrator would close both.ensureWorktreesChainalready breaks on null, butensureWorktreessilently drops it.Adversarial Re-Read
Findings: I traced the AC-2 null result end to end and found the main-checkout fallback described above. I ran the issue's repro shape: AC-1(a) is the "Issue #1305" fallback case, and it passes. Process state is clean: 0 commits behind main and no uncommitted work. Non-Goals are respected: no plugin or skill edits, no
new-feature.shedits, no retry ofgh.Status: Severe Gap. AC-2's "issue fails" clause is marked unmet. It had no test, and I verified it from the code path.
Follow-up Ledger
Status: Resolved
Verdict: AC_NOT_MET
AC-2 is PARTIALLY_MET. An ambiguous issue returns no worktree, but the run does not fail it. In non-chain mode its phases run in the main checkout. The mutation markers for AC-1 to AC-3 are also missing, and CI
testis still running.Next Steps
run-orchestrator.ts, when worktree isolation is on, fail each issue that has noworktreeMapentry instead of running it inprocess.cwd(). Add a test that two branches plus the titleIssue #Ngive a failed issue and no phase run.SEQUANT_MUTATIONmarkers for AC-1, AC-2 and AC-3 to exec's summary or the PR body./qa 1487after CItestreports.admarble commentedon Oct 17, 2026
QA Verdict: AC_NOT_MET
AC coverage: 3/4 met
fix(#1487): an ambiguous issue records its candidate branches as the …
admarble commentedon Oct 17, 2026
QA Review for Issue #1487 (re-run at 0eec3b4)
The previous QA, at 4a2a275, returned AC_NOT_MET for two reasons: the AC-2 "issue fails" clause was not met, and the mutation markers were missing. This re-run checks the merged
main(#1469 / #1493) and commit 0eec3b4.AC Coverage
findIssueBranches+selectIssueBranch. Evidence-t "reuses the issue's branch": 4 passed, 0 failed. Covers (a)–(d).-t "several branches for one issue": 2 passed. Commit 0eec3b4 writes the candidate list intoprovisioning.failures, and the test asserts it.batch-executor.ts:1189(worktreeRequired && !worktree, from #1469) fails the issue before any phase runs.run-orchestrator.worktree-failure.test.ts(3 passed) covers that half. Both orchestrator call sites (run-orchestrator.ts:1322,1331, chain and non-chain) pass{ failures: worktreeFailures }.-t "title unreadable warning": 4 passed. The dry-run and real-run wiring is covered inrun-orchestrator.test.ts.-t "1380|1405": 12 passed. The diff ofworktree-manager.test.tsagainst main removes 0 lines.Coverage: 4/4
CI Status (PR #1497)
testtestis a required check and has not finished, so the verdict below is gated on it.Quality Metrics
any/ security patterns in added linestsc --noEmitplugin/,.claude/skills/,templates/skills/)The quality checks ran inline in this pass. No sub-agents were used.
Code Review
Strengths:
resolveIssueWorktree,merge-checkandpr-statusalready use.findExistingWorktreematches exactly instead of by substring. This closes the latent bug wherefeature/1-matchedfeature/12-.Suggestions (non-blocking):
origin/feature/N-*ref left by a merged and deleted PR stays a candidate untilfetch --prune. A reopened issue would reuse it. This matches the behavior before this change when the title was unchanged, so it is not a regression.findIssueBrancheshits a git error it returns[]and falls back to the title-derived name. That is the old behavior, but it does so silently.Mutation Verification
src/lib/workflow/worktree-manager.test.ts > … > reuses the issue's branch for the fallback title Issue #Nsrc/lib/workflow/worktree-manager.test.ts > … > several branches for one issue…src/lib/workflow/get-issue-info.test.ts > title unreadable warning (#1487) > …HTTP 502Status: Verified. All three files named in the markers are in the diff.
Declared-Evidence Execution
All four Evidence commands ran in this pass and were green (4 / 2 / 4 / 12 passed). Status: Complete
Trust-Boundary Check
Finding: Clean. The diff implements only the product requirements. Status: Clean
Behavior-Rule Survival Check
Status: N/A. The title-derived name survives only as the tie-break and first-creation name, which the ACs intend.
CHANGELOG Verification
Result: Met. An
[Unreleased] → Fixedentry with (#1487) is present.Risk Assessment
feature/N-*branch exists that is not the issue's working branch, for example a hand-made side branch. That issue becomes ambiguous and fails loudly. This is the intended trade, and the message names the branches.sequant runto a failedIssueResult. That outcome is covered by composing the failures-map assertion with fix(run): a failed git worktree add must fail the issue, not run its phases in the main checkout (two CLIs race on .git/config) #1469's run-level test.templates/scripts/new-feature.sh(node C, a Non-Goal) and the frozen/execin-place prose are still title-keyed. All consumers already key on the number.ensureWorktreesChainandensureWorktreesboth pass the failures map, and thegetGitRootnull path already records its failure.Adversarial Re-Read
Findings: I ran the issue's repro shape (an existing pushed branch, then
Issue #N), which is AC-1(a), and it passes. I traced the AC-2 null result throughbatch-executor.ts:1189to the failed issue. Process state: 0 commits behind main, clean tree, and the merge ofmainbrings in #1469. ThegetIssueInfoerror paths cover non-zero exit (stderr), spawn error (ENOENT) and a JSON parse throw (catch). Non-Goals are respected: no retry or caching of gh, no rename of stray branches, nonew-feature.shchange, no start-ref change. No new gaps. Status: CleanFollow-up Ledger
new-feature.shtitle lookup is dropped: it is node C of graph freeze-c (Non-Goal).Status: Resolved
Verdict: NEEDS_VERIFICATION
All four ACs are met. Every Evidence command passed locally, the mutation records are verified, and both prior blockers are fixed. The required CI check
testis still IN_PROGRESS, so this cannot be READY_FOR_MERGE yet. Iftestgoes green, the code review supports READY_FOR_MERGE.Next Steps
testcheck on PR fix(#1487): an existing branch for issue N is reused whatever the title — a gh blip or a retitle cuts feature/N-issue-n from main and QA reviews main #1497, then re-run/qa 1487, or merge on green.findIssueBranches' git call fails.admarble commentedon Oct 17, 2026
QA Verdict: NEEDS_VERIFICATION
AC coverage: 4/4 met
admarble commentedon Oct 17, 2026
Runner verification of QA's NEEDS_VERIFICATION, on 081f898 (0eec3b4 merged with
main). QA marked 4/4 met and named nothing pending. The runner ran every Evidence command exactly as written:1380|1405): 12 passed, with no existing test edited.run-orchestrator.worktree-failure.test.tsandrun-orchestrator.test.ts: 18 passed.tscis clean.The AC-1 and AC-2 tests run real git in temp repos, with no mocks. The three mutations (AC-1 to AC-3) each failed the test their AC names; the records are in PR #1497. AC-2's 'the issue fails' clause comes from #1469's guard (merged as 73d0078). This branch also records the candidate branches as the failure reason.