Skip to content

refactor(repo-fleet-hygiene): simplify the second half of audit-fleet.sh - #15205

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14712-42918185778-1
Nov 10, 2026
Merged

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14712

Summary

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

Simplified the code that starts in the second half of audit-fleet.sh (from line 1854 of the file as this part started) without changing behavior. analyze_repo's two copies of the merged-PR row lookup now share one find_merged_pr helper. repo_kind_counts_text counts kinds with sort | uniq -c instead of a hand-rolled key/count table, and print_collapsed_target_detail and append_or_extend_action build their comma lists with ${var:+, }. The repo and root argument loops now use index loops instead of counting by hand, the ls-remote branch of the merged-remote-branch check reads more simply, a duplicated fleet_unconfigured_note is computed once, and the existing physical_path_key helper replaces an inline path_key/physical_path pair. One more candidate was reverted: swapping the default-branch sed pipeline for capture_text plus a prefix strip. The review showed the old sed fails with a stderr message for a remote name containing '|', so the swap would have changed printed text in that case.

Not verified

  • plugins/repo-fleet-hygiene/skills/audit/scripts/audit-fleet.test.sh was not run: this lane runs only the named wrappers, so the suite is left to the PR's CI
  • ci-status green on the PR is a CI check, left to the PR's CI
  • tidy: passes 1-4 ran with no edits; pass 5 (ai-slop fix on the changelog fragment) did the rubric read only, because detect.sh is not among the wrappers this lane may run, so its deterministic detector did not run
  • cant-fail-scan not applicable: the change edits no test file
  • Review note outside this change: audit-fleet.sh uses printf '%(%s)T' (bash 4.2+) in the remote-branch-family age calculation, which does not work on macOS bash 3.2; pre-existing and left alone as out of scope

Fix

  • plugins/repo-fleet-hygiene/skills/audit/scripts/audit-fleet.sh: index loops for REPO_ARGS/ROOT_ARGS; repo_kind_counts_text counts with sort | uniq -c; print_collapsed_target_detail and append_or_extend_action use ${var:+, } joins; new find_merged_pr helper replaces two identical inline loops in…
  • .changes/repo-fleet-hygiene/work-resolve-issue-issue-14712-42918185778-1-6d182c70.md: patch fragment from new-changelog-fragment, body '### Changed' with '- Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against 0e29b73:

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

The run reports:

  • check-changelog-fragments: all 20 fragments valid
  • check-changed-skills: plugins/repo-fleet-hygiene/skills/audit PASS, 0 errors, 3 pre-existing size warnings on SKILL.md (not touched)
  • check-affected: first run failed shellcheck (SC2128/SC2178, a local array named kinds shadowing the global kinds string); renamed the array to repo_kinds; rerun 13 passed, 6 skipped, shellcheck included
  • fresh-context review subagent over the whole diff: no bugs; nine hunks behavior-identical under bash 3.2 and set -u; flagged the default-branch sed swap as differing for remote names containing '|', so that hunk was reverted
  • tests that extract functions with sed /^name()/,/^}/ (repo_kind_counts_text, print_collapsed_target_detail) checked by reading: both functions stay self-contained and need only F_KIND, F_REPO_IDX, F_CONF, F_TARGET, sort and uniq
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42918185778

Left out: the items under Not verified.

Related

#14712

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

Security review: PR #15205 (head 0e29b73)

No security issues found.

What I read: every hunk of both changed files.

  • .changes/repo-fleet-hygiene/…-6d182c70.md: a new patch-bump changelog fragment that is prose only.
  • plugins/repo-fleet-hygiene/skills/audit/scripts/audit-fleet.sh: a refactor of a local, read-only audit script.

What I checked in the script:

  • Argument loops. The REPO_ARGS and ROOT_ARGS loops now step through each array by index. The CLI-versus-config split still compares repo_index with root_index against CLI_REPO_COUNT and CLI_ROOT_COUNT. So a CLI --root that is missing, is a symlink, or cannot be traversed still stops the run, and the symlinked-root refusal still holds.
  • find_merged_pr helper. It replaces two identical inline loops over the same repo_pr_rows data. It assigns the caller's pr_match and pr_any exactly as the loops did.
  • ls-remote probe. live_oid is now always computed, but the HIGH finding still needs live_status -eq 0, a non-empty oid and a match on remote_tip. LS_REMOTE_FAILURES still goes up only when the probe fails. The removed %%$'\t'* strip was redundant, because [[:space:]] already matches a tab. Nothing new reaches a command: the script still only prints push --delete --dry-run text.
  • Kind counting and list joins. repo_kind_counts_text now counts with sort | uniq -c, and the comma lists are built with ${var:+, }. Neither adds eval, unquoted expansion or new command construction from repository data.
  • physical_path_key. It replaces an inline path_key "$(physical_path …)" pair, still in a comparison only.

Scope checks:

  • No changed file matches a TRUSTED PATHS glob.
  • No plugin manifest, workflow, trust control, merge hold or instruction surface is touched.
  • The PR context file contains no embedded directives aimed at this lane.

Prior findings: none; this lane has not reviewed an earlier head, so this was not a blocking-only review.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: PR #15205, a refactor of the second half of audit-fleet.sh

Result: no findings. I read every hunk of both changed files. Each refactor works the same as the code it replaces under the script's set -uo pipefail.

What I checked, one hunk at a time:

  • Repo and root loops (REPO_ARGS / ROOT_ARGS). Both arrays start empty at audit-fleet.sh:1283-1284, so ${#ARR[@]} is safe under set -u. The old loops counted every element, empty ones too, and the new for ((…)) loops do the same, because continue still advances the counter. Nothing after the old early root_index increment reads the index (only fleet_discover_root and the ROOT_* appends run there), so dropping that increment changes nothing.
  • repo_kind_counts_text. sort | uniq -c read through read -r count kind gives the same kinds in the same LC_ALL=C order with the same counts. Empty kinds are still skipped, and a repo with no findings still prints none. count and kind are both declared local.
  • print_collapsed_target_detail. The ${kinds_line:+, } join prints the same list. Removing the kind and conf locals is safe because nothing in the function assigns them any more, so no global leaks. The test's sed '/^name()/,/^}/' extraction still works, since both functions only need F_*, sort and uniq.
  • find_merged_pr. It matches the two inline loops it replaces: return 0 stands in for break, and it resets pr_match and pr_any itself. It writes analyze_repo's locals (audit-fleet.sh:2562) through bash's dynamic scoping. No test extracts analyze_repo on its own.
  • ls-remote branch. Outcomes are the same in every case. The HIGH branch still requires status 0. LS_REMOTE_FAILURES still goes up exactly when the status is not 0. The dropped %%$'\t'* strip did nothing, because [[:space:]] already matches a tab.
  • fleet_unconfigured_note. It is now computed once, before the if chain. The else branch never used it, and FLEET_WT_UNCONFIGURED starts at 0 (audit-fleet.sh:910).
  • physical_path_key. The helper is exactly path_key "$(physical_path "$1")" (audit-fleet.sh:884-886).

Closing issue #14712, acceptance criteria:

  • Behavior unchanged: I found no change in behavior by reading the code. The test suite was not run (author-claimed and unverified). The existing extraction tests for repo_kind_counts_text and print_collapsed_target_detail cover two of the refactored functions.
  • Only the listed file plus a changelog fragment edited: met.
  • Under 400 changed lines: met.
  • Changelog fragment: met. The fragment has bump: patch, ### Changed, and the exact line the issue requires.
  • Only range 2 edited: met. Every edited hunk sits after line 2047, past the range start at 1854. physical_path_key, at line 884, is only called, not edited.
  • ci-status green: CI's job, not checked here.

No plugin manifest changed. The path-scoped rules that match plugins/*/skills/** (skill-bodies-state-current-rules.md, cost-claims.md) cover skill prose and cost claims, which this script change does not touch. I found no embedded instructions in the PR context.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 0e29b73

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-15205-0e29b736d93cd4481f1ad7b6c5ba8be2a7fa04ac, expires on 2026-12-10.

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 10, 2026
Merged via the queue into main with commit 6e7dfa6 Nov 10, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14712-42918185778-1 branch November 10, 2026 23:26
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 5, survived 2, timeout 0, no coverage 0, invalid 0, not run 0.
Covered-code score 71%; mutation score 71%.

File Killed Survived Timeout No coverage Invalid Not run
plugins/repo-fleet-hygiene/skills/audit/scripts/audit-fleet.sh 5 2 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/repo-fleet-hygiene/skills/audit/scripts/audit-fleet.sh:2084 SBR productive input-gap
plugins/repo-fleet-hygiene/skills/audit/scripts/audit-fleet.sh:2372 other productive no-assertion

The run's summary has the full report.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 6e7dfa6e788b2d4ce9a9e9ed33ee206e1d9a6cca; 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-fleet.sh repo-fleet-hygiene plugin code (part 2 of 2)

0 participants