Repository navigation
Conversation
|
…ssor blocks A handling successor skips recovery re-announcement, so a row another writer appends to the home's own wake queue while it blocks (a captain inbox note, a mail or contributions check) waited for an unrelated event before the primary saw it. Every actionable exit now records the queue sequence it handed over, and each poll surfaces a still-queued row above that record once as "check: undelivered queued wake: <keys>". Drain and acknowledgement semantics, the recovery marker, and away-mode one-shot behaviour are unchanged.
Replace the grant-coupled handover record with a narrower rule. Only a check: close advances the record, because a check trigger always reaches main while attended and main's drain presents every row it can claim. A signal, stale, or heartbeat close may be taken by a supervision branch that presents only its granted rows, so it leaves the record alone, and the watcher surfaces only check rows, the only kind other writers append. A note queued just before a branch-taken close therefore still reaches main once, the branch's own signal row is never announced to main, and the record only moves forward, so no row is surfaced twice. The grant script, the supervision host, and the Pi branch extension return to their main versions.
76ad24f to
acbe866
Compare
|
This PR fixes #5967 (inbox notes waiting in the wake queue until the watcher cycle closes for another reason). Could a maintainer approve the fork workflow runs? CI and Require no-mistakes are both at action_required, so the required checks have not run yet. No check waiver is requested. |
|
Speaking as Kun's firstmate: First stamp this fetch vs tip HEAD contract-class: restore — concrete existing inbox-note→check-row→primary-attention path broken for idle primary behind a handling successor; not a new always-on observer class. VISION: restart/queue durability (obligations closed by durable events); scripts own mechanics; peace of mind (notes do not sit silent); away-mode one-shot unchanged (afk gate). Fork CI + Require no-mistakes runs on tip approved this pass ( |
|
Speaking as Kun's firstmate: Correction vs tip Attestation MATCH (body |
|
Independent before/after check of this change, in case it helps review. Disposable scratch homes only, synthetic fixtures (one empty task record so the home needs supervision, crew events appended to a status file, notes filed with Reproduces on main. Idle primary whose live watcher is a handling successor (any idle period after the first wake of a session):
On the Claude path about 11s of each figure is the attached arm's confirmation wait after the watcher exits, which is the same on main for every wake kind. Other cases, same on both unless noted:
Two small costs observed, both consistent with the accepted cost in the description:
Adjacent, not caused by this PR: in a home with nothing in flight the Stop hook arms no watcher ( Tests: 73 behaviour scripts (the runner's Not exercised: host-on supervision, OpenCode/omp adapters, away and quiet modes, real Pi and Codex binaries. |
|
Speaking as Kun's firstmate (an automated assistant, posting publicly). This is waiting on you, the author. It is not a captain hold. What changed since my last stamp (2026-09-29): the head moved from What the tip does (my reading vs main contract-class: restore. This is my own reading, not the PR's label. On main, VISION (per rule):
Gates on this head (
What unblocks it: bring the branch up to current main (merge or rebase) and re-raise it with |
|
Tested this locally on macOS ARM in isolated scratch homes, without touching the live primary or Herdr lifecycle (context: #5967, where I reported 15–20 min delays for phone-bridged inbox notes on a Pi + Herdr primary). I started the real Results over three runs each:
I also ran the focused suites on the PR head — I did not find an issue in the tested watcher/inbox layer. This is not a full live Pi-primary or Herdr lifecycle test, but it directly reproduces the handling-successor mechanism behind the delayed queued-note behavior. The PR base is behind main, so a rebase plus a fresh CI run is probably the next step. Thanks, @mcka. |
Intent
Captain inbox notes (
bin/fm-inbox.sh note) are saved and announced by appending onecheckrow to the home's durable wake queue; nothing else tells the primary the row exists.A plain watcher notices such an append, because every queue append republishes the recovery marker as pending downtime and
resurface_after_downtimeturns that into acheck: rearm-resurfaceexit.A handling successor does not: it is the watcher the Claude Stop hook and the Pi/omp/OpenCode adapters start before delivering an actionable wake, and it deliberately skips
resurface_after_downtimeso a lost handshake cannot become an unbounded re-announcement loop.Nothing else in its cycle looks at its own home's queue, so on an idle primary a note waited until an unrelated event (a crew signal, a heartbeat, a stale pane) made the watcher exit, or until the operator typed again.
In a live home, four notes queued over four minutes sat unread while the watcher beacon stayed fresh.
The same gap applies to every other writer that appends to the home's own queue from outside the watcher: mail and contributions checks, the deferred startup network stage, merge outcomes, process-event results.
Reproduction, in a scratch home with
FM_POLL=1: startbin/fm-watch.sh, wait for its poll loop, runbin/fm-inbox.sh note "hello"against the sameFM_HOME, and watch for six seconds.A plain watcher exits with
check: rearm-resurface; a handling successor (FM_WATCH_HANDLING_SUCCESSOR=1) keeps blocking with the note queued, whatever the recovery marker's state.Requirements: while the watcher blocks, an undelivered row another writer appends to its own home's queue makes it exit within one poll; the same row never causes a second exit; drain and acknowledgement semantics, the recovery marker, the handling successor's no-re-announcement rule, secondmate foreign-queue observation, away/quiet daemon mode, and other harnesses stay unchanged; the per-poll cost stays trivial.
Design: a forward-only record,
state/.watch-queue-handed, of the queue sequence already handed over.Only a
check:close advances it, because a check trigger always reaches main while the captain is attended and main's drain presents every row it can claim (in the away posture the supervision branch takes check rows itself).A signal, stale, or heartbeat close may be taken by a supervision branch that presents only its granted rows, so it leaves the record alone.
Each poll surfaces only
checkrows above the record, the only kind other writers append, leaving out rows a live branch grant holds or main's last drain already claimed; the watcher's own signal, stale, and heartbeat rows reach their actor through their own close.So a note queued just before a branch-taken close still reaches main once, a branch's own signal row is never announced to main, and no row is surfaced twice.
An earlier revision of this PR coupled the record to branch grants through
bin/fm-wake-grant.sh, the supervision host, and the Pi branch extension; each review round found a new edge case in that coupling, so it was replaced by this narrower rule, and those files are unchanged from main.Alternatives rejected: having
fm-inbox.shtouch an input the watcher already scans would fix only notes, and extending recovery re-announcement to handling successors would reopen the loop successors exist to avoid.Accepted cost: if a note races a close that main takes, the next successor can surface it once more before main's drain claims it, one extra main turn per row at most.
What Changed
bin/fm-watch.shaddsqueue_handover_surface, run once per poll right afterresurface_after_downtime. It surfaces onecheck: undelivered queued wake: <keys>wake for check rows that another writer (such as a captain inbox note) appended to the home's own queue and that no actor has picked up yet. Before this, a handling successor that never re-announced recovery left those rows waiting unread. It does nothing while the away-mode daemon owns triage, and when no append has happened it costs two builtin reads.bin/fm-wake-lib.shaddsfm_wake_seq_read, the forward-onlystate/.watch-queue-handedrecord (watch_queue_handed_read/watch_queue_handed_write) andfm_wake_keys_after_locked. Rows above the record count unless a live branch grant holds them or main's last drain claimed them. A counter read of 0 means "unknown", so it never lowers the record. The record only resets when a positive counter falls below it.wake()inbin/fm-push-transition-lib.shnow advances the handover record only oncheck:closes. Signal, stale and heartbeat closes leave it alone. The new record is documented indocs/watcher-continuity.mdand the operational-home-layout skill.tests/fm-watch-recovery-loop.test.shgets regression cases for: one surface per row, the away-mode exclusion, a note queued just before a signal close, rows main already claimed, and torn counter reads.Risk Assessment
✅ Low: The change is a small addition that stays within the stated scope. I found no reachable path that loses or double-delivers a row. Every watcher close that appends a check row is prefixed
check:, so it advances the record; acks re-claim only rows at or below their cutoff, so the main-claimed exclusion cannot hide an unpresented note; drain/ack, the recovery marker, the successor no-re-announce rule, and away mode are unchanged; and the new tests drive the real watcher, inbox and drain scripts instead of grepping source.Testing
I ran the focused watcher recovery-loop suite on the branch and all 7 cases passed. I also ran it against the base watcher code: the new foreign-append test fails there, which confirms the regression tests catch the missed wake. The wake-queue, supervision-events and inbox suites all passed, so drain/ack, grant and inbox behavior are unchanged. A manual run of the real watcher and the realbin/fm-inbox.sh noteshowed the successor exiting within 1s withcheck: undelivered queued wake: inbox:<id>. A restarted successor kept blocking for the same unacknowledged note, the durable queue stayed untouched, and the away-mode watcher left the note to the daemon. One leftover: the/tmp/fm-base-repro.X49AUascratch copy from the reproduction run is still there because myrm -rfwas denied. It is outside the worktree, and the worktree is clean.Evidence: End-to-end CLI transcript: an inbox note wakes a handling successor once
Source: End-to-end CLI transcript: an inbox note wakes a handling successor once
### 2. captain runs: bin/fm-inbox.sh note 'please look at the release notes' queue rows now: 1 check inbox:1791199376-teGNw1 watcher exited after 1s with wake line: > check: undelivered queued wake: inbox:1791199376-teGNw1 state/.watch-queue-handed = 1 state/.wake-queue.seq = 1 ### 3. restart a handling successor with the same note still queued (unacknowledged) watcher pid 80323 still blocking after 4s: the same row did NOT cause a second exit ### 4. away mode (state/.afk present): a new note is left to the daemon away-mode watcher still blocking 4s after the note: left to daemonEvidence: Demo driver script used for the transcript
Source: Demo driver script used for the transcript
Evidence: Recovery-loop suite on the branch (all pass)
Source: Recovery-loop suite on the branch (all pass)
Evidence: Recovery-loop suite against base watcher code (reproduces the missed wake)
Source: Recovery-loop suite against base watcher code (reproduces the missed wake)
not ok - a handling successor kept blocking after an inbox note was queued:Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
⏭️ **Rebase** - skipped
Step was skipped.
bin/fm-watch.sh:2104- Accepted design tradeoff, noted for awareness. A captain note can be queued after the predecessor's last queue check and before a signal/stale/heartbeat close. If main (not a branch) takes that close, the handling successor is armed right away by fm-watch-arm.sh and its first poll usually runs before main's fm-wake-drain.sh claims the note into .main-eligible-rows. The successor then exits withcheck: undelivered queued wake: inbox:<id>for a row main's drain is about to present anyway, which costs one extra handling turn. The window is a single poll, the outcome is an extra wake rather than a lost one, and the reviewed design deliberately leaves non-check closes alone (T5 encodes this). No change needed.bin/fm-watch.sh:2107- queue_handover_surface reads .wake-queue.seq intolast, then callswatch_queue_handed_read handedwith no counter argument, so the counter is read a second time. The quiet path is three builtin reads, not the 'two builtin reads' its comment claims. Passing the value already read (watch_queue_handed_read handed "$last") drops the extra read and makes the comment accurate. Behavior is the same: a 0 counter still skips the reset check and returns early.✅ **Test** - passed
✅ No issues found.
bash tests/fm-watch-recovery-loop.test.shon the branch: all 7 cases pass, including the 5 new ones (foreign append surfaced once, away mode leaves it to the daemon, a note that races a signal close, a note already claimed by main's drain, and a torn counter read)Bug reproduction: ranbash tests/fm-watch-recovery-loop.test.shin a /tmp export of HEAD with the base (f470a01) versions ofbin/fm-watch.sh,bin/fm-wake-lib.shandbin/fm-push-transition-lib.sh. It fails with 'a handling successor kept blocking after an inbox note was queued'bash tests/fm-wake-queue.test.sh(drain/ack semantics): passesbash tests/fm-supervision-events.test.sh(supervision branch and grant interplay): all assertions passbash tests/fm-inbox.test.sh: passesManual end-to-end transcript (inbox-note-wakes-successor-demo.sh) using the realbin/fm-watch.shwith FM_WATCH_HANDLING_SUCCESSOR=1 and the realbin/fm-inbox.sh note. Checked: exit within 1s carrying the inbox key, no second exit while the note is still unacknowledged, durable queue unchanged, and no exit in away mode✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.