Skip to content

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

Closed

Description

@admarble

Summary

/fullsolve tells /exec that a worktree exists, /exec trusts it and skips creation, and nobody ever creates one. Nothing in the chain verifies the path before using it. The result is that skill-driven /fullsolve runs execute in the main checkout, on whatever branch it happens to be on — and where the path does resolve, it can resolve into a different repository's worktree, because ../worktrees/ is one namespace shared by every sibling repo. With one session this is silent — commits land, a PR opens, nothing errors. With two sessions it becomes interleaved checkout / reset / commit in a shared working tree.

Three links, all in the skills:

1. /spec does not create a worktree. .claude/skills/fullsolve/SKILL.md:293 asserts it does:

The `/spec` skill will:
- ...
- Create feature worktree

and Phase 1's post-state (line 336) declares "Feature worktree ready". spec/SKILL.md has three worktree mentions across 397 lines — a frontmatter permission and two git worktree list calls for collision detection. No creation step, in either mirror.

2. /fullsolve exports an unexpanded glob (fullsolve/SKILL.md:366, repeated at 468 and 537):

export SEQUANT_WORKTREE=../worktrees/feature/<issue-number>-*/

3. /exec is instructed to trust it without checking (exec/SKILL.md:474):

**If orchestrated (SEQUANT_WORKTREE is set):**
- Use the provided worktree path directly: `cd $SEQUANT_WORKTREE`
- Skip steps 1-2 below (worktree already created by orchestrator)

There is no existence guard anywhere in the chain. The cd fails, creation is skipped by contract, and the agent proceeds in the current directory.

The tell is in the frontmatter: fullsolve/SKILL.md:38 grants Bash(./scripts/new-feature.sh:*). The body never invokes it, in either mirror. The permission was written for a call that was never added.

Evidence

Dogfood, 2026-08-05. Two /fullsolve sessions in ai-devtools-weekly on issues #10 and #23.

git worktree list shows zero sequant worktrees — only the main checkout, sitting on feature/10-distribution-measurement. The reflog is the incident, all in one working tree:

