Skip to content

refactor(docs-hygiene): simplify detect, articles-setting, audit-scan, detect-caveman and setup-apply scripts - #14549

Merged
kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-14457-42601529490-1
Nov 9, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-14457-42601529490-1

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14457

Summary

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

Behavior-preserving simplification of the docs-hygiene scripts listed in the issue. detect.sh replaces its three grep-over-tempfile dedupe sets (seen files, seen pointers, reached spokes) with associative arrays, extracts the duplicated context-line pipeline into a line_ctx helper, and folds each link filter into one case statement. articles-setting.sh drops a dead count=1, a one-use status variable and the now-redundant numeric guards. audit-scan.sh prints rows as it classifies them instead of buffering, and builds the COMPRESS reason once. detect-caveman.sh pipes claude's output straight into jq. setup-apply.mjs looks up dropped keys in a Set. emit-verify-facts.sh is unchanged: its one candidate edit (dropping || true after cd) tripped shellcheck SC2164, so it was reverted.

Not verified

  • The scripts' *.test.sh suites (detect.test.sh, articles-setting.test.sh, audit-scan.test.sh, detect-caveman.test.sh, setup-apply.test.sh) could not be run directly in this lane; left to the PR's CI
  • tidy: passes 4 and 5 (markdown writing rules, ai-slop fix) skipped on the changelog fragment, whose wording the issue fixes verbatim
  • Behavior note: detect.sh paths starting with '-' used to defeat the grep -Fxq dedupe (grep read them as options). The associative arrays dedupe them correctly, so output differs only for those inputs, which the original mishandled
  • ci-status green is a PR CI check, not runnable here

Fix

  • plugins/docs-hygiene/skills/audit-progressive-disclosure/scripts/detect.sh: associative arrays replace the SEEN_FILES, SEEN_PTR and per-hub REACHED tempfiles and their grep -Fxq lookups; new line_ctx helper shared by md_links and backtick_paths; merged case filters, and dropped the backtick URL…
  • plugins/docs-hygiene/skills/compress/scripts/articles-setting.sh: removed the dead count=1, the status variable and the regex guards around count (an empty count still evaluates as 0)
  • plugins/docs-hygiene/skills/compress/scripts/audit-scan.sh: rows print as classified (no rows buffer); one COMPRESS emit_row with the article wording chosen first; shorter word_count floor
  • plugins/docs-hygiene/skills/compress/scripts/detect-caveman.sh: pipe claude plugin list --json straight to jq instead of going through a json variable with || true
  • plugins/docs-hygiene/skills/setup/scripts/setup-apply.mjs: precompute the Set of keys with problems instead of calling problems.some per key
  • .changes/docs-hygiene/work-resolve-issue-issue-14457-42601529490-1-43d62d52.md: patch fragment, ### Changed: Internal simplification, no behavior change.

Verification

The runner ran each check from the base copy against 740bf62:

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

The run reports:

  • check-changelog-fragments: all 2 fragments valid
  • check-changed-skills: 3 skills checked, 0 failed (only warnings that predate this change)
  • check-affected: 13 passed, 6 skipped, 0 failed; the first run failed shellcheck SC2164 on emit-verify-facts.sh, which was fixed by reverting that edit
  • fresh-context review subagent: found one behavior change (articles-setting.sh counted keys from grep output, which differs from grep -c on a file grep treats as binary), fixed by restoring grep -cE; other findings were nits: one fewer duplicate stderr line on an unreadable file, stderr/stdout…
  • tidy-diff over the change's lines: no edits needed; comments kept as class C
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42601529490

Left out: the items under Not verified.

Related

#14457

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

Security review: PR #14549 (head 740bf62)

I found no security issues. I read every hunk of all 6 changed files in .claude-lane/pr.diff.

None of the changed files matches a trusted-path glob. The diff doesn't touch a plugin manifest, an instruction surface (CLAUDE.md, a skill or agent body, a hook list), a workflow, or a trust control, so the manifest and instruction-deletion checks don't apply.

What I checked:

  • audit-progressive-disclosure/scripts/detect.sh: the grep -Fxq tempfile dedupe sets are now associative arrays (seen_files, seen_ptr, reached). Bash expands assoc-array subscripts once and doesn't evaluate them as arithmetic, so a file path or link target used as a key can't run code. Empty targets are still skipped before they're used as keys. The new line_ctx helper passes the file and line number as quoted arguments to sed -n "${2}p". $2 is the line number taken from grep -n output, so only digits can reach that sed expression. The merged case filters still drop http(s):// and mailto: targets. For backtick spans, the existing character class rejects any colon. Removing the tempfiles also removes the extra mktemp and rm handling, which leaves less to clean up.
  • compress/scripts/articles-setting.sh: dropping the ^[0-9]+$ guards puts count straight into (( )). Bash arithmetic re-evaluates a variable's value, so that would be an injection risk if count could hold arbitrary text. Here it can't: count comes only from grep -cE ... "$file" on one file, which prints a number or nothing, and an empty value evaluates to 0. Nothing attacker-controlled reaches it.
  • compress/scripts/audit-scan.sh: rows now print as they're classified, and the COMPRESS reason string is built once. Both are formatting changes only.
  • compress/scripts/detect-caveman.sh: claude plugin list --json now pipes straight into jq instead of going through a variable. The jq filter, and what it selects, didn't change.
  • setup/scripts/setup-apply.mjs: a Set of keys with problems replaces a problems.some call per key. The logic is the same.
  • .changes/...md: a changelog fragment, data only.

