Scope the Stop-hook fix loop to the session that made the commit - #1
Merged
andreidavid merged 1 commit intoJul 24, 2026
Merged
Conversation
With two Claude sessions open in one repo, a FAIL review by session A also blocks session B on Stop. B is then told to "amend the reviewed commit" -- a commit it did not make, while A is very likely still editing those files with uncommitted changes. Following that instruction clobbers live work. post-commit-review.sh runs as a PostToolUse hook, so it already receives the harness JSON and knows which session made the commit. Record that session id as a fourth field on the FAIL state, and have the Stop hook block only when the state is unowned or owned by the current session. A non-owning session stays completely inert: it does not block, and it does not touch the state file or the loop counter, both of which the owning session is still using. Ownership is checked after the existing staleness rules, so an abandoned session's state still self-clears for anyone via the one-hour cap. Backward compatible: state written before this change (or by a commit made outside a Claude session) carries no session id, which disables the check and preserves current behaviour exactly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
andreidavid
approved these changes
Jul 24, 2026
andreidavid
left a comment
Owner
There was a problem hiding this comment.
Exactly the fix this needed. The details are all right: ownership checked after the staleness rules so state can't wedge, the state format compatible in both directions, and a non-owning session staying fully inert instead of touching the owner's counter. The test coverage is exemplary — every edge case I went looking for was already there, including "non-owner leaves the counter untouched" and "unstamped pre-upgrade state still blocks". Thanks for the careful diagnosis and the writeup; this was a pleasure to review. Merging.
andreidavid
added a commit
that referenced
this pull request
Jul 24, 2026
…NDS) Conflict with #1 resolved as predicted in the PR: the round-cap restructure of the FAIL branch keeps the session-id field on the blocking arm's state write, so both features compose. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
andreidavid
added a commit
that referenced
this pull request
Jul 24, 2026
Round-counter staleness: the counter is now stamped with the epoch of
the last FAIL ("<count> <epoch>"); a stamp older than an hour -- or a
bare pre-stamp count, or a stamp from the future (clock stepped
backward) -- reads as a fresh saga. Without this, a count abandoned
mid-saga (interrupt, kill switch, manual fix outside a session) leaked
into unrelated future FAILs and tripped the cap early.
History entries gain "capped": true on a FAIL demoted to advisory at
the round cap, so it can be told apart from a FAIL that blocked. The
cap message reports the actual round number instead of assuming it
equals the cap.
README catches up with #1 and #2: CODEX_REVIEW_MAX_ROUNDS in the
config table, session-scoped fix loop, the round-count state file and
its staleness rule, and a cost section that states the real per-saga
bound. CHANGELOG for 1.6.0 credits both contributions.
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
With two Claude Code sessions open in the same repo, a FAIL review triggered by session A also blocks session B on
Stop. B receives:…for a commit it did not make. Meanwhile session A is very likely still working those same files with uncommitted changes. Following the instruction means editing a file another agent holds live edits in, and
--amend-ing that agent's commit out from under it.I hit this for real: a second session was told three times to amend another running session's unpushed commit, with that session's
server/routes.tsdirty at the time.Fix
post-commit-review.shruns as a PostToolUse hook, so it already receives the harness JSON and knows which session made the commit. Record thatsession_idas a fourth field on the FAIL state; the Stop hook then blocks only when the state is unowned or owned by the current session.Two details that matter:
Compatibility
State written before this change — or by a commit made outside a Claude session — carries no session id. That disables the check and preserves current single-session behaviour exactly. Same when the harness supplies no
session_id.Tests
tests/helpers.bashgains an optional trailingsession_idargument onhook_inputandstop_input; omitted means the key is absent from the JSON, so every existing test exercises the unstamped path unchanged.Seven new cases:
bats tests/— 56/56 pass (1 pre-existing skip:coreutils timeoutnot available on this machine).