Skip to content

refactor(guardrails): simplify block-noncanonical-commit and root-delete fixtures - #14645

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14475

Summary

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

Simplified two of the three listed guardrails files with no behavior change. In block-noncanonical-commit.sh, one probe_key_to helper now builds the probe cache keys that repo_git_probe and alias_launch_dir had each built inline. The one-caller git_rev_parse_field wrapper and its HOOK_REV_PARSE_FIELD global are gone. The !-alias reparse save/restore sequence that was copied in both alias branches is now one shell_alias_reparse function. set_probe_locating is shorter, and a redundant empty check, a second set of global initializations and the per-line >&2 redirects in block_message_flag were removed. The fixtures file now builds its 3000-brace operand with the existing rdt_rep helper. block-root-delete-target-resolve.sh needed no change: its helpers are already minimal, and the remaining candidates (negative array subscripts) would raise the minimum bash version. persisted_alias_expansions keeps its original cache-key format on purpose: review found that switching it to probe_key_to would change which lookups share a cache entry when a subcommand name contains a newline. That would flip an allow/block decision, so it is out of scope for a no-behavior-change PR.

Not verified

  • The guardrails hook test suites (block-noncanonical-commit.test.sh, block-root-delete-target*.test.sh, run-guards.test.sh) were not run: this lane cannot run bash test scripts, so they are left to the PR's CI.
  • Tidy did not tidy block-noncanonical-commit.sh, because it is wired as a hook command and is GLOBAL HARD for tidy-diff. The ai-slop detector was not run on the fragment (lane Bash allows only named wrappers); a by-hand rubric read found nothing. Passes 1-3 and 4 found nothing to change on the…
  • Separate pre-existing issue, not fixed here: the persisted_alias_expansions cache key puts the subcommand name in raw, so a subcommand containing a newline can collide with another (dir, locating) lookup and reuse its alias result, which can fail open. Keyed this way on main; fixing it is a…
  • Separate pre-existing issue: the comment near block-noncanonical-commit.sh:662 says the persisted-alias lookup drops the locating globals, but repo_git_probe passes HOOK_PROBE_LOCATING, so the comment looks stale. Left as is because comment rewrites are outside this chunk's scope.
  • ci-status green is left to the PR's CI.

Fix

  • plugins/guardrails/hooks/block-noncanonical-commit.sh: new probe_key_to helper replaces the inline key loops in repo_git_probe and alias_launch_dir; removed git_rev_parse_field and HOOK_REV_PARSE_FIELD; new shell_alias_reparse replaces two identical inline !-alias reparse sequences; shorter…
  • plugins/guardrails/hooks/block-root-delete-target-fixtures.sh: the 3000-brace operand is built with the existing rdt_rep helper instead of an inline loop
  • .changes/guardrails/work-resolve-issue-issue-14475-42614327823-1-0e0126b4.md: patch fragment, ### Changed with "Internal simplification, no behavior change."

Verification

The runner ran each check from the base copy against 094468f:

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

The run reports:

  • check-changelog-fragments: all 116 fragments valid (passed after the final edit)
  • check-changed-skills: no changed skills, nothing to gate
  • check-affected: 13 passed, 6 skipped over 3 changed files (passed after the final edit)
  • fresh-context review subagent: one finding (the persisted-alias cache-key change could flip a decision for a subcommand containing a newline); fixed by restoring the original key in persisted_alias_expansions. It confirmed the other eight changes match the old behavior.
  • tidy-diff: block-noncanonical-commit.sh rows dropped as a hook-wired script (GLOBAL HARD); the fixtures line and the fragment needed no edits
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42614327823

Left out: the items under Not verified.

Related

#14475

Merge-Risk: max=MEDIUM demote=false head=094468f81c607da9de6b4021d9081636bfb65769 rubric=8.1.4 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-review reviewed 094468f81c607da9de6b4021d9081636bfb65769: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

I read every hunk of all 3 changed files. I checked each refactor in block-noncanonical-commit.sh against the code it replaces, and found no behavior change:

  • msg_count_to: an empty $2 now fails the loop guard on the first check, so __mc_out still gets 0.
  • probe_key_to: it builds the same keys as before. In repo_git_probe the key is the %q-encoded dir, then the locating globals, then the git args. In alias_launch_dir it is the dir and the locating globals only. The nameref targets the caller's local key, and its own __pk_* names don't collide with it.
  • git_rev_parse_field / HOOK_REV_PARSE_FIELD: nothing else in the repository references either one any more.
  • shell_alias_reparse: the save/restore runs in the same order as the inline copies did.
    • saved_locating is still captured before shell_alias_inherited_locating runs.
    • saved_base, saved_seen and sub still resolve through dynamic scope to the calling check_segment frame's locals, because nested check_segment frames declare their own.
    • Removing saved_locating from check_segment's locals leaves nothing else reading it.
  • set_probe_locating: same result, and the empty-array expansion is still safe under set -u.
  • sequencer_in_progress: the removed empty check is repeated right after the fi.
  • block_message_flag: the moved echos now go through the existing { … } >&2 group, so the output stream and order are the same.
  • Removed globals: the second set of initializations was a duplicate. Lines 430–432 already set HOOK_EFFECTIVE_LOCATING, HOOK_PROBE_LOCATING and HOOK_FRAME_PREFIX_HAS_C, and no top-level code changes them before the main parse.