The PR context file contains no embedded instructions aimed at this lane. The prior-findings file shows this is the lane's first review of the PR (blocking only: no).

critical-findings: 0

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Code review: PR #14549, simplify docs-hygiene scripts (closes #14457)

No findings. I read every hunk of all 6 changed files and checked each simplification against the head file and its set options.

Behavior-preservation check, per file

  • detect.sh
    • Associative arrays. These replace the SEEN_FILES, SEEN_PTR and REACHED tempfiles. declare -A needs bash 4, and the script already relied on bash 4 through mapfile.
      • No key can be empty: $f, the ln\ttarget key, the -f-checked $t and $spoke all have a value. Bash would reject an empty key.
      • seen_ptr=() and reached=(...) keep the associative attribute and reset once per file or hub, as the tempfiles did.
      • ${#seen_files[@]} gives the same unique count as wc -l did on SEEN_FILES.
      • [[ … ]] && continue does not trip set -e.
    • md_links. It now checks for a URL after removing the #anchor. Every URL still starts with its scheme, so it is still skipped. An empty target fails the *.md match, so the dropped -z check is redundant.
    • backtick_paths. The reordered case is a conjunction, so order does not matter. Dropping the URL check is safe: every http:/https:/mailto: span contains :, and the character class [!A-Za-z0-9._+/-] rejects it.
    • line_ctx. It is defined after md_links but before anything calls it, which is fine in bash.
  • articles-setting.sh (set -uo pipefail, no -e): $? right after value="$(…)" is still the reader's status. An empty count evaluates to 0 in (( )), the same result the removed regex guards produced. The removed count=1 was dead code: nothing reads count after that point.
  • audit-scan.sh (no -e): printing inside the loop gives the same stdout order, because classify_file runs in a command substitution. ((n < 50)) && n=50 is equivalent to the old floor, and the COMPRESS reason strings match the originals byte for byte.
  • detect-caveman.sh (set -uo pipefail, no -e, documented as always exit 0): removing || true changes only the pipeline's status, which nothing reads. plugin_id gets the same value.
  • setup-apply.mjs: badKeys.has(k) is equivalent to problems.some((p) => p.key === k). Problems without a key add undefined to the set, which never equals a key name.

Closing issue #14457 acceptance criteria

  • Behavior unchanged: met for realistic inputs. One edge case differs, and the PR body says so. When a target path starts with -, the old grep -Fxq read the path as a grep option, so those paths were never de-duplicated. The new arrays de-duplicate them, so detect.sh output differs only for such paths. This fixes a latent bug rather than adding one, so I am not counting it as a finding. emit-verify-facts.sh is untouched, which the PR also explains.
  • Diff edits only the listed files plus a fragment: met.
  • Within 400 lines and 15 files: met.
  • Fragment with bump: patch, ### Changed and the required line: met.
  • ci-status green: I could not check this, since this lane has no CI access. The PR says the *.test.sh suites were not run in the authoring lane, so that is unverified by its author. Its claimed checks (changelog-fragment, changed-skills, check-affected) are also author-claimed and unverified.

Other checks

  • Path-scoped rules: .claude/rules/skill-bodies-state-current-rules.md and .claude/rules/cost-claims.md match these paths by glob, but they govern skill and agent body text. The only prose change in this diff is a script comment, so neither rule applies.
  • Paved paths and manifests: no plugin manifest changed, and no paved-path concern applies.
  • Embedded instructions: none found in the PR context or prior-findings file.
  • Prior findings: none. This is the first review of this PR (earlier heads reviewed: 0).

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 740bf62

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-14549-740bf62a6e310fb562230d7b4d1033eb4749f5b0, 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
@melodic-automation-lanes
melodic-automation-lanes Bot removed this pull request from the merge queue due to a manual request Nov 9, 2026
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit 928c95a Nov 9, 2026
63 checks passed
@kyle-sexton
kyle-sexton deleted the work-resolve-issue/issue-14457-42601529490-1 branch November 9, 2026 12:39
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-progressive-disclosure, compress, extract-ssot and 1 more docs-hygiene plugin code

1 participant