Skip to content

fix(guardrails): let quoted heredoc bodies hold merge text in block-unresolved-pr-merge - #10376

Merged
melodic-automation-lanes[bot] merged 2 commits into
mainfrom
work-resolve-issue/issue-8949-40407723459-1
Oct 26, 2026
Merged

melodic-automation-lanes[bot] merged 2 commits into
mainfrom
work-resolve-issue/issue-8949-40407723459-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #8949

Summary

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

block-unresolved-pr-merge refused any command with a backtick plus merge-shaped text, including commands where that text sat only in the body of a quoted heredoc passed to python3 or git commit -F -. Following the recorded decision on #8949, the shared Bash parser now records each heredoc body's byte span, quoting, closed flag and delimiter in HOOK_HEREDOC_BODIES, and run-guards replays it. The guard tests its backtick and backslash-newline refusals on the command with quoted bodies cut out. A body stays in wherever it could run as commands or the parser might bound it differently from bash. Stay-quiet cases cover the three reported shapes, and refusal cases cover the decision's list plus the bypasses a review found.

Not verified

  • Did not run the test suites (bash plugins/guardrails/hooks/block-unresolved-pr-merge.test.sh, lib/hook-utils.test.sh, plugins/guardrails/hooks/run-guards.test.sh) or check-affected --tests: this lane's Bash runs only the named wrappers. Left to the PR's CI, which runs every *.test.sh on a hooks chan
  • A second fresh-context review of the revised strip logic (plain-word delimiter and closed flag from the parser, the wider shell list, the ${/((/\[\[ stops) stopped partway and returned no verdict. Its one concern, pairing bodies with openers by order, was removed by having the parser record ea
  • Changes left uncommitted in the working tree, as the runner's instructions require; the runner turns them into the patch.
  • The changelog fragments were written by hand: new-changelog-fragment refuses on a detached HEAD. The 8-hex suffixes were chosen by hand rather than read from /dev/urandom; check-changelog-fragments validates all 23.
  • Deliberate deviation from the decision's wording: a quoted body is cut only when its delimiter is a plain word that closed it. A body holding a backslash-newline is also kept, so that the existing test.sh:665 refusal still passes as the decision requires. Gaps that remain: a heredoc written to a fil
  • Two decision-listed checks are covered differently. The 'opener inside quotes' case uses echo "<<'EOF'". The <<-'X' case uses cat <<-'X' > notes.md with a tab-indented body and delimiter.

Fix

  • lib/hook-utils.sh: hook::bash_parse_segments_uncached publishes HOOK_HEREDOC_BODIES (<start> <end> <quoted> <closed> <delimiter> per heredoc body, byte offsets, set after the last callback so a nested parse cannot clobber it). A heredoc delimiter word now ends at (
  • lib/hook-utils.test.sh: bps_hd_case rows for the body spans (three openers on one line, an unterminated body, an opener inside double quotes, a multibyte body, a delimiter closed by )), plus a redirection row for (cat <<'E').
  • plugins/*/hooks/hook-utils.sh and plugins/repo-hygiene/skills/clean/scripts/hook-utils.sh (20 copies): regenerated from lib/hook-utils.sh by sync-shared-copies.
  • plugins/guardrails/hooks/block-unresolved-pr-merge.sh: parses before judging the backtick and continuation refusals, then tests them on the command with quoted heredoc bodies removed (_bupm_strip_bodies). A body is kept when: a word names a shell, sudo, su, ssh or at; the command word is eval, sourc
  • plugins/guardrails/hooks/block-unresolved-pr-merge.test.sh: 5 new quiet cases: the issue's python3 -I - file deny-rule edit, the python3 - regex body, the git commit -q -F - message, a <<"EOF" comment body and a <<\EOF body. 19 new unresolvable cases: the decision's list (an opener insid
  • plugins/guardrails/hooks/run-guards.sh: records HOOK_HEREDOC_BODIES with the shared parse and sets it after a replay's last callback.
  • plugins/guardrails/hooks/run-guards.test.sh: the shared-parse stubs print HOOK_HEREDOC_BODIES; asserts it rides along unchanged to replaying guards (HD [86 95 0 1 EOF]).
  • plugins/guardrails/README.md: the block-unresolved-pr-merge row says the backtick and continuation tests skip a quoted heredoc body fed to a non-shell program.
  • .changes/guardrails/fix-8949-heredoc-merge-text-4b1e9d07.md: patch fragment (Fixed) for the guard, parser and run-guards changes.
  • .changes/<19 carriers of lib/hook-utils.sh>/fix-8949-heredoc-merge-text-*.md: patch fragments (Changed) for the parser change, as sync-shared-copies --check-bump requires (animation, autonomy, bash-format, biome-format, context-guard, desktop-notification, eol-normalizer, explainer-video, go-f

Verification

The runner ran each check from the base copy against 30d201d:

  • scripts/check-changelog-fragments.sh --check: passed

The run reports:

  • .lane/checks/bin/check-affected: 10 passed, 6 skipped, 0 failed over 47 changed files. The first runs failed on shellcheck (SC2154/SC2034/SC2016/SC2329) and a missing guardrails fragment; both were fixed and the check re-run.
  • .lane/checks/bin/check-changelog-fragments: all 23 fragments under .changes/ valid.
  • sync-shared-copies (no args): regenerated all 20 hook-utils.sh copies from lib/hook-utils.sh, exit 0.
  • cant-fail-scan --file <test> --check on block-unresolved-pr-merge.test.sh, lib/hook-utils.test.sh and run-guards.test.sh: PASS, no gating findings. One pre-existing report-only source-text-read finding at run-guards.test.sh:862, unrelated.
  • Fresh-context review subagent over the whole diff: found that the parser misbounds bodies in (cat &lt;&lt;'E'), ${x:-&lt;&lt;'E'}, ((...&lt;&lt;'E')) and &lt;&lt;"E\"F", which would let a real backtick merge after them pass. It also found shell runners (sudo -s, ssh, globbed or .sh command w
  • Hand trace of every new quiet and unresolvable row against the final guard code, and of the existing rows at test.sh:656, :665, :687, :693, :712 and :809.
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/40407723459

Left out: the items under Not verified.

Related

#8949

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

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 88182305f6208740781a6130852cfde3c224c6a1: 0 finding(s), 0 as inline comments.

Incremental review of plugins/guardrails/README.md since 30d201d. The only change is a one-sentence rewording at line 1041. It now reads "The measurement that holds is the hook's own cost, ≈ 6.3 spawn-equivalents, ≈ 505 ms…". The figures match the table rows above it (6.31 and ≈ 505 ms), and the sentence still reads correctly with the text that follows. This is prose only, with no code, config or manifest change, so there are no findings.

I read the change in .claude-lane/incremental.diff and the surrounding README lines. I did not run any measurements. The benchmark numbers are the author's own and I did not verify them.

The skill's other checks (closing-issue criteria, plugin manifests, path-scoped rules) did not apply to this wording-only change. This change spends no money or credits, so no hold applies.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 88182305f6208740781a6130852cfde3c224c6a1: 0 finding(s), 0 as inline comments.

Incremental security review of plugins/guardrails/README.md since 30d201d. No security issues found.

The only change rewords one sentence in a benchmark paragraph ("The hook's own cost is the measurement that holds" became "The measurement that holds is the hook's own cost"). The figures and meaning are unchanged. The file is documentation only. It is not a trusted path or trust control, it is not a plugin manifest, and it is not a standing instruction that a hook or rule enforces. The diff removes no rule, so the instruction-surface lens does not apply. Skip gate 2 applies: the change has no security-relevant surface.

The 46 other files in this pull request are unchanged since the last review and were not re-reviewed here. No manifest items are hit by this change. I did not read the PR context file because the change is a wording edit.

critical-findings: 0

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 88182305f6208740781a6130852cfde3c224c6a1.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit 2e08aa6 Oct 26, 2026
42 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-8949-40407723459-1 branch October 26, 2026 23:41
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.

guardrails: block-unresolved-pr-merge fires on merge-endpoint text inside a heredoc body

0 participants