Skip to content

refactor(guardrails): simplify convention and credential-read hooks - #14664

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14471-42615209822-1
Nov 9, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14471-42615209822-1

Conversation

@melodic-automation-lanes

@melodic-automation-lanes melodic-automation-lanes Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes #14471

Summary

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

Ran the four listed guardrails hooks through /simplify's checks (reuse, simplification, efficiency, abstraction level), without changing behavior. block-convention-violation.sh now combines the duplicate --title/-t case arms, sets the dependency-line flag in one line instead of two near-identical branches, and assigns each key's pattern and diagnostic in a single case (it had two). block-credential-read.sh now checks the env-echo allow-list once for both env-echo shapes. Two files are unchanged. abort-boundary.sh: the only candidate, deduplicating guard::_abort_settle's message, would have moved the stderr notice after the JSON escape, which breaks the 'notice already written' contract that abort-boundary.test.sh asserts; keeping that order made the code longer, so I kept the original. block-cd-prefix.sh: the only candidate, dropping the two empty initializations, trips shellcheck SC2154, so I restored them.

Not verified

  • The guardrails hook test suites (block-convention-violation, block-credential-read and abort-boundary tests) did not run here: the lane allows only the named wrappers, and the review subagent's attempt was refused by the sandbox. Left to the PR's CI.
  • Tidy skipped its code passes: the two changed code files are wired hook commands, which tidy's hard exclusions keep it from editing. Only the markdown passes ran, over the fragment.
  • ai-slop's deterministic detector (detect.sh) did not run, because the lane allows no such command; the fragment's one line was checked against the catalog rubric by reading.
  • ci-status green: a PR CI check, left to the PR's CI.
  • Build/lint beyond check-affected (which ran shellcheck on the changed hooks): no other build applies to bash hooks.

