From d2c9af99ff671c3ff785d4ae44a806e0c2ee551e Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Thu, 23 Jul 2026 04:17:50 -0400 Subject: [PATCH 1/4] fix(disk-hygiene): require immediate re-enumeration before container-wide manual deletions (#1108) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An approval for a container-wide operation (Clear-RecycleBin, emptying the Trash) was bound to a prose item list that could go stale between approval and execution: items landing in the container after approval would be destroyed under an approval that predated their existence — a live near-miss in the 0.6.4 consumer audit (F2). The manual-handoff lane now forbids container-wide operations unless the container is re-enumerated immediately before execution and matches the approved count and set exactly, aborting on any drift. Also documents that Recycle Bin / Trash reversibility is conditional (bin size caps, policy-disabled bins, non-NTFS/network volumes silently make removal permanent). disk-hygiene 0.6.4 -> 0.6.5. Co-Authored-By: Claude Fable 5 (200k context) --- plugins/disk-hygiene/.claude-plugin/plugin.json | 2 +- plugins/disk-hygiene/CHANGELOG.md | 15 +++++++++++++++ plugins/disk-hygiene/skills/clean/SKILL.md | 12 ++++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/plugins/disk-hygiene/.claude-plugin/plugin.json b/plugins/disk-hygiene/.claude-plugin/plugin.json index 1226c57a77e..832937e6772 100644 --- a/plugins/disk-hygiene/.claude-plugin/plugin.json +++ b/plugins/disk-hygiene/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json", "name": "disk-hygiene", - "version": "0.6.4", + "version": "0.6.5", "description": "Context-aware disk hygiene for arbitrary directory trees: inventories orphaned and temporary artifacts, classifies evidence into review tiers, and offers exact-path cleanup only after a fresh safety preview and explicit per-tier approval. The target is read-only by default; OS-managed paths, links and mount points, VCS-tracked content, changed entries, and live-handle uncertainty fail closed.", "author": { "name": "Melodic Software", diff --git a/plugins/disk-hygiene/CHANGELOG.md b/plugins/disk-hygiene/CHANGELOG.md index 142d5036ff9..3d33c8a7137 100644 --- a/plugins/disk-hygiene/CHANGELOG.md +++ b/plugins/disk-hygiene/CHANGELOG.md @@ -3,6 +3,21 @@ All notable changes to the `disk-hygiene` plugin are documented here. Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); this plugin uses semantic versioning. +## [0.6.5] + +### Fixed + +- **Manual-handoff lane: container-wide deletions now require immediate pre-execution + re-enumeration (#1108).** An approval for a container-wide operation (`Clear-RecycleBin`, + emptying the Trash) was bound to a prose item list that could go stale between approval and + execution — items landing in the container after approval would be destroyed under an approval + that predated their existence (a live near-miss in the 0.6.4 consumer audit, F2). The clean + skill's unsupported-platform handoff now forbids container-wide operations unless the container + is re-enumerated immediately before execution and matches the approved count and set exactly, + aborting on any drift — the engine lane's changed-since-scan discipline applied to the manual + lane. Also documents that Recycle Bin / Trash reversibility is conditional: bin size caps, + policy-disabled bins, and non-NTFS/network volumes silently make removal permanent. + ## [0.6.4] ### Fixed diff --git a/plugins/disk-hygiene/skills/clean/SKILL.md b/plugins/disk-hygiene/skills/clean/SKILL.md index f7e11384119..c650aed5455 100644 --- a/plugins/disk-hygiene/skills/clean/SKILL.md +++ b/plugins/disk-hygiene/skills/clean/SKILL.md @@ -223,8 +223,16 @@ handoff, not an engine plan: audit evidence; no reparse point/symlink; any owner process named in the evidence still absent; an exclusive-open probe succeeds (no live handle). 2. Prefer reversible removal (Windows Recycle Bin / macOS Trash) over permanent deletion, and say - which was used. -3. Skip and report any path that fails revalidation; never substitute a sibling or retry around a + which was used. That reversibility is conditional, not guaranteed: bin size caps, a + policy-disabled bin, and non-NTFS or network volumes silently make the same operation + permanent — disclose when a target's volume or policy turns "reversible" removal permanent. +3. Container-wide operations (`Clear-RecycleBin`, emptying the Trash, or any "delete everything in + this container" spelling) are forbidden unless the container is re-enumerated immediately + before execution and the result matches the approved count and set exactly; on any drift, abort + and re-ask. An approval bound to a prose list goes stale the moment new items land in the + container — the engine lane's changed-since-scan threat resurfacing in the manual lane, where + no snapshot token protects it. +4. Skip and report any path that fails revalidation; never substitute a sibling or retry around a lock. The PowerShell guard lane turns deletion spellings into a final human permission prompt (the same From 87f0b4306fd35a79d1607c90d2c295def5d7571f Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Thu, 23 Jul 2026 04:28:27 -0400 Subject: [PATCH 2/4] docs(disk-hygiene): hedge Recycle-Bin permanence cases as conditional, not absolute The specific silent-permanence causes (bin caps, disabled bin, non-NTFS or network volume) are standard Windows shell behavior but were stated as flat fact on producer report alone; "can silently make permanent" is the honest claim strength for what this session could confirm from Microsoft's SHFileOperation docs (FOF_ALLOWUNDO recycle-vs-permanent split). Co-Authored-By: Claude Fable 5 (200k context) --- plugins/disk-hygiene/CHANGELOG.md | 2 +- plugins/disk-hygiene/skills/clean/SKILL.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/disk-hygiene/CHANGELOG.md b/plugins/disk-hygiene/CHANGELOG.md index 3d33c8a7137..b18926c75a6 100644 --- a/plugins/disk-hygiene/CHANGELOG.md +++ b/plugins/disk-hygiene/CHANGELOG.md @@ -16,7 +16,7 @@ All notable changes to the `disk-hygiene` plugin are documented here. Format fol is re-enumerated immediately before execution and matches the approved count and set exactly, aborting on any drift — the engine lane's changed-since-scan discipline applied to the manual lane. Also documents that Recycle Bin / Trash reversibility is conditional: bin size caps, - policy-disabled bins, and non-NTFS/network volumes silently make removal permanent. + policy-disabled bins, or non-NTFS/network volumes can silently make removal permanent. ## [0.6.4] diff --git a/plugins/disk-hygiene/skills/clean/SKILL.md b/plugins/disk-hygiene/skills/clean/SKILL.md index c650aed5455..56de27203ed 100644 --- a/plugins/disk-hygiene/skills/clean/SKILL.md +++ b/plugins/disk-hygiene/skills/clean/SKILL.md @@ -224,8 +224,8 @@ handoff, not an engine plan: an exclusive-open probe succeeds (no live handle). 2. Prefer reversible removal (Windows Recycle Bin / macOS Trash) over permanent deletion, and say which was used. That reversibility is conditional, not guaranteed: bin size caps, a - policy-disabled bin, and non-NTFS or network volumes silently make the same operation - permanent — disclose when a target's volume or policy turns "reversible" removal permanent. + policy-disabled bin, or a non-NTFS/network volume can silently make the same operation + permanent — disclose when a target's volume or policy may turn "reversible" removal permanent. 3. Container-wide operations (`Clear-RecycleBin`, emptying the Trash, or any "delete everything in this container" spelling) are forbidden unless the container is re-enumerated immediately before execution and the result matches the approved count and set exactly; on any drift, abort From 5019f4653f71769eacef3666c1ee96985050299d Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Thu, 23 Jul 2026 04:41:16 -0400 Subject: [PATCH 3/4] fix(disk-hygiene): Clear-RecycleBin raises the guard's final prompt; cross-reference manual lane from engine gotcha MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review findings on PR #1118: (1) Codex P1 — step 3's re-enumeration rule blesses a container-wide op the PowerShell guard could not intercept (_POWERSHELL_MUTATION_WORDS lacked clear-recyclebin), so the stated final exact-list confirmation and audit-only denial never fired for it. Added to the mutation words with ask + audit-only-deny grid coverage; the broader F4 spellings stay in #1111. (2) Orchestrator AC3 note — the engine-side changed-since-scan gotcha now points back at the manual lane's re-enumeration rule, closing the cross-reference in both directions. Co-Authored-By: Claude Fable 5 (200k context) --- plugins/disk-hygiene/CHANGELOG.md | 6 ++++++ plugins/disk-hygiene/skills/clean/SKILL.md | 4 +++- .../disk-hygiene/skills/clean/scripts/destructive_guard.py | 2 +- plugins/disk-hygiene/skills/clean/scripts/test_hygiene.py | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/disk-hygiene/CHANGELOG.md b/plugins/disk-hygiene/CHANGELOG.md index b18926c75a6..00d9a639837 100644 --- a/plugins/disk-hygiene/CHANGELOG.md +++ b/plugins/disk-hygiene/CHANGELOG.md @@ -17,6 +17,12 @@ All notable changes to the `disk-hygiene` plugin are documented here. Format fol aborting on any drift — the engine lane's changed-since-scan discipline applied to the manual lane. Also documents that Recycle Bin / Trash reversibility is conditional: bin size caps, policy-disabled bins, or non-NTFS/network volumes can silently make removal permanent. + `Clear-RecycleBin` added to the PowerShell guard's mutation words (review finding on the same + PR: the newly blessed-with-re-enumeration container op must still raise the guard's final + ask prompt, and be denied in audit-only mode) — the broader F4 spelling additions + (`.Delete(`, robocopy purge flags) remain tracked in #1111. Engine-side changed-since-scan + gotcha now cross-references the manual lane's re-enumeration rule (closes #1108's third + acceptance criterion in both directions). ## [0.6.4] diff --git a/plugins/disk-hygiene/skills/clean/SKILL.md b/plugins/disk-hygiene/skills/clean/SKILL.md index 56de27203ed..28aa44fd7bd 100644 --- a/plugins/disk-hygiene/skills/clean/SKILL.md +++ b/plugins/disk-hygiene/skills/clean/SKILL.md @@ -257,7 +257,9 @@ sparse files, hard links, compression, and delayed allocation affect it. directory is reopened without following links, matched by device/inode/type, and proven empty after its captured children are removed. - A directory's contents can change after preview. Apply revalidates each captured entry and removes - bottom-up; it never follows a new link or recursively discovers new entries. + bottom-up; it never follows a new link or recursively discovers new entries. The manual-handoff + lane's container re-enumeration rule applies this same changed-since-scan discipline where no + snapshot token exists. - `allowed-tools` would pre-approve rather than restrict tools, so this destructive skill intentionally grants none. Consumer permission policy remains authoritative. - The Bash hook denies unknown commands rather than trying to enumerate deletion spellings. Supporting diff --git a/plugins/disk-hygiene/skills/clean/scripts/destructive_guard.py b/plugins/disk-hygiene/skills/clean/scripts/destructive_guard.py index 0183885710f..73c8d39559c 100755 --- a/plugins/disk-hygiene/skills/clean/scripts/destructive_guard.py +++ b/plugins/disk-hygiene/skills/clean/scripts/destructive_guard.py @@ -377,7 +377,7 @@ def is_exact_kill_switch_probe(command: str) -> bool: _POWERSHELL_MUTATION_WORDS = re.compile( r"(?i)(? None: "Remove-Item -Recurse -Force C:/tmp/example", "rm C:/tmp/example", "del C:/tmp/example", + "Clear-RecycleBin -Force", "[IO.File]::Delete('C:/tmp/example')", "[Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile('x', 'OnlyErrorDialogs', 'SendToRecycleBin')", ): @@ -2444,6 +2445,7 @@ def test_powershell_deletion_spellings_denied_in_audit_only_mode(self) -> None: "Remove-Item -Recurse -Force C:/tmp/example", "rm C:/tmp/example", "del C:/tmp/example", + "Clear-RecycleBin -Force", "[IO.File]::Delete('C:/tmp/example')", "[Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile('x', 'OnlyErrorDialogs', 'SendToRecycleBin')", ): From 039ac8bdb9a513e48e3525fe8a98dd14dc68048a Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Thu, 23 Jul 2026 05:06:05 -0400 Subject: [PATCH 4/4] fix(disk-hygiene): forbid container-wide manual deletions outright; match module-qualified deletion cmdlets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Second review round on PR #1118: (1) re-enumeration cannot close the approval-to-execution window against a live container (items arriving while the human answers the prompt die under an approval that never saw them) — the manual lane now forbids container-wide deletion commands and satisfies "empty the container" by per-item deletion under the lane's per-path revalidation, so unenumerated arrivals survive. (2) Module-qualified invocations (Microsoft.PowerShell.Management\Clear-RecycleBin) evaded the mutation words' lookbehind; a companion pattern now matches module-qualified Remove-Item / Clear-Content / Clear-RecycleBin, with ask + audit-only-deny grid coverage. Suite 112 OK. Co-Authored-By: Claude Fable 5 (200k context) --- plugins/disk-hygiene/CHANGELOG.md | 16 +++++++++------- plugins/disk-hygiene/skills/clean/SKILL.md | 13 +++++++------ .../skills/clean/scripts/destructive_guard.py | 13 +++++++++++++ .../skills/clean/scripts/test_hygiene.py | 3 +++ 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/plugins/disk-hygiene/CHANGELOG.md b/plugins/disk-hygiene/CHANGELOG.md index 00d9a639837..27dba9d4feb 100644 --- a/plugins/disk-hygiene/CHANGELOG.md +++ b/plugins/disk-hygiene/CHANGELOG.md @@ -12,14 +12,16 @@ All notable changes to the `disk-hygiene` plugin are documented here. Format fol emptying the Trash) was bound to a prose item list that could go stale between approval and execution — items landing in the container after approval would be destroyed under an approval that predated their existence (a live near-miss in the 0.6.4 consumer audit, F2). The clean - skill's unsupported-platform handoff now forbids container-wide operations unless the container - is re-enumerated immediately before execution and matches the approved count and set exactly, - aborting on any drift — the engine lane's changed-since-scan discipline applied to the manual - lane. Also documents that Recycle Bin / Trash reversibility is conditional: bin size caps, + skill's unsupported-platform handoff now forbids container-wide deletion commands outright — + review showed even immediate re-enumeration leaves an approval-to-execution window against a + live container — and satisfies "empty the container" by per-item deletion under the lane's + per-path revalidation, so unenumerated arrivals survive. Also documents that Recycle Bin / Trash reversibility is conditional: bin size caps, policy-disabled bins, or non-NTFS/network volumes can silently make removal permanent. - `Clear-RecycleBin` added to the PowerShell guard's mutation words (review finding on the same - PR: the newly blessed-with-re-enumeration container op must still raise the guard's final - ask prompt, and be denied in audit-only mode) — the broader F4 spelling additions + `Clear-RecycleBin` added to the PowerShell guard's mutation words, and module-qualified + deletion cmdlets (`Module\Remove-Item`, `Module\Clear-Content`, `Module\Clear-RecycleBin`) now + match a companion pattern the word boundary's lookbehind previously rejected (review findings + on the same PR; the guard word is defense-in-depth for attempted container ops, which the + manual lane now forbids) — the broader F4 spelling additions (`.Delete(`, robocopy purge flags) remain tracked in #1111. Engine-side changed-since-scan gotcha now cross-references the manual lane's re-enumeration rule (closes #1108's third acceptance criterion in both directions). diff --git a/plugins/disk-hygiene/skills/clean/SKILL.md b/plugins/disk-hygiene/skills/clean/SKILL.md index 28aa44fd7bd..985cfacf5b1 100644 --- a/plugins/disk-hygiene/skills/clean/SKILL.md +++ b/plugins/disk-hygiene/skills/clean/SKILL.md @@ -226,12 +226,13 @@ handoff, not an engine plan: which was used. That reversibility is conditional, not guaranteed: bin size caps, a policy-disabled bin, or a non-NTFS/network volume can silently make the same operation permanent — disclose when a target's volume or policy may turn "reversible" removal permanent. -3. Container-wide operations (`Clear-RecycleBin`, emptying the Trash, or any "delete everything in - this container" spelling) are forbidden unless the container is re-enumerated immediately - before execution and the result matches the approved count and set exactly; on any drift, abort - and re-ask. An approval bound to a prose list goes stale the moment new items land in the - container — the engine lane's changed-since-scan threat resurfacing in the manual lane, where - no snapshot token protects it. +3. Container-wide deletion commands (`Clear-RecycleBin`, emptying the Trash, or any "delete + everything in this container" spelling) are forbidden in the manual lane — they execute + against the live container, so items arriving between approval (or even re-enumeration) and + execution die under an approval that never saw them. Satisfy "empty the container" by + enumerating the container and deleting per item under steps 1, 2, and 4; items that arrive + after enumeration are simply not deleted. This is the engine lane's changed-since-scan threat + in the manual lane, where no snapshot token protects execution. 4. Skip and report any path that fails revalidation; never substitute a sibling or retry around a lock. diff --git a/plugins/disk-hygiene/skills/clean/scripts/destructive_guard.py b/plugins/disk-hygiene/skills/clean/scripts/destructive_guard.py index 73c8d39559c..0528cc2a0f1 100755 --- a/plugins/disk-hygiene/skills/clean/scripts/destructive_guard.py +++ b/plugins/disk-hygiene/skills/clean/scripts/destructive_guard.py @@ -382,6 +382,12 @@ def is_exact_kill_switch_probe(command: str) -> bool: r")(?![\w-])" ) _POWERSHELL_DOTNET_DELETE = re.compile(r"(?i)::\s*delete") +# Module-qualified cmdlet invocations (Module\Cmdlet) put a backslash before the +# cmdlet name, which the word pattern's lookbehind rejects; cover the deletion +# cmdlets explicitly (aliases like rm/del cannot be module-qualified). +_POWERSHELL_QUALIFIED_DELETE = re.compile( + r"(?i)[a-z][\w.]*\\(remove-item|clear-content|clear-recyclebin)(?![\w-])" +) def powershell_decision(command: str, enabled: bool) -> tuple[str, str] | None: @@ -413,6 +419,13 @@ def powershell_decision(command: str, enabled: bool) -> tuple[str, str] | None: return _powershell_mutation_verdict( enabled, "disk-hygiene flagged a .NET Delete call." ) + qualified = _POWERSHELL_QUALIFIED_DELETE.search(command) + if qualified: + return _powershell_mutation_verdict( + enabled, + "disk-hygiene flagged the module-qualified deletion spelling " + f'"{qualified.group(0)}".', + ) return None diff --git a/plugins/disk-hygiene/skills/clean/scripts/test_hygiene.py b/plugins/disk-hygiene/skills/clean/scripts/test_hygiene.py index 3acca3a4b75..e334ac9fb0a 100755 --- a/plugins/disk-hygiene/skills/clean/scripts/test_hygiene.py +++ b/plugins/disk-hygiene/skills/clean/scripts/test_hygiene.py @@ -2419,6 +2419,8 @@ def test_powershell_deletion_spellings_force_final_prompt(self) -> None: "rm C:/tmp/example", "del C:/tmp/example", "Clear-RecycleBin -Force", + "Microsoft.PowerShell.Management\\Clear-RecycleBin -Force", + "Microsoft.PowerShell.Management\\Remove-Item -Recurse C:/tmp/example", "[IO.File]::Delete('C:/tmp/example')", "[Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile('x', 'OnlyErrorDialogs', 'SendToRecycleBin')", ): @@ -2446,6 +2448,7 @@ def test_powershell_deletion_spellings_denied_in_audit_only_mode(self) -> None: "rm C:/tmp/example", "del C:/tmp/example", "Clear-RecycleBin -Force", + "Microsoft.PowerShell.Management\\Clear-RecycleBin -Force", "[IO.File]::Delete('C:/tmp/example')", "[Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile('x', 'OnlyErrorDialogs', 'SendToRecycleBin')", ):