Skip to content

feat(disk-hygiene): standing policy layers, leak-signature hints, OS auto-clean advisory - #229

Merged
kyle-sexton merged 2 commits into
mainfrom
feat/disk-hygiene-issue-228
Jul 16, 2026
Merged

feat(disk-hygiene): standing policy layers, leak-signature hints, OS auto-clean advisory#229
kyle-sexton merged 2 commits into
mainfrom
feat/disk-hygiene-issue-228

Conversation

@kyle-sexton

Copy link
Copy Markdown
Contributor

Closes #228 — post-ship follow-ups for disk-hygiene from a verified gap analysis of the shipped source against issue #160, docs/PLUGIN-PHILOSOPHY.md, and docs/MIGRATION-PLAYBOOK.md.

Changes

  1. Leak-signature hints shipped in the baseline.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.
  2. Standing policy auto-discovery — without --policy, the engine layers ~/.claude/disk-hygiene.json (user-global) then <project>/.claude/disk-hygiene.json (passed as the new --project-dir scan argument, substituted from ${CLAUDE_PROJECT_DIR} in the skill body). Explicit --policy stays 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 records policy_sources; cross-layer duplicate hint IDs fail closed with the offending file named.
  3. os_autoclean advisory (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 from HKCU\...\StoragePolicy incl. the cadence=0 "low disk only" trap, systemd-tmpfiles on Linux) and recommends enabling it instead of hand-cleaning. Never blocks or authorizes anything.
  4. Guard — exact scan shape extended for the optional --policy / --project-dir pair set; duplicates, unknown flags, and dangling values still fail closed.
  5. Intent comment on 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.
  • Existing tests isolated from developer machines' real standing policy files via a setUp patch.
  • ruff check clean; whole-file ruff format deliberately not applied (baseline files are unformatted — formatting churn kept out of this PR). markdownlint clean on changed docs.
  • Two new evals (standing-policy layering, OS-mechanism handoff).
  • plugin.json bumped 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

…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>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread plugins/disk-hygiene/skills/clean/scripts/hygiene.py
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>
@kyle-sexton
kyle-sexton merged commit 6e4da2c into main Jul 16, 2026
13 checks passed
@kyle-sexton
kyle-sexton deleted the feat/disk-hygiene-issue-228 branch July 16, 2026 23:29
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.

feat(disk-hygiene): post-#160 follow-ups — leak-signature hints, standing policy discovery, OS auto-clean awareness

1 participant