Skip to content

disk-hygiene: batch handoff-apply per tier with a fail-closed Windows Recycle Bin backend #9764

Description

@kyle-sexton

Refs #4224. Slice 1 of 2: build option A, the batched fail-closed Windows verify-and-recycle (owner decision 2026-09-29; requirements from the PR #5128 review, listed in the 2026-09-29 comment). Option C (inline repeatable --path, the self-describing ask reason, the allow-rule gotcha) already shipped in #5528.

Problem

On Windows the manual handoff lane still costs about one permission prompt and two to three tool calls per deleted path: handoff-verify, then a model-composed PowerShell Recycle Bin call that the guard answers with a hook ask. The engine's handoff-apply already verifies and deletes in one process, but it takes one --path and runs on Linux only (plugins/disk-hygiene/lib/engine_grammar.py, the handoff-apply subcommand; execution_blockers() in the clean skill's engine script blocks other platforms).

Fix

Extend handoff-apply (plugin disk-hygiene):

  • Accept a repeatable --path and a required --tier. Refuse the whole call, deleting nothing, when any path's tier in the snapshot is not --tier (the tier must not be a label only).
  • For each path, inside the approved process and immediately before its removal, re-run the handoff-verify checks (existence, type, protections). A path whose verdict is not clear is skipped and reported. A declined or interrupted call deletes nothing.
  • On Windows, recycle through IFileOperation (or the shell API with undo enabled). Fail closed when the path's volume has no Recycle Bin, or when the API would delete permanently: refuse, never fall back to a permanent delete. The report's permanent_delete_used reflects what happened, not a hardcoded False.
  • Keep the guard's classification: handoff-apply is already a hook ask (destructive_guard.py, _HANDOFF_APPLY_ASK_REASON). Do not change _decide or any ask/allow outcome. Do extend the ask reason so the prompt lists the tier, the count, and every path.
  • Update skills/clean/SKILL.md and skills/clean/reference/unsupported-platform-handoff.md so the Windows lane runs one handoff-apply per tier, and drop the separate AskUserQuestion approval for a tier whose hook ask already lists the paths.

Put the Windows recycle call behind a small backend function so the Linux suite can test every refusal with a stub.

Done when

  • A test proves a batch whose volume has no Recycle Bin refuses and deletes nothing: python3 -m pytest plugins/disk-hygiene/skills/clean/scripts/test_hygiene.py -k recycle exits 0
  • A test proves a path whose snapshot tier differs from --tier refuses the whole batch: python3 -m pytest plugins/disk-hygiene/skills/clean/scripts/test_hygiene.py -k tier exits 0
  • A test proves a path that changed after approval is skipped and reported, not deleted
  • git diff origin/main...HEAD -- plugins/disk-hygiene/skills/clean/scripts/destructive_guard.py changes no line inside _decide
  • A guard test asserts the tier, the count and each path appear in permissionDecisionReason for a batched handoff-apply
  • pr-test-windows and ci-status are green on the PR head

