Skip to content

refactor(guardrails): simplify block-root-delete-target range 2 of 5 - #15216

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14477

Summary

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

Simplified the functions that start in range 2 of 5 of plugins/guardrails/hooks/block-root-delete-target.sh (lines 1667-3332 of 8329, measured at start: rdt_resolved_walk through rdt_judge_pending), with no behavior change. Ten repeated resolve-map-canonicalize lookups in rdt_judge_pending now go through one helper, rdt_compared_to. The three allowed-root filters (allowed roots, name-prefix and segment entry directories) share rdt_allowed_root_to in place of three copies of the same root/HOME test. rdt_tree_to declares its locals initialized, and rdt_nearest_to and rdt_resolve_all each drop a needless if-block. Choice of means: the two helpers sit just before rdt_judge_pending, inside range 2, so nothing moves between files.

Not verified

  • The guardrails hook test suites (e.g. block-root-delete-target*.test.sh, lib/hook-utils-shfmt.test.sh) were not executed here, because this lane's Bash runs only the named wrappers; left to the PR's CI
  • tidy: rows for plugins/guardrails/hooks/block-root-delete-target.sh were dropped (it is a hook script wired in plugins/guardrails/hooks/hooks.json, a GLOBAL HARD exclusion under the default enforce), so code passes 1-3 had no rows; markdown passes 4-5 ran on the changelog fragment and changed…
  • File is 7 lines longer net (two documented helpers added, 16 lines of duplication removed); line count was traded for removing the repeated lookups and filter logic

Fix

  • plugins/guardrails/hooks/block-root-delete-target.sh: added rdt_compared_to and rdt_allowed_root_to; rdt_judge_pending uses them for its ten RDT_WMAP/RDT_RES canonical lookups and its three allowed-root filter loops; rdt_tree_to initializes d and out in its local declaration; rdt_nearest_to and…
  • .changes/guardrails/work-resolve-issue-issue-14477-42928937882-1-b7c18c5d.md: patch fragment from new-changelog-fragment, body ### Changed / - Internal simplification, no behavior change.

Verification

The runner ran each check from the base copy against 0620c5d:

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

The run reports:

  • check-changelog-fragments: all 13 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 over the whole diff: no behavior difference found; it confirmed that a t left unset on a rejected entry and the allow loop's final status are never read, that the new helpers' locals cannot collide through dynamic scoping, and that no new shellcheck finding arises…
  • grep of plugins/guardrails for tests naming the changed functions: only block-root-delete-target-resolve.test.sh mentions rdt_canon_to, in a comment; no test asserts on the changed lines
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42928937882

Left out: the items under Not verified.

Related

#14477

Merge-Risk: max=HIGH demote=true head=0620c5dbb11fcdf86f594aaa3d21b6c32f752e32 rubric=8.4.0 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 0620c5dbb11fcdf86f594aaa3d21b6c32f752e32: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15216 (refactor of block-root-delete-target range 2 of 5)

I found no security issues.

Scope. I read every hunk of both changed files: the changelog fragment and plugins/guardrails/hooks/block-root-delete-target.sh. The hook is a guardrail that refuses deletes aimed at filesystem roots, HOME and protected trees. A behavior change here could weaken that guard, so I checked each hunk for equivalence with the base code. I did not rely on the PR's own "no behavior change" claim.

  • rdt_nearest_to (L2015). The new [[ "$2" == -d && ! -d "$__rn_a" ]] && __rn_a="" clears the path in exactly the cases the old if did. The function's last command is still printf -v, so its return status is unchanged.
  • rdt_resolve_all (L2435). A && B && ok=1 sets ok exactly when the old if did. The script runs under set -uo pipefail with no -e (L845), so the list's nonzero status when it fails cannot end the script.
  • rdt_tree_to (L2541). d and out are now set to empty when declared, not a few lines later. Nothing reads them in between, and the cache-hit path returns before using them.
  • rdt_compared_to / rdt_allowed_root_to (L2951-2966).
    • rdt_compared_to declares no locals, so the caller's variable name reaches rdt_canon_to unchanged. rdt_canon_to uses only __rc_* locals (L2101-2113), so __ar_t, t, c and RDT_HOMEC cannot collide with them.
    • rdt_allowed_root_to still rejects an entry that resolves to / before mapping, and a root-like path, a filesystem root or HOME after it. It writes its result only on success. The three loops add an entry to RDT_ALLOWC, RDT_PDIRC/RDT_PNAME and RDT_SDIRC/RDT_SNAME only when the helper returns 0, which is the same set of entries the old inline tests admitted. When an entry is rejected, t is left unset, but no code reads it afterwards.
    • The other rdt_compared_to call sites (temp roots, scratchpad, tree, HOME, worktrees, ~/.claude, protected trees) are one-for-one replacements of the same lookup.