time (CDT) reflog entry
12:49:36 commit: chore(#10): drop stray #23 line committed to this branch by mistake
12:49:53 checkout: moving from feature/10-distribution-measurement to fix/issue-023-cloud-egress
12:50:25 commit (cherry-pick): chore(#23): strip unused connectors from the routine
12:58:05 checkout: moving from fix/issue-023-egress-clean to feature/10-distribution-measurement

Downstream damage in that session: a git reset clobbered the other session's branch, two commits were pushed onto the other session's PR branch, and an uncommitted RUNBOOK edit was destroyed by the other session's branch operations.

matcha-maps shows the milder form the same day — repeated checkout: moving from main to main from separate sessions, with fix/sentry-auth-token-doc-staleness created directly in the shared tree.

Which path ran: ai-devtools-weekly/.sequant/ contains only an empty locks/ — no state.json, no logs/, no pids/. So sequant locks acquire ran (fullsolve Phase 0.3) and sequant run never did. Positive evidence for the skill path, not an inference from absence.

The CLI path is unaffected. sequant run calls ensureWorktrees → ensureWorktree (src/lib/workflow/worktree-manager.ts:599) before setting SEQUANT_WORKTREE, which is what /exec's skip branch was written against. matcha-maps/.sequant/state.json shows 20 issues with real worktree paths, all from CLI runs.

Second failure mode: the glob can resolve into another repo

../worktrees/ is derived from the parent of the git root (src/lib/workflow/worktree-manager.ts:615, and identically scripts/new-feature.sh:103), so every repo under ~/Projects/ writes into one ~/Projects/worktrees/feature/ tree. new-feature.sh:404 already acknowledges this for the npm cache ("../worktrees/ is shared by every repo (#847)") — the consequence for worktree resolution was never followed through.

Both lookups key on issue number, which is per-repo and collides constantly:

  • fullsolve/SKILL.md:366 — export SEQUANT_WORKTREE=../worktrees/feature/<issue-number>-*/
  • exec/SKILL.md:483 — standalone path: "check if ../worktrees/ contains a directory for this issue"

~/Projects/worktrees/feature/ today, owner resolved via git rev-parse --git-common-dir per entry:

directory owning repo
9-create-solve-sequence-real-terminal-footage-with-p sequant-demo-video
10-create-result-and-cta-sequences-3-30-5-00 sequant-demo-video
35-qa-final-cross-browser-and-mobile-review portfolio-2025
125-onboarding-flow-ai-program-generation workout
145-sheet-save-load-named-campaigns ad-motion
578-seo-expand-city-coverage-to-20-cities matcha-maps

Five repos, one flat namespace. ai-devtools-weekly was working #9 and #10 on the same day; ../worktrees/feature/9-* and 10-* from that repo glob straight onto sequant-demo-video's directories.

A second reason the path name is not identity: 578-seo-expand-city-coverage-to-20-cities currently holds branch feature/578-city-expansion-clean. Slug and branch have already diverged, so a glob match tells you nothing about which branch you land on.

Creation is not the exposed surface — git worktree add onto an existing foreign path fails loudly. Resolution is. Same class as #881 (parallel-group marker filename was global across projects), fixed there by scoping per project.

Provenance — not a regression

Worth naming: #625 (2026-05-11) added the per-issue lock to fullsolve Phase 0.3 with the rationale at line 255 — "prevents a second session ... from racing". True for the same issue; for two different issues in one checkout it reads as coverage that isn't there. See #901.

Impact

  • Skill-driven /fullsolve has never had worktree isolation. Every such run has been executing in the main checkout.
  • Single-session runs degrade silently — no error, PR still opens — so the defect survived seven months undetected.
  • Concurrent sessions corrupt each other's branches, as above. Lost uncommitted work is unrecoverable.
  • The pre-tool worktree guard cannot help: with SEQUANT_WORKTREE unset-or-invalid there is nothing for it to enforce against.

Acceptance Criteria

  • AC-1: /fullsolve creates the feature worktree itself before Phase 2, via ./scripts/new-feature.sh <issue-number> (already granted in its frontmatter), rather than asserting /spec did it.
  • AC-2: Every SEQUANT_WORKTREE= export in fullsolve/SKILL.md carries a resolved absolute path; no * glob appears in any exported value.
  • AC-3: /exec halts with a named error when SEQUANT_WORKTREE is set but is not an existing directory, instead of continuing in the current directory.
  • AC-4: /exec halts when SEQUANT_WORKTREE resolves to a path absent from the current project's git worktree list, so a foreign or stale path cannot be adopted.
  • AC-5: /exec's standalone lookup resolves through git worktree list in the current repository instead of globbing ../worktrees/feature/<issue-number>-*.
  • AC-6: Lookup selects on the branch reported by git worktree list, not on the directory slug, so a directory whose name has diverged from its branch cannot be mis-selected.
  • AC-7: /fullsolve no longer claims /spec creates the worktree, and its Phase 1 post-state describes what actually happens.
  • AC-8: /spec states its worktree contract explicitly — planning runs in the main repo, the worktree is created by the orchestrator or /exec — restoring the line dropped by perf(spec): prompt compression and tiered context — reduce spec skill token cost by ~60% #515.
  • AC-9: Both skill mirrors (.claude/skills/, templates/skills/) carry identical changes.
  • AC-10: A regression test asserts the absence of a globbed SEQUANT_WORKTREE export in fullsolve and the presence of the existence guard in exec, scoped to the delimited region rather than the whole file, with a recorded mutation result per CLAUDE.md.
  • AC-11: A regression test creates a foreign worktree directory matching the issue-number glob and asserts the lookup does not select it, with a recorded mutation result per CLAUDE.md.

Non-Goals

Activity

  1. added
    bug
    on Aug 6, 2026
  2. changed the title [-]bug(fullsolve/exec): /fullsolve never creates the worktree it exports, so skill-driven runs execute in the main checkout[/-] [+]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[/+] on Aug 6, 2026
  3. admarble commented on Aug 6, 2026

    @admarble
    ContributorAuthor

    Plan (/spec) — #899

    Complexity: Complex (11 ACs, 3 directories)

    AC Quality Check

    All 11 ACs pass the linter — no vague, unmeasurable, incomplete, or open-ended patterns; no title/body tension. Behavior-rule detection ran on every AC: no triggers, so no Rule Touchpoints section.

    Two corrections to the issue text, surfaced rather than silently absorbed:

    1. AC-9 says "Both skill mirrors" — there are three. .claude/skills/ (canonical), templates/skills/, and skills/ (the published plugin). scripts/check-skill-sync.ts enforces all three. I will sync all three via npm run sync:skills; AC-9 is satisfied a fortiori.
    2. AC-11 needs an executable lookup to test. "Asserts the lookup does not select it" cannot be verified against LLM-interpreted SKILL.md prose. This drives the design decision below.

    Scope Assessment

    Non-Goals: present (5 items) — CLI run path untouched, SEQUANT_WORKTREE precedence unchanged, no re-layout of ../worktrees/, no checkout-scoped locking (#901).

    Metric Value Status
    Feature count 2 (clustered test / other) ⚠️
    AC items 11 ❌
    Directory spread 3 (src/, skills/, tests) ⚠️

    Verdict: ❌ SCOPE_SPLIT_RECOMMENDED — recommend overriding; do not split.

    The split signal is an artifact: the "2 features" clustering keys on the word test in AC-10/AC-11, which are the regression tests for this same fix, not a second feature. All 11 ACs land in two skills plus their mirrors and one new resolver. The issue already consolidated #900 into it on exactly this reasoning ("same two files, same mirrors, same PR"). Splitting would ship a guard without its creation step, or vice versa — a worse intermediate state than either end.


    Design Decision: one repo-scoped resolver, not six inline snippets

    AC-3 through AC-6 all reduce to one question: given this repo and this issue, which worktree? Three ways to answer it:

    Option AC-11 testable? Drift risk
    Inline bash in SKILL.md ❌ prose is not executable 6 copies (2 skills × 3 mirrors)
    New templates/scripts/*.sh ✅ consumer projects get it at scripts/dev/, not scripts/ — path breaks
    sequant worktree CLI subcommand ✅ single source of truth

    Chosen: a worktree CLI subcommand group, following the existing sequant locks pattern (src/commands/locks.ts + a bin/cli.ts command group). It reuses listWorktrees() (src/lib/workflow/worktree-manager.ts:367), which already parses git worktree list --porcelain and derives the issue number from the branch — precisely AC-6 — and which ready.ts:136 already uses for this same lookup. git worktree list only ever reports the current repo's worktrees, so AC-4/AC-5 scoping is structural, not a filter that can be forgotten. It also avoids the TS↔shell mirror drift class documented in #871.

    Known limitation, stated up front: listWorktrees() extracts the issue from feature/<N>-… only. new-feature.sh always produces that shape, so sequant-created worktrees always resolve. A hand-made fix/issue-023-… branch will not — and that failure is a halt (WORKTREE_NOT_FOUND), never a silent adoption, so it fails safe. Broadening the regex would change ready.ts semantics and is out of scope.


    Acceptance Criteria

    AC-1: /fullsolve creates the worktree itself before Phase 2

    Verification: Integration Test (skill-content gate)
    Scenario: Given fullsolve/SKILL.md → When the Phase 1.5 region is read → Then it invokes ./scripts/new-feature.sh <issue-number> (grant already in frontmatter line 38)
    Assumptions: new-feature.sh is idempotent — it exits 0 with "Worktree already exists" (line 132), so re-running on resume is safe.

    AC-2: No globbed SEQUANT_WORKTREE export

    Verification: Integration Test (gate, scoped to the export regions)
    Scenario: Given the three export SEQUANT_WORKTREE= sites (lines 366, 468, 537) → When each is read → Then the value is "$SEQUANT_WORKTREE" captured from sequant worktree resolve, containing no *

    AC-3: /exec halts on a non-existent SEQUANT_WORKTREE

    Verification: Integration Test (CLI) + skill-content gate
    Scenario: Given SEQUANT_WORKTREE=/no/such/dir → When sequant worktree verify runs → Then exit 1 with named error SEQUANT_WORKTREE_NOT_FOUND, and exec/SKILL.md:474 instructs halting rather than cd-and-continue

    AC-4: /exec halts on a foreign or stale path

    Verification: Integration Test
    Scenario: Given a real directory that is a worktree of a different repo → When verify runs in this repo → Then exit 1 with SEQUANT_WORKTREE_FOREIGN (realpath-compared against this repo's git worktree list)

    AC-5: standalone lookup resolves through git worktree list

    Verification: Integration Test + gate
    Scenario: Given standalone /exec → When it looks up the worktree → Then it calls sequant worktree resolve <issue>; the string ../worktrees/feature/<issue-number>-* no longer appears in the lookup region

    AC-6: selection keys on branch, not directory slug

    Verification: Integration Test
    Scenario: Given a worktree at …/899-old-slug whose branch is feature/899-renamed → When resolve 899 runs → Then it returns that path via the branch; and given a directory named 899-foo that is not a worktree, it is never returned

    AC-7: /fullsolve stops claiming /spec creates the worktree

    Verification: Integration Test (gate)
    Scenario: Given fullsolve/SKILL.md → When the Phase 1 description (line 293) and post-state (line 336) are read → Then neither attributes worktree creation to /spec

    AC-8: /spec states its worktree contract

    Verification: Integration Test (gate)
    Scenario: Given spec/SKILL.md → When read → Then it states planning runs in the main repo and the worktree is created by the orchestrator or /exec (restores the line dropped by #515)

    AC-9: all mirrors identical

    Verification: Integration Test — npm run lint:skill-sync (scripts/check-skill-sync.ts) exits 0 across all three roots

    AC-10: regression test for the skill text

    Verification: Integration Test, mutation-verified
    Scenario: Asserts (a) no * in any SEQUANT_WORKTREE= export in fullsolve, (b) the existence guard is present in exec — each scoped to its delimited region, per CLAUDE.md. Mutation: reintroduce the glob / delete the guard → confirm exactly that test fails → restore → record in the PR body.

    AC-11: regression test for foreign-worktree rejection

    Verification: Integration Test, mutation-verified
    Scenario: Given two real temp git repos, repo B has a worktree whose directory name matches repo A's issue-number glob → When resolve runs in repo A → Then repo B's path is not returned. Mutation: swap the lookup back to a filesystem glob → confirm this test fails → restore → record.


    Implementation Plan

    Phase 1 — Resolver (src/, bin/)

    1. Add src/commands/worktree.ts with two actions, modelled on src/commands/locks.ts:
      • sequant worktree resolve <issue> [--json] — listWorktrees() filtered on w.issue === issue. Exactly one match → print the absolute path on stdout and nothing else (clean $(…) capture). Zero → exit 1, WORKTREE_NOT_FOUND. More than one → exit 1, WORKTREE_AMBIGUOUS with candidates, so an ambiguous state is never silently resolved.
      • sequant worktree verify <path> [--issue <n>] [--json] — exit 1 with SEQUANT_WORKTREE_NOT_FOUND (missing / not a directory), SEQUANT_WORKTREE_FOREIGN (realpath absent from this repo's git worktree list), or SEQUANT_WORKTREE_ISSUE_MISMATCH (branch's issue ≠ --issue).
    2. Wire the worktree command group into bin/cli.ts next to locks (~line 724).

    Phase 2 — Skills (canonical .claude/skills/ only)

    1. fullsolve/SKILL.md: new Phase 1.5 — Create the feature worktree running ./scripts/new-feature.sh <issue> then capturing SEQUANT_WORKTREE="$(sequant worktree resolve <issue>)", halting if resolve fails (AC-1). Replace all three glob exports with the captured absolute path (AC-2). Drop "Create feature worktree" from the /spec bullet list and rewrite the Phase 1 post-state (AC-7). Also correct the stale "already done by /spec" line at 370.
    2. exec/SKILL.md: orchestrated branch (line 474) gains a mandatory sequant worktree verify "$SEQUANT_WORKTREE" --issue <n> gate that halts on failure instead of continuing in the current directory (AC-3, AC-4). Standalone lookup (line 482) replaces the ../worktrees/ glob with sequant worktree resolve (AC-5, AC-6). Add Bash(npx sequant worktree:*) to frontmatter.
    3. spec/SKILL.md: add the explicit worktree contract (AC-8).

    Phase 3 — Mirrors and tests

    1. npm run sync:skills → propagate to templates/skills/ and skills/; npm run lint:skill-sync to confirm (AC-9).
    2. src/commands/__tests__/worktree-resolve.integration.test.ts — real temp git repos, foreign-worktree and slug-divergence cases (AC-11, AC-6, AC-3, AC-4). Note: filename carries .integration. so it lands in the integration project, not the 5s-timeout unit project (fix(test): tsx-spawning integration tests blow vitest's 5s default — phase-registry should use the prebuilt dist like its five siblings #842).
    3. __tests__/integration/worktree-contract-skill.integration.test.ts — region-scoped skill-text gates (AC-10, AC-2, AC-7, AC-8), asserting across all three mirror roots.
    4. Mutation-verify tests 7 and 8; record results in the PR body per CLAUDE.md.

    Design Review

    1. Where does this logic belong? In the TypeScript layer, surfaced as a CLI verb. The skills are prompts; a rule they must enforce belongs in code they call, not in prose they interpret. This is the layer boundary the repo already draws for locks.
    2. Simplest correct approach? Reuse listWorktrees() rather than writing a new porcelain parser. Rejected: inline bash (untestable, six copies) and a new templates/scripts/*.sh (lands at scripts/dev/ in consumer projects, so the documented path is wrong there).
    3. Existing pattern? sequant locks — a small command group backed by a lib module, called from skill bodies. ready.ts:136 already does this exact listWorktrees().find(w => w.issue === n) lookup; this promotes it to a shared verb.
    4. What would a senior reviewer challenge? "Why a new CLI command for a docs bug?" — because AC-11 requires an executable lookup, and prose cannot be regression-tested. "Why not fix the glob and stop?" — a correct glob still resolves into a sibling repo; ../worktrees/ is one flat namespace across five repos today. Resolution scoping, not path shape, is the actual defect.

    Feature Quality Planning

    All standard checks pass. Notable items:

    • Idempotence on resume: /fullsolve can re-enter Phase 1.5 after a context restore. new-feature.sh already exits 0 when the worktree exists, and resolve is read-only, so re-entry is safe. Covered by test 7.
    • Fail-closed, not fail-open: every new failure mode halts. The bug being fixed is precisely a fail-open one — do not replace it with a lenient guard.
    • Consumer-project portability: the resolver is reached via sequant, which consumer projects have; it does not depend on scripts/ layout.

    Open Questions

    1. Broaden listWorktrees()'s feature/(\d+)- regex to also match fix/? — Recommendation: no, this pass. It would change ready.ts selection semantics for a case new-feature.sh never produces, and the unmatched case already fails safe (halt, not mis-adopt). Impact if wrong: a hand-named branch's worktree needs SEQUANT_WORKTREE set explicitly. Worth a follow-up issue if it bites.
    2. Should verify also warn when SEQUANT_WORKTREE is set but the shell is elsewhere? — Recommendation: out of scope; the pre-tool hook owns boundary enforcement once the path is valid.

    Recommended Workflow

    Phases: spec → exec → qa
    Quality Loop: enabled
    Reasoning: No UI surface, so no /test. Testgen skipped — bug label only, and AC-10/AC-11 already specify the tests concretely. Quality loop on: 11 ACs across a CLI addition plus three skill mirrors, with two mutation-verified gates to confirm.

    Label Review

    Current: bug
    Recommended: bug, no-browser-test
    Reason: No UI surface; the explicit opt-out keeps /test from being inferred on later re-runs.


  4. added
    planned
    no-browser-test
    on Aug 6, 2026
  5. admarble commented on Aug 6, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #899

    PR: #902 · Reviewed at: e0731316

    AC Coverage

    AC Source Description Status Notes
    AC-1 Original /fullsolve creates the worktree via ./scripts/new-feature.sh MET New Phase 1.5, region worktree-creation (#899). Literal check: invokes ./scripts/new-feature.sh <issue-number>, the exact command the AC names, and the grant at frontmatter line 38 is now actually used. Idempotence verified at new-feature.sh:132 — exit 0 on "Worktree already exists".
    AC-2 Original No * in any exported SEQUANT_WORKTREE value MET grep -rn "export SEQUANT_WORKTREE=" … | grep '\*' across all three mirrors → no matches. All 4 export sites carry "$SEQUANT_WORKTREE". The two surviving ../worktrees/feature/<issue>-* strings are inside "Never substitute a glob" / "Do not glob" prohibitions — prose, not exported values.
    AC-3 Original /exec halts on a non-existent path MET SEQUANT_WORKTREE_NOT_FOUND. Executed: worktree verify /no/such/dir → exit 1. Also rejects an unexpanded glob as a path. The skill region halts with exit 1 rather than falling through to cd.
    AC-4 Original /exec halts on a foreign or stale path MET SEQUANT_WORKTREE_FOREIGN. Executed against the shipped dist/ artifact: worktree verify /Users/tony/Projects --issue 899 → exit 1 with the named error. Test proves the harder case — a real worktree of another repo is rejected from repo A and accepted from repo B.
    AC-5 Original Standalone lookup resolves through git worktree list MET Region worktree-standalone-lookup (#899) calls sequant worktree resolve. The old "check if ../worktrees/ contains a directory for this issue" directive is gone; the only remaining mention is the prohibition.
    AC-6 Original Selection keys on branch, not directory slug MET listWorktrees() derives the issue from branch refs/heads/…. Test fixture is deliberately adversarial: directory 810-original-slug holding branch feature/810-renamed-after-the-fact resolves correctly, and a directory named 900-not-a-worktree that is not a worktree is never returned.
    AC-7 Original No longer claims /spec creates the worktree MET The - Create feature worktree bullet is gone; Phase 1 post-state now reads "Still in the main repository — no worktree exists yet". Also caught the stale companion claim at the orchestration table ("already done by /spec") and the workflow diagram.
    AC-8 Original /spec states its worktree contract MET New "Worktree Contract" section, region spec-worktree-contract (#899). Restores the "Planning happens in the main repository directory" line #515 dropped, and names both creators (orchestrator or /exec).
    AC-9 Original Mirrors carry identical changes MET npm run lint:skill-sync → 44 synced, 0 diverged, 0 missing. Note: the AC says "Both skill mirrors" — there are three. skills/ (the published plugin) sits alongside .claude/skills/ and templates/skills/, and scripts/check-skill-sync.ts enforces all three. All three updated; AC satisfied a fortiori.
    AC-10 Original Region-scoped skill-text regression test, mutation-verified MET __tests__/integration/worktree-contract-skill.integration.test.ts, 24 tests (8 × 3 roots). Mutation results below.
    AC-11 Original Foreign-worktree rejection test, mutation-verified MET src/lib/workflow/worktree-resolver.integration.test.ts, 11 tests over two real temp git repos. Mutation results below.

    Coverage: 11/11 AC items fully met
    Derived ACs: none — the /spec plan produced no Derived ACs table


    Quality Plan Verification

    Dimension Items Planned Items Addressed Status
    Completeness 3 3 ✅ Complete
    Error Handling 1 (fail-closed on every new mode) 1 ✅ Complete
    Code Quality 1 (single source of truth, no TS↔shell mirror) 1 ✅ Complete
    Test Coverage 2 (both mutation-verified) 2 ✅ Complete
    Best Practices 1 (consumer-project portability) 1 ✅ Complete
    Polish N/A N/A – (not a UI feature)

    Quality Plan Status: Complete

    The plan's three named concerns all hold up: re-entry is safe (new-feature.sh is idempotent and resolve is read-only); every new failure mode halts rather than degrading; and the resolver is reached via sequant, not a scripts/ path that differs in consumer projects.


    Precheck Findings

    Precheck Findings: unavailable — inline fallback used.


    CI Status

    Check State Bucket Impact
    typecheck SUCCESS pass ✅ MET
    build (22.x) SUCCESS pass ✅ MET
    validate-skills SUCCESS pass ✅ MET
    validate-plugin SUCCESS pass ✅ MET
    Plugin Structure Validation SUCCESS pass ✅ MET
    Hooks Validation SUCCESS pass ✅ MET
    node-floor-guard SUCCESS pass ✅ MET
    Setup Directory Creation SUCCESS pass ✅ MET

    CI Summary: 8 passed, 0 pending, 0 failed
    CI-related AC items: none of the 11 ACs is CI-gated


    Quality Metrics

    Metric Value Status
    Type issues (any) 0 OK
    Deleted tests 0 OK
    Files changed 16 OK
    Lines added +1154 –
    Lines deleted −61 –

    The +1154 overstates the change: the three skill mirrors are byte-identical copies, so ~450 of those lines are the same content written three times.


    Size Gate

    Diff is 1154 lines — well over the 100-line threshold, so SMALL_DIFF=false and the standard pipeline applies. Code review was performed inline rather than via sub-agents: the substantive diff is ~400 unique lines (the mirrors triple it), and delegating worktree-resident review is the known-hallucination path.


    Build Verification

    N/A — build passed (npm run build, tsc clean).


    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    src/lib/workflow/worktree-resolver.ts Standard ✅ Yes worktree-resolver.integration.test.ts (11)
    src/lib/workflow/worktree-manager.ts Standard ✅ Yes run.test.ts + the new resolver suite exercises listWorktrees(cwd)
    src/commands/worktree.ts Standard ⚠️ Indirect Thin Commander wrapper; logic lives in the tested resolver. Both actions smoke-tested against the built dist/ artifact — see Execution Evidence.
    bin/cli.ts Standard ✅ Yes --help output verified; validate-plugin + typecheck green
    9 × SKILL.md Standard ✅ Yes worktree-contract-skill.integration.test.ts (24, across all 3 roots)

    Coverage: 4/5 changed source files have direct tests; the fifth is a wrapper whose logic is covered and whose surface is smoke-tested.
    Critical paths without tests: none — no auth/payment/security/middleware paths touched.


    Code Review

    Strengths:

    • The fix targets resolution, not path shape. Correcting the glob alone would still have let one repo's lookup land on a sibling's worktree. Routing through git worktree list makes repo-scoping structural — there is no filter to forget.
    • Reuses listWorktrees() rather than writing a second porcelain parser. ready.ts:136 already performed this exact find(w => w.issue === n) lookup; this promotes it instead of duplicating it. Avoids the TS↔shell mirror-drift class (PM_CONFIG.yarn.ciInstall uses Yarn 2+ --immutable, which Yarn 1 rejects — no berry detection exists #871) that six inline bash copies would have created.
    • Fails closed everywhere. Five named errors, all halts. Given the defect being fixed was a fail-open one, this is the right instinct rather than over-caution.
    • WORKTREE_AMBIGUOUS is a nice catch — two worktrees claiming one issue is resolvable-looking but not safely resolvable, and it errors instead of picking one.
    • Region markers make the gate tests honest. region() throws when a marker is absent, so deleting the markers fails loudly rather than degrading the assertion to a match on "".

    Issues:

    • None blocking.

    Suggestions:

    • canonicalize() recurses on the parent path for not-yet-existing paths. Correct, and bounded by the filesystem root — but it duplicates intent with the symlink-resolution fix in 7a0d9e7. Worth consolidating if a third caller appears.

    Test Quality Review

    Category Status Notes
    Behavior vs Implementation ✅ OK Assert on returned paths/branches/error codes, never on internals
    Coverage Depth ✅ OK Both directions of the foreign case (rejected from A, accepted from B), slug-vs-branch divergence, look-alike non-worktree directory, empty/glob/missing/mismatch inputs
    Mock Hygiene ✅ OK No mocks. Real git init + git worktree add in a temp sandbox — correct, since the entire claim is about what git worktree list reports
    Test Reliability ✅ OK Deterministic; hermetic git config (user.email, commit.gpgsign=false) avoids the recurring gpg-signing breakage class

    The suite's afterAll carries an explicit comment pinning sandbox as assign-once so a future mutation pass cannot redirect its rmSync — a direct guard against the destructive-mutation incident in #883.


    Anti-Pattern Detection

    Dependency Audit: N/A — package.json unchanged.

    Code Patterns: no findings. No await-in-loop, no empty catch, no hardcoded secrets, no SQL concatenation, no uncleared timers. The two bare catch {} blocks in canonicalize() are intentional control flow (probe-and-fall-back on a path that may not exist), not swallowed errors.

    Critical Issues: 0 · Warnings: 0


    Call-Site Review

    New exported functions detected: 5

    Function Call Sites Loop? Conditions AC Match
    resolveIssueWorktree() src/commands/worktree.ts:50 No none ✅ AC-5/AC-6
    verifyWorktreePath() src/commands/worktree.ts:103 No --issue optional ✅ AC-3/AC-4
    worktreeResolveCommand() bin/cli.ts:804 No .action() ✅ AC-1
    worktreeVerifyCommand() bin/cli.ts:813 No .action() ✅ AC-3
    listWorktrees(cwd?) ready.ts:136, ready.ts:226, resolver ×2 No – ✅ Signature change is additive

    Findings: No dead exports. The listWorktrees signature change is the one back-compat risk, and it is safe: cwd is optional and both pre-existing ready.ts callers pass nothing, preserving the process.cwd() default. ready.test.ts mocks it with vi.fn(), which is indifferent to arity. Confirmed green in the full suite.


    Execution Evidence

    Test Type Command Exit Code Result
    Resolve (hit) node dist/bin/cli.js worktree resolve 899 0 Bare absolute path on stdout — clean $(…) capture
    Resolve (miss) worktree resolve 12345 1 WORKTREE_NOT_FOUND + remediation
    Verify (missing) worktree verify /no/such/dir 1 SEQUANT_WORKTREE_NOT_FOUND
    Verify (glob) worktree verify '../worktrees/feature/899-*/' 1 SEQUANT_WORKTREE_NOT_FOUND: unexpanded glob
    Verify (foreign) node dist/bin/cli.js worktree verify /Users/tony/Projects --issue 899 1 SEQUANT_WORKTREE_FOREIGN
    Verify (ok) worktree verify "$(pwd)" --issue 899 0 ✓ <path> (feature/899-…)
    Verify (mismatch) worktree verify "$(pwd)" --issue 42 1 SEQUANT_WORKTREE_ISSUE_MISMATCH
    Help worktree --help 0 Both subcommands and all flags listed

    Evidence status: Complete — run against the built dist/ artifact this PR ships, not only via tsx.


    Script Verification (§11)

    Not Required — no files under scripts/ or templates/scripts/ were modified. scripts/new-feature.sh is invoked by the new skill text but is unchanged.


    Skill Command Verification

    Skill files changed: 9 (3 skills × 3 mirrors)

    File Commands Found Verification Status
    fullsolve/SKILL.md 3 ✅ Passed
    exec/SKILL.md 2 ✅ Passed
    spec/SKILL.md 0 (prose only) ✅ N/A

    Commands Verified:

    • ./scripts/new-feature.sh 899 → ✅ executed; created the worktree this PR was built in
    • npx sequant worktree resolve 899 → ✅ exit 0, printed the absolute path
    • npx sequant worktree verify "$PATH" --issue 899 → ✅ exit 0 valid / exit 1 with each named error
    • npx sequant locks release <issue> → ✅ subcommand exists (pre-existing, unchanged)

    Commands with Issues: none.

    One honest observation on invocation form: the bare global binary (/opt/homebrew/bin/sequant → the main repo's dist/) currently answers error: unknown command 'worktree', because main has not been rebuilt with this PR. npx sequant worktree … — the form the skills actually use — resolves correctly and exits 0. This is a dev-environment artifact of reviewing pre-merge, not a product defect: skills and the CLI ship in the same npm package, so any project that has the new skill text necessarily has the new CLI. Worth knowing when testing this branch locally.

    Verification Status: Passed


    Detection Pattern Verification

    Omitted — precondition false. The added lines in the changed skill markdown introduce no grep/awk/jq/sed command and no regex literal; the diff-hunk gate returned empty.


    CLI Registration Verification

    Option files modified: bin/cli.ts (new command group). RunOptions untouched.

    Interface Field Runtime Usage CLI Registered Status
    WorktreeResolveOptions.json options.json (worktree.ts:53) --json on worktree resolve ✅ OK
    WorktreeVerifyOptions.issue options.issue (worktree.ts:96) --issue <issue> on worktree verify ✅ OK
    WorktreeVerifyOptions.json options.json (worktree.ts:106) --json on worktree verify ✅ OK

    Verification Status: Passed — every field with runtime usage has a matching .option(). Confirmed live via --help.


    Skill Change Review

    • Command verified: executed ./scripts/new-feature.sh, sequant worktree resolve, sequant worktree verify — all four subcommand paths
    • Fields verified: no JSON-field-dependent commands added; --json output shapes are this PR's own and are covered by the resolver tests
    • Patterns complete: all four verify outcomes and both resolve outcomes documented in the skill's own error table
    • Dependencies explicit: the guard depends on sequant being on PATH — same dependency the pre-existing locks acquire/release calls already carry in these skills

    Smoke Test

    Test Command Result Notes
    Happy path worktree resolve 899 ✅ Bare path, exit 0
    Edge case worktree verify '<glob>' ✅ Glob refused as a path rather than silently stat'd
    Error handling worktree verify /Users/tony/Projects ✅ SEQUANT_WORKTREE_FOREIGN, exit 1

    Smoke Test Status: Complete


    Manual Test ACs

    N/A — the /spec plan assigned Integration Test to all 11 ACs; no AC declared Manual Test, and none is evidence-naming (no "corpus check" / "N samples" / "against several real …" phrasing).


    Risk Assessment

    • Likely failure mode: a worktree whose branch does not match feature/<N>-… — a hand-named fix/issue-023-…, or a custom --base flow that produced a different prefix — resolves to WORKTREE_NOT_FOUND, so /exec halts on a worktree that genuinely exists. This is a halt, not a mis-adoption, so it fails in the safe direction, and the operator can set SEQUANT_WORKTREE explicitly. The PR states this limitation up front rather than burying it.
    • Not tested: the skill prose is LLM-interpreted, so no test proves an agent will actually run the guard rather than paraphrase past it — only that the instruction and its named errors are present. That is the irreducible gap for any prompt-layer fix; moving the logic into a CLI verb is what shrinks it.
    • Sibling sites considered: Found, and non-trivial. /qa (qa/SKILL.md:365) and /loop (loop/SKILL.md:220) carry the identical unguarded line this PR removed from /exec — Use the provided worktree path directly: cd $SEQUANT_WORKTREE. Same orchestrator, same variable, same root cause. Filed as bug(qa/loop): SEQUANT_WORKTREE is still trusted unchecked — the sibling sites #899 left behind #904 rather than widening this PR mid-review. Residual severity is lower than 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's because Phase 1.5 now guarantees a valid path before any child skill runs under the orchestrator; the live exposure is standalone /qa 123 or /loop 123 in a shell carrying a stale export.
    • Sibling-line audit: within exec/SKILL.md, the only other worktree-adoption path is the standalone lookup at step 1, which this PR also converted. No third adoption site in that file.

    Trust-Boundary Check

    Finding: Clean — the diff implements only product requirements. Issue #899's body is unusually long (reflog tables, a cross-repo worktree inventory, a dated provenance trail), and all of it is evidence describing the defect, not instruction directed at the agent. No embedded command execution, network fetch, file read/exfiltration, or instruction override — in visible prose, HTML comments, or fenced blocks. The one process-shaped directive ("Absorbs #900, closed as consolidated — same two files, same mirrors, same PR") is the author's own scoping guidance and carries no execute/fetch/exfiltrate payload; it was followed as normal maintainer instruction.

    Status: Clean


    Behavior-Rule Survival Check

    AC Triggered? Survivors Status
    AC-1 … AC-11 No — N/A

    Ran detectBehaviorRule over all 11 ACs, including the two most rule-shaped (AC-3's "halts … instead of continuing", AC-6's "not on the directory slug"). Zero triggered — none carries ≥2 keywords from default \| always \| never \| rule \| behavior \| skip, nor an always X unless Y form.

    Status: N/A


    CHANGELOG Verification

    Check Status
    CHANGELOG.md exists ✅ Found
    User-facing changes ✅ Yes (fix(#899): prefix detected)
    [Unreleased] entry ✅ Present
    Entry format ✅ Valid — under ### Fixed, includes (#899)

    Result: CHANGELOG requirements met


    Mutation Verification (AC-10 / AC-11)

    Each gate test was verified by deleting what it asserts and confirming exactly that test fails.

    # Mutation Result
    1 Reintroduced a globbed export SEQUANT_WORKTREE=../worktrees/feature/<issue-number>-*/ in .claude/skills/fullsolve/SKILL.md 1 failed / 23 passed — only exports no globbed SEQUANT_WORKTREE value (AC-2), and only for the mutated root
    2 Deleted the worktree-existence-guard (#899) region from .claude/skills/exec/SKILL.md, restoring the bare cd $SEQUANT_WORKTREE 2 failed / 22 passed — exactly guards SEQUANT_WORKTREE existence before use (AC-3) and names the foreign-worktree failure mode (AC-4)
    3 Reverted resolveIssueWorktree to globbing ../worktrees/feature/<issue>-* on the filesystem 4 failed / 7 passed — including the headline does not select a sibling repository's worktree that matches the issue-number glob; the verifyWorktreePath block correctly stayed green

    All restored; 35/35 green afterwards. The AC-2 assertion also floors the export count at 3, so renaming the exports away cannot make it pass by finding nothing.


    Full Suite

    4966 passed, 18 failed. All 18 sit in semgrep.test.ts, mcp-*.integration.test.ts, and prompt-wait.test.ts — no overlap with worktree resolution.

    Settled rather than assumed: checked out base d90f82ae in the same worktree and re-ran those five files. Base produced 2 failed files / 4 failed tests; this branch produced the identical 2 failed files / 4 failed tests (semgrep ×3 pre-existing, plus one rotating flake inside mcp-serve.integration.test.ts — SIGTERM at base, health-check on branch). The extra failures seen 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.


    Adversarial Re-Read

    Findings:

    1. Sibling sites in /qa and /loop (the substantive one). Grepped every skill for cd $SEQUANT_WORKTREE and found the exact line 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 removed from /exec still live at qa/SKILL.md:365 and loop/SKILL.md:220. Both receive SEQUANT_WORKTREE from the same orchestrator. Filed as bug(qa/loop): SEQUANT_WORKTREE is still trusted unchecked — the sibling sites #899 left behind #904.
    2. Fixtures. Issue 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 supplies no verbatim repro command — its evidence is a reflog table and a cross-repo directory inventory. Both were converted into executable fixtures rather than quoted: the two-repo shared-worktrees/ layout is reconstructed literally in the test sandbox, and the real-world slug/branch divergence it cites (578-seo-expand-city-coverage holding feature/578-city-expansion-clean) is reproduced as the AC-6 case.
    3. Evidence-vs-repro audit. Checked that no "evidence" in the PR body is a pre-fix bug reproduction dressed as post-fix validation. All eight Execution Evidence rows were run against the built dist/ artifact after the fix, and each mutation result is a post-fix demonstration that the test detects the regression.
    4. Process state. Working tree clean at review time; branch is 0 commits behind origin/main; no stashes; no uncommitted residue from the three mutation passes (git status --short empty after each restore).
    5. Non-Goals. All four honored. Checked the one with real teeth — "Not changing SEQUANT_WORKTREE precedence — it stays authoritative when set and valid." It does: a valid value is used unchanged; only an invalid one now halts instead of being silently ignored, which is the AC's own requirement rather than a precedence change. sequant run's ensureWorktree path is untouched, and ../worktrees/ was not re-laid-out.
    6. Trust boundary. Covered above — clean.

    Status: Gaps Found — finding (1) is a real cross-file sibling that maps to follow-up #904, not to a missing AC fixture.


    Verdict: AC_MET_BUT_NOT_A_PLUS

    All 11 acceptance criteria are MET, each verified literally against its text rather than its intent, and both mutation-verified gates behave correctly under deletion. CI is fully green (8/8). The design is the right one: it fixes resolution rather than path shape, which is what actually closes the cross-repo failure mode, and it does so in one tested CLI verb instead of six copies of inline bash across the mirrors.

    The verdict is gated below READY_FOR_MERGE by the adversarial re-read (§6d, Gaps Found), for one reason: /qa and /loop still carry the identical unguarded cd $SEQUANT_WORKTREE that this PR removed from /exec. That is out of scope for #899's ACs — they name /exec only — and correctly left to #904 rather than widening the PR mid-review. But it means the class of defect is not fully closed at the end of this PR, and the review should say so rather than round up.

    Per the break-don't-loop rule, AC_MET_BUT_NOT_A_PLUS is a break to PR, not a /loop trigger. PR #902 is ready for human review and merge; #904 tracks the remainder.

    Documentation

    • CHANGELOG entry added (### Fixed, [Unreleased], includes (#899))
    • Skill files are self-documenting — the new error table lives in exec/SKILL.md beside the guard
    • N/A — no README/docs/ change needed; sequant worktree is an internal verb for skill bodies, not a user-facing workflow command

    Next Steps

    1. Human review and merge PR fix(#899): create the worktree in /fullsolve, verify it in /exec #902.
    2. Rebuild main after merge so the globally-linked sequant picks up the worktree command.
    3. Address bug(qa/loop): SEQUANT_WORKTREE is still trusted unchecked — the sibling sites #899 left behind #904 to close the same defect class in /qa and /loop.

  6. added a commit that references this issue on Aug 6, 2026
  7. admarble commented on Aug 6, 2026

    @admarble
    ContributorAuthor

    QA Re-Review for Issue #899 — after gap closure

    PR: #902 · Reviewed at: 90a84f53b8e33835f2bbec8461e2c2bb2e7954bb · Supersedes the prior verdict of AC_MET_BUT_NOT_A_PLUS

    The prior review's single gating finding was the cross-file sibling sites (§5 / §6d "Gaps Found"), filed as #904. That gap is now closed in this PR, and the sweep found more than #904 named.

    What changed since the last review

    Site Defect Fixed
    /qa, /loop Unguarded cd $SEQUANT_WORKTREE Verify gate + halt
    /qa, /loop, /testgen Globbed ../worktrees/feature/<issue>-* worktree resolve
    /merger ×2 grep "feature/$ISSUE" then worktree remove --force worktree resolve
    /qa Phase 0 Bare-number grep -i gating the implementation probe worktree resolve
    /assess Same prefix match, read-only probe worktree resolve

    Two of these were more severe than #904 described: /merger's force-remove (a slug collision destroys an unrelated issue's worktree — ISSUE=89 matches feature/899-…) and /testgen's glob (it writes stubs into whatever tree it lands in).

    Sibling-site scan — now clean

    The prior review's §5 finding is resolved. Re-ran the sweep: no skill in any mirror carries an unguarded cd $SEQUANT_WORKTREE, and no skill globs ../worktrees/ or greps git worktree list for an issue number. This is no longer asserted by inspection — two completeness invariants enforce it across every skill, so a future skill reintroducing either pattern fails the build. Pinning the six known sites would not have held; the pattern reached six skills by being copied.

    Additional mutation results

    # Mutation Result
    4 Removed /qa's guard region 2 failed / 49 passed — per-skill test and the invariant both fired
    5 Appended a glob to /docs, a skill in no pinned list 1 failed / 50 passed — invariant named docs:; this is the case pinning could never catch
    6 Restored /merger's grep 1 failed / 50 passed — invariant named merger:

    All restored; 62/62 green.

    Verification

    Gate Result
    Full test suite 237/237 files, 5011 passed, 0 failed
    CI on #902 8/8 SUCCESS
    lint / lint:skill-sync / lint:skill-calls / lint:skill-gates all clean
    Build passes

    On the full suite: it is now completely green. The 18 failures in the prior review (semgrep, MCP, prompt-relay) did not recur — consistent with the base-commit comparison that showed base and branch failing identically, i.e. concurrency-load flakes rather than regressions.

    One CI note, for the record: validate-skills first reported FAILURE on this commit. Reading the log rather than trusting the status: the job died in Set up job with Failed to resolve action download info. Error: Service Unavailable — GitHub infrastructure. validate:skills never executed. It passes locally (19/19 skills valid) and passed on re-run. Not a code defect.

    AC Coverage

    Unchanged: 11/11 MET. The gap fixes touch no #899 AC — they extend the same fix to skills outside its scope. The AC-10 gate test grew from 24 to 51 assertions and all pre-existing ones still pass.

    Trust-Boundary Check

    Finding: Clean — no agent-directed instruction from external text was acted on.

    Status: Clean

    Adversarial Re-Read

    Findings: The prior review's one finding is closed, and closing it surfaced three sites that review had missed (/testgen, /merger ×2, /qa Phase 0) plus one false positive worth recording: /assess's grep "^worktree" looks like the same pattern but enumerates every worktree and keys on nothing, so it is correct code and is deliberately exempted. Re-swept for further siblings after the fix — none remain, and the invariants now hold that line mechanically rather than by inspection. Process state clean (working tree empty after all six mutations, branch 0 behind origin/main). Non-Goals still honoured.

    Status: Clean

    Verdict: READY_FOR_MERGE

    All 11 ACs met, the sibling-site gap that gated the prior verdict is closed, the full suite and CI are green, and six mutations confirm the gates detect what they claim. The completeness invariants make this stronger than the ACs asked for: the defect class is now closed against future reintroduction, not just at the six sites where it existed.

    #904 is absorbed and closed.


  8. added a commit that references this issue on Aug 6, 2026
  9. added a commit that references this issue on Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugno-browser-testplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions