Skip to content

fix(hooks): turn off core.fsmonitor on the format adapters' and reap helper's git calls - #17260

Merged
kyle-sexton merged 2 commits into
mainfrom
fix/16959-hook-git-overrides
Nov 18, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
fix/16959-hook-git-overrides

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Refs: #16959

Summary

#17104 and #17082 routed the hooks' own git calls through hook::git_untrusted (lib/hook-utils.sh), which passes the overrides PR #16954 uses (--no-pager -c core.fsmonitor=false -c core.hooksPath=/dev/null). Two files hooks run from outside hooks/ still ran plain git in a repository the hook did not create, and each read the index, which starts the command that repository's core.fsmonitor names:

  • The format hooks (bash, JavaScript, Markdown, Python) source their plugin's git-hooks/adapters.sh (and markdown-format's markdown-gates.sh). On every edit, the adapter's config and install lookups ran git -C <repo> ls-files in the edited file's repository.
  • worktree-remove-gate.sh runs scripts/reap-project-plugin-records.sh, whose settings-state check ran git ls-files and git diff in the worktree once a plugin install record names it.

Fix

  • lib/git-hooks/resolve-tool.sh adds rt_git: hook::git_untrusted when a Claude Code hook loaded hook-utils.sh first, plain git otherwise (a git hook, which runs inside git's own command, or a git-hook entry run on its own). The override list stays in one definition, hook::git_untrusted. The selector follows worktree_root_git in scripts/worktree-root-resolve.sh.
  • Every git call in the bash, JavaScript, Markdown and Python adapters.sh and in markdown-gates.sh calls rt_git.
  • reap-project-plugin-records.sh sources its plugin's hooks/hook-utils.sh and calls hook::git_untrusted.
  • scripts/sync-shared-copies.sh regenerated the eight resolve-tool.sh copies. One patch fragment per touched plugin (nine).

Verification

  • lib/hook-git.test.sh gains nine planted-fsmonitor cases: each format adapter's config lookup, bash-format's .shellcheckrc lookup, the committed-node_modules and committed-.venv checks, and the reap helper's settings state (with a stub claude that reports an install record for the worktree, and an assertion that the reap reaches its survivor check). Before the fix: 6 passed, 9 failed, each with "ran the repository's core.fsmonitor". After: 15 passed, 0 failed.
  • scripts/affected-tests.sh --run over this diff: every selected suite passes after one test edit. reap-project-plugin-records.test.sh case 66 records git's argv through a shim and expected a bare rev-parse --is-inside-work-tree; it now expects the overrides ahead of it (94/94). The format plugins' format, lint, end-of-turn and resolve-tool suites all report 0 failed. lib/prerequisites.test.mjs is selected but not run by the shell runner.
  • shellcheck -x clean on every changed shell file; check-changelog-fragments.sh --check passes; the pre-push check-affected passed.

Not delivered

The issue's first Done-when line ("every git call a hook makes against a repository it did not create") is still not met by these three PRs together:

  • worktree-create-gate.sh runs scripts/worktree-create.sh, whose git worktree add runs the repository's post-checkout hook: passing core.hooksPath=/dev/null there changes what it does. Owner decision, as fix(hooks): turn off core.fsmonitor and hooks on the remaining hook git calls #17082 recorded.
  • Eight hooks run their plugin's git-hook entry (git-hooks/lint.sh --worktree or format.sh --worktree) as a separate process in the session's project directory: actionlint-check.sh:13, bash-format.sh:27, go-format.sh:24, javascript-format.sh:16, markdown-format.sh:13, powershell-format.sh:19, python-format.sh:21, spelling.sh:33. That process has no hook-utils.sh, so check-lib.sh and the adapters run plain git. Covering it needs a design choice: the hook passes the overrides through GIT_CONFIG_COUNT/GIT_CONFIG_KEY_n to the child, or check-lib.sh gains a wrapper for its own git calls.
  • Content filters: a status or restore that rehashes a tracked file runs the repository's filter.<driver>.clean; -c cannot switch off a driver whose name is unknown (fix(hooks): turn off core.fsmonitor and hooks on the remaining hook git calls #17082).

Related

🤖 Generated with Claude Code

kyle-sexton and others added 2 commits November 18, 2026 15:30
…helper's git calls

The format hooks source their plugin's git-hook adapters, whose config and
install lookups ran plain `git ls-files` in the edited file's repository, and
worktree-remove-gate runs reap-project-plugin-records.sh, whose settings-state
check ran plain `git ls-files` and `git diff`. Each read the index and so
started the command that repository's `core.fsmonitor` names.

The shared resolve-tool.sh adds `rt_git`: `hook::git_untrusted` when a hook
loaded hook-utils.sh first, plain git in a git hook. The bash, JavaScript,
Markdown and Python adapters and markdown-gates.sh call it. The reap helper
sources hook-utils.sh and calls `hook::git_untrusted`. The override list stays
in one definition.

Refs: #16959

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reap now sends its git calls through hook::git_untrusted, so the logging
git shim records the overrides ahead of the subcommand.

Refs: #16959

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton

Copy link
Copy Markdown
Member Author

Owner of this pull request: the control-hub session for plugin profiles (melodic-software/control-hub#11). It waits on CI Status and the review lanes; the hub reads the reviews and merges. Other sessions: do not push, resolve threads or queue it.

@kyle-sexton
kyle-sexton marked this pull request as ready for review November 18, 2026 20:36
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T20:38:34.136350Z 2007fce Draft marked ready
ℹ️ 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

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 2007fcefc4646b108eaba84403f8c6636c546468: read 26 of 26 changed file(s); 0 finding(s), 0 as inline comments.

Security review: no security issues found

This PR hardens git calls; it does not loosen anything. It adds rt_git to the shared resolve-tool.sh (the source and its eight synced copies). Inside a Claude Code hook, rt_git uses hook::git_untrusted; everywhere else it runs plain git, exactly as before. The bash, JavaScript, Markdown and Python format adapters and markdown-gates.sh now call rt_git. reap-project-plugin-records.sh sources hooks/hook-utils.sh and calls hook::git_untrusted.

What I checked:

  • The wrapper adds overrides and nothing else. hook::git_untrusted is defined at plugins/source-control/hooks/hook-utils.sh#L1017-L1019 and runs git --no-pager -c core.fsmonitor=false -c core.hooksPath=/dev/null "$@". It only adds overrides that turn off fsmonitor and git hooks for a repository the hook did not create. When the function is missing, rt_git behaves as the base code did, so no path runs more code than before.
  • The Markdown trust record still matches. md_trust in markdown-gates.sh now computes its signature with rt_git hash-object --no-filters. The -c overrides do not change object hashes, so existing trust-approvals/md-<sig> records still match. The trust gate is neither widened nor broken.
  • Sourcing hook-utils.sh has no risky side effects. Its top-level statements are a load guard and variable defaults: no stdin read, no traps, no exec. If the source fails, the reap script exits 2 and stops instead of running unprotected git.
  • The tests stay sandboxed. The new test cases in lib/hook-git.test.sh build a stub claude and a worktree in the test's temp directory, and the updated assertion in reap-project-plugin-records.test.sh only expects the new override arguments. Neither reaches anything outside the sandbox.

The diff changes no trust controls, plugin manifests, workflows or standing instructions. The PR description lists remaining gaps (worktree-create.sh, the git-hook entries the eight hooks run as separate processes, and content filters) as not delivered. Those gaps already exist on the base branch; this diff does not add them.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 2007fcefc4646b108eaba84403f8c6636c546468: read 26 of 26 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #17260, no findings

I read every hunk of the full diff. That covers the 17 files in the read scope; the copies listed in identical.txt share their first path's change.

What changed

  • rt_git is added to the shared resolve-tool.sh. The bash, JavaScript, Markdown and Python adapters and markdown-gates.sh now send their git calls through it.
  • reap-project-plugin-records.sh now sources its plugin's hooks/hook-utils.sh and calls hook::git_untrusted.
  • New planted-fsmonitor cases in lib/hook-git.test.sh.
  • One updated expectation in reap-project-plugin-records.test.sh.

What I checked (by reading code; I ran nothing)

  • rt_git resolves everywhere it is called.
    • Every place that sources adapters.sh or markdown-gates.sh sources resolve-tool.sh first. That holds for the in-process hooks (bash-format.sh, javascript-format.sh, markdown-format.sh, python-format.sh) and the git-hooks/{format,lint,lint-full}.sh entries.
    • rt_git tests declare -F when it is called, not when the file is sourced, so the order of sourcing does not matter.
    • Installed git-hook copies stay consistent: install.mjs's stamp hash covers the assets, so an installed resolve-tool.sh cannot lag a newer adapters.sh.
  • Sourcing hook-utils.sh in the reap script is safe.
    • At load it only sets globals and two readonly guards. It defines no have or PROG that would clash with the script's earlier definitions.
    • If the source fails, the script exits 2. worktree-remove-gate.sh refuses on any non-zero reap exit, so the removal fails closed.
  • Existing reap tests still match. The --dry-run filter at reap-project-plugin-records.test.sh#L403 still matches the main-tree probe: the overrides only add a prefix, and the line still ends with the pattern.
  • The new hook-git cases are not vacuous.
    • Each adapter case creates the executable that its probe checks for before it reaches ls-files.
    • The reap case reaches ls-files --error-unmatch, which reads the index, so the planted fsmonitor would fire there.
    • The PR's "9 failed before, 15 passed after" is author-claimed and I did not verify it.
  • Remaining plain git calls are in the stated scope. They are in the actionlint, powershell-format and spelling adapters. Those adapters are reached only through the separate git-hook process, which the PR lists under "Not delivered", and the changelog fragments say so ("adapters do not call it yet").

Closing issue: none. The PR says Refs: #16959 and closes nothing, so there were no acceptance criteria to check.

Path-scoped rules: no .claude/rules/ glob matches a changed file. Paved paths: the standards index has no paved-path row. Plugin manifests: none changed.

Loosened-check verdict: fail (default; no loosened_check_verdict: or loosened_check_patterns: line in the prompt); patterns: 0. I did not check the citation requirement, because the prompt has no loosened_check_decision_record: line.

  • I considered the one changed expectation (reap-project-plugin-records.test.sh#L389-L390) and judged it not a loosening.
  • It is still an exact-equality check on one string, so it accepts nothing it rejected before.
  • It now also requires the core.fsmonitor=false / core.hooksPath=/dev/null overrides, which makes it stricter.

Security-scoped observations are left to the separate security-review lane.

Verifier dropped 0 of 0 candidates.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit bcccf60 Nov 18, 2026
78 checks passed
@kyle-sexton
kyle-sexton deleted the fix/16959-hook-git-overrides branch November 18, 2026 21:06
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant