Repository navigation
feat(bin): record worker event time and task relaunches in fleet ledger - #49
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
I approve the wake question.
Approved first stories 4 and 12 of the Wake initiative:
atmember from the status line's[at=<epoch>]stamp; docs/fleet-ledger.md documents it; existing members unchanged. Verify: a status line stamped[at=N]yields a record with at=N and its other members unchanged; the ledger suite passes.Context: the captain approved Wake on 2026-11-21 ("I approve the wake question"), a firstmate throughput retrospective: a deterministic daily collector plus a thin /wake judgment skill. Approved defaults: daily note written automatically as a file, weekly /wake with chat summary; no cost capture yet; Sunday weekly cutoff; one manual retro first; changes land only in this fork (github.com/clarsen/firstmate), nothing offered to upstream firstmate. The product-owner ticket tree is ~/src/therealfirstmate/data/wake-value-model-revise/tickets (initiative-wake.md, value-model.md, epic-wake-daily-record/).
What Changed
task.statusledger records now include an optionalatmember, taken from the status line's[at=<epoch>]stamp when it is valid. The member is left out when the line has no valid stamp, and the existingstate/key/textmembers are unchanged.task.relaunchedevent with a newfm-fleet-ledger.sh relaunched <task>command. When the ledger is on,bin/fm-spawn.sh --relaunchwrites this event once the replacement worker has launched;fm-control.sh relaunchgoes through the same path. Fresh dispatches still write onlytask.dispatched. Before writing the event, the command records any status lines still waiting for that task.docs/fleet-ledger.mdfor both changes: the new event and theatmember, an updated example, relaunch added to the capture triggers, and "relaunch events" removed from the deferred follow-ups. Adds tests totests/fm-fleet-ledger.test.shandtests/fm-control-relaunch.test.sh.Risk Assessment
✅ Low: The change adds one optional
atmember and one new event to an opt-in ledger. Each relaunch path writes exactly onetask.relaunched: fm-control relaunch calls fm-spawn --relaunch once, and fm-control has no emitter of its own. Theatvalue comes from the shared parser in fm-classify-lib, so the existing members are unchanged.Testing
I ran both ledger test suites and drove the real worker status command and
fm-fleet-ledger.sh relaunchedin a disposable marked lab home. Stamped status lines getatwith the other members unchanged, and bad or missing stamps add noat. A relaunch writes exactly onetask.relaunchedrecord after capturing pending status, and bad arguments and the flag-off case write nothing. The fm-control and fm-spawn relaunch paths, and the fresh-dispatch case with no relaunch record, passed in the hermetic suites that run the real scripts with a stubbed tmux. A fully live tmux spawn and relaunch could not run because this host's tmux server crashes oncapture-pane -p. I removed the lab home and its treehouse slot afterwards, and the worktree is clean.[at=1790000123]and the ledger gets a task.status record with at=1790000123 and unchanged state, key and text (lab home, synthetic lines)[at=soon]stamp gives a record with noatmember and the other members unchangedfm-fleet-ledger.sh relaunched <task>writes exactly one task.relaunched record with the task id, after first capturing the task's pending status linefm-control.sh relaunchand a directfm-spawn.sh --relauncheach write exactly one relaunch record, and a fresh dispatch writes nonebash tests/fm-control-relaunch.test.sh: 'fm-control relaunch records exactly one task.relaunched event' and 'fm-spawn --relaunch records exactly one task.relaunched event' pass. `bash tests/fm-fleet…Evidence: Live ledger CLI transcript (Story 4 and Story 12)
Evidence: Fleet ledger suite output
Evidence: Control relaunch suite output
Evidence: Attempted live tmux spawn/relaunch transcript (host tmux crash)
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-control.sh:1268- Onlyfm-control.sh relaunchwritestask.relaunched. Thefm-spawn.sh --relaunchheader (bin/fm-spawn.sh:67-75) still documents a supported direct path, "deliberately re-launching an already-stopped task". That path replaces the worker for an existing task, and bin/fm-spawn.sh:8536 skipsdispatchedwhen RELAUNCH=1, so it writes no ledger event at all. A captain who relaunches a stopped task this way leaves no record, which conflicts with Story 12 ("a relaunch of an existing task writes a new ledger event"). The docs row fortask.relaunched(docs/fleet-ledger.md:33) and the producer comment (bin/fm-fleet-ledger.sh:15, "successful replacement only") describe only the control-plane path. One remedy is to write the event from fm-spawn's existing ledger line when RELAUNCH=1. The trade-off is that the event would then fire when the replacement is launched rather than after it is confirmed alive. The other remedy is to document that a direct fm-spawn relaunch is not recorded. Which semantics to choose is a product decision.🔧 Fix applied.
1 warning still open:
bin/fm-control.sh:1268- Onlyfm-control.sh relaunchwritestask.relaunched. Thefm-spawn.sh --relaunchheader (bin/fm-spawn.sh:67-75) still documents a supported direct path, "deliberately re-launching an already-stopped task". That path replaces the worker for an existing task, and bin/fm-spawn.sh:8536 skipsdispatchedwhen RELAUNCH=1, so it writes no ledger event at all. A captain who relaunches a stopped task this way leaves no record, which conflicts with Story 12 ("a relaunch of an existing task writes a new ledger event"). The docs row fortask.relaunched(docs/fleet-ledger.md:33) and the producer comment (bin/fm-fleet-ledger.sh:15, "successful replacement only") describe only the control-plane path. One remedy is to write the event from fm-spawn's existing ledger line when RELAUNCH=1. The trade-off is that the event would then fire when the replacement is launched rather than after it is confirmed alive. The other remedy is to document that a direct fm-spawn relaunch is not recorded. Which semantics to choose is a product decision.✅ **Test** - passed
✅ No issues found.
[at=1790000123]and the ledger gets a task.status record with at=1790000123 and unchanged state, key and text (lab home, synthetic lines)[at=soon]stamp gives a record with noatmember and the other members unchangedfm-fleet-ledger.sh relaunched <task>writes exactly one task.relaunched record with the task id, after first capturing the task's pending status linefm-control.sh relaunchand a directfm-spawn.sh --relauncheach write exactly one relaunch record, and a fresh dispatch writes nonebash tests/fm-control-relaunch.test.sh: 'fm-control relaunch records exactly one task.relaunched event' and 'fm-spawn --relaunch records exactly one task.relaunched event' pass. `bash tests/fm-fleet…bash tests/fm-fleet-ledger.test.sh(rc=0, includes the new at-stamp and no-relaunch-on-fresh-dispatch assertions)bash tests/fm-control-relaunch.test.sh: both new ledger relaunch tests pass. The suite as a whole exits 1 at the later 'Herdr Pi relaunch' test, which fails becausepiis not on PATH on this host; that test is unrelated to this change.Live:bin/fm-lab-home.sh create, thenbin/fm-brief.sh wake-live sample --mode local-onlyin the lab home, then the generated worker status command run with stamped, unstamped and malformed linesLive:bin/fm-fleet-ledger.sh relaunched wake-livewith a pending status line, the usage-guard cases, and the flag-off caseAttempted live: realbin/fm-spawn.sh ... --harness claudeon a privatetmux -L fm-labsocket; blocked by the host tmux server crashing on capture-pane✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.