Skip to content

fix(guardrails): batch the pre-commit content scan instead of spawning processes per file - #11135

Merged
melodic-automation-lanes[bot] merged 2 commits into
mainfrom
work-resolve-issue/issue-10591-40993954103-1
Oct 30, 2026
Merged

melodic-automation-lanes[bot] merged 2 commits into
mainfrom
work-resolve-issue/issue-10591-40993954103-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #10591

Summary

Opened by the work-resolve-issue lane. The run's own summary:

The guardrails pre-commit content hook started about 10 to 20 processes per staged file, so a merge of the default branch took 23-55 s. Following the owner's recorded decision (option a: faster, not narrower), it now reads every line it read before with a few processes per commit plus one git read per file. A raw diff gives modes and object ids, one batch query gives sizes, one grep over all files finds the secret candidates, and a joined, halving path probe replaces most per-file path scans. Findings stay the same, and a file it cannot read or write down now blocks instead of going unscanned.

Not verified

  • pre-commit-content.test.sh was not executed: this lane runs no test runner or interpreter, and check-affected runs without --tests. The new and existing cases are left to the PR's CI test lanes.
  • No wall-time or file-count measurement of the hook on a large merge was taken here (no command can run the hook in this lane). The decision record moves the before/after timing to a post-merge check on the owner's host.
  • checks_changed_lines in the shared check-lib.sh still probes each changed file for NUL bytes (about three processes per file). The decision keeps the shared check-lib.sh copies unchanged, so that cost remains.
  • Tidy ran only the markdown passes on the changelog fragment, with no edits. The hook script and its test were dropped from tidy because they are a git-hook script and secret-detection fixtures under the tidy GLOBAL HARD list. The ai-slop detector script could not run in this lane, so the rubric was
  • The decision record's 'security-review pass at the PR head' (from the earlier re-triage comment) was covered only by the local fresh-context review, which looked for fail-opens; no separate /security-review ran in this lane.
  • Behavior change beyond speed: a staged file whose content cannot be read out, or a scan text that cannot be written under the temp directory, now blocks the commit with a message where it was skipped before. A staged name starting with '<0-3>:' is now read by object id and scanned, where the o

Fix

  • plugins/guardrails/git-hooks/pre-commit-content.sh: replaced the per-file index_mode/file_size/checks_has_nul/checks_file_text calls with one raw diff (checks_diff --raw --no-abbrev -z --diff-filter=ACMR, the same set checks_files lists), one git cat-file --batch-check for sizes and one `git cat
  • plugins/guardrails/git-hooks/pre-commit-content.test.sh: added a multi-file fixture set judged in one commit with pinned findings: a secret, Linux machine paths, a Windows user path in a .ps1 that the OS context suppresses beside a Linux path that it does not, a NUL-byte file, a quoted file name, cl
  • .changes/guardrails/fix-10591-batch-pre-commit-content-scan-3b7d91e2.md: patch changelog fragment for guardrails.

Verification

The runner ran each check from the base copy against 63e4214:

  • scripts/check-changelog-fragments.sh --check: passed

The run reports:

  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-changelog-fragments: all 18 fragments valid
  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-affected: first run failed shellcheck (SC2004 in the hook, SC1003 in the test); fixed both; final run 12 passed, 6 skipped, 0 failed
  • cant-fail-scan --file plugins/guardrails/git-hooks/pre-commit-content.test.sh --check: PASS, no gating findings
  • fresh-context review subagent over the whole diff: found two fail-opens (joined probe could overflow the awk argument limit and scan clean; unchecked temp-file writes could skip a file when TMPDIR fills) and one output-order difference under sort -u for file names holding ':'; all three fixed (32 Ki
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/40993954103

Left out: the items under Not verified.

Related

#10591

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

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

No security findings in the incremental change since 63e4214.

The only change is one line in plugins/guardrails/git-hooks/pre-commit-content.test.sh (line 240). It edits a test fixture: the non-ASCII sample written to f.md changes from café dev notes to été dev notes. Both are plain UTF-8 test data written to a temporary test repo.

  • It touches no hook logic, no secret or path patterns, no token handling, and no trust control.
  • The file is a test script and matches no trusted-path glob.
  • It changes no manifest and no instruction surface.

I skipped deep review because the change has no security-relevant surface. Files other than this one were reviewed at 63e4214 and are unchanged since.

critical-findings: 0

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 06f496704b3464dc36b1b6fe8a7bc56c02c592d5: 0 finding(s), 0 as inline comments.

Incremental review of plugins/guardrails/git-hooks/pre-commit-content.test.sh since 63e4214. No findings.

The only change is the f.md fixture at line 240. It was café dev notes and is now été dev notes, written with the same octal printf escapes. The file is still clean text that contains non-ASCII bytes, and the expected findings in want (a.md, b.md, e.ps1:2, n.bin, the optional quoted name) don't mention it. So the multi-file case should still expect no finding for f.md. The comment above the fixture (lines 226-229, "clean text the path scan still has to read (ASCII and not)") still describes it accurately.

I read the hook's ascii_text helper (pre-commit-content.sh:104-107). Both versions of the fixture hit its non-ASCII branch. I did not find why the byte content was changed. I did not run the test, since this lane has no shell. Whether it passes is left to the PR's CI test lanes.

No spend, manifest, or trusted-path concerns apply to this change.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head 63e4214888dafcd60aa4345ca14a9ccb75d94a70. The lanes clear this reason on their own; the next scheduled run judges it again.

pr-merge's gate refuses its verifier verdict (verify:missing)

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 06f496704b3464dc36b1b6fe8a7bc56c02c592d5.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit 3ec5bf2 Oct 30, 2026
40 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-10591-40993954103-1 branch October 30, 2026 03:56
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.

guardrails: pre-commit content scan takes 23-55 s on merge commits

0 participants