Skip to content

chore(hooks): wedge-proof commands + drop project tool_guard#713

Merged
zackees merged 1 commit into
mainfrom
chore/wedge-proof-hook-commands
Jun 20, 2026
Merged

chore(hooks): wedge-proof commands + drop project tool_guard#713
zackees merged 1 commit into
mainfrom
chore/wedge-proof-hook-commands

Conversation

@zackees

@zackees zackees commented Jun 20, 2026

Copy link
Copy Markdown
Member

Follow-up to #712.

Summary

  • Drop the project-local tool_guard.py PreToolUse hook (user runs it globally).
  • Every remaining hook command is now wedge-proof:
    • Prefer \$CLAUDE_PROJECT_DIR (harness anchor that survives worktree shifts) → fall back to git rev-parse --show-toplevel.
    • [ -f <script> ] && uv run ... || exit 0 so a worktree without ci/hooks/ (orphan branch, fresh checkout-in-progress) cannot block the shell.

Root cause

During the online-data orphan-branch setup in #712, git rm -rf . inside the worktree removed ci/hooks/. The PreToolUse command then resolved git rev-parse --show-toplevel to that worktree, tried uv run ci/hooks/tool_guard.py, and python errored with "no such file" — blocking every subsequent Bash/Edit/Write call. The guard turns "script missing" into a no-op instead of a block.

Test plan

  • The new command shape exits 0 cleanly from both inside-the-repo and outside-the-repo cwds (smoke-tested locally).
  • No production-side behavior change — when scripts exist, they still run identically.

🤖 Generated with Claude Code

…llow-up)

Two changes to .claude/settings.json:

1. Removed the project-local `tool_guard.py` PreToolUse hook — the user
   confirmed they install soldr/uv guards globally, so the duplicate
   fires twice without value. `forbidden_commands.py` (pyocd/esptool
   policy) stays as the project-specific Bash gate.

2. Every hook command is now wedge-proof:
   - Prefer `${CLAUDE_PROJECT_DIR}` (the harness anchor that survives
     worktree shifts) and fall back to `git rev-parse --show-toplevel`.
   - Wrap the actual `uv run` invocation in `[ -f <script> ] && ... || exit 0`
     so a worktree without `ci/hooks/` (e.g. the `online-data` orphan
     branch's worktree, or a freshly-orphaned branch mid-setup) cannot
     fail the hook startup and freeze the shell.

This was the catch-22 that wedged the original `online-data` orphan
setup in PR #712: `git rm -rf .` removed `ci/hooks/` from the worktree;
the PreToolUse hook command then resolved `git rev-parse --show-toplevel`
to that worktree, tried `uv run ci/hooks/tool_guard.py`, and python
errored with "no such file" — blocking every subsequent Bash/Edit/Write
call. The guard above turns the "script not found" case into a no-op
instead of a block.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@zackees, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 22 minutes and 45 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2b7a1b71-fc63-49ec-b5ec-752607c40661

📥 Commits

Reviewing files that changed from the base of the PR and between 302b01c and 3943038.

📒 Files selected for processing (1)
  • .claude/settings.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/wedge-proof-hook-commands

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees zackees merged commit 0b8aae4 into main Jun 20, 2026
84 of 91 checks passed
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant