Skip to content

refactor(guardrails): simplify secret-pattern-detection and skill-reference-verify hooks - #15209

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14485-42919011265-1
Nov 11, 2026
Merged

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14485

Summary

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

Simplified the two guardrails hooks without changing behavior. secret-pattern-detection.sh now has one spd_send_tel helper for the telemetry envelope both lanes emit and one spd_one_link helper for the hard-link check both path gates ran. Its MCP dispatch also runs straight from the tool case, so the IS_MCP flag is gone. skill-reference-verify.sh now passes the text to emit_refs as an argument instead of saving and restoring SCAN_CONTENT around the call, folds two redundant skill-name branches, and moves srv_git_dir_to above the manifest-index comment that describes build_plugin_index. Every helper is a pure extraction: same commands, same arguments, same return statuses, no added process.

Not verified

  • The guardrails hook test suites (secret-pattern-detection.test.sh, skill-reference-verify.test.sh) were not executed: this lane runs no interpreter or test runner. Left to the PR's CI.
  • bash -n syntax check could not run in this lane; check-affected passed and the review read every hunk. Left to the PR's CI.
  • Tidy did not run on the code: both hook scripts are wired as hook commands, and secret-pattern-detection.sh is a secret-pattern detection rule, so tidy's GLOBAL HARD exclusions (enforced) dropped every code row. Its markdown passes were skipped for the changelog fragment because the issue fixes…
  • ci-status green is a PR CI check, left to the PR's CI.
  • Untracked .bashrc, .bash_profile, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile and .zshrc at the repository root are /dev/null character devices the sandbox mounts, not part of this change; they should be excluded from the patch.
  • hardcoded-path-check.sh still has the IS_MCP flag and inline jq envelope shape this change removed here; deduping across files is out of scope (the sub-epic's restructuring pass).

Fix

  • plugins/guardrails/hooks/secret-pattern-detection.sh: extracted spd_send_tel (the shared jq envelope and hook::emit_telemetry call, used by mcp_lane and emit_tel) and spd_one_link (the stat hard-link check, used by spd_temp_declines and spd_exempt_target); removed IS_MCP by running mcp_lane; exit 0…
  • plugins/guardrails/hooks/skill-reference-verify.sh: emit_refs takes its text as $1 (both call sites pass it), replacing the SCAN_CONTENT save/restore; skill_resolves folds an if/else into ${fname:-${sdir##*/}} and drops an -n test that a non-empty $skill makes redundant; srv_git_dir_to moved above…
  • .changes/guardrails/work-resolve-issue-issue-14485-42919011265-1-6b501300.md: patch fragment, ### Changed, "Internal simplification, no behavior change."

Verification

The runner ran each check from the base copy against 8b03cf4:

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

The run reports:

  • check-changelog-fragments: all 29 fragments valid (run before and after tidy)
  • check-changed-skills: no changed skills, nothing to gate (run before and after tidy)
  • check-affected: 13 passed, 6 skipped over 3 changed files (run before and after review)
  • fresh-context review subagent over the full diff: no findings; it confirmed each extracted helper keeps its callers' return statuses, that no other file reads the removed IS_MCP/links/saved, that hardcoded-path-check.sh sets its own IS_MCP before reading it, and that no test asserts on changed…
  • read secret-pattern-detection.test.sh D1_SEAM and SPE_SEAM: both cut by pattern from ^spd_win=0$ to the spd_temp_declines call, and the new spd_one_link sits inside that range, so the seam-evaluated code still defines it
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42919011265

Left out: the items under Not verified.

Related

#14485

Merge-Risk: max=MEDIUM demote=false head=8b03cf4937739c1cf6da3a2a5071129c342d0146 rubric=8.3.5 rater=claude-opus-5-5 checker=claude-opus-5-5

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

Copy link
Copy Markdown
Contributor

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

Security review: PR #15209, refactor of two guardrails hooks

No security issues found. This is a full review: I read every hunk of all 3 changed files. None of them matches a trusted-path glob, and the PR touches no trust control and no plugin manifest.

secret-pattern-detection.sh is a guardrail hook, so I checked each change for whether the scan still runs and still fails closed:

  • spd_one_link. This is the hard-link check, now used by spd_temp_declines (line 595) and spd_exempt_target (line 700). I compared it with the inline code it replaces:
    • When the target is not a regular file, it returns 0, which is the same as skipping the old if [[ -f ]] block.
    • When both stat forms fail, it returns 1. The callers' || return 1 then declines the exemption, so the file is scanned.
    • A link count other than 1 also returns 1, so the file is scanned.
    • It receives the same $t, after the same Windows rewrite in spd_exempt_target. links is now local to the helper, and nothing else reads it (I grepped). Neither path gate gets wider.
  • MCP dispatch. The GitHub MCP write tools (push_files / create_or_update_file, including the mcp__plugin_*_github__* forms) still reach mcp_lane (lines 286–293). That function exits 2 on a violation, and the arm then exits 0, the same as the old IS_MCP branch. Write, Edit and NotebookEdit fall through to the local-write scan, and every other tool exits 0 as before. Under set -uo pipefail, no other line reads IS_MCP (grepped).
  • spd_send_tel. This is the same jq envelope and hook::emit_telemetry call, with the same arguments, at both call sites (lines 268 and 653). It only changes telemetry, not the block decision.

skill-reference-verify.sh is a check that skill references resolve, not a security control:

  • emit_refs now takes its text as $1, and both callers pass it (lines 851 and 857).
  • The two skill_resolves folds behave the same because $skill is never empty.
  • Moving srv_git_dir_to up only defines it earlier than its first call, at line 278.

The changelog fragment is prose only.

The PR context contains no embedded instructions aimed at the review. Nothing removed narrows a standing instruction, so the instruction exception register was not needed. This lane has no earlier findings on this PR.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: no findings

This PR refactors two guardrails hooks without changing their behavior, and adds a patch changelog fragment. I read every hunk of all 3 changed files.

What I checked against the base code, by reading only. I could not run anything here: no bash -n and no test suites. The author's verification list is their own claim and I have not confirmed it.

  • secret-pattern-detection.sh
    • spd_send_tel: it builds the same jq envelope and makes the same hook::emit_telemetry call as before. $start is the script-level global at line 69. data is still declared local, now inside the helper.
    • spd_one_link: it returns 0 when the path is not a regular file or has exactly one link. It returns 1 when the link count cannot be read or is above 1. Both callers use || return 1, so they keep the old status.
    • Removed links local: no other line in the file reads links.
    • Test seams: spd_one_link sits at line 468. That is inside the D1_SEAM and SPE_SEAM range, which runs from line 413 (spd_win=0) to line 611 (the spd_temp_declines "$FILE" && exit 0 call). So the spd_exempt_target seam test at secret-pattern-detection.test.sh:1305 still has the helper defined.
    • IS_MCP removal: the MCP branch now runs mcp_lane; exit 0 straight from the case. Nothing ran between the old esac and the if ((IS_MCP)) check, so the order is the same. hardcoded-path-check.sh keeps its own IS_MCP variable.
  • skill-reference-verify.sh
    • emit_refs: both callers now pass the text as an argument (lines 851 and 857). No other caller exists.
    • Root SKILL.md check: ${fname:-${sdir##*/}} gives the same result as the old if/else.
    • Dropped -n test: removing it is safe because skill comes from ${ref##*:}. emit_refs' pattern :[a-z][a-z0-9-]* guarantees a non-empty value there.
    • srv_git_dir_to: the function is now defined earlier in the file. Its only call is at line 278, which comes after the new definition.

Closing issue #14485, acceptance criteria:

  • Behavior is unchanged: met, as far as I can tell from reading. The existing hook test suites cover these paths.
  • The diff edits only the listed files and changelog fragments: met.
  • Within 400 changed lines: met. The diff is small.
  • The fragment has ### Changed and "Internal simplification, no behavior change.": met. The fragment is bump: patch with that exact body.
  • ci-status is green: left to CI. I did not check it.

There are no plugin manifest changes and no prior findings from this lane. The PR does not touch any trusted path.

Spend: none. Nothing in this change starts a charge, so there is no hold.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 8b03cf4

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-15209-8b03cf4937739c1cf6da3a2a5071129c342d0146, expires on 2026-12-10.

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 10, 2026
Merged via the queue into main with commit e18c9d0 Nov 11, 2026
72 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14485-42919011265-1 branch November 11, 2026 00:02
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit e18c9d04e3949ed4b6a9c64d14f6b12589024132; 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 (7 of 7)

0 participants