Repository navigation
Description
Summary
FirstMate describes supervision as event-driven and zero-token, but its reference tmux backend and experimental Orca backend still use a 15-second polling loop plus terminal-tail regexes as their default lifecycle signal. Herdr can replace the blind sleep with pane.agent_status_changed events, but the watcher still performs periodic reconciliation and most backends have no typed lifecycle source.
Add a backend-neutral typed supervision event contract so supported harness/backends can report durable task transitions without terminal scraping, while retaining the existing watcher as a compatibility and reconciliation fallback.
Verified current behavior
Current main documents and implements:
FM_POLLdefaults to 15 seconds inbin/fm-watch.sh.- tmux, Orca, zellij, and cmux report no native busy primitive and fall back to terminal-tail regex detection.
- Herdr protocol 16+ can block on
pane.agent_status_changed, immediately surfacingblocked, but capability or runtime failures revert to polling. - Append-only status files are wake-event history, not authoritative current state;
fm-crew-state.shcombines no-mistakes state, backend busy detection, pane content, and status-log fallback. - Several additional guards, beacons, queues, daemon paths, and turn-end hooks compensate for missed or ambiguous supervision signals.
This architecture is careful and defensive, but the number of compensating mechanisms is also evidence that terminal state is carrying lifecycle semantics it cannot authoritatively represent.
Why it matters
For manager-of-managers workflows, silent delay or ambiguity at each layer compounds:
- a finished worker can look idle, stale, or still working depending on pane text;
- a steer can be accepted by the terminal transport but remain queued inside a busy harness;
- restart recovery must infer current truth from several partially overlapping records;
- the same work can be represented differently across tmux, Herdr, Orca, and harness-specific hooks.
Polling itself is not expensive in tokens, but terminal scraping and inferred state make unattended correctness hard to prove.
Proposed direction
Define a versioned backend-neutral event envelope such as:
task_id, attempt_id, sequence, event_type, state, timestamp, backend_identity, payload_digest
Minimum event types: started, heartbeat, blocked, needs_decision, completed, failed, interrupted, and endpoint_exited.
Requirements:
- Events are appended durably before the producer advances its local state.
- Consumers resume from a cursor/sequence after restart and deduplicate replay.
- A terminal or backend exit deterministically reconciles the task attempt.
- Harness hooks, Herdr events, and Orca orchestration messages normalize into the same envelope.
- Pane scraping remains an explicitly degraded fallback, never silently equivalent to typed state.
- The watcher periodically reconciles authoritative task/endpoint state even when push delivery appears healthy.
Acceptance criteria
- A supported event-capable backend reports
blocked,completed, andfailedwithout reading terminal text. - Completion reaches the first mate within two seconds under normal operation.
- Killing and restarting the first-mate session replays an unconsumed event exactly once.
- Killing a worker endpoint cannot leave the task indefinitely
workingorreadywithout a recorded failure/retry state. - Duplicate events and reconnects are idempotent.
- The UI/CLI exposes when a backend is using typed events versus polling/scraping fallback.
- Existing tmux users keep working through the fallback path.
Related
- Daemon-mode watcher (or durable wake queue) — supervisor misses crewmate wakes between turns in chat mode #27: durable watcher/daemon path for missed chat-mode wakes.
- Watcher silently dies on Linux (stat -f portability crash) — misses all supervision wakes #26: Linux watcher portability failure.
- Validation watcher arm can leave live
fm-watch.shfrom.no-mistakes/worktrees#321: validation watcher can survive from a disposable checkout. - fm-send: steers falsely succeed while agent is busy on long shell (Pi queues Steering) #677: text steering can report transport success while a busy Pi session only queued it.
This is intended as an incremental contract beneath the existing recovery policy, not a request to delete the watcher. Prepared with AI assistance after comparing FirstMate's current watcher and backend implementations. Reporter: @ericjung.
Activity
str0203 commentedon Aug 10, 2026
Orca is now a good first concrete backend for this contract rather than only an example. The current CLI exposes supervised-worker state, while the broader versioned protocol discussion is active upstream:
A bounded first slice could add an optional backend capability such as
wait_events(cursor, timeout)while leaving the existing watcher polling path unchanged:That would let the contract prove itself against one real consumer before generalizing every harness/backend. The minimum useful acceptance test is blocked + completed + failed delivery, restart replay exactly once, duplicate-event dedupe, and a visible diagnostic naming typed-events versus polling fallback.
kunchenguid commentedon Aug 24, 2026
Speaking as Kun's firstmate: inspected on current
main8fa0505e48a1.VISION.md (each rule):
FM_POLLdefault 15 inbin/fm-watch.sh).pane.agent_status_changed; pull-only stay on reconcile).Related open #1813 / #683. No covering PR. Labeling
ready-for-pr.kunchenguid commentedon Aug 24, 2026
Speaking as Kun's firstmate:
Scheduled 3:10am PT 8/24 pass (FM-FMOSS-CRON). VISION.md read in full from current main
8fa0505e48a155da78a9aeeb50911719dc558710(#2939). Unstamped; one later comment from str0203 (2026-08-10) proposing Orca as first consumer. No covering implementation PR.Inspected
bin/fm-watch.sh(POLL=${FM_POLL:-15}),bin/fm-backend.shfm_backend_has_push/fm_backend_events_capable/fm_backend_wait_transition(herdr-only; others return incapable/2),bin/backends/herdr.shfm_backend_herdr_events_capable(events.subscribe+pane.agent_status_changed),bin/fm-busy-event.sh/docs/architecture.md(harness turn busy/idle, not backend task lifecycle),bin/backends/orca.sh,docs/orca-backend.md(no native Orca busy/events; watcher has no Orca push path), andtests/fm-supervision-events.test.sh(Herdr splice only).Still present. Existing primitives do not cover the proposed envelope:
fm-busy-event.shis adapter-owned turn busy/idle/unknown/dead. It is notstarted/blocked/completed/failed/interrupted/endpoint_exitedwith a cursor.wait_events(cursor, timeout), no diagnostic that names typed-events versus polling fallback for pull-only backends.VISION (inspected those files):
blocked/completed/failed), never as reconstructed terminal mechanics.fm_backend_wait_transitionand the busy record; first real consumer is Orca supervised-worker state (Orca backend: adopt Orca's supervised-worker primitives instead of raw worktree + terminal #1813), as str0203 sketched.Constraints: incremental; keep the watcher as compatibility/reconcile; pane scrape is a named degraded mode; acceptance stays blocked + completed + failed without terminal text, restart replay exactly once, duplicate dedupe, and a visible typed-vs-poll diagnostic. Related open #1813 / #2084 / #683.
Labeling
ready-for-pr.ready-for-pris a queue label, not a merge vote.devin-ai-integration commentedon Sep 24, 2026