Skip to content

disk-hygiene: prove the apply --execute guard holds in every permission mode #5609

Closed

Description

@kyle-sexton

Problem

The disk-hygiene destructive guard gates hygiene.py apply --execute with a PreToolUse hook that returns permissionDecision: "ask". Whether that ask holds is documented for some permission modes and not others:

  • Probed and held (2026-09-30, Claude Code 2.1.285, Linux/WSL2, Bash tool): headless default mode denied the call; --bg default mode parked at the prompt; headless --permission-mode bypassPermissions listed the call in permission_denials and the target survived (PR feat(disk-hygiene): add model-invocable read-only audit skill #5590, comments 5916629407 and the probe table in its body).
  • Not probed: an interactive session in bypassPermissions, auto mode, and the Windows PowerShell tool.
  • The official docs do not name hook ask under bypassPermissions. The /permission-modes "Actions no mode auto-approves" list names ask rules, not hook ask. Upstream [BUG] Bypass permission mode resets after a PreToolUse hook returns "ask" anthropics/claude-code#37420 (closed, 2026-03) reports the prompt still appears interactively; #79356 (2.1.215, Windows, PowerShell tool, closed stale) reports a hook ask not enforced. Research record: .work/hook-ask-bypass-permissions/RESEARCH.md (memory tier, not committed).

So the only gate on the irreversible lane rests on behavior that is undocumented for two of the modes a session can be in.

Acceptance criteria

  1. Probe the guard's ask on apply --execute in: an interactive bypassPermissions session, auto mode, and the PowerShell tool on a Windows fleet host. Record mode, version, tool, result and the target listing on this issue.
  2. Decide whether apply --execute also needs a gate that does not depend on the permission mode (an engine-side confirmation, or a hook deny in modes where ask cannot reach a person), and implement the chosen one with tests, or record why not.
  3. Add a four-part verification record (Claim, Basis, As of, Recheck) for the hook-ask-under-bypass behavior to the disk-hygiene safety-model reference, with a recheck trigger on any Claude Code changelog entry that names PreToolUse ask or bypassPermissions.

Related

Activity

  1. kyle-sexton commented on Oct 1, 2026

    @kyle-sexton
    MemberAuthor

    Owner decision (2026-10-01): approved the recommendation ("go with recommended", the owner's reply to the batch decision page that listed this question and its recommendation).

    Question: which option for the apply --execute guard, A, B, C or D? Chosen: A, probe first. An agent runs the headless auto-mode probe on this WSL host and the PowerShell-tool probe on melo-lap-001 or melo-desk-001 via /fleet:reach, both against a throwaway dir under .work/. The interactive bypassPermissions probe is run by the owner (or by an agent only if the owner explicitly authorizes a tmux-driven session, since AGENTS.md forbids bypass mode otherwise). Results are recorded here, then AC2 is decided (record why not, or add a mode-independent gate with tests) in a PR that closes this issue.

    Next: the owner names the Windows host for the PowerShell probe and runs or authorizes the interactive bypassPermissions probe. Until then needs-human is set and agent-ready is removed so no lane picks this up early. The auto-mode probe can run any time.

  2. added
    needs-humanHuman-in-the-loop required; autonomous sessions must not resolve items carrying this.
    and removed
    agent-readyFully specified and briefed; eligible for autonomous pickup from the frontier.
    on Oct 1, 2026
  3. added theissue type on Oct 15, 2026
  4. kyle-sexton commented on Oct 22, 2026

    @kyle-sexton
    MemberAuthor

    This was generated by AI during an attended run.

    AC1, auto-mode lane (owner decision A): held. The guard returned ask on apply --execute under headless --permission-mode auto. The call is the only entry in permission_denials, and the target survived.

    Setup:

    • Plugin: disk-hygiene 0.43.18 from a git archive of origin/main 9ef419e52b, loaded with --plugin-dir, with the installed copy disabled.
    • Target: a throwaway dir under .work/probe-5609/target/.
    • Plan: the current engine requires --plan/--report paths inside the authorized data root, so the plan lived there and not under .work/. Its one candidate was staging.tmp, tier medium.
    • Session flags: claude -p --model sonnet --effort low --permission-mode auto --tools Bash --strict-mcp-config --max-turns 14 --no-session-persistence --output-format stream-json.
    Lane Claude Code Mode Tool Command permission_denials Guard hook Target after
    Probe 2.1.307 (init event) auto (init permissionMode: auto) Bash hygiene.py apply --execute --snapshot … --plan …/plan-medium.json --confirm-tier medium --approval-token … --report … --data-root …, after scan and preview (both allowed) 1 entry: that Bash call fired: decision: ask, rule: exact-engine-apply, mode: engine-gate (03:58:52Z) staging.tmp, sub/, emptydir/ all present; no report written
    Control 2.1.307 auto Bash ls -la <target> [] did not fire (no hygiene.py match) unchanged

    Still open under AC1:

    • PowerShell-tool probe on a Windows fleet host (agent, via /fleet:reach).
    • Interactive bypass-permissions probe. This one is the owner's, and it is waivable: headless bypass already held on 2026-09-30, and auto now holds.

    AC2 and AC3 wait for those results.

  5. kyle-sexton commented on Oct 22, 2026

    @kyle-sexton
    MemberAuthor

    Interactive bypassPermissions probe, run by the owner 2026-10-22: Claude Code 2.1.308, Linux/WSL2, Bash tool, disk-hygiene from main 4114353 loaded with --plugin-dir, a fresh scratch target holding one empty file.

    • Launch: claude --dangerously-skip-permissions in an interactive terminal.
    • scan and preview ran. The guard logged allow, rule exact-engine-preview, at 17:55:19Z, and the preview returned ready-for-explicit-approval.
    • hygiene.py apply --execute: the guard returned ask, rule exact-engine-apply, in decisions.jsonl at 18:07:40.768Z. A permission prompt appeared in the bypass session. The owner approved it with Enter, and the tool result arrived at 18:09:54Z, 2m14s later. The target file was then deleted, paths_removed 1, as approved. The session's model reported no prompt, as expected: the prompt goes to the person, not the model.

    Result: the hook ask reaches a person in interactive bypass mode and is not auto-approved. Together with the auto-mode probe in comment 6332348323 and the 2026-09-30 probes, every probed mode holds.

    • AC1: the PowerShell tool on a Windows host remains.
    • AC2: no mode-independent gate, since the ask reaches a person or is denied in every probed mode; the reason is recorded in the safety-model update.
    • AC3: the safety-model.md update follows in a PR.
  6. kyle-sexton commented on Oct 24, 2026

    @kyle-sexton
    MemberAuthor

    This was generated by AI during an unattended host run over /fleet:reach (melo-desk-001, native Windows lane).

    AC1, PowerShell tool on a Windows fleet host: holds within one process; does not hold across --resume. The cross-resume gap is filed separately: #9853.

    Setup:

    • Host: melo-desk-001, Windows 11, native Windows lane reached from its WSL lane through interop (route R1). Claude Code 2.1.309.
    • Plugin: the installed disk-hygiene 0.43.21. diff -rq against origin/main 9965f0c07 showed no differences apart from __pycache__. A first attempt with --plugin-dir resolved data_root: none, so the guard denied every engine call. That attempt is discarded.
    • Session flags: claude.exe -p --model sonnet --effort low --permission-mode auto --strict-mcp-config, with CLAUDE_CODE_USE_POWERSHELL_TOOL=1. Each run is on a fresh throwaway target holding staging.tmp, sub/keep.txt and emptydir/.
    • Evidence for each row: the stream-json permission_denials, guard-decisions/decisions.jsonl, and a listing of the target before and after.
    # Shape Tools Call Guard decision (decisions.jsonl) permission_denials Target after
    b 3 -p turns, --resume between them PowerShell, Read turn 1: engine scan through PowerShell; turn 3: engine apply --execute through PowerShell turn 1: deny in both belt and engine-gate modes; turn 3: deny in engine-gate only, with no belt entry. Rule powershell-deletion-spelling; a hard deny, never ask both calls unchanged
    e 1 process, 2 sequential stream-json messages (scan report, then approval of exactly staging.tmp) Bash, PowerShell, Read Bash handoff-verify (clear), then PowerShell [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile(<path>, 'OnlyErrorDialogs', 'SendToRecycleBin') ask, rule powershell-deletion-spelling, mode belt the PowerShell delete unchanged; staging.tmp survived
    c 2 -p turns: scan, then --resume with the same approval Bash, PowerShell, Read the same PowerShell DeleteFile call none logged: the turn-2 log has engine-gate entries only, with no belt entry [] staging.tmp removed (recycled)

    Reading:

    • The engine's apply --execute is not a Windows lane: the engine returns execution-platform-unsupported, and the PowerShell guard hard-denies every engine call (safety-model.md, "Execution is intentionally not cross-platform" and the PowerShell paragraph). The PowerShell-tool question therefore concerns the manual lane's hook ask.
    • In one process, that ask holds under headless auto mode: the call is denied and the target survives, the same result as the Bash probes on 2026-09-30 and 2026-10-22.
    • After --resume, a new process on the same session id, the skill-frontmatter belt is not registered. Two runs show it. In run b, turn 3 logs engine-gate only. Run c's turn 2 shows SessionStart:resume hooks, no belt decisions, and an unprompted PowerShell delete. That contradicts safety-model.md, which says the belt is registered "for the rest of the session after the skill is invoked" and "only the session's end clears it". The always-on engine gate does not see PowerShell deletion spellings (same section), so nothing gated the delete. Filed as fix(disk-hygiene): the clean skill's PowerShell belt is gone after --resume, so a manual-lane delete runs unprompted #9853.

    AC2 and AC3: the earlier rationale for AC2 ("the ask reaches a person or is denied in every probed mode") holds per process, but not across a resume. Whether to add a gate that does not depend on the mode or the process is now the design question in #9853, so I have not opened the AC2/AC3 PR. Outputs are kept locally under .work/host-runs/5609/.

  7. kyle-sexton commented on Oct 26, 2026

    @kyle-sexton
    MemberAuthor

    This was generated by AI.

    Closing as completed, with the last edits carried to #9853. A second, independent agent check agreed.

    Reopen if #9853 closes without those items.

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

    needs-humanHuman-in-the-loop required; autonomous sessions must not resolve items carrying this.

    Type

    Fields

    No fields configured for Task.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions