You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(hooks): new-feature.sh bypasses the checkout guard — the script the block message recommends mutates the main checkout #910
Found during adversarial validation of #906 (Design v2, "Adjacent defects"). A #901 gap. Verified against main at e2e57a7c.
Bug
The checkout guard in pre-tool.sh inspects only the top-level Bash command string the agent runs. ./scripts/new-feature.sh <issue> contains no guarded git verb, so the guard passes it through — and then the script runs, internally, in the main checkout:
A session that does not hold the checkout lock can therefore switch the main checkout's branch out from under the holder, which is precisely what #901 exists to prevent. The guard's own refusal message even recommends ./scripts/new-feature.sh <your-issue> as the way to proceed — so the documented escape hatch is the bypass.
Severity
Moderate. It needs two concurrent sessions, but the path is not exotic: it is the one the block message tells the loser to take.
Fix options
Guard inside the script. Have new-feature.sh consult the checkout lock itself (sequant locks checkout check) and refuse when held by another session. Keeps enforcement next to the mutation, and covers direct terminal invocations the hook never sees. Needs the script to stay usable when the CLI is absent.
Avoid the mutation.git worktree add does not require the main checkout to be on the base branch; git worktree add -b <new> <path> <base-ref> reads the ref directly. If line 148 exists only to make the subsequent worktree add resolve, removing it closes the gap outright and is strictly better — no lock needed for an operation that no longer touches the main tree.
Extend the hook to resolve known project scripts and inspect their contents — rejected: fragile, and it cannot see through arbitrary indirection.
Option 2 first if it holds; option 1 as the general backstop for other scripts.
Test plan
Hold the checkout lock as session A; run ./scripts/new-feature.sh as session B; assert the main checkout's HEAD is unchanged.
Assert the guard still allows the script when the lock is free or held by the caller.
If option 2: assert worktree creation still works with the main checkout sitting on an unrelated branch with a dirty tree.
#910 — fix(hooks): new-feature.sh bypasses the checkout guard — the script the block message recommends mutates the main checkout
Open · bug
────────────────────────────────────────────────────────────────
→ PROCEED — Bypass confirmed on main at 5a68930 — new-feature.sh:148 runs git checkout "$BASE_BRANCH", and pre-tool.sh:679 recommends that script in the refusal message
Commands:
sequant run 910 -Q
spec → exec → qa
Flags:
-Q changes the worktree provisioning path every consumer uses; a wrong call here breaks new-feature.sh for all issues
Considered:
--testgen bug-only label; testgen skips bug/fix issues even though the body carries a Test plan
--security-review no security/auth label — a guard bypass, but process isolation rather than authz
────────────────────────────────────────────────────────────────
⚠ Body has zero - [ ] checkboxes — spec must derive ACs from the Fix options / Test plan; --strict-preflight would hard-stop this issue
⚠ Preferred fix option 2 removes the git checkout from new-feature.sh entirely — verify git worktree add still resolves the base ref with the main checkout sitting on an unrelated, dirty branch before committing to it, and keep option 1 as the fallback
⚠ Fix option 1 would have the script shell out to sequant locks checkout check; that path inherits #909's cwd-relative locks-dir bug, so prefer option 2 or sequence behind #909
────────────────────────────────────────────────────────────────
Complexity: Standard (4 derived ACs, 2 directories)
The issue ships no - [ ] AC block; ACs below are derived from the Test plan + Fix options in the body.
Scope Assessment
Non-Goals: Not stated. Implicit: this fixes new-feature.sh only. The general "every script that mutates the main tree" backstop (fix-option 1) belongs to sibling #911 (/merger, /release) — do not widen #910 into it.
Metric
Value
Status
Feature count
1
OK
AC items
4 (derived)
OK
Directory spread
2 (templates/scripts/, __tests__/)
OK
Verdict: SCOPE_OK — localized fix.
Design decision: Option 2 confirmed, and strictly better
resolveBaseRef (src/lib/workflow/phase-executor.ts:719) resolves the downstream comparison ref to origin/<base>, never local main. So line 148's checkout + line 149's pull exist only to make the local HEAD equal the base before an argless git worktree add -b. Branching the worktree directly from the freshly-fetched remote ref does the same job and eliminates any local-vs-origin drift — the worktree is created from exactly the ref the zero-diff guard later compares against.
Consequences that make the fix cohesive rather than a one-liner:
The --stash / dirty-tree guard (lines ~128-140) exists solely because line 148 was about to switch branches.git worktree add ... <ref> never touches the main working tree, so a dirty main tree is now irrelevant. The guard's exit 1 must stop blocking (Test-plan bullet 3 requires creation to succeed with a dirty main tree on an unrelated branch).
The hook needs no change.pre-tool.sh:679 recommends ./scripts/new-feature.sh <your-issue> as the way out; option 2 makes that recommendation genuinely safe, which resolves the bug's core irony (the documented escape hatch was the bypass).
Edit templates/scripts/new-feature.sh — scripts/new-feature.sh is a symlink to it.
Fix-option 1 (in-script sequant locks checkout probe) becomes moot for this script: an operation that no longer touches the main tree needs no lock. Leave the general backstop to #911.
Acceptance Criteria
AC-1: new-feature.sh performs no branch-mutating git in the main checkout. Verification: Integration Test Scenario: Given a repo whose main checkout is on branch X at commit C -> When ./scripts/new-feature.sh <issue> runs and succeeds -> Then the main checkout is still on X at C (HEAD ref + SHA unchanged). No branch-switching or pull against the main tree remains in the script.
AC-2: The worktree is created from the fresh remote base ref, and sequantBase is still recorded. Verification: Integration Test Scenario: Given origin/$BASE_BRANCH advanced beyond local $BASE_BRANCH -> When the script runs -> Then the new worktree's HEAD equals origin/$BASE_BRANCH (latest base preserved without a local pull), and git -C <worktree> config branch.<branch>.sequantBase equals $BASE_BRANCH (unchanged, so resolveBaseRef keeps working).
AC-3: Worktree creation succeeds with the main checkout on an unrelated branch and a dirty tree. Verification: Integration Test Scenario: Given the main checkout on an unrelated branch with uncommitted (and untracked) changes, no --stash -> When the script runs -> Then it exits 0, the worktree is created, and the main tree's uncommitted changes are untouched (no stash, no blocking exit 1).
AC-4: The checkout-guard escape hatch is now safe (regression pin). Verification: Integration Test Scenario: Given session A holds .sequant/locks/checkout.lock -> When session B runs ./scripts/new-feature.sh <B-issue> -> Then the main checkout's HEAD is unchanged (the action pre-tool.sh:679 recommends no longer races the holder). Existing guard behavior (block a non-holder's direct branch-switch in the main tree; allow it for the holder or a free lock) is unchanged.
Implementation Plan
Phase 1 — Fix the script (templates/scripts/new-feature.sh)
Replace lines 146-149 (fetch / checkout / pull) with: git fetch origin "$BASE_BRANCH" then base the worktree on the remote ref — git worktree add "$WORKTREE_DIR" -b "$BRANCH_NAME" "origin/$BASE_BRANCH". Keep the sequantBase config write (line 159) as-is.
Neutralize the dirty-tree guard (lines ~128-140): a dirty main tree no longer blocks. Keep parsing --stash (accept it as a harmless no-op / optional convenience) so existing invocations and docs don't error — see Open Question 1.
Confirm no other main-tree mutation remains: grep -nE 'git (checkout|switch|reset|rebase|merge|cherry-pick|pull)' over the script should show only worktree-scoped git -C usage. (Sibling scan already done: lines 148-149 were the only sites.)
Phase 2 — Tests (extend __tests__/new-feature-frozen-install.integration.test.ts, or a sibling new-feature-checkout-isolation.integration.test.ts)
4. Add integration cases for AC-1..AC-4 driving the real script against a temp git repo.
5. Mutation-verify each gate test (CLAUDE.md testing rule): revert the script's fix, confirm exactly the intended test fails, restore, and record the result in the PR body. Otherwise a test that passes on the old script proves nothing.
Design Review
Where does this logic belong? In templates/scripts/new-feature.sh — the mutation site. No TypeScript change; resolveBaseRef already keys off origin/<base>, so it's forward-compatible by construction.
Simplest correct approach? Pass the remote ref as git worktree add's start-point and drop the now-purposeless checkout/pull/dirty-guard. Rejected: fix-option 1 (in-script lock) — unnecessary once the mutation is gone, and it's fix(skills): /merger and /release mutate the main checkout without participating in the checkout lock #911's job. Rejected: fix-option 3 (teach the hook to read script contents) — the issue already rejects it as fragile.
Existing pattern? Worktree-scoped git -C <worktree> is already used in this same script (line 159) and across the codebase — this extends the "never touch the main tree" discipline to the creation step.
What would a senior reviewer challenge? "Does branching from origin/$BASE_BRANCH change the base a worktree gets?" — Yes, and correctly: it's the ref the downstream guard already uses; the old local-pull was a redundant, mutation-heavy way to reach the same SHA. "Local-only base branch?" — already unsupported (current git fetch origin "$BASE_BRANCH" fails under set -e), so no regression; see Open Question 2.
Open Questions
--stash fate. Recommendation: keep the flag accepted (no error) but no longer required; a dirty main tree just works. Impact if dropped entirely: existing docs/scripts passing --stash would hit "unknown arg". Low-risk either way — I lean "accept-and-ignore (still stashes if passed, harmless)".
Base ref for a local-only --base. Recommendation: resolve to origin/$BASE_BRANCH (matches resolveBaseRef). Impact: a base branch that exists only locally is unsupported — but it already is today (git fetch origin <base> fails first). Flagging so the fix doesn't silently claim to add local-base support.
Recommended Workflow
Phases: exec -> qa Testgen: skip (bug label; targeted integration tests written in exec) Quality Loop: disabled (SCOPE_OK, localized) Reasoning: Focused bug fix in one shell script + its integration tests. Verification is script-execution (integration), no unit-stub surface. Consider /verify after exec to capture real script output per the CLI/script-feature convention.
Label Review
Current:bug Recommended:bug, planned (added by this phase) Reason: No UI/refactor/complex signal. Quality loop stays off.
new-feature.sh no longer mutates the main checkout. The base-branch update flow — git fetch <base> → git checkout <base> → git pull — is replaced by a single git fetch origin <base> followed by git worktree add -b <branch> <path> origin/<base>, which branches the new worktree directly off the freshly fetched remote ref without ever touching the main tree. This is the issue's option 2, chosen over teaching the hook to see through the script (option 3, rejected as fragile).
Because the main working tree is no longer switched or pulled, the pre-#910 dirty-tree guard is gone and --stash is now a deprecated no-op (still accepted for backward compatibility). No pre-tool.sh change was needed — the guarded operation no longer exists.
AC / test-plan coverage
Item
Status
Evidence
Main checkout HEAD unchanged when script runs without the lock
✅ Implemented
Script never touches the main tree; gate test asserts branch + HEAD unchanged
Guard still allows the script (lock free / held by caller)
✅ Implemented
No hook change; script runs no guarded verb so the guard never engages
(opt 2) Worktree creation works from a dirty, unrelated-branch main checkout
✅ Implemented
Dedicated dirty-tree test; dirty changes left untouched
Files changed
templates/scripts/new-feature.sh — replace checkout/pull with worktree add … origin/<base>; --stash → deprecated no-op (scripts/new-feature.sh is a symlink to this)
__tests__/new-feature-checkout-guard.integration.test.ts — new gate test (4 cases)
npm run build ✅ · npm run lint ✅ · 103/103 tests pass across the 4 new-feature/worktree integration files
Gate test mutation-verified: reintroducing git checkout <base> + git pull fails Test A (main branch flips to main) and Test C (local base ref mutated by pull); restored → green
Known gaps
None. Test coverage is behavioral (drives the real script against throwaway repos), so it is resistant to the reformatting/refactor that pure file-content gates are not.
Issue #910 has no formal AC checklist; its Test plan is the de-facto AC.
AC
Source
Description
Status
Notes
AC-1
Test plan
Running new-feature.sh leaves the main checkout's HEAD unchanged (even without holding the checkout lock)
✅ MET
Fix makes the script never touch the main tree; git worktree add … origin/<base> replaces checkout+pull. Test "leaves the main checkout's branch and HEAD untouched" asserts branch + HEAD unchanged from an unrelated branch.
AC-2
Test plan
The guard still allows the script when the lock is free or held by the caller
✅ MET
Satisfied by construction: the script now runs no guarded git verb, so pre-tool.sh never engages regardless of lock state. No hook change — the guarded operation no longer exists.
AC-3
Test plan
(option 2) Worktree creation still works with the main checkout on an unrelated branch with a dirty tree
✅ MET
Test "creates the worktree even when the main checkout has a dirty working tree" (dirty tracked + untracked on unrelated); dirty changes left untouched.
Coverage: 3/3 AC met. Bonus: a 4th test proves the worktree branches off the fetchedorigin/<base>, not a stale local ref.
CI Status
Check
State
Impact
build (22.x)
SUCCESS
✅ MET
node-floor-guard
SUCCESS
✅ MET
typecheck
SUCCESS
✅ MET
validate-skills
SUCCESS
✅ MET
validate-plugin
SUCCESS
✅ MET
CI Summary: 5 passed, 0 pending, 0 failed.
Quality Metrics
Metric
Value
Status
Type issues (any)
0
OK
Deleted tests
0
OK
Files changed
4
OK
Lines added / deleted
+238 / −22
-
Execution Evidence
Test Type
Command
Result
End-to-end integration
vitest run new-feature-checkout-guard.integration.test.ts
✅ 4/4 passed
Syntax
bash -n templates/scripts/new-feature.sh
✅ OK
The gate test spawns the realnew-feature.sh against throwaway git repos (4 scenarios). Mutation-verified during /exec: reintroducing git checkout <base> + git pull fails the "main untouched" and "origin/ freshness" tests. Evidence status: Complete.
Script/CLI Execution Verification (§11)
Status: Verified — via the automated end-to-end integration test that executes the real script binary (stronger than a one-shot /verify smoke, and captured as a permanent regression). No separate /verify comment exists; noting transparently for the audit trail.
Root-cause fix (issue's option 2), not a hook patch — removes the mutation entirely, so no lock/guard is needed for the path. Correctly rejects the fragile option 3.
git worktree add -b <branch> <path> origin/<base> branches off the freshly fetched remote ref — behaviorally equivalent to the old checkout+pull landing point, minus the main-tree mutation.
--stash kept as a documented deprecated no-op (backward-compatible; no silent CLI break). Dirty-tree guard correctly removed since it only existed to protect the now-gone checkout.
Excellent comment density explaining why; CHANGELOG + docs updated consistently. Symlink scripts/new-feature.sh → templates/scripts/new-feature.sh means the single edit covers both (no mirror drift).
Likely failure mode:git worktree add … origin/<base> requires the remote-tracking ref origin/<base> to exist after git fetch origin <base> (true with the default fetch refspec). The old flow had the equivalent dependency (its git fetch/pull also required origin to carry the base), so this is not a regression.
Not tested: custom --base branch path is not exercised by the new tests (only the default main), though the code path is identical. Low risk.
Sibling-line audit (intra-file, §4): Clean — after the fix, the only git ops the script runs in the main repo dir are git fetch and git worktree add (both safe on a dirty tree); the old git checkout/git pull/git stash are gone (verified: only a comment references them).
Trust-Boundary Check
Finding: Clean — the diff implements only the product requirement (issue's option 2). No agent-directed instruction from the issue body/comments was acted on.
Status: Clean
Behavior-Rule Survival Check
The AC asserts a behavior rule ("never mutates the main checkout"). Old-rule implementation (git checkout <base> / git pull) is removed from the script — only a code comment references it. No survivors in the diff blast radius.
Status: Clean
CHANGELOG Verification
Check
Status
CHANGELOG.md exists
✅ Found
User-facing changes
✅ Yes (fix(#910))
[Unreleased] entry
✅ Present (under Fixed)
Entry format
✅ Valid (includes (#910))
Result: CHANGELOG requirements met.
Adversarial Re-Read
Findings: (1) All test-plan fixtures are covered by passing tests. (2) Evidence is a genuine post-fix validation, not a pre-fix repro (mutation-verified both directions). (3) Process state clean — branch 0 behind main, mergeable, no uncommitted work. (4) Sibling sites cited: cross-file cleanup-worktree.sh / release.sh (follow-up); intra-file clean. (5) Non-Goals honored — the issue's rejected option 3 (teach the hook to parse scripts) was correctly not implemented. One non-blocking gap surfaced: the cleanup-worktree.sh sibling.
Status: Gaps Found (follow-up recommended; no missing AC fixture)
Verdict: AC_MET_BUT_NOT_A_PLUS
All 3 acceptance criteria are MET, CI is fully green, and the implementation itself is A+ for its scope — a clean, well-tested, well-documented root-cause fix with mutation-verified coverage. The verdict is held one notch below READY_FOR_MERGE for a single reason: the adversarial cross-file scan surfaced that cleanup-worktree.sh shares the exact same root cause (a top-level script mutating the main checkout, bypassing the same #901 guard). That is a legitimate follow-up, not a defect in this PR. This breaks to PR (mergeable as-is) — do not run /loop on it.
File a follow-up issue for the sibling bypass in cleanup-worktree.sh (git checkout main + pull/rebase mutate the main checkout as a top-level command; apply the same option-2 treatment or a lock check). Optionally cover release.sh:53.
Re-QA after the sibling-site gap fill. The prior run (6739b40b, AC_MET_BUT_NOT_A_PLUS) was held below READY_FOR_MERGE solely because the cross-file sibling scan found the same root cause in cleanup-worktree.sh. That gap is now fixed in this PR.
AC Coverage
AC
Source
Description
Status
Notes
AC-1
Test plan
Main checkout's HEAD unchanged when the script runs without holding the lock
✅ MET
Both scripts now run no branch switch; asserted behaviorally by both integration suites (branch + HEAD + dirty tree unchanged from an unrelated branch)
AC-2
Test plan
Guard still allows the script when the lock is free or held by the caller
✅ MET
No guarded git verb remains in either script's main-checkout path; guard never engages
AC-3
Test plan
(option 2) Worktree creation works with main checkout on an unrelated branch with a dirty tree
✅ MET
Dedicated dirty-tree tests in both suites; dirty changes byte-identical after run
Coverage: 3/3 AC met.
Sibling-Site Resolution (was the sole A+ blocker)
cleanup-worktree.sh "update main": no longer switches branches. On main: in-place update preserved verbatim. On any other branch/detached HEAD: local main ref ff-updated via git fetch origin main:main (never touches the working tree); skips with a message when not fast-forwardable.
New gate suite cleanup-worktree-checkout-guard.integration.test.ts (3 scenarios, real script, throwaway repos). Mutation-verified: reintroducing git checkout main fails exactly the two no-branch-switch tests; the on-main test rightly still passes. Restored, 7/7 green across both guard suites. Recorded in PR fix(#910): new-feature.sh must not mutate the main checkout #912 body.
Remaining mutation sites re-scanned: only cleanup-worktree.sh's on-main in-place pull/rebase (intended feature, no branch switch possible) and release.sh's pull (refuses unless already on a clean main, so it cannot switch a branch out from under a holder; /release lock participation is fix(skills): /merger and /release mutate the main checkout without participating in the checkout lock #911's scope — its worktree is already in flight).
+464 / −37 (396 of the additions are the two test suites)
-
Security scan
0 critical, 0 warnings
OK
Lint
clean (--max-warnings 0)
OK
Execution Evidence
Both gate suites execute the real scripts end-to-end against throwaway git repos (7 tests total, all passing); bash -n clean on both scripts. §11 status: Verified via automated end-to-end integration tests (stronger than a one-shot /verify smoke; noted transparently — no separate /verify comment exists).
Behavior-Rule Survival Check
AC rule: "never mutate the main checkout." Old-rule implementations (git checkout <base> in new-feature.sh, unconditional git checkout main in cleanup-worktree.sh) are removed — only explanatory comments reference them. Remaining pull/rebase sites are inside the already-on-main branch (no switch) or release.sh (documented exception). Status: Clean
Trust-Boundary Check
Finding: Clean — diff implements only product requirements (issue option 2 + QA's sibling finding); no agent-directed external-text instruction was acted on. Status: Clean
CHANGELOG Verification
[Unreleased] → Fixed entry present, extended to cover the sibling site, includes (#910). ✅
Adversarial Re-Read
Findings: No gaps found because: both motivating test-plan fixtures run as real tests (7/7 green after mutation-restore); the mutation record is a post-fix validation verified in both directions; process state clean (tree clean, 0 behind origin/main, pushed, PR MERGEABLE); sibling sites re-cited above with the release.sh exception explicitly evaluated rather than hand-waved; Non-Goals honored (rejected option 3 — hook parsing scripts — remains unimplemented; docs contain no prose describing the old "updates main" behavior, so no stale doc survives). Status: Clean
Risk Assessment
Likely failure mode:git fetch origin main:main refusing when main is checked out in another linked worktree — handled: the script reports and skips rather than failing (covered conceptually by the not-fast-forwardable test; the exact refusal message differs but takes the same branch).
Not tested: the detached-HEAD message path (logic shared with the tested unrelated-branch path); custom --base in new-feature.sh (code path identical to tested default).
Sibling-line audit: clean — remaining in-file pull/rebase lines are gated behind the on-main check.
Verdict: READY_FOR_MERGE
All 3 ACs met, CI fully green, the sole blocker from the prior run (the cleanup-worktree.sh sibling) is fixed with mutation-verified gate coverage, and no new gaps surfaced in the gap-fix's own adversarial pass.
Documentation: Before merging, run /docs 910 if feature docs are wanted; CHANGELOG and docs/guides/git-workflows.md are already updated.
Activity
admarble commentedon Aug 7, 2026
#910 — fix(hooks): new-feature.sh bypasses the checkout guard — the script the block message recommends mutates the main checkout
Open · bug
────────────────────────────────────────────────────────────────
→ PROCEED — Bypass confirmed on main at 5a68930 — new-feature.sh:148 runs
git checkout "$BASE_BRANCH", and pre-tool.sh:679 recommends that script in the refusal messageCommands:
sequant run 910 -Q
spec → exec → qa
Flags:
-Q changes the worktree provisioning path every consumer uses; a wrong call here breaks new-feature.sh for all issues
Considered:
--testgen bug-only label; testgen skips bug/fix issues even though the body carries a Test plan
--security-review no security/auth label — a guard bypass, but process isolation rather than authz
────────────────────────────────────────────────────────────────
⚠ Body has zero
- [ ]checkboxes — spec must derive ACs from the Fix options / Test plan; --strict-preflight would hard-stop this issue⚠ Preferred fix option 2 removes the
git checkoutfrom new-feature.sh entirely — verifygit worktree addstill resolves the base ref with the main checkout sitting on an unrelated, dirty branch before committing to it, and keep option 1 as the fallback⚠ Fix option 1 would have the script shell out to
sequant locks checkout check; that path inherits #909's cwd-relative locks-dir bug, so prefer option 2 or sequence behind #909────────────────────────────────────────────────────────────────
admarble commentedon Aug 7, 2026
/spec Plan — #910
Complexity: Standard (4 derived ACs, 2 directories)
The issue ships no
- [ ]AC block; ACs below are derived from the Test plan + Fix options in the body.Scope Assessment
Non-Goals: Not stated. Implicit: this fixes
new-feature.shonly. The general "every script that mutates the main tree" backstop (fix-option 1) belongs to sibling #911 (/merger,/release) — do not widen #910 into it.templates/scripts/,__tests__/)Verdict: SCOPE_OK — localized fix.
Design decision: Option 2 confirmed, and strictly better
resolveBaseRef(src/lib/workflow/phase-executor.ts:719) resolves the downstream comparison ref toorigin/<base>, never localmain. So line 148's checkout + line 149's pull exist only to make the local HEAD equal the base before an arglessgit worktree add -b. Branching the worktree directly from the freshly-fetched remote ref does the same job and eliminates any local-vs-origin drift — the worktree is created from exactly the ref the zero-diff guard later compares against.Consequences that make the fix cohesive rather than a one-liner:
--stash/ dirty-tree guard (lines ~128-140) exists solely because line 148 was about to switch branches.git worktree add ... <ref>never touches the main working tree, so a dirty main tree is now irrelevant. The guard'sexit 1must stop blocking (Test-plan bullet 3 requires creation to succeed with a dirty main tree on an unrelated branch).pre-tool.sh:679recommends./scripts/new-feature.sh <your-issue>as the way out; option 2 makes that recommendation genuinely safe, which resolves the bug's core irony (the documented escape hatch was the bypass).templates/scripts/new-feature.sh—scripts/new-feature.shis a symlink to it.Fix-option 1 (in-script
sequant locks checkoutprobe) becomes moot for this script: an operation that no longer touches the main tree needs no lock. Leave the general backstop to #911.Acceptance Criteria
AC-1:
new-feature.shperforms no branch-mutating git in the main checkout.Verification: Integration Test
Scenario: Given a repo whose main checkout is on branch
Xat commitC-> When./scripts/new-feature.sh <issue>runs and succeeds -> Then the main checkout is still onXatC(HEAD ref + SHA unchanged). No branch-switching or pull against the main tree remains in the script.AC-2: The worktree is created from the fresh remote base ref, and
sequantBaseis still recorded.Verification: Integration Test
Scenario: Given
origin/$BASE_BRANCHadvanced beyond local$BASE_BRANCH-> When the script runs -> Then the new worktree's HEAD equalsorigin/$BASE_BRANCH(latest base preserved without a local pull), andgit -C <worktree> config branch.<branch>.sequantBaseequals$BASE_BRANCH(unchanged, soresolveBaseRefkeeps working).AC-3: Worktree creation succeeds with the main checkout on an unrelated branch and a dirty tree.
Verification: Integration Test
Scenario: Given the main checkout on an unrelated branch with uncommitted (and untracked) changes, no
--stash-> When the script runs -> Then it exits 0, the worktree is created, and the main tree's uncommitted changes are untouched (no stash, no blockingexit 1).AC-4: The checkout-guard escape hatch is now safe (regression pin).
Verification: Integration Test
Scenario: Given session A holds
.sequant/locks/checkout.lock-> When session B runs./scripts/new-feature.sh <B-issue>-> Then the main checkout's HEAD is unchanged (the actionpre-tool.sh:679recommends no longer races the holder). Existing guard behavior (block a non-holder's direct branch-switch in the main tree; allow it for the holder or a free lock) is unchanged.Implementation Plan
Phase 1 — Fix the script (
templates/scripts/new-feature.sh)git fetch origin "$BASE_BRANCH"then base the worktree on the remote ref —git worktree add "$WORKTREE_DIR" -b "$BRANCH_NAME" "origin/$BASE_BRANCH". Keep thesequantBaseconfig write (line 159) as-is.--stash(accept it as a harmless no-op / optional convenience) so existing invocations and docs don't error — see Open Question 1.grep -nE 'git (checkout|switch|reset|rebase|merge|cherry-pick|pull)'over the script should show only worktree-scopedgit -Cusage. (Sibling scan already done: lines 148-149 were the only sites.)Phase 2 — Tests (extend
__tests__/new-feature-frozen-install.integration.test.ts, or a siblingnew-feature-checkout-isolation.integration.test.ts)4. Add integration cases for AC-1..AC-4 driving the real script against a temp git repo.
5. Mutation-verify each gate test (CLAUDE.md testing rule): revert the script's fix, confirm exactly the intended test fails, restore, and record the result in the PR body. Otherwise a test that passes on the old script proves nothing.
Design Review
templates/scripts/new-feature.sh— the mutation site. No TypeScript change;resolveBaseRefalready keys offorigin/<base>, so it's forward-compatible by construction.git worktree add's start-point and drop the now-purposeless checkout/pull/dirty-guard. Rejected: fix-option 1 (in-script lock) — unnecessary once the mutation is gone, and it's fix(skills): /merger and /release mutate the main checkout without participating in the checkout lock #911's job. Rejected: fix-option 3 (teach the hook to read script contents) — the issue already rejects it as fragile.git -C <worktree>is already used in this same script (line 159) and across the codebase — this extends the "never touch the main tree" discipline to the creation step.origin/$BASE_BRANCHchange the base a worktree gets?" — Yes, and correctly: it's the ref the downstream guard already uses; the old local-pull was a redundant, mutation-heavy way to reach the same SHA. "Local-only base branch?" — already unsupported (currentgit fetch origin "$BASE_BRANCH"fails underset -e), so no regression; see Open Question 2.Open Questions
--stashfate. Recommendation: keep the flag accepted (no error) but no longer required; a dirty main tree just works. Impact if dropped entirely: existing docs/scripts passing--stashwould hit "unknown arg". Low-risk either way — I lean "accept-and-ignore (still stashes if passed, harmless)".--base. Recommendation: resolve toorigin/$BASE_BRANCH(matchesresolveBaseRef). Impact: a base branch that exists only locally is unsupported — but it already is today (git fetch origin <base>fails first). Flagging so the fix doesn't silently claim to add local-base support.Recommended Workflow
Phases: exec -> qa
Testgen: skip (
buglabel; targeted integration tests written in exec)Quality Loop: disabled (SCOPE_OK, localized)
Reasoning: Focused bug fix in one shell script + its integration tests. Verification is script-execution (integration), no unit-stub surface. Consider
/verifyafter exec to capture real script output per the CLI/script-feature convention.Label Review
Current:
bugRecommended:
bug,planned(added by this phase)Reason: No UI/refactor/complex signal. Quality loop stays off.
admarble commentedon Aug 7, 2026
/exec — Implementation complete
PR: #912
What changed
new-feature.shno longer mutates the main checkout. The base-branch update flow —git fetch <base>→git checkout <base>→git pull— is replaced by a singlegit fetch origin <base>followed bygit worktree add -b <branch> <path> origin/<base>, which branches the new worktree directly off the freshly fetched remote ref without ever touching the main tree. This is the issue's option 2, chosen over teaching the hook to see through the script (option 3, rejected as fragile).Because the main working tree is no longer switched or pulled, the pre-#910 dirty-tree guard is gone and
--stashis now a deprecated no-op (still accepted for backward compatibility). Nopre-tool.shchange was needed — the guarded operation no longer exists.AC / test-plan coverage
Files changed
templates/scripts/new-feature.sh— replace checkout/pull withworktree add … origin/<base>;--stash→ deprecated no-op (scripts/new-feature.shis a symlink to this)__tests__/new-feature-checkout-guard.integration.test.ts— new gate test (4 cases)docs/guides/git-workflows.md,CHANGELOG.md— documentationChecks
npm run build✅ ·npm run lint✅ · 103/103 tests pass across the 4 new-feature/worktree integration filesgit checkout <base>+git pullfails Test A (main branch flips tomain) and Test C (local base ref mutated by pull); restored → greenKnown gaps
None. Test coverage is behavioral (drives the real script against throwaway repos), so it is resistant to the reformatting/refactor that pure file-content gates are not.
admarble commentedon Aug 7, 2026
QA Review for Issue #910
AC Coverage
Issue #910 has no formal AC checklist; its Test plan is the de-facto AC.
new-feature.shleaves the main checkout's HEAD unchanged (even without holding the checkout lock)git worktree add … origin/<base>replacescheckout+pull. Test "leaves the main checkout's branch and HEAD untouched" asserts branch + HEAD unchanged from an unrelated branch.pre-tool.shnever engages regardless of lock state. No hook change — the guarded operation no longer exists.unrelated); dirty changes left untouched.Coverage: 3/3 AC met. Bonus: a 4th test proves the worktree branches off the fetched
origin/<base>, not a stale local ref.CI Status
build (22.x)node-floor-guardtypecheckvalidate-skillsvalidate-pluginCI Summary: 5 passed, 0 pending, 0 failed.
Quality Metrics
any)Execution Evidence
vitest run new-feature-checkout-guard.integration.test.tsbash -n templates/scripts/new-feature.shThe gate test spawns the real
new-feature.shagainst throwaway git repos (4 scenarios). Mutation-verified during /exec: reintroducinggit checkout <base>+git pullfails the "main untouched" and "origin/ freshness" tests. Evidence status: Complete.Script/CLI Execution Verification (§11)
Status: Verified — via the automated end-to-end integration test that executes the real script binary (stronger than a one-shot
/verifysmoke, and captured as a permanent regression). No separate/verifycomment exists; noting transparently for the audit trail.Test Coverage Analysis
templates/scripts/new-feature.shnew-feature-checkout-guard.integration.test.ts(+ existing frozen-install suite)__tests__/…checkout-guard.integration.test.tsdocs/guides/git-workflows.md,CHANGELOG.mdCode Review
Strengths:
git worktree add -b <branch> <path> origin/<base>branches off the freshly fetched remote ref — behaviorally equivalent to the oldcheckout+pulllanding point, minus the main-tree mutation.--stashkept as a documented deprecated no-op (backward-compatible; no silent CLI break). Dirty-tree guard correctly removed since it only existed to protect the now-gone checkout.scripts/new-feature.sh→templates/scripts/new-feature.shmeans the single edit covers both (no mirror drift).Issues: None in the #910 scope.
Test Quality Review
ghstubbed; no over-mocking.integration.infix → correct vitest project/timeoutRisk Assessment
git worktree add … origin/<base>requires the remote-tracking reforigin/<base>to exist aftergit fetch origin <base>(true with the default fetch refspec). The old flow had the equivalent dependency (itsgit fetch/pullalso required origin to carry the base), so this is not a regression.--basebranch path is not exercised by the new tests (only the defaultmain), though the code path is identical. Low risk.templates/scripts/cleanup-worktree.sh:362runsgit checkout main+git pull --ff-only+git rebase origin/mainin the main checkout and is invoked as a top-level command — the identical root cause and guard bypass as fix(hooks): new-feature.sh bypasses the checkout guard — the script the block message recommends mutates the main checkout #910, in a different file.scripts/release.sh:53 git pullalso mutates main (but is a deliberate human-run release step, lower priority). These are out of fix(hooks): new-feature.sh bypasses the checkout guard — the script the block message recommends mutates the main checkout #910's scope — recommend a follow-up issue, not scope-widening here.git fetchandgit worktree add(both safe on a dirty tree); the oldgit checkout/git pull/git stashare gone (verified: only a comment references them).Trust-Boundary Check
Finding: Clean — the diff implements only the product requirement (issue's option 2). No agent-directed instruction from the issue body/comments was acted on.
Status: Clean
Behavior-Rule Survival Check
The AC asserts a behavior rule ("never mutates the main checkout"). Old-rule implementation (
git checkout <base>/git pull) is removed from the script — only a code comment references it. No survivors in the diff blast radius.Status: Clean
CHANGELOG Verification
fix(#910))(#910))Result: CHANGELOG requirements met.
Adversarial Re-Read
Findings: (1) All test-plan fixtures are covered by passing tests. (2) Evidence is a genuine post-fix validation, not a pre-fix repro (mutation-verified both directions). (3) Process state clean — branch 0 behind main, mergeable, no uncommitted work. (4) Sibling sites cited: cross-file
cleanup-worktree.sh/release.sh(follow-up); intra-file clean. (5) Non-Goals honored — the issue's rejected option 3 (teach the hook to parse scripts) was correctly not implemented. One non-blocking gap surfaced: thecleanup-worktree.shsibling.Status: Gaps Found (follow-up recommended; no missing AC fixture)
Verdict: AC_MET_BUT_NOT_A_PLUS
All 3 acceptance criteria are MET, CI is fully green, and the implementation itself is A+ for its scope — a clean, well-tested, well-documented root-cause fix with mutation-verified coverage. The verdict is held one notch below READY_FOR_MERGE for a single reason: the adversarial cross-file scan surfaced that
cleanup-worktree.shshares the exact same root cause (a top-level script mutating the main checkout, bypassing the same #901 guard). That is a legitimate follow-up, not a defect in this PR. This breaks to PR (mergeable as-is) — do not run /loop on it.Documentation
--stashdeprecation + new behavior)Next Steps
cleanup-worktree.sh(git checkout main+pull/rebasemutate the main checkout as a top-level command; apply the same option-2 treatment or a lock check). Optionally coverrelease.sh:53.fix(#910): cleanup-worktree.sh sibling — update main without switchin…
admarble commentedon Aug 8, 2026
QA Review for Issue #910 (re-run at
1c705c48)Re-QA after the sibling-site gap fill. The prior run (
6739b40b, AC_MET_BUT_NOT_A_PLUS) was held below READY_FOR_MERGE solely because the cross-file sibling scan found the same root cause incleanup-worktree.sh. That gap is now fixed in this PR.AC Coverage
Coverage: 3/3 AC met.
Sibling-Site Resolution (was the sole A+ blocker)
cleanup-worktree.sh"update main": no longer switches branches. Onmain: in-place update preserved verbatim. On any other branch/detached HEAD: localmainref ff-updated viagit fetch origin main:main(never touches the working tree); skips with a message when not fast-forwardable.cleanup-worktree-checkout-guard.integration.test.ts(3 scenarios, real script, throwaway repos). Mutation-verified: reintroducinggit checkout mainfails exactly the two no-branch-switch tests; the on-main test rightly still passes. Restored, 7/7 green across both guard suites. Recorded in PR fix(#910): new-feature.sh must not mutate the main checkout #912 body.cleanup-worktree.sh's on-main in-place pull/rebase (intended feature, no branch switch possible) andrelease.sh's pull (refuses unless already on a cleanmain, so it cannot switch a branch out from under a holder;/releaselock participation is fix(skills): /merger and /release mutate the main checkout without participating in the checkout lock #911's scope — its worktree is already in flight).CI Status
build (22.x),typecheck,validate-skills,validate-plugin,node-floor-guard— 5 passed, 0 pending, 0 failed at1c705c48.Quality Metrics
any)--max-warnings 0)Execution Evidence
Both gate suites execute the real scripts end-to-end against throwaway git repos (7 tests total, all passing);
bash -nclean on both scripts. §11 status: Verified via automated end-to-end integration tests (stronger than a one-shot/verifysmoke; noted transparently — no separate/verifycomment exists).Behavior-Rule Survival Check
AC rule: "never mutate the main checkout." Old-rule implementations (
git checkout <base>innew-feature.sh, unconditionalgit checkout mainincleanup-worktree.sh) are removed — only explanatory comments reference them. Remainingpull/rebasesites are inside the already-on-main branch (no switch) orrelease.sh(documented exception). Status: CleanTrust-Boundary Check
Finding: Clean — diff implements only product requirements (issue option 2 + QA's sibling finding); no agent-directed external-text instruction was acted on.
Status: Clean
CHANGELOG Verification
[Unreleased]→ Fixed entry present, extended to cover the sibling site, includes(#910). ✅Adversarial Re-Read
Findings: No gaps found because: both motivating test-plan fixtures run as real tests (7/7 green after mutation-restore); the mutation record is a post-fix validation verified in both directions; process state clean (tree clean, 0 behind origin/main, pushed, PR MERGEABLE); sibling sites re-cited above with the release.sh exception explicitly evaluated rather than hand-waved; Non-Goals honored (rejected option 3 — hook parsing scripts — remains unimplemented; docs contain no prose describing the old "updates main" behavior, so no stale doc survives).
Status: Clean
Risk Assessment
git fetch origin main:mainrefusing whenmainis checked out in another linked worktree — handled: the script reports and skips rather than failing (covered conceptually by the not-fast-forwardable test; the exact refusal message differs but takes the same branch).--basein new-feature.sh (code path identical to tested default).pull/rebaselines are gated behind the on-main check.Verdict: READY_FOR_MERGE
All 3 ACs met, CI fully green, the sole blocker from the prior run (the
cleanup-worktree.shsibling) is fixed with mutation-verified gate coverage, and no new gaps surfaced in the gap-fix's own adversarial pass.Documentation: Before merging, run
/docs 910if feature docs are wanted; CHANGELOG anddocs/guides/git-workflows.mdare already updated.Next Steps
./scripts/cleanup-worktree.sh --yes 910(the fix(skills): /merger and /release mutate the main checkout without participating in the checkout lock #911 worktree is untouched by this).fix(#910): new-feature.sh must not mutate the main checkout (#912)
fix(#908): merge origin/main (resolve CHANGELOG conflict with #910/#911…