In the fixtures file, rdt_rep '{' 3000 uses printf '%s' with no trailing newline, so $(…) builds the same 3000-brace string. rdt_d is not used anywhere else in that file.

Closing issue #14475, acceptance criteria:

  • Behavior unchanged: confirmed by reading the code, as above. I did not run the tests.
  • Only the listed files plus a fragment are edited: met.
  • Within the 400-line / 15-file limit: met.
  • Guardrails fragment: met. It has bump: patch, ### Changed, and the required line.
  • ci-status is green: I couldn't check this from here. The PR's verification list is the author's claim and I did not confirm it.

There are no plugin manifest changes, no paved-path questions, and no embedded instructions in the PR context.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Security review: PR #14645 (refactor(guardrails): simplify block-noncanonical-commit and root-delete fixtures)

I found no security issues. I read every hunk in all 3 changed files. None of them matches a TRUSTED PATHS glob, and no plugin manifest changed. The diff removes a few lines from a guard hook (block-noncanonical-commit.sh), so before skipping anything I checked each edit for whether it changes what the hook blocks. I didn't read the instruction exception register, because no standing rule was deleted or softened: every edit is a code refactor, and each one still reaches the same allow/block decision.

What I checked against the head file:

  • msg_count_to (L194-L202): the empty-needle early return is now a -n "$2" condition on the loop. With an empty needle the loop never runs and __mc_out=0, the same as before.
  • probe_key_to (L440-L450):
    • In repo_git_probe (probe_key_to key "$@"), the key is still the %q-encoded dir, then the locating globals, then the git args, one per line, built before the shift.
    • In alias_launch_dir, the key is the dir plus the locating globals, as before.
    • The nameref __pk_out collides with no local in probe_key_to. The cache keys are unchanged, so no lookup now shares an entry it didn't share before.
    • persisted_alias_expansions is left on its original key on purpose.
  • Removing git_rev_parse_field and HOOK_REV_PARSE_FIELD: nothing else in plugins/guardrails reads them. alias_launch_dir now reads HOOK_REPO_GIT_PROBE_OUT straight after each repo_git_probe call, so the --show-prefix test gets the same value.
  • set_probe_locating (L538-L544): it builds the same array, inherited globals (only when no -C is in the frame prefix) followed by the frame's own globals, in last-wins order.
  • shell_alias_reparse (L560-L570):
    • Both !-alias branches (L839, L898) now call it.
    • Bash's dynamic scoping still resolves saved_base, saved_seen, sub and locating_globals to the calling check_segment frame's locals (L714, L726, L772-L773), so nested frames can't overwrite them.
    • saved_locating is now local to the helper, and no other code reads that name.
    • The reparse still goes through alias_reexpand_admit with the same restore steps, so the depth cap and traversal budget still fail closed.
  • sequencer_in_progress: the inner empty check that was dropped is repeated straight after the fi (L616), so an empty git-dir answer still returns 1.
  • Duplicate global initializations removed (the old end-of-file block): HOOK_EFFECTIVE_LOCATING, HOOK_PROBE_LOCATING and HOOK_FRAME_PREFIX_HAS_C are still set at L430-L432. That runs before any reader, so an inherited environment value still can't seed them.
  • block_message_flag: the same text now goes to stderr from one { … } >&2 group, still followed by exit 2.
  • Fixtures file (block-root-delete-target-fixtures.sh): rdt_rep '{' 3000 (L24-L28) builds the same 3000-brace string. It is test-only code.
  • Changelog fragment: prose only.

The PR context contains no embedded instructions aimed at this lane. This was the lane's first review of this PR (blocking only: no), and there were no prior findings or settled threads. The PR says the guardrails hook test suites were not run and were left to CI; I didn't run them either, because this lane has no shell.

critical-findings: 0

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 094468f

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-14645-094468f81c607da9de6b4021d9081636bfb65769, 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 012eff6 Nov 9, 2026
72 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14475-42614327823-1 branch November 9, 2026 14:09
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

0 participants