Skip to content

refactor(guardrails): simplify stale-path-verify, workflow-resilience-check and github-post-body - #15401

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14487

Summary

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

Simplified the three listed guardrails files without changing what they do. stale-path-verify.sh merges the two anchor-count branches into one shared uniqueness gate, copies the hit array in one line, and trims comments that described earlier versions. workflow-resilience-check.sh folds its two clean-exit greps into one condition. github-post-body.sh adds one in-file helper (ghpost::_cmd_name_to) for the command-name normalization that _wrapper and segment each repeated, replaces the two-test method check in gh_api with a case, merges segment's three loops over the same words into one, and moves a loop-invariant GHPOST_WRITES check out of the loop in bodies. Choice of means: I kept the helper in the same file, because the issue puts moving or deduplicating code across files out of scope. I dropped a second candidate helper (for the gh_api/curl rollback) because it made the file longer for little gain.

Not verified

  • The guardrails test suites (stale-path-verify.test.sh, workflow-resilience-check.test.sh, and the block-fix-request-post / block-github-post-content suites that source github-post-body.sh) could not run here because the lane's Bash only runs the named wrappers. Left to the PR's CI.
  • ci-status green is a PR check, left to the PR's CI.
  • tidy pass 5: the ai-slop detector (detect.sh) and digest-guard could not run under the lane's Bash restrictions. The rubric was applied by reading the one-line fragment instead, with no findings.
  • Untracked dotfiles at the checkout root (.bashrc, .bash_profile, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) are runner environment files, not part of this change. They were left out of the tidy measurement.

Fix

  • plugins/guardrails/hooks/stale-path-verify.sh: one shared occ==1 gate for the word and non-word anchor counts; hits=(${SPV_HITS[]+...}) in place of an if-copy; file_rel declared with its value; comments that described earlier versions trimmed
  • plugins/guardrails/hooks/workflow-resilience-check.sh: the no-fan-out and already-resilient exits merged into one if ! A || B with one emit_tel/exit; history narration trimmed from the jq_fields comment
  • plugins/guardrails/lib/github-post/github-post-body.sh: new ghpost::_cmd_name_to helper used by ghpost::_wrapper and ghpost::segment; gh_api method handling as a case and an early return; segment's header-skip, $-detection and $(cat file) scan loops merged into one; GHPOST_WRITES/WTARGETS check…
  • .changes/guardrails/work-resolve-issue-issue-14487-43067391484-1-53116856.md: patch fragment, ### Changed, 'Internal simplification, no behavior change.'

Verification

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

  • 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
  • check-affected: 13 passed, 6 skipped over 4 changed files (run before and after tidy)
  • fresh-context review subagent over the whole diff: no behavior differences found, including set -u with empty arrays, nameref resolution, loop-merge ordering, ! A || B precedence, and stale-path-verify.test.sh's sed-range extraction between its marker comments (both markers unchanged)
  • git-read diff --numstat HEAD: 3 code files, about 130 changed lines, 1 area, inside the issue's 400-line / 15-file cap
  • tidy (code-tidying:tidy-diff): ran all passes; no class-A comments and no residue in the listed lines, so no edits
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/43067391484

Left out: the items under Not verified.

Related

#14487

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

Security review: PR #15401 (guardrails simplification)

I found no security issues.

None of the changed files matches a trusted path or a trust control. Two of them are guardrail hooks: stale-path-verify.sh, workflow-resilience-check.sh, and the github-post-body.sh library that the post-content block hooks source. A hook's checks are a standing control, so I read every hunk to see whether the change weakens what they catch.

  • github-post-body.sh, ghpost::segment. The three loops over the posting command's words are now one loop. The $ check (GHPOST_SUBST) and the $(cat …) / $(<…) scan (GHPOST_FILES) now run at the top of each pass, before the -H / --header skip and before continue. So they still see every word, including skipped header values, just as the old separate loops did. The order of entries in GHPOST_FILES is unchanged, and GHPOST_TEXTS gets the same words. Nothing a post used to be checked for is skipped now (L386-L418).
  • github-post-body.sh, gh_api method check. The new case gives the same results as the old pair of tests: an empty method leaves writes alone, GET or HEAD sets it to 0, anything else sets it to 1. The early return 0 is the old if ((!writes)) turned around, with the same rollback of GHPOST_FILES and GHPOST_STDIN (L176-L187).
  • github-post-body.sh, ghpost::_cmd_name_to. The new helper normalizes a command name the same way the old inline code did. Its nameref resolves to the caller's local b or cmd, and neither name collides with __ghp_name (L152-L158).
  • github-post-body.sh, GHPOST_WRITES in bodies. The check moved out of the loop, but it still sets the flag only when GHPOST_FILES and GHPOST_WTARGETS are both non-empty, which is exactly when the old loop body ran and set it (L457).
  • workflow-resilience-check.sh. Bash parses if ! A || B as (! A) || B, so the two clean-exit cases (no fan-out, or a throttle or retry helper already in use) behave as before. Both greps still read the script through process substitution.
  • stale-path-verify.sh. The word and non-word anchor paths now share one occ == 1 check, and the word path still drops anchors that contain . or -. The one-line hits=(${SPV_HITS[@]+…}) copy is equivalent to the old if-copy under set -u.
  • File mode. github-post-body.sh changes from 100644 to 100755, which the PR description doesn't mention. It is a sourced library, and being executable gives no new way to run it with different trust, so this is not a security finding.
  • Instruction surface. Only comments were removed: notes about earlier versions. No rule in a block list or allowlist was deleted, narrowed or softened.

