Skip to content

refactor(harness-config): simplify audit-permission-state reader and lint scripts - #15425

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14500

Summary

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

Simplified permission-plane-lint.sh and permission-state.sh with no behavior change. In the lint script, the specifier parser's two identical return branches became one, the parameter-form membership tests are computed once and reused, and the long history-narration comments are cut down to the mechanics they explain. In the reader, classify_json_file uses one jq call instead of two: the jq -e shape filter already exits nonzero on a parse error, so the separate jq empty stage was redundant, and dropping it saves a jq and a sed process per settings file. The ownership check and the USER_CONFIG_ROOT resolution are shorter, the multi-line rule notice reuses note(), and the invalid-json/present branching is one case statement. test-helpers.sh is unchanged: it already follows the shared shell-test-helpers contract and had nothing to simplify.

Not verified

  • The audit-permission-state *.test.sh suites were not run here: this lane runs no test runner or interpreter. Left to the PR's CI.
  • ci-status green is a PR CI check, left to the PR's CI.
  • permission-state.test.sh:137-140 still says the jq empty stage rejects the syntactically broken fixture on its own. That stage is gone and jq -e now rejects it, so the comment is stale, but the assertions still hold. Left unedited because the issue limits test edits to assertions the change…
  • Tidy recorded as skipped: passes 1-4 ran with no edits, but in pass 5 the ai-slop detector script cannot run under this lane's Bash allowlist. Only the rubric read ran on the fragment, and it found no tells.
  • cant-fail-scan does not apply: it scans test files, and this change touches none.

Fix

  • plugins/harness-config/skills/audit-permission-state/scripts/permission-plane-lint.sh: specifier_body collapses its ok/trailing branches into one ternary and uses a local in place of the spec_rest global; is_param_only and is_documented are computed once and reused by C6-colonStar,…
  • plugins/harness-config/skills/audit-permission-state/scripts/permission-state.sh: classify_json_file drops the redundant jq empty stage (the jq -e shape filter exits nonzero on parse errors too); ownership block merged into one branch with the override and the -O loop setting a single flag;…
  • .changes/harness-config/work-resolve-issue-issue-14500-43084216005-1-e5591e9b.md: patch fragment, ### Changed, Internal simplification, no behavior change.

Verification

The runner ran each check from the base copy against 2ec43dd:

  • 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-permission-state PASS, 0 errors (4 warnings about SKILL.md size and description length, which this change does not touch)
  • check-affected: first run failed shellcheck (SC1011/SC1036) on apostrophes I had added to comments inside the single-quoted awk program; fixed, and the rerun passed 13 checks, skipped 6, failed 0
  • fresh-context review subagent, reading the code only, checked each edit for any input that behaves differently (specifier parsing, param_form logic, single-jq classification on empty, multi-document, scalar, null, array and mid-stream parse-error input, ownership override vs -O, set -u parameter…
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/43084216005

Left out: the items under Not verified.

Related

#14500

Merge-Risk: unrated reason=no-rating

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

Copy link
Copy Markdown
Contributor

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

Security review: PR #15425 (head 2ec43dd)

No security issues found. I read every hunk of all 3 changed files. None of them matches a trusted path, none is a plugin manifest, and none is a trust control or merge hold.

This change refactors the audit-permission-state reader and lint scripts. I checked whether any rewrite changes the audit's verdict in the fail-open direction, for example by reporting a malformed settings file as present or hiding a deny-rule defect. None does. Each rewrite behaves the same as the base:

  • classify_json_file drops the separate jq empty stage (permission-state.sh:295-305). Every input that check used to reject still makes the remaining jq -e call exit nonzero, so the file still gets invalid-json:

    • a syntax error, including a truncated file or a mid-stream error after a valid first document (jq exits 2);
    • a non-object top level, since .permissions on a string or array errors (exit 5);
    • a file of the wrong shape.

    Multi-document and empty input get the same verdict as before, because jq empty let both through to the same filter. The file's contents still never land in a shell variable.

  • Ownership fallback (permission-state.sh:248-262):

    • With the override set, the start-directory fallback still happens only when the value is foreign.
    • Without it, the -O loop flags only paths that exist, which matches the old owner_checked && owner_foreign condition.
  • USER_CONFIG_ROOT: ${CLAUDE_CONFIG_DIR:-${HOME:+$HOME/.claude}} gives the same three outcomes as before and is safe under set -u.

  • note() reuse: it prints NOTE: %s\n (permission-state.sh:146), so the output is byte-identical to the old inline printf.

  • specifier_body (permission-plane-lint.sh:118-133): the && --depth short-circuit decrements only on ), so ok/trailing/unclosed come out the same. The removed spec_rest global has no other reader in the scripts directory.

  • param_form: is_param_shape && (kind != "allow" || is_param_only) is logically the same as the old ternary. C6-colonStar, C6-colonStarAmbiguous and C6-allowParam therefore still fire on the same rules, so deny Bash(git:* push) is still reported.

No instruction surface is narrowed. The deleted comments are history narration; the checks they describe are unchanged in the code.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: PR #15425, simplifying the audit-permission-state scripts

No findings. I read every hunk of all 3 changed files and found no change in behavior, in line with closing issue #14500.

What I checked

permission-plane-lint.sh

  • specifier_body: ch == ")" && --depth == 0 short-circuits, so depth drops only on a ), the same as before. rest ~ /^[ \t]*$/ → ok is the same test as the old strip-leading-whitespace-then-check-empty. The old spec_rest was a global, and nothing else in plugins/harness-config reads it, so making it a local changes nothing.
  • param_form: is_param_shape && (kind != "allow" || is_param_only) is logically the same as the old ternary.
  • is_param_only / is_documented: they are computed once per rule, after tool and pfx are set. Neither value is reassigned before the C6-colonStar, C6-colonStarAmbiguous and C6-allowParam checks read it, so all three see the values the old inline in tests gave.
  • Comments: the shortened comments still describe what the code does.

permission-state.sh

  • Ownership block: the override path still applies only when LOCAL_ROOT != START_DIR. Dropping owner_checked is safe: owner_foreign can only be set for a path that exists, which already implies the old "checked" flag. Nothing else references owner_checked.
  • USER_CONFIG_ROOT: ${CLAUDE_CONFIG_DIR:-${HOME:+$HOME/.claude}} gives the same three results, including empty when HOME is unset or empty. :+ does not trip set -u.
  • classify_json_file: both the old jq empty stage and the remaining jq -e stage led to the same invalid-json output. A parse error makes jq -e exit nonzero. An empty file gives no output, so jq -e exits 4, which was already the old result for that case. So removing the first stage cannot change any verdict.
  • note: it prints NOTE: %s\n (permission-state.sh:146), so the reworked newline-rule notice prints the same bytes as the old printf.
  • case "$status:$scope": it matches the old if/elif chain exactly. managed and user are matched exactly, and the other invalid-json cases fall to the general branch.

Changelog fragment: bump: patch, a ### Changed heading and "Internal simplification, no behavior change.", as the issue requires.

Closing issue #14500, acceptance criteria

  • Behavior unchanged: met, from reading the code (above).
  • Diff edits only the listed files plus a fragment: met. test-helpers.sh is untouched.
  • Size limit: met, well under 400 lines.
  • Fragment: met.
  • ci-status green: CI checks this, not the review. I ran nothing.

The test suites and the review subagent's behavior check are the author's claims; I did not verify them.

Note (not a finding)

The comment at permission-state.test.sh:137 still says jq empty rejects the syntactically broken fixture. That stage is gone, so the comment is now out of date, though the assertions still hold. The PR already says so under "Not verified", and the issue does not allow edits to tests beyond broken assertions. It belongs in the follow-up restructuring pass.

No paid resources or billing settings are touched.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head 2ec43dd8f193e4d3033b00da82b3d3e1eb4e3c29. 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 2ec43dd8f193e4d3033b00da82b3d3e1eb4e3c29, 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 a968abb Nov 11, 2026
64 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14500-43084216005-1 branch November 11, 2026 22:28
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit a968abb0e7dedac67f1d18fd3ea795651956b843; 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 audit-permission-state harness-config plugin code (2 of 2)

0 participants