feat(disk-hygiene): standing policy layers, leak-signature hints, OS auto-clean advisory - #229
Merged
Merged
Conversation
…auto-clean advisory Post-#160 follow-ups (#228): - baseline-policy.json ships the agent-leak hint families #160 named (.claude.json.tmp.*, temp_git_*, .pulumi-write-test-*), hint-only. - Standing policy files layer additively over the baseline when --policy is absent: ~/.claude/disk-hygiene.json then the consumer project's .claude/disk-hygiene.json via a new --project-dir scan argument (substituted from ${CLAUDE_PROJECT_DIR} in the skill body). Explicit --policy remains the invocation-specific override. Scan output now names its policy_sources. - Report-only os_autoclean advisory: when the audited zone overlaps the user temp directory, the scan names the OS mechanism that should own it (Windows Storage Sense via HKCU StoragePolicy, systemd-tmpfiles) and recommends enabling it instead of hand-cleaning. - Guard accepts the extended exact scan shape (optional --policy and --project-dir, no duplicates, fail-closed otherwise). - Documented why validate_plan demands native-GC eligibility evidence for permanently report-only managed candidates. Tests: 50 passed, 4 platform skips (Windows). ruff check clean; whole-file reformatting deliberately omitted (baseline is unformatted). Closes #228 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c66075738
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Preview/apply recovered baseline protected names via load_policy(None), which now also layers the user-global standing file — a malformed or later-edited ~/.claude/disk-hygiene.json could fail preview/apply of an existing snapshot. Extract baseline_policy()/baseline_protected_names() and use the baseline-only helper at every validation site, so approval never depends on config outside the snapshot. Regression test included. Addresses the P2 review finding on #229. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #228 — post-ship follow-ups for
disk-hygienefrom a verified gap analysis of the shipped source against issue #160,docs/PLUGIN-PHILOSOPHY.md, anddocs/MIGRATION-PLAYBOOK.md.Changes
.claude.json.tmp.*(failed atomic write),temp_git_*(agent Git scratch leaked outside a worktree),.pulumi-write-test-*(orphaned writability probe). These are the families feat: new plugin audit-artifacts — context-aware directory junk audit with tiered, gated cleanup #160 named as the plugin's reason to exist; all hint-only, discovery never authorizes removal. The README policy example no longer duplicates a baseline pattern.--policy, the engine layers~/.claude/disk-hygiene.json(user-global) then<project>/.claude/disk-hygiene.json(passed as the new--project-dirscan argument, substituted from${CLAUDE_PROJECT_DIR}in the skill body). Explicit--policystays the invocation-specific choice and replaces both standing layers, per PLUGIN-PHILOSOPHY's configuration-ownership seam. Safe by construction: overlay application is additive-only (add protections, add hints, disable discovery hints), so ambient config cannot widen the destructive surface. Scan output recordspolicy_sources; cross-layer duplicate hint IDs fail closed with the offending file named.os_autocleanadvisory (report-only) — extends the defer-to-the-owning-GC rule from products to the OS: when the audited zone overlaps the user temp directory, the scan reports the owning mechanism (Windows Storage Sense read fromHKCU\...\StoragePolicyincl. the cadence=0 "low disk only" trap,systemd-tmpfileson Linux) and recommends enabling it instead of hand-cleaning. Never blocks or authorizes anything.--policy/--project-dirpair set; duplicates, unknown flags, and dangling values still fail closed.validate_plan's native-GC eligibility gate: managed candidates are permanently report-only; the evidence exists so the report names a proven-runnable native command and ineligible managed state is never proposed.Deliberately deferred (tracked in #228 with triggers): reversible Recycle-Bin/XDG-trash disposal (TOCTOU vs descriptor-anchored unlink), RELOCATE disposition, Windows/macOS execution lanes.
Verification
test_hygiene.py: 50 passed, 4 platform skips (run on Windows). New coverage: standing-layer ordering and sources, explicit-policy replacement, cross-layer ID collision, non-weakening invariant, baseline leak signatures matching real leaked names, advisory zone logic, guard shape matrix.setUppatch.ruff checkclean; whole-fileruff formatdeliberately not applied (baseline files are unformatted — formatting churn kept out of this PR). markdownlint clean on changed docs.plugin.jsonbumped 0.1.0 → 0.2.0.Fresh-docs mandate: verified this session against skills (
${CLAUDE_PROJECT_DIR}substitution in skill body, v2.1.196+) and plugins reference (manifest schema, path substitutions), plus Configure Storage Sense and Policy CSP - Storage for cadence value semantics (0/1/7/30).🤖 Generated with Claude Code