Skip to content

fix: a hook fails open even on a panic - #29

Merged
maxgfr merged 1 commit into
mainfrom
worktree-hook-fail-open
Nov 5, 2026
Merged

maxgfr merged 1 commit into
mainfrom
worktree-hook-fail-open

Conversation

@maxgfr

@maxgfr maxgfr commented Nov 5, 2026

Copy link
Copy Markdown
Owner

A Scopelet failure must never disturb the agent.

  • Errors already answered {}. A panic in a release build (panic = "abort") would have exited by SIGABRT, and a failed write to stdout could exit 2, which Claude Code treats as a blocking error. The hook command now installs a panic hook that prints {} and exits 0 before the abort, and ignores a failed print.
  • a_hook_fails_open_whatever_goes_wrong sends Claude, Codex and OpenCode malformed events, an unwritable cache and a forced panic (trigger compiled in debug builds only) and requires status 0 with JSON.
  • Checked outside the suite: 156 hostile calls (corrupt and mutated events, read-only or file-replaced dirs, corrupt state, no HOME, closed stdout) all fail open; an abort-mode release build with a forced panic answers {} with status 0; the slowest call (a 30 MB output) takes 164 ms against the 5 s hook timeout.
  • Docs: design, verification, README and the website state the guarantee.

Errors already answered {}, but a release build aborts on a panic, which
the host would show as a hook error, and a failed write to stdout could exit
2, which Claude Code treats as blocking. The hook command now installs a
panic hook that answers {} with status 0 before the abort, and ignores a
failed print. A test sends every host malformed events, an unwritable cache
and a forced panic (debug builds only).
@maxgfr
maxgfr merged commit 1bd0093 into main Nov 5, 2026
6 checks passed
@maxgfr
maxgfr deleted the worktree-hook-fail-open branch November 5, 2026 12:43
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.

1 participant