fix(stop-hook): don't trip the ERR trap on the normal no-active-loop case - #9
Open
mahlerm454 wants to merge 1 commit into
Open
Conversation
…case
claudex_find_active_loop returns exit code 1 by design when no loop is
active — which is the normal case in almost every session. The bare
command-substitution assignment at the top of the stop hook let that
expected non-zero status fire the ERR trap, so every ordinary session
logged "ERR trap at line 67; failing open" instead of taking the clean
`approve "no active loop"` path right below it.
Guard the assignment with `|| true` so the ERR trap goes back to being
what it is meant to be: a net for unexpected errors only.
Verified both paths: no state file → {"decision":"approve"} with
"APPROVE: no active loop" logged; active plan loop (drafting, missing
PLAN.md) → correct block decision.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
claudex_find_active_loopreturns exit code 1 by design when no loop is active (state-helpers.sh: "They return non-zero on failure so the caller can decide how to handle it"). But that is the normal case in almost every session — and the bare command-substitution assignment in the stop hook lets that expected non-zero status fire the ERR trap installed a few lines above:The clean
approve "no active loop"path right below the assignment is never reached. The outcome happens to be identical (both paths approve), so nothing user-visible breaks — but the log fills up with pseudo-errors on every ordinary turn, and the ERR trap no longer distinguishes real failures from business as usual.Fix
Guard the assignment with
|| trueso the expected no-loop case takes the intended code path, and the ERR trap goes back to being a net for unexpected errors only.Verification
{"decision":"approve"}, log showsAPPROVE: no active loopphase: drafting,PLAN.mdmissing) → correct{"decision":"block", ...}with the drafting instructions🤖 Generated with Claude Code