Skip to content

refactor(attribution): simplify audit scripts without behavior change - #14834

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14414

Summary

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

Simplified the five attribution audit scripts and kept their outputs, exit codes, messages, flags and exported names the same. fingerprint.mjs merges stripInlineQuotes' three keep-the-mark branches into one opens test, and parseArgs now reads its value-taking options from a table instead of a switch. list-corpus.sh merges the whole-repo and directory-target enumeration branches, and its two JSON array printers now share one json_array helper. score-golden.sh builds the verdict from the cell names, sweep-ledger.sh folds the sha256 length check into its regex, and lib.sh defines its lib path once and sources config-root.sh through it. Nothing was moved or deduplicated across files.

Not verified

  • Script test suites (fingerprint.test.mjs, list-corpus.test.sh, score-golden.test.sh, sweep-ledger.test.sh) were not executed: this lane cannot run node or bash scripts. Left to the PR's CI.
  • ci-status green is a PR check, so it is left to the PR's CI.
  • tidy pass 5 (ai-slop detector) on the changelog fragment did not run, because detect.sh cannot run in this lane. An inline rubric read of the one required line found no tells. Passes 1-4 ran and needed no edits.
  • Shellcheck and node lint did not run here (no such wrapper in this lane). check-affected covered what it runs locally, and the rest is left to CI.

Fix

  • plugins/attribution/skills/audit/scripts/fingerprint.mjs: stripInlineQuotes computes one opens condition in place of three early-continue branches; parseArgs uses a VALUE_OPTIONS map for --local/--source/--k/--min-containment/--min-span-words with the same error messages
  • plugins/attribution/skills/audit/scripts/lib.sh: _CFG_LIB is defined before the config-root.sh source and reused for it
  • plugins/attribution/skills/audit/scripts/list-corpus.sh: anchor_dir calls dirname directly; the empty-target and directory-target branches are merged; the files and declined arrays print through one json_array helper (byte-identical output), and declined_total is summed in the same loop
  • plugins/attribution/skills/audit/scripts/score-golden.sh: the case verdict is built from ["tp","fn","fp","tn"] filtered by value, with the same order and join
  • plugins/attribution/skills/audit/scripts/sweep-ledger.sh: the sha256 check is the single regex ^[0-9a-f]{64}$
  • .changes/attribution/work-resolve-issue-issue-14414-42681181755-1-1a093857.md: patch fragment, ### Changed, "Internal simplification, no behavior change."

Verification

The runner ran each check from the base copy against 812f78c:

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

