Skip to content

fix: bound remote supervision calls to keep the watcher responsive - #3

Merged
earljman merged 10 commits into
mainfrom
fm/fm-watch-remote-bound
Sep 30, 2026
Merged

earljman merged 10 commits into
mainfrom
fm/fm-watch-remote-bound

Conversation

@earljman

@earljman earljman commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Intent

Bound the watcher's remote second-mate calls so a thrashing or unreachable host cannot stall the supervision beacon.

Context: on 2026-09-28 and again on 2026-09-29 the primary firstmate's watcher (bin/fm-watch.sh) went stale past its 300 s grace while one of its per-cycle remote calls to a registered remote second mate (over bin/fm-on.sh / ssh) ran for 5-7 minutes, first because the MacBook host was swap-thrashing at load 176 and later because that host was down ("Host is down"). The remote secondmate liveness tick, the remote-reply mirror read, and the contributions poll each ran without a local time bound, so the beacon was not refreshed between mates, the Stop-owned auto-arm then exited 2 as failed-suppressed on every turn end, and the only documented remedy, a single TERM to the watcher, was refused by the harness. Supervision of the local fleet and of healthy remote mates degraded for the duration each time.

What Changed

  • Add a configurable 60-second local deadline for remote supervision calls, covering liveness probes and relaunches, crew-state reads, pending replies, reply mirroring, and public followups.
  • Refresh the watcher beacon between supervision operations; treat timeouts as ambiguous, preserve retryable remote results, and log liveness timeouts once per episode.
  • Document deadline and beacon behavior and add regression coverage for hanging hosts, partial responses, timeout settings, and continued healthy-mate supervision.

Risk Assessment

✅ Low: The changes reuse existing timeout machinery, preserve ambiguous remote outcomes and retained replies, and refresh the beacon between bounded operations without introducing a substantiated material defect.

Testing

Targeted timeout checks and five live product scenarios passed using isolated local transports. The initial reply fixture refusal was corrected and its rerun passed. CLI evidence was captured, fixtures were cleaned up, and no UI surface was involved.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Monitor stalled mates while reaching healthy mates; reject partial dead responses and reset timeout episodes after recovery ✅ pass live Watcher progress and timeout recovery
Bound a stalled reply read without claiming freshness, then deliver queued replies and reports exactly once ✅ pass live Reply delivery and persisted cursor
Poll contributions through a stalled transport and retain the pending result for reconciliation ✅ pass live Contributions timeout retains result
Read a partial or unreachable remote endpoint as unknown while recognizing a responsive idle mate ✅ pass live Remote state classification
Reject invalid deadlines before execution and preserve bounded command output and exit status ✅ pass live Deadline validation and output preservation
Evidence: Watcher progress and timeout recovery

Source: Watcher progress and timeout recovery

b observe 1
a observe 0
c observe 0
healthy observe 0
a state 0
b state 0
c state 0
healthy state 0
b observe 1
a observe 0
c observe 0
healthy observe 1
a state 0
b state 0
c state 0
healthy state 0
b observe 0
a observe 0
c observe 1
healthy observe 0
a state 1
b state 0
c state 0
healthy state 0
b observe 0
a observe 0
c observe 0
healthy observe 0
a state 0
b state 0
c state 0
[2026-09-30T02:42:25-0500] secondmate a liveness: remote probe timed out; endpoint unreachable/ambiguous; route preserved on lab-host
[2026-09-30T02:42:27-0500] secondmate b liveness: remote probe timed out; endpoint unreachable/ambiguous; route preserved on lab-host
[2026-09-30T02:42:29-0500] secondmate c liveness: remote probe timed out; endpoint unreachable/ambiguous; route preserved on lab-host
[2026-09-30T02:43:03-0500] secondmate a liveness: remote probe timed out; endpoint unreachable/ambiguous; route preserved on lab-host
[2026-09-30T02:43:06-0500] secondmate b liveness: remote probe timed out; endpoint unreachable/ambiguous; route preserved on lab-host
[2026-09-30T02:43:08-0500] secondmate c liveness: remote probe timed out; endpoint unreachable/ambiguous; route preserved on lab-host
ok - watcher: hanging remote probes stay ambiguous, bounded, episode-deduplicated, and beacon-safe
Evidence: Reply delivery and persisted cursor

Source: Reply delivery and persisted cursor

ok - remote reply: hanging source is locally bounded without advancing freshness
ok - a blocking non-destructive remote delta reaches durable process-event capture
ok - a captured delta is applied, acknowledged, and re-armed without a handler
ok - ingest appends one validated line, fetches its document, and advances the cursor
ok - replayed capture has one deduplicated append and one durable handling identity
cannot retire terminal source; it remains registered: remote-reply-ios
cannot retire terminal source; it remains registered: remote-reply-ios
ok - later generations cannot invalidate an unacknowledged ingested result
cannot retire terminal source; it remains registered: remote-reply-ios
ok - the remote status and decision model mirrors and the cursor advances
ok - a remote mate's new decision folds open exactly as a local mate's does
ok - a replayed mirrored delta is idempotent in both the stream and the cursor
Remote source status records:
done [corr=0123456789abcdef] [at=1700000000]: build verified report=data/reply/report.md
working [corr=1111111111111111]: second generation
done [corr=2222222222222222]: third generation
working [key=version-audit]: family --version audit complete (data/reply/prose-only.md)
needs-decision [key=rough-cut-version]: implement --version or retire the tool
needs-decision [at=1700000000]: which base branch?
needs-decision [at=1700086400]: which base branch?
done [corr=48a0179aab5189ae]: release chain audited

