Skip to content

refactor(harness-config): simplify state-digest and permission-rule-check scripts - #15424

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14498

Summary

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

Simplified the two listed harness-config scripts without changing outputs, exit codes, messages, flags or written files. state-digest.sh now resolves the sha256 command once instead of re-probing on every hash, folds hash_path's two unreadable branches into one fallback, streams the digest body straight into the hash instead of through an unregistered temp file, drops collect_entries' skip flag for continue 2, and registers cmd_dirty's temp files with the existing mk_temp/trap instead of hand-cleaning them on each die path. permission-rule-check.sh tokenizes each rule once in scan_bare_tool (was once per tool) and matches tokens without a read loop in scan_bare_tool and scan_agent, and joins the coverage scope list with one printf. A helper that would have collapsed scan_rule's five emit loops was reverted: scripts/check-detector-eval-coverage.sh needs every emit call to carry a literal severity and id.

Not verified

  • The two suites (state-digest.test.sh, permission-rule-check.test.sh) were not run here: the lane's Bash runs only named wrappers. check-affected did not list them by name, so they are left to the PR's CI
  • CI-only scanners, including detector-eval-coverage and cant-fail-scan, did not run here and are left to the PR's CI. cant-fail-scan reads only test files, and this change edits none
  • tidy: passes 1-4 ran with no edits. Pass 5 (ai-slop) applied the rubric only, because detect.sh and digest-guard.sh are not runnable in this lane. Proposal: the \[\[ -n "$m" \]\] guard in scan_rule's loops checks a state that can't happen (grep -o never prints an empty match); it predates this…
  • Review finding left as is: state-digest.test.sh:211's ,+5d sed range now deletes one cleanup line beyond the guard block, and its assertions still pass. Changing the test to ,+4d would go beyond the test edits the issue allows (only asserted lines the change breaks)
  • ci-status green is a PR CI check

Fix

  • plugins/harness-config/skills/audit-pass/scripts/state-digest.sh: sha256 command resolved once (resolve_sha256 + SHA256_CMD) and used by sha256_stdin; hash_path unreadable branches merged; collect_entries uses continue 2 and inlines the hash; digest_from_entries pipes the joined body into…
  • plugins/harness-config/skills/audit-permission-grants/scripts/permission-rule-check.sh: scan_bare_tool computes top-level tokens once and matches newline-framed tokens; scan_agent matches the same way; coverage_block joins scope_status with printf
  • .changes/harness-config/work-resolve-issue-issue-14498-43084188796-1-84e9e757.md: new patch fragment, ### Changed / Internal simplification, no behavior change.

Verification

The runner ran each check from the base copy against 37260ee:

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

The run reports:

  • check-changelog-fragments: all 113 fragments valid
  • check-changed-skills: audit-pass and audit-permission-grants PASS, 0 errors (warnings are existing SKILL.md size/description notes)
  • check-affected: first run failed shellcheck SC2249 (missing default case in state-digest.sh main); added *) : ;;, re-run: 13 passed, 6 skipped
  • fresh-context review subagent over the whole diff: no runtime behavior difference found; flagged that an emit_matches helper (emit "$1" "$2" ...) would make scripts/check-detector-eval-coverage.sh report an UNRESOLVED emit site and exit 2; confirmed against that script's header (lines 142-149) and…
  • state-digest.test.sh sed mutations checked by reading: s/--untracked-files=all // and s/LC_ALL=C sort/sort/ still match; the /if \[\[ "$rc" -ne 0 \]\]; then/,+5d range still removes the git-status guard and now also removes the following rm -f "$err" line, which the EXIT trap covers, so the…
  • permission-rule-check.test.sh sed target fm_no_block=$((fm_no_block + 1)) unchanged
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/43084188796

Left out: the items under Not verified.

Related

#14498

Merge-Risk: unrated reason=pending

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

Copy link
Copy Markdown
Contributor

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

Security review: PR #15424

I found no security issues. I read the whole change in all 3 listed files.

Changelog fragment. .changes/harness-config/work-resolve-issue-issue-14498-43084188796-1-84e9e757.md is a new patch note. It holds only text and runs nothing.

