Repository navigation
feat(bin): record dispatch decisions and add a calibration replay - #318
Merged
Merged
Conversation
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.
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
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.shgains an optional--decision-record <json-file>flag for fresh ship/scout spawns. The file must hold one JSON object with a numericconfidencefrom 0 to 100. When confidence is below 70 it must also namerunner_upandrunner_up_why_lost. The record is attached to the existingdispatchtelemetry event asdecision_record. The flag is refused on--relaunchand--secondmate, and omitting it leaves the event unchanged.bin/fm-dispatch-calibration.shjoins each recordeddecision_recordto outcomes already in the telemetry archive: anoutcomeevent, a later redelegation, or adelegationwithhad_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 inbin/fm-test-run.sh.docs/llm-usage-telemetry.mddocuments the decision record and the calibration outcome signals. New tests are intests/fm-dispatch-calibration.test.sh, with extended coverage intests/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.
Evidence: calibration test log
Source: calibration test log
Evidence: telemetry integration test log
Source: telemetry integration test log
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 adelegationwith had_issue=true as a failure fortask_id. Butfm-spawn.shemits 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-recordis documented and validated as holding "one JSON object", but the check isjq -e 'type=="object"', which accepts a file containing several concatenated objects. At emit timejq -c .then prints several lines. The multi-line string is archived,fromjsonfails in the calibration replay, and the decision is silently dropped from the score. The emit path also swallows ajq -cfailure and records the dispatch with no decision at all, instead of refusing as the validation promises. Fix: validate withjq -s -e 'length==1 and (.[0]|type=="object")', 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.
bin/fm-test-run.sh --changed --exclude-family real-herdr-gated --exclude-quarantined --pc02-if-idlebash tests/fm-dispatch-calibration.test.shbash tests/fm-llm-usage-telemetry-integration.test.shbaselinebin/fm-test-run.sh --changed ...✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.