Parent status after handling and replaying generation 4:
done [corr=0123456789abcdef] [at=1700000000]: build verified report=data/remote-secondmates/ios/data/reply/report.md
working [corr=1111111111111111]: second generation
done [corr=2222222222222222]: third generation
working [key=version-audit]: family --version audit complete (data/reply/prose-only.md)
needs-decision [key=rough-cut-version]: implement --version or retire the tool
needs-decision [at=1700000000]: which base branch?
needs-decision [at=1700086400]: which base branch?
done [corr=48a0179aab5189ae]: release chain audited

Committed remote cursor:
schema=fm-remote-reply-cursor.v1
offset=508
prefix_sha256=d5ecf6ae59309ba7dde37317b1fea4e61d2b2888f9c08ab8cc797b0548e2ec34
cannot retire terminal source; it remains registered: remote-reply-ios
ok - transported control bytes are normalized in place and never stop the stream
cannot retire terminal source; it remains registered: remote-reply-ios
ok - payload protocol-field names cannot collide with transport metadata
cannot retire terminal source; it remains registered: remote-reply-ios
ok - NUL bytes are normalized in place before shell line processing
ok - local document storage failures remain retryable until delivery succeeds
ok - a structured pointer must end at its token boundary
ok - adjacent pointers are fetched while malformed tokens remain unchanged
ok - a rejected candidate never gives the following text a false leading boundary
ok - nested remote reports relay while an undeliverable foreign pointer fails open
ok - the reported incident raises no standing decision and still delivers the report
ok - an undeliverable structured offer fails open with one note and never a decision
ok - a remote refusal surfaces its own reason without opening a decision
ok - a failed pointer extraction never commits a partial delta
ok - a failed mirror write never drops status content or advances the cursor
ok - source-line identity survives commit failure and cursor-loss recapture
ok - a mirrored reserved-key line cannot squat or clear the parent's own decision
ok - a reply that arrives after escalation resolves it and clears the open decision
ok - a preempted reply poll cannot publish channel freshness
ok - a quiet reply window publishes the caught-up watermark the reply guard reads
ok - a cursor-loss whole-log recapture is acknowledged quietly with no duplicate wake

New continuity escalation after ingest retry:
blocked [key=remote-reply-continuity-ios] [at=1790754387]: remote reply continuity broke for ios (truncated)
ok - truncation is detected, escalated once, and not silently rebased
ok - remote reply retirement quiesces and refuses unhandled captured results
ALL TESTS PASSED
Evidence: Contributions timeout retains result

Source: Contributions timeout retains result

unreached pf-remote-down: the work home mini-default never answered, so its terminal result stays retained there for reconciliation
ok - an unreachable remote work home fails loudly instead of reporting an empty inbox
Elapsed seconds: 4
Evidence: Remote state classification

Source: Remote state classification

state: unknown · source: remote-endpoint · unknown-remote: remote-mac unreachable or endpoint unreadable (not proof of death)
ok - fm-crew-state remote: local timeout stays unknown despite partial output
state: unknown · source: remote-endpoint · unknown-remote: remote-mac unreachable or endpoint unreadable (not proof of death)
ok - fm-crew-state remote: an unreachable host reads unknown-remote, never gone or dead
state: unknown · source: remote-endpoint · alive on remote-mac (an idle secondmate is healthy)
ok - fm-crew-state remote: an idle alive endpoint reads alive, never gone or dead
Evidence: Deadline validation and output preservation

Source: Deadline validation and output preservation

fm-watch-remote: FM_WATCH_REMOTE_TIMEOUT must be whole seconds from 1 to 120
invalid_status=125
first

last
error
command_status=23
successful output
success_status=0

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Monitor stalled mates while reaching healthy mates; reject partial dead responses and reset timeout episodes after recovery ✅ pass live Watcher progress and timeout recovery
Bound a stalled reply read without claiming freshness, then deliver queued replies and reports exactly once ✅ pass live Reply delivery and persisted cursor
Poll contributions through a stalled transport and retain the pending result for reconciliation ✅ pass live Contributions timeout retains result
Read a partial or unreachable remote endpoint as unknown while recognizing a responsive idle mate ✅ pass live Remote state classification
Reject invalid deadlines before execution and preserve bounded command output and exit status ✅ pass live Deadline validation and output preservation
  • bash tests/fm-timeout-lib.test.sh
  • Executed test_watcher_bounds_remote_mates against the real watcher using a temporary focused driver.
  • Executed crew-state timeout, unreachable-host, and healthy-idle scenarios using a temporary focused driver.
  • Executed public-followup collection with a 30-second stalling SSH fake and FM_WATCH_REMOTE_TIMEOUT=2.
  • Ran tests/fm-remote-reply.test.sh; corrected the disposable fixture's overlapping paths and reran all reply checks successfully.
  • Invoked fm_watch_remote_run directly to capture invalid-setting diagnostics and unchanged command output/status.
  • Captured product logs and persisted reply records; removed disposable fixtures and drivers; verified clean git status.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…l the beacon

The watcher's per-mate remote calls (liveness probe, remote relaunch,
pending-reply observation, reply-mirror read, public-followup collection)
now run under a local deadline from bin/fm-watch-remote-lib.sh, defaulting
to 60 s and overridable through FM_WATCH_REMOTE_TIMEOUT, on top of the
unchanged SSH keepalives. The watcher refreshes its beacon between mates
and between pending-reply records.

A timed-out probe is classified ambiguous, never dead: it authorizes no
relaunch and logs one bounded triage line per timeout episode, reset by a
responsive probe. Remote crew-state reads discard a partial timed-out
response instead of reading a dead prefix as a verdict.

Tests fake a hanging remote command and prove the cycle completes, the
beacon stays within grace, no relaunch is attempted, and the triage line
appears once per episode; the watcher case fails on the unchanged code.
@earljman
earljman merged commit 88b956b into main Sep 30, 2026
36 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant