Repository navigation
feat(bin): deliver local steers through durable task inboxes - #2856
Merged
Merged
Conversation
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the prior post-enqueue nonzero statuses now become successful delivered outcomes with explicit non-resend diagnostics, and the acknowledged parser-prefix behavior is unchanged. Reviews (8): Last reviewed commit: "no-mistakes: apply CI fixes" | Re-trigger Greptile |
kunchenguid
force-pushed
the
fm/fm-send-inbox-doorbell-r1
branch
from
August 23, 2026 11:17
0b16d56 to
571ed81
Compare
…orbell Stage 1 (local steers) of the captain-adopted reframe in data/fm-send-reliability-reframe-s1/report.md: an ordinary fm-send text steer to a task recorded in this home is appended as a sequenced durable record under state/<id>.inbox/ and the terminal receives only one constant self-describing doorbell line, best-effort. The worker acknowledges by moving the record into handled/; the watcher re-rings an unacknowledged message on an idle pane and escalates once as an ordinary stale wake. --resolve-key closes decisions at enqueue time, because the durable enqueue IS delivery to the task's record. bin/fm-task-inbox-lib.sh owns the record format, doorbell line, and re-ring ladder. The typed plane remains for what must reach the terminal itself: lifecycle keys, harness-native slash and codex $-skill invocations, explicit backend targets, and the remote secondmate leg (unchanged until the remote inbox leg ships separately). The composer classifier is demoted from delivery proof to an advisory ring guard that skips only on a proven pending verdict. Verified live against claude, codex, opencode, pi, grok, and muse: each real worker read its record, acted, and acked with the mv (docs/verification/runtime-backends.md "Steering-inbox doorbell").
…erved by the doorbell run
…x macOS wc padding in the tool-update suite
…failed exit out of stage 1 The CI monitor's fix changed the secondmate marking contract for parser-native invocations (appending the marker after the text) and softened the both-commit-and-marker-failed branch to exit 0. The merge authority ruled the marking question out of scope for this stage-1 transport PR (follow-up: fm-send-secondmate-harness-invocation-r1) and ruled the both-failed case a loud nonzero local failure. Restore both, keeping the monitor's legitimate migrations and hardening.
Captain-refined ruling on the F2/Greptile finding: the durable inbox record is what delivers the steer, so pending-reply bookkeeping trouble after a successful enqueue never exits nonzero - a resend-inviting status would make automated callers enqueue the delivered instruction again under a new sequence. With the recovery marker stored the watcher reconciles silently; with the commit and marker both lost the send surfaces a distinct reply-tracking-degraded do-not-resend warning and still exits 0. Nonzero remains only where nothing was delivered (or a decision close needs its manual command). Regression: record durable + both bookkeeping writes lost -> exit 0, one record, no duplicate.
kunchenguid
force-pushed
the
fm/fm-send-inbox-doorbell-r1
branch
from
August 23, 2026 19:00
e95ad30 to
aeb0d05
Compare
chadgpete-outline
pushed a commit
to chadxgpt/firstmate
that referenced
this pull request
Aug 25, 2026
* fix(bearings): restore decision options and add close controls (#2707) * fix(bearings): always show decision options and a close/drop control Freeform-only Captain's Call cards hid the option buttons the board was designed around, and there was no way to drop a stale hold without inventing an answer. Require selectable options, keep freeform as a supplement, and route the reserved __drop__ answer through decline so the hold leaves Captain's Call. * no-mistakes(review): Fix drop closure and decision-only option validation * no-mistakes(review): Preserve answerability for non-decision cards * no-mistakes(document): Clarify decision drop documentation * ci: require no-mistakes pipeline step attestation (#2710) Signature-only PRs can hide skipped review, test, or document steps. Fail unless no-mistakes >= 1.46.0 attests those three steps completed. * feat: collapse decisions into tasks held for the captain (#2728) * feat(captain-hold): collapse the decisions concept into tasks held for the captain A decision is no longer a separate type: it is an ordinary backlog task held for the captain, identified by its task id. bin/fm-captain-hold.sh owns the surviving behaviors - guarded hold creation, the recorded-answer close (answer/answers with a release mode for captain-gated work), the source bindings, and the investigation completion gate - and bin/fm-decision-hold.sh becomes a one-release compatibility shim over it. The fleet snapshot now parses hold-until and computes captain_actionable as queued + captain-held + unblocked + due, independent of row kind, plus a presentation-only deferred_marker for prose-deferred rows. Bearings renders every due captain-held task in Captain's Call, date-deferred holds as dated Charted Next gates, suppresses prose-deferred rows from default views with an omitted disclosure, and excludes from Recently Landed anything that closed while still held for the captain. Legacy compatibility: pre-collapse <origin>-decision-<key> rows are already plain task ids and keep working; short keys in recorded metadata, concrete origin bindings, chat --resolve-key fallbacks, and old resolution records all resolve in place. * no-mistakes(review): Fix captain answer replay and body preservation * no-mistakes(review): Fix captain hold idempotency and legacy replay * no-mistakes(review): Validate card close modes and compatibility routing * no-mistakes(review): Enforce release replay mode matching * no-mistakes(review): Prevent duplicate decision cards and released replay mismatches * no-mistakes(review): Preserve answer columns and legacy resolve replays * no-mistakes(document): Document strict replay and legacy compatibility * no-mistakes(lint): Quote done literals to satisfy ShellCheck * no-mistakes: apply CI fixes * fix(rebase): keep collapsed captain hold board semantics * fix: bound recovery announcements and preserve supervision (#2733) * fix(watch): announce recovery once per generation and keep successors supervising A lost Pi/OpenCode handling handshake re-announced the same recovery generation on every cycle and spent the successor's first ~55s blind, so a real crew event could be ignored and then dropped. Record the announcement in the durable marker, confirm the handshake before the follow-up without swallowing failure, and enter the poll loop immediately. * no-mistakes(review): Tighten recovery event timing regression * no-mistakes(document): Document recovery-loop supervision guarantees * fix(bin): surface captain-call record divergence (#2744) * fix(bin): signal a captain call resolved in the log but still held A captain call has two records and closing one has never closed the other: a `resolved [key=...]` line closes the status-log fold, while the backlog task held for the captain closes only through `fm-captain-hold.sh answer`. Answering on the status side alone left no trace of the disagreement - the fold went quiet, the durable record kept saying the captain owed an answer, and nothing warned. The defect was never the separation; it was the silence. Add `fm-captain-hold.sh diverged`, a read-only report of that contradiction, and print it from `fm-wake-drain.sh` as a bounded RECORD DIVERGENCE section beside OPEN DECISIONS on every drain. It flags one condition: a task still open and still carrying the captain-hold annotations whose key was closed on the status side by the resolve verb, under the collapsed identity or the legacy derived one. It closes nothing, ever. A captain call closed wrongly leaves review entirely, which is worse than the noise, so both reconciliation directions stay human-owned and the printed hint names both - a resolution is not proof the captain ruled, since a call can dissolve on a false premise or turn out to have been a question of fact. Three states are deliberately not divergence: a `captain-held` close is the verified transfer `complete` writes, a still-open keyed decision belongs to the OPEN DECISIONS fold, and a captain call with no routed work item is legitimate rather than incomplete, so routed work is no part of the test. `fm-classify-lib.sh` gains `status_key_closing_verb`, which reports how the status side currently reads one key by replaying the existing `_fm_decision_fold_line` rule rather than re-deriving it, so the two closing verbs stay distinguishable in one place. The per-wake cost is one `tasks-axi list`, one key scan per status log, and the precise per-key fold only for a key that already names a still-open task; the call is hard-bounded so a slow backlog tool can never delay wake presentation. * fix(document): Correct divergence lifecycle documentation * fix(document): Neutralize divergence lifecycle prose * fix(bin): re-arm after an abandoned auto-arm claim and defer a wedge escalation while a worktree is written (#2524) * fix(watch): re-arm supervision after an abandoned auto-arm claim A Claude auto-arm cycle that armed, delivered one rewake, and exited left its single-flight lock behind. Both Stop-event participants then deferred to that lock forever, because its recorded pid was still live: the turn-end guard read it as recovery under way and allowed the stop, and the next Stop firing treated it as another owner and declined to arm. On 2026-08-14 a home with two tasks in flight lost supervision for about 40 minutes with no watcher process and no watcher lock, its beacon frozen at the one delivery, and both crewmates' finished reports sat in the durable queue until an operator drained it by hand. Abandonment is now proven from the epoch ledger instead of inferred from pid liveness. A lock whose holder pid matches the ledger's own owner_pid while the recorded outcome is anything other than arming has already finished its decision, so that claim is reclaimed under the lock's steal mutex, stops counting as recovery ownership in the guard, and is cleared by the guard's terminal check rather than deferred to. A failed clear re-blocks instead of allowing a blind stop, and an arming entry stays in flight however old it is, because its owner foregrounds the arm for the whole watcher cycle. Issue #2251's PR #2263 does not cover this failure. It is closed and unmerged, lives entirely in bin/fm-watch-arm.sh, and retires the stalled watcher and matching stale watcher lock of an arm that is currently running. Here no arm and no watcher were running and no watcher lock existed, so it has nothing to retire and the home stays blind. tests/fm-claude-stop-autoarm.test.sh covers the reclaim, the still-arming and unnamed-owner cases that must keep the gate closed, and the failed clear. tests/fm-turnend-guard.test.sh covers the guard side of the same boundary. Both fail without this change. * fix(watch): defer a wedge escalation while the task worktree is written The wedge detector had two inputs, rendered pane quietness and the run step, and neither can see a crew that is writing source, then tests, then documentation behind a static pane. On 2026-08-14 one crewmate produced eight consecutive possible-wedge escalations in a single afternoon, three of them demanding deep inspection, while it was demonstrably working and then committed. Every one of them cost a supervision turn to disprove by hand. Add write activity inside the crew's own recorded worktree as a third liveness input. crew_worktree_written_since compares the worktree against the caller's existing idle-window timer file, so -newer needs no clock arithmetic, no temp file, and no portable mtime write. The probe runs only inside the branch that was about to escalate, which bounds it to one pruned, depth-bounded walk per window per FM_STALE_ESCALATE_SECS and leaves the per-poll stale sweep exactly as cheap as before. Positive evidence defers rather than cancels. The idle timer restarts so the next window probes again, the escalation counter is neither advanced nor reset so a later genuine wedge keeps the demand-deep-inspection history it earned, and a .writing-since marker ages the whole deferral chain so the pane still re-surfaces once per FM_PAUSE_RESURFACE_SECS, through the same throttle shape a declared pause already uses, labeled as a recheck rather than a wedge. This can only reduce false positives: every absence of evidence, including no recorded worktree, a torn-down worktree, a missing anchor, and a failed walk, falls through to the unchanged escalation schedule, so a crew that writes nothing still escalates on the existing timetable. What the signal cannot see, by design or by construction: - CPU burn with no writes, such as a long compaction, is invisible. That case keeps the old behavior exactly. - A commit-only phase writes only .git, which is pruned first so that firstmate's own read-only git commands against the worktree can never make the probe self-fulfilling. - Writes under the pruned generated trees, or deeper than FM_WORKTREE_WRITE_MAXDEPTH, do not count. - The probe cannot attribute a write to the crew, so a background build or another process touching the tree looks the same. The hourly re-surface is what bounds that, and a churny file cannot buy silence. - The away-mode daemon's own escalation path is deliberately untouched. tests/fm-watch-triage.test.sh covers the classifier including the .git prune, both halves of the live case on one fixture (quiet plus writing defers, quiet plus silent still escalates and counts), and the bounded re-surface. All three fail without this change. * no-mistakes(review): prove autoarm claims by identity; skip mate-home write probe * no-mistakes(document): document away-mode wedge boundary and probe filesystem limit * no-mistakes(document): qualify turn-end recovery condition for abandoned auto-arm claims * fix(watch): keep a write deferral scoped to its own idle window Two consistency gaps in the worktree write probe, both found while reviewing the wedge-deferral change on this branch. A write deferral is a bounded chain: its .writing-since marker ages the whole chain so a churning worktree still re-surfaces once per resurface window. That is only sound while the chain belongs to the current quiet stretch, so every path that restarts the idle-window timer has to drop it too. Two did not: the corrupt-timer repair in wedge_timer_check, and both first-sight branches for a captain-relevant status. A chain left over from an earlier quiet stretch made the first deferral of the new window re-surface immediately instead of after a full fresh window. FM_WORKTREE_WRITE_PRUNE is a skip list, so clearing it reads as "skip nothing" and is the obvious way to widen the probe to the whole depth-bounded tree. Instead an empty list reported no evidence at all, quietly costing the wedge detector its third liveness input on a home that meant to widen the walk. An empty list now widens the walk, and the header says so. Neither change alters when a stall that writes nothing escalates. Regressions in tests/fm-watch-triage.test.sh cover all three paths and each one fails on the pre-fix code. * no-mistakes(review): honor an empty write-prune, bound the probe, share window_key * no-mistakes(document): align probe knob count and guard regression-coverage ownership * no-mistakes(lint): silence deliberate single-quote SC2016 in write-prune env test * fix(bin): give a captain hold the same bounded pause cadence as a declared pause (#2748) * fix(bin): give a captain hold the same bounded pause cadence as a declared pause Two supervisors read a finished task's last status line and disagreed about which declarations mean an idle endpoint is expected. bin/fm-inactive-reconcile.sh suppresses its inactive-outcome scan only on `captain-held`, while the away-mode daemon's wedge path gated deferral on `paused` alone. Both read the LAST line, so the two verbs are mutually exclusive and no finished task waiting on a person could satisfy both at once. Marking 11 such tasks `captain-held:` silenced the 900s outcome scan and immediately produced five possible-wedge escalations in one batch, because the 240s wedge detector no longer saw a pause verb. fm-classify-lib.sh's status_is_paused_or_captain_held already owns the combined question, and bin/fm-watch.sh's ordinary-crew wedge path already asked it. This extends that same answer to the paths still asking the narrower one: - bin/fm-supervise-daemon.sh, all six sites, which form one subsystem and have to move together. classify_stale returns the pause action, reconcile_pause_tracking and migrate_watcher_pause_markers record and migrate the marker, and housekeeping defers the wedge and then re-surfaces the recheck. Changing only the stale-persistence gate would defer the escalation while reconcile_pause_tracking recorded nothing, so the wedge marker would persist and the sweep would `continue` past it forever: quiet, but never re-surfacing. - bin/fm-watch.sh's secondmate stale gate, whose downstream owner pause_state_class already treats both declarations identically. - bin/fm-push-transition-lib.sh's absorb, where either declaration already names the human the transition would report and the wait is already durably recorded. Quieting alone would be half a fix, so the bounded re-surface had to reach a hold too. A hold has no current-state mapping, unlike `paused`, so authoritative crew state reports it as unknown and pause_state_class received `none`. An ordinary crew recovers pause classification from that state through confirmed agent death, which proves no live decision gate is being silenced. A secondmate's endpoint liveness is deliberately never read there, because an idle mate is
Intent
STAGE 1 (LOCAL steers only) of the captain-adopted inbox+doorbell steering design from data/fm-send-reliability-reframe-s1/report.md, replacing fm-send's typed-payload local data plane; the prior payload-delta/composer-verification approach was DROPPED and must not be resurrected. All requirements captain-approved, including two explicit gate rulings refined during validation: (A) SCOPE EXCLUSION - the pre-existing interaction where a MARKED secondmate parser-native invocation types marker-prefixed bytes (parser sees chat) is APPROVED as out-of-scope pre-existing behavior; follow-up fm-send-secondmate-harness-invocation-r1 owns it; do NOT change the marking contract (no appended-marker variant, no unmarked secondmate invocations) and do not flag it again - the stage-1 boundary comment in fm-send.sh documents this deliberately. (B) EXIT-STATUS RULING (final, refining the earlier both-failed call): on the inbox plane the durable record IS the delivery, so the record's fate alone governs the exit status - exit 0 whenever the record is durably written, including when pending-reply bookkeeping later fails; with the recovery marker stored the watcher reconciles silently, and with the commit and marker BOTH lost fm-send prints a distinct 'reply-tracking-degraded (steer delivered, do not resend)' warning and still exits 0, because any resend-inviting status would make automated callers duplicate a delivered instruction; nonzero is reserved for cases where nothing was delivered (unresolvable target, retired/changed endpoint under the metadata lock, unwritable record) or a decision-close append failed with its manual command attached; this exact contract is deliberate - do not re-flag either direction of it. Core design: (1) bin/fm-task-inbox-lib.sh is the ONE owner of the steering-inbox contract: sequenced durable records at state/.inbox/NNN.msg (temp-write + atomic rename, lock-serialized sequence allocation with bounded wait), the handled/ move as the acknowledgement, never-reissued sequences, BYTE-EXACT bodies (no added newline; raw read-back after the -- line), the constant self-describing doorbell line, and the delivery-attempt ladder (grace-paced; attempts include composer-protected skips and failed rings so nothing retries silently forever; escalate once per message with wake-before-marker ordering; reset on ack; bookkeeping tolerates a concurrently torn-down inbox; FM_TASK_INBOX_GRACE_SECS=90, FM_TASK_INBOX_RING_MAX=3). (2) fm-send local plane: CLI shape, resolution, fail-closed FM_HOME, gate-agent refusal kept; endpoint revalidated under the task metadata lock; durable record appended; ONE constant doorbell rung best-effort (advisory composer check skips only on exact proven pending; ambiguous verdicts still ring - skip-starvation observed live on grok 1.0.5); exit contract per ruling B; the exit-3 ladder and post-send composer proof REMOVED from the local plane. (3) --resolve-key closes the ledger and feeds the captain-hold intake at ENQUEUE time; pending-reply expectations marked delivered at enqueue. (4) Every brief scaffold carries the receive-and-ack paragraph; the relaunch note gains check-your-inbox; teardown removes the inbox. (5) Watcher: one cheap per-task check per poll - re-ring aged unhandled messages on a not-busy pane, wait on busy, escalate exactly once as an ordinary stale: wake with pre-wake revalidation; healthy/empty inboxes stay silent (silent file-move ack). (6) Typed-plane carve-outs UNCHANGED: --key lifecycle keys; harness-native slash and codex $-skill invocations classified on the pre-marker text; explicit backend targets; and the REMOTE secondmate leg, explicitly OUT OF SCOPE (cmd_send and the exit-3 contract crossing ssh stay byte-compatible; remote inbox leg ships separately). (7) KEEP per report section 5: every fail-closed refusal; fm-pending-reply-lib's REPLY direction untouched; fm-control lifecycle keys; spawn-time readiness/trust handling; composer classifier and capture adapters for non-send consumers, demoted to advisory. (8) Tests: portable regressions with real processes (byte-exact round-trips incl. trailing newlines, sequence dedup + idempotent ack, concurrent writers, the attempt ladder, real-watcher re-ring/busy-wait/silence/single-escalation, plane routing, enqueue-time close, endpoint revalidation, torn-down-inbox tolerance, and the ruling-B regression: record durable + both bookkeeping writes lost -> exit 0, distinct degraded warning, no duplicate record); existing suites migrated to the record plane without weakening; plus the env-gated live doorbell guard RUN 2026-08-23: claude, codex, opencode, pi, grok, muse all honored the doorbell end to end (docs/verification/runtime-backends.md, with the dated grok 1.0.5 composer-matrix staleness note; matrix refresh owed separately). Drive-by macOS BSD-wc fix in tests/fm-tool-update-check.test.sh rides along. KNOWN DEFERRED (do not fix in this run): the opt-in cmux live composer guard still expects the payload typed; the captain will route it as follow-up work. (9) Docs: AGENTS.md state entry + section 7 steering rewrite; configuration.md state clause + env knobs; scripts/tmux-backend/architecture/harness-adapters/stuck-crewmate-recovery scoped to the typed plane. PR note: homes pick this up after merge + self-update; landing timing coordinated with the main firstmate; STAGE 1 (local) with the remote leg to follow. One PR; yolo OFF; the captain owns the merge.
What Changed
fm-sendmessages through byte-exact, sequenced inbox records with a constant best-effort doorbell, while preserving typed delivery for native commands, explicit backend targets, and remote secondmates.Risk Assessment
Testing
Reviewed the base-to-target change, ran the focused inbox/watcher and fm-send routing regressions, and manually exercised the delivered record → doorbell → handled acknowledgement flow; all checks passed and the evidence transcript shows the end-user-visible behavior and persisted state.
Evidence: Inbox and doorbell end-to-end transcript
Source: Inbox and doorbell end-to-end transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed (3) ✅
bin/fm-task-inbox-lib.sh:178- The doorbell targets one specific record rather than enforcing the inbox's numeric-order contract. Concrete path: 001's initial ring is swallowed, then 002's ring lands; the worker is explicitly told to read and act on 002, while 001 is only re-rung later by the watcher, reversing the steer order without error. Make the shared doorbell instruct the worker to list and process all unhandled records in numeric order (or otherwise prevent a newer record from bypassing the oldest).🔧 Fix: Preserve inbox ordering with drain-all doorbells
1 error still open:
bin/fm-watch.sh:303- The required ladder invariant says failed attempts must ensure “nothing retries silently forever,” but the watcher ignoresfm_task_inbox_record_ringfailure. If.ring-statecannot be written while the inbox still exists (for example, permissions or filesystem failure), each poll rings again without advancing toward escalation; only the private triage log records it. Handle non-vanished-inbox bookkeeping failure loudly rather than continuing an unbounded retry loop.🔧 Fix: Surface unwritable inbox ladder bookkeeping
1 error still open:
bin/fm-watch.sh:326- The bookkeeping-failure wake checks only that the inbox directory exists, not that the record remains unhandled. Concrete race: the ring prompts the worker to move the record into handled/,.ring-statewriting then fails, and this branch emits a stale wake claiming the already-acknowledged record remains unhandled. Revalidate[ -f "$rec" ]immediately before appending the wake and quietly reset/return when it was acknowledged.🔧 Fix: Silence ladder failures after inbox acknowledgement
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-task-inbox.test.shbash tests/fm-send-inbox.test.shManual sandbox execution ofbin/fm-send.shthrough a stubbed tmux backend, verifying exit 0, byte-exact persisted payload, constant doorbell-only terminal traffic, and acknowledgement via move tohandled/git status --shortconfirmed testing left the worktree clean✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.