Spend: none. The change touches no paid plan, billing, workflow or lane setting.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: PR #15401, simplifying three guardrails files (closes #14487)

I read all 4 changed files in full. 1 advisory finding, no blocking findings.

Behavior-equivalence checks (done by reading the code; no tests run in this lane)

  • stale-path-verify.sh
    • The word and non-word anchor branches now share one ((occ == 1)) gate. Both paths still continue in the same cases. When occ is empty after a failed count, ((occ == 1)) is false either way.
    • hits=(${SPV_HITS[@]+"${SPV_HITS[@]}"}) is equivalent to the old if-copy under set -u.
    • The file_rel="" merge is a no-op.
  • workflow-resilience-check.sh: bash parses if ! A || B as (! A) || B, so both clean exits still emit_tel '[]'; exit 0.
  • github-post-body.sh
    • _cmd_name_to: the helper's nameref resolves to the caller's local b or cmd. The name __ghp_name cannot collide with either.
    • gh_api: the case "${method^^}" matches the old two tests. Nothing after the old upper-casing read method, so not storing the upper-cased value back changes nothing.
    • segment: in the merged loop, $ detection and the $(cat …) scan sit before the skip/header continues, so they still cover every word, as the old separate loops did. The words loop adds nothing to GHPOST_FILES, so the order of GHPOST_FILES is unchanged.
    • bodies: read_to and _add never touch GHPOST_WTARGETS, so moving the GHPOST_WRITES check out of the loop is equivalent.

Advisory finding (no changed line can carry it)

  • Unexplained file-mode change on a library file. The diff changes plugins/guardrails/lib/github-post/github-post-body.sh from 100644 to 100755.
    • The file's own header says it is "A library, not executable". It has no shebang and is only sourced by block-fix-request-post.sh and block-github-post-content.sh.
    • Neither the PR body nor the issue's scope mentions or needs the mode change. It looks like a side effect of the lane's environment.
    • The issue requires "Behavior is unchanged … written files", and the change makes a library file runnable directly when it should only be sourced.
    • scripts/check-affected.sh's exec-bit check only requires #! files to be 100755. It does not flag the reverse, so CI will not catch this.
    • Fix: restore mode 100644 (git update-index --chmod=-x plugins/guardrails/lib/github-post/github-post-body.sh).

Closing issue #14487 acceptance criteria

  • Behavior unchanged: met in the code paths reviewed above, apart from the mode change. The existing suites (stale-path-verify.test.sh, workflow-resilience-check.test.sh, and the block-fix-request-post / block-github-post-content suites) are the tests that would fail if a path broke. The author says these could not run in their lane, so their results are still unverified and left to CI.
  • Only listed files plus a fragment edited: met.
  • Within 400 lines / 15 files: met. About 130 changed lines over 3 code files.
  • ci-status green: left to CI, so it is unverified here.
  • Fragment: met. It is bump: patch with ### Changed and "Internal simplification, no behavior change."

Other notes

  • Manifests: no plugin.json or marketplace.json changes, and no changed file matches a trusted path.
  • Prior findings: none, and this was a full review, not blocking-only.
  • Embedded text: no directives in the PR context or closing issue.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head bc84da0a5c389339a3d7441e5afd9dbe04f94066. No person needs to act: a lane clears this reason, and the next scheduled run judges it again.

pr-merge's gate refuses its verifier verdict (verify:missing)

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for bc84da0

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-15401-bc84da0a5c389339a3d7441e5afd9dbe04f94066, 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 f9159e2 Nov 11, 2026
72 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14487-43067391484-1 branch November 11, 2026 18:33
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit f9159e2757a272b086d1f91320b315d24ab8dd89; 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 and github-post guardrails plugin code

0 participants