Skip to content

feat(guardrails): install the commit-msg entry as a git config hook under an includeIf, from git 2.54 - #11166

Merged
kyle-sexton merged 5 commits into
mainfrom
feat/9775-config-hook-install
Oct 30, 2026
Merged

kyle-sexton merged 5 commits into
mainfrom
feat/9775-config-hook-install

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #9775

Replaces #11082 (lanes App PR). The pr-unblock resolver ran two address-feedback rounds on its head 63674424a2 and could not settle the pr-verify findings, so this owner-login PR carries the same change: origin/main with that head merged, no other edits.

Summary

The shared git-hook installer gains a config-hook --include-if <condition> action. It writes a stable copy of each commit-msg entry and an include file with one [hook "<plugin>-<entry>"] block under $XDG_CONFIG_HOME/git/checks/<plugin>/, and returns the global includeIf.<condition>.path line as a decision. /guardrails:setup apply install-git-hooks scope=user routes to a new context doc covering the git 2.54 floor, the location, the friendly name guardrails-commit-msg-convention, and checks.skipmissing as the only skip. verify reports a config-hook install by its stable copy, and reports missing when the repository disables the hook or overrides its command.

Fix

  • lib/git-hooks/install.mjs and its ten synced plugin copies: the config-hook action and its decisions (include-if, include-if-unmatched, git-too-old, modified); verify reads an entry's config hook before its copies.
  • lib/git-hooks/install.test.mjs: config-hook tests (idempotent second run, git hook list, verify after a repo override, checks.skipmissing, lefthook coexistence), gated on git 2.54 with a visible SKIP below it.
  • plugins/guardrails/skills/setup/context/install-commit-msg.md (new) and plugins/guardrails/skills/setup/SKILL.md: the scope=user install.
  • .changes/*/feat-9775-config-hook-install-a3c9e517.md: guardrails minor; the nine plugins that carry only the synced installer patch, because their shipped install.mjs changed.

Verification

Related

🤖 Generated with Claude Code

melodic-automation-lanes Bot and others added 4 commits October 29, 2026 22:34
Lane-Activity: work-resolve-issue/resolve-issue
Lane-Activity: pr-unblock/address-feedback
Lane-Thread: PRRT_kwDOTCGFQM6xy0gm
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T05:48:59.427767Z 53f7a6e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 1f14d29b11339e38690e5a195b511c2917ce15fa: 0 finding(s), 0 as inline comments.

No security findings in the incremental change since 53f7a6e.

The change touches lib/git-hooks/install.mjs, its test, the same installer vendored into 10 plugins, and one guardrails doc. I read all of it, and I read git() in lib/git-hooks/install.mjs (line 179) to check the new parsing. I did not check the vendored copies against the canonical file beyond what the diff shows.

  • --null parsing in configHookEvents: git() calls .trim() on stdout, but JS trim() does not strip \0. So each value keeps its terminating NUL, and a trailing empty value (a repository that clears the hook's event) now survives as "". An unset key gives "", which splits to []. A cleared event is therefore detected, and verify no longer reports ok for a hook that does not run. This makes verify stricter, not looser. Values are not interpolated into a command or a path here.
  • WORKTREE_INCLUDE_FLOOR guard in configHook: this is a refusal before any write when the git version is below 2.56 and the condition starts with worktree: or worktree/i:. The condition has already passed INCLUDE_IF_RE, and the new check only reads the git version. It fails closed: if the version cannot be parsed, gitAtLeast returns false, so the install refuses. I did not check that 2.56 is the version that added the worktree keyword. That is a correctness question, not a security one.
  • gitAtLeast refactor: hasConfigHooks behaves as before, with the same floor and comparison.
  • Doc change in install-commit-msg.md: it only restates the git floor and the new refusal. No standing instruction is removed or softened.
  • Trust controls and manifests: no plugin manifest, token scope, kill switch, merge hold or trusted-actor list is touched. The trusted-path globs match none of the changed files except possibly plugins/** copies, and none of those widen anything.

No spend, so no cost hold.

critical-findings: 0

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude-review: 1 inline finding(s) on 53f7a6e6b2ea494002dbb7ba65eff66aa413c8d9; the summary is in this lane's pull request comment.

claude-lane: claude-review

Comment thread lib/git-hooks/install.mjs Resolved
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 1f14d29b11339e38690e5a195b511c2917ce15fa: 0 finding(s), 0 as inline comments.

Incremental review of 53f7a6e6..1f14d29b: no findings. I read the diff and the surrounding code but ran no tests.

  • Empty-event fix (configHookEvents): git() trims its output, and --null ends each value with a NUL, which trim() doesn't strip. The trailing empty value is kept, so lastIndexOf("") sees the clear. An unset key gives "", which split("\0").slice(0, -1) turns into [], the same result as before. The new test "a repository that clears the hook's event does not verify ok" covers this.
  • Worktree floor: gitAtLeast replaces the hard-coded 2.54 check, and hasConfigHooks behaves as before. configHook throws a UsageError (exit code 2) for worktree: and worktree/i: below 2.56. The guard runs before the 2.54 git-too-old decision, so on git below 2.54 these conditions get this error instead. The test expects exactly that.
  • Synced copies: all ten plugin install.mjs files carry the same hunks as lib/git-hooks/install.mjs.
  • Docs: the edit to install-commit-msg.md matches the new behavior. It no longer says git below 2.54 ignores hook.* silently, and it says verify does not count the block there. This also fits the closing issue's checks.skipmissing-only skip decision.
  • Not checked: I didn't confirm that git 2.56 is the version that added the worktree: keyword; that number is the PR's claim.
  • Minor, not counted: the new test at lib/git-hooks/install.test.mjs:1144 reads the git version with a 2.x-only regex. On a future git 3.x it would take the "git too old" branch and fail. The installer's gitAtLeast handles a higher major version correctly, and the existing configHooks gate has the same limitation.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 53f7a6e6b2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…es below their floor

configHookEvents reads hook.<name>.event with --null, so the empty value a
repository sets to clear the events survives git()'s trim and verify no
longer reports ok for a hook git does not run. config-hook refuses a
worktree: or worktree/i: condition on a git older than 2.56, whose
conditional includes lack that keyword. Synced the ten installer copies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit 29e8bbb Oct 30, 2026
42 checks passed
@kyle-sexton
kyle-sexton deleted the feat/9775-config-hook-install branch October 30, 2026 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(git-hooks): install hook entries as git config-based hooks under an includeIf, from git 2.54

1 participant