Repository navigation
Conversation
The pre-tool checkout guard (#901) inspects only the top-level Bash command an agent runs. `./scripts/new-feature.sh <issue>` carries no guarded git verb, so it passed the guard and then ran `git checkout <base>` + `git pull` internally, in the main checkout — letting a non-holder session switch the holder's branch out from under it. The guard's own refusal message even recommended new-feature.sh as the way to proceed, so the documented escape hatch was the bypass. Fix per the issue's option 2: remove the mutation instead of teaching the hook to see through the script. The worktree is now branched directly off the freshly fetched `origin/<base>` via `git worktree add -b <branch> <path> origin/<base>`, which resolves the start-point ref without checking out or pulling into the main tree. Because the main working tree is no longer touched, a dirty main checkout no longer blocks worktree creation, and `--stash` (whose only job was to clear the way for the old checkout) becomes a deprecated no-op, still accepted so existing callers do not break. No hook change is needed. Gate test (new-feature-checkout-guard.integration.test.ts, mutation-verified by reintroducing checkout+pull → Test A and Test C fail): - main checkout branch/HEAD unchanged after running the script from an unrelated branch - worktree created even with a dirty main working tree - worktree branched off the fetched origin/<base>, local base ref untouched - --stash accepted as a no-op without stashing Entire-Checkpoint: 300525659938
…g branches QA's cross-file sibling scan on the new-feature.sh fix flagged the identical root cause in cleanup-worktree.sh: its post-cleanup "update main" step ran an unconditional `git checkout main` (+ pull/rebase) inside the script, invisible to the pre-tool checkout guard, so a non-holder session could switch the main checkout's branch out from under the #901 lock holder. Same option-2 treatment: never switch branches. On main, update in place as before; on any other branch, ff-update the local main ref via `git fetch origin main:main` (never touches the working tree), skipping with a message when not fast-forwardable. release.sh's `git pull` is deliberately left alone: it refuses to run unless already on a clean main (no branch switch possible), and /release lock participation is #911's scope.
…-new-feature-sh-bypasses-the-checkout-gua # Conflicts: # CHANGELOG.md
admarble
deleted the
feature/910-fix-hooks-new-feature-sh-bypasses-the-checkout-gua
branch
August 8, 2026 03:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
new-feature.shno longer mutates the main checkout, closing the last bypass of the feat(locks): per-issue locks give no mutual exclusion on the shared working tree — checkout-scoped protection #901 checkout guard.pre-tool.shinspects only the top-level Bash command an agent runs;./scripts/new-feature.sh <issue>carries no guarded git verb, so it passed the guard and then rangit checkout <base>+git pullinternally, in the main checkout — letting a non-holder session switch the holder's branch out from under it. The refusal message even recommendednew-feature.shas the way to proceed, so the documented escape hatch was the bypass.origin/<base>viagit worktree add -b <branch> <path> origin/<base>, which resolves the start-point ref without checking out or pulling into the main tree. No hook change is needed — the operation that required the lock no longer exists.--stash(whose only job was to clear the way for the old checkout) becomes a deprecated no-op, still accepted so existing callers do not break.AC / Test-plan coverage
new-feature-checkout-guard.integration.test.tsasserts branch + HEAD unchanged from an unrelated branchTest plan
npm run build— cleannpm run lint— cleannpx vitest runon the four new-feature/worktree integration files — 103 passedgit checkout <base>+git pullfails Test A (main branch flips tomain) and Test C (local base ref mutated by pull); restored, green againCloses #910
QA gap fill:
cleanup-worktree.shsibling site (commit 1c705c4)QA's cross-file sibling scan flagged that
cleanup-worktree.sh's post-cleanup "update main" step shared the exact root cause: an unconditionalgit checkout main(+pull/rebase) run inside a script the pre-tool guard can't see into. Fixed in this PR with the same option-2 treatment:mainalready: update in place (fetch + ff-only pull; rebase on divergence) — unchanged behavior, no branch switch involved.mainref is fast-forwarded viagit fetch origin main:main, which never touches the working tree. Not fast-forwardable → skip with a message.release.sh'sgit pullis deliberately untouched: it refuses to run unless already on a cleanmain(so it can never switch a branch out from under a holder), and/releaselock participation is fix(skills): /merger and /release mutate the main checkout without participating in the checkout lock #911's scope.Gate test mutation record: reintroducing
git checkout mainafter the fetch fails exactly the two tests that assert no branch switch incleanup-worktree-checkout-guard.integration.test.ts("leaves an unrelated branch checked out…" and "skips the main-ref update…"); the on-main test rightly still passes (checkout is a no-op there). Restored — all 7 tests across both checkout-guard suites green.