Repository navigation
feat(bin): send dispatch router only the brief's task sections and add per-rule confidence floors - #5478
Conversation
* Sent Jev only the scaffolded Captain's intent and Firstmate spec sections, falling back to the whole brief when neither heading is present, so the identical setup, rules, and definition-of-done boilerplate no longer reads as a signal about the task * Added an optional per-rule min_confidence that replaces the global 0.6 floor for that rule; a picked rule below its own floor falls to the most probable other option that clears its floor, or returns ambiguous * Kept files with no declared floor on the exact previous behavior and kept the model blind to the new field * Recorded the live old-versus-new comparison over scaffolded fixtures
|
Speaking as Kun's firstmate: Diff review on HEAD VISION per-rule:
contract-class: opt-in — unconfigured (no TYPESAFE) unchanged; context trim + attestation: MATCH. |
|
Speaking as Kun's firstmate: this is merged. Thank you @zachlandes — really appreciate you taking the time on this. |
…d per-rule confidence floors (kunchenguid#5478) * feat(bin): send dispatch resolver only the brief's task sections * Sent Jev only the scaffolded Captain's intent and Firstmate spec sections, falling back to the whole brief when neither heading is present, so the identical setup, rules, and definition-of-done boilerplate no longer reads as a signal about the task * Added an optional per-rule min_confidence that replaces the global 0.6 floor for that rule; a picked rule below its own floor falls to the most probable other option that clears its floor, or returns ambiguous * Kept files with no declared floor on the exact previous behavior and kept the model blind to the new field * Recorded the live old-versus-new comparison over scaffolded fixtures * no-mistakes(review): share brief heading parser, add kind line, fix floors * no-mistakes(test): stop sending ship delivery mode to jev, keep scout tag * no-mistakes(document): docs: list shared brief heading lib in scripts inventory
…d per-rule confidence floors (kunchenguid#5478) * feat(bin): send dispatch resolver only the brief's task sections * Sent Jev only the scaffolded Captain's intent and Firstmate spec sections, falling back to the whole brief when neither heading is present, so the identical setup, rules, and definition-of-done boilerplate no longer reads as a signal about the task * Added an optional per-rule min_confidence that replaces the global 0.6 floor for that rule; a picked rule below its own floor falls to the most probable other option that clears its floor, or returns ambiguous * Kept files with no declared floor on the exact previous behavior and kept the model blind to the new field * Recorded the live old-versus-new comparison over scaffolded fixtures * no-mistakes(review): share brief heading parser, add kind line, fix floors * no-mistakes(test): stop sending ship delivery mode to jev, keep scout tag * no-mistakes(document): docs: list shared brief heading lib in scripts inventory
…d per-rule confidence floors (kunchenguid#5478) * feat(bin): send dispatch resolver only the brief's task sections * Sent Jev only the scaffolded Captain's intent and Firstmate spec sections, falling back to the whole brief when neither heading is present, so the identical setup, rules, and definition-of-done boilerplate no longer reads as a signal about the task * Added an optional per-rule min_confidence that replaces the global 0.6 floor for that rule; a picked rule below its own floor falls to the most probable other option that clears its floor, or returns ambiguous * Kept files with no declared floor on the exact previous behavior and kept the model blind to the new field * Recorded the live old-versus-new comparison over scaffolded fixtures * no-mistakes(review): share brief heading parser, add kind line, fix floors * no-mistakes(test): stop sending ship delivery mode to jev, keep scout tag * no-mistakes(document): docs: list shared brief heading lib in scripts inventory
…d per-rule confidence floors (kunchenguid#5478) * feat(bin): send dispatch resolver only the brief's task sections * Sent Jev only the scaffolded Captain's intent and Firstmate spec sections, falling back to the whole brief when neither heading is present, so the identical setup, rules, and definition-of-done boilerplate no longer reads as a signal about the task * Added an optional per-rule min_confidence that replaces the global 0.6 floor for that rule; a picked rule below its own floor falls to the most probable other option that clears its floor, or returns ambiguous * Kept files with no declared floor on the exact previous behavior and kept the model blind to the new field * Recorded the live old-versus-new comparison over scaffolded fixtures * no-mistakes(review): share brief heading parser, add kind line, fix floors * no-mistakes(test): stop sending ship delivery mode to jev, keep scout tag * no-mistakes(document): docs: list shared brief heading lib in scripts inventory
…d per-rule confidence floors (kunchenguid#5478) * feat(bin): send dispatch resolver only the brief's task sections * Sent Jev only the scaffolded Captain's intent and Firstmate spec sections, falling back to the whole brief when neither heading is present, so the identical setup, rules, and definition-of-done boilerplate no longer reads as a signal about the task * Added an optional per-rule min_confidence that replaces the global 0.6 floor for that rule; a picked rule below its own floor falls to the most probable other option that clears its floor, or returns ambiguous * Kept files with no declared floor on the exact previous behavior and kept the model blind to the new field * Recorded the live old-versus-new comparison over scaffolded fixtures * no-mistakes(review): share brief heading parser, add kind line, fix floors * no-mistakes(test): stop sending ship delivery mode to jev, keep scout tag * no-mistakes(document): docs: list shared brief heading lib in scripts inventory
…d per-rule confidence floors (kunchenguid#5478) * feat(bin): send dispatch resolver only the brief's task sections * Sent Jev only the scaffolded Captain's intent and Firstmate spec sections, falling back to the whole brief when neither heading is present, so the identical setup, rules, and definition-of-done boilerplate no longer reads as a signal about the task * Added an optional per-rule min_confidence that replaces the global 0.6 floor for that rule; a picked rule below its own floor falls to the most probable other option that clears its floor, or returns ambiguous * Kept files with no declared floor on the exact previous behavior and kept the model blind to the new field * Recorded the live old-versus-new comparison over scaffolded fixtures * no-mistakes(review): share brief heading parser, add kind line, fix floors * no-mistakes(test): stop sending ship delivery mode to jev, keep scout tag * no-mistakes(document): docs: list shared brief heading lib in scripts inventory
…d per-rule confidence floors (kunchenguid#5478) * feat(bin): send dispatch resolver only the brief's task sections * Sent Jev only the scaffolded Captain's intent and Firstmate spec sections, falling back to the whole brief when neither heading is present, so the identical setup, rules, and definition-of-done boilerplate no longer reads as a signal about the task * Added an optional per-rule min_confidence that replaces the global 0.6 floor for that rule; a picked rule below its own floor falls to the most probable other option that clears its floor, or returns ambiguous * Kept files with no declared floor on the exact previous behavior and kept the model blind to the new field * Recorded the live old-versus-new comparison over scaffolded fixtures * no-mistakes(review): share brief heading parser, add kind line, fix floors * no-mistakes(test): stop sending ship delivery mode to jev, keep scout tag * no-mistakes(document): docs: list shared brief heading lib in scripts inventory
…d per-rule confidence floors Port of upstream kunchenguid#5478, adapted to this fork's brief scaffold, which has no "## Captain's intent" / "## Firstmate spec" subsections: the resolver now sends Jev the top-level "# Task" and "# Acceptance criteria" sections instead, prefixed with "Brief kind: scout (report only)" on scout briefs, and still sends the whole brief when neither section exists. Ship delivery mode is not sent, matching upstream's measured over-routing finding. Rules may declare min_confidence (0 through 1), a confidence floor on that rule's own probability, distinct from the existing quota "floor" fields: a picked rule below its floor falls to the most probable other option that clears its own floor (global 0.6 when undeclared) with a fallback: line, else ambiguous. Files with no declared floors keep the global 0.6 check on the answer confidence exactly, and bootstrap plus the resolver reject malformed values before any network call. The heading parser lives in new bin/fm-brief-heading-lib.sh as the single owner of brief-section reading, sourced by the resolver; fm-test-run.sh maps it to the dispatch-resolve test lane.
) * feat(bin): send dispatch router only the brief's task sections and add per-rule confidence floors Port of upstream kunchenguid#5478, adapted to this fork's brief scaffold, which has no "## Captain's intent" / "## Firstmate spec" subsections: the resolver now sends Jev the top-level "# Task" and "# Acceptance criteria" sections instead, prefixed with "Brief kind: scout (report only)" on scout briefs, and still sends the whole brief when neither section exists. Ship delivery mode is not sent, matching upstream's measured over-routing finding. Rules may declare min_confidence (0 through 1), a confidence floor on that rule's own probability, distinct from the existing quota "floor" fields: a picked rule below its floor falls to the most probable other option that clears its own floor (global 0.6 when undeclared) with a fallback: line, else ambiguous. Files with no declared floors keep the global 0.6 check on the answer confidence exactly, and bootstrap plus the resolver reject malformed values before any network call. The heading parser lives in new bin/fm-brief-heading-lib.sh as the single owner of brief-section reading, sourced by the resolver; fm-test-run.sh maps it to the dispatch-resolve test lane. * no-mistakes(review): Accept trailing heading whitespace and narrow parser ownership * no-mistakes(review): Remove unused nested-heading wrapper functions * no-mistakes(ci): Fixed `bin/fm-dispatch-resolve.sh` to canonicalize fallback probability/floor formatting, resolving the portable serial 1 failure (`0.30` vs `0.3`). Verified with bash syntax checks and the targeted dispatch test (fallback case passes). Portable serial 4’s `fm-send --key` mismatch reproduces in an unchanged backend conformance test and is unrelated to this PR; no out-of-scope changes were made * no-mistakes(ci): Fixed `bin/fm-dispatch-resolve.sh` to normalize fallback probability/floor diagnostics deterministically (e.g. `0.30` → `0.3`) across all emitted fields. Portable serial 1’s failure is addressed; portable serial 4’s `fm-send --key` failure is unrelated to this PR’s changed code, so no out-of-scope change was made * no-mistakes(review): Preserve exponents in dispatch fallback diagnostics * no-mistakes(review): Remove unused brief heading stdin mode * no-mistakes(document): Clarify dispatch extraction and verification documentation * no-mistakes(ci): Captain, fixed the CI failure by normalizing exponent markers to lowercase in the shared formatter for all four fallback diagnostic fields. Expanded executable regression coverage for e/E notation and trailing mantissa zeros. Dispatch tests, bash syntax checks, and git diff --check passed * no-mistakes(document): Clarify dispatch extraction and whole-brief fallback comments
…d per-rule confidence floors (kunchenguid#5478) * feat(bin): send dispatch resolver only the brief's task sections * Sent Jev only the scaffolded Captain's intent and Firstmate spec sections, falling back to the whole brief when neither heading is present, so the identical setup, rules, and definition-of-done boilerplate no longer reads as a signal about the task * Added an optional per-rule min_confidence that replaces the global 0.6 floor for that rule; a picked rule below its own floor falls to the most probable other option that clears its floor, or returns ambiguous * Kept files with no declared floor on the exact previous behavior and kept the model blind to the new field * Recorded the live old-versus-new comparison over scaffolded fixtures * no-mistakes(review): share brief heading parser, add kind line, fix floors * no-mistakes(test): stop sending ship delivery mode to jev, keep scout tag * no-mistakes(document): docs: list shared brief heading lib in scripts inventory
Intent
The typed dispatch resolver (
bin/fm-dispatch-resolve.sh) asks Jev which rule inconfig/crew-dispatch.jsonfits a task, and until now it sent the whole brief as context.Most of a scaffolded brief is the same setup, rules and definition-of-done text in every task, full of never-do-X safety language that says nothing about how hard the task is.
A routine port-and-installer build was routed to a config's most expensive rule this way, and a supervisor that has to re-check every pick loses the point of the resolver.
This change sends Jev only the task-specific text and gives each rule a way to demand stronger support before it wins.
Context sent. Only the
## Captain's intentand## Firstmate specsections under# Taskgo to Jev, read by the same heading parser that spawn validation and the no-mistakes--intentcontract use (now inbin/fm-brief-heading-lib.sh).Scout briefs are prefixed with
Brief kind: scout (report only), because a report-only deliverable is a real routing signal.Ship delivery mode is deliberately not sent: in live runs, adding
Brief kind: ship, mode=no-mistakespushed a routine port brief from about 0.89 to 0.97 on a top-tier rule.A brief with neither heading is sent whole, so hand-written briefs keep working.
Per-rule floors. A rule may declare
min_confidence(0 to 1), checked against that rule's own probability whether it is the model's pick or a runner-up, so a runner-up never needs weaker support than it would as the pick.A picked rule under its floor falls to the most probable other option that clears its own floor, with a
fallback:line; otherwise the result isambiguous.Rules without the field keep the global 0.6 check on the answer confidence, so existing configs behave exactly as before, and the model never sees the field.
What the evidence says. Measured live on jev-1.13.0 with generic scaffolded fixtures (recorded in
docs/verification/dispatch-resolve.md): trimming the context did not change routing accuracy (16 of 16 either way), cut input from about 4,350 to about 600 tokens per ship brief, and made one borderline brief newlyambiguous(0.77 to 0.59 confidence).On a routine port brief under a loosely worded top-tier rule, both shapes still picked the top tier (0.88 to 0.93); a 0.95 floor on that rule is what turned the pick
ambiguous, and a low floor on the implementation rule routed it there instead.The trim reduces irrelevant input; the floor is what prevents an expensive mis-route.
Written with AI assistance.
What Changed
fm-dispatch-resolve.shnow sends Jev only the## Captain's intentand## Firstmate specsections under# Task, not the whole brief. Scout briefs get a leadingBrief kind: scout (report only)line. A brief with neither section is still sent whole. Ship delivery mode is deliberately left out, because in live runs it pushed routine ship briefs to the top tier.min_confidence(0 through 1), which is checked against that rule's own probability. When a picked rule misses its floor, the resolver falls back to the most probable other option that clears its own floor and prints afallback:line. If no other option clears its floor, or two tie, the result isambiguous. Rules without the field keep the global 0.6 floor on the answer confidence, so existing configs behave as before. Both the resolver and bootstrap validate the field while typed resolution is on.fm-dod-lib.shinto a new sharedbin/fm-brief-heading-lib.sh, so the router, the spawn validation and the no-mistakes--intentcontract all read sections the same way. The change adds resolver and bootstrap tests, plus documentation indocs/configuration.md,docs/scripts.mdand the dispatch-resolve verification record.Risk Assessment
✅ Low: The change is opt-in and limited to the typed resolver. The fix round did what round 1 asked for, and tracing concrete inputs found no wrong results: the shared parser now lives in one place, scaffold kind lines are read correctly, and floors behave the same whether a rule is the pick or a runner-up, with undeclared files unchanged.
Testing
I scaffolded real ship (no-mistakes, direct-PR, local-only), scout and free-form briefs with bin/fm-brief.sh in an isolated FM_HOME. I ran the unmodified resolver on each one against the real TypeSafe endpoint through a curl wrapper that records the request body and forwards it unchanged. Every run authenticated with a placeholder key, so each got a real 401, and the captured request body shows exactly what the resolver would send to Jev. All five package scenarios and the config-rejection scenario passed. The targeted offline test file tests/fm-dispatch-resolve.test.sh also passed; it covers the floor and fallback cases. Those cases stay untested live because they need a real Jev answer and no API key was available.
##line inside a nested ```` fence in the Firstmate spec neither ends nor splits the sectionBrief kind: scout (report only)first, then its two sectionsEvidence: Captured request bodies sent to the TypeSafe endpoint for ship, scout and free-form briefs, plus the min_confidence rejection
Source: Captured request bodies sent to the TypeSafe endpoint for ship, scout and free-form briefs, plus the min_confidence rejection
Evidence: Output of the targeted resolver test file
Source: Output of the targeted resolver test file
Live Jev evidence
The three scenarios marked untested above, and the five package and config scenarios, were re-run against the live TypeSafe endpoint (
jev-1.13.0) with a real key, using the unmodified resolver ata40dd495.Briefs were scaffolded by
bin/fm-brief.shin an isolatedFM_HOMEand filled with generic fixture text.Fixture rules: rule_1 hard or high-stakes work (opus xhigh), rule_2 routine implementation (sonnet medium), rule_3 read-only investigation (sonnet high).
A pass-through
curlwrapper recorded each request body; quota came from the realquota-axi --json.All 8 pass.
##line inside a nested ```` fence neither ends nor splits the specBrief kind: scout (report only)min_confidencekeeps the global 0.6 floor on answer confidencemin_confidence: 1.5rejected before any network callTwo notes from the runs.
A declared floor is checked against the option's probability, which on borderline briefs ran well above Jev's answer confidence (0.61-0.63 against 0.48-0.49), so declaring a floor below 0.6 on an expensive rule loosens it relative to the global check (row 6, third case).
During the runs the Claude quota endpoint rate-limited
quota-axi, and resolutions in that window endedescalate: no rankable eligible candidateafter correct routing; the floor cases were re-run once it cleared and the table shows those results.Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 4 issues found → auto-fixed ✅
bin/fm-dispatch-resolve.sh:374- The stated intent is to improve the context package sent to Jev ("maybe we need to improve the context package for the router (jev)"). The per-rulemin_confidencefield and its runner-up fallback (bin/fm-dispatch-resolve.sh:365-384, plus the validators at bin/fm-dispatch-resolve.sh:171 and bin/fm-bootstrap.sh:1197, thefallback:output line, and docs/configuration.md:507,528,578-580) change routing decisions, not the context package, so they go beyond that requirement. There is also a narrower form: a per-rule floor that returnsambiguouswhen missed, with no runner-up, would cover the 0.76-confidence hardest-tier incident on its own. The fallback also gives a wrong result without erroring, because it checks a runner-up's floor against that option's probability while the picked rule's floor is checked against Jev's confidence. The verification doc (docs/verification/dispatch-resolve.md:72) shows these differ: probability 0.66 came with confidence 0.59. Example: rule B declares min_confidence 0.3. If Jev picks B at probability 0.35 and confidence 0.25, the result is ambiguous. If instead A (min_confidence 0.9) is picked at confidence 0.55 with B as runner-up at probability 0.30, the result is clear to B. B gets dispatched on weaker support as a runner-up than it needs as the model's own pick, and nobody is asked. Recommend removing the runner-up fallback, and the min_confidence field too unless the captain wants it as part of this change. Needs a decision because it is scope, not a mechanical fix.bin/fm-dispatch-resolve.sh:236- The new inline awk extractor is a second definition of brief-section parsing. bin/fm-dod-lib.sh already owns this in fm_brief_task_heading_body / fm_brief_heading_parse (lines 169-252), which fm-spawn.sh, fm-promote.sh and the --intent contract use to read these exact two sections. The two parsers differ in ways a real brief can hit. (a) The new awk is not scoped to# Task. (b) It prints every matching heading, not just the first. (c) Its fence check toggles on any line starting withor ~~~, while the owner tracks fence marker and length. So a ```` fence that contains aline inside Captain's intent flips the state, and a later##line inside the fence ends or starts a section. (d) It accepts trailing whitespace on a heading, which the owner (and so fm-spawn's validation) rejects. The resolver can therefore send Jev a different 'Captain's intent' from the one the worker's --intent and spawn validation use. Fix: move fm_brief_heading_parse and the task-heading wrappers into a small sourceable lib (fm-dod-lib.sh pulls in the pr, classify and nm-run libs) and call fm_brief_task_heading_body for both headings, falling back to the whole brief when neither is present. Update the trailing-whitespace test in tests/fm-dispatch-resolve.test.sh to match.bin/fm-dispatch-resolve.sh:233- Sending only## Captain's intentand## Firstmate specalso drops the one part of the scaffold that is task-specific: whether the brief is a scout or a ship brief, and its mode. A scout brief's contract (deliverable is data/<id>/report.md, no branch, no push, no PR; bin/fm-brief.sh:20-21) is exactly what a 'read-only investigation or audit' rule should match, like the one in the recorded fixture set. With the change, a scout brief whose intent reads like a fix ('the pager export is slow, find out why') loses the structural signal that it can't ship code, and can land on a build or bug-fix tier. Consider adding a one-line kind/mode marker (e.g. 'Brief kind: scout (report only)') to the task text, so the boilerplate stays out but that signal stays in. This changes what the model sees, so the captain should confirm.docs/verification/dispatch-resolve.md:72- The recorded comparison doesn't show the context change improving routing. The top rule matched the label 16 of 16 both before and after. The only routing difference is a regression: the large-file-split fixture went from clear (0.77) toambiguous(0.59). That hands one more decision back to the supervisor, which the intent ('without the supervisor second-guessing it') wants less of. The incident that motivated the change (a routine port/installer brief sent to the hardest tier at 0.76) is not reproduced before and after. The token cut (about 4.3k to about 0.6k per ship brief) is real. Consider replaying the incident brief, or a faithful redacted copy, through both shapes and recording the result, so the evidence shows the fix addresses the reported failure.🔧 Fix applied.
✅ Re-checked - no issues remain.
🔧 **Test** - 1 issue found → auto-fixed ✅
##line inside a code fence in the Firstmate spec neither ends nor splits the extracted section, Resolving a scaffolded scout brief tags the task textBrief kind: scout (report only), A free-form brief with neither task section is sent whole and gets no kind line, A rules file with no min_confidence keeps the global 0.6 floor on the answer confidence (0.55 ambiguous, 0.65 clear even at probability 0.50), Declared floors: B (min 0.3) picked at probability 0.35 clears; A (min 0.9) at 0.65 falls to B at 0.30; at B 0.25 the result is ambiguous; default at 0.30 does not take the fallback, An out-of-range min_confidence (1.5) is rejected with exit 2 before any network call, Real Jev routes the task-sections package for a routine port brief to a sensible tier##line inside a code fence in the Firstmate spec neither ends nor splits the extracted sectionBrief kind: scout (report only)bash tests/fm-dispatch-resolve.test.sh(all passed)bash tests/fm-dod-lib.test.sh(all passed; shared heading parser moved out of fm-dod-lib.sh)bash tests/fm-bootstrap.test.sh(exit 0; includes min_confidence validation cases)bash tests/fm-brief.test.sh(exit 0)Scaffolded real ship (fm-brief.sh port-task demo --mode no-mistakes) and scout (fm-brief.sh scout-task demo --scout) briefs in a temp FM_HOME, filled {TASK}/{FIRSTMATE_SPEC} (ship spec included a fenced##line), and ranbin/fm-dispatch-resolve.sh <brief> --project demowith a recording fake curl and fake quota-axiChecked the recorded request body for boilerplate (# Rules,# Setup,Definition of done,Herdr lifecycle,Project memory): none presentRan the resolver on a free-form brief with no task sections to check the whole-brief fallbackDrove 8 confidence-floor cases through the CLI with FM_CONFIG_OVERRIDE rules files: no declared floors (ambiguous at 0.55, clear at 0.65), reviewer example [email protected] clear, A→B fallback at 0.30, no fallback at 0.25, default not stealing fallback, A clear at 0.95, and min_confidence 1.5 rejected with exit 2🔧 Fix applied.
✅ Re-checked - no issues remain.
##line inside a nested ```` fence in the Firstmate spec neither ends nor splits the sectionBrief kind: scout (report only)first, then its two sectionsbin/fm-brief.sh port-task demo-repo --mode no-mistakesand--scout, then filled placeholders, in an isolated temp FM_HOMEbin/fm-brief.sh t-direct-PR|t-local-only demo-repo --mode direct-PR|local-onlyto check other ship modes get no kind lineTYPESAFE_API_KEY=<placeholder> bin/fm-dispatch-resolve.sh <brief> --project demo-repoagainst the real https://api.typesafe.ai with a pass-through recording curl (ship, scout, free-form briefs)Rules file withmin_confidence: 1.5throughbin/fm-dispatch-resolve.sh(exit 2, no request recorded)bash tests/fm-dispatch-resolve.test.sh(targeted offline test for this change: task-section extraction, scout tag, per-rule floors and fallback, config errors)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.