Repository navigation
feat: add opt-in fleet activity ledger - #5375
Merged
Merged
Conversation
Homes that create config/fleet-ledger get an append-only JSONL file, state/fleet-ledger.jsonl, recording task.dispatched, task.status, task.merged, and task.cleaned_up so outside tools can follow a fleet. With the flag absent each producer does one file test and nothing else. docs/fleet-ledger.md owns the record contract and its documented limits.
…test.sh: the replacement-wake test now waits for the prompt to start before releasing it. The focused test passed twice, and git diff --check passed
RajeshRajendiran
added a commit
to RajeshRajendiran/firstmate
that referenced
this pull request
Sep 23, 2026
Intent
A user asked publicly for an "official hook for firstmate status": a stable, documented ledger that external tools can read to follow all the activity in a firstmate fleet.
"ok let's do it - make it opt-in to avoid overhead for everyone though"
A first attempt grew too complex in review. The follow-up decision:
"for activity ledger do C after your assessment of what the right minimum scope is, then ask a new crewmate to start from clean slate, potentially referencing what's done in that branch but don't inherit all the complexity"
The first attempt is kept for reference on branch fm/fm-fleet-activity-ledger-r1 on origin.
Minimum scope (firstmate's assessment - this IS the spec; everything else is out):
When this work reaches its promised terminal outcome, report it as typed data
(never as a sentence for someone to parse) by running exactly:
~/fm-homes/firstmate/bin/fm-public-followup-emit.sh
--stage-in ~/fm-homes/fmdev-f1
--obligation public-fleet-ledger
--relation rel-fleet-ledger-v2
--source-home secondmate:fmdev-f1
--work-id fm-fleet-ledger-min-r1
--generation 2
--outcome pr-merged
--deliverable pr_url=
--outcome-text ''
Do not post anything publicly yourself and do not look for the public thread:
the home that owes that reply is on another machine and owns it. Leave the
result exactly where the command above puts it; that home collects it over the
same route it reaches you on, and nothing here needs a path back to it.
What Changed
config/fleet-ledgerpresence flag and an append-only JSONL ledger for task dispatch, status, merge, and cleanup events.Risk Assessment
Both findings raised here (status-text contract and merge/cleanup status capture) were resolved by the review decisions below.
Testing
The focused behavioral test passed. Direct executable-writer checks showed zero ledger writes with the flag absent and the expected verbatim status text, event order, and offset cleanup with it present. A named Herdr lab was provisioned and torn down, but the gate’s spawn guard prevented the live worker lifecycle; its diagnostic and the writer’s JSONL output were captured. Temporary worktree data was removed.
Evidence: Named Herdr lab attempt and spawn refusal
Source: Named Herdr lab attempt and spawn refusal
Evidence: Executable ledger writer output
Source: Executable ledger writer output
Live lifecycle validation (run outside the gate)
The required live worker lifecycle could not run inside the validation gate, because the fleet guard refuses
fm-spawnwheneverNO_MISTAKES_GATEis set.The worker therefore ran it from an ordinary (non-gate) process against a byte-exact snapshot of pipeline head
8360eff9, and the test step was approved under that recorded exception.The pushed head
d29ef731differs from8360eff9only by the document step's wording edits todocs/configuration.mdanddocs/fleet-ledger.md; no code changed.Evidence file:
data/fm-fleet-ledger-min-r1/live-evidence/run-4-head-8360eff9.txtin the supervising firstmate home.Setup: a named
fm-lab-Herdr session throughfm-herdr-lab.shwith its teardown trap; disposable homes under/private/tmp; a throwaway raw-shell worker spawned withfm-spawn.sh --backend herdr --mode local-only; the real watcher poll viafm-watch-checkpoint.sh; thenfm-merge-local.shandfm-teardown.sh.Flag on - the final ledger:
{"v":1,"ts":1790136102,"event":"task.dispatched","task":"ledger-live-on","kind":"ship","project":"ledgerlive-on","harness":"sh","model":null} {"v":1,"ts":1790136106,"event":"task.status","task":"ledger-live-on","state":"working","key":null,"text":" live worker started"} {"v":1,"ts":1790136106,"event":"task.status","task":"ledger-live-on","state":"needs-decision","key":"live-pick","text":" live worker asks a question"} {"v":1,"ts":1790136106,"event":"task.status","task":"ledger-live-on","state":"done","key":null,"text":" live worker ready in branch"} {"v":1,"ts":1790136112,"event":"task.merged","task":"ledger-live-on","via":"local"} {"v":1,"ts":1790136117,"event":"task.cleaned_up","task":"ledger-live-on"}Flag off - the same lifecycle (spawn, poll, local merge, teardown all exit 0) left no
*fleet-ledger*file instate/.The lab teardown verified the default Herdr session unchanged.
Review decisions
textis everything after the first colon, verbatim, then capped.mergedandcleaned_uphooks and preserves at-least-once delivery, because cleanup deletes the task's status log before the next watcher poll could read it.working [at=...]: setuprecordsstate: working(covered bytests/fm-fleet-ledger.test.shand the live run above).[key=default]finding: not applied; the shared status parser treats an unkeyed line as keydefault, so both recordnull, and preserving it would grow the minimum scope.Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-fleet-ledger.sh:137- The requiredtext = the status line after the first colon, verbatim, cappedcontract is contradicted here:status_line_noteremoves leading whitespace and a note-head[key=...]token. Fordone: [key=review] ready, the ledger recordsready, not[key=review] ready. docs/fleet-ledger.md:41 documents the same exception. Ask whether to honor the specified verbatim field; do not silently change the public contract.bin/fm-fleet-ledger.sh:190- The merge-time status capture, and its cleanup-time counterpart at bin/fm-fleet-ledger.sh:198, add an eager status producer beyond the specifiedwatcher's existing poll (status lines)andNo other hook sites. A status line written after a poll is published during merge or teardown instead of on a watcher poll; the lifecycle test explicitly relies on this path. This component is not required by the stated producer list. Ask whether to remove both eager captures; teardown's deletion of the status log makes that scope decision consequential.🔧 Fix applied.
4 issues (2 errors, 2 warnings) still open:
bin/fm-fleet-ledger.sh:137- The requiredtext = the status line after the first colon, verbatim, cappedcontract is contradicted here:status_line_noteremoves leading whitespace and a note-head[key=...]token. Fordone: [key=review] ready, the ledger recordsready, not[key=review] ready. docs/fleet-ledger.md:41 documents the same exception. Ask whether to honor the specified verbatim field; do not silently change the public contract.bin/fm-fleet-ledger.sh:190- The merge-time status capture, and its cleanup-time counterpart at bin/fm-fleet-ledger.sh:198, add an eager status producer beyond the specifiedwatcher's existing poll (status lines)andNo other hook sites. A status line written after a poll is published during merge or teardown instead of on a watcher poll; the lifecycle test explicitly relies on this path. This component is not required by the stated producer list. Ask whether to remove both eager captures; teardown's deletion of the status log makes that scope decision consequential.bin/fm-fleet-ledger.sh:133- A normally stamped line such asworking [at=1790000000]: setupreaches line 134 withverb=working [at=1790000000], which is rejected and recorded withstate:nullinstead ofworking. Keyed lines such asneeds-decision [key=pick-one]: ...lose their state the same way. Extract the leading state word without treating status metadata as part of it.bin/fm-fleet-ledger.sh:136- A real status writer emitsresolved [key=default]: ..., but this branch records its key asnull, indistinguishable from an unkeyed line. The shared parser returnsdefaultfor both cases; preservedefaultwhen a key token is explicitly present, whether before the colon or at the note head.bin/fm-fleet-ledger.sh dispatchedcheck; the focused producer test also exercised the full disabled lifecycle.tests/fm-fleet-ledger.test.shadditionally exercised the real producer scripts with a fake terminal backend.tests/fm-fleet-ledger.test.shManual disposable-home ledger CLI check: flag absent, then dispatch, capture, local merge, and cleanupManual boundary check: opt-in after status was written, 2000-character cap, unchanged poll, and incomplete lineAttempted named Herdr lab worker lifecycle; spawn timed out after 240 seconds and guarded teardown completed🔧 No changes applied.
2 warnings still open:
tests/fm-fleet-ledger.test.shbash .ledger-live-run.shagainst this worktree in a named Herdr lab; spawn refused and lab teardown succeededDirectbin/fm-fleet-ledger.shdispatch, capture, local merge, and cleanup with the flag absent and present; verified JSONL records and offset removal withjq✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.