fix(hooks): anchor plan-gate to project root + exempt plan file#876
Open
thecodingshrimp wants to merge 1 commit into
Open
fix(hooks): anchor plan-gate to project root + exempt plan file#876thecodingshrimp wants to merge 1 commit into
thecodingshrimp wants to merge 1 commit into
Conversation
Fix three defects in pretool-plan-gate.py per docs/handoff-plan-gate-hook-fix.md: - Defect 1 (cwd resolution): add _find_project_root() — resolves via CLAUDE_PROJECT_DIR, then nearest .git ancestor, then cwd. A task_plan.md at the git root now satisfies the gate from any subdirectory depth, instead of only when the session pwd is the repo root. - Defect 2 (chicken-and-egg): short-circuit before the gate check so a file named task_plan.md is never blocked, even inside a gated subtree. - Defect 3 (docstring drift): docstring and inline comments now state that all files under agents/ and skills/ are gated regardless of extension, because SKILL.md and agent .md files are behavioral specs. Add tests/test_plan_gate_hook.py covering all five handoff scenarios. PLAN_GATE_BYPASS=1 escape hatch and gated-directory scope unchanged.
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
Two defects in
pretool-plan-gate.pycaused false denials and false allows. The hook now anchorstask_plan.mdlookup to the project root (not session cwd), and never gates writes totask_plan.mditself.Changes
hooks/pretool-plan-gate.py— add_find_project_root(walks.git; respectsCLAUDE_PROJECT_DIRenv); exempttask_plan.mdtarget from gating; update docstring to state allagents//skills/files are gated regardless of extensiontests/test_plan_gate_hook.py— add 7 TDD tests covering: deny on missing plan, allow with plan at git root + deep cwd, allow writingtask_plan.md, allow non-gated path,PLAN_GATE_BYPASS=1,CLAUDE_PROJECT_DIRoverride, docstring accuracyNotes
High-risk path (
hooks/pretool-plan-gate.py) — behavioral gate change; hook was blocking the plan file itself, preventing the plans skill from creating the unblocker. Tests were written before fixes and verified to fail on unfixed code.