Skip to content

Plans refuse to trash your own folders - #20

Merged
Chartres merged 5 commits into
mainfrom
safety/plan-refuses-only-yours
Nov 3, 2026
Merged

Chartres merged 5 commits into
mainfrom
safety/plan-refuses-only-yours

Conversation

@Chartres

@Chartres Chartres commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Pavol's choice on 2026-11-03 (decision card mac-dir-stat.o0, relayed by the orchestrating session): "Refuse such plans in validation." This was proposal 1 in the 30 Oct hand-back.

What changed

  • cleanup::only_yours_reason(path, home) refuses any trash path that is, is inside, or holds one of the inventory's own folders: Documents, Desktop, Pictures, Movies, Music, Mail and Messages under home, plus any *.photoslibrary. The match is case-insensitive, as on APFS. The error names the folder, e.g. "~/Documents/Taxes is inside ~/Documents, your own Documents folder. MacDirStat never offers your own files for deletion; …".
  • plan::validate runs this check right after the system-path check. It also checks the raw path when the path can't be resolved, so the refusal names the folder either way. A plan with any refused op is valid: false, and approving it returns 409. The existing rule already makes one bad op refuse the whole plan.
  • cleanup::PLACES is now one shared list for the Cleanup window and the plan check.
  • MCP propose_plan description, README, CHANGELOG and the SIGNATURE.md decision log are updated.

Reversible calls (default taken)

  • Trash ops only. "Move to External Disk" of Movies or Pictures is still allowed: that's the relocate feature's purpose, and it copies and verifies before the original goes. Default: trash only.
  • Stored as an invalid plan, not a 4xx on propose. This matches how protected system paths are already handled: the model sees the plan and the reason. Default: invalid plan.
  • Folders that hold one are refused too (e.g. ~/Library holds Mail; it was already protected). Default: refuse.

Tests (written first)

  • plan::tests::validate_refuses_your_own_folders_and_their_contents: with a temp home, ~/Documents and ~/Documents/taxes are refused with a message naming ~/Documents. A plan mixing node_modules with a file in Documents is invalid and can't be approved.
  • inventory_tests::a_plan_may_not_trash_your_own_folders_or_anything_in_them: covers subfolders, case, Mail, Photos libraries, holders, and look-alikes that stay allowed (~/DocumentsOld, another user's Documents, node_modules, Caches).
  • server_tests::mcp_plan_touching_your_own_folders_is_refused: the journey over MCP. propose_plan with ~/Documents and ~/Documents/Taxes 2025 returns invalid with the folder named, approve gets 409, and nothing runs.
  • Linux: everything new passes; the same 6 macOS-only failures as main. macOS CI is the gate.

No release tag (v0.7.0 is Pavol's step).


Generated by Claude Code

Plan validation checks each trash against the inventory's only-yours
folders (Documents, Desktop, Pictures, Movies, Music, Mail, Messages under
home, and any Photos library). A path that is one, sits inside one, or
holds one gets an error naming the folder, so the plan can't be approved.
Before, only the human approval stopped a model proposing ~/Documents.

PLACES moves to a shared constant so the Cleanup window and plan checks use
one list. validate() keeps its signature; validate_with() takes the home
folder for tests.

Pavol chose "Refuse such plans in validation" on 2026-11-03.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017mKbacqC4bPDSYsaK9dVdu
…Documents) may still go

Matches the inventory, which lists it on the rebuildable side.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017mKbacqC4bPDSYsaK9dVdu
- Links: check the path as asked and as resolved, and each folder at its
  real location, so ~/Movies moved to a disk and left as a link stays
  protected.
- A folder that holds a Photos library is refused (bounded search, three
  levels, no links followed).
- The build-output exemption covers project build rules only; caches,
  logs, .gradle and .m2 inside your folders stay refused.
- Docs say what the code does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017mKbacqC4bPDSYsaK9dVdu
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017mKbacqC4bPDSYsaK9dVdu
@Chartres
Chartres merged commit 986c54e into main Nov 3, 2026
2 checks passed
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.

2 participants