Skip to content

feat(bin): add opt-in systemone and openai decision providers to dispatch resolution - #7664

Merged
kunchenguid merged 3 commits into
kunchenguid:mainfrom
rchristensen:fm/fm-decisions-provider
Oct 29, 2026
Merged

kunchenguid merged 3 commits into
kunchenguid:mainfrom
rchristensen:fm/fm-decisions-provider

Conversation

@rchristensen

@rchristensen rchristensen commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Add two opt-in decision providers to bin/fm-dispatch-resolve.sh (issue #7643) on top of #7149's FM_DISPATCH_PROVIDER/FM_DISPATCH_MODEL provider seam, which has merged: a generic systemone provider (any System One-compatible host such as a local llama.cpp server running Cloudflare's Clef models, given FM_DISPATCH_BASE_URL and an optional FM_DISPATCH_API_KEY) and an openai provider (OpenAI's Decisions API, mapped to and from the System One shape). Constraints from the issue and the maintainer triage: reuse the one provider seam, never add a second; "off stays off" byte for byte (no provider set keeps the original typesafe key gate, one stderr off line, exit 0, no network call), backed by a config-absent test; keys reach curl only through fd 3, never argv or child environments; exit 2 on an unknown provider or a missing required setting before any network call; malformed or partial responses are rejected; transport failure returns to normal intake as an error outcome; the never-send check runs on the endpoint and the final per-provider request body, including JSON text inside OpenAI's input. Docs the seam already documents are updated (docs/configuration.md, the fm-env-lib header, docs/verification/dispatch-resolve.md). The PR carries a dated live section per provider: the OpenAI section records a real 2026-10-23 run with 25 hand-labeled synthetic briefs (the Jev run's original briefs are not available, which the section states) and verbatim request/response captures; the systemone section records a real 2026-10-23 run of the same 25 briefs against Clef on Cloudflare Workers AI (@cf/cloudflare/clef), approved by the operator, reached through a local test-only relay because Workers AI serves System One at /ai/run/ inside a {result, success} envelope instead of /v1/systemone; the relay, the capture scripts, the token, and the account id are deliberately not committed, and a direct Workers AI option (a configurable path plus envelope unwrapping) is deliberately out of scope. The one failing CI job (Behavior portable parallel 2, tests/fm-test-run.test.sh 'packing exactly at the budget must be accepted') also fails on unmodified main and was decided as unrelated, with no fix to be added in this PR. Out of scope: any other change to the resolver, enabling dispatch resolution in any home, and editing #7149. This run exists so the PR body carries the no-mistakes Pipeline attestation that the maintainer requested.

What Changed

  • bin/fm-dispatch-resolve.sh gains two opt-in providers on the existing FM_DISPATCH_PROVIDER/FM_DISPATCH_MODEL seam. systemone targets any System One-compatible host via FM_DISPATCH_BASE_URL and an optional FM_DISPATCH_API_KEY. openai calls OpenAI's Decisions API and maps requests and responses to and from the System One shape. Keys reach curl only through fd 3. An unknown provider or missing required setting exits 2 before any network call. Malformed or partial responses are rejected, and transport failures return to normal intake as an error outcome. The never-send check covers the endpoint and the final per-provider request body, including JSON text inside OpenAI's input. With no provider set, behavior is unchanged: the original key gate, one stderr off line, exit 0, and no network call. bin/fm-env-lib.sh header is updated to match.
  • tests/fm-dispatch-resolve.test.sh adds coverage for the new providers, including a config-absent test for the off-stays-off path. docs/configuration.md documents the new settings.
  • docs/verification/dispatch-resolve.md adds dated 2026-10-23 live sections for each provider. The OpenAI section records a run with 25 hand-labeled synthetic briefs and verbatim request/response captures. It states that the original briefs from the earlier run are unavailable. The systemone section records the same 25 briefs run against Clef (@cf/cloudflare/clef) on Cloudflare Workers AI through a local test-only relay, because Workers AI serves System One at /ai/run/<model> inside a {result, success} envelope. The relay, capture scripts, token, and account id are not committed. A direct Workers AI option is out of scope.

Risk Assessment

✅ Low: The opt-in providers reuse the existing seam and validation gates, with bounded request mapping, protected credential handling, and no substantiated material regressions.

Testing

I ran the dispatch-resolve test script, which drives the real script against local fake servers, and every test passed. That includes the systemone and openai request mapping, key handling on fd 3 only, never-send checks, malformed and partial responses, transport failures, and exit 2 on configuration errors. I also ran the script by hand in a disposable lab home. With no provider it printed the one off line and exited 0. An unknown provider, and systemone or openai without a model, each exited 2 before any network call. I did not repeat the live runs against OpenAI or Clef recorded in the verification doc.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
No provider set prints the single off line and exits 0 with no network call ✅ pass live manual run printed the off line, rc=0; config-absent test passes
Unknown provider, or a provider missing its required setting, exits 2 ✅ pass live manual run: bogus, systemone and openai without a model each rc=2
systemone and openai request mapping, key on fd 3 only, never-send check, malformed or partial responses, and transport failure ✅ pass live tests/fm-dispatch-resolve.test.sh systemone and openai cases, run against local fake servers

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
No provider set prints the single off line and exits 0 with no network call ✅ pass live manual run printed the off line, rc=0; config-absent test passes
Unknown provider, or a provider missing its required setting, exits 2 ✅ pass live manual run: bogus, systemone and openai without a model each rc=2
systemone and openai request mapping, key on fd 3 only, never-send check, malformed or partial responses, and transport failure ✅ pass live tests/fm-dispatch-resolve.test.sh systemone and openai cases, run against local fake servers
  • bash tests/fm-dispatch-resolve.test.sh
  • bin/fm-dispatch-resolve.sh run in a disposable lab home with no provider, an unknown provider, and systemone/openai without a model
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @rchristensen. This builds on the #7149 seam instead of adding a second one, which is what we hoped for in #7643.

What I checked: I read head 29d3d159 against main e930d960 myself. With no FM_DISPATCH_PROVIDER set, the typesafe key gate, the single off line and the no-network exit are unchanged. systemone and openai only run when you select them, and unknown providers or missing settings exit 2 before any network call. Keys still reach curl only through fd 3. The wider never-send scan (the endpoint plus decoded JSON text) only applies when the optional never-send list exists. tests/fm-dispatch-resolve.test.sh passes for me locally on this head. No workflow or secret surface is touched.

  • Contract class (my read): opt-in.
  • VISION, rule by rule: One captain aligns (no new captain-facing surface). Authority aligns (off unless configured). Scripts/agents aligns (the mapping is deterministic jq, and the resolver's judgment boundary is unchanged). Restart is neutral. Delegation aligns, with the caveat below. Outlives any vendor aligns (less coupling to one decision vendor). Scope aligns.

What's needed from you (this is waiting on you, no rush):

  1. Raise it through no-mistakes. "PR must be raised via no-mistakes" fails because the body has no ## Pipeline attestation. Please re-raise with git push no-mistakes so the attestation binds the head.
  2. Live captures. You noted the live provider checks are still pending, and fm-dispatch-resolve: opt-in System One-compatible and OpenAI Decisions providers, building on #7149 #7643 asked that the PR carry them because the OpenAI Decisions response shape is only described as illustrative. When you have access, could you run one real request per provider (an OpenAI key, and a System One-compatible host such as a local llama.cpp/Clef server) and post the redacted request/response or the dispatch-resolve outcome lines? If one provider can't be tested, saying so plainly is fine. Then I can look at it again.

Separately, Behavior portable serial 1 hit its 30-minute limit on this run. That's unrelated to your change, and the re-raise will run CI again anyway.

@rchristensen
rchristensen force-pushed the fm/fm-decisions-provider branch from d72cb79 to 8d01fe8 Compare October 23, 2026 17:52
@rchristensen rchristensen changed the title feat: add opt-in systemone and openai providers to typed dispatch resolution feat(bin): add opt-in systemone and openai decision providers to dispatch resolution Oct 23, 2026
@rchristensen

Copy link
Copy Markdown
Contributor Author

Both items are addressed at head 8d01fe8d:

  • OpenAI live capture added. docs/verification/dispatch-resolve.md now has a dated 2026-10-23 run against https://api.openai.com/v1/decisions with gpt-6-luna. The top rule matched the hand label on 25 of 25 synthetic briefs (20 clear, 1 ambiguous below the 0.6 floor, 4 approval escalations, 0 errors), with no clear result on the wrong profile. The section has one verbatim redacted request/response pair and a calibration note. The live response matched the guide's illustrative shape, so the mapping needed no change.
  • System One / Clef not tested. No compatible host or hardware was available, so that live section stays marked pending.
  • Raised through no-mistakes. The PR body now carries the ## Pipeline attestation bound to this head.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @rchristensen. Both asks are done: the attestation binds 8d01fe8d and passes, and the OpenAI capture (25 of 25 matched, with a verbatim redacted pair) is exactly what #7643 wanted. Saying plainly that System One/Clef couldn't be tested is fine.

What I checked (head 8d01fe8d vs main af1c6817): the code commit is byte-identical to the 29d3d159 I reviewed (range-diff =), and the only new commit is the verification doc. With no FM_DISPATCH_PROVIDER set, nothing changes. systemone/openai run only when selected, missing settings exit before any network call, and keys still reach curl only through fd 3. No workflow or secret surface is touched.

Contract-class (my own read): opt-in, unchanged. VISION.md per rule: One captain aligns · Authority aligns (off unless configured) · Scripts aligns (deterministic jq mapping) · Restart neutral · Delegation aligns (live capture on record) · Vendor aligns (less coupling to one decision vendor) · Scope aligns.

Status: waiting on CI, not on you. Every behavior check passes except Behavior portable parallel 2, which fails the "packing exactly at the budget" test in tests/fm-test-run.test.sh. That test is failing the same way on main, and this PR doesn't touch it. The Behavior timing aggregate job is still queued behind the runners. Once it finishes and the head is unchanged, I'll merge this on the opt-in path. Nothing else is needed from you.

@rchristensen

Copy link
Copy Markdown
Contributor Author

The one failing job here, Behavior portable parallel 2, fails on tests/fm-test-run.test.sh: "packing exactly at the budget must be accepted: expected exit 0, got 1". The same test fails on unmodified main af1c6817, both in main's own CI run (https://github.com/kunchenguid/firstmate/actions/runs/39968920221/job/120581384511) and locally. This PR does not touch the test runner or its timing data, so the failure is unrelated, and this PR adds no fix for it.

…h resolution

Extend the FM_DISPATCH_PROVIDER/FM_DISPATCH_MODEL seam with a generic
systemone provider (any System One-compatible host at FM_DISPATCH_BASE_URL,
optional FM_DISPATCH_API_KEY) and an openai provider that maps the Choice
request to OpenAI's Decisions API and its answer back. No provider set keeps
the original off line; the never-send check runs on the endpoint and the final
per-provider body. Live provider captures are recorded as pending.

Refs kunchenguid#7643, builds on kunchenguid#7149.
…atch resolution

Add a dated 2026-10-23 section for the openai provider: 25 hand-labeled
synthetic briefs against gpt-6-luna, outcome and latency tables, the usage
and header fields actually returned, a calibration note, and one verbatim
request and response pair. The systemone live check stays pending.

Refs kunchenguid#7643.
…ovider

Replace the pending systemone section with a dated 2026-10-23 run against
Cloudflare Workers AI's @cf/cloudflare/clef, reached through a local
test-only relay because Workers AI serves System One at /ai/run/<model> in
a {result, success} envelope. Adds the outcome and latency tables, a
calibration note compared with the gpt-6-luna run, and one verbatim request
and envelope pair. A direct Workers AI option stays out of scope.

Refs kunchenguid#7643.
@rchristensen
rchristensen force-pushed the fm/fm-decisions-provider branch from 8d01fe8 to 7236b68 Compare October 23, 2026 21:46
@rchristensen

Copy link
Copy Markdown
Contributor Author

The systemone live capture is now recorded too, at head 7236b686: verification section.

  • Clef (@cf/cloudflare/clef on Cloudflare Workers AI) ran on the same 25 synthetic briefs and rules as the OpenAI run. The top rule matched the label on 23 of 25. Outcomes were 18 clear, 3 ambiguous and 4 approval escalations, with 0 errors and no clear result on the wrong profile. The two misses were both ambiguous, below the 0.6 floor. Resolver latency was 151 to 513 ms.
  • Workers AI serves System One at /ai/run/<model> inside a {result, success} envelope rather than at /v1/systemone. The run therefore went through a local test-only relay that forwarded the body unchanged and returned result verbatim. The resolver accepted every response without adaptation. The relay is not part of this PR, and a direct Workers AI option is out of scope here.
  • The section includes one verbatim request and envelope pair. The token and account id are absent from every capture. The attestation is bound to the new head.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @rchristensen — the Clef capture closes the last open item, and the write-up of the Workers AI relay (test-only, body forwarded unchanged, token/account id absent from the captures) is exactly the clarity I'd want. The resolver code is byte-identical to what I reviewed (82336f71, range-diff =). The new commit 7236b686 is only docs/verification/dispatch-resolve.md, and the attestation binds that head.

Contract-class (my own read): opt-in, unchanged. VISION per rule is as in my last note (all align / restart neutral).

Status: waiting on CI, not on you. On this head, Behavior portable parallel 2 fails only the main-inherited "packing exactly at the budget" test (this PR doesn't touch fm-test-run*). Behavior portable serial 8 failed once in tests/fm-fork-free-helpers.test.sh ("epoch helper differs … outside [1792793461, 1792793461]"), which is a one-second clock-boundary race in an unrelated helper test. I'll rerun it when the run finishes. Serial 1 and the timing aggregate are still going. Once those are green and the head hasn't moved, I'll merge on the opt-in path.

@rchristensen

Copy link
Copy Markdown
Contributor Author

None of the CI results at head 7236b686 comes from this change, which touches only the dispatch-resolve files:

  • Behavior portable parallel 2 is the known packing test in tests/fm-test-run.test.sh ("packing exactly at the budget must be accepted"). It also fails on main.
  • Behavior portable serial 1 was cancelled at the 30-minute job limit. Main 86437e28 shows the same cancel.
  • Behavior portable serial 8 failed on a 1-second clock-boundary race in tests/fm-fork-free-helpers.test.sh: the epoch helper read 1792793460 against a date +%s window of 1792793461. That test passes on main and passed 5 of 5 times locally.

Could a maintainer rerun Behavior portable serial 1 and Behavior portable serial 8? Rerunning a job needs admin rights, which the author's account doesn't have.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @rchristensen, and agreed on all three. I checked the logs for run 40029198928 at head 7236b686:

  • Behavior portable parallel 2: the packing-at-budget test in tests/fm-test-run.test.sh, inherited from main; this PR does not touch the test runner.
  • Behavior portable serial 1: cancelled at the 30-minute job cap. Main hits the same cap, and the fix for that is in flight separately.
  • Behavior portable serial 8: the 1-second epoch-boundary race in tests/fm-fork-free-helpers.test.sh, a known flake unrelated to dispatch resolution.

I've rerun the failed jobs (run 40029198928, attempt 2). If serial 1 and serial 8 come back green and the head is still 7236b686, this is ready to merge on the next pass: it is opt-in (both providers stay off unless configured), no-mistakes passes, and both live captures are recorded. Nothing further is needed from you unless the rerun turns up something new.

@rchristensen

Copy link
Copy Markdown
Contributor Author

@kunchenguid it looks like serial 1 was canceled, can we retry?

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks for the nudge, @rchristensen. You're right: on attempt 2 of run 40029198928, serial 8 passed and serial 1 was cancelled at the 30-minute cap again. The only other red is the parallel 2 packing test, which comes from main.

I'm not re-running it right now, and here's why. Main's own CI is currently red because GitHub moved ubuntu-latest to 26.04, which breaks a set of watcher/timeout tests on every PR. A re-run would also reuse the merge ref from Oct 23, which still has the old packing failure. A fix for main is pending (pinning the Linux jobs to 24.04). Once it lands, we'll start a fresh CI run on current main for this PR, rather than re-running the stale one. That run is the useful signal.

I re-checked the tip 7236b686 myself against main 127f0f30. With FM_DISPATCH_PROVIDER unset, the typesafe gate and request are unchanged. systemone and openai engage only when you select them and give a model, plus a base URL or key. Keys still reach curl only through fd 3. The never-send check now also covers the endpoint and nested JSON text, which only tightens it. Contract-class: opt-in. VISION is unchanged from my last note: all rules align, and restart is neutral. no-mistakes passes, the attestation binds this head, and both live captures are recorded.

Status: waiting on CI, on our side, not on you. If the fresh run is green and the head is still 7236b686, this lands on the opt-in path.

@rchristensen

Copy link
Copy Markdown
Contributor Author

@kunchenguid can we get one more re-run here? looks like serial 1 was cancelled. let me know if i need to rebase or make further changes

@kunchenguid kunchenguid reopened this Oct 29, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks for the nudge, @rchristensen. No rebase or changes are needed from you.

Rather than re-run the old run, which would reuse the Oct 23 merge ref, I closed and reopened this PR to start a fresh CI run against current main (run 40890060873). Main is now on the 24.04 runner pin and has the packing fix, so this run is the useful signal. Head is still 7236b686. My last verdict stands: contract-class opt-in (with FM_DISPATCH_PROVIDER unset the typesafe gate is unchanged), VISION aligns, no-mistakes binds this head, both live captures are recorded, and the PR is mergeable.

Status: waiting on CI, on our side. If the fresh run is green and the head is unchanged, this lands on the opt-in path next pass.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Reviews (1) · Last reviewed commit: "docs(verification): record the live Clef..." · Reviewed by Greptile

@kunchenguid
kunchenguid merged commit 0f2cf78 into kunchenguid:main Oct 29, 2026
53 of 58 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

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