Skip to content

refactor(guardrails): simplify range 4 of block-root-delete-target.sh - #15253

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14479

Summary

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

Simplified functions that start in range 4 of 5 (lines 4997-6662 of 8328) of plugins/guardrails/hooks/block-root-delete-target.sh, with no behavior change. Choice and basis: only redundant state was removed, each change justified by bash's own semantics (a for-list and function arguments are expanded once, before the body runs) and by the call graph read in the file. rdt_ix_calls and rdt_ix_list drop their copy of RDT_IX_ARGS; rdt_ix_target folds its single-argument and [...] list branches into one loop with the same per-element rule; rdt_find_scan replaces its gnu flag with a count of the start points collected so far (the only place sw is filled before the check); rdt_xargs_check takes its HOOK_SEG_WORD_QUOTED snapshot when it is declared (the option loop calls nothing and never writes that array). Larger ideas (merging the duplicated push and pop of a substitution in rdt_scan_substitutions, a shared command-basename helper for rdt_text_class, rdt_dec_class and rdt_feed_class) were left alone: the first is the guard's quote-aware scanner, and the second would dedupe across ranges other parts own.

Not verified

  • The guardrails hook test suites were not run: this lane can run only its named wrappers, not bash test scripts. Left to the PR's CI (ci-status).
  • ci-status green on the PR: a CI check, left to the PR's CI.
  • Tidy: the hook script's 9 hunks were dropped from tidy because the script is wired as a hook command (plugins/guardrails/hooks/hooks.json:113), which puts it on tidy's GLOBAL HARD list (hard_exclusions unset, so enforce). Passes 1-3 had no rows. Pass 4 made no edit because the issue sets the…
  • Build/lint of the touched shell file beyond check-affected (shellcheck, shfmt) not run separately; the lane cannot invoke them directly. Left to the PR's CI.

