Skip to content

refactor(disk-hygiene): simplify destructive_guard.py part 2 of 2 - #15208

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14451

Summary

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

Simplified six spots in functions that start in the second half of destructive_guard.py (from line 1834 of 3666) without changing behavior. The changes: a try/except/else in place of a None sentinel in _nt_trusted_readonly_bin_roots, a merged nested if in _path_under_trusted_readonly_bin, removal of a check in _absolute_bracket_test_words that _literal_shell_words already performs, one branch for the preview and mutating kinds in _record_run_step (which now normalizes ends_with where it is set), and nested conditions in _decide's PowerShell and mutating-engine branches instead of repeated tests. No names, outputs, exit codes or messages changed, and no code moved between files.

Not verified

  • plugins/disk-hygiene/skills/clean/scripts/test_hygiene.py suite not executed here (the lane allows no interpreter); left to the PR's CI
  • tidy: code passes 1-3 dropped every destructive_guard.py row because tidy-diff's GLOBAL HARD list excludes a script wired as a hook command; markdown passes ran on the fragment with no edits; ai-slop detect.sh and digest-guard.sh could not run under the lane's Bash allowlist, so pass 5 was a manual…
  • verify: build/test step not run locally (no interpreter allowed); the Python suites run in the PR's CI
  • ci-status green is a PR CI check, left to the PR's CI
  • cant-fail-scan not applicable: it audits test files and this change touches none

Fix

  • plugins/disk-hygiene/skills/clean/scripts/destructive_guard.py: behavior-preserving simplifications in _nt_trusted_readonly_bin_roots, _path_under_trusted_readonly_bin, _absolute_bracket_test_words, _record_run_step and _decide (all start in range 2 of 2)
  • .changes/disk-hygiene/work-resolve-issue-issue-14451-42918984228-1-e3a3673e.md: patch fragment, '### Changed' with 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against 7796bd1:

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

The run reports:

  • check-changelog-fragments: all 29 fragments valid (run before and after tidy)
  • check-changed-skills: CHECK-SKILL clean PASS, 0 errors, 3 warnings that were there before this change (description length, body length, token size)
  • check-affected: 13 passed, 6 skipped over 2 changed files (run before and after tidy)
  • fresh-context review subagent: all six hunks verdict equivalent (exception scope, short-circuit order, lock and mock order in the _record_run_step race test, redundant-check subsumption by _literal_shell_words lines 230-234); no changed line over 88 chars, no unused names
  • diff size: 2 files, about 45 changed lines, within the 400-line and 15-file limits
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42918984228

Left out: the items under Not verified.

Related

#14451

Merge-Risk: max=HIGH demote=true head=7796bd1df2afe151d1363dc26101e621200f23ec 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-review reviewed 7796bd1df2afe151d1363dc26101e621200f23ec: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

I read every hunk of both changed files and checked each one against the code it touches at head 7796bd1d. All six simplifications in destructive_guard.py behave the same as before:

  • _nt_trusted_readonly_bin_roots: the try/except/else replaces the None sentinel. Path.resolve() never returns None, so the else branch runs exactly when the old is not None branch did.
  • _path_under_trusted_readonly_bin: the nested if is merged into one condition. The short-circuit order is unchanged.
  • _absolute_bracket_test_words: the removed _SHELL_EXPANSION_OR_OPERATOR_CHARS.intersection(_without_quoted_braces(interior)) check is repeated exactly by _literal_shell_words at destructive_guard.py#L230-L234, on the same _without_quoted_braces input. For an empty interior, both versions return (head, []) because an empty string holds no flagged characters.
  • _record_run_step: preview still selects _preview_plan_file and the mutating kinds still select --report. Path normalization now happens only in the branch that sets a non-None ends_with. The other branches set ends_with = None (handoff-verify) or return early, so they were never normalized before either.
  • _decide PowerShell branch: if verdict and released: return …; if verdict: became if verdict: if released: return …. Same result.
  • _decide mutating-engine branch: the enabled test moved inside the command_kind in _MUTATING_ENGINE_SUBCOMMANDS block. Same result.

Closing issue #14451, acceptance criteria:

  • Behavior unchanged: met, by the reasoning above.
  • Edits only the listed file plus a changelog fragment: met.
  • Size within limits: met (about 45 changed lines, 2 files).
  • Fragment is bump: patch with ### Changed and "Internal simplification, no behavior change.": met.
  • Only functions that start in range 2 of 2 are changed: met. The edited functions start from about line 1860 onward, past the stated split at line 1834.
  • ci-status green: depends on CI, which I could not see.

These are equivalence-preserving refactors, so the existing guard tests in test_hygiene.py that exercise these functions are what would catch a regression. I did not run them, and the test-suite result the PR describes is the author's claim, unverified by me.

No plugin manifest changed, so there are no manifest lines. There are no prior findings, no settled threads, and no embedded instructions in the PR context. Security scope is left to the security lane.

@github-actions

Copy link
Copy Markdown
Contributor

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

Security review: PR #15208 (refactor of disk-hygiene destructive_guard.py, part 2 of 2)

No security issues found. I read every hunk of both changed files. Neither file matches a trusted path. destructive_guard.py is a PreToolUse guard hook, though, so I checked each hunk against the base code to make sure no guard behavior changes:

  • _nt_trusted_readonly_bin_roots (L1884-L1893): the try/except OSError: pass / else: form behaves the same as the old None sentinel. A SystemRoot that cannot be resolved still adds no trusted directories.
  • _path_under_trusted_readonly_bin (L1914-L1917): the nested if became one condition joined with and. The anchored-prefix check and the fallback to the POSIX prefix list are unchanged.
  • _absolute_bracket_test_words: the removed check, _SHELL_EXPANSION_OR_OPERATOR_CHARS.intersection(_without_quoted_braces(interior)), is the same test _literal_shell_words runs first, on the same string and the same character set (L230-L234). An empty interior still returns (head, []) before that call, which the removed check also allowed. So a bracket test with shell metacharacters is still rejected.
  • _record_run_step (L2683-L2702): preview is still tested first, so it reads its plan file as before. abspath/expanduser now runs only in the branch that sets a non-None ends_with; before, it ran wherever ends_with was not None, which is the same set of cases. It still runs inside the same try, so a failure still leaves the marker alone and the verdict unchanged. The order of the lock and the manual-lane check is unchanged.
  • _decide PowerShell branch (L3407-L3417) and mutating-engine branch (L3477-L3501): the nested conditions give the same results as before. _belt_released is still checked only when there is a verdict. A mutating command still gets ask when the kill switch allows it and deny when it doesn't.
  • .changes/...md: a changelog fragment only, with no security relevance.

No standing instruction was deleted or softened, and no plugin manifest changed. No trust control, merge hold, token scope or kill-switch read is touched; the guard's kill-switch deny path is unchanged. Prior findings: none (0 earlier heads reviewed; not blocking-only). The PR context contains no embedded directives.

critical-findings: 0

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head 7796bd1df2afe151d1363dc26101e621200f23ec. No person needs to act: a lane clears this reason, and the next scheduled run judges it again.

pr-merge's gate refuses its verifier verdict (verify:missing)

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 7796bd1

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-15208-7796bd1df2afe151d1363dc26101e621200f23ec, 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 80594fb Nov 11, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14451-42918984228-1 branch November 11, 2026 00:02
@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/disk-hygiene/skills/clean/scripts/destructive_guard.py 5 2 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/disk-hygiene/skills/clean/scripts/destructive_guard.py:1998 SBR productive input-gap
plugins/disk-hygiene/skills/clean/scripts/destructive_guard.py:2691 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 80594fba80005d0ead555773603b839602e4f314; 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 destructive_guard.py disk-hygiene plugin code (part 2 of 2)

0 participants