Gate: only stderr signals failure when no exit code is present - #18
Open
greghughespdx wants to merge 1 commit into
Open
Gate: only stderr signals failure when no exit code is present#18greghughespdx wants to merge 1 commit into
greghughespdx wants to merge 1 commit into
Conversation
Claude Code's Bash tool often omits an exit code from the PostToolUse hook
payload, so the gate fell back to matching FAILURE_RE against the full response
text. Successful commands whose stdout carries failure vocabulary - commit
messages ('fix fail-open'), gitleaks output ('leaks found'), grep of a doc that
discusses failures - tripped a constant stream of false 'tool failure' gates.
Failure text is now matched against stderr only; stdout no longer manufactures
failures. Structured exit_success is unchanged and still authoritative. Verified:
stdout-contains-failure -> clean; real stderr error and nonzero exit -> still flagged;
existing gate + robustness suites pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The PostToolUse observation gate reports "fablize gate observed a tool failure" on fully successful commands. Claude Code's Bash tool often omits an exit code from the hook payload, so
detect_failure/exit_successfall back to matchingFAILURE_REagainst the full response text (stdout + stderr). Any successful command whose stdout carries the failure vocabulary trips it: a commit message containing 'fail'/'failure', gitleaks printing 'leaks found', or grepping a doc that discusses failures. In sessions that do security or infra work (where that vocabulary is constant) the gate fires on nearly every successful command, training the operator to ignore it, which defeats the gate.Fix
When structured exit status is present it remains authoritative (unchanged). When it is absent, the failure regex now matches stderr only via a new
stderr_text()helper; stdout can no longer manufacture a failure. Genuine failures surface on stderr (command not found, tracebacks, non-zero-exit error streams) and are still caught.Verification
stdoutcontains failure vocabulary, no exit code -> clean (was a false positive)test_gate.py(6/6) andtest_gate_robustness.py(12/12) pass.One file changed:
scripts/gate/parse_tool_result.py.