state-digest.sh (local digest helper for audit-pass)

  • Hash command check. The script still finds the sha256 command at the top level before it hashes anything. resolve_sha256 runs from main for digest, input-digest and hash-file. Its die therefore runs in the main shell, not in a subshell, so a missing sha256sum/shasum still exits 2 instead of producing an empty hash. Because sha256_stdin no longer checks for the command itself, the up-front check is now the only one.
  • Unreadable paths. out is declared local out="" at line 161. A directory, an unreadable file or an empty hash result still all fall back to SENTINEL_UNREADABLE.
  • Temp files. In cmd_dirty, both temp files now go through mk_temp, which registers them with the EXIT trap, so they are removed on every exit path. Streaming the digest into the hash drops a temp file that was never registered. Nothing new is left behind and no new temp path is exposed.
  • collect_entries. It still runs in the main shell, with only its output redirected, so its die calls still reach the exit code. continue 2 skips excluded surfaces exactly as the old flag did.

permission-rule-check.sh (auditor that flags risky permission grants)

The checks for a bare Bash/PowerShell grant and for Agent give the same results as before:

  • Matching. The tokens come from top_level_tokens, which outputs one token per line, the same lines the old read loop went through. Each token is matched as a whole line, and *$'\n'Agent\(* matches a token that starts with Agent(, as before.
  • Quoting. $tool is quoted inside the pattern, so it is not treated as a wildcard.
  • Coverage text. The coverage_block join gives the same output, including the fallback text when no scope was attempted.

Other checks

  • Trust controls. No file matches a TRUSTED PATHS: glob. Nothing touches a trust control, token scope, kill switch, merge hold, plugin manifest or standing instruction.
  • PR description. It contains no embedded instructions aimed at this lane.
  • Spend. None: the change only alters local shell scripts.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: PR #15424, no findings

I read every hunk of all 3 changed files and found nothing to block or flag. I could not run anything in this lane, so everything below comes from reading the code. I have not run the test suites or CI.

Is behavior unchanged? (#14498 acceptance criteria)

state-digest.sh

  • resolve_sha256 / SHA256_CMD. It runs in main before every subcommand that hashes (digest, input-digest, hash-file). dirty never calls sha256_stdin, so the array staying empty there does no harm. The missing-tool message and exit 2 are the same as before.
  • hash_path. out is now local out="", so ${out:-$SENTINEL_UNREADABLE} covers the same three cases as before: a directory, a path that fails -r, and a failed or empty hash. Each still returns unreadable.
  • collect_entries. continue 2 skips to the next list entry, as the old skip flag did. The script uses set -uo pipefail, not -e, so the [[ … ]] && continue lines carry no errexit risk.
  • digest_from_entries. The loop now reads sort output directly. Dropping || [[ -n "$line" ]] is safe because sort always ends its last line with a newline. The bytes sent to the hash are the same as before (the separator goes before every entry except the first), and an empty set still hashes the empty string. cmd_digest's exit status still comes from its last rm -f, so pipefail on this pipeline does not change it.
  • cmd_dirty. mk_temp runs in the main shell, so the EXIT trap still deletes both temp files when the script dies.

permission-rule-check.sh

  • scan_bare_tool / scan_agent. top_level_tokens is grep -o, so every token ends with a newline. Matching against the newline-framed string gives the same result as the old line-by-line loop. Each rule still triggers at most one warning, and Agent\( matches a literal (.
  • coverage_block. Every scope_status entry is a non-empty "<scope>: …" string, so the printf plus ${joined%; } join gives the same text. With no entries, the (no settings scope was attempted) fallback still applies.

Tests and scope

  • sed mutations in state-digest.test.sh. The ones at lines 179 and 233 still match the script. The PR body already discloses that the ,+5d range at line 211 now also deletes the rm -f "$err" line after it. The deleted guard is still the mutation under test, so the test keeps its value.
  • sed target in permission-rule-check.test.sh. It still matches, because fm_no_block was not touched.
  • Scope. The diff touches only the two listed scripts and one changelog fragment. The fragment's text and bump: patch match the issue's wording.
  • Author-claimed, unverified. The PR body's check-affected, changelog-fragment and changed-skills results are the author's claims. I did not reproduce them.

No hold applies, and nothing in this change spends anything.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@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 15b8bbf Nov 11, 2026
77 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14498-43084188796-1 branch November 11, 2026 20:08
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 audit-pass and audit-permission-grants harness-config plugin code

0 participants