Fix

  • plugins/guardrails/hooks/block-convention-violation.sh: combined the --title and -t case arms; replaced the if/else that built DEP 0|1 lines with one flag assignment; assign each key's pattern and diagnostic in one case statement instead of two
  • plugins/guardrails/hooks/block-credential-read.sh: test allowed env-echo once around both env-echo shape checks (same messages, same order)
  • .changes/guardrails/work-resolve-issue-issue-14471-42615209822-1-16030f2f.md: new patch fragment, ### Changed with 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against 676438b:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • check-changelog-fragments: all 116 fragments valid (run before and after tidy)
  • check-changed-skills: no changed skills under plugins/*/skills/, nothing to gate
  • check-affected: first run failed shellcheck SC2154 on block-cd-prefix.sh (removed initializations); restored them; second run: 13 passed, 6 skipped, 0 failed over the changed files
  • fresh-context review subagent over the whole diff: found one behavior difference (abort-boundary.sh's notice written after the JSON escape, so abort-boundary.test.sh lines 487/495 would fail); I reverted that file to its original. It confirmed no behavior difference in block-cd-prefix.sh,…
  • tidy (code-tidying:tidy-diff): both code rows dropped because the files are wired hook commands (hooks.json:110,114), which the GLOBAL HARD list excludes under enforce; the fragment row got write-for-humans and ai-slop rubric passes with no findings and no edits
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42615209822

Left out: the items under Not verified.

Related

#14471

Merge-Risk: max=HIGH demote=true head=676438b99ab9f20ac3c0b1b76a5521c00fb46041 rubric=8.1.4 rater=claude-opus-5-5 checker=claude-opus-5-5

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

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 676438b99ab9f20ac3c0b1b76a5521c00fb46041: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #14664, no findings

I read every hunk of all 3 changed files. These hooks are guardrails, so I read each refactor under the instruction-surface lens to check that it removes, narrows or softens no block. None of them does.

  • plugins/guardrails/hooks/block-credential-read.sh: one allowed env-echo test now wraps both env-echo shape checks, where before each check ran its own test. The two are equivalent. allowed() only reads CLAUDE_PLUGIN_OPTION_BLOCK_CREDENTIAL_READ_ALLOW and has no side effects (L152-L155). block() exits 2 (L157-L163). The regexes, the messages and the order the checks run in are unchanged, so every command blocked before is still blocked.
  • plugins/guardrails/hooks/block-convention-violation.sh:
    • The --title and -t case arms are combined. Their bodies were identical.
    • The DEP 0|1 flag is now set in one assignment instead of an if/else. The output is the same, and the [[ ]] && ... form inside a loop does not trip errexit.
    • SUBJECT_DIAG and TITLE_DIAG are now set on every pass to conv_diag, which is reset to empty for each key. Before, they were set only when resolution failed. The function runs once (the CONV_LOADED latch, L173), each key appears once in the loop, and both variables start empty (L168-L169). So no diagnostic can be cleared. The fail-open gate and the cache-write skip at L287 see the same values as before.
  • .changes/guardrails/...md: a changelog fragment, with no security surface.

The diff touches no plugin manifest, no trust control and no merge hold. It changes no trusted path, and the PR context contains no embedded instructions aimed at this lane. I did not consult the protected-class register, because the diff removes no rule.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

claude-review reviewed 676438b99ab9f20ac3c0b1b76a5521c00fb46041: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

I read all three changed files in full and checked each refactor against the base behavior. This PR closes #14471, which requires that behavior stay the same. Each change below does what the old code did.

plugins/guardrails/hooks/block-convention-violation.sh

  • DEP 0|1 flag (L236-240): conv_exists=0; [[ -e ]] && conv_exists=1 produces the same line as the old if/else. A failing [[ ]] on the left of && does not trigger errexit.
  • SUBJECT_DIAG / TITLE_DIAG now set on every pass (L255, L271-280):
    • Before, they were assigned only when a key failed. Now each key's pass assigns conv_diag, which is reset to "" at L255.
    • Both globals start empty (L168-169), and ensure_convention_patterns runs once per process because of the CONV_LOADED latch at L173. Each key is visited exactly once in the loop.
    • So both variables end with the same values as before. The L287 cache-write gate and the L289-296 cache write get the same inputs.
  • --title | -t (L495): joining the two case arms keeps the same matches. -t never overlapped --title=*, so moving it ahead of that arm changes nothing.

plugins/guardrails/hooks/block-credential-read.sh

  • Single allowed env-echo check (L243-252): allowed (L152-155) is a pure test with no side effects, and block (L157-163) exits 2. Checking the allow-list once around both shapes keeps the same order, messages and exit codes.

Changelog fragment: bump: patch, ### Changed, and "Internal simplification, no behavior change." match the issue's fragment criterion exactly.

Closing issue #14471 acceptance criteria

  • Behavior unchanged: met, by the reasoning above. I could not run the hook tests here (no shell). The PR says they were left to CI, so that claim is the author's and unverified.
  • Diff edits only listed files and fragments: met.
  • Within 400 lines and 15 files: met.
  • ci-status green: depends on CI; I have not seen the results.
  • guardrails fragment: met.

Path-scoped rules: .claude/rules/mod-authoring.md matches plugins/*/hooks/**, but it only covers hooks modules ("modules" in hooks.json). These are bash hook commands, so it does not apply.

No plugin manifests changed. No embedded instructions were found in the PR context.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 676438b99ab9f20ac3c0b1b76a5521c00fb46041, the head its arming checks judged.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 676438b

The verifier passed this head. The capture artifact holds the capture summary, which says whether the capture ran, and any screenshot or video that passed the mask check; this comment uploads no file.

Capture artifact: pr-capture-14664-676438b99ab9f20ac3c0b1b76a5521c00fb46041, expires on 2026-12-09.

One comment per pull request, updated in place for each new head.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit 0cc2061 Nov 9, 2026
72 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14471-42615209822-1 branch November 9, 2026 14:56
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 0cc2061aabf2ca54563f6faa7f99d2d2a56e3055; later checks count it verified from this comment.

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.

Simplify the hooks guardrails plugin code (1 of 7)

0 participants