Skip to content

feat(bin): record dispatch decisions and add a calibration replay - #318

Merged
sKeLe100 merged 4 commits into
mainfrom
fm/dispatch-decision-records
Nov 23, 2026
Merged

sKeLe100 merged 4 commits into
mainfrom
fm/dispatch-decision-records

Conversation

@sKeLe100

Copy link
Copy Markdown
Owner

Intent

Record every dispatch decision first, and re-score a router in about two weeks. The PC02 router scout concluded no PC02 model can serve as the router: the loss is unrecorded dispatch inputs, not model intelligence. Captain's words on the endpoint: "what about reevaluating every time you dispatch a task, you outpit to yourself the confidence in making that decision (based on fleet, model needed, effort needed, dispatch matrix, benchmarks, etc) if that's going to be the end of the jev router investigation" - the deepened version was chosen: each dispatch record carries a confidence with its inputs, and a later replay scores confidence against real outcomes.

What Changed

  • bin/fm-spawn.sh gains an optional --decision-record <json-file> flag for fresh ship/scout spawns. The file must hold one JSON object with a numeric confidence from 0 to 100. When confidence is below 70 it must also name runner_up and runner_up_why_lost. The record is attached to the existing dispatch telemetry event as decision_record. The flag is refused on --relaunch and --secondmate, and omitting it leaves the event unchanged.
  • New read-only bin/fm-dispatch-calibration.sh joins each recorded decision_record to outcomes already in the telemetry archive: an outcome event, a later redelegation, or a delegation with had_issue=true. It reports the Brier score and a reliability table by 10-point confidence band, as text or --json. Unresolved tasks are excluded from the score. The helper is registered in bin/fm-test-run.sh.
  • docs/llm-usage-telemetry.md documents the decision record and the calibration outcome signals. New tests are in tests/fm-dispatch-calibration.test.sh, with extended coverage in tests/fm-llm-usage-telemetry-integration.test.sh.

Risk Assessment

✅ Low: Both round-1 fixes are correct in the current code and have regression tests, and the replay is read-only with the new spawn flag opt-in and validated.

Testing

I ran the two targeted test files that drive the real bin/fm-spawn.sh, fm-control.sh, fm-teardown.sh and fm-dispatch-calibration.sh against isolated fake-tmux fixtures. All 25 checks passed, and the configured baseline command had already passed. They cover decision records being attached to dispatch events, the Brier score and reliability bands, and the refusal of malformed or multi-object records. They also cover the redispatched replacement not being scored as a failure and a below-70 confidence decision needing a named runner-up. No live Herdr or harness primary was needed, because the change adds no pane or UI surface.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Replay joins dispatch decisions to outcomes and reports Brier score and reliability bands (local fixture archive, real CLI) ✅ pass live fm-dispatch-calibration.test.sh.log
fm-spawn --decision-record attaches parseable decision JSON to the dispatch event; the record is unchanged without the flag ✅ pass live fm-llm-usage-telemetry-integration.test.sh.log
Adversarial: a malformed or multi-object --decision-record is refused before any task record or dispatch event ✅ pass live fm-llm-usage-telemetry-integration.test.sh.log
Adversarial: a redispatched replacement task is not scored as a failure ✅ pass live fm-dispatch-calibration.test.sh.log
A below-70 confidence decision must name its runner-up and why it lost ✅ pass live fm-llm-usage-telemetry-integration.test.sh.log
Evidence: calibration test log

Source: calibration test log

ok - fm-dispatch-calibration.sh: joins outcomes to decisions and reports Brier plus reliability bands
ok - fm-dispatch-calibration.sh: text mode prints a summary line and a reliability table
ok - fm-dispatch-calibration.sh: decisionless and malformed records are ignored, unresolved tasks excluded
ok - fm-dispatch-calibration.sh: defaults to FM_HOME/data and honors FM_DATA_OVERRIDE
ok - fm-dispatch-calibration.sh: empty archives report zero; a missing archive is a clear error
ok - fm-dispatch-calibration.sh: reads the archive without writing it
ok - fm-dispatch-calibration.sh: a redispatched replacement is not scored as a failure
Evidence: telemetry integration test log

Source: telemetry integration test log

ok - fm-spawn.sh: a real spawn records purpose in the task's own meta and in a dispatch archive record
ok - fm-spawn.sh: a real redelegated spawn records from_task_id in both dispatch and delegation events
ok - fm-spawn.sh: a fresh spawn without --redelegated-from omits from_task_id from its dispatch record
ok - fm-spawn.sh: --decision-record attaches the decision to the dispatch event as parseable JSON
ok - fm-spawn.sh: without --decision-record the dispatch record is unchanged
ok - fm-spawn.sh: a malformed --decision-record is refused before any task record or dispatch event
ok - fm-spawn.sh: a multi-object --decision-record is refused before any task record or dispatch event
ok - fm-spawn.sh: a below-70 confidence decision record must name its runner-up and why it lost
ok - fm-spawn.sh: a path-traversing --redelegated-from is refused before any meta is read
ok - fm-spawn.sh: spawns are isolated onto the fake tmux backend and never target the live default Herdr session
ok - fm-control.sh relaunch: a real harness switch records the delegation chain, reusing --note as reason
warning: You appear to have cloned an empty repository.
ok - fm-teardown.sh: a real landed teardown records an outcome=landed archive record
warning: You appear to have cloned an empty repository.
ok - fm-teardown.sh: a real --force teardown of unlanded work records an outcome=abandoned archive record
ok - fm-control.sh relaunch: a rolled-back relaunch leaves a journal that does not claim a relaunch happened
warning: You appear to have cloned an empty repository.
ok - fm-teardown.sh: an outcome after a completed relaunch records retried=true
warning: You appear to have cloned an empty repository.
ok - fm-teardown.sh: a rolled-back relaunch is not reported as retried
warning: You appear to have cloned an empty repository.
ok - fm-teardown.sh: telemetry follows FM_DATA_OVERRIDE instead of FM_HOME/data
ok - no case in this file reached herdr, so no live panes are left behind

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 2 issues found → auto-fixed (2) ✅
  • 🚨 bin/fm-dispatch-calibration.sh:97 - Outcome rule 3 counts a delegation with had_issue=true as a failure for task_id. But fm-spawn.sh emits the redispatch delegation (trigger=redispatch) with task_id=<the NEW replacement task> and from_task_id=<the failed task>, so the replacement is scored as a failure even though it did nothing wrong. Concrete case: task A is dispatched and fails. B is spawned with --redelegated-from A, which emits dispatch(B, from_task_id=A) and delegation(task_id=B, had_issue=true). A is correctly a failure via rule 2. B has no outcome yet, so rule 3 marks it actual=0 while it is still in flight, or even if it later fails for unrelated reasons. Its confidence is then compared against a spurious 0, which inflates the Brier score and skews the reliability bands. This is the signal the replay exists to compute. Rule 3 only fits the relaunch delegation from fm-control.sh:1361, where task_id is the same task that had the issue. Fix: for rule 3, count only delegations with trigger=relaunch (or exclude trigger=redispatch). Alternatively, key the redispatch case on from_task_id, which rule 2 already does.
  • ⚠️ bin/fm-spawn.sh:1243 - --decision-record is documented and validated as holding "one JSON object", but the check is jq -e &#39;type==&#34;object&#34;&#39;, which accepts a file containing several concatenated objects. At emit time jq -c . then prints several lines. The multi-line string is archived, fromjson fails in the calibration replay, and the decision is silently dropped from the score. The emit path also swallows a jq -c failure and records the dispatch with no decision at all, instead of refusing as the validation promises. Fix: validate with jq -s -e &#39;length==1 and (.[0]|type==&#34;object&#34;)&#39;, or pass the validated single-line output straight through.

🔧 Fix applied.
1 warning still open:

  • ⚠️ tests/fm-dispatch-calibration.test.sh - The fix round changed the calibration replay to exclude trigger=redispatch delegations (rule 3) and tightened --decision-record validation to a single object, but added no regression tests. Nothing pins that a redispatched replacement task is not scored as a failure. Nothing pins that a file with two concatenated JSON objects is refused. Both could silently regress.

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Replay joins dispatch decisions to outcomes and reports Brier score and reliability bands (local fixture archive, real CLI) ✅ pass live fm-dispatch-calibration.test.sh.log
fm-spawn --decision-record attaches parseable decision JSON to the dispatch event; the record is unchanged without the flag ✅ pass live fm-llm-usage-telemetry-integration.test.sh.log
Adversarial: a malformed or multi-object --decision-record is refused before any task record or dispatch event ✅ pass live fm-llm-usage-telemetry-integration.test.sh.log
Adversarial: a redispatched replacement task is not scored as a failure ✅ pass live fm-dispatch-calibration.test.sh.log
A below-70 confidence decision must name its runner-up and why it lost ✅ pass live fm-llm-usage-telemetry-integration.test.sh.log
  • bin/fm-test-run.sh --changed --exclude-family real-herdr-gated --exclude-quarantined --pc02-if-idle
  • bash tests/fm-dispatch-calibration.test.sh
  • bash tests/fm-llm-usage-telemetry-integration.test.sh
  • baseline bin/fm-test-run.sh --changed ...
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@sKeLe100
sKeLe100 merged commit 9fcd75e into main Nov 23, 2026
25 checks passed
sKeLe100 pushed a commit that referenced this pull request Nov 23, 2026
…he upstream catch-up

Fork main moved from 397c859 to 968740b while the catch-up branch was
in validation, leaving the PR in conflict with its base. This is a true
merge of origin/main into the branch, never a rebase, so the 221-commit
upstream merge and its resolution commits stay intact.

Three conflicts, each an additive same-spot insertion kept on both sides:
- .agents/skills/operational-home-layout/SKILL.md: the branch's
  ready-after-green, record-export-root and status-archive rows plus
  main's underused-capacity-threshold row (#316), in sorted order.
- bin/fm-test-run.sh: the branch's fm-capacity.sh and
  fm-lane-vitals-lib.sh mapping arms plus main's
  fm-dispatch-calibration.sh and fm-llm-usage-lib.sh arms (#318).
- tests/fm-tool-update-check.test.sh: upstream's
  test_a_failing_probe_still_reports_its_version plus main's
  test_windows_interop_copy_is_never_a_candidate (#319), both run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant