Repository navigation
fix(bin): detect and surface workers parked on the account allowance - #6
Merged
Merged
Conversation
…ed in) A worker whose harness refuses a turn on the account allowance keeps a live pane and a live process, so every liveness probe firstmate owns reads healthy and no wake fires. On 2026-08-17 two crewmates parked seconds after launch, their reset passed at 08:30, and nothing surfaced or resumed them until an unrelated wedge timer happened to fire on one of the two panes hours later. This adds bin/fm-allowance-lib.sh, the one owner of that detection, with two independent signals so no single vendor string is load-bearing: - session-record: the harness's own transcript records the refusal as an assistant record carrying isApiErrorMessage with an HTTP 429 status. Structural, and preferred. Reading the LAST conversational record is what makes it current-state rather than history. - pane: the rendered notice matched against a per-harness signature in a bounded tail of the capture, for a worker whose transcript firstmate cannot locate or a harness that reworded its records. Per-harness support is a gate, not a default: only claude has a verified signature, and every other adapter reports not-parked, so firstmate's behaviour for them is unchanged. The library is deliberately kept out of the semantic busy-state contract in bin/fm-busy-lib.sh, which forbids rendered text as a state source; this one can only ever ADD a wake or name a cause. Both signals were verified against real evidence on this machine: 106 refusal records across ~/.claude/projects, all carrying apiErrorStatus 429, with the last-record test separating 27 still-parked transcripts from 28 that resumed after their refusal. PARTIAL WORK, committed so nothing is lost while the account allowance is exhausted. Still to come on this branch: - wiring into bin/fm-watch.sh so a park surfaces immediately as a named wake instead of waiting out a wedge timer, detected independently of the busy verdict; - wiring into bin/fm-crew-state.sh so recovery reads the cause instead of "harness busy"; - the portable regression and the opt-in live guard both required for a harness-dependent check, and the docs/verification/supervision.md entry; - the AGENTS.md state-file line for the new watcher marker. Nothing calls this library yet, so this commit changes no firstmate behaviour.
A worker whose provider refused the turn on the account allowance keeps a live process, a live endpoint, and a normally rendered pane, so every liveness probe firstmate owns reads it as healthy and no wake fires. On 2026-08-17 two crewmates parked seconds after launch, their reset passed at 08:30, and nothing surfaced them until an unrelated wedge alarm happened to fire on one of the two panes two and a half hours later - and what it said then was "possible wedge", not the cause. Wire bin/fm-allowance-lib.sh into the two places that decide whether a worker needs attention: - bin/fm-watch.sh surfaces the park as a named wake that says what happened and that recovery is a single Enter, once per park episode (state/.allowance-<key> remembers what was already reported, and is dropped as soon as the worker is no longer parked). It runs ahead of the busy gate and independently of the busy verdict, because a refused turn need not close the turn-end hook that would mark the worker idle, in which case the pane reads as provably working indefinitely. It also runs ahead of the secondmate skip, from the structural signal alone, so an idle-by-design mate is covered without reading its pane. - bin/fm-crew-state.sh reports it as the crew's current state ahead of every other source, so recovery reads the cause rather than "harness busy". Detection only. Automatic resume once the reset passes is deliberately not part of this change: a resume that fires at the wrong moment is worse than a notification that reaches firstmate. tests/fm-allowance-park.test.sh pins the classifier and both integration points with real processes and no harness, including that either signal alone carries the verdict; reverting the two wired scripts fails three of its cases. tests/fm-allowance-park-live-e2e.test.sh is the opt-in drift guard over every installed harness, and docs/verification/supervision.md records the dated per-harness evidence and the command that refreshes it.
…nclusive empty-tail probe
…-park's priority over crew-state and add script inventory row
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
Notice and recover workers parked on the account allowance.
Evidence, 2026-08-17: two crewmates spawned at 05:47 UTC hit the account session limit immediately, printed "You've hit your session limit - resets 8:30am (UTC) - Press Enter to continue after reset", and parked. The reset happened at 08:30. Nothing resumed them. They were still parked at 11:07 UTC - about two and a half hours of dead time past the reset - and were only found because an unrelated stale notification fired on one of the two panes. A third worker spawned in the same batch never hit the limit and ran normally, so nothing at the fleet level looked wrong. Recovery was a single Enter followed by one steer per worker, after which both picked up their briefs and ran. The cost is entirely in not noticing.
Two separate defects, which must not be conflated because the fixes differ:
Nothing notices a worker parked on the allowance. The pane stays alive and the process stays alive, so the ordinary liveness check reads healthy and no wake fires. The stale notification that eventually found it was incidental. Detection is the primary deliverable.
Nothing resumes a worker after the reset passes. The condition is trivially detectable - the pane prints its own reset time, and quota-axi reports the account position directly (at 11:07 the account had 84 percent of the session window and 42 percent of the week left, so the allowance was not the constraint by then).
Accepted scope decision carried into this change: fix 1 first and completely, since it is the defect that cost two and a half hours. Fix 2 only if it falls out cleanly from the same change - an automatic resume that fires at the wrong moment is worse than a notification that reaches firstmate, so where there is any doubt, ship the detection and file the resume as separate work. This change ships detection only and the automatic resume is deliberately excluded, to be filed separately.
Whatever is built must not be more elaborate than the observed recovery, which was a single Enter plus one steer per worker.
Constraints:
Tests: ship a test that fails without the change - a pane rendering the allowance-parked message is detected as parked, and a pane rendering ordinary working output is not.
What Changed
bin/fm-allowance-lib.sh, the single owner of allowance-park detection: per-harness session-record (Claude transcriptisApiErrorMessage/apiErrorStatus: 429) and rendered-pane signature checks, gated to only verified harnesses (currentlyclaude*) so unsupported adapters behave exactly as before.bin/fm-crew-state.shas the highest-priority state source (outranks the no-mistakes run lookup and status-log reconciliation) and intobin/fm-watch.sh, which surfaces a parked worker as a named "stale" wake (once per park episode, tracked via a.allowance-<key>marker) instead of waiting out an ordinary wedge timer; a structural-only probe (no settled pane yet) can detect and wake but never clears a prior marker, while a call carrying a settled pane tail is treated as the complete evidence for the cycle.fm-allowance-park.test.shandfm-allowance-park-live-e2e.test.shinbin/fm-test-run.sh's test families, and movewait_poll_cycle/file_mtimeout oftests/fm-watch-triage.test.shinto the sharedtests/wake-helpers.shfor reuse across test files.AGENTS.md,docs/architecture.md, anddocs/scripts.mdto document the new.allowance-*state files, the allowance-park priority over crew-state's other sources, and the new script's entry in the inventory table.Risk Assessment
✅ Low: The fix commit correctly threads a
finalflag through allowance_park_check so only the call that has seen every available signal for a window this cycle (the settled-pane call, or a secondmate's structural-only call when no pane check follows) may clear the marker; a structural-only probe ahead of the pane check for an ordinary worker or admitted mate now leaves the marker intact on an inconclusive failure, closing the wake-storm path the prior round identified. Traced both call sites, the marker-clear/write/dedup logic, and fm_allowance_park_detail's signal precedence, and the new test exercises the previously-buggy pane-only fallback across two watcher relaunches, asserting no double wake and no marker loss.Testing
Ran the targeted suite
tests/fm-allowance-park.test.shviabin/fm-test-run.sh: all 13 tests pass, including the new regression testtest_watcher_surfaces_a_pane_only_park_once_across_relaunches, which reproduces the exact wake-storm scenario from the recorded decision (pane-only-detected park with an unresolvable transcript). I confirmed this is a genuine regression test by checking out the pre-fix bin/fm-watch.sh (commit 09e6b43) with the new test file and re-running: the new test failed with the same symptom described in the bug report ("the same pane-only park woke firstmate twice"), while all other tests still passed. Restoring the fixed bin/fm-watch.sh made all 13 tests pass again, and the working tree was left clean.Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
🔧 **Rebase** - 1 issue found → auto-fixed ✅
bin/fm-watch.sh- merge conflict rebasing onto origin/main🔧 Fix applied.
✅ Re-checked - no issues remain.
🔧 **Review** - 1 issue found → auto-fixed ✅
bin/fm-watch.sh:772- The previously-identified and user-approved-to-fix defect (allowance-marker-cleared-before-pane-check) is still present in this diff, unchanged in substance. allowance_park_check() (fm-watch.sh:762-781) is still called twice per poll for the same $key: once with an empty tail ahead of the secondmate skip (line 1376) and once with the settled pane tail once the capture is byte-identical across polls (line 1398). Inside the function, ANY failure of fm_allowance_park_detail unconditionally doesrm -f "$marker"(line 773), with no distinction between 'this call saw every signal available for this window' and 'this call only had the empty-tail structural probe'. For an ordinary (non-mate) worker whose session-record transcript cannot be resolved/trusted for its worktree (relocated CLAUDE_CONFIG_DIR store, or a worktree cwd-prefix mismatch after a cd) but whose pane still renders the limit notice: call 1 (tail='') fails structurally and deletes the marker; call 2 (tail=$tail40, same poll) detects the park via the pane fallback, finds the marker absent, and fires fm_wake_append/wake as though it were a brand-new park. Because a parked pane stays byte-identical across polls, this repeats on every subsequent poll, directly violating the 'surfaces once per episode' guarantee the user explicitly required in the prior round ('the once-per-episode contract is the only thing keeping a parked worker from becoming a wake storm'). tests/fm-allowance-park.test.sh's test_watcher_surfaces_each_park_once (line 326) still cannot catch this: build_parked_case always uses transcript-mode 'parked' (a locatable, trusted transcript), so its call 1 succeeds via the session-record signal and never reaches the rm -f branch; the pane-only fallback path is only exercised via direct fm_allowance_park_detail calls (test_either_signal_alone_carries_the_verdict), never through two watcher poll cycles on the same window. The user's required invariants from the prior round (marker cleared only by a call that saw every signal available for that window; a secondmate's structural-only call must still be able to clear its own marker since its pane is never captured; a worker whose hash changed since the last poll never reaches the settled-pane call site) are not implemented - the code has no logic distinguishing these cases at all.🔧 Fix: fix(bin): stop allowance marker clearing on inconclusive empty-tail probe
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
./bin/fm-test-run.sh tests/fm-allowance-park.test.sh(post-fix, target commit 69174d4): 13/13 pass./bin/fm-test-run.sh tests/fm-allowance-park.test.shwith bin/fm-watch.sh reverted to pre-fix commit 09e6b43: 12/13 pass,test_watcher_surfaces_a_pane_only_park_once_across_relaunchesfails reproducing the wake-storm bugrestored bin/fm-watch.sh to the fixed version and reran the suite to confirm clean pass and clean working tree✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.