Repository navigation
feat(bin): wake-outcome ledger for measured coordinator attention cost - #1284
sbracewell64 wants to merge 3 commits into
Conversation
f1e0c0f to
1518120
Compare
|
Automated reminder: thanks for the PR! This branch currently has a merge conflict with the base branch. When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again. Noted for firstmate#1284 at |
Supervision attention cost was estimated, never measured, and the dormant model-promotion system is gated on exactly this instrument plus a terminal per-task outcome line. Adds data/wake-ledger.tsv, a per-home append-only evidence record, and bin/fm-wake-ledger.sh as its single owner of format, closed outcome vocabulary, and append semantics. Three record kinds: one wake record per drained wake, one outcome record per handled wake joined on the wake-queue sequence, and one terminal task record per finished task. The wake half is written deterministically by the drain and the outcome half by the coordinator. That split is deliberate: a single coordinator-written line would make measured attention cost fall whenever the recording step was skipped, so the metric would move without the underlying quantity moving. Splitting it gives a denominator that is stable under no change and turns missing coverage into a reported number instead of a silent undercount. The ledger cannot block, delay, alter, or fail a wake. Its call site sits below the drain's authoritative print-and-delete boundary, with stdout discarded and failure ignored; the ledger takes no lock and writes one capped line per record. Teardown writes the terminal record immediately before deleting the task metadata, the last moment that task's harness, model, and effort are recoverable anywhere. It lives under data/ rather than state/ because teardown clears state/<id>.* and this evidence must outlive the tasks it describes. Watcher-absorbed wakes stay out by design: they never reach the coordinator, so they are not part of the quantity being measured.
1518120 to
083a709
Compare
|
Automated reminder: thanks for the PR! This branch currently has a merge conflict with the base branch. When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again. Noted for firstmate#1284 at |
|
Speaking as Kun's firstmate: closing this as stale. It has been waiting on a contributor update for 14+ days with no author push or comment. Reopen if you want to pick it back up. |
Intent
Add a wake-outcome ledger so firstmate's coordinator attention cost becomes measurable rather than estimated, and so the dormant model-promotion system can activate.
Why: the captain's scheduling policy (config/crew-dispatch.json _scheduling.telemetry.must_answer) requires telemetry answering why work was queued or promoted, which threshold fired, wait times, and whether thresholds are tuned right - none of which was collectable. The dormant model-promotion design (data/model-onboarding-policy/report.md sections 10.1/10.3/10.6) names this ledger plus a terminal per-task outcome line as its single named first instrument, and requires that it use no second evidence store and that a later task extend this file format rather than define a competing one. The captain's instrumentation doctrine also governs: the required instrumentation is whatever makes the quantity verifiable after deployment, and a signal used to detect change must be stable under no change.
This work followed a mandatory design review: the design was written to data/wake-outcome-ledger/design.md, reviewed and APPROVED by firstmate before any implementation, with three decisions explicitly ruled. Those three are deliberate and must not be flagged as mistakes:
Other deliberate choices a reviewer reading only the diff would not know:
Verification already done locally: the new tests/fm-wake-ledger.test.sh passes all 10 cases; tests/fm-teardown.test.sh passes 35 cases including 3 new ledger cases; fm-backend old-vs-new teardown conformance, teardown-endpoint-safety, gotmp, test-run and lint suites all pass; bin/fm-lint.sh is clean at pinned ShellCheck 0.11.0; bin/fm-doc-audience-check.sh is clean; and the test coverage guard accepts the new test. Three watcher suites (fm-pi-watch-extension, fm-turnend-guard, fm-watcher-lock) fail or hang in this worktree, but that is a known pre-existing fleet defect: a Stop hook keeps re-arming a watcher from the worktree, and those suites are sensitive to an externally armed watcher. I proved this by reverting my drain change and re-running: they fail byte-identically at baseline, so they are unrelated to this change.
What Changed
bin/fm-wake-ledger.shmaintains a durable append-only ledger atdata/wake-ledger.tsv(deliberately outside volatilestate/) with two records per wake: a deterministic wake record appended byfm-wake-drain.shbelow its print-and-delete boundary, and a coordinator-written outcome record joined on(seq, queued)so distinct wakes stay distinct across state resets — the join key was widened from bareseqafter the pipeline review flagged silent collapse after a sequence reset. The ledger enforces a closed outcome vocabulary, sanitizes fields, caps lines under the PIPE_BUF atomic-append bound, and can never block, alter, or fail a wake.bin/fm-teardown.shnow writes a best-effort terminal task record (landed/abandoned, with--forcemapping toabandoned) immediately before deleting task metadata — the last moment harness/model/effort are recoverable; an unwritable ledger warns on stderr but never fails teardown. Areportcommand surfaces coverage, latency percentiles, outcome mix, and per-profile joins, turning missed coordinator recordings into a reported number instead of a silent undercount.tests/fm-wake-ledger.test.sh(11 cases, including unwritable-ledger isolation, delayed-ledger non-blocking, concurrent-append integrity, and reused-seq joins) plus 3 new teardown ledger cases; docs updated inAGENTS.md,docs/architecture.md,docs/configuration.md, anddocs/scripts.md. Watcher-absorbed wakes are deliberately excluded — they never reach the coordinator.Risk Assessment
✅ Low: The round-2 commit implements the requested (seq, queued) join fix exactly as instructed — write side, report dedup, coverage join, unknown-never-dedups rule, docs, and a targeted seq-reuse regression test — without touching the drain path or any captain-ruled decision, leaving no open findings.
Testing
Ran the two targeted suites (tests/fm-wake-ledger.test.sh, tests/fm-teardown.test.sh) — all 47 cases pass including the never-block and best-effort-teardown guarantees — then demonstrated the full workflow end-to-end with the real production scripts, capturing a CLI transcript showing wake records written by the drain, coordinator outcome records joined on (seq, queued), the terminal task record, the durable TSV at data/wake-ledger.tsv, and a report that answers the scheduling policy's telemetry questions (wake volume, coverage with missing outcomes reported not hidden, latency, outcome mix, per-profile model join). No findings.
Evidence: End-to-end ledger workflow transcript (enqueue → drain → outcomes → terminal record → report)
===== 2b. the drain wrote one deterministic wake record per deduped row ===== v1 wake 1785379594 seq=2 kind=signal key=task-demo1.status task=task-demo1 queued=1785379592 latency=2 v1 wake 1785379594 seq=3 kind=heartbeat key=heartbeat task=- queued=1785379592 latency=2 v1 wake 1785379594 seq=4 kind=check key=task-demo2.check.sh task=task-demo2 queued=1785379594 latency=0 ===== 3. out-of-vocabulary token ===== error: unknown outcome token: shrugged (absorbed inspected steered decided escalated repaired false-positive) -> refused, exit 2 ===== 6. fm-wake-ledger.sh report ===== wakes: 3 total, 2 with a recorded outcome, 1 unrecorded (67% coverage) outcomes: by token: absorbed 1 decided 1 tasks: 1 terminal (landed 1) per profile: pi/openai-codex/gpt-5.6-sol/medium tasks 1 wakes/task 1.0 coordinator response latency (queued -> drained), seconds: min 0 median 2 p90 2 max 2Evidence: Reproducible demo script
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed ✅
bin/fm-wake-ledger.sh:482- The durable ledger's identity/join key is the wake-queue sequence from state/.wake-queue.seq, but state/ is volatile while data/wake-ledger.tsv is durable evidence spanning weeks. After a state wipe or home rebuild, sequences restart and distinct wakes in the durable file share a seq. cmd_report dedups wake records by seq alone (wake_seen, line 482) and outcome records by seq alone (outcome_seen, line 493), so an all-records report silently collapses distinct wakes/outcomes across a seq reset — undercounting the very denominator the design requires to be stable under no change. The live outcome join is unaffected (the bounded tail read takes the newest matching wake), and wake records already carry queued= which could disambiguate report dedup (seq SUBSEP queued); outcome records carry no second key, so a complete fix would touch the approved seq-as-join-key ruling — hence ask-user rather than auto-fix.bin/fm-teardown.sh:1237- The terminal outcome vocabulary accepts landed|failed|abandoned, but the only caller (fm-teardown.sh) maps --force to abandoned and everything else to landed, so 'failed' is currently unreachable vocabulary with no writer. This is coherent (teardown refuses un-landed work without --force), but worth confirming that reserving 'failed' for a future caller is intended rather than a missed mapping.🔧 Fix: join wake outcomes on (seq, queued) across state resets
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-wake-ledger.test.sh— all 11 cases pass (record format, closed vocabulary, sanitization, task attribution, drain integration, unwritable-ledger never changes drain rows/exit, delayed ledger never blocks a concurrent wake append, concurrent-append integrity, report counts/coverage, reused-seq (seq,queued) join)bash tests/fm-teardown.test.sh— all 36 cases pass, including the 3 new ledger cases: terminal record with the meta's harness/model/effort written before metadata deletion, --force records outcome=abandoned, unwritable ledger warns on stderr but never fails or halts teardownManual end-to-end demo (/tmp/no-mistakes-evidence/01KYRDQ3AZH2SPJ0X4CEQ869N5/e2e-demo.sh): enqueued wakes via production fm_wake_lib, drained with the real bin/fm-wake-drain.sh, recorded coordinator outcomes per the new AGENTS.md instruction, wrote the teardown-style terminal task record, verified an out-of-vocabulary token is refused with exit 2, and ranfm-wake-ledger.sh reportshowing coverage (67% with one deliberately unrecorded wake), latency percentiles, outcome mix, and the per-profile joingit status --porcelain— worktree left clean, no transient test artifacts✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.