Fix

  • plugins/guardrails/hooks/block-root-delete-target.sh: rdt_ix_calls drops the cargs copy and reads RDT_IX_ARGS directly; rdt_ix_target joins its placeholder and [...] list branches into one loop; rdt_ix_list drops the el copy; rdt_find_scan removes the gnu flag in favor of ${#sw[]};…
  • .changes/guardrails/work-resolve-issue-issue-14479-42951659933-1-c89e9724.md: new patch fragment from new-changelog-fragment, body '### Changed' and '- Internal simplification, no behavior change.'

Verification

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

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

The run reports:

  • check-changelog-fragments: all 27 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)
  • fresh-context review subagent, given the diff and the file: all 5 hunks SAFE, each with a trace (args expanded before the call, for-list expanded once, sw filled only by the GNU start-point loop, xargs option loop calls nothing and never writes HOOK_SEG_WORD_QUOTED, a placeholder starts with \001…
  • range measured on the current file: 8328 lines, range 4 of 5 is lines 4997-6662; every edited function starts in it (rdt_ix_calls 5319, rdt_ix_target 5438, rdt_ix_list 5582, rdt_find_scan 5625, rdt_xargs_check 6120, as numbered before the edit)
  • git-read diff --numstat: one plugin area (plugins/guardrails plus .changes/guardrails), 2 files, under the 400-line and 15-file limits
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42951659933

Left out: the items under Not verified.

Related

#14479

Merge-Risk: unrated reason=no-rating

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

Copy link
Copy Markdown
Contributor

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

Security review: no security issues found

I read the whole change in both files: plugins/guardrails/hooks/block-root-delete-target.sh and the new changelog fragment .changes/guardrails/work-resolve-issue-issue-14479-42951659933-1-c89e9724.md. Neither matches a trusted-path glob. The hook script is a guardrail: it blocks deletes that target the root. It is not on the skip list, so I checked each refactor against the head file to confirm it does not narrow what the guard refuses.

  • rdt_ix_calls (L5341-L5347): the cargs copy is gone. Nothing runs between rdt_ix_split and the use of RDT_IX_ARGS. Bash expands a function's arguments before the call, so rdt_ix_del and rdt_ix_run calling rdt_ix_split again cannot change the arguments they were already given. The count check is the same, and so are the arguments passed on.
  • rdt_ix_target: RDT_IX_PH_RE is anchored and starts with \001 (L4787), so no argument can match both the placeholder pattern and '['*']'. With the two branches folded into one loop, the rule per argument is unchanged:
    • an s placeholder goes to rdt_ix_path;
    • any other placeholder goes to rdt_ix_unplaceable;
    • any other non-list word goes to rdt_ix_unplaceable;
    • each element of a list is judged by the same rule.
  • rdt_ix_list: bash expands a for list once, before the loop body runs, so iterating over RDT_IX_ARGS directly behaves the same as iterating over the copy.
  • rdt_find_scan (L5658-L5668): sw starts empty, and the only place that fills it before the check is the GNU start-point loop, which is also the only place that set gnu=1. So ${#sw[@]} == 0 is the same test as gnu == 0, and the implicit . start point is still added in exactly the same cases.
  • rdt_xargs_check (L6106-L6161): the option loop calls no function and never writes HOOK_SEG_WORD_QUOTED, so taking the snapshot when the array is declared gives the same value as taking it after the loop. The early-return paths never read q0.

The changelog fragment is text only and has no security surface.

The PR description contains no embedded instructions aimed at this review. No standing instruction is deleted or narrowed, no manifest changed, no trust control is touched, and nothing in the change spends money.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: no findings

I read both changed files in full: the changelog fragment and all 5 hunks in plugins/guardrails/hooks/block-root-delete-target.sh. I checked each hunk against the code it calls at head. As far as bash semantics go, none of them changes behavior.

  • rdt_ix_calls: the cargs copy is gone and the code now reads RDT_IX_ARGS directly. Bash expands a function's arguments before the call, so the change is safe even when rdt_ix_run → rdt_ix_shell → rdt_parse re-enters the loop and overwrites RDT_IX_ARGS. Every iteration calls rdt_ix_split again before it reads the array, so no stale value is ever read.
  • rdt_ix_target: the placeholder branch and the [...] branch are now one loop. It matches the old behavior because RDT_IX_PH_RE is anchored (^\001…\002$, line 4787). A placeholder can never also match '['*']', so the order of the two checks doesn't matter. Placeholders of kind s, other kinds and non-placeholder text still reach the same rdt_ix_path or rdt_ix_unplaceable call. An empty list [] still makes no call.
  • rdt_ix_list: the el copy is gone. A for-list is expanded once, before the loop body runs, and rdt_ix_word_to doesn't write RDT_IX_ARGS anyway.
  • rdt_find_scan: gnu was set only inside the GNU start-point loop, which is the only code that fills sw before the check. So ${#sw[@]} == 0 is the same test as gnu == 0. Nothing else read gnu.
  • rdt_xargs_check: the q0 snapshot is now taken when the array is declared. The option loop between the old and new positions calls nothing and never writes HOOK_SEG_WORD_QUOTED. The early returns don't use q0.

Closing issue #14479 acceptance criteria:

  • Behavior unchanged: met by the trace above. The existing block-root-delete-target*.test.sh suites test find start points, xargs rm, and interpreter deleter or list calls, and could fail if this broke. I did not run them; I have no shell.
  • Only the listed file plus a changelog fragment edited: met.
  • Within 400 lines and 15 files: met (2 files, about 40 lines).
  • Fragment says bump: patch, ### Changed, "Internal simplification, no behavior change.": met.
  • Only functions starting in range 4 of 5 (lines 4997–6662) changed: met. All 5 edited functions start between lines 5319 and 6120.
  • ci-status green: I can't see CI from here, so this is left to the PR's checks. The author's verification claims (check-affected, fragment checks) are their own and I have not confirmed them.

Rules: .claude/rules/mod-authoring.md matches by path, but it covers hooks modules ("modules" in hooks.json). This PR changes a shell hook script, so the rule doesn't apply.

There are no plugin manifest changes. No prior findings exist (first review), no settled threads were provided, and the PR context contains no embedded instructions.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit f04d91a Nov 11, 2026
72 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14479-42951659933-1 branch November 11, 2026 04:03
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit f04d91aeb9fda29a671a8f8db47e4db96faaeead; 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 4 of 5)

0 participants