Skip to content

refactor(guardrails): simplify block-cross-domain.sh - #14658

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14472

Summary

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

Simplified plugins/guardrails/hooks/block-cross-domain.sh with no behavior change. It now has one list of HOME spellings in place of three copies, one bcd::deny_document helper in place of five copies of the deny-document code, one bcd::add_once helper in place of three loops that add a value only once, and one bcd::tool_to helper in place of two copies of the command-name normalization. All deny reason strings, the document template, the exit codes, the trace lines and the telemetry calls are unchanged. One order changes: four deny paths now JSON-escape the reason after the telemetry call instead of before it. The escape reads none of the state the telemetry call touches, so the output is the same. bcd::writes keeps its own command-name normalization, which does not strip .cmd, because using bcd::tool_to there would change which commands it matches.

Not verified

  • plugins/guardrails/hooks/block-cross-domain.test.sh did not run here: this lane's Bash runs only the named wrappers. It is left to the PR's CI.
  • ci-status green: left to the PR's CI.
  • shellcheck was not run on its own. The review subagent noted a possible SC2178 warning on the bcd::add_once nameref and judged it unlikely. check-affected passed, but its output does not list which linters ran, so CI's shellcheck settles it.
  • tidy: passes 1 to 4 ran with no edit (no matching helper in hook-utils.sh, no zero-information comment, no generated-code residue, and the issue fixes the fragment's wording). Proposal: bcd::auth_found and bcd::write_found are now one-line wrappers around bcd::add_once, but their callers fall…
  • build/test step: a bash hook has no build. Testing was limited to the repository checks above, with the hook's own test suite left to CI.

Fix

  • plugins/guardrails/hooks/block-cross-domain.sh: hoisted the 8 HOME spellings into BCD_HOME_SPELLINGS, used by bcd::dir_to, bcd::add_root and bcd::is_idfile; added bcd::deny_document, used by bcd::deny, bcd::identity_deny, bcd::config_deny, bcd::auth_deny and bcd::write_deny; added bcd::add_once (a…
  • .changes/guardrails/work-resolve-issue-issue-14472-42615145901-1-f6327524.md: new patch fragment, created with new-changelog-fragment, whose body is '### Changed' and the line 'Internal simplification, no behavior change.'

Verification

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

  • 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 (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 compared the edit with HEAD: no behavior differences found; the deny strings are byte-identical, the add_once nameref names cannot collide with its target arrays, and the empty-array expansions are safe under set -u
  • diff size: 1 hook file, 52 lines added and 44 removed, plus a 7-line fragment; inside the issue's 400-line and 15-file limits
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42615145901

Left out: the items under Not verified.

Related

#14472

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

Security review: PR #14658, refactor(guardrails): simplify block-cross-domain.sh

I found no security issues.

I read every hunk of both changed files. Neither matches a trusted-path glob. The hook is a guardrail, so I checked it under the instruction-surface lens (a hook's block list) to see whether any deny path was removed or narrowed.

What I checked in plugins/guardrails/hooks/block-cross-domain.sh:

  • BCD_HOME_SPELLINGS (L324): it holds the same 8 spellings, in the same order, as the three inline lists it replaces in bcd::dir_to, bcd::add_root and bcd::is_idfile. It is set once at top level and nothing writes to it later. Fold, needle and idfile matching are unchanged.
  • bcd::deny_document: all five deny paths still print the same document template with permissionDecision":"deny" and $BCD_NOTICE_JSON, and still exit 0 where they did before.
    • The reason text is now built after bcd::emit_tel instead of before it. I read bcd::emit_tel (L476-484). It assigns only its own locals (subject, data, cwd) and reads BCD_CWD_DOMAIN without changing it.
    • So the reason text, including $BCD_CWD_DOMAIN, $list, $others and $BCD_MAP, comes out the same.
  • bcd::add_once (L805): this nameref helper adds a value to an array only once, as the three loops it replaces did. Its local names (__bcd_list, __bcd_v) cannot collide with the three target arrays.
    • The empty-array expansion stays safe under set -u.
    • local -n is already used in sibling guardrail hooks (hook-utils.sh, block-root-delete-target.sh, block-noncanonical-commit.sh), so this needs no newer bash than the hooks already require.
  • bcd::tool_to (L1027): it normalises the command name the same way as before (last path segment, lowercased, .exe then .cmd removed).
    • tool is now stored with .cmd already removed, where before only the case subject had it removed.
    • tool is local in both callers (L1041, L1150), and neither reads it after the case. So the gh/az config and auth checks match the same commands as before.

The .changes/ fragment is a changelog entry (bump: patch). It has no security surface.

PR text: I found no embedded instructions aimed at the review lane.

Instruction-surface lens: the diff removes no rule, deny path or position the guard checks. The guard denies exactly what it denied before. I did not consult the protected-class register because no rule was removed.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Code review: PR #14658, refactor(guardrails): simplify block-cross-domain.sh

No findings. I read every hunk of both changed files: plugins/guardrails/hooks/block-cross-domain.sh and the new changelog fragment.

What I checked

  • BCD_HOME_SPELLINGS: the array holds the same 8 spellings, in the same order, as each of the three loops it replaces (bcd::dir_to, bcd::add_root, bcd::is_idfile). The test suite does not source the script, so declaring the array at the top level causes no problem.
  • bcd::deny_document: all five deny reasons are passed through unchanged. The document template and $BCD_NOTICE_JSON are the same as before. The reason is now JSON-escaped after bcd::emit_tel instead of before it. The functions bcd::emit_tel and hook::emit_telemetry (hook-utils.sh:3288) keep their variables local, so moving the escape changes no input the reason reads ($list, $BCD_CWD_DOMAIN, $BCD_MAP). The new local esc follows the way bcd::deny already called hook::json_escape_to.
  • bcd::add_once: the nameref lookup, append and empty-array expansion behave like the three loops it replaces, and the expansion is safe under set -u. Its __bcd_* local names cannot collide with the target arrays. Namerefs are already used on this hook's call path (hook-utils.sh:3777), so this adds no new bash version floor.
  • bcd::tool_to: it strips .exe and then .cmd, in the same order as before. After the case, neither bcd::config nor the auth scan reads tool again, so the value it now stores (with .cmd stripped) changes nothing. bcd::writes keeps its own normalization, as the PR states.

Closing issue #14472 acceptance criteria

  • Behavior unchanged: met as far as reading the code shows. The PR says the hook's own test suite (block-cross-domain.test.sh) did not run in the lane. That and ci-status is green are left to CI. I could not run either, so both are unverified.
  • The diff edits only the listed file and changelog fragments: met.
  • Within 400 lines / 15 files: met (about 100 changed lines, 1 hand-edited file).
  • Fragment body is ### Changed plus "Internal simplification, no behavior change.": met. Its bump: is patch.

The PR's verification output (check-changelog-fragments, check-changed-skills, check-affected, subagent review) is the author's claim; I did not verify it.

No plugin manifest changed, so the manifest checks do not apply. Neither the PR context file nor the prior-findings file contained embedded instructions.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for cd56ce4

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-14658-cd56ce4a16d52688de7d2b41574331b22e52ce9f, 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 2768c0e Nov 9, 2026
72 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14472-42615145901-1 branch November 9, 2026 14:56
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 2768c0eaad9c4ee372e6add2833f7f8358be4931; 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-cross-domain.sh guardrails plugin code

0 participants