Repository navigation
Description
This was generated by AI, delegated directly by the repository operator to resolve this blocker.
Split out of #1416. That issue reported two guard launch failures; both named root causes are now
fixed (see the scope-decision comment on #1416). While confirming that, the transcript sweep turned
up a third, still-live failure that is not in #1416's body and has a different shape: the guard
launches successfully, runs for 17 seconds, and then exits 1 with no stderr — so the
destructive Bash command proceeds unguarded.
Type
Bug — fail-open in a PreToolUse destructive-operation guard.
Summary
disk-hygiene's engine-gate guard (destructive_guard.py --mode engine-gate) produced a
hook_non_blocking_error with exitCode: 1 and empty stderr after durationMs: 17054. This is
not the ${user_config.disk_hygiene_enabled} launch refusal fixed by #1242 — the recorded command
is the post-fix 0.9.x form with no ${user_config.*} token. The process started and did work, then
died silently.
Per the hooks reference (fetched 2026-07-25): "Claude Code
treats exit code 1 as a non-blocking error and proceeds with the action... If your hook is meant to
enforce a policy, use exit 2." So every unhandled error path in this guard is a silent fail-open.
Evidence (single observed occurrence)
| Field | Value |
|---|---|
timestamp |
2026-07-25T21:03:30.942Z |
toolUseID |
toolu_01CHywBHXQSS5hXeQifPnL3m |
hookName |
PreToolUse:Bash |
exitCode |
1 |
stdout |
(empty) |
stderr |
Failed with non-blocking status code: No stderr output |
durationMs |
17054 |
command |
python3 ${CLAUDE_PLUGIN_ROOT}/skills/clean/scripts/destructive_guard.py --mode engine-gate --plugin-root ${CLAUDE_PLUGIN_ROOT} --authorized-data-root ${CLAUDE_PLUGIN_DATA} |
cwd |
C:\Users\KyleSexton |
| Claude Code | 2.1.220 |
| Installed plugin | disk-hygiene 0.9.1 |
Honest scoping: this is one occurrence with no known reproduction. It is the only
destructive_guard.py hook error recorded after #1242's fix propagated. Do not treat the 17 s
duration as characterized — it is a single sample.
It is not a hook timeout: the documented default timeout for command hooks is 600 s.
This record also does useful double duty — it is the only positive proof that the plugin-level
hooks/hooks.json gate still registers and fires post-fix. Without it, "zero errors since
07-24" could equally have meant the hook stopped registering entirely.
Current behavior
An unexpected failure inside the guard (uncaught exception, interpreter-level abort, killed
subprocess, or any non-2 exit) terminates with exit 1 and no diagnostic. Claude Code records a
non-blocking error and runs the destructive command. From the outside this is indistinguishable
from the guard having inspected the command and approved it.
Desired behavior
The guard fails closed and legibly: any path that is not a deliberate, reasoned allow
decision must deny the tool call with a diagnostic the operator can act on.
Acceptance criteria
destructive_guard.pywraps its entire entrypoint so that any otherwise-unhandled exception
or unexpected termination exits2with a one-line diagnostic on stderr naming the guard and the
failure — never exit1, never a silent exit.- Exit
1is no longer reachable from any internal error path in the guard. If a genuine
"allow" outcome needs a distinct code, it is exit0; deny is exit2. - A regression test in
skills/clean/scripts/test_hygiene.pyasserts that an injected internal
failure produces exit2with non-empty stderr, and that no code path yields exit1. - The 17-second duration is investigated and the finding recorded in the issue or the fix's
changelog entry — either an identified slow path with a bounded fix, or an explicit statement
that it could not be reproduced and what was ruled out. - If the guard can legitimately take many seconds on a large
cwd, it declares an explicit
timeoutinhooks/hooks.jsonand denies on its own internal deadline rather than risking a
harness-level kill that surfaces as a non-blocking error. plugins/disk-hygiene/CHANGELOG.mdgains an entry under a new version, and the version in
.claude-plugin/plugin.jsonis bumped.
Out of scope
- Making guard failures visible to the operator as a class — that is disk-hygiene: the destructive-operation guard has never launched — 73 recorded runs, all hook_non_blocking_error #1416's remaining spine.
repo-hygiene's guard (verified working; see disk-hygiene: the destructive-operation guard has never launched — 73 recorded runs, all hook_non_blocking_error #1416).- The
${user_config.*}launch refusal (fixed in fix(disk-hygiene): resolve kill switch by reading user settings directly #1242) and the WSL/bin/bashrouting (fixed in
fix(repo-hygiene): destructive-guard fail-open on Windows — shell-form hook launch + jq fail-closed degraded mode #1006). - Broadening what the guard classifies as destructive.
Refs #1416
Activity
kyle-sexton commentedon Jul 25, 2026
This was generated by AI, delegated directly by the repository operator to resolve this blocker.
Clarification to acceptance criterion 2.
The phrasing "If a genuine 'allow' outcome needs a distinct code, it is exit
0" reads as thoughthere is a choice to make. There is not — exit
0is already the allow path today. Replace with:The point of the criterion is the exit-
1prohibition, not the allow encoding.kyle-sexton commentedon Jul 26, 2026
kyle-sexton commentedon Jul 26, 2026
This was generated by AI during work-loop execution.
Opened PR #1449 with the fix:
main()now wraps the guard's decision logic intry/except BaseException, denying (exit 2, stderr diagnostic) on any internal failure instead of falling through to exit 1. Added a self-enforced watchdog (default 10s,DISK_HYGIENE_GUARD_WATCHDOG_SECONDSoverride) plus an explicittimeout: 20on both hook registrations, and a regression-test sweep across the guard's real call graph asserting exit 2 / non-empty stderr / exit 1 never observed.The 17s duration itself is investigated but not conclusively reproduced (single occurrence) — findings and residual uncertainty (the empty-stderr detail not fully squaring with a plain uncaught exception) are recorded in the module docstring and CHANGELOG. Full writeup in the PR description.
Never-merge boundary: this is a loop-lane worker session — authored the branch/commit/PR only, did not merge. Handing off to the PR review/merge lane.
fix(disk-hygiene): arm the watchdog before stdin read; raise guard ti…
fix(disk-hygiene): surface silent destructive-guard launch failures (#…
Merge origin/main into fix/1423-destructive-guard-fail-open
fix(disk-hygiene): destructive guard denies at exit 2 instead of fail…
fix(disk-hygiene): deny when the guard's decision cannot be written t…
perf(disk-hygiene): cut the destructive guard's per-call spawns 4 to …