Skip to content

refactor(repo-hygiene): simplify clean skill script helpers part 4 of 5 - #15191

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14719

Summary

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

Simplified the clean skill's shell helpers with no behavior change. clean-common.sh folds its return-0/return-1 ladders into single tests and bare returns, and the six identical manifest rejections now go through one private _clean_reject helper. run-marker.sh merges its two staleness branches into one condition, cleanup-paths.sh drops a single-use variable, remove-path.sh shortens count_preserve_classes, and test-helpers.sh sends every assert's PASS line through pass and every FAIL line through one private _fail_with. Every printed line, exit code, flag and public function name is unchanged. I reverted one attempted change: preflight.sh keeps its direct source of cleanup-paths.sh, because shellcheck needs it to see CLEAN_FIND_EXCLUDE_GIT (SC2154). git-noninteractive.sh is unchanged: the one candidate, ${base,,} in place of tr, lowercases non-ASCII characters differently, so it would not be a pure no-behavior-change edit.

Not verified

  • The repo-hygiene clean shell test suites (clean-caches.test.sh, clean-build.test.sh, remove-path.test.sh, destructive-guard.test.sh, git-tree-reset-batch.test.sh, cleanup-paths.test.sh and the others that source test-helpers.sh) were not executed: this lane's Bash runs only the named wrappers. Left…
  • Tidy pass 5: the ai-slop deterministic detector (detect.sh) and its fix-run guard scripts could not run in this lane (Bash limited to named wrappers), so only the rubric read ran on the one-line changelog fragment. No findings file was written (the fragment is untracked).
  • remove-path.sh count_preserve_classes now returns 1 when the path is not skill data (it always returned 0 before). Neither caller reads the status and the script does not use set -e, so nothing observable changes, but a future errexit would need to account for it.
  • ci-status green is a PR CI check, left to the PR's CI.
  • Changes were left uncommitted in the working tree, as the runner instructs, rather than committed.

Fix

  • plugins/repo-hygiene/skills/clean/scripts/lib/clean-common.sh: clean_skip_matches, clean_dir_has_protected_descendant and clean_path_has_pruned_segment use single conditional tests; clean_manifest_target_valid uses { check; return; } in place of && return 0 || return 1;…
  • plugins/repo-hygiene/skills/clean/scripts/lib/cleanup-paths.sh: cleanup_paths_config_file inlines its single-use variable
  • plugins/repo-hygiene/skills/clean/scripts/lib/run-marker.sh: run_marker_state_to merges the non-numeric and fresh-stamp cases into one condition (an unreadable or non-numeric marker still reads live)
  • plugins/repo-hygiene/skills/clean/scripts/lib/test-helpers.sh: the assert_* helpers print PASS through pass() and FAIL through a new private _fail_with, with byte-identical PASS/FAIL lines and counter updates
  • plugins/repo-hygiene/skills/clean/scripts/remove-path.sh: count_preserve_classes uses two check && count lines in place of two if blocks
  • .changes/repo-hygiene/work-resolve-issue-issue-14719-42884822897-1-75f00389.md: new patch fragment, '### Changed' with 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against b7a0fd9:

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

The run reports:

  • check-changelog-fragments: all 12 fragments valid
  • check-changed-skills: CHECK-SKILL clean PASS, 0 errors (4 warnings that were already there, about SKILL.md size and Gotchas)
  • check-affected: first run failed shellcheck SC2154 on preflight.sh after the cleanup-paths re-source was removed; reverted that change; final run 13 passed, 6 skipped over 6 changed files
  • fresh-context review subagent over the whole diff: no observable behavior difference; it confirmed no script sources these libs under set -e or an ERR trap, no test overrides pass/fail, and stderr/stdout text is byte-identical
  • tidy-diff (code-tidying:tidy-diff) over 33 hunk rows: passes 1-3 found nothing to change; pass 4 (docs-hygiene:write-for-humans) made no edit because the fragment text is set verbatim by the issue; pass 5 (ai-slop:audit) rubric read found no tells
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42884822897

Left out: the items under Not verified.

Related

#14719

Merge-Risk: unrated reason=no-rating

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

Copy link
Copy Markdown
Contributor

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

Security review: PR #15191 (refactor(repo-hygiene): simplify clean skill script helpers, part 4 of 5)

I found no security issues.

I read every hunk of all 6 changed files. None of them matches a trusted-path glob. None is a trust control, a merge hold, a plugin manifest or an instruction surface. The one deleted text is a code comment in clean_plan, and the comment that stays still describes the dedup logic.

The risk in this PR is the rm -rf gate in the clean skill. A refactor there could stop rejecting manifest entries that should be refused. I checked each rewritten guard against the base version, and each one behaves the same as before:

  • clean_manifest_target_valid: { clean_is_plain_dir "$abs"; return; } returns the status of the check, the same as && return 0 || return 1. A class or name that does not match still falls through to return 1, so it still fails closed.
  • clean_path_has_pruned_segment: the [[ "/$rel/" == *"/$seg/"* ]] glob test matches what the old case matched. .git/... entries are still rejected.
  • clean_path_has_reparse_ancestor: the walk now starts from $1 directly, and nothing else in the function used root (clean-common.sh#L720-L730). Symlinked ancestors are still rejected.
  • clean_dir_has_protected_descendant and clean_skip_matches: each condition chain gives the same result as the old if/return ladder.
  • _clean_reject: the entry and the reason go in as %s arguments with a fixed format string, so no format-string injection is possible. Each rejection still counts as failed, and continue is kept at every call site.
  • run-marker.sh: an unreadable or non-numeric stamp still reads as live, the conservative choice.
  • count_preserve_classes: it can now return 1. remove-path.sh runs under set -uo pipefail without -e (remove-path.sh#L45), and neither caller (L266, L314) reads the status.
  • test-helpers.sh and cleanup-paths.sh: these only touch test output and how the config path string is built. Neither has a security impact.

The diff also changes three lib/*.sh files from mode 100644 to 100755. That has no security impact: these files are sourced, not run.

Embedded text: the PR context has no directives aimed at the review lane.

I found no spend or cost impact.

critical-findings: 0

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude-review: 1 inline finding(s) on b7a0fd9d31f080e0810ace81f42381779e461c6b; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: PR #15191, simplify clean skill script helpers (part 4 of 5)

I read every hunk of all 6 changed files. I also read the unchanged code each change touches: pass/fail in test-helpers.sh, run_marker_state_to in full, clean_path_has_reparse_ancestor, the callers of count_preserve_classes in remove-path.sh, and the exec-bit check in scripts/check-affected.sh. I ran no tests or shell. The author's "Verification" results are their own claims and I have not checked them.

Behavior equivalence (checked by reading the code):

  • clean_skip_matches, clean_dir_has_protected_descendant and clean_path_has_pruned_segment: each folded single test gives the same truth value. The quoted $seg in [[ == *"/$seg/"* ]] still matches as a literal, as the case did.
  • clean_manifest_target_valid: { check; return; } now passes through the check's own status instead of a normalized 0/1. That is fine because the only caller tests it with if !.
  • _clean_reject: the stderr text is byte-identical, including not a $class target passed as a %s argument. CLEAN_FAILED_COUNT is still incremented on the same global.
  • run_marker_state_to: now is local. A non-numeric stamp short-circuits before the arithmetic, so it still reads live.
  • test-helpers.sh: pass increments CASE_NUM and prints the same PASS: [%d] %s. _fail_with reproduces each FAIL line exactly, with %q kept through printf -v.
  • count_preserve_classes: it now returns 1 when the path is not skill data. remove-path.sh runs set -uo pipefail without -e, and both call sites are statements inside while loops, so nothing reads that status.

Findings

  1. Inline, clean-common.sh:650: the edit cut the only explanation of why nested eligible paths are dropped (otherwise the byte total double-counts and apply hits a path already removed).
  2. Mode changes nobody mentions (whole-PR, no line can carry it): the diff switches three files from 100644 to 100755. They are clean-common.sh, cleanup-paths.sh and test-helpers.sh.
    • All three are libraries that other scripts source. Each starts with # shellcheck shell=bash and has no #! line.
    • The PR body says nothing about the mode change, and it is not part of the simplification. It looks like a side effect of the lane's working tree.
    • The repo's convention is that a file with no shebang that runs through bash needs no exec bit. See scripts/time-gates.sh:10. The exec-bit check in check-affected.sh:453-462 only requires 755 for #! files, so CI will not catch this.
    • With the bit set, running one of these files directly hands it to whatever shell the OS picks, instead of failing with "permission denied".
    • Fix: git update-index --chmod=-x on the three files to restore 100644.

Closing issue #14719 acceptance criteria

  • Behavior unchanged: met, by my reading above (finding 2 is a file-mode change, not a runtime behavior change). The PR adds no tests; the existing clean suites that source these helpers are what would catch a regression. The author says they did not run those suites, and neither did I.
  • Edits only listed files plus a fragment: met.
  • Within 400 lines and 15 files: met.
  • ci-status green: left to CI; I have not checked it.
  • Fragment body: met. The fragment has bump: patch, ### Changed, and "Internal simplification, no behavior change."

No embedded instructions found in the PR context. No prior findings from this lane, and the prior-findings file says this is not a blocking-only review. No plugin manifests changed. No hold class applies.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

pr-unblock / address-feedback finished round 1 of max 4 on b7a0fd9.

@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 c9562ac Nov 10, 2026
73 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14719-42884822897-1 branch November 10, 2026 23:28
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit c9562acdb03c2d5d4fd746f8367e5cb381e067fd; 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 clean repo-hygiene plugin code (4 of 5)

0 participants