Repository navigation
fix(guard): advisory-only turn end in lock-refused sessions - #81
Merged
Merged
Conversation
The Claude turn-end guard re-blocked every turn end forever in a lock-refused session: the Stop-owned auto-arm stays inert there, so the epoch ledger never advances and the epoch-keyed re-block budget never consumes toward fail-open (frozen counter with a stale epoch, unverified episode without one). Detect the live-other-owner lock before any blocking branch and report the lapse as advisory wording only (exit 0, no budget/epoch/episode/lock mutation), preserving the backstop for owned, missing, malformed, and dead-owner locks. Regression tests cover both epoch shapes plus default mode, with owned-lock and dead-owner blocking negatives.
…t-hygiene PR75) into fm/fm-turnend-guard-lock-refused-loop
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.
fix(guard): advisory-only turn end in lock-refused sessions
Problem
The Claude turn-end guard (
bin/fm-turnend-guard.sh --claude) re-blocked EVERY turn end forever in a lock-refused (read-only) session.Causal split (trigger / mask / symptom):
bin/fm-claude-stop-autoarm.sh) stays inert by design, sostate/.claude-autoarm-epochnever advances. The guard's re-block budget keys off epoch change: with a stale epoch the counter freezes (observed:count=1across 5 consecutive blocks); with no epoch the counter grows but terminal fail-open never verifies (no failure episode exists). Either way the guard exits 2 forever.TURN WOULD END BLINDrepair banner, instructing a read-only session to perform repairs it must not perform.Fix
bin/fm-turnend-guard.shnow detects the lock-refused state once, before any blocking branch: the session lock names a live harness pid that is not this session's (same idiom the auto-arm and Cursor park already use). Such a turn ends with advisory wording only (exit 0,READ-ONLY SESSION WITHOUT LOCK OWNERSHIP) and zero shared-state mutation: no budget write, no epoch write, no failure-episode reset, no legacy-acceptance log.Untouched backstop: missing, malformed, or dead-owner locks keep blocking exactly as before, and the lock-owning session's own guard is unchanged.
docs/turnend-guard.mdgains one invariant sentence plus regression-coverage pointer (one sentence per line, per repo style).Verification (local runs are the CI evidence: Actions minutes are exhausted on this fork)
Red without fix:
tests/fm-turnend-guard.test.shagainst the unpatched guard fails at the first new test:plus the stale-epoch fixture reproduction (exit 2 x5, budget frozen at
count=1,epoch=7).Green with fix:
Branch already merges fork main at
d49dee6(PR 76 attestation path), so the required "PR must be raised via no-mistakes" check can run from this branch workflow.Code Review (Stage 1)
Command:
bin/fm-review.sh worktree --from d49dee6 --to HEADwith ShellCheck 0.11.0 on PATH (exit 0). The unscoped run escalates only on the upstream merge content (2299 lines, already reviewed on fork main) and on the host's ambient ShellCheck 0.9.0 version refusal; neither touches this change.Independent Second-Level Review
Reviewer: opencode-go/deepseek-v4.1-flash (independent of the authoring lane opencode-go/muse-spark-1.3-contributor)
Report: data/fm-pr81-second-level-review/report.md
Verdict: PASS at head 2e52e57 (one Low-severity malformed-binding gap noted in the report; no blocker)