Repository navigation
feat(bin): add idempotent inbox capture, replies, receipts, and readiness JSON - #5103
Merged
kunchenguid merged 6 commits intoSep 21, 2026
Merged
Conversation
Let a caller supply a request id when publishing a captain inbox note so a retry returns the original note instead of creating a second one, including across the crash window between save and wake announcement. Separate saved from announced so a failed wake is repairable without enqueueing again. Add bounded receipts JSON with omission disclosure, a durable primary reply against a note id, and a read-only readiness projection that can say unknown instead of inferring liveness from a lock file.
…nd readiness verdict
…-json Remove the extra JSON surface from fm-lock.sh so its human status still always exits zero. Have the readiness projection classify the inspected home from the lock-holder pid via fm-harness.sh ancestry, with an explicit FM_SUPERVISION_MODEL still winning and an unknown model when there is no holder. Prove the yes path when that ancestry names a known harness.
Owner
|
Speaking as Kun's firstmate: Triage stamp — contract-class opt-in; attestation MATCH; CI+NM SUCCESS; VISION aligned.
|
kunchenguid
approved these changes
Sep 21, 2026
kunchenguid
left a comment
Owner
There was a problem hiding this comment.
Speaking as Kun's firstmate:
Safe review approve. Opt-in console-backend contract; plain inbox path preserved; request-id and readiness paths refuse unsafe ids and can say unknown honestly.
Owner
|
Speaking as Kun's firstmate: Merged — thank you @cliflacata-svg. The idempotent inbox capture / receipts / reply / readiness contract lands on main as opt-in surfaces with the plain note path preserved. |
dscott98
pushed a commit
to Simplifying-Cloud/firstmate
that referenced
this pull request
Sep 21, 2026
…ness JSON (kunchenguid#5103) * feat(bin): add idempotent inbox orders, receipts, replies, and readiness Let a caller supply a request id when publishing a captain inbox note so a retry returns the original note instead of creating a second one, including across the crash window between save and wake announcement. Separate saved from announced so a failed wake is repairable without enqueueing again. Add bounded receipts JSON with omission disclosure, a durable primary reply against a note id, and a read-only readiness projection that can say unknown instead of inferring liveness from a lock file. * no-mistakes(review): fix(bin): honest inbox announce, reply cursor, and readiness verdict * fix(bin): resolve ready from lock-holder ancestry; drop lock status --json Remove the extra JSON surface from fm-lock.sh so its human status still always exits zero. Have the readiness projection classify the inspected home from the lock-holder pid via fm-harness.sh ancestry, with an explicit FM_SUPERVISION_MODEL still winning and an unknown model when there is no holder. Prove the yes path when that ancestry names a known harness. * no-mistakes(review): Harden inbox announce, receipts reads, and reply sequence cursor * no-mistakes(document): Note read-only lock inspection in scripts inventory * no-mistakes(lint): Pass missing id argument to malformed-reply test printf --------- Co-authored-by: cliflacata-svg <[email protected]>
dscott98
added a commit
to Simplifying-Cloud/firstmate
that referenced
this pull request
Sep 21, 2026
…nation (#4) * feat: route Lavish feedback directly to owning workers (kunchenguid#5099) * feat(procevent): route worker-owned Lavish rounds * no-mistakes(review): drop duplicate artifact field from task-owned registration * no-mistakes(review): post worker reply once, fix ring label, keep re-arm atomic * no-mistakes(review): keep worker board owned until terminal round acknowledged * no-mistakes(review): refuse every retirement of an open worker-owned round * no-mistakes(review): use real lavish reply flag, isolate reply generations * no-mistakes(review): drop .posted marker for best-effort reply posting * no-mistakes(review): consume staged reply after listener setup, refuse orphaned captures * no-mistakes(review): require a reachable owner, redeliver open rounds, roll back failed re-arms * no-mistakes(review): re-arm only to acknowledge an open round * no-mistakes(review): conclude only a still-open terminal round * no-mistakes(review): record the acknowledgement before retiring the board * no-mistakes(review): retain the registration across a conclude, qualify terminal docs * no-mistakes(document): Document worker-owned Lavish round lifecycle * fix(bin): fit pull observation within the contribution poll budget (kunchenguid#5107) * fix(bin): reserve contribution observation budget * no-mistakes(review): Strengthen slow-read regression test to exceed the poll budget * feat(bin): add idempotent inbox capture, replies, receipts, and readiness JSON (kunchenguid#5103) * feat(bin): add idempotent inbox orders, receipts, replies, and readiness Let a caller supply a request id when publishing a captain inbox note so a retry returns the original note instead of creating a second one, including across the crash window between save and wake announcement. Separate saved from announced so a failed wake is repairable without enqueueing again. Add bounded receipts JSON with omission disclosure, a durable primary reply against a note id, and a read-only readiness projection that can say unknown instead of inferring liveness from a lock file. * no-mistakes(review): fix(bin): honest inbox announce, reply cursor, and readiness verdict * fix(bin): resolve ready from lock-holder ancestry; drop lock status --json Remove the extra JSON surface from fm-lock.sh so its human status still always exits zero. Have the readiness projection classify the inspected home from the lock-holder pid via fm-harness.sh ancestry, with an explicit FM_SUPERVISION_MODEL still winning and an unknown model when there is no holder. Prove the yes path when that ancestry names a known harness. * no-mistakes(review): Harden inbox announce, receipts reads, and reply sequence cursor * no-mistakes(document): Note read-only lock inspection in scripts inventory * no-mistakes(lint): Pass missing id argument to malformed-reply test printf --------- Co-authored-by: cliflacata-svg <[email protected]> * fix(bin): stop harness footer rows below a composer from reading as pending text (kunchenguid#5118) * fix(composer): stop a harness footer row from reading as a composer holding text A harness draws its own furniture below the composer - a user statusLine, a permission-mode hint - and the cursorless "bottom-most shape wins" rule looks exactly there. `→` (U+2192) is Cursor's prompt glyph but ordinary text everywhere else, so a statusLine opening with `→` was selected as a bare composer, swallowed the hint row beneath it as wrapped input, and answered `pending` on a visibly empty pane. `fm_task_inbox_ring` defers on exactly that verdict, and `bin/fm-watch.sh`'s re-ring calls the same function, so the first doorbell and every retry were skipped and the worker never saw the steer. Measured live on 2026-09-20: three of five Claude Code 2.1.236 worker panes on Herdr 0.8.0 had genuinely empty composers and every one of them was refused. A separator pair that closed over a bare agent-glyph row is a proven composer container, so the contiguous non-blank rows below its closing rule are that composer's footer and are no longer composer candidates. The demotion is bounded by all three of its own preconditions: a blank row ends the zone, a pair that closed over no glyph row demotes nothing, and a shape with no separator pair at all (Cursor's half-block rules) is untouched. Real unsubmitted text in that same composer, including a stray SGR mouse report left by a click in the pane, still reads `pending`. Pinned by two portable regressions and by a new cursorless arm on the live composer-matrix guard, which re-reads each harness's already-proven-idle pane the way every non-tmux backend reads it and fails naming the harness and version when that read is `pending`. * no-mistakes(review): make composer footer-zone demotion shape-independent * no-mistakes(review): make footer-zone demotion refuse-only and drop rescan * no-mistakes(lint): quote probe-absent sentinel to clear ShellCheck SC2100 --------- Co-authored-by: Koen Muller <[email protected]> * feat(bin): append optional home-local include to briefs (kunchenguid#5115) Co-authored-by: guanchengh-lgtm <[email protected]> * fix(bin): report a branch with no validation run as absent instead of an unreadable runs table (kunchenguid#5114) * fix(bin): stop misreading a no-run branch as an unreadable runs table Defect: when `no-mistakes axi status`'s overview is truncated (a task's own branch has zero rows among the shown ones), fm_nm_select_run's Python fallback derived the repo identity for its direct SQLite query from a `repo: <path>` line it expected in the overview text. The real CLI never emits that line, truncated or not (see the genuine capture at tests/captures/no-mistakes-v1.70.1/overview.toon, which has only `count:`/`runs[...]:`), so the lookup always failed and reported "unreadable runs table" for a task that simply has no run on its branch. On a fleet with many concurrent runs, every idle-branch task hits the truncated-overview path routinely, so this fired every few minutes and drowned genuine unreadable/blocked verdicts in noise. Fix: derive the repo identity from the task worktree path instead, which is exactly the value `no-mistakes` records as a repo's `working_path` (confirmed against the existing capped-overview test fixtures, which already register repos by worktree path). A worktree path that is not absolute cannot be matched and still reads as unreadable rather than being guessed at. Also raise the reader's SQLite busy timeout from 1s to 30s so ordinary lock contention on a busy fleet cannot masquerade as an unreadable database. Safety: every other verdict byte-for-byte unchanged - the repo lookup still requires exactly one matching row (a genuinely corrupt or mismatched repos table still reports unreadable, per the existing `repo` failure-mode test), the branch query and row validation are untouched, and a zero-row result for the branch still flows through the same recursive re-parse that already turns an empty `runs[0]{...}` table into `absent`. Added a regression test (test_capped_overview_without_repo_line_and_no_runs_reports_absent) that reproduces the real overview shape - capped, zero rows for the task's branch, no `repo: ` line - and asserts the crew state falls through to the pane/busy verdict instead of reporting unknown or "unreadable". Full fm-crew-state.test.sh suite passes unchanged otherwise. * fix: recovered same-branch inventory awk misreads empty result as unreadable fm_nm_select_run's deep SQLite reader rebuilds a `count:`/`runs[...]:` overview and re-runs it through the same awk selection pass. When that rebuilt inventory has zero rows for the branch, the row-matching loop never executes, so its counters (`seen`) stay at awk's uninitialized empty string while `expected` and `shown` are plain strings parsed from the header text. Comparing an uninitialized value against a non-numeric string uses string comparison, so "" != "0" is true, and the END block takes the "unreadable runs table" branch instead of falling through to the correct "absent" verdict for a branch with genuinely zero runs. Coerce the affected END comparisons with `+0` so they are always numeric, matching seen/expected/shown/total regardless of whether awk classified them as strings or numeric strings. A truncated or genuinely malformed inventory still differs numerically and still reports unreadable. * no-mistakes(review
Intent
The captain authorized starting the web front end for the VPS base of operations on 2026-09-20, after reading the scoping report. This task is that report's section 8, step 1, backend half.
What is wanted, in substance: a browser console that can be opened from any device to see what the fleet is doing, give it orders, and read its answers. Cost-sensitive: a design that spends model tokens to render a page or to remember a conversation is the wrong answer. There are exactly three subscriptions (Claude Pro, ChatGPT Plus/Codex, SuperGrok) and no budget for a new paid service.
This task builds NONE of the web UI and starts no HTTP service. It builds the durable contract underneath it, because the existing scripts cannot yet support a browser client honestly: an order submitted over HTTP can be silently duplicated on retry, a saved order whose wake announcement failed looks like a failure, there is no machine-readable way to see whether an order was acknowledged, there is no durable path for the primary's actual answer to come back to the submitter, and there is no structured way to tell whether a primary is even alive to receive the order.
The specific findings this task acts on:
Section 8 step 1 backend half, in substance: extend the existing inbox and health owners so a caller can supply a request id when capturing an order and a retry reuses the original note, including after a crash between recording and announcing; expose a saved-but-wake-failed result that is repairable without creating another note; add a bounded JSON view of pending and handled notes with acknowledgement and recorded replies, stating what it omitted rather than implying the first page is everything; give the primary a supported way to publish its actual answer against a note id as a durable record with a cursor so a client can read what is new; and add a read-only structured projection of whether a primary can currently receive work (lock ownership, wake-consumer health, away posture, observation age) that can say unknown honestly and does not infer liveness from a lock, a session, or a pane.
Standing direction this must not paint into a corner: persistent expert agents selected by task type, agents that debate to a conclusion, durable memory on cheaper models, all on the VPS and reachable from any device, doing real coding work against GitHub. Keep identity and correlation independent of any harness name or terminal pane.
What Changed
bin/fm-inbox.sh notetakes an optional--request-id <id>and--json. The request id is recorded before the wake is announced, so a retry returns the original note and does not create a new one, even after a crash between those two steps. With either flag, a note that was saved but whose wake failed exits 3 instead of 1, so a caller knows to repair it rather than resubmit. The newannounce <id>command repairs that wake without creating another note. It skips notes that are already acknowledged, and it refuses notes older than this change because nothing on disk shows whether their wake was announced. Plainnote/list/drainoutput and exit codes are unchanged.reply <id>saves the primary's actual answer against a note id: one reply per note, each stamped with a per-home sequence number. Newreceipts [--after <cursor>] [--all-pending] [--all-handled] [--all-replies]returns bounded JSON listing pending and handled notes with their acknowledgement and announcement state and any reply. It also returns a cursor for reading new replies and anomitted[]list naming anything left out by the default limits. AGENTS.md now tells the primary to publish durable answers withreply.readyoutputs JSON on whether the primary can currently take work: lock ownership, wake-consumer health, away posture and when the state was observed. It reports unknown when it can't tell, and never treats a lock, session or pane as proof of liveness. This uses a newfm_session_lock_inspecthelper inbin/fm-session-lock-lib.sh, whichfm-lock.sh statusnow shares without changing its output. Docs are updated, and a newtests/fm-inbox.test.shcovers the new commands.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The fix round correctly implements all four requested fixes: acknowledged notes get no wake, receipts skips missing files and reads bad bytes safely, the sequence counter can't go backwards, and a reply without a valid seq is reported as malformed. Both announce_note callers handle the new return code 2, and the new tests are behavioral regressions. What remains is one minor inconsistency in the announced value for legacy handled notes.
Testing
I ran the focused inbox test and two live CLI scripts against temporary FM_HOMEs; every scenario passed. The scripts cover: - idempotent retry and repair after a wake failure (made real with a read-only wake queue) - no wake for a note already acknowledged - bounded receipts that report what they omitted - replies and the forward-only cursor, including after the sequence counter was lost - thereadyprojection across free, stale, unknown and live-holder locks, away status and an old beacon - invalid inputs, and the unchanged plain note path The change is CLI-only, with no UI and no Herdr lifecycle, so no screenshots or Herdr lab were needed. Evidence is CLI transcripts. The temp homes were removed and the worktree is clean.announcerepairs with exactly one wake and no new notereceipts --after <cursor>and sees only replies newer than its cursorreadysays can_receive true only for a live harness lock holder with a fresh wake beacon, and reports away statusreadydoes not infer liveness from a lock file (free, dead pid, non-harness pid, stale beacon, holder exited) and never modifies the locknote/list/drainpath andfm-lock.sh statuswording are unchangedEvidence: Live CLI transcript: idempotency, repair, acked-no-wake, receipts, ready, adversarial inputs
Source: Live CLI transcript: idempotency, repair, acked-no-wake, receipts, ready, adversarial inputs
Evidence: Live CLI transcript: reply cursor increments and readiness with live holder/away/stale beacon
Source: Live CLI transcript: reply cursor increments and readiness with live holder/away/stale beacon
Evidence: Driver script (contract)
Source: Driver script (contract)
Evidence: Driver script (cursor + ready)
Source: Driver script (cursor + ready)
Evidence: Focused test log
Source: Focused test log
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-inbox.sh:358- A repair or replay can add a wake for a note the primary has already acknowledged.finish_note_result(replay path) andcmd_announce(line 515) callannounce_notefor any note that has no marker, andnote_pathalso resolves notes in inbox/handled/. Concrete sequence:note --request-id r1 --jsonsaves the note but the wake append fails, so it exits 3. The primary wakes for something else, sees the note during its normal drain, and runsdrain --ack. The client then follows the documented repair flow (announce <id>, or a retry with r1). Acheckwake is appended for a note that is already handled, so the primary spends a model turn on an empty inbox. The intent is explicitly cost-sensitive about spending tokens. Fix: inannounce_note/finish_note_result, skip the append when the note is in handled/ and report it as acknowledged (announced is not needed) rather than appending a wake.bin/fm-inbox.sh:646-receiptsfails the whole view on a single bad or moving file.parse_recordcallsPath.read_text(encoding="utf-8")with no error handling. (1) Ifdrain --ackmoves a note from inbox/ to handled/ between the glob and the read, a FileNotFoundError traceback makesreceiptsexit nonzero. A client that polls receipts while the primary acks notes will hit this. The same race can also list one note under both pending and handled in one snapshot. (2) If any note or reply contains bytes that are not valid UTF-8 (note -accepts arbitrary stdin), a UnicodeDecodeError breaksreceiptspermanently, because handled notes are never purged. Fix: skip files that vanish (catch FileNotFoundError), decode with errors="replace", and drop from pending any id that also appears in handled.bin/fm-inbox.sh:542-next_reply_seqrewrites.replies/.seqin place withprintf >, which truncates the file before writing. If that write is interrupted, or the file is lost, the next reply restarts at seq 1. Its cursor000000000001|...then sorts below any cursor a client already holds, soreceipts --aftersilently hides every new reply until the counter climbs back past the old value. Fix: write the counter via a temp file and mv, and/or seed it from max(seq of existing reply files) + 1 so the cursor can never go backwards.bin/fm-inbox.sh:684- Simplification: the receipts reply cursor has a fallback for replies "recorded before the sequence existed": a missing or non-numeric seq becomes 0, with ties broken by at/id.replyis new in this change and every reply it writes carriesseq=, so no shipped reply lacks a sequence. No intent requirement needs this legacy path. Recommend removing it and treating a reply without a valid seq as malformed, rather than keeping a second ordering rule.🔧 Fix applied.
1 info still open:
bin/fm-inbox.sh:513-cmd_announcechanges any non-truestate toacknowledgedwhen the note is in handled/, and then emits"announced": falseat line 547. That includesunknown, a legacy note written before the marker existed. For that note the JSON claims it was not announced.receiptsreportsannounced: nullfor the same note (see the enrich comment: "not announced" cannot be read off this state). Concrete case: a pre-marker note that was drained withdrain --ack, thenannounce --json <id>, gives{"outcome":"replay","announced":false,"acknowledged":true}, whilereceiptsgivesannounced: null. Fix: keep the original state and passunknownas the announced argument when the prior state wasunknown, so emit_note_json prints null.✅ **Test** - passed
✅ No issues found.
announcerepairs with exactly one wake and no new notereceipts --after <cursor>and sees only replies newer than its cursorreadysays can_receive true only for a live harness lock holder with a fresh wake beacon, and reports away statusreadydoes not infer liveness from a lock file (free, dead pid, non-harness pid, stale beacon, holder exited) and never modifies the locknote/list/drainpath andfm-lock.sh statuswording are unchangedbash tests/fm-inbox.test.sh(focused suite for the changed contract, 16 cases, all ok)drive-console-contract.sh: live CLI drive in a throwaway FM_HOME: multiline request-id retry, wake failure made real with a read-only .wake-queue (exit 3, replay,announcerepair, second announce), drain --ack then repair/replay, reply + duplicate reply, receipts bounds with --all-pending, ready for free/unknown/stale locks, fm-lock.sh status, bad/empty/dash-body inputs, the plain human note/list pathdrive-cursor-and-ready.sh:receipts --after <cursor>returns only the new reply; deleted .replies/.seq then new reply stays at seq 4;readywith a liveclaude-named lock holder + fresh beacon, then .afk=away, then a 2h-old beacon, then the holder exits; the lock file is unchanged afterwards✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → auto-fixed → no changes applied (2) ✅
🔧 Fix applied.
1 warning still open:
🔧 No changes applied.
1 warning still open:
🔧 No changes applied.
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.