The run reports:

  • check-changelog-fragments: all 14 fragments valid (run before and after tidy)
  • check-changed-skills: plugins/attribution/skills/audit PASS, 0 errors, 5 warnings that the SKILL.md already had before this change
  • check-affected: 13 passed, 6 skipped over 6 changed files (run before and after tidy)
  • fresh-context review subagent: read the whole diff hunk by hunk against HEAD and the adjacent .test.mjs/.test.sh files and found no behavior difference (checked: JSON output bytes, empty arrays under set -u, jq $c[.] semantics, regex {64} equivalence, every quote-char case in stripInlineQuotes,…
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42681181755

Left out: the items under Not verified.

Related

#14414

Merge-Risk: max=MEDIUM demote=false head=812f78ce3dc3aa245e6625fe6488f189984f5b4f rubric=8.2.0 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 812f78ce3dc3aa245e6625fe6488f189984f5b4f: read 6 of 6 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #14834 (attribution audit script simplification)

I found no security issues in this change. I read every hunk of all 6 changed files, and I read the enumeration section of list-corpus.sh at head for context. None of the files is on a trusted path, and the diff doesn't touch any trust control, merge hold, plugin manifest or standing instruction.

What I checked:

  • sweep-ledger.sh sha256 check. Before, the code checked for 64 characters and also matched ^[0-9a-f]+$. Now it uses one regex, ^[0-9a-f]{64}$ (L278). Bash =~ anchors to the whole string, so $ doesn't stop at an embedded newline. The new check accepts exactly the same values as the old one. The URL guard on the line above it is unchanged, so no new text can get into the ledger line.
  • fingerprint.mjs parseArgs. The lookup table is a Map with fixed keys, so a __proto__-style flag finds nothing and falls through to unknown option. args[key] is only ever written with keys from that table, so prototype pollution isn't possible. The missing-value and -- checks are kept. --json no longer sets args.json, but args.json already starts as true.
  • fingerprint.mjs stripInlineQuotes. The opens condition is the same logic as the three branches it replaces. This code only parses text and has no security surface.
  • list-corpus.sh enumeration merge. With an empty target, the prefix stays "" and DEFAULT_BASE stays "", which was already its value from the initialization at L163. The -z "$prefix" test then keeps every tracked markdown file, as before. A directory target still goes through rel_to_root and the same prefix filter, so the corpus covers no new paths.
  • list-corpus.sh json_array. Every item is still encoded with json_str before it goes into the array, so the JSON escaping hasn't changed.
  • lib.sh. _CFG_LIB is now defined before the source line and uses the same BASH_SOURCE-relative path, so it sources the same file.
  • score-golden.sh. The jq verdict now uses $c[.] on a fixed list of names. No input reaches it in a new way.
  • Changelog fragment. Prose only.

The PR context file has no embedded instructions aimed at this review.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Code review: PR #14834, refactor(attribution): simplify audit scripts without behavior change. No findings.

I read every hunk of all 6 changed files. I also read the head code around each change: stripInlineQuotes, parseArgs and the list-corpus.sh enumeration and roots blocks, plus every use of _CFG_LIB. Each rewrite does the same thing as the code it replaces:

  • fingerprint.mjs stripInlineQuotes: the single opens check keeps a mark in the same three cases as the old early exits: a char that is not an opener, an apostrophe after a char that is not whitespace or an opening bracket, and an opener with no closing mark. block[-1] is undefined at i = 0, as before.
  • fingerprint.mjs parseArgs: the VALUE_OPTIONS table keeps the same keys and the same requires a value / unknown option messages. String(value) returns the string unchanged. --json no longer sets args.json = true again, but args already starts with json: true and nothing sets it to false.
  • lib.sh: _CFG_LIB is now set before config-root.sh is sourced. BASH_SOURCE[0] is still lib.sh at that point, and no sourced file uses or resets _CFG_LIB.
  • list-corpus.sh:
    • anchor_dir is only called inside $(...), so the extra newline dirname prints gets stripped.
    • In the merged empty-or-directory branch, an empty TARGET leaves prefix and DEFAULT_BASE as "" (the value DEFAULT_BASE already had), and the [[ -z "$prefix" ... ]] test adds every non-empty line, as the old branch did.
    • json_array prints the same bytes: the same [, line breaks, 4-space indent and \n ], and [] when empty. Empty arrays are guarded under set -u. The declined object text matches the old printf format.
  • score-golden.sh: $c[.] == 1 over ["tp","fn","fp","tn"] keeps the same order and the same null-is-false result for a missing key.
  • sweep-ledger.sh: ^[0-9a-f]{64}$ accepts the same strings as the old length check plus hex regex.

Closing issue #14414 acceptance criteria:

  • Behavior unchanged: met as far as reading the code shows. I did not run the existing suites (fingerprint.test.mjs, list-corpus.test.sh, score-golden.test.sh, sweep-ledger.test.sh); they cover these paths. The PR author says the suites, shellcheck and node lint were not run in the authoring lane. That is their claim, unverified here, and left to CI.
  • Edits only the listed files plus a fragment: met.
  • Under 400 lines and 15 files: met.
  • ci-status green: a CI check, not judged here.
  • Fragment: .changes/attribution/…-1a093857.md has bump: patch, ### Changed and the required line. Met.

The PR context contained no instructions aimed at this lane. No manifest files changed. No settled threads or prior findings apply: this is the first review of this PR, so it was not blocking only. The change adds no spend.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 812f78c

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-14834-812f78ce3dc3aa245e6625fe6488f189984f5b4f, 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 14ac97e Nov 9, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14414-42681181755-1 branch November 9, 2026 21:05
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 3, survived 4, timeout 0, no coverage 0, invalid 0, not run 0.
Covered-code score 43%; mutation score 43%.

File Killed Survived Timeout No coverage Invalid Not run
plugins/attribution/skills/audit/scripts/fingerprint.mjs 0 3 0 0 0 0
plugins/attribution/skills/audit/scripts/list-corpus.sh 2 0 0 0 0 0
plugins/attribution/skills/audit/scripts/score-golden.sh 1 0 0 0 0 0
plugins/attribution/skills/audit/scripts/sweep-ledger.sh 0 1 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/attribution/skills/audit/scripts/fingerprint.mjs:136 LCR productive input-gap
plugins/attribution/skills/audit/scripts/fingerprint.mjs:394 LCR productive input-gap
plugins/attribution/skills/audit/scripts/fingerprint.mjs:398 other productive input-gap
plugins/attribution/skills/audit/scripts/sweep-ledger.sh:278 other productive input-gap

The run's summary has the full report.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 14ac97e8ffc1435058225f90f6d975eacf1b6d2a; 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 attribution plugin code (2 of 2)

0 participants