Skip to content

fix(hooks): read the tier from -F message files; unscannable forms fail closed (#35) - #84

Merged
atrawog merged 2 commits into
mainfrom
feat/p35-gate-tier-parse
Jul 12, 2026
Merged

atrawog merged 2 commits into
mainfrom
feat/p35-gate-tier-parse

Conversation

@atrawog

@atrawog atrawog commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

#35 (superproject half) — pre-commit-gate: read the tier from -F message files; unscannable forms fail closed

A follow-up to #34 (found while landing it). The pre-commit-gate parsed the attribution tier ONLY from the git commit command string, so an external -F <file> (the form I used for #38/#83) or a $(...) substitution HID the tier — and all three tier-dependent checks (attribution-absence, docs-only-diff, the #34 CHANGELOG requirement) silently failed OPEN.

Change

  • .claude/hooks/pre-commit-gate.sh —
    • scan_commit_args captures -F/--file values into msg_files + flags message-REUSE forms (-c/-C/--reuse-message/--reedit-message/--fixup/--squash, REUSE_OPTS).
    • New read_file_tiers() reads the trailer from a readable regular -F file (capped, never a device/FIFO); - is stdin (readable only via a heredoc whose body is already in the command string).
    • Tier = TIER_RE.findall(cmd) + file_tiers (shared TIER_RE, R3). When no tier is found and the message isn't inherited (amend/reuse), the gate fails CLOSED on an unreadable message ($(...)/backtick, piped/unreadable -F, editor) and reports absence on a readable one — uniformly for all three tier-dependent checks.
  • .claude/hooks/gate_test.py — the old -a -F msg.txt → ALLOW fail-open case flips to BLOCK, plus 9 new cases. 77/77 green.
  • plugins gitlink f8b7f4a → 6c46690 (the agents-skill hooks-doctrine correction, chore(harness): autoMode.allow grants sub-agent/teammate merge authority #35 plugins half, PR refactor(hooks): shared shlex tokenizer, no fallback; fix -C-space; fail closed on unparseable #39).

RDD note (corrects the task framing)

A << heredoc body IS in the command string, so heredoc was NEVER a hole (spike-proven on the harness) — only external -F <file> and $(...) substitutions were. The task's "heredoc→fail-closed" framing is corrected: heredoc stays scannable.

Base

becba99 (post-#34).

R10 — hook/script change class (gate executed live)

Tier analysed on a live system. gate_test.py 77/77 + a coverage-gate differential: -F <file> docs-reviewed+no-CHANGELOG AND -m "$(cat)" → OLD hook=ALLOW (both holes) vs NEW hook=BLOCK (both closed). Dogfooded — this PR's own -F commits pass the new gate.


https://claude.ai/code/session_017rPy3PE6EuVHWsBbAUvxxL

Assisted-by: Claude (analysed on a live system)

…il closed (#35)

The mechanical half of #35 (a follow-up to #34, found while landing it). The pre-commit-gate
parsed the attribution tier ONLY from the `git commit` command string, so an external
`-F <file>` (my own #38/#83 form) or a `$(...)` substitution hid it and all three
tier-dependent checks (attribution-absence, docs-only-diff, the #34 CHANGELOG requirement)
silently failed OPEN. `scan_commit_args` now captures `-F`/`--file` values + reuse flags; a
new `read_file_tiers()` reads readable `-F` files; the tier = `TIER_RE.findall(cmd) +
file_tiers`. When no tier is found and the message is not inherited (amend/reuse), the gate
fails CLOSED on an unreadable message (`$(...)`/backtick, piped/unreadable `-F`, editor) and
reports absence on a readable one. RDD: a heredoc body is in the command string, so heredoc
was never a hole. `analysed on a live system` — gate_test.py 77/77 + an old-fail-open →
new-fail-closed differential.

- .claude/hooks/pre-commit-gate.sh: scan_commit_args (+msg_files, +REUSE_OPTS), the new
  read_file_tiers(), shared TIER_RE (R3), the fail-closed logic.
- .claude/hooks/gate_test.py: the -a -F fail-open case -> fail-closed, +9 new cases. 77/77.
- plugins gitlink -> 6c46690 (the agents-skill hooks-doctrine correction, #35 plugins half).

Assisted-by: Claude (analysed on a live system)
Claude-Session: https://claude.ai/code/session_017rPy3PE6EuVHWsBbAUvxxL
@atrawog

atrawog commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

pr-validator — APPROVED ✅

Change class: hook/workflow (behavioral) — pre-commit-gate tier-parsing hardening (#35 code half)

I am a FRESH, independent validator (not the author). I re-derived every claim.

Independent verification (trust-no-author)

  • gate_test.py on the PR final code (materialized from 623b5ea, sha-verified): 77 case(s), 0 failure(s), exit 0.
  • DIFFERENTIAL — NEW test suite vs the OLD gate (becba99): 7 fail-OPEN holes now BLOCK. Each OLD=ALLOW → NEW=BLOCK: unreadable -F; -F docs-tier w/o CHANGELOG (refactor(charly): externalize deploy/IR machinery to sdk (P4) #34 now fires); -F docs-tier on a CODE diff; -F no-trailer; nonexistent -F; -m "$(cat)" substitution; bare editor commit. Preserved on both gates: heredoc docs-tier no-CHANGELOG = BLOCK (corroborates the RDD note — a heredoc body lives in the command string, never a hole), -F + CHANGELOG = ALLOW, --amend --no-edit = ALLOW.
  • Gate logic by inspection: read_file_tiers reads only regular files (os.path.isfile), capped at 1 MiB, never a device/FIFO; a - value is readable only via a heredoc, a piped - is unreadable. Fail-CLOSED is the consistent SAFE direction for every ambiguous form; legit -m/heredoc/readable--F-with-trailer and --amend/reuse are correctly exempt. The tier now flows into assert_docs_only / assert_changelog / late-staging for -F commits too.
  • Self-block check: this PR's own commit form (-F message, runtime tier, CHANGELOG staged) → the NEW gate ALLOWs. It does not self-block.
  • Gitlink: plugins f8b7f4a → 6c46690 is a FORWARD bump (ancestor→descendant), 6c46690 is on plugins origin/main (refactor(hooks): shared shlex tokenizer, no fallback; fix -C-space; fail closed on unparseable #39's merge — the matching hooks doctrine). Rides at the runtime tier (correct).

Security screen (T1–T4)

STRENGTHENS the security machinery — closes 7 differential-proven fail-open holes, loosens nothing (every unscannable form fails CLOSED). No exfiltration, no scope mismatch, no supply-chain surprise, no attempt to manipulate the validator. The REUSE_OPTS exemption is not a new hole — the old gate already left reuse forms un-gated for absent-trailer/CHANGELOG; the exemption only prevents the new fail-closed path from OVER-blocking a legitimate inherited-message reuse, mirroring the pre-existing --amend exemption.

Checklist — all 18 PASS

0 security ✅ · 1 description ✅ · 2 change-class gate (77/77 live) ✅ · 3 tier analysed on a live system justified ✅ · 4 R0 agents-hooks-doctrine honored ✅ · 5 R1 zero-warning/RCA ✅ · 6 R2 immediate-next cutover ✅ · 7 R3 shared TIER_RE ✅ · 8 R4 no ad-hoc workaround ✅ · 9 R5 hard cutover + no stale refs ✅ · 10 R6/R8/R9 N/A ✅ · 11 R10 coverage-that-fails-without-fix ✅ · 12 RDD spike / ADE·SDD N/A ✅ · 13 concurrency N/A ✅ · 14 one atomic commit ✅ · 15 kernel-boundary N/A ✅ · 16 disposable-autonomy N/A ✅ · 17 clean-arch/go-gates N/A ✅ · 18 CHANGELOG present ✅

Decision: APPROVED. The fix closes real, differential-proven fail-open holes in the attribution gate while preserving every legitimate commit form; the tier now flows through all three tier-dependent checks for -F and heredoc messages, and every unscannable form fails CLOSED. Finalizing the merge-time CalVer and squash-merging.

Assisted-by: Claude (analysed on a live system)

Assisted-by: Claude (analysed on a live system)
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.

1 participant