So no allowed root is widened and no protected tree or root refusal is narrowed. The hook's block list is unchanged, so the instruction-surface lens finds nothing removed. No trusted path, plugin manifest or trust control is touched.

The PR context file contains no embedded directives aimed at the review.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: PR #15216, block-root-delete-target range 2 of 5

No findings. I read every hunk of both changed files (2 of 2). This was a full review, not blocking-only: the prior-findings file shows no earlier heads reviewed.

Behavior is unchanged

I checked each hunk against the code at head. The script runs under set -uo pipefail, without -e.

  • rdt_nearest_to, line 2015. The if block became [[ "$2" == -d && ! -d … ]] && __rn_a="". This line now returns 1 when the test is false. That status is never seen: the function's last command is printf -v, and with no errexit a failing && list does not stop the script.
  • rdt_resolve_all. The if … then ok=1; fi became an && chain. ok is set the same way, and a too-slow block from rdt_lines_to still fires inside it as before.
  • rdt_tree_to. d="" and out="" now sit in the local line. Nothing reads them on the early cache-hit return, so this is the same as before.
  • rdt_compared_to. It expands ${RDT_WMAP[${RDT_RES[$2]}]} exactly as the ten inline copies did. It declares no locals, so no output-variable name (t, c, RDT_HOMEC) can be shadowed.
  • rdt_allowed_root_to. It keeps the old order: the / test before mapping, then rdt_root_like, rdt_is_root on the lower-cased path, and the RDT_HOMEC test. RDT_HOMEC is assigned on the line before the three loops that call it. Its local __ar_t does not clash with any __rc_* local in rdt_canon_to.
    • One difference: t is no longer assigned when an entry is rejected. That doesn't matter, because t is assigned again before its next read (the wts loop at line 3270, and line 3305).

Closing issue #14477, acceptance criteria

  • Behavior unchanged: met (see above). The hook's test suites exercise allowed roots (block-root-delete-target-{b,c,d,e}.test.sh), so a regression in the filter would be caught. I did not run them. The PR says they were not run in the lane and leaves them to CI.
  • Only the listed file plus a fragment is edited: met.
  • Within 400 changed lines: met. The diff is about 50 changed lines.
  • ci-status green: not something this lane can see. CI decides it.
  • Changelog fragment: met. bump: patch, a ### Changed heading, and the exact required line.
  • Only functions starting in range 2 (lines 1667–3332) are changed: met. The edits are to rdt_nearest_to (2008), rdt_resolve_all, rdt_tree_to and rdt_judge_pending. The two new helpers sit just before rdt_judge_pending, inside the range.

The verification lines in the PR body (check results and the subagent review) are the author's claims, and I did not check them myself. The rule .claude/rules/mod-authoring.md matches the path but covers hooks modules and hooks.json "modules", so it does not apply to this shell hook. No plugin manifest changed.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 0620c5d

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-15216-0620c5dbb11fcdf86f594aaa3d21b6c32f752e32, expires on 2026-12-11.

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

Copy link
Copy Markdown
Contributor Author

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

0 participants