Repository navigation
Conversation
Inthuson
force-pushed
the
fm/pause-live-agent-w2
branch
from
August 19, 2026 16:43
641d647 to
7a31443
Compare
A Claude auto-arm cycle that armed, delivered one rewake, and exited left its single-flight lock behind. Both Stop-event participants then deferred to that lock forever, because its recorded pid was still live: the turn-end guard read it as recovery under way and allowed the stop, and the next Stop firing treated it as another owner and declined to arm. On 2026-08-14 a home with two tasks in flight lost supervision for about 40 minutes with no watcher process and no watcher lock, its beacon frozen at the one delivery, and both crewmates' finished reports sat in the durable queue until an operator drained it by hand. Abandonment is now proven from the epoch ledger instead of inferred from pid liveness. A lock whose holder pid matches the ledger's own owner_pid while the recorded outcome is anything other than arming has already finished its decision, so that claim is reclaimed under the lock's steal mutex, stops counting as recovery ownership in the guard, and is cleared by the guard's terminal check rather than deferred to. A failed clear re-blocks instead of allowing a blind stop, and an arming entry stays in flight however old it is, because its owner foregrounds the arm for the whole watcher cycle. Issue kunchenguid#2251's PR kunchenguid#2263 does not cover this failure. It is closed and unmerged, lives entirely in bin/fm-watch-arm.sh, and retires the stalled watcher and matching stale watcher lock of an arm that is currently running. Here no arm and no watcher were running and no watcher lock existed, so it has nothing to retire and the home stays blind. tests/fm-claude-stop-autoarm.test.sh covers the reclaim, the still-arming and unnamed-owner cases that must keep the gate closed, and the failed clear. tests/fm-turnend-guard.test.sh covers the guard side of the same boundary. Both fail without this change.
The wedge detector had two inputs, rendered pane quietness and the run step, and neither can see a crew that is writing source, then tests, then documentation behind a static pane. On 2026-08-14 one crewmate produced eight consecutive possible-wedge escalations in a single afternoon, three of them demanding deep inspection, while it was demonstrably working and then committed. Every one of them cost a supervision turn to disprove by hand. Add write activity inside the crew's own recorded worktree as a third liveness input. crew_worktree_written_since compares the worktree against the caller's existing idle-window timer file, so -newer needs no clock arithmetic, no temp file, and no portable mtime write. The probe runs only inside the branch that was about to escalate, which bounds it to one pruned, depth-bounded walk per window per FM_STALE_ESCALATE_SECS and leaves the per-poll stale sweep exactly as cheap as before. Positive evidence defers rather than cancels. The idle timer restarts so the next window probes again, the escalation counter is neither advanced nor reset so a later genuine wedge keeps the demand-deep-inspection history it earned, and a .writing-since marker ages the whole deferral chain so the pane still re-surfaces once per FM_PAUSE_RESURFACE_SECS, through the same throttle shape a declared pause already uses, labeled as a recheck rather than a wedge. This can only reduce false positives: every absence of evidence, including no recorded worktree, a torn-down worktree, a missing anchor, and a failed walk, falls through to the unchanged escalation schedule, so a crew that writes nothing still escalates on the existing timetable. What the signal cannot see, by design or by construction: - CPU burn with no writes, such as a long compaction, is invisible. That case keeps the old behavior exactly. - A commit-only phase writes only .git, which is pruned first so that firstmate's own read-only git commands against the worktree can never make the probe self-fulfilling. - Writes under the pruned generated trees, or deeper than FM_WORKTREE_WRITE_MAXDEPTH, do not count. - The probe cannot attribute a write to the crew, so a background build or another process touching the tree looks the same. The hourly re-surface is what bounds that, and a churny file cannot buy silence. - The away-mode daemon's own escalation path is deliberately untouched. tests/fm-watch-triage.test.sh covers the classifier including the .git prune, both halves of the live case on one fixture (quiet plus writing defers, quiet plus silent still escalates and counts), and the bounded re-surface. All three fail without this change.
…ned auto-arm claims
Two consistency gaps in the worktree write probe, both found while reviewing the wedge-deferral change on this branch. A write deferral is a bounded chain: its .writing-since marker ages the whole chain so a churning worktree still re-surfaces once per resurface window. That is only sound while the chain belongs to the current quiet stretch, so every path that restarts the idle-window timer has to drop it too. Two did not: the corrupt-timer repair in wedge_timer_check, and both first-sight branches for a captain-relevant status. A chain left over from an earlier quiet stretch made the first deferral of the new window re-surface immediately instead of after a full fresh window. FM_WORKTREE_WRITE_PRUNE is a skip list, so clearing it reads as "skip nothing" and is the obvious way to widen the probe to the whole depth-bounded tree. Instead an empty list reported no evidence at all, quietly costing the wedge detector its third liveness input on a home that meant to widen the walk. An empty list now widens the walk, and the header says so. Neither change alters when a stall that writes nothing escalates. Regressions in tests/fm-watch-triage.test.sh cover all three paths and each one fails on the pre-fix code.
A worker that was alive and had correctly appended `paused:` (or carried a durable `captain-held` transfer) could not be quieted. It surfaced a bare `stale: <window>` roughly every poll, forever, and killing a healthy worker was the only way to stop it. `pause_state_class` gated its whole declared-wait verdict on the backend confidently reporting the agent DEAD (added alongside the bounded cadence in ab8cea6, kunchenguid#743), so for any non-dead agent it returned `none` before the `paused` verdict `crew_absorb_class` had already derived. The two halves of the feature disagreed: `handle_paused_stale` creates `.paused-<key>` and `.paused-rechecked-<key>`, but the classifier that decides whether to call it could not return `paused` while the agent was up. Two consequences compounded: - On a first-sight stale hash, the non-terminal branch took `surface_nonterminal_stale`, the bare wake, instead of `handle_paused_stale`. - On a NEW pane hash, the loop's tail branch took `clear_pause_tracking`, which deletes `.paused-resurfaced-<key>` - the very throttle that bounds the cadence. Every pane repaint therefore rearmed a fresh full-rate wake, which is why the observed rate accelerated over an hour instead of settling. `bin/fm-supervise-daemon.sh` was already the other way round: its `classify_stale` absorbs a live declared pause from the status line alone, with no liveness gate. The always-on watcher was the outlier. `pause_state_class` now consults no liveness verdict at all. The declaration, not whether the agent process is still up, is what makes the idling expected; the `PAUSE_RESURFACE_SECS` bound is what keeps absorbing safe, and only a window whose crew actually WROTE a declaration can reach the function. To keep that from hiding anything, `crew_absorb_class` gains a fourth token, `actionable`, for the authoritative states that positively need a supervisor - parked, blocked, done, failed. It refines what used to fall into `none`, so a window at a live ask-user gate or with a checks-green PR keeps the routing it had before this change rather than this function's bounded cadence, even when a stale wait line is the last thing the crew wrote. Precedence is working > actionable > declared wait. Both `crew_is_*` wrappers test exact tokens and every watcher case site routes `actionable` exactly where `none` already went, so nothing else moves. The new token also removes a per-recheck backend process-name read from the absorb path. A crew that goes quiet having declared nothing is untouched: it still surfaces on the unchanged wedge schedule. This change only removes false positives. Two independent reasons to stay quiet now coexist: a declared wait, and k4's recent-worktree-writes deferral. The total order is working (active run step or busy pane) > declared wait > recent writes and they never both decide the same poll. `wedge_defer_writing` is reachable only through `wedge_timer_check`, and at every stale site the declared-wait branch is evaluated first: a `paused` verdict always goes to `handle_paused_stale`, which never calls the wedge timer and does call `clear_write_tracking` to retire any deferral chain the window had accumulated. `wedge_timer_check`, and therefore the deferral, is reached only when the declaration is absent or outranked. Declared-wait-wins is also the safer resolution where they would disagree. Both absorb on the same `PAUSE_RESURFACE_SECS` bound, but the declared wait anchors its age on the status file's mtime, which is older, while the deferral anchors on a freshly touched `.writing-since-<key>`. Letting the declaration win therefore re-surfaces sooner than or at the same time as the deferral would, never later. That made this an obvious answer rather than a design decision, so it is documented here instead of raised as a decision. `tests/fm-watch-triage.test.sh` gains one three-phase differential: - A live agent with a fresh declared wait is absorbed silently, records the pause cadence marker, and starts no wedge timer. - Aged past the threshold and repainted on all six following rounds, exactly one bounded recheck reaches the durable queue, it names the wait ("paused 501s, awaiting external"), no round produces a bare stopped-crew wake, and the throttle survives every repaint. - The safety half: the same live agent, same idle pane, same inconclusive authoritative verdict, but no declaration - still surfaces at once and is given no pause cadence. On the pre-change base the same test reproduces the reported symptom exactly: a bare stale on first sight, then six bare wakes across the six repaints. Phase three passes on both trees, which is the point of including it. `test_crew_absorb_class_classifier` covers the new token across all four authoritative states and asserts both wrappers stay narrow. One pre-existing test was leaking an exported `FM_FAKE_CREW_STATE` into whatever ran next, which had silently made the safety half of this differential vacuous; it now unsets it, and every phase of the new test pins its own verdict rather than inheriting one. This path is now backend-independent. It previously varied with whether a runtime's `fm_backend_agent_alive` could return a confident `dead`: any backend answering `unknown` - including a remote or experimental one - could never quiet a declared wait, and the same crew behaved differently under tmux than elsewhere for reasons that had nothing to do with its work. Removing the read makes every supported harness and backend take the same bounded cadence, so no per-adapter verification is affected and no harness-dependent signal is introduced.
…ble wedge Rebasing onto kunchenguid#2619 made the mate-home write-probe fixture's routing unreachable, so it asserted a wedge escalation that can no longer happen. kunchenguid#2619 gave busy_turn_bound_check ownership of a crossed busy-pane completed-turn bound: a crew whose own last status line declares an external wait now takes the bounded pause cadence instead of the wedge timer. A kind=secondmate window is only triaged at all while it declares a pause (the watcher skips every other mate window before it captures the pane), so after kunchenguid#2619 a secondmate can no longer reach wedge_timer_check in normal mode at all - the declaration that lets it be triaged is the same declaration that routes it away from the wedge. The fixture drove exactly that pair, so it hung on an absorbed pause instead of the escalation it asserts. The claim under test is that a provisioned firstmate home's own supervision churn is not crew write evidence, and crew_worktree_written_since enforces that two ways: the kind=secondmate record and the .fm-secondmate-home marker on the recorded worktree. The marker half is reachable end-to-end through an ordinary crew task, so the fixture now records the home for a kind=ship task with no declared wait. Every assertion is unchanged: the pane still escalates as a possible wedge on the unchanged schedule, no .writing-since marker is created, the escalation is counted once, and the wake reaches the durable queue. The kind=secondmate short-circuit stays covered by the classifier unit test, which pins both halves directly. docs/architecture.md said such a pane keeps "escalating on the unchanged schedule", which kunchenguid#2619 made imprecise for the only mate panes the watcher triages. It now states what this deferral actually guarantees - that it never relaxes the schedule those panes already had - and names the marker, so the sentence covers whoever records a firstmate home rather than mates alone.
Inthuson
force-pushed
the
fm/pause-live-agent-w2
branch
from
August 21, 2026 08:19
7a31443 to
9e93d57
Compare
Owner
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.
Intent
Fix a supervision bug in firstmate's always-on watcher: a worker that is ALIVE and has correctly declared it is waiting (appended a
paused:status line, or carries a durablecaptain-heldtransfer) cannot be quieted. It surfaces a barestale: <window>wake on every poll, forever, and the only way to stop it today is to kill the healthy worker, which is backwards. Confirmed live: a parked-but-alive worker generated about ten bare stale wakes in one hour, accelerating toward one a minute.Acceptance criteria the captain set: (1) a live worker whose last status line is
paused:orcaptain-held:is absorbed on the bounded cadence exactly as a dead one already is; (2) the wedge-detection path still escalates a worker that is genuinely stuck and has NOT declared a wait; (3) a test exists that fails before the change for the live-agent declared-wait shape.Overriding safety constraint the captain stated: a stall that writes nothing must still escalate on the existing schedule. This change may ONLY reduce false positives. Widening what gets suppressed in order to make a test pass was explicitly forbidden, because the failure mode created would be a silently dead worker that firstmate reports as fine, which costs far more than the noise being fixed.
Deliberate decisions and context a reviewer reading only the diff would not know:
BASE BRANCH: the captain explicitly required branching from an unmerged sibling branch (head b3d8759, PR #2524) and NOT from the default branch, because this fix builds directly on that work. Those commits therefore appear in this branch's history until 2524 merges. That is expected and ordered: do not rebase onto the default branch, do not remove them, do not cherry-pick.
ROOT CAUSE: pause_state_class gated its whole declared-wait verdict on the backend confidently reporting the agent DEAD (added alongside the bounded cadence in ab8cea6, #743). For any non-dead agent it returned
nonebefore thepausedverdict crew_absorb_class had already derived, so the two halves of the feature disagreed: handle_paused_stale creates the .paused- and .paused-rechecked- markers, but the classifier deciding whether to call it could not returnpausedwhile the agent was up. Two consequences compounded: on a first-sight stale hash the non-terminal branch took surface_nonterminal_stale (the bare wake) instead of handle_paused_stale; and on a NEW pane hash the loop's tail branch ran clear_pause_tracking, deleting the .paused-resurfaced- throttle that bounds the cadence, so every pane repaint rearmed a fresh full-rate wake. That is why the observed rate accelerated instead of settling. bin/fm-supervise-daemon.sh's classify_stale already absorbed a live declared pause from the status line alone with no liveness gate, so the always-on watcher was the outlier.FIX: pause_state_class now consults no liveness verdict at all. The declaration, not whether the agent process is still up, is what makes the idling expected; the finite PAUSE_RESURFACE_SECS bound is what keeps absorbing safe, and only a window whose crew actually WROTE a declaration can reach that function.
NEW CLASSIFIER TOKEN, deliberate and load-bearing: crew_absorb_class gained a fourth token,
actionable, for the authoritative states parked|blocked|done|failed. Without it those states would fall intononeand be absorbed for up to an hour, which would newly hide a live ask-user gate or a checks-green PR - exactly the new false negative the safety constraint forbids. It refines what used to benone; both crew_is_* wrappers test exact tokens, and every watcher case site routesactionableexactly wherenonealready went, so no other routing moves. Precedence is working > actionable > declared wait. The token also removes a per-recheck backend process-name read from the absorb path.COMPOSITION WITH THE WRITE DEFERRAL: the captain asked for this to be reasoned about explicitly rather than bolted on beside it, and raised as a keyed needs-decision only if it needed a real design decision. It did not, so it is documented in the commit body. Total order is working (active run step or busy pane) > declared wait > recent worktree writes. They can never both decide the same poll: wedge_defer_writing is reachable only through wedge_timer_check, the declared-wait branch is evaluated first at every stale site, a
pausedverdict always goes to handle_paused_stale which never calls the wedge timer, and handle_paused_stale calls clear_write_tracking to retire any deferral chain. Declared-wait-wins is also the safer resolution where they would disagree: both absorb on the same PAUSE_RESURFACE_SECS bound, but the declaration anchors its age on the status file's mtime, which is older, while the deferral anchors on a freshly touched .writing-since-, so letting the declaration win re-surfaces sooner than or level with the deferral, never later.TESTS: one three-phase differential added to the existing tests/fm-watch-triage.test.sh (extend the existing runner, do not invent a new one). It drives a real fm-watch.sh subprocess and asserts observable wake output and durable state, never implementation source content. Agent liveness is faked rather than driven through real panes, which the captain explicitly preferred over provisioning real panes. Proven to discriminate against the pre-change base: pre-change it reports a bare stale on first sight and six bare wakes across six pane repaints; post-change exactly one bounded recheck that names the wait ("paused 501s, awaiting external"), with the throttle surviving every repaint. Phase three - the same live worker, same idle pane, same inconclusive authoritative verdict, but no declaration - passes on BOTH trees on purpose: it is the safety half of the differential, proving the undeclared-quiet escalation guarantee is untouched.
PRE-EXISTING TEST DEFECT FIXED IN SCOPE: one existing test exported FM_FAKE_CREW_STATE and never unset it, leaking a
pausedverdict into whatever test ran next. That had silently made the safety phase of the new differential vacuous (it failed for the leak, not for the product). Fixed by unsetting it there, and by having every phase of the new test pin its own authoritative verdict instead of inheriting an ambient one. Deliberately in scope because it is what made the new test's safety half untrustworthy.COMPATIBILITY: the change removes a runtime-backend-dependent read, so this path no longer varies by whether a backend's agent-liveness probe can answer
dead. Previously any backend answeringunknown, including remote or experimental ones, could never quiet a declared wait, and the same crew behaved differently under tmux than elsewhere for reasons unrelated to its work. Every supported harness and backend now takes the same bounded cadence. No new harness-dependent signal is introduced, so no live-harness opt-in guard is needed and no per-adapter verification record is affected.DOCUMENTATION: docs/architecture.md was updated to state the new rule (the declaration, not a backend liveness verdict, governs; authoritative crew state still outranks it) rather than leaving the removed liveness gate documented. The wording deliberately says a parked/blocked/done/failed verdict "keeps whatever routing that pane already had" and is "never newly hidden", which is precise rather than overclaiming: at the repeat-sight branch such a verdict was already absorbed before this change, and this change does not make that worse.
VERIFICATION HONESTY: the three affected suites were run green (fm-watch-triage 59 checks, fm-daemon 99, fm-crew-state 49), as was bin/fm-doc-audience-check.sh. Lint was NOT independently verifiable from the agent's environment, so it is not claimed as agent-verified evidence; the captain separately ran the canonical pinned ShellCheck 0.11.0 set at this exact head and reported zero findings.
What Changed
pause_state_classinbin/fm-watch.shno longer consultsfm_backend_agent_alive: a window whose last status line is a declaredpaused:wait or a durablecaptain-heldtransfer takes the boundedPAUSE_RESURFACE_SECSrecheck cadence whether its agent is live or exited, instead of falling through to a barestale: <window>wake and dropping the.paused-resurfaced-<key>throttle on every pane repaint.crew_absorb_classgained a fourth token,actionable, for the authoritativeparked|blocked|done|failedstates so a real gate, ready PR, or failure keeps the routingnonealready had,.paused-rechecked-<key>now stores that verdict (instead of an epoch) so a throttled poll replays the token it recorded, andsurface_nonterminal_stalestopped overwriting it.crew_worktree_written_sincetobin/fm-classify-lib.sh— one pruned, depth-bounded,fm_run_timed-boundedfindover the task's recorded worktree, skipping secondmate homes — and wired it intowedge_timer_check, which now takes a task argument and defers via the newwedge_defer_writingwhen the worktree was written since the idle window opened. New.writing-since-<key>/.writing-resurfaced-<key>markers age that deferral chain through a sharedresurface_absorbedhelper (also now used byhandle_paused_stale),clear_write_trackingretires the chain wherever stale bookkeeping resets, the daemon'sclear_pause_trackingremoves both markers, and a singlewindow_keyhelper replaces the four duplicated key derivations. New knobs:FM_WORKTREE_WRITE_PRUNE,FM_WORKTREE_WRITE_MAXDEPTH,FM_WORKTREE_WRITE_TIMEOUT.fm_autoarm_claim_record_identity,fm_autoarm_claim_abandoned, andfm_autoarm_release_abandonedtobin/fm-wake-lib.sh, proving a Claude Stop auto-arm claim finished from its own ledger entry (owner_pidmatching the lock with a non-armingoutcome) or from a recordedpid-identitythat no longer matches the live pid, and reclaiming it under the lock's steal mutex.bin/fm-claude-stop-autoarm.shrecords its identity before publishing theautoarmrole and reclaims an abandoned lock once before standing down;bin/fm-turnend-guard.shstops reading such a lock as recovery in flight in bothautoarm_owns_recoveryandterminal_fail_open, clearing it rather than allowing a blind stop.Risk Assessment
✅ Low: The round-3 fix is sound and I confirmed its invariant holds by tracing all four pause_state_class call sites, the sole-writer claim, and routing parity for the new
actionabletoken; every acceptance criterion is met with no forbidden widening, and the three remaining items are comment accuracy, a test-assertion hardening, and an already-authorized tradeoff.Testing
No baseline test output was supplied for this phase, so I started from a clean worktree at the target commit and ran targeted validation myself. I exercised the three suites the change touches (fm-watch-triage 60 checks, fm-crew-state 49, fm-daemon 99, all green), then proved the regression differential by reverting only the two product files to the pre-fix base and re-running the new tests unchanged: they fail there with exactly the reported symptom and pass on this change. For end-user-visible evidence I replayed the reported scenario through a real fm-watch.sh subprocess on both trees and captured the wake reasons firstmate actually receives - six barestale: <window>wakes across six pane repaints before, one boundedpaused 500s, awaiting externalrecheck after, for both thepaused:andcaptain-held:live shapes - alongside three safety replays (undeclared quiet crew, a stall that writes nothing, and a live ask-user gate behind a stalepaused:line) whose output is identical on both trees, so the change only removes false positives. This is a CLI/supervision-daemon behavior change with no rendered surface, so the reviewer-visible artifacts are watcher wake transcripts and durable wake-queue state rather than screenshots. I removed the transient driver scripts from the working tree (archived copies live in the evidence directory) and confirmed the worktree is clean at 1e4017b; lint and the doc-audience check were deliberately not run in this phase.Evidence: Differential: wake reasons firstmate received, pre-fix vs post-fix (same fixture, six pane repaints)
BEFORE (b3d8759, pre-fix): queued: stale: test:fm-live-held queued: stale: test:fm-live-held queued: stale: test:fm-live-held queued: stale: test:fm-live-held queued: stale: test:fm-live-held queued: stale: test:fm-live-held TOTAL stale wakes: 6 of which BARE "stale: test:fm-live-held": 6 AFTER (1e4017b, this change): queued: stale: test:fm-live-held (paused 500s, awaiting external - declared pause, rechecked on a long cadence not a wedge; confirm the wait still holds) TOTAL stale wakes: 1 of which BARE "stale: test:fm-live-held": 0 Unchanged on both trees: undeclared quiet crew -> stale: test:fm-live-quiet (surfaced at once) stall that writes nothing -> stale: test:fm-live-wedged (idle 500s, possible wedge, escalation 1) live ask-user gate behind a paused: line -> stale: test:fm-gate on every one of 3 pollsEvidence: Full watcher transcript, this change: live `paused:` and `captain-held:` absorbed on the bounded cadence, undeclared quiet crew and a non-writing stall still escalate
Evidence: Full watcher transcript, pre-fix base: the same live declared waits flood a bare stale wake on every poll
Evidence: Live ask-user gate behind a stale `paused:` line still surfaces on every poll (this change)
--- poll round 1 (first stale sight) --- watcher woke firstmate with: stale: test:fm-gate --- poll round 2 (pane repainted moments later) --- watcher woke firstmate with: stale: test:fm-gate --- poll round 3 (pane repainted moments later) --- watcher woke firstmate with: stale: test:fm-gateEvidence: Same live ask-user gate on the pre-fix base - identical, so no new false negative was introduced
Evidence: New tests against pre-change product code (must fail)
not ok - a live crew's declared wait surfaced instead of being absorbed: stale: test:fm-live-held EXIT=1Evidence: New tests against this change (must pass)
ok - a LIVE crew's declared wait is absorbed on the bounded cadence, while an undeclared quiet crew still surfaces at once ok - an actionable verdict behind a declared wait keeps its recheck throttle and is never replayed as a pause EXIT=0Evidence: New tests pass with a hostile ambient FM_FAKE_CREW_STATE exported (each phase pins its own verdict)
Evidence: tests/fm-watch-triage.test.sh full run (60 checks, exit 0)
Evidence: tests/fm-crew-state.test.sh full run (49 checks, exit 0)
Evidence: tests/fm-daemon.test.sh full run (99 checks, exit 0)
/tmp/no-mistakes-evidence/01M087BFYDVKHGWC8WJ54T2V6W/drivers)Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-classify-lib.sh:152- bin/fm-classify-lib.sh:151-153 still documents the liveness gate this change removed:status_is_paused_or_captain_held's contract comment says "the watcher applies its bounded pause cadence when agent death confirms that no live decision gate is being silenced". That is now false —pause_state_classconsults no liveness verdict, and the "no live decision gate silenced" guarantee is instead provided by the newactionabletoken. This is the shared classifier's own contract comment for the exact predicate that gates the new function, so a future reader auditing the invariant is pointed at the removed rule. bin/fm-classify-lib.sh:79 has the same problem in smaller form ("a declared pause or a dead-agent captain hold" for FM_PAUSE_RESURFACE_SECS_DEFAULT, which is now liveness-independent). The commit updated bin/fm-watch.sh's comments and docs/architecture.md but not the library that owns the predicate.bin/fm-watch.sh:467- bin/fm-watch.sh:467-469 states the change's central safety argument as "only a window whose crew actually WROTE a declaration reaches this function at all".pause_state_classis in fact called for every first-sight non-terminal stale pane (bin/fm-watch.sh:1185), declaration or not — the new test's Phase C exercises exactly that. The property does hold, but via the early return at bin/fm-watch.sh:478, which delegates tocrew_absorb_classwhen no declaration is present. As written, a maintainer could conclude any fallthrough inside this function is safe by construction. Reword to "only a window whose crew wrote a declaration can reach the declared-wait verdict (see the early return above)".bin/fm-watch.sh:495- After the fallthrough at bin/fm-watch.sh:495,crew_absorb_class'spausedandnonetokens produce identical behavior in every production path: inpause_state_classboth fall through todate +%s > recheck; printf 'paused', and on the no-declaration early return at line 480 both land in the*)arm of all three case sites.crew_is_paused(bin/fm-classify-lib.sh:1157) has no production caller either — only tests. So the four-token vocabulary is effectively three tokens for consumers, which will read as a distinction that matters when it no longer does. Noting the redundancy only; collapsing it would change a documented shared-classifier contract and is not worth doing as part of this fix.🔧 Fix: align pause-cadence contract comments with liveness-free rule
4 issues (2 warnings, 2 infos) still open:
bin/fm-watch.sh:492- The.paused-rechecked-<key>throttle is discarded for anactionableverdict even though the absorb still holds, socrew_absorb_classruns on every poll indefinitely. Concrete path: window withpaused:as its last status line and an authoritativeparked/donerun-step verdict (exactly the shape the new token was added for). First sight returnsactionable->surface_nonterminal_stale(line 1198) stamps.paused-$keyand a fresh.paused-rechecked-$key. Repeat-sight polls take the fast path at line 485 until the stamp ages past STALE_ESCALATE_SECS (240s). At that poll,crew_absorb_classreturnsactionable, line 492 removes the recheck file, and the caller's*)arm at line 1210 callshandle_paused_stale- which absorbs but never re-stamps.paused-rechecked-$key. From then onage_ofreturns 999999 every poll, the fast path is never taken again, andfm-crew-state.sh(a subprocess that may shell out toaxi statuswith FM_CREW_STATE_NM_TIMEOUT, default 10s) is invoked once per POLL (default 15s) forever, per such window. This directly falsifies the header claim at line 473-474 that the read is throttled "to once per STALE_ESCALATE_SECS while the absorb holds", and undercuts the change's own stated benefit of removing a per-recheck read from the absorb path. Note the naive fix is unsafe: stamping the recheck file onactionablewould make the fast path replaypausedand, at the new-hash site (line 1242-1245), route a real gate tohandle_paused_staleinstead ofclear_pause_tracking, hiding it for up to 240s. Persist the verdict alongside the timestamp (or use a separateactionablethrottle marker) so the fast path replays the same token and routing is unchanged; failing that, correct the comment to state the throttle covers only thepausedverdict.tests/fm-watch-triage.test.sh:1117- The new differential varies two inputs, not one, so the riskiest half of acceptance criterion (1) is untested. The comment at line 1089-1091 claims Phases A and C "share the fixture - same live agent, same idle pane, same inconclusive authoritative verdict - and differ ONLY in whether the crew declared a wait, so the absorb is pinned to the declaration and to nothing else." But Phase A passesFM_FAKE_CREW_STATE="$paused_state"(line 1117,state: paused) while Phase C passes$inconclusive_state(line 1184,state: unknown). Phase A's absorb is therefore equally explained by the authoritativepausedverdict: an implementation that absorbed oncrew_absorb_class = pausedalone, with no declaration check, would pass both phases. The consequence is that thenone/unknown-verdict + live-agent + declaration path is never driven end to end - and that is the only shape where the watcher absorbs with no positive evidence whatsoever, plus thecaptain-held:half of criterion (1) ("a live worker whose last status line ispaused:orcaptain-held:"), sincemap_log_statehas nocaptain-heldverb so such a crew always reportsunknown->none. The existing captain-held coverage at line 1006-1022 is dead-agent only (FM_FAKE_TMUX_CURRENT_COMMAND=zsh). Fix: give Phase A$inconclusive_stateso the differential really has one variable. That still absorbs post-change (declaration +nonefalls through line 496 topaused) and still fails pre-change (live agent forcednone-> bare stale), while covering the untested path.bin/fm-watch.sh:470- The fix-round rewrite of this contract comment says the early return "leaves a crew that goes quiet having written nothing on the unchanged wedge schedule", but that is not the routing for the main safety case: an undeclared quiet crew whose verdict isnoneoractionablehits the*)arm at line 1197 and is surfaced immediately bysurface_nonterminal_stale; only aworkingverdict puts it on the wedge timer (line 1188-1192). docs/architecture.md:27 states it correctly ("still surfaces one stale wake at once, on the unchanged schedule"). Since the whole point of the previous round's finding was contract-comment accuracy on this function, align the wording with the doc.bin/fm-watch.sh:498- Incidental (and undocumented) behavior change for secondmates, noting it as a tradeoff rather than a defect. Pre-change,pause_state_classwas internally inconsistent forkind=secondmate: the fast path at line 485 printedpausedbecause the liveness block was guarded bywindow_kind != secondmate, while the slow path leftagent_aliveunset so[ "${agent_alive:-unknown}" = dead ]failed andclass=nonewas returned verbatim. A secondmate with apaused:last line and an unreadable authoritative verdict (torn-down worktree, missing meta) therefore hitclear_pause_trackingat line 1121 and was silently suppressed. The unconditionalprintf 'paused'here now returnspausedfor that case too, so it gets one bounded re-surface per PAUSE_RESURFACE_SECS instead of silence. That makes the slow path agree with the fast path and errs toward visibility, so it is consistent with the safety constraint, but it is a new (rare) wake not covered by the intent or by any test.🔧 Fix: bound actionable rechecks and pin the declared-wait differential
1 warning still open:
bin/fm-watch.sh:523- The round-2 fix's own invariant - "anactionableverdict must NEVER be served out of the throttle aspaused" - is defeated on the only path that can produce it, becausesurface_nonterminal_staleis a second writer of.paused-rechecked-<key>and writes an epoch instead of the verdict.Concrete sequence (declared wait + authoritative
parked/blocked/done/failed, i.e. exactly the shapeactionablewas added for):pause_state_classtakes the slow path,crew_absorb_classreturnsactionable, line 508 recordsactionable, and the*)arm at line 1208 callssurface_nonterminal_stale.surface_nonterminal_stalesees the declaration (line 521), sets.paused-$key, and line 523 overwrites the recordedactionablewithdate +%s.h != prevbranch and reaches the new-hash site at line 1252 ->pause_state_classfast path (line 494:.paused-$keyexists, recheck fresh) -> content is an epoch -> line 497 printspaused-> line 1254 routes tohandle_paused_stale, which absorbs the window and advances.stale-$keyto h2.STALE_ESCALATE_SECS(240s), after which the slow path re-derivesactionableand the window escapes.So a parked/blocked/done/failed crew is routed onto the bounded pause cadence and logged as "absorbed stale (paused, awaiting external...)" at the new-hash site - precisely the site named as forbidden. Pre-change (
b3d8759) that same repaint gaveclear_pause_trackingand a re-surface. It is bounded (<=240s, and a wake was already delivered at step 1, so this is not a silently-dead-worker case), which is why this is a warning rather than an error, but it falsifies two contract statements this change added: bin/fm-watch.sh:481-483 ("the epoch stamp surface_nonterminal_stale writes ... reads as paused, which is what this function recorded there in every such case" - it recordedactionable, notpaused) and docs/architecture.md:29 ("keeps whatever routing that pane already had").The new test cannot catch this: tests/fm-watch-triage.test.sh:1225 hand-seeds the throttle file, so the repaint phase never starts from the state
surface_nonterminal_staleactually leaves.Fix: have
surface_nonterminal_stalerecord the verdict rather than an epoch in its declared-wait branch.actionableis the only verdict that can reach line 1209 with a declaration present (a declared wait forcespausedoractionableinpause_state_class, andworkingreturns earlier), so writingactionablethere is exact; passing the class in from the line 1198 case statement is the alternative if you prefer not to rely on that reasoning. Then extend the repaint phase of test_actionable_gate_behind_a_declared_wait_keeps_its_recheck_throttle to start from a real first-sightactionablesurface instead of a seeded stamp, so the epoch path is covered. If instead the <=240s quiet period after a delivered wake is wanted, correct bin/fm-watch.sh:481-483, docs/architecture.md:29, and the test comment at tests/fm-watch-triage.test.sh:1204-1207 to stop claiming the stronger invariant.🔧 Fix: stop clobbering the recorded recheck verdict on surface
3 infos still open:
bin/fm-watch.sh:476- The contract comment added by the fix rounds claims.paused-rechecked-<key>"throttles the crew_absorb_class read (which may shell out to no-mistakes) to once per STALE_ESCALATE_SECS while the absorb holds". That is not true for theworkingverdict, which is the one arm that still deletes the stamp (line 504). Concrete reachable path, kind=ship: the crew appendspaused:and is absorbed aspaused(handle_paused_stale sets.paused-<key>, the stamp recordspaused). Firstmate then hands the crew to a no-mistakes validation, which appends no new status line (the sparse status contract the case-site comment at lines 1147-1155 already describes), so the declaration stays the last line. Once the stamp ages past STALE_ESCALATE_SECS, the slow path returnsworking, the repeat-sightworkingarm (line 1220) calls clear_pause_state, and.paused-<key>plus the stamp are gone. Every later poll then re-enters pause_state_class through the line-1217 guard (the declaration is still the last line), finds no.paused-<key>, and pays a full crew_absorb_class read - which for kind=ship shells out toaxi statusunder FM_CREW_STATE_NM_TIMEOUT (default 10s) once per POLL (default 15s), for the whole duration of the run. The read loop itself is pre-existing and untouched by this diff (the repeat-sight block and pause_state_class's working branch are both unchanged from b3d8759), so only the new comment's coverage claim is in scope: narrow it to say the stamp throttles the declared-wait absorb only, and that aworkingverdict deliberately drops it so an active run is re-read each poll. Fixing the loop itself (e.g. routing a declared-waitworkingwindow straight to wedge_timer_check on repeat sight, as the undeclared branch at line 1227 already does) would be a behavior change beyond this fix's scope.tests/fm-watch-triage.test.sh:1248- The assertion[ -e "$state/.paused-rechecked-$key" ]fails with the message "an actionable recheck dropped its throttle clock, so crew state is re-read every poll", but it cannot prove that. The test itself seeds that file at line 1231 with mtime now-500 (line 1234), so-epasses whether or not the watcher refreshed it. It does catch the exact round-2 regression it was written for (anrm -fon the actionable path), but a change that merely stops refreshing the stamp - leaving the same unbounded per-poll crew_absorb_class read this test exists to prevent - would still pass, because a stamp stuck at now-500 fails theage_of < STALE_ESCALATE_SECSfast-path test on every poll. Strengthen it to assert the stamp's mtime is newer than the seeded$backvalue (durable marker state, so still an observable-state assertion, not a source-content one);wait_live "$pid" 40already gives ~4s at FM_POLL=1 for the poll to land.bin/fm-watch.sh:496- Noting the residual window the recorded-verdict design accepts, not a defect. Because the fast path replays the recorded token, apausedverdict recorded before the crew's authoritative state changed is served for up to STALE_ESCALATE_SECS (240s) after that change. A repaint inside that window is servedpausedand routed to handle_paused_stale (line 1257), which re-anchors.stale-<key>to the repainted hash; the window then lands in the repeat-sight branch, whose*)arm (line 1224) also absorbsactionable, so on a pane that then goes static the only exit is the PAUSE_RESURFACE_SECS re-surface, labeled "awaiting external - declared pause". This is bounded and mostly pre-existing: pre-change the repeat-sight*)arm absorbednoneidentically, and in practice a real gate appends a captain-relevant status line, which takes the window out of the declared-wait path at line 1105 and surfaces it through the Layer-2 signal scan instead. The one genuine delta versus b3d8759 is that a live declared-wait crew is now absorbed silently at first sight, so it can enter that absorbing arm without having received a prior bare-stale wake. That is the unavoidable cost of fixing the reported bug, and the round-2 instruction explicitly authorized throttling the read, so no action is implied - recording it so the tradeoff is visible to a human.✅ **Test** - passed
✅ No issues found.
bash tests/fm-watch-triage.test.sh- 60 checks, exit 0, including the two new teststest_live_declared_wait_is_absorbed_on_the_bounded_cadenceandtest_actionable_gate_behind_a_declared_wait_keeps_its_recheck_throttlebash tests/fm-crew-state.test.sh- 49 checks, exit 0 (authoritative state vocabulary the newactionabletoken keys off: working|parked|done|blocked|paused|failed|unknown)bash tests/fm-daemon.test.sh- 99 checks, exit 0 (the always-on watcher's sibling classifier consumer)Regression differential: reverted onlybin/fm-watch.sh+bin/fm-classify-lib.shtob3d8759(git checkout b3d8759 -- bin/fm-watch.sh bin/fm-classify-lib.sh) and ran the two new tests unchanged -> exit 1,not ok - a live crew's declared wait surfaced instead of being absorbed: stale: test:fm-live-held; restored to1e4017b-> both passManual product-level replay of the reported bug on both trees (realbin/fm-watch.shsubprocess, six pane repaints, drain+ack between rounds): live agent +paused:aged 500s, and the same shape withcaptain-held:Manual product-level replay of the safety half on both trees: same live agent, same idle pane, same inconclusive authoritative verdict, no declaration ->stale: test:fm-live-quietsurfaced at once, no.paused-<key>markerManual product-level replay of the overriding safety constraint on both trees: live agent, no declaration, authoritativeworking · source: run-step, wedge timer aged pastFM_STALE_ESCALATE_SECS=240->stale: test:fm-live-wedged (idle 500s, possible wedge, escalation 1)Manual product-level replay of the forbidden new false negative on both trees: live agent, status log still showingpaused:, authoritativestate: parked · source: run-step · parked at review: 2 finding(s) (ask-user: authority decision),FM_PAUSE_RESURFACE_SECS=999->stale: test:fm-gatesurfaced on all three polls, never relabeled an external waitAmbient-verdict immunity check for the in-scope test-leak fix:FM_FAKE_CREW_STATE='state: paused · source: status-log · leaked ambient verdict' bash <focused driver>-> both new tests still pass, so every phase pins its own verdict✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.