Repository navigation
fix(claude): brace the project dir in the devtools gate hook - #5739
Merged
Merged
Conversation
Under CLAUDE_CODE_SHELL_PREFIX, Claude Code expands hook command variables itself and reads an unbraced "$CLAUDE_PROJECT_DIR/.claude/..." as one invalid variable name, so the hook command becomes empty and the gate never runs. The braced form expands correctly. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
Sinity
enabled auto-merge (squash)
September 28, 2026 19:11
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Sinity
added a commit
that referenced
this pull request
Sep 28, 2026
## Summary The patterns gate trusts an exemption that any parent of `HEAD` already carried, so a PR whose tip merges `master` no longer fails for `master`'s own baseline additions. ## Problem `_trusted_baseline` read the committed baseline from `HEAD^` only. On a PR whose head is a merge of `master`, `HEAD^` is the PR's previous tip, so every exemption `master` added since the PR last merged it counts as growth. The quick-gate of #5739 (a one-line hook change merged with `master` at f2562c3) failed with `patterns: committed baseline grew` over dozens of `master`'s own entries (`diagnosis=gate_input_error`); #5643, #5696 and #5704 fail the same way. ## Solution Read the baseline at every parent (`git rev-parse HEAD^@`) and trust each entry at the largest count any parent carried. A merge resolution that adds an entry present in neither parent is still growth. ## Verification `devtools test tests/unit/devtools/test_verify_patterns.py` on a checkout of origin/master 82e84ec with this change: 9 passed, 1 failed. The new `test_merging_the_base_branch_does_not_count_its_exemptions_as_growth` passes; it fails with first-parent-only trust. The failing `test_displacing_a_baselined_match_does_not_trip_the_gate` fails the same way on unpatched master (IndentationError in its synthetic file) and is recorded in polylogue-rb7tx. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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
Brace
CLAUDE_PROJECT_DIRin the PreToolUse devtools-gate hook so the hook runs under a Claude Code shell prefix.Problem
Sinnix now launches Claude Code with
CLAUDE_CODE_SHELL_PREFIX(sinnix 23fe8fb3), which moves tool processes into their own memory slice. With a prefix set, Claude Code expands variables in hook commands itself, and it reads an unbraced$CLAUDE_PROJECT_DIR/.claude/hooks/require-devtools.shas a single variable name. That name is invalid, so the command expands to an empty string. The session's debug log shows 764 hook failures in one session: "Invalid environment variable name evaluates to an empty string: CLAUDE_PROJECT_DIR/.claude/hooks/require-devtools.sh" followed by "zsh: string expected after -c". The devtools gate never ran.Solution
Use
${CLAUDE_PROJECT_DIR}, the form the sinex project already uses.Verification
In a scratch project, a PreToolUse hook written as
${CLAUDE_PROJECT_DIR}/h.shran on a Bash call under the shell prefix (claude -pwith Haiku), both with and withoutCLAUDE_PROJECT_DIRin the launching environment. The unbraced form fails in the live session log quoted above.🤖 Generated with Claude Code
https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg