1 Commits

Author SHA1 Message Date
Edward Cheng-I Wu 4f8acbcaf2 fix(#454): Windows Python hook portability + graceful no-Python degradation
The PreToolUse write-scope guard was wired as a bare `python3 ".../ars_write_scope_guard.py"`.
On Windows `python3` is commonly a 0-byte Microsoft Store alias stub (exit 49, no output), so
the hook failed before the guard's own fail-safes ran and spammed the hook log every call.

A new cross-platform launcher `hooks/run_guard.sh` (POSIX sh; `hooks.json` invokes it via bash)
finds a real interpreter — `py -3` / `python3` / `python`, each verified by a marker probe that
must exit 0 AND print the marker (a stub is skipped) — then runs the guard as a supervised,
time-bounded subprocess. Plan A graceful degradation: if no real interpreter is found or the
guard subprocess misbehaves, the launcher emits a valid pass-through hook JSON and exits 0,
never blocking and staying silent on stderr on the degraded paths.

Hardened across a two-model dual-track review (codex + gemini, both POSIX-reproduced): the
no-`timeout` watchdog fallback's stdin/stdout/timeout handling, a pid-reuse race (done-file
handshake), a predictable-/tmp symlink fail-open (mktemp failure degrades to pass-through), and
a gameable CI exec assertion (line-anchored). 76 tests (21 launcher + 55 guard); README
documents the Git Bash prerequisite on Windows.

Verified against the reporter's confirmed environment (py -3 real, python3 an exit-49 stub):
the stub is skipped, the guard runs via py -3, and the decision is forwarded.

Closes #454.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-06-18 11:56:04 +08:00