Skip to content

refactor(guardrails): simplify part 1 of block-root-delete-target.sh without changing behavior - #15207

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14476

Summary

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

Simplified code in range 1 of 5 (lines 1-1667 of 8337, measured at the start) of plugins/guardrails/hooks/block-root-delete-target.sh with no behavior change. The PowerShell CR/LF unescape now uses one bracket pattern per case pair instead of two substitutions. The PowerShell prefilter drops its rdt_ps_hit flag and exits straight from the case fallback. rdt_is_root folds its four drive-root regexes into one anchored alternation and returns that test's status. rdt_runuser_argv's long-option branch tests command/session-command once instead of twice. I left the header comment block and the other functions in range as they were: they are already tight, and rewording the documentation is not a code simplification.

Not verified

  • The guardrails hook test suites (block-root-delete-target*.test.sh, run-guards.test.sh) were not run: this lane runs no test runner. Left to the PR's CI.
  • ci-status green is a PR check, left to the PR's CI.
  • Tidy ran without edits: the hook script row was dropped because a script wired as a hook command (hooks.json) is a GLOBAL HARD tidy exclusion, so passes 1-3 had no rows. On the changelog fragment, write-for-humans made no edit to the mandated text. ai-slop's detector (detect.sh) could not run…
  • check-affected skipped typos (not installed) and three validate-plugins sub-checks that run code from the checked tree; CI runs them.

Fix

  • plugins/guardrails/hooks/block-root-delete-target.sh: merged the \u000d/\u000D and \u000a/\u000A substitutions into [dD]/[aA] patterns; removed the rdt_ps_hit flag from the PowerShell prefilter (the case fallback now runs the ri|mi|clc regex and exits 0 on a miss); merged rdt_is_root's four…
  • .changes/guardrails/work-resolve-issue-issue-14476-42918969806-1-d726d1c1.md: new patch fragment, made with new-changelog-fragment guardrails patch, with body '### Changed' and '- Internal simplification, no behavior change.'

Verification

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

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

The run reports:

  • check-changelog-fragments: all 31 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 2 changed files (run before and after tidy)
  • grep for rdt_ps_hit, rdt_is_root and RDT_RU_CMDS across the repository: the edited names are used only in this file, and no caller of rdt_is_root reads BASH_REMATCH afterwards
  • fresh-context review subagent over the whole diff: found no input where old and new code behave differently (it checked bash pattern-substitution semantics, non-overlapping replacements, locale, exit status, set -u and BASH_REMATCH)
  • git-read diff --unified=0 HEAD: every hunk sits at or before line 1423, inside range 1 (lines 1-1667)
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42918969806

Left out: the items under Not verified.

Related

#14476

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

Security review: PR #15207 (head 9552771)

I read every hunk in both changed files. Neither file is on a trusted path. The hook script is a guardrail, though: it blocks deletion of filesystem roots. So I checked each hunk against the base code to see whether any input the base blocks would now get through. I found no security issues.

  • CR/LF unescape (block-root-delete-target.sh L934-L935): "${rdt_bs}u000"[dD] is a quoted literal followed by an unquoted bracket expression. Inside ${var//pattern/repl}, the shell treats the bracket as a pattern and does not run filename expansion on it, so the nullglob toggle at L2040 has no effect here. nocasematch is never set. It matches exactly what the base's two substitutions matched, and the replacements cannot build a new match. Equivalent.
  • PowerShell prefilter (L1196-L1203): the base ran the ri|mi|clc regex only when no case arm matched, and exited 0 on a miss. The new *) arm does the same thing, so every command the base passed on to the tokenizer still reaches it. Equivalent.
  • rdt_is_root (L1330): the anchored alternation ^([a-z]:|/[a-z]|/cygdrive/[a-z]|/mnt/[a-z])$ accepts exactly the strings the four base regexes accepted. It returns the test's status, and all six callers (L2591, L3237, L3242, L3249, L3279, L6371) use only that status. Equivalent.
  • rdt_runuser_argv (L1419-L1423): this hunk turns two command/session-command tests into one if block. It appends the same values in the same order, including the operand that follows --. The script never sets set -e, so the && chain's exit status changes nothing. Equivalent.
  • Changelog fragment: a prose patch note with no security relevance.

None of the deny rules is narrowed or removed, so the instruction-surface deletion check does not apply. Nothing touches a trust control or a plugin manifest, and nothing spends money or credits.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: PR #15207, no findings

I read both changed files in full: plugins/guardrails/hooks/block-root-delete-target.sh (4 hunks) and the new changelog fragment. Each hunk does what it did before.

  • CR/LF unescape (L934-935). Two bracket patterns replace the four literal substitutions. Only [dD] and [aA] are left unquoted, so they act as glob classes and \u000 stays literal. Swapping two sequential passes for one pass gives the same result: the replacement text (\r / \n) starts with a backslash and never holds u000, so it can't create or break a later match. The \001 placeholder for \\ is still applied before and restored after, as on base.
  • PowerShell prefilter (L1196-1202). The named-word arms are now empty, and the *) fallback runs the ri|mi|clc regex with || exit 0. That is the same as the old flag logic, and the regex still runs only when no word arm matched. The script runs under set -uo pipefail with no -e, so exit status doesn't change control flow.
  • rdt_is_root (L1329-1330). The single anchored alternation ^([a-z]:|/[a-z]|/cygdrive/[a-z]|/mnt/[a-z])$ accepts the same strings as the four separate regexes. A non-match returns 1, as return 1 did. Every caller (L2591, L3237-3279, L6371) uses it in an if or a ||/&& list and none reads BASH_REMATCH afterwards. On a match the new regex also fills BASH_REMATCH[1], which nothing reads.
  • rdt_runuser_argv (L1419-1423). The command|session-command test now runs once. The appends to RDT_RU_CMDS and the -- lookahead behave as before. Without -e, the if body ending in a false && chain has no effect.

Closing issue #14476, acceptance criteria:

  • Behavior unchanged: met, by my reading of each hunk above. The existing guardrails hook suites cover these paths. The author says they didn't run them locally and left them to CI; I couldn't run them either, so that is unverified.
  • Edits only the listed file plus a fragment: met.
  • Within 400 changed lines and 15 files: met (about 30 lines, 1 hand-edited file).
  • ci-status green: left to CI, not something this review can check.
  • Fragment with bump: patch, a ### Changed heading and the required line: met.
  • Only range 1 (lines 1-1667) changed: met, the last hunk ends at L1423.

Rules: .claude/rules/mod-authoring.md matches plugins/*/hooks/**, but it covers hooks modules and hooks.json "modules", and this change touches neither. No plugin manifest changed. No embedded instructions in the PR context.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head 955277125e298b1260950c900de0a5561ef55fbf. No person needs to act: a lane clears this reason, and the next scheduled run judges it again.

pr-merge's gate refuses its verifier verdict (verify:missing)

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 9552771

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-15207-955277125e298b1260950c900de0a5561ef55fbf, 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 fec1365 Nov 11, 2026
72 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14476-42918969806-1 branch November 11, 2026 00:00
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit fec1365dd1b0b5171872431c1db79f0b4ce49a3c; 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 block-root-delete-target.sh guardrails plugin code (part 1 of 5)

0 participants