Activity

  1. added
    status: ready
    on Oct 24, 2026
  2. added
    needs-triage
    on Oct 24, 2026
  3. github-actions commented on Oct 24, 2026

    @github-actions
    Contributor

    Proposed work class: work-class: scoped
    Basis: automated intake triage; the lanes App applied this class.

    Size: Medium
    Complexity: Medium
    Uncertainty: Known
    Flags: none
    Blocked by: none

    Understood: extend disk-hygiene handoff-apply to take repeatable --path and a required --tier. It re-verifies each path just before removal and recycles through a fail-closed Windows backend. The ask reason lists the tier, count and paths, and _decide stays unchanged.

    Decision recorded. Check each --path against the confidence_ceiling of its hints in the snapshot, used as a cap. Refuse the whole batch, deleting nothing, when --tier ranks above the lowest confidence_ceiling among that path's hints. Refuse the whole batch when any path has no hint, whatever the tier, so the check fails closed.
    [quote truncated; the full decision is at the link]

    #9764 (comment)

    This decision settles the open question about where --tier is checked from. Nothing else is open.

    Automated triage, applied by the lanes App.

  4. added and removed
    needs-triage
    on Oct 24, 2026
  5. added
    needs-owner-decision
    and removed
    status: ready
    on Oct 24, 2026
  6. removed
    needs-owner-decision
    on Oct 25, 2026
  7. 1 remaining item

  8. added
    status: ready
    and removed on Oct 26, 2026
  9. melodic-automation-lanes commented on Oct 26, 2026

    @melodic-automation-lanes
    Contributor

    Not admitted to the issue lane yet: blocker #9779 is not closed by a listed human or a merge.

  10. added
    agent-ready
    needs-human
    and removed
    agent-ready
    on Oct 29, 2026
  11. melodic-automation-lanes commented on Oct 29, 2026

    @melodic-automation-lanes
    Contributor

    The work-resolve-issue lane did not start this issue: it needs a person to make it clearer first.

    Why, in the run's own words:

    The --tier check has no source to read, so one decision is needed before building. The issue says to refuse the batch "when any path's tier in the snapshot is not --tier", but a snapshot entry records no tier. test_preselect_stays_capped_at_the_hint_confidence_ceiling in plugins/disk-hygiene/skills/clean/scripts/test_hygiene.py asserts "tier" is absent from an entry. The snapshot holds only zero or more hints, each with a confidence_ceiling, and preview treats that ceiling as a cap: a plan tier must rank at or below it (hygiene.py preview, TIER_RANK\[plan\["tier"\]\] <= TIER_RANK\[ceiling\]). The tier itself is assigned in plan-<tier>.json, which the skill also writes on Windows, and the investigated catalog may record it too. Which should handoff-apply --tier check each --path against? (A) Hint ceilings as a cap: refuse when --tier ranks above the highest confidence_ceiling on the path's hints. (B) Hint ceilings by equality (the issue's "differs"): refuse unless the path's ceiling equals --tier. This also refuses a medium approval of a path whose hint ceiling is high, which pushes toward raising tiers. (C) A plan: add --plan, require --tier to equal the plan's tier and every --path to be a plan candidate. This ties the batch to the previewed plan, not to scan evidence, because the model writes the plan. (D) Another source. Also say what happens to an approved path with no hint (the SKILL.md section 2 positional-read findings carry none): refuse it in every tier, or allow it in some tier. The rest of the issue is clear: repeatable --path, a per-path re-verify right before each removal, a fail-closed IFileOperation backend with an honest permanent_delete_used, the extended ask reason with _decide unchanged, and the doc updates. The #1116 security-review precondition is settled by the 2026-10-24 comment on #4224 (security review now happens at PR review).

    What the run says it did not do:

    • Nothing was implemented: the run pushed back before any edit, so there were no tests, tidy, review or class audits to run

    The newest comment from a listed maintainer, #9764 (comment), does not start with **Decision recorded.**, so the lane did not count it as an answer. If it answers the question, post the answer again in a new comment whose first line is:

    **Decision recorded.** <answer>
    

    Run: https://github.com/melodic-software/claude-code-plugins/actions/runs/40905518452

    To retry, answer the question in a comment whose first line is **Decision recorded.**, then remove needs-human and add agent-ready again.

  12. removed
    status: ready
    needs-human
    on Oct 29, 2026
  13. kyle-sexton commented on Oct 29, 2026

    @kyle-sexton
    MemberAuthor

    Decision recorded. Check each --path against the confidence_ceiling of its hints in the snapshot, used as a cap. Refuse the whole batch, deleting nothing, when --tier ranks above the lowest confidence_ceiling among that path's hints. Refuse the whole batch when any path has no hint, whatever the tier, so the check fails closed.

    Basis:

    • The owner's decision on disk-hygiene: batch verify-and-recycle into one gated call per tier and fold the approval into the hook ask #4224 (2026-09-29): "Build option A (the batched, fail-closed verify-and-recycle)". The requirement it accepted, from the decision packet, is "Validate paths against --tier (it is only a label)".

    • That decision held the build "only after the chore(disk-hygiene): affirm recorded decline of Windows engine-execution lane (F12) #1116 security review exists". Owner rule C12 (2026-10-24) replaced that gate: between agent-ready and post-merge the only stops are an intent or vision mismatch found during the build and "a security issue found at PR review". The 2026-10-24 split comment applied C12 to this issue, so security review happens at this PR's review.

    • A snapshot entry records no tier, only hints with a confidence_ceiling (lane pushback). The body's "differs from --tier" therefore reads as "ranks above the path's lowest ceiling". Taking the lowest ceiling when a path has several hints is the most conservative reading. A path with no hint has nothing to validate against, so it is refused.

    • The check adds a refusal where today there is none. The hook ask and _decide stay unchanged, as the body requires.

    • A test proves a batch whose volume has no Recycle Bin refuses and deletes nothing: python3 -m pytest plugins/disk-hygiene/skills/clean/scripts/test_hygiene.py -k recycle exits 0 (body, unchanged)

    • A test proves that a batch refuses as a whole when any path's lowest hint confidence_ceiling ranks below --tier, or when any path has no hint: python3 -m pytest plugins/disk-hygiene/skills/clean/scripts/test_hygiene.py -k tier exits 0 (body, amended: the snapshot records no tier, so "snapshot tier differs from --tier" becomes the ceiling cap above, plus the no-hint refusal)

    • A test proves a path that changed after approval is skipped and reported, not deleted (body, unchanged)

    • git diff origin/main...HEAD -- plugins/disk-hygiene/skills/clean/scripts/destructive_guard.py changes no line inside _decide (body, unchanged)

    • A guard test asserts the tier, the count and each path appear in permissionDecisionReason for a batched handoff-apply (body, unchanged)

    • pr-test-windows and ci-status are green on the PR head (body, unchanged)

  14. added
    needs-triage
    and removed
    needs-triage
    on Oct 29, 2026
  15. added
    status: ready
    agent-ready
    on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readystatus: ready

    Type

    Fields

    No fields configured for Task.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions