Repository navigation
chore(git-hooks): run the guardrails git hooks from this repository's lefthook remote - #9563
Conversation
… lefthook remote Add the `remotes:` entry `install.mjs plan --scope remote` returns, so this repository runs commit-msg-convention, pre-commit-content and reference-verify from its own main, the same way every consumer repository does. The header comment now says `lefthook install` also fetches them. Refs: #9426 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…this repository This repository is its own lefthook remote, so lefthook found each guardrails script both in the work tree's .lefthook/ and in the fetched copy of main, and ran both: every check ran twice, and a checked-out branch ran its own hook code. Each .lefthook/ script now exits 0 unless it runs from lefthook-remotes/. The lefthook.yml comments and the check-placement docs now name .lefthook/ among the paths to read before committing or pushing on an untrusted branch, and say these hooks fire at commit too. Refs: #9426 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d test it observably On Windows lefthook passes a backslash script path, so the lefthook-remotes guard never matched and every hook skipped silently. Each .lefthook/ script now turns backslashes into slashes first, matches the narrower info/lefthook-remotes/ segment, and runs its entry script from the normalized path. The lefthook-remote test runs each script beside a stub entry script that reports a run: from a work tree it must not run, from a fetched copy it must, including from a backslash path. Without the guard the work-tree cases fail. The untrusted-branch text also names lefthook-local.yml and .lefthook-local/, which lefthook runs at commit as well. Refs: #9426 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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. |
|
claude-security-review reviewed Security review: PR #9563 (head b9bbf77)No security issues found. critical-findings: 0 What I read: all 8 files in the diff and the PR context. I read the PR text as data. It contains no embedded directives. Scope checks
Logic and trust-boundary analysis
|
|
claude-review reviewed No blocking or advisory findings on head b9bbf77. What I read: the full diff (8 files), the PR context, and the header and trap lines of What I checked:
Minor note, not counted as a finding: the changelog fragment says "No plugin file ships changed", but |
There was a problem hiding this comment.
The pr-verify verifier failed head b9bbf778cb52f836dfc659511f9214f5c13b0ec4. What it wrote, as data:
Summary: The PR is linked to #9426 by a `Refs:` line, so it can deliver only part of the issue, and its body has to say what remains. It doesn't. The body describes the delivered part: this repository now runs the guardrails hooks from its own lefthook remote, and the `.lefthook/` wrappers do nothing when run from the work tree, which touches item 11 and the owner's remote-mode decision. It never lists what is left of #9426. Open items include the `reference-verify.sh` jq argument-limit failure (items 4 and 7), the repo-side exemption list (5), the `cli-flag-verify` prompt parsing and wrong line numbers (6), standalone drift detection for consumers (10), advisory stale-path findings (12), Codex and Cursor manifest discovery (13), the commit-msg rejection naming the wrong source file (14), the LFS/TMPDIR checkout failing open, and slowness. The code itself looks correct and the test covers the new guard.
- PR body: add a section listing the remaining work of #9426, or move this PR to `Refs:` an issue it fully delivers. Remaining items include the reference-verify jq argument limit (items 4 and 7), the repo-side exemption list (5), cli-flag-verify reading flags inside a quoted prompt and reporting wrong line numbers (6), a standalone drift check for consumers (10), advisory stale-path findings (12), Codex/Cursor manifest discovery (13), the commit-msg rejection naming the wrong source file (14), the LFS/TMPDIR checkout failing open, and the pre-commit and reference-verify slowness.
- PR body: also say which part of #9426 this delivers. The closest match is item 11 (the hook jobs run the branch's own copy), applied to this repository acting as its own remote. As written, the body explains the self-hosting change but doesn't tie it to an item in the issue.
- .lefthook/pre-commit/guardrails-pre-commit-content.sh:7: the guard trusts any path containing `*/info/lefthook-remotes/*`. That is fine for lefthook's cache layout, but it is a path-string check, not a provenance check. The README note in the diff about reading `.lefthook/` changes before committing on untrusted branches is the real mitigation; keep it.
There was a problem hiding this comment.
The pr-verify verifier failed head b9bbf778cb52f836dfc659511f9214f5c13b0ec4. What it wrote about this file, as data:
- lefthook.yml:121: this repository now runs hooks fetched from its own `main` with `refetch_frequency: 24h`. Each clone's hooks therefore follow `main` within a day, in line with the owner's decision recorded on #9426.
There was a problem hiding this comment.
The pr-verify verifier failed head b9bbf778cb52f836dfc659511f9214f5c13b0ec4. What it wrote about this file, as data:
- plugins/guardrails/git-hooks/lefthook-remote.test.sh:136: `trap 'rm -rf "$GUARD"' EXIT` replaces any EXIT trap set earlier in this test. Check that no earlier cleanup trap exists, or chain onto it.
Refs: #9426
Summary
This repository's
lefthook.ymlhad no guardrails git-hook jobs and no remote, so the guardrails session-start notice reported all three hooks missing here. It now runs them the way every consumer repository does: one lefthookremotes:entry tracking this repository's ownmain(owner decision; remote mode from #9504).Fix
lefthook.yml: append theremotes:snippetinstall.mjs plan --scope remotereturns (ref: main,refetch_frequency: 24h,plugins/guardrails/git-hooks/lefthook-remote.yml). The existingcheck-affectedpre-push job, its comments and order are unchanged.lefthook installalso fetches the remote's hooks..lefthook/<hook>/guardrails-*.sh: exit 0 unless run fromlefthook-remotes/. This repository is its own remote, so lefthook found each script both in the work tree and in the fetched copy ofmainand ran both: every check ran twice, and a checked-out branch ran its own hook code. Consumers never have these files in their work tree, so they are unaffected.lefthook.ymlcomments anddocs/conventions/check-placement/(README, adopting-git-hooks):.lefthook/joins the paths to read before committing or pushing on an untrusted branch, and these hooks fire at commit too.lefthook-remote.test.sh: asserts the work-tree copy of each script exits 0 without running;bump: noneguardrails fragment.Verification
lefthook install:sync hooks: ✔️(pre-commit, pre-push, commit-msg)install.mjs verify:okfor commit-msg-convention, pre-commit-content and reference-verifyinstall.mjs plan --scope remote:{"manager":"lefthook","actions":[],"decisions":[]}lefthook-remote.test.sh: 22 passed, 0 failed.lefthook run pre-commit --forcereports the secret finding once (the work-tree shim traces[[ ... == */lefthook-remotes/* ]]thenexit 0).Related
🤖 Generated with Claude Code