Skip to content

feat(git-hooks): read pushed blobs in pre-push checks through a shared check-lib reader - #8024

Merged
kyle-sexton merged 6 commits into
mainfrom
work-resolve-issue/issue-7898-39095565459-1
Oct 20, 2026
Merged

kyle-sexton merged 6 commits into
mainfrom
work-resolve-issue/issue-7898-39095565459-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #7898

Summary

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

Adds checks_file_text and checks_regular_file to the shared check library. In pre-push mode they read a path from the tip of the pushed range that changed it, with an optional --tip for two refs changing one path. reference-verify drops its private copies and uses them.

Not verified

  • check-lib.test.sh and reference-verify.test.sh do not exit 0 in this runner: hook-installation and hook-firing cases fail (install.mjs 'hook managers conflict'; commit hooks do not fire). I could not confirm these fail on main too, since a baseline checkout was not permitted; they do not touch the c
  • sync-shared-copies --check-bump origin/main refused to run (the lane's copy runs from outside the repo, exit 2); left to the PR's CI. Fragments for all 10 carrying plugins were added by hand.
  • shellcheck could not be run here

Fix

  • lib/git-hooks/check-lib.sh: new checks_range_tip, checks_regular_file, checks_file_text, documented in the header list
  • lib/git-hooks/check-lib.test.sh: pre-push reader cases (committed vs edited worktree, two refs, --tip, deleted path, symlink, untouched path, worktree mode)
  • plugins/*/lib/git-hooks/check-lib.sh: regenerated by sync-shared-copies
  • plugins/guardrails/git-hooks/reference-verify.sh: private file_text/regular_file replaced by the shared functions
  • .changes/<plugin>/feat-prepush-check-lib-reader-7898a1c4.md: fragments for the 10 carrying plugins (guardrails minor, others patch)

Verification

The run reports:

Left out: the items under Not verified.

Related

#7898

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

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

Security review (incremental, since 6510a65, head d8921da): no security findings.

The change merges checks_file_text and checks_regular_file in lib/git-hooks/check-lib.sh into a single reader with a shared --tip parse (checks_tip_arg). It reads from the tip of the pushed range in pre-push mode, from the work tree in worktree mode, and from the index in pre-commit mode. The ten plugin copies are regenerated from it, and the .changes/* fragments and check-lib.test.sh are updated.

  • Path handling: paths and revs come from git or hook arguments and are quoted. They only reach git show, git ls-tree, git ls-files (with :(literal)) and cat --, so there is no injection or path-traversal surface.
  • Regular-file check: it still excludes symlinks and submodules in every mode, so a symlink can't make a check read an arbitrary file.
  • Callers: pre-commit-content.sh calls checks_file_text with no tip, and reference-verify.sh passes --tip "$TIP". Neither treats a non-regular path as clean in a way that opens a new bypass. A symlink's own target text is no longer secret-scanned in pre-commit mode. That text is only a path string, and pre-push already skipped symlinks, so I'm not reporting it.
  • Copies: the ten plugin copies of check-lib.sh are identical to the canonical file apart from the generated-file header.
  • Instruction surfaces: the diff doesn't delete or soften any standing instruction, so I didn't consult the instruction exception register.

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

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

No findings in the incremental changes (6510a65 → d8921da).

What changed. The earlier head defined checks_file_text twice in lib/git-hooks/check-lib.sh. The later, older-style definition silently overrode the new pre-push reader. This head merges them into one pair:

  • checks_tip_arg is a shared [--tip <sha>] <path> [<rev>] parser.
  • checks_regular_file and checks_file_text pick the tip's tree, the work tree (worktree mode) or the index (pre-commit) in the same place.

The header docs, the nine changelog fragments and the ten plugin copies were updated to match.

What I checked by reading.

  • Parser scoping. checks_tip_arg writes tip and path through bash dynamic scope. Both callers declare them local, so nothing leaks.
  • Empty --tip. checks_file_text passes --tip "" outside pre-push. The parser then falls through to the mode branch as intended.
  • <rev> callers. checks_has_nul and checks_change_has_nul pass a <rev>, which the parser treats as the tip. That path still works.
  • Behaviour change in checks_file_text. It now returns 1 for a non-regular path, such as a symlink or submodule, in pre-commit and worktree modes too. The callers in pre-commit-content.sh and reference-verify.sh already skip non-regular paths first. checks_has_nul reads an unreadable path as "no NUL", the same result as before. I found no regression.
  • New test cases. The four added in lib/git-hooks/check-lib.test.sh cover:
    • <rev> read in pre-push
    • worktree reads on disk
    • pre-commit reads the index rather than the unstaged edit
    • an indexed symlink is not a regular file
  • Closing issue feat(git-hooks): read pushed blobs in pre-push checks through a shared check-lib reader #7898. Its acceptance criteria for committed-versus-edited content, two refs, and a deleted path are still met by the earlier cases, which this diff doesn't touch. The new cases add coverage for the merged behaviour.
  • Fragments. The guardrails fragment is unchanged and still accurate.

What I could not run. The sandbox refused sync-shared-copies.sh --check and the loop that compares the copies with the canonical file. I couldn't confirm the plugin copies match byte for byte. Each copy's diff is the same 104-line change, which is consistent, but CI's --check is the real confirmation. I also did not run the test scripts or shellcheck. The PR's own verification claims remain author-claimed.

@melodic-automation-lanes

melodic-automation-lanes Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Unattended merge: the verifier verdict refuses verify:earlier-fail at head d8921da3f4e7260127c5c526d33653e5ed7ddf6a. That refusal needs a human, who merges in person; the pr-merge lane will not merge this pull request.

@melodic-automation-lanes melodic-automation-lanes Bot added the needs-human Human-in-the-loop required; autonomous sessions must not resolve items carrying this. label Oct 19, 2026
kyle-sexton and others added 2 commits October 20, 2026 01:39
…n reference-verify

reference-verify called checks_file_text and checks_regular_file without
--tip, leaving the shared reader to pick the first range touching the path.
It now passes --tip "$TIP" for the range being checked, and a two-ref test
covers two pushed refs changing the same file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SysXJ1mcLncKqyhsHzqKjP
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The pr-merge lane escalated this pull request, and its head has moved (head-moved): its escalation names head 5581bee328c95441bc15dc00f32149616ff792d8, and the head is now 5ca84347674ca4d29e79dd04a13f4e712081a980. pr-merge removed needs-human so it judges 5ca84347674ca4d29e79dd04a13f4e712081a980 afresh, and escalates again if its refusal still holds. To keep a person on it, add needs-human back: a label a person adds is never removed.

@melodic-automation-lanes melodic-automation-lanes Bot added needs-human Human-in-the-loop required; autonomous sessions must not resolve items carrying this. and removed needs-human Human-in-the-loop required; autonomous sessions must not resolve items carrying this. labels Oct 20, 2026
@kyle-sexton kyle-sexton removed the needs-human Human-in-the-loop required; autonomous sessions must not resolve items carrying this. label Oct 20, 2026
@kyle-sexton

Copy link
Copy Markdown
Member

Removed needs-human: its recorded reason (the pr-verify verify:fail refusal) is cleared. The reference-verify.sh reader calls now pass --tip "$TIP" (fix at 5ca8434), and pr-verify passed this head (run https://github.com/melodic-software/claude-code-plugins/actions/runs/39378009595, verdict pass-notes, 06:02Z). CI is green on this head. Merging under the owner's overnight SOP.

Lane-Activity: pr-unblock/resolve-conflicts
Comment thread lib/git-hooks/check-lib.sh Resolved
Conflict: plugins/guardrails/git-hooks/reference-verify.sh. Kept main's
quoted-name whole-file branch (#8232) and this branch's shared reader calls
with --tip "$TIP".

Semantic conflict: main added checks_file_text <path> [<rev>] to
check-lib.sh, and this branch added checks_file_text [--tip <sha>] <path>;
both definitions merged cleanly, and the later one shadowed the earlier.
They are now one function taking both forms: the tip's blob, else the work
tree in worktree mode, else the index, returning 1 for a path that is not a
regular file there. checks_regular_file reads the same place, the index in
pre-commit. Worktree reader tests now run with --worktree, with pre-commit
index and <rev> cases added. Copies regenerated; fragments reworded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SysXJ1mcLncKqyhsHzqKjP
@melodic-automation-lanes melodic-automation-lanes Bot added the needs-human Human-in-the-loop required; autonomous sessions must not resolve items carrying this. label Oct 20, 2026
…095565459-1' into work-resolve-issue/issue-7898-39095565459-1
@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 20, 2026
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The pr-merge lane escalated this pull request, and its head has moved (head-moved): its escalation names head 6510a6500ad18e06de809d81be994514986a4af3, and the head is now d8921da3f4e7260127c5c526d33653e5ed7ddf6a. pr-merge removed needs-human so it judges d8921da3f4e7260127c5c526d33653e5ed7ddf6a afresh, and escalates again if its refusal still holds. To keep a person on it, add needs-human back: a label a person adds is never removed.

@melodic-automation-lanes melodic-automation-lanes Bot removed the needs-human Human-in-the-loop required; autonomous sessions must not resolve items carrying this. label Oct 20, 2026
Merged via the queue into main with commit 94f1126 Oct 20, 2026
41 checks passed
@kyle-sexton
kyle-sexton deleted the work-resolve-issue/issue-7898-39095565459-1 branch October 20, 2026 06:47
@melodic-automation-lanes melodic-automation-lanes Bot added the needs-human Human-in-the-loop required; autonomous sessions must not resolve items carrying this. label Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-human Human-in-the-loop required; autonomous sessions must not resolve items carrying this.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(git-hooks): read pushed blobs in pre-push checks through a shared check-lib reader

1 participant