Browse Source

fix(skills): pin cwd in worktree-guard arg-mode test

The arg-mode invocation carries no payload cwd, so the hook falls back
to CLAUDE_PROJECT_DIR/PWD. When the suite itself runs from a checkout
inside .claude/worktrees/ (worktree-isolated sessions), the hook's
own-worktree exemption silently exits before the rm check and the
'WORKTREE GUARD' advisory assertion fails. Pin CLAUDE_PROJECT_DIR to
the sandbox like the stdin-mode tests pin an explicit cwd.

Hook text and test expectation were never out of sync - the failure
was environment-dependent, not text drift from efb83b5.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
0xDarkMatter 2 weeks ago
parent
commit
3dbbed035b
1 changed files with 4 additions and 1 deletions
  1. 4 1
      skills/supply-chain-defense/tests/run.sh

+ 4 - 1
skills/supply-chain-defense/tests/run.sh

@@ -233,7 +233,10 @@ if [[ -f "$WGHOOK" ]]; then
   out="$(printf '{"tool_input":{"command":"ls -la"},"cwd":"%s"}' "$SB/wt-proj" | bash "$WGHOOK" 2>&1)"; rc=$?
   expect_exit "benign command -> 0" 0 "$rc"
   [[ -z "$out" ]] && ok "benign command is silent" || no "benign command should be silent"
-  out="$(bash "$WGHOOK" "rm -rf .claude/worktrees/x" </dev/null 2>&1)"; rc=$?
+  # arg mode has no payload cwd — the hook falls back to CLAUDE_PROJECT_DIR/PWD,
+  # so pin it to the sandbox or the own-worktree exemption silently swallows the
+  # advisory when the suite itself runs from inside a .claude/worktrees/ checkout.
+  out="$(CLAUDE_PROJECT_DIR="$SB/wt-plain" bash "$WGHOOK" "rm -rf .claude/worktrees/x" </dev/null 2>&1)"; rc=$?
   expect_exit "arg: rm worktrees advisory -> 0" 0 "$rc"
   expect_has  "arg: advisory text" "WORKTREE GUARD" "$out"
 else