Skip to content

refactor(disk-hygiene): simplify hygiene.py range 3 of 4 - #15308

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14756

Summary

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

Simplified the functions that start in range 3 of 4 of plugins/disk-hygiene/skills/clean/scripts/hygiene.py (6486 lines when this part started, so lines 3244-4865: inline_plan through purge_directory_contents), with no behavior change. The duplicate lstat-failure verdict dicts in verify_emptied_container and handoff_verify, and the duplicate failed VCS-evidence dicts in handoff_verify, now each come from one small helper (lstat_failure_verdict, failed_vcs_evidence). Other changes: the git SHA regex is compiled once (GIT_SHA_RE); snapshot_digest and approval_token share canonical_sha256; preview and handoff_verify share snapshot_truncated_paths; the three identical dirfd checks in execution_blockers are one condition; same_removal_identity now calls same_identity, which has the same body. Every existing name, output, dict key order and exception path is kept. preview still reads the baseline policy before resolving the target, so the first error raised stays the same. The file is 22 lines shorter (73 added, 95 removed).

Not verified

  • The disk-hygiene Python test suite (test_hygiene.py) was not run: this lane allows no interpreter, so it is left to the PR's CI
  • tidy: ran every pass (simplify, comments, residue, write-for-humans, ai-slop) with no further edits. ai-slop's deterministic detect.sh layer could not run because the lane allows only the named wrappers; its rubric layer found no tells in the one-line fragment. Residue proposals not applied:…
  • Untracked runner dotfiles in the checkout root (.bashrc, .bash_profile, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) were not created by this run and are not part of the change; they were left out of the tidy measurement

Fix

  • plugins/disk-hygiene/skills/clean/scripts/hygiene.py: behavior-preserving simplification of the range-3 functions; adds the helpers GIT_SHA_RE, canonical_sha256, snapshot_truncated_paths, lstat_failure_verdict and failed_vcs_evidence in place of duplicated code
  • .changes/disk-hygiene/work-resolve-issue-issue-14756-42987341255-1-511f8d16.md: patch fragment, '### Changed' with 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against 31416ed:

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

The run reports:

  • check-changelog-fragments: all 52 fragments valid (run before and after tidy)
  • check-changed-skills: CHECK-SKILL clean PASS, 0 errors, 3 warnings about existing SKILL.md size (run before and after tidy)
  • check-affected: 13 passed, 6 skipped over 2 changed files (run before and after tidy)
  • fresh-context review subagent read the whole diff hunk by hunk against the original, including exception-subclass order, short-circuit order, dict key order, new-name collisions and test monkeypatch points in test_hygiene.py: verdict CLEAN
  • range measurement: hygiene.py had 6486 lines at start, range 3 = lines 3244-4865; every edited function starts in that range (the new helpers sit beside their callers in that range)
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42987341255

Left out: the items under Not verified.

Related

#14756

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

Security review: PR #15308, refactor(disk-hygiene): simplify hygiene.py range 3 of 4

I found no security issues. I read every hunk of both changed files. Neither matches a trusted path. No manifest, workflow, trust control or instruction surface is touched.

hygiene.py decides what gets deleted, so I checked each change against the code it replaces:

  • same_removal_identity now calls same_identity. The two bodies are the same: an lstat that returns False on OSError, then same_stat_identity (hygiene.py#L3422-L3427). The changed-or-link check before each removal still fails closed (L5062, L5857).
  • lstat_failure_verdict tests FileNotFoundError first, then PermissionError, then any other OSError. That is the order the old except chain used. Missing still means gone, and any other error still means contested.
  • failed_vcs_evidence in handoff_verify. The two failure results keep the same status, gates, blockers and error key. contested.update(...) still runs in both branches, so a missing or failed evidence check still adds its blocker.
  • execution_blockers. The three dirfd and O_NOFOLLOW checks are now one OR condition. It returns the same blocker whenever any one of them fails.
  • GIT_SHA_RE, canonical_sha256, snapshot_truncated_paths. The regex, the JSON canonicalization and the [:24] cut of the approval token are unchanged, so tokens and digests are the same as before.
  • Changelog fragment. Prose only.

The PR text contains no embedded instructions aimed at this lane.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: no findings

This PR is a refactor of plugins/disk-hygiene/skills/clean/scripts/hygiene.py that should not change behavior, plus a changelog fragment. I read every hunk of both changed files and checked each simplification against the code it replaces at head.

Equivalence checks (read from the code, not run):

  • same_removal_identity → same_identity: the two bodies were identical (lstat, False on OSError, then same_stat_identity). The test at test_hygiene.py:8645 that wraps same_stat_identity still sees the call through same_identity.
  • lstat_failure_verdict: FileNotFoundError and PermissionError are separate OSError subclasses. The mapping is the same as before (gone/no-longer-present, contested/needs-elevation, contested/filesystem-state-unverified), and so are the dict key order and the continue in handoff_verify.
  • failed_vcs_evidence: the key order (status, gates, blockers, then error when given) is unchanged, and each call still builds a new gates dict. The nested if candidate_evidence: if evidence_inventory_eligible: branches are equivalent to the old if candidate_evidence and eligible / elif candidate_evidence branches, and contested.update(...) still runs on both paths.
  • GIT_SHA_RE.fullmatch is equivalent to re.fullmatch with the same pattern. canonical_sha256 produces the same serialization and digest for snapshot_digest and approval_token (the latter still truncated to 24 characters). The combined execution_blockers condition keeps the same short-circuit order and return value. The inlined payload return and the inlined git_marker variable are trivial.

Closing issue #14756 acceptance criteria:

  • Behavior unchanged: met by the reading above. The existing test_hygiene.py suite covers these paths. I could not run it here; the PR leaves it to CI.
  • Only the listed file and a fragment are edited: met.
  • At most 400 changed lines: met (73 added, 95 removed by the PR's own count, which matches the diff).
  • Fragment is bump: patch, ### Changed, "Internal simplification, no behavior change.": met.
  • Only functions starting in range 3 (lines 3244–4865) are changed: met. Every edited function and new helper sits between same_removal_identity (L3484) and handoff_verify.
  • ci-status green: not checkable from this lane.

The test-suite run and the fresh-context review verdict in the PR body are the author's claims; I did not verify them. No plugin manifest changed, no settled threads or prior findings apply, and 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 31416ed4c8158730379cf7660ecef61c1a4ad3c6, the head its arming checks judged.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 31416ed

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-15308-31416ed4c8158730379cf7660ecef61c1a4ad3c6, expires on 2026-12-11.

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 11, 2026
Merged via the queue into main with commit 577fcde Nov 11, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14756-42987341255-1 branch November 11, 2026 08:58
@github-actions

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/disk-hygiene/skills/clean/scripts/hygiene.py 3 4 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/disk-hygiene/skills/clean/scripts/hygiene.py:3486 SBR productive no-assertion
plugins/disk-hygiene/skills/clean/scripts/hygiene.py:3705 ROR productive input-gap
plugins/disk-hygiene/skills/clean/scripts/hygiene.py:4019 LCR productive input-gap
plugins/disk-hygiene/skills/clean/scripts/hygiene.py:4531 SBR 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 577fcdedc33a88a8e6aba760f3b4050d7957c283; 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 disk-hygiene engine script (part 3 of 4)

0 participants