Skip to content

feat(bin): send dispatch router only the brief's task sections and add per-rule confidence floors - #5478

Merged
kunchenguid merged 4 commits into
kunchenguid:mainfrom
zachlandes:fm/dispatch-resolve-context
Sep 24, 2026
Merged

kunchenguid merged 4 commits into
kunchenguid:mainfrom
zachlandes:fm/dispatch-resolve-context

Conversation

@zachlandes

@zachlandes zachlandes commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Intent

The typed dispatch resolver (bin/fm-dispatch-resolve.sh) asks Jev which rule in config/crew-dispatch.json fits 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 intent and ## Firstmate spec sections under # Task go to Jev, read by the same heading parser that spawn validation and the no-mistakes --intent contract use (now in bin/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-mistakes pushed 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 is ambiguous.
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 newly ambiguous (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.sh now sends Jev only the ## Captain's intent and ## Firstmate spec sections under # Task, not the whole brief. Scout briefs get a leading Brief 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.
  • Rules can now declare an optional 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 a fallback: line. If no other option clears its floor, or two tie, the result is ambiguous. 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.
  • The brief-heading parser moved out of fm-dod-lib.sh into a new shared bin/fm-brief-heading-lib.sh, so the router, the spawn validation and the no-mistakes --intent contract all read sections the same way. The change adds resolver and bootstrap tests, plus documentation in docs/configuration.md, docs/scripts.md and 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.

  • Live validation: ✅ go - 6 of 9 scenarios driven live against the product
Scenario Result Live Evidence
A scaffolded no-mistakes ship brief sends Jev only the Captain's intent and Firstmate spec sections, with no boilerplate and no ship kind or mode line ✅ pass live dispatch-resolve-live-payloads.md: the 13,155-byte brief went out as 360 bytes containing only the two sections; grep for no-mistakes, Brief kind, Setup, Rules and Definition of done found 0 matches
direct-PR and local-only ship briefs also get no kind or mode line ✅ pass live Recorded request body for t-direct-PR and t-local-only contained only the two sections
Adversarial: a ## line inside a nested ```` fence in the Firstmate spec neither ends nor splits the section ✅ pass live dispatch-resolve-live-payloads.md: the fenced '## Not a heading, inside a fence' and the SPEC-TAIL-MARKER after the fence both appear inside the sent spec section
A scaffolded scout brief is sent with Brief kind: scout (report only) first, then its two sections ✅ pass live dispatch-resolve-live-payloads.md, scout-task section (169 bytes)
A free-form brief with neither section is sent whole, with no kind line ✅ pass live dispatch-resolve-live-payloads.md, freeform.md section: the body matches the file exactly
An out-of-range min_confidence (1.5) stops with exit 2 before any network call ✅ pass live rc=2, 'min_confidence must be a number from 0 through 1 when present'; the recording curl never wrote a body file
A rules file with no min_confidence keeps the global 0.6 floor on the answer confidence ⏸️ untested no Needs a real Jev answer. No TYPESAFE_API_KEY was available in the environment or the worktree .env. Set TYPESAFE_API_KEY to drive it live.
Declared floors: a picked rule below its min_confidence falls to the runner-up that clears its own floor, or returns ambiguous ⏸️ untested no Needs real Jev probabilities. No TYPESAFE_API_KEY was available. Set TYPESAFE_API_KEY to drive it live.
Real Jev routes the task-sections package for a routine port brief to a sensible tier ⏸️ untested no No valid TYPESAFE_API_KEY was available. Provide one in the environment to replay this live.
Evidence: 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

# Dispatch resolver context package, live transcript (2026-09-23)
Briefs scaffolded by the real bin/fm-brief.sh in an isolated FM_HOME; resolver run unmodified with a placeholder key against https://api.typesafe.ai (real 401).
A recording curl saved the POST body and forwarded it to /usr/bin/curl unchanged.

Scaffolded ship brief size:    13451 bytes; scout brief:     7274 bytes

## port-task_brief.md resolver output
dispatch-resolve:
  status: error
  reason: http 401 after 255 ms: {"detail":{"error_type":"authentication_error","message":"Cannot authenticate with the server. Please check your API key and try again."}}
## port-task_brief.md state.task.brief sent to Jev (360 bytes)
~~~~
## Captain's intent
Port the macOS-only screen capture helper to Windows and add a Windows installer. This is a straightforward port of existing behavior.

## Firstmate spec
Follow the existing helper layout.

`` ``text
example config:
`` `
## Not a heading, inside a fence
`` `
`` ``

Never delete user captures. Never ship unsigned installers.
SPEC-TAIL-MARKER

~~~~

## scout-task_brief.md resolver output
dispatch-resolve:
  status: error
  reason: http 401 after 188 ms: {"detail":{"error_type":"authentication_error","message":"Cannot authenticate with the server. Please check your API key and try again."}}
## scout-task_brief.md state.task.brief sent to Jev (169 bytes)
~~~~
Brief kind: scout (report only)

## Captain's intent
The pager export is slow, find out why.

## Firstmate spec
Profile the export path and report the top three costs.

~~~~

## freeform.md resolver output
dispatch-resolve:
  status: error
  reason: http 401 after 207 ms: {"detail":{"error_type":"authentication_error","message":"Cannot authenticate with the server. Please check your API key and try again."}}
## freeform.md state.task.brief sent to Jev (77 bytes)
~~~~
Fix the typo "recieve" in README.md line 12.

No headings here, just prose.

~~~~

## min_confidence 1.5 rejected before any network call
error: malformed rules file: /var/folders/4n/_bv20k5d26dgrq1t5y4l69940000gn/T/tmp.yun1sosAWo/home/config/crew-dispatch.json - min_confidence must be a number from 0 through 1 when present
(recording curl body file absent: no request made)
Evidence: Output of the targeted resolver test file

Source: Output of the targeted resolver test file

ok - absent key is off: one stderr line, exit 0, no network call
ok - TYPESAFE_API_KEY= in .env activates the tool; environment and config overrides work
ok - clear: one rule Choice request, key on the fd header only, spendPriority argmax over every candidate
ok - rules snapshots and shell quoting preserve the profile protocol
ok - no-rule fallback, Agy, Gemini, and documented configurations resolve
ok - ambiguous: confidence below the fixed floor hands the decision back
ok - per-rule confidence floors fall to the most probable runner-up that clears its own floor
ok - only the brief's task sections and scout tag reach the model, with a whole-brief fallback
ok - escalate: a rule declared approval: captain never yields a profile
ok - rule floor: known shortfall falls through while unavailable evidence escalates
ok - declared provider and profile floor evidence are applied in code
ok - nonnumeric spendPriority evidence is never ranked
ok - partial and missing quota evidence remain eligible but unranked
ok - provider-wide and exact quota rows combine into one limiting candidate
ok - default: no rule matched resolves among the default profiles
ok - tie: equal spendPriority never breaks by array order
ok - no rankable candidate: the tool escalates instead of guessing
ok - native Codex binds to codex-home before default, independently of Pi accounts and row order
ok - Pi native adapters bind to codex-home with existing fallbacks and schema 5 compatibility
ok - schema 6: each candidate binds to its account row; schema 5 is unchanged
ok - quota evidence comes from one quota-axi --json read, and its failure is an error outcome
ok - API, transport, and response failures are error outcomes with exit 0
ok - configuration errors exit 2 before any network call
# all fm-dispatch-resolve tests passed
- Outcome: 🔧 1 issue found → auto-fixed ✅ across 2 runs (8m39s)

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 at a40dd495.
Briefs were scaffolded by bin/fm-brief.sh in an isolated FM_HOME and 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 curl wrapper recorded each request body; quota came from the real quota-axi --json.
All 8 pass.

# Scenario Live Jev Sent (bytes / input tokens) Result
1 Scaffolded no-mistakes ship brief sends only Captain's intent and Firstmate spec yes 14,222-byte brief -> 456 / 603 ✅ only the two sections; no Setup, Rules, Definition of done, Herdr, mode or ship kind text
2 ## line inside a nested ```` fence neither ends nor splits the spec yes same request as 1 ✅ fenced heading and the tail marker after the fence both inside the sent spec
3 Scout brief tagged Brief kind: scout (report only) yes 7,930-byte brief -> 202 / 545 ✅ tag first, then both sections; rule_3 p=1.0, clear
4 Free-form brief with neither section is sent whole yes 76 / 519 ✅ sent body byte-identical to the file, no kind line; rule_2 p=1.0, clear
5 No min_confidence keeps the global 0.6 floor on answer confidence yes 179 / 537 ✅ rule_1 p=0.62 but confidence 0.48 -> ambiguous, "confidence 0.48 below floor 0.6"
6 Declared floors fall to a runner-up or return ambiguous yes 179 / 537 ✅ rule_1=0.9, rule_2=0.3: rule_1 p=0.61 misses, fallback to rule_2 p=0.39, clear (sonnet medium). rule_1=0.9, rule_2=0.5: ambiguous, no other option clears. rule_1=0.5: p=0.63 clears, clear
7 min_confidence: 1.5 rejected before any network call n/a nothing sent ✅ exit 2, "min_confidence must be a number from 0 through 1 when present"; no request recorded
8 Real Jev routes a routine port brief to a sensible tier yes 456 / 603 ✅ two runs: rule_2 p=0.98 / 0.99, confidence 0.97 / 0.99, clear to sonnet medium; top tier p=0.02 / 0.01

Two 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 ended escalate: no rankable eligible candidate after 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-rule min_confidence field 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, the fallback: 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 returns ambiguous when 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 with or ~~~, while the owner tracks fence marker and length. So a ```` fence that contains a line 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&#39;s intent and ## Firstmate spec also 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) to ambiguous (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 ✅
  • ⚠️ live validation verdict: inconclusive (0 of 8 scenarios were driven live against the product); untested: Resolving a scaffolded ship brief sends Jev only the Brief kind: ship, mode=no-mistakes line plus Captain's intent and Firstmate spec, with no boilerplate, Adversarial: a ## line inside a code fence in the Firstmate spec neither ends nor splits the extracted section, Resolving a scaffolded scout brief tags the task text Brief 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
  • Live validation: ⚠️ inconclusive - 0 of 8 scenarios driven live against the product
Scenario Result Live Evidence
Resolving a scaffolded ship brief sends Jev only the Brief kind: ship, mode=no-mistakes line plus Captain's intent and Firstmate spec, with no boilerplate ⏸️ untested no The prior payload did not establish a live result: the Jev API was stubbed by a recording fake curl because TYPESAFE_API_KEY was not set. Export TYPESAFE_API_KEY to run it live.
Adversarial: a ## line inside a code fence in the Firstmate spec neither ends nor splits the extracted section ⏸️ untested no The prior payload did not establish a live result: it ran only against a stubbed Jev API because TYPESAFE_API_KEY was not set.
Resolving a scaffolded scout brief tags the task text Brief kind: scout (report only) ⏸️ untested no The prior payload did not establish a live result: it ran only against a stubbed Jev API because TYPESAFE_API_KEY was not set.
A free-form brief with neither task section is sent whole and gets no kind line ⏸️ untested no The prior payload did not establish a live result: it ran only against a stubbed Jev API because TYPESAFE_API_KEY was not set.
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) ⏸️ untested no The prior payload did not establish a live result: the Jev answers were injected through a stub, not returned by the live API.
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 ⏸️ untested no The prior payload did not establish a live result: the Jev answers were injected through a stub, not returned by the live API.
An out-of-range min_confidence (1.5) is rejected with exit 2 before any network call ⏸️ untested no The prior payload did not establish a live result: this ran only with the other stub-driven CLI runs and in tests/fm-bootstrap.test.sh, and the payload did not mark it live.
Real Jev routes the task-sections package for a routine port brief to a sensible tier ⏸️ untested no No TYPESAFE_API_KEY in the test environment, and the operator's key in the fleet FM_HOME .env was not used because it is a production credential. Export TYPESAFE_API_KEY in the test environment to run…
  • 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 ran bin/fm-dispatch-resolve.sh &lt;brief&gt; --project demo with a recording fake curl and fake quota-axi
  • Checked the recorded request body for boilerplate (# Rules, # Setup, Definition of done, Herdr lifecycle, Project memory): none present
  • Ran the resolver on a free-form brief with no task sections to check the whole-brief fallback
  • Drove 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.

  • Live validation: ✅ go - 6 of 9 scenarios driven live against the product
Scenario Result Live Evidence
A scaffolded no-mistakes ship brief sends Jev only the Captain's intent and Firstmate spec sections, with no boilerplate and no ship kind or mode line ✅ pass live dispatch-resolve-live-payloads.md: the 13,155-byte brief went out as 360 bytes containing only the two sections; grep for no-mistakes, Brief kind, Setup, Rules and Definition of done found 0 matches
direct-PR and local-only ship briefs also get no kind or mode line ✅ pass live Recorded request body for t-direct-PR and t-local-only contained only the two sections
Adversarial: a ## line inside a nested ```` fence in the Firstmate spec neither ends nor splits the section ✅ pass live dispatch-resolve-live-payloads.md: the fenced '## Not a heading, inside a fence' and the SPEC-TAIL-MARKER after the fence both appear inside the sent spec section
A scaffolded scout brief is sent with Brief kind: scout (report only) first, then its two sections ✅ pass live dispatch-resolve-live-payloads.md, scout-task section (169 bytes)
A free-form brief with neither section is sent whole, with no kind line ✅ pass live dispatch-resolve-live-payloads.md, freeform.md section: the body matches the file exactly
An out-of-range min_confidence (1.5) stops with exit 2 before any network call ✅ pass live rc=2, 'min_confidence must be a number from 0 through 1 when present'; the recording curl never wrote a body file
A rules file with no min_confidence keeps the global 0.6 floor on the answer confidence ⏸️ untested no Needs a real Jev answer. No TYPESAFE_API_KEY was available in the environment or the worktree .env. Set TYPESAFE_API_KEY to drive it live.
Declared floors: a picked rule below its min_confidence falls to the runner-up that clears its own floor, or returns ambiguous ⏸️ untested no Needs real Jev probabilities. No TYPESAFE_API_KEY was available. Set TYPESAFE_API_KEY to drive it live.
Real Jev routes the task-sections package for a routine port brief to a sensible tier ⏸️ untested no No valid TYPESAFE_API_KEY was available. Provide one in the environment to replay this live.
  • bin/fm-brief.sh port-task demo-repo --mode no-mistakes and --scout, then filled placeholders, in an isolated temp FM_HOME
  • bin/fm-brief.sh t-direct-PR|t-local-only demo-repo --mode direct-PR|local-only to check other ship modes get no kind line
  • TYPESAFE_API_KEY=&lt;placeholder&gt; bin/fm-dispatch-resolve.sh &lt;brief&gt; --project demo-repo against the real https://api.typesafe.ai with a pass-through recording curl (ship, scout, free-form briefs)
  • Rules file with min_confidence: 1.5 through bin/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.

* 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

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Diff review on HEAD a40dd495f7aeba2a1cd655cfa6ea9cabb0d8163e: typed dispatch sends Jev only ## Captain's intent / ## Firstmate spec (scout gets Brief kind: scout; neither heading → whole brief). Optional per-rule min_confidence (0..1) with fallback/ambiguous; rules without it keep global 0.6. Absent TYPESAFE stays off; bootstrap validates min_confidence only while typed is on. Security clean (same key-on-fd pattern; model never sees floors).

VISION per-rule:

  1. One captain, one interface — aligns (token-leaner routing under existing typed opt-in).
  2. Authority explicit — aligns (TYPESAFE gate; floors optional).
  3. Scripts own mechanics / agents own judgment — aligns (heading parser + jq floors; Jev still chooses).
  4. Restart non-event — aligns.
  5. Delegation with a spine — aligns (expensive mis-route refused via floors).
  6. Fleet outlives vendor — aligns.
  7. Scope — aligns.

contract-class: opt-in — unconfigured (no TYPESAFE) unchanged; context trim + min_confidence only apply inside typed resolution. Note: overlapping paths with #5485 (fm-dispatch-resolve.sh etc.); land one then rebase the other.

attestation: MATCH.
CI: FAILURE 35936239068 — Behavior portable serial 1: not ok - watcher pid … did not exit within 10s of TERM (family watcher-wake-lock, outside this PR's files). Re-ran failed jobs once; waiting on that re-run.
NM: SUCCESS 35936239121/35936557650/35944061967.
mergeable: MERGEABLE/UNSTABLE.
workflow-approved: yes — CI 35936239068, NM 35936239121/35936557650/35944061967.
next: waiting-ci (flake re-run). If re-run stays red, author/CI needs a green tip before merge. Not a captain hold. Firstmate-flag no. Closes none.

@kunchenguid
kunchenguid merged commit 795e4b5 into kunchenguid:main Sep 24, 2026
38 of 39 checks passed

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @zachlandes — really appreciate you taking the time on this.

mituso89 pushed a commit to mituso89/firstmate that referenced this pull request Sep 26, 2026
…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
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 26, 2026
…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
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 26, 2026
…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
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 27, 2026
…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
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 27, 2026
…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
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 27, 2026
…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
RooseveltAdvisors pushed a commit to RooseveltAdvisors/firstmate that referenced this pull request Sep 29, 2026
…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
dnth added a commit to dnth/firstmate that referenced this pull request Oct 3, 2026
…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.
dnth added a commit to dnth/firstmate that referenced this pull request Oct 4, 2026
)

* 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
max-metaplanet pushed a commit to max-metaplanet/firstmate that referenced this pull request Oct 6, 2026
…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
max-metaplanet added a commit to max-metaplanet/firstmate that referenced this pull request Oct 6, 2026