Repository navigation
fix(bin): make every counted wake queue row presentable or retired - #3950
Conversation
A wake row could be counted as queued while no drain would ever present it, leaving the operator told to "drain them before anything else" by a command that printed nothing and offered no acknowledgement. Two independent paths produced that state. A row reserved by a live supervision-branch grant is excluded from a main drain by design, but fm-guard.sh counted the whole queue, so main was warned about rows only the branch could present, on every guarded command for as long as the grant was held. A row that lost its five appended fields or its numeric sequence can never be claimed, presented, or named by an --ack-through cutoff, yet it still counted as queued, wedging the queue permanently. The guard now counts only the rows the calling actor can itself present or retire, and a main drain retires unusable rows under the queue lock, reporting them in bounded escaped form before removal so the evidence survives for the separate row-generating defects. A retirement failure is reported loudly and never suppresses unrelated consumable work. A main drain whose remaining rows are all branch-held says so in one bounded line instead of exiting silently. Grant row-list and owner-record reads move into fm-wake-lib.sh so the drain, the grant publisher, and the guard share one implementation. Ownership is unchanged: a branch drain still touches nothing outside its grant and never retires a row, and main still cannot present or acknowledge an active grant. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GghGvsa4JDB1E5FuznX2i1
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (2): Last reviewed commit: "no-mistakes(ci): Addressed the Greptile ..." | Re-trigger Greptile |
… ("Unreadable queue suppresses alarms"). Root cause: fm_wake_actor_pending_count inferred "the queue could not be counted" only from awk's printed output (`case "$count" in ''|*[!0-9]*) count=1`). That relies on awk aborting before its END rule when the input cannot be opened. An awk that reaches END after a failed open prints `0`, which the fallback accepts as a genuine count; both actor counts then read zero and bin/fm-guard.sh emits neither the queued-wake warning nor the branch-held advisory for a queue nobody proved empty. Fix (bin/fm-wake-lib.sh:1828,1835): both counting awk invocations now set `count=''` on a non-zero awk exit status, so the existing "cannot be counted => report a pending row" fallback is driven by awk's exit status instead of an implementation-defined detail of what it printed. No new code path or behavior; the pre-existing fallback just becomes unconditional. Comment updated to state why. Regression test (tests/fm-wake-queue.test.sh: test_uncountable_queue_still_raises_the_pending_alarm, registered in the run list): runs the real bin/fm-guard.sh against a non-empty, unreadable queue with a PATH-injected awk emulating an END-running implementation (prints 0, exits 2; execs the real awk otherwise) and asserts "queued wakes pending" is still emitted; disconfirming half asserts the same fake awk over a readable, provably empty queue stays silent. Fails on the pre-fix library ("not ok - a queue that could not be counted silenced the queued-wake alarm"), passes after. Verified locally: bin/fm-test-run.sh tests/fm-wake-queue.test.sh -> 0 failed; tests/fm-guard-stale-banner.test.sh + tests/fm-watcher-lock.test.sh -> 0 failed; bin/fm-lint.sh (ShellCheck 0.11.0 + actionlint 1.7.12) clean. Caveat reported honestly: on the awks available/known here (mawk locally, plus gawk and BWK/macOS awk, all of which treat an unopenable input as fatal and skip END) the alarm was not actually suppressed - I reproduced the unreadable-queue case and the warning fired. The change removes the code's dependence on that awk detail rather than repairing an outage observed on this platform. Both intent constraints still hold: every counted row remains presentable or retirable, and no alarm-suppressing path was added
|
Speaking as Kun's firstmate: First look on HEAD Diff reviewed: Contract-class: restore. Restores the already-promised drain contract: every row counted in the pending-warning condition is presentable with an ack path or is retired. Unconfigured empty-queue behavior unchanged; the broken "warn then present nothing" path is what is corrected. Not new-default (no new autonomy grant; retirement is only for rows that can never be claimed/acked). VISION.md (each rule)
Merging now. |
|
Speaking as Kun's firstmate: this is merged. Thank you @cisrd — really appreciate you taking the time on this. |
…unchenguid#3950) * fix(bin): make every counted wake queue row presentable or retired A wake row could be counted as queued while no drain would ever present it, leaving the operator told to "drain them before anything else" by a command that printed nothing and offered no acknowledgement. Two independent paths produced that state. A row reserved by a live supervision-branch grant is excluded from a main drain by design, but fm-guard.sh counted the whole queue, so main was warned about rows only the branch could present, on every guarded command for as long as the grant was held. A row that lost its five appended fields or its numeric sequence can never be claimed, presented, or named by an --ack-through cutoff, yet it still counted as queued, wedging the queue permanently. The guard now counts only the rows the calling actor can itself present or retire, and a main drain retires unusable rows under the queue lock, reporting them in bounded escaped form before removal so the evidence survives for the separate row-generating defects. A retirement failure is reported loudly and never suppresses unrelated consumable work. A main drain whose remaining rows are all branch-held says so in one bounded line instead of exiting silently. Grant row-list and owner-record reads move into fm-wake-lib.sh so the drain, the grant publisher, and the guard share one implementation. Ownership is unchanged: a branch drain still touches nothing outside its grant and never retires a row, and main still cannot present or acknowledge an active grant. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GghGvsa4JDB1E5FuznX2i1 * no-mistakes(test): keep SIGTERM-safe arithmetic in wake queue retirement pass * no-mistakes(review): add guard advisory for branch-held wake rows * no-mistakes(document): document per-actor wake counting and unusable-row retirement * no-mistakes(ci): Addressed the Greptile P1 on bin/fm-wake-lib.sh:1840 ("Unreadable queue suppresses alarms"). Root cause: fm_wake_actor_pending_count inferred "the queue could not be counted" only from awk's printed output (`case "$count" in ''|*[!0-9]*) count=1`). That relies on awk aborting before its END rule when the input cannot be opened. An awk that reaches END after a failed open prints `0`, which the fallback accepts as a genuine count; both actor counts then read zero and bin/fm-guard.sh emits neither the queued-wake warning nor the branch-held advisory for a queue nobody proved empty. Fix (bin/fm-wake-lib.sh:1828,1835): both counting awk invocations now set `count=''` on a non-zero awk exit status, so the existing "cannot be counted => report a pending row" fallback is driven by awk's exit status instead of an implementation-defined detail of what it printed. No new code path or behavior; the pre-existing fallback just becomes unconditional. Comment updated to state why. Regression test (tests/fm-wake-queue.test.sh: test_uncountable_queue_still_raises_the_pending_alarm, registered in the run list): runs the real bin/fm-guard.sh against a non-empty, unreadable queue with a PATH-injected awk emulating an END-running implementation (prints 0, exits 2; execs the real awk otherwise) and asserts "queued wakes pending" is still emitted; disconfirming half asserts the same fake awk over a readable, provably empty queue stays silent. Fails on the pre-fix library ("not ok - a queue that could not be counted silenced the queued-wake alarm"), passes after. Verified locally: bin/fm-test-run.sh tests/fm-wake-queue.test.sh -> 0 failed; tests/fm-guard-stale-banner.test.sh + tests/fm-watcher-lock.test.sh -> 0 failed; bin/fm-lint.sh (ShellCheck 0.11.0 + actionlint 1.7.12) clean. Caveat reported honestly: on the awks available/known here (mawk locally, plus gawk and BWK/macOS awk, all of which treat an unopenable input as fatal and skip END) the alarm was not actually suppressed - I reproduced the unreadable-queue case and the warning fired. The change removes the code's dependence on that awk detail rather than repairing an outage observed on this platform. Both intent constraints still hold: every counted row remains presentable or retirable, and no alarm-suppressing path was added --------- Co-authored-by: Alex William <[email protected]> Co-authored-by: Claude Opus 5 <[email protected]>
* fix(bin): derive watcher beacon staleness grace from poll cadence Port of upstream kunchenguid/firstmate kunchenguid#3946, adapted: the fork has no away-mode daemon predicate, so only the shared derivation and its two in-scope readers change. fm-claude-stop-autoarm.sh required the watcher beacon fresh within the flat FM_GUARD_GRACE default (300s), but a healthy watcher touches the beacon once per cycle and can legitimately age up to FM_POLL seconds between touches, so a long-poll home reads stale mid-wait and the hook misjudges a live cycle as down. fm-wake-lib.sh gains fm_poll_derived_grace, the single owner of the max(300, FM_POLL + 60) formula. fm-watch.sh's own pre-acquisition beacon-staleness check and the auto-arm hook both derive their default grace from it, and the hook now exports its resolved FM_GUARD_GRACE to the fm-watch-arm.sh invocations so arm and check agree on one value. * fix(bin): count only actor-presentable wake rows and retire unusable rows Port of upstream kunchenguid/firstmate kunchenguid#3950, adapted to the fork's SCOPED drain and OMP branch-grant machinery. A branch grant already excluded its rows from a main drain, but fm-guard.sh still counted every queued row as pending for the calling actor, so main was told to run a drain that could only print nothing for as long as the branch held the grant. And a queue row that lost the five appended fields or its numeric sequence was counted as queued while it could never be claimed, presented, or named by an --ack-through cutoff, wedging the queue permanently. fm-wake-lib.sh gains the shared per-actor helpers: fm_wake_grant_rows_valid, fm_wake_branch_owner_matches, fm_wake_branch_grant_live, and fm_wake_actor_pending_count - the last reports a pending row when a queue exists but cannot be counted, so an unreadable queue still raises the alarm. fm-wake-drain.sh and fm-wake-grant.sh now delegate their grant row-list and owner-record reads to the library. A main drain retires structurally unusable rows under the queue lock and reports them verbatim (a branch drain never does), and a main drain left with only branch-held rows names the holder instead of exiting silently. fm-guard.sh warns only for rows the calling actor can itself present or retire, and gives main a distinct held-by-branch advisory when that is the whole non-empty queue. tests/fm-wake-queue.test.sh covers the branch-held warning boundary end to end, the uncountable-queue alarm, and main-only retirement. * fix(bin): gate secondmate wake-loop stall alerts on real queue no-progress Port of upstream kunchenguid/firstmate kunchenguid#3943, which lands the detector's final form on this fork (the fork had no foreign-queue stall check at all, so the whole feature arrives already fixed). The watcher now reads the oldest structurally valid actionable row in every endpoint-recorded local secondmate home's durable wake queue, and times the interval since that position last changed instead of the row's age. A queue that is draining is not stalled, so a moved oldest row - drain progress, or a queue reprovisioned under the same task id that restarts its sequence anywhere - ends the no-progress episode and starts a fresh observation interval, recorded by state/.secondmate-wake-progress-<task> as the same epoch-sequence row identity the stall receipts use. Declared external-wait pause rows are not actionable evidence, and a mate provably inside an active turn (an exact busy verdict bounded by FM_BUSY_TURN_MAX_SECS) never escalates. One keyed check notification covers each no-progress episode across watcher and handling crashes; the foreign queue is only ever read. FM_SECONDMATE_WAKE_STALL_SECS defaults to 180 and is the backstop behind the active-turn gate, not a substitute for it. Fork adaptation: the parent watcher keeps its secondmate home-beacon rule, so the ported tests give the fixture mate a fresh .last-watcher-beat under its (stubbed or real) clock to isolate the stall detector; assertions are unchanged from upstream. tests/fm-wake-queue.test.sh covers progress tracking, once-per-episode alerting, declared-pause exclusion, reprovisioned-generation reset, active-turn deferral, and marker symlink rejection. * fix(bin): never type doorbells into dead panes; recover them instead Port of upstream kunchenguid#3823, adapted: the fork's task-inbox ring reserves return code 6 for a positively dead or missing endpoint (codes 3-5 are OMP-native and Hermes-lock outcomes here). The doorbell line itself is now a shell no-op (": ...") with quoted, printable-only paths, so even a liveness race that loses to an exiting agent runs nothing in a bare shell. The watcher escalates a dead/missing endpoint's unhandled record once through the ordinary stale wake - over stale busy-state evidence - instead of walking the re-ring ladder, and fm-send reports the skipped doorbell as recovery, not a re-ring. Remote secondmate send inherits the rc-6 recovery notice through fm-send without a new branch. Secondmate restart also resolves all arrived persist answers before any timeout decision and rechecks at the decision boundary, so a reply landing at the deadline wins over the fallback nudge. Regression coverage: doorbell shell-noop across real shells, control-byte path rejection, dead/missing ring skip, watcher escalate-once-without- ringing, dead-pane override of stale busy state, and the resolution/timeout boundary race. Fake tmux inventories across the suite now list recorded windows and answer pane_current_command so the recovery-grade endpoint check exercises real paths. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(omp): prove the doorbell turn instead of trusting triggerTurn The task-inbox doorbell claimed `.delivered` the moment sendMessage returned, but OMP can downgrade `triggerTurn` to append-only delivery on an idle, non-streaming session: the steer was accepted and reported received while no turn ever ran, leaving an idle worker stranded with an unhandled durable record. The extension now renames an accepted request to `.awaiting-turn` when no turn is open and settles it to `.delivered` only on a `turn_start` or `agent_start` proving the turn actually began. A steer that lands while a turn is open is still delivered immediately, since it joins that turn. When the bound passes with no turn, the extension re-drives the same instruction through `sendUserMessage` - a user prompt an idle session cannot defer - and a failed re-drive reports `.failed` rather than stranding silently. Requests left `.awaiting-turn` by a dead generation re-queue as `.pending` on the next activation. Installs on runtimes without the event or user-prompt surface keep the prior accept-only semantics. On the shell side, `fm_omp_task_doorbell_request_existing` reports an awaiting-turn request as in-flight, so fm-send honestly reports a downgraded doorbell as queued (exit 4 semantics) rather than received while the extension's own recovery still wakes the worker. Regression coverage drives the downgrade end to end: an accepted sendMessage with no turn event stays unproven, the bounded grace re-drives the identical instruction through sendUserMessage exactly once, a firing turn_start settles without any re-drive, an open turn delivers the steer immediately, a failing re-drive reports failed, and a dead generation's unsettled proof re-enters delivery on activate. The suite's tmux fake also now lists the recorded task window so the recovery-grade endpoint check exercises the live path instead of classifying the fixture missing. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(bin): bound detached procevent runners to their owning home's lease A runner is detached into its own process group so it survives the turn that started it, and on its own that lets a runner outlive its whole home: once reparented to init, nothing bounds its lifetime, so a blocking source child - and everything it spawns - can poll forever after the home that owns the work is gone. This is the upstream kunchenguid#3904 port, adapted to the fork's simpler procevent (no extension subsystem or capture reservations). Every claim now records the canonical physical state root with its device, inode, owner, and mode, and every claimed runner spawns a detached owner guard in a separate process group. The guard re-reads the recorded root's .owner-lease marker - refreshed by register, handled, reconcile, sweep, and an attached start's keepalive - and after two consecutive checks cannot prove both the root identity and a fresh lease, it signals the runner's whole process group. Runner descendants inherit FM_PROCEVENT_IN_RUNNER so they cannot keep their own lease alive; a confused agent that deliberately strips the marker is out of scope. Reconcile no longer signals a leaderless surviving group: once the leader is gone, PID/PGID reuse makes the group's provenance unprovable, so the claim stays owned and uncertain instead of risking a foreign group or a second poller on one canonical source. Retirement and reconcile take their signal through an identity-and-leadership-gated group path, and a launch floor paces relaunches per registration generation so a crash-looping source cannot spin. Fork deviations from upstream: the state-root check requires ownership and canonicality but not a private mode (operational homes use group-readable state roots), the serialized launch-floor section releases the source lock at the stamp write because this caller holds no further locked work, central storage keeps its distinct commit point, and the usage window is widened to keep the durability-boundary line visible. Regression coverage: an orphaned runner's group is stopped by its guard after the home's lease expires, a crashed leader's ambiguous group is preserved rather than signalled or replaced, and the registration replacement test now waits for the old generation's source to actually start so the launch-floor supersede check cannot eat the race. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(omp): latch a provider-broken branch with a bounded cooldown probe A settled branch prompt whose last assistant message carries stopReason "error" is a provider failure OMP reports on the message instead of rejecting prompt(), so the old code never latched: every later wake kept paying for a predictably broken branch turn before its settlement could reject to main. Port of upstream kunchenguid#3497, adapted to the fork's extension shape (generation-only guards, offer.accept(promise) settlement). Two consecutive settled provider errors now latch the branch off and merge a captain-facing health note. While latched, main keeps every wake except one recovery probe after each cooldown, which starts at five minutes and doubles to a one-hour ceiling; a probe that ends in a durable fm_branch_report clears the latch with a second note, and a failed probe reschedules by the current cooldown. A settled prompt that produced no durable outcome now rejects its settlement instead of silently claiming its granted wake rows. The branch record keeps its SessionManager so the settled-prompt scan can read only the entries the prompt appended. The strict typecheck also caught two stale errors from the earlier doorbell work: the doorbell options builder returned a Required<> literal missing turnGraceMs, and its `on` property signature could not accept the runtime's overloaded event subscription - the latter is now a method declaration so the parameter stays bivariant. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(omp): start a fresh supervision branch conversation per main session Port of upstream kunchenguid#3600. A branch conversation that outlives its main session keeps reasoning from an older thread's accumulated memory, which competes with today's generated prompt and current fleet rules. The OMP extension kept one persistent conversation keyed on a durable pointer, so /new, /resume, /fork, and reload all reopened the stale thread. The branch record is now scoped to the extension generation: createBranch reopens only a conversation it built under the current generation, and both session_start and session_switch advance the generation, drop the live handle (beginDispose + dispose), and re-anchor the mirror so the fresh branch receives the new main session's dialog from its start. The durable outcome store, not the conversation, carries unacknowledged outcomes across the boundary. The on-disk pointer remains a record for operators and the effort picker's model lookup, not a reopen source. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(omp): give the supervision branch main's live model registry Port of upstream kunchenguid#3871 by equivalent mechanism. A provider an extension registered into main's runtime at run time is invisible to a freshly discovered registry, so pinning or following such a model built a branch that could not resolve its own model. OMP's createAgentSession already takes a modelRegistry option, so instead of upstream's provider-by-provider config copy into an isolated ModelRuntime, the branch session now receives main's live registry directly - read-only sharing: the branch never installs, converts, or overwrites credentials or registrations. The resolve and picker paths already read that same registry, so the build, the pin resolution, and the picker now agree on one model catalog. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(bin/omp): route decision-owned signal and stale wake batches to main Port of upstream kunchenguid#3776. A needs-decision status append, a captain-held status transfer surfaced through the no-verb signal path, or a blocked pending-reply escalation is owned by the captain and must stay on main. The previous logic only forced the check-kind class to main, so a coalesced signal batch that also contained routine rows could end up split: the decision row to the branch, the rest to main, which loses the single-actor ordering the per-actor acknowledgement contract depends on. The bash side now: - `status_span_first_actionable_record` returns a side-band flag when its span carries a needs-decision, a captain-held declaration, or a pending- reply escalation, without changing the event text it already returns. - `signal_files_actionable` surfaces those files (even when the captain-held line is otherwise non-actionable) and populates `FM_SIGNAL_NEEDS_DECISION_FILES`. - The watcher appends the row payload as `needs-decision:$files` for exactly the flagged files; other files in the same batch keep the ordinary reason. The OMP dispatch side now: - `scopeForUnreadWake` parses each mapped task's `.status` log to detect an open needs-decision or a current captain-held declaration, and excludes those rows from `eligibleSeqs` while populating `needsDecisionKeys`. - `offerWakeToBranch` in `fm-primary-omp.ts` cross-references the current signal or stale trigger keys against every unread decision-owned row by task identity: any overlap forces the entire coalesced batch to main. - Heartbeat handling remains independent, and a decision-owned row in one task does not affect eligibility for other tasks. Also fixed a pre-existing full-lint `SC2031` info note in `tests/fm-afk-launch.test.sh` by disabling it file-wide, so the canonical lint run is green again. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(core/omp/pi): settle watcher delivery on runtime acceptance, consume on turn start Port of upstream kunchenguid#3513. A follow-up queued while main is streaming joins that run as a user message without raising before_agent_start, so waiting for the model to consume the wake stalled the successor chain: no successor started, later wakes were not delivered, and the turn-end guard re-armed by hand. The shared core now: - Treats sendFollowUp resolution as delivery; consumption is tracked only to let a session replacement replay a wake the runtime accepted but had not yet read. - Keeps accepted-but-unconsumed wakes in a per-generation unconsumedWakes map keyed by the pending token. - Consumes a wake when the runtime starts a turn carrying the exact wake text: before_agent_start for an idle main, message_start for a streaming main. - Does not mark a pending row delivered or finish cleanup until the wake is consumed or the branch owns it. - Skips over unconsumed rows when picking the next pending record, so the successor chain keeps moving while waiting for a streaming main to read the prior wake. - Defers a verified successor's failure close when the pipeline is still delivering the wake it was started for; the retry runs once that delivery settles. - Adds armRetired so a child the core itself killed does not earn a deferred retry. The Pi and OMP adapters both gain a message_start handler that extracts the user message text and passes it to watch.acknowledgeWake. Documentation in docs/omp-supervision-branch.md now states the delivery versus consumption boundary for main fall-back follow-ups. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * no-mistakes(review): Make supervision provider latch recoverable after transient failures * no-mistakes(review): Correlate doorbells and latch rejected supervision prompts * no-mistakes(review): Correlate doorbell turn proofs and recover prompt failures * no-mistakes(review): Correlate synchronous turn proofs to each doorbell dispatch * no-mistakes(review): Correlate turn proof and redrive uncorrelated doorbells * no-mistakes(test): Fix procevent sweep claims and OMP turn handler coexistence * no-mistakes(test): Preserve claim-only sources for reliable home sweeps * no-mistakes(test): Disabled unreliable turn observation for generated OMP workers * no-mistakes(document): Updated stale branch-session documentation * no-mistakes(review): Enforce state-root identity before ownership and stale-claim decisions * no-mistakes(review): Requeue unreadable awaiting-turn requests for redelivery * no-mistakes(document): Correct stale supervision and process-event verification docs --------- Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Intent
A wake row that is counted as queued but not presented by
bin/fm-wake-drain.shcan never be acknowledged, permanently wedging the queue and repeatedly waking supervision.This was measured on 2026-09-07 in the fmverif second-mate home.
bin/fm-wake-drain.shprinted onlyWARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.with no presented row and noWAKE_ACK_REQUIREDcommand.The queue itself still contained this row:
1788792074<TAB>574<TAB>stale<TAB>fleet:w2:p3<TAB>stale: fleet:w2:p3 (paused 7227s, awaiting external - declared pause, rechecked on a long cadence not a wedge; confirm the wait still holds).Determine why this counted row is omitted from presentation and make the invariant true: every row counted in the pending-warning condition must either be presented with an executable acknowledgement path or be retired from the queue.
Do not assume the proposed cause; verify whether stale-row type, stopped endpoint, changed recovery generation, supervision-branch ownership, or another filter explains the divergence.
This is distinct from the existing monitoring defects that generate stale rows too often or escalate a declared external wait; this task owns the drain behavior after a row already exists.
What Changed
bin/fm-guard.shnow counts queued wakes per actor via a newfm_wake_actor_pending_counthelper inbin/fm-wake-lib.sh, so the "queued wakes pending - drain them" warning only fires for rows the calling actor can actually present or retire; a non-empty queue whose rows are reserved by a live supervision-branch grant instead raises a distinctNOTICEnaming the branch as holder and saying not to drain from there.bin/fm-wake-drain.shretires rows that can never be consumed: under the queue lock, a main drain drops rows missing the five appended fields or a numeric sequence, reports the count plus the removed rows verbatim (first 20, then a remainder count), and treats a failed repair as non-fatal so usable rows are still presented; a branch drain never retires. A main drain left with nothing of its own also prints a boundedWAKE ROWS HELD BY SUPERVISION BRANCHline with the held sequences instead of exiting silently.bin/fm-wake-drain.shandbin/fm-wake-grant.shinto sharedfm_wake_grant_rows_valid/fm_wake_branch_owner_matches/fm_wake_branch_grant_livehelpers;tests/fm-wake-queue.test.shadds two cases driving guard and drain together (branch-held row raises the advisory and becomes presentable and acknowledgeable once the grant clears; unusable rows are retired by main alone while remaining rows stay acknowledgeable), anddocs/architecture.mdanddocs/watcher-continuity.mdrecord the per-actor counting and retirement contract.Risk Assessment
✅ Low: The change is well-bounded and lock-protected: the riskiest element (irreversible row retirement) is main-only, runs under the queue lock, reports what it removed, and never fails the drain, while the guard narrowing provably cannot silence a non-empty queue since main's and the branch's counted sets partition every queued row — and both behaviors are pinned by new tests that drive the real scripts.
Testing
Exercised the wake-queue, guard-stale-banner, branch-supervision and pi-branch-extension suites (all passing), proved both new tests fail on the base commit and pass on the target, and captured a before/after CLI transcript that replays the reported fmverif field row end-to-end: pre-fix the guard tells the operator to drain while the drain presents nothing and the queue stays wedged; post-fix the branch-held row raises a distinct "do not drain them from here" advisory with the drain naming the holder, and once the grant is released the same row is presented with an executable
--ack-throughcommand that empties the queue, while a structurally truncated row is retired with its content reported verbatim. This change has no UI surface — it is entirely stdout/stderr from shell CLIs — so the reviewer-visible evidence is the operator-facing terminal transcript rather than a screenshot.Evidence: End-to-end CLI transcript: reported field state, before vs after the fix
Source: End-to-end CLI transcript: reported field state, before vs after the fix
Evidence: Regression proof: new tests fail on base commit, pass on target commit
Source: Regression proof: new tests fail on base commit, pass on target commit
Evidence: Reproduction script used to generate the transcript (runnable against any tree)
Source: Reproduction script used to generate the transcript (runnable against any tree)
Evidence: Key contrast — the reported field state, one stale row held by a live supervision-branch grant
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
🔧 **Rebase** - 6 issues found → auto-fixed ✅
bin/fm-wake-lib.sh- merge conflict rebasing onto origin/mainbin/fm-watch.sh- merge conflict rebasing onto origin/maindocs/architecture.md- merge conflict rebasing onto origin/maindocs/configuration.md- merge conflict rebasing onto origin/maintests/fm-pi-branch-extension.test.sh- merge conflict rebasing onto origin/maintests/fm-wake-queue.test.sh- merge conflict rebasing onto origin/main🔧 Fix applied.
✅ Re-checked - no issues remain.
🔧 **Review** - 1 issue found → auto-fixed ✅
bin/fm-guard.sh:189- Suppressing branch-held rows from the guard count removes the only always-on alarm for a grant that is never released, so such a row can stay unacknowledged indefinitely with no automatic signal. Concrete sequence: the watcher wakes, the Pi extension calls activateEligibleRowsOwner(process.pid, gen) and writeEligibleRowsSnapshot for seq N (.pi/extensions/fm-branch-supervision.ts:879,1402), thenawait session.prompt(...)(line 1416) never settles - there is no timeout or abort anywhere in that file, and releaseEligibleRowsSnapshot runs only after a settled prompt (line 1437) or in the rejection handler (line 1442), neither of which fires. The owner pid is the live Pi process, so fm_wake_branch_grant_live stays true forever. From then on every guarded command in the captain's main session takes this line, fm_wake_actor_pending_count main returns 0 because seq N is reserved, and the queued-wakes warning that previously fired on every guarded command goes silent. The branch actor's own warning is suppressed by design (line 267), and bin/fm-watch.sh's secondmate_wake_stall_tick only inspects foreign secondmate homes ($home/state/.wake-queue), not the captain's own queue - so no channel alarms. print_branch_held_notice (bin/fm-wake-drain.sh:119) surfaces it only if someone manually runs a drain. This is a deliberate consequence of the stated invariant (uncounted rows satisfy it vacuously) and is documented in the header here and in docs/watcher-continuity.md, but it trades an always-on alarm for a pull-only notice. Flagging as ask-user rather than auto-fix because the remedy is not a correction of what the change does: bounding a grant's lifetime, or alarming on a grant older than some threshold, needs new durable state and a new timer, which extends the change beyond its stated intent. Confirm whether losing the automatic alarm for an unreleasable grant is acceptable.🔧 Fix: add guard advisory for branch-held wake rows
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-wake-queue.test.sh(full suite, exit 0) — includes the two new casestest_main_is_never_told_to_drain_rows_only_the_branch_ownsandtest_unconsumable_rows_are_retired_instead_of_wedging_the_queuebash tests/fm-guard-stale-banner.test.sh(exit 0) — fm-guard.sh changedbash tests/fm-branch-supervision.test.sh(exit 0)bash tests/fm-pi-branch-extension.test.sh(exit 0)Regression proof: extracted both new test functions verbatim and ran them against a cleangit archive ffd2c899export — both fail pre-fix (not ok - main drain went silent instead of naming who holds the queued rows,not ok - main drain did not report the rows it retired)Manual end-to-end CLI reproduction (wake-drain-invariant-repro.sh) drivingbin/fm-wake-grant.sh,bin/fm-guard.shandbin/fm-wake-drain.shagainst base and target trees: scenario A replays the reportedstale fleet:w2:p3 (paused 7227s, awaiting external ...)row under a live branch grant; scenario A2 releases the grant leaving the row otherwise identical; scenario B queues a structurally truncated row beside a usable one, then acknowledges through to an empty queueAGENTS.md:135- Judgment call, no action taken: AGENTS.md:135 still describes state/.wake-queue as "durable queued wakes retained until post-handling acknowledgement", while a main drain now also retires structurally unusable rows without an acknowledgement. I left it unchanged deliberately - AGENTS.md is always-loaded and its size discipline forbids conditional detail, the line's own five-field format already implies the shape a retired row lost, and the exception's authoritative owner (docs/watcher-continuity.md "Per-actor acknowledgement") now states it in full. Flagging only so the omission is a visible decision rather than an oversight.✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.