Repository navigation
fix(#899): create the worktree in /fullsolve, verify it in /exec - #902
Merged
admarble merged 2 commits intoAug 6, 2026
Merged
Conversation
Skill-driven /fullsolve never had worktree isolation. Three links failed together since #111/#112 (2026-01-17): 1. /fullsolve claimed /spec creates the feature worktree. /spec never has. 2. /fullsolve exported SEQUANT_WORKTREE as an unexpanded glob, at three sites. 3. /exec was told to `cd $SEQUANT_WORKTREE` and skip creation without checking. The cd failed, creation was skipped by contract, and the agent implemented in whatever directory it was already in. Single-session runs degraded silently; concurrent ones interleaved checkout/reset/commit in one working tree. A second failure mode compounded it: ../worktrees/ is derived from the parent of the git root, so every sibling repo shares one flat namespace, and both lookups keyed on the issue number, which is per-repo. Creation was never the exposed surface (git worktree add onto a foreign path fails loudly); resolution was. Changes: - New `sequant worktree` command group. `resolve <issue>` prints this repo's worktree path; `verify <path> [--issue N]` refuses a missing, foreign, or stale one. Both read `git worktree list` in the current repository, so a sibling project's worktree structurally cannot appear, and both select on the branch git reports rather than the directory slug — the two already diverge in practice (578-seo-expand-city-coverage holds feature/578-city-expansion-clean). - /fullsolve gains Phase 1.5: creates the worktree via new-feature.sh (idempotent, safe on resume), resolves the absolute path, exports it. All three glob exports replaced. The false /spec claim and the Phase 1 post-state are corrected. - /exec verifies before it trusts, halting on a named error rather than continuing in place; its standalone lookup resolves through git. - /spec states its worktree contract explicitly again (dropped by #515). - All three skill mirrors synced. Every new failure mode halts: SEQUANT_WORKTREE_NOT_FOUND, SEQUANT_WORKTREE_FOREIGN, SEQUANT_WORKTREE_ISSUE_MISMATCH, WORKTREE_NOT_FOUND, WORKTREE_AMBIGUOUS. The bug was a fail-open one; the fix does not replace it with a lenient guard. The `sequant run` CLI path is unaffected — it always called ensureWorktree before setting SEQUANT_WORKTREE, which is what /exec's skip branch was written against. Absorbs #900. Fixes #899
This was referenced Aug 6, 2026
Closed
…ust /exec #899 fixed /exec. The same pattern had been copied into five more skills, each found by widening the search rather than trusting the first fix. Unguarded `cd $SEQUANT_WORKTREE` (the exact line #899 removed from /exec): - /qa — reviewed the main checkout while reporting on the feature branch - /loop — worse: it WRITES, so it applied fixes and committed them there Filesystem globbing of the shared ../worktrees/ namespace: - /qa, /loop, /testgen — /testgen writes test stubs, so a cross-repo match scatters them into an unrelated project Prefix matching on the issue number instead of the branch: - /merger ×2 — `git worktree list | grep "feature/$ISSUE"`, and the next line is `git worktree remove --force`. With ISSUE=89 that matches feature/899-* and force-removes an unrelated issue's worktree. - /qa Phase 0 — `grep -i "<issue-number>"` gated the "no implementation found" verdict on a bare-number match - /assess — read-only probe, corrected for the same reason All now route through `sequant worktree verify` / `resolve` from #899. Rather than pin the six known sites, two completeness invariants close the class: every `cd $SEQUANT_WORKTREE` in ANY skill must sit inside a verify-bearing guard region, and no skill may glob ../worktrees/ or grep `git worktree list` for an issue number. A new skill reintroducing either pattern now fails the build. The bug reached six skills by being copied, so pinning known sites would not have held. Both invariants are scoped to spare legitimate uses: /assess's `grep "^worktree"` enumerates every worktree for diff-overlap and keys on nothing, so it is not flagged. Narrowing that exemption is what caught the `--porcelain` variant in /merger that the first regex missed. Fixes #904
admarble
deleted the
feature/899-bug-fullsolve-exec-the-worktree-is-never-creat
branch
August 6, 2026 20:15
7 tasks
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Skill-driven
/fullsolvehas never had worktree isolation. Three links failed together since #111/#112 (2026-01-17):/fullsolveclaimed/speccreates the feature worktree./specnever has — and said so, until perf(spec): prompt compression and tiered context — reduce spec skill token cost by ~60% #515's compression deleted the line./fullsolveexportedSEQUANT_WORKTREE=../worktrees/feature/<issue>-*/— an unexpanded glob, at three sites./execwas instructed tocd $SEQUANT_WORKTREEand skip creation without checking anything.The
cdfailed, creation was skipped by contract, and the agent implemented in whatever directory it was already in, on whatever branch was checked out. Single-session runs degraded silently — commits landed, a PR opened, nothing errored — which is how this survived seven months.A second failure mode compounded it.
../worktrees/is derived from the parent of the git root, so every repository under the same parent shares one flat namespace, and both lookups keyed on the issue number, which is per-repo and collides constantly. Creation was never the exposed surface (git worktree addonto an existing foreign path fails loudly); resolution was.Design
One repo-scoped resolver instead of six inline snippets. AC-3 through AC-6 all reduce to "given this repo and this issue, which worktree?" — so that question is answered once, in code, and both skills call it.
New
sequant worktreecommand group:resolve <issue>WT="$(…)"captures cleanly.verify <path> [--issue N]It reuses
listWorktrees()(src/lib/workflow/worktree-manager.ts), whichready.ts:136already used for this same lookup, gaining an optionalcwdparameter. Two properties fall out structurally rather than as filters that can be forgotten:git worktree listonly ever reports the current repository's worktrees, so a sibling project's worktree cannot appear at all.578-seo-expand-city-coverage-to-20-citiesalready holdsfeature/578-city-expansion-clean— so a name match proves nothing about which branch you'd land on.Rejected: inline bash in the SKILL.md files (prose is not executable, so AC-11 could not be tested, and it means six copies across 2 skills × 3 mirrors — the drift class from #871); and a new
templates/scripts/*.sh(consumer projects receive those atscripts/dev/, so the documented path would be wrong there).Everything fails closed.
SEQUANT_WORKTREE_NOT_FOUND,SEQUANT_WORKTREE_FOREIGN,SEQUANT_WORKTREE_ISSUE_MISMATCH,WORKTREE_NOT_FOUND,WORKTREE_AMBIGUOUS— every one halts. The bug being fixed was a fail-open one; the fix does not replace it with a lenient guard.The
sequant runCLI path is untouched — it always calledensureWorktreebefore settingSEQUANT_WORKTREE, which is what/exec's skip branch was originally written against.AC Verification
/fullsolvecreates the worktree vianew-feature.shfullsolve/SKILL.md, regionworktree-creation (#899)SEQUANT_WORKTREEexport"$SEQUANT_WORKTREE"; gated by test/exechalts on non-existent pathSEQUANT_WORKTREE_NOT_FOUND; regionworktree-existence-guard (#899)/exechalts on foreign/stale pathSEQUANT_WORKTREE_FOREIGN, realpath-compared against this repo's worktree listgit worktree listworktree-standalone-lookup (#899); glob appears only inside a "Do not" prohibitionlistWorktrees()derives the issue frombranch refs/heads/…; test uses a deliberately diverged slug/speccreates the worktree/specstates its worktree contractspec-worktree-contract (#899)npm run lint:skill-sync→ 44 synced, 0 diverged. Note: there are three mirrors, not two —skills/(the published plugin) alongside.claude/skills/andtemplates/skills/. All three updated.__tests__/integration/worktree-contract-skill.integration.test.ts— 24 tests (8 × 3 roots)src/lib/workflow/worktree-resolver.integration.test.ts— 11 tests over two real git reposMutation results (per CLAUDE.md)
Each gate test was verified by deleting what it asserts and confirming exactly that test fails.
export SEQUANT_WORKTREE=../worktrees/feature/<issue-number>-*/in.claude/skills/fullsolve/SKILL.mdexports no globbed SEQUANT_WORKTREE value (AC-2), and only for the mutated rootworktree-existence-guard (#899)region from.claude/skills/exec/SKILL.md, restoring the barecd $SEQUANT_WORKTREEguards SEQUANT_WORKTREE existence before use (AC-3)andnames the foreign-worktree failure mode (AC-4)resolveIssueWorktreeto globbing../worktrees/feature/<issue>-*on the filesystemdoes not select a sibling repository's worktree that matches the issue-number glob; theverifyWorktreePathblock correctly stayed greenAll restored; 35/35 green afterwards.
Regions are delimited by
<!-- BEGIN: … -->/<!-- END: … -->markers and the extractor throws when a region is absent, so deleting the markers fails loudly rather than reducing the assertion to a vacuous match on"". The AC-2 assertion also floors the export count at 3, so renaming the exports away cannot make it pass by finding nothing.Test plan
npm run build— passesnpm run lint— passesnpm run lint:skill-sync/lint:skill-calls/lint:skill-gates— all cleannpx vitest runon both new files — 35/35On the 18: all in
semgrep.test.ts,mcp-*.integration.test.ts, andprompt-wait.test.ts— no overlap with worktree resolution. Settled by checking out based90f82aein the same worktree and re-running those five files: base produced2 failed files / 4 failed tests, this branch produced the identical2 failed files / 4 failed tests(semgrep ×3 pre-existing, plus one rotating flake insidemcp-serve.integration.test.ts— SIGTERM at base, health-check on branch). The extra failures in the full-suite run did not reproduce under a targeted run, i.e. they are concurrency-load artifacts. Pre-existing on main; not introduced here.Known limitation
listWorktrees()extracts the issue fromfeature/<N>-…only.new-feature.shalways produces that shape, so sequant-created worktrees always resolve. A hand-named branch (fix/issue-023-…) will not — and that case halts withWORKTREE_NOT_FOUNDrather than mis-adopting anything, so it fails safe. Broadening the regex would changeready.tsselection semantics and is deliberately out of scope.Non-goals honoured
sequant runCLI worktree path unchanged.SEQUANT_WORKTREEprecedence unchanged — still authoritative when set and valid.../worktrees/not re-laid-out into per-project subdirectories; that would strand every existing worktree on disk, and scoping resolution closes the failure mode without it.Absorbs #900.
Update — the gap this PR's own review found (#904, now fixed here)
The first pass fixed
/exec. The QA re-read then asked whether the same patternexisted elsewhere, and it did — in five more skills. Rather than ship a
partial fix and a follow-up, all of them are closed here and #904 is absorbed.
Unguarded
cd $SEQUANT_WORKTREE— the exact line #899 removed from/exec/qa/loopBoth now run the same
sequant worktree verifygate and halt on a named error.Globbing the shared
../worktrees/namespace/qa,/loopand/testgenall located worktrees by globbing../worktrees/feature/<issue>-*— the same cross-repo bug. All three now resolvethrough
sequant worktree resolve./testgenmatters because it writes teststubs: a cross-repo match scatters them into an unrelated project.
Prefix matching on the issue number instead of the branch
The sharpest one.
/mergerhadgit worktree list | grep "feature/$ISSUE"with
git worktree remove --forceon the very next line — soISSUE=89matches
feature/899-…and force-removes an unrelated issue's worktree.Also
/qa's Phase 0 implementation probe (a bare-numbergrep -igating the"no implementation found" verdict) and
/assess's read-only probe.Two completeness invariants instead of six pinned assertions
The bug reached six skills by being copied, so pinning the known sites would
not have held. The gate test now asserts, across every skill in every mirror:
cd $SEQUANT_WORKTREEsits inside a verify-bearing guard region.../worktrees/or grepsgit worktree listfor an issue number.A newly-added skill that reintroduces either pattern fails the build.
Both are scoped to spare legitimate uses —
/assess'sgrep "^worktree"enumerates every worktree for diff overlap and keys on nothing, so it is not
flagged. Narrowing that exemption is what surfaced the
--porcelainvariant in/mergerthe first regex had missed.Additional mutation results
worktree-existence-guardregion from.claude/skills/qa/SKILL.md, restoring the barecdls ../worktrees/feature/<issue-number>-*/to/docs— a skill in no pinned listdocs:as the offender, proving it catches future skills, not just known ones/merger'sgit worktree list | grep "feature/$ISSUE"merger:as the offenderAll restored; 62/62 green afterwards.
Closes #904 in addition to #899.
Closes #899
Closes #904