Skip to content

refactor(scripts): simplify six hook and guardrails check scripts - #14796

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14356

Summary

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

Simplified six of the eight listed scripts without changing behavior. Repeated code is collapsed (the jq args join, the duplicate command branches in the frontmatter reader, the sorted findings print), single-use helpers are inlined, and the liveness gate now builds each hook's match pattern once per hook instead of spawning sed once per hook-and-ref pair. check-hooks-description.sh and check-html-assets.sh were already tight and are unchanged. The only cut that would have changed printed output (running htmlhint once instead of twice on a lint failure) was not made.

Not verified

  • Tidy step skipped: every change is under scripts/, a listed shared path, so the change is not tidied.
  • Whole-repo scanners for these gates (hook-exec-form, hook-slow-shapes, hook-wiring-liveness, hooks-description, userconfig-argv) and the scripts' *.test.sh suites, plus check-guardrails-ps-differential.test.sh, are not run here; check-affected marks the scanners CI only, so they are left to the…
  • check-hook-wiring-liveness.sh: if sed itself failed while escaping a basename, set -e now stops the script, where before the failure was hidden inside a || continue call. Review judged this unreachable in practice.
  • check-hooks-description.sh and check-html-assets.sh are unchanged: no simplification found that keeps printed output identical.

Fix

  • scripts/check-guardrails-ps-differential.sh: row_args_of's jq binds the joined args string once as $args; the base-refused command indices are collected once into REFUSED and reused by both the token-subset cell list and the report loop instead of re-reading results twice; report_cell declares…
  • scripts/check-hook-exec-form-frontmatter.py: scan_node merges the exec-form and shell-form command branches into one (same V/N/S/X records and text); frontmatter_of drops the dead not lines test (str.split never returns an empty list).
  • scripts/check-hook-exec-form.sh: is_bare, consider and flag are folded into on_hook, the only caller; same rule, same message and counters.
  • scripts/check-hook-slow-shapes.sh: the sorted findings print, written twice, is now one print_findings function.
  • scripts/check-hook-userconfig-argv.sh: the remedy text is a quoted heredoc instead of five echo lines (same text, leading blank line kept).
  • scripts/check-hook-wiring-liveness.sh: hook_ref_matches is inlined into the loop and the escaped basename pattern is computed once per hook instead of once per (hook, ref) pair.

Verification

The runner ran each check from the base copy against ebd5684:

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

The run reports:

Left out: the items under Not verified.

Related

#14356

Merge-Risk: max=MEDIUM demote=false head=ebd5684ac42545376c17e28d9615437e1ed8aad1 rubric=8.1.6 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 ebd5684ac42545376c17e28d9615437e1ed8aad1: read 6 of 6 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #14796, head ebd5684a

No security issues found.

This was a full first review, not a blocking-only one: the prior-findings file shows no earlier heads reviewed. I read every hunk of all 6 changed files.

Scope

The diff only refactors six CI check scripts under scripts/. None of them matches a TRUSTED PATHS glob. None is a trust control: the trusted-trigger check, the lane token request or broker, the kill switch, merge holds and the other .github/actions/ controls are untouched. No instruction surface or plugin manifest is changed.

What I checked

I compared each rewrite with the base logic to see whether any check now passes something it used to fail:

  • check-guardrails-ps-differential.sh
    • The jq $args binding picks the same value as before.
    • The commands base block-dangerous-git refuses are now gathered once into REFUSED. The cell list and the report loop both read that list, so they cover the same cells as the two scans they replace.
    • The empty-array spelling ${REFUSED[@]+"${REFUSED[@]}"} is safe under set -u.
    • The differential guardrail check covers the same cells, so a lost refusal is still reported.
  • check-hook-exec-form-frontmatter.py
    • The merged command branch emits the same records (V/N/S/X) for exec-form and shell-form hooks, including a command that is not a scalar.
    • The dropped not lines test was dead code: str.split never returns an empty list.
  • check-hook-exec-form.sh
    • The rule folded into on_hook is unchanged: only exec form, a bare command with no / or \, and the same allowlist check.
    • It prints the same message and increments the same counters.
  • check-hook-slow-shapes.sh: print_findings is exactly the sorted print it replaces.
  • check-hook-userconfig-argv.sh: the remedy text is now a quoted heredoc. It is static text with no expansion and still ends in exit 1.
  • check-hook-wiring-liveness.sh
    • The inlined test [[ "$ref" == *"$hook"* || "$ref" =~ $pat ]] matches the same way as the removed hook_ref_matches.
    • The PR notes that a sed failure now stops the script under set -e. A stop fails the check, so this can only make it stricter.

No changed script handles credentials, tokens or untrusted input in a new way, and none lets through a hook or guardrail case the base version rejected.

PR context

I found no embedded instructions aimed at the review lane. The PR text says the scripts' *.test.sh suites and the whole-repo scanners were not run by the authoring lane, and leaves them to CI. That is a verification gap, not a security finding.

Spend

None. The change touches no billing, paid plan or runner settings.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Code review: PR #14796, refactor(scripts): simplify six hook and guardrails check scripts

No findings. I read every hunk of all 6 changed files and checked each rewrite against the base behavior. This is a complete review, not a partial one. No changed file matches a trusted-path glob.

What I checked, file by file:

  • scripts/check-guardrails-ps-differential.sh
    • The jq $args binding returns the same string and takes the same elif/empty branches as before.
    • REFUSED is filled after run_cells cells1. That is the same data both old loops read, because the mask-0 result files are not rewritten by cells2.
    • The empty-array expansion ${REFUSED[@]+"${REFUSED[@]}"} is safe under set -u.
    • [[ … ]] && REFUSED+= inside the loop does not trip set -e. It is the same pattern already used in report_cell.
    • Moving local tokens changes nothing.
  • scripts/check-hook-exec-form-frontmatter.py
    • str.split("\n") always returns at least one element, so dropping not lines changes nothing.
    • The merged scan_node branch still emits V/N for a scalar command with args, S for a scalar command without args, and X with the same "an exec-form" / "a shell-form" wording otherwise.
  • scripts/check-hook-exec-form.sh: the inlined on_hook keeps the same order (exec form only, path separator, then allowlist), the same message and both counters.
  • scripts/check-hook-slow-shapes.sh: print_findings returns 0 when there are no findings and prints the sorted list to stderr otherwise. Both call sites behave as before.
  • scripts/check-hook-userconfig-argv.sh: the quoted heredoc prints the same text. That includes the leading blank line and the literal ${user_config.*}, which the old echo produced with \$.
  • scripts/check-hook-wiring-liveness.sh
    • The inlined test matches the same refs: a quoted literal *"$hook"* or the segment-bounded ERE.
    • ere/pat are now script globals. Nothing else in the file uses those names.
    • One difference the PR body already states: if sed itself failed, set -e would now stop the script.

Closing issue #14356 acceptance criteria:

  • Behavior unchanged: met as far as I can tell from reading the code. The existing suites can fail if it breaks: check-guardrails-ps-differential.test.sh, check-hook-exec-form.test.sh (which also exercises the frontmatter reader), check-hook-slow-shapes.test.sh, check-hook-userconfig-argv.test.sh and check-hook-wiring-liveness.test.sh. I did not run them; I have no shell. The PR body says the scanners and their *.test.sh suites were not run either and are left to CI.
  • Edits only listed files: met. All 6 files are on the issue's list.
  • Within 400 lines / 15 files: met (6 files, about 100 changed lines).
  • ci-status green: CI has to show this; I could not check it.

Everything the PR body says it verified (check-affected, changelog fragments, the subagent review) is the author's claim. I did not confirm any of it.

Path-scoped rules: only .claude/rules/ruff-pin.md (**/*.py) matches a changed file. It is about the Ruff version pin, which this change does not touch.

Embedded text: none found in the PR context.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for ebd5684

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-14796-ebd5684ac42545376c17e28d9615437e1ed8aad1, 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 6cbdc2b Nov 9, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14356-42646630635-1 branch November 9, 2026 20:04
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 6cbdc2b2d2252c492031fef9cb33299c82226352; 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 check-guardrails-ps-differential.sh, check-hook-exec-form-frontmatter.py, check-hook-exec-form.sh and 5 more repository scripts

0 participants