Skip to content

perf(coordinator): use WriteString for per-chunk SSE writes - #411

Closed
matiasinsaurralde wants to merge 2 commits into
Layr-Labs:masterfrom
matiasinsaurralde:perf/sse-stream-writes
Closed

matiasinsaurralde wants to merge 2 commits into
Layr-Labs:masterfrom
matiasinsaurralde:perf/sse-stream-writes

Conversation

@matiasinsaurralde

@matiasinsaurralde matiasinsaurralde commented Jun 19, 2026 •

Copy link
Copy Markdown

Summary

  • Replace fmt.Fprintf(w, "%s\n\n", frame) on the streaming SSE hot path with a writeSSEFrame helper backed by io.WriteString.
  • Avoids reflection-based formatting and per-chunk buffer allocation on every streamed token.
  • Behavior-preserving: wire output is byte-identical to the old call sites.

What changed

handleStreamingResponseWithFirstChunk now uses writeSSEFrame for the four passthrough writes that emit an already-serialized frame:

  • first-chunk forward
  • per-token relay
  • finish-chunk finalize
  • usage-chunk finalize

Terminal/error writes (data: %s\n\n) are unchanged — they run once per request, not on the hot path.

Adds TestWriteSSEFrame to lock in byte-identical framing (unicode, % literals, embedded newlines, empty frames).

Test plan

  • cd coordinator && go test ./api -run TestWriteSSEFrame -v
  • cd coordinator && go test ./api/...

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

@vercel

vercel Bot commented Jun 19, 2026

Copy link
Copy Markdown

@matiasinsaurralde is attempting to deploy a commit to the EigenLabs Team on Vercel.

A member of the Team first needs to authorize it.

Replace fmt.Fprintf on hot-path streaming writes with io.WriteString.

Signed-off-by: Matías Insaurralde <matias@insaurral.de>
@matiasinsaurralde
matiasinsaurralde marked this pull request as ready for review June 19, 2026 23:47

@ethenotethan ethenotethan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review — Layr-Labs/d-inference#

Verdict: REQUEST_CHANGES

Security — ✅ No issues found

Performance — 1 finding(s) (1 blocking)

  • 🟡 [MEDIUM] coordinator/api/consumer.go:325-327 — Two separate WriteString calls instead of single write may cause additional syscalls
    • Suggestion: Use a single write with pre-allocated buffer or strings.Builder to avoid potential double syscall overhead on hot streaming path

Type_diligence — ✅ No issues found

Additive_complexity — ✅ No issues found

1 finding(s) total, 1 blocking. Verdict: REQUEST_CHANGES.

🤖 Automated review by Centaur · DAR-186

Comment on lines +325 to +327
func writeSSEFrame(w io.Writer, frame string) {
_, _ = io.WriteString(w, frame)
_, _ = io.WriteString(w, "\n\n")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 [MEDIUM] ⚡ Two separate WriteString calls instead of single write may cause additional syscalls

💡 Suggestion: Use a single write with pre-allocated buffer or strings.Builder to avoid potential double syscall overhead on hot streaming path

📊 Score: 3×4 = 12 · Category: Blocking I/O on hot paths

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ethenotethan The two WriteString calls should actually be faster than a concatenated call in most scenarios:

Variant ns/op B/op allocs/op vs Fprintf
TwoWrites 4.6 0 0 6.8x faster
Fprintf 31.2 16 1 baseline
Concat 40.4 192 1 1.3x slower

Benchmark:

package api

import (
	"fmt"
	"io"
	"testing"
)

// Realistic SSE chunk from a streaming chat completion response.
var benchFrame = `data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1719849600,"model":"qwen3-30b-a3b","choices":[{"index":0,"delta":{"content":" the"},"finish_reason":null}]}`

// writeSSEFrameFprintf is the original implementation using fmt.Fprintf.
func writeSSEFrameFprintf(w io.Writer, frame string) {
	fmt.Fprintf(w, "%s\n\n", frame)
}

// writeSSEFrameTwoWrites uses two separate io.WriteString calls.
func writeSSEFrameTwoWrites(w io.Writer, frame string) {
	_, _ = io.WriteString(w, frame)
	_, _ = io.WriteString(w, "\n\n")
}

// writeSSEFrameConcat uses a single io.WriteString with string concatenation.
func writeSSEFrameConcat(w io.Writer, frame string) {
	_, _ = io.WriteString(w, frame+"\n\n")
}

func BenchmarkWriteSSEFrame_Fprintf(b *testing.B) {
	b.ReportAllocs()
	for b.Loop() {
		writeSSEFrameFprintf(io.Discard, benchFrame)
	}
}

func BenchmarkWriteSSEFrame_TwoWrites(b *testing.B) {
	b.ReportAllocs()
	for b.Loop() {
		writeSSEFrameTwoWrites(io.Discard, benchFrame)
	}
}

func BenchmarkWriteSSEFrame_Concat(b *testing.B) {
	b.ReportAllocs()
	for b.Loop() {
		writeSSEFrameConcat(io.Discard, benchFrame)
	}
}

@Gajesh2007

Copy link
Copy Markdown
Member

@codex review this

@matiasinsaurralde

Copy link
Copy Markdown
Author

@Gajesh2007 Updated, the review wasn't that accurate

@Gajesh2007 Gajesh2007 closed this Sep 14, 2026
jonathan308 added a commit that referenced this pull request Nov 14, 2026
* feat(provider): draft through Qwen JSON reasoning and retain service opt-in

* test(provider): drain span fixtures on every failure path

* fix(inference): pin qualified native reasoning budget runtime

* fix(provider): keep the Gemma tool grammar linear in nested optional objects

A required or named tool_choice on Gemma 4 builds a byte automaton of the
call. `members` built a property's value once for each emitted state of the
members before it, and a nested object gets a fresh member scope, so an
optional object behind an optional sibling was copied twice per level. A
depth-16 chain of such objects is accepted by every compiler limit (its
grammar cost counts each property once) yet built about 2.5 million states,
and a schema near the cost ceiling projects to billions, all before the
100,000-state check ran on the finished automaton.

- Build each property's `name:value` and the members after it once per
  object and enter it from both emitted states, after a comma or not. Every
  member list of an object ends where the object closes, so the accepted
  language is unchanged.
- Check the 100,000-state limit in `value` and `members` while building, so
  an oversized grammar stops one value past the limit instead of being built
  and distance-ranked in full.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(provider): refuse deeply nested request JSON and bound schema normalization

A coordinator request's decrypted body is parsed by JSONSerialization and
JSONDecoder, which recurse once per object or array level, on a Swift
concurrency task whose stack is 512 KiB. A chat body of a few KB whose tool
schema nested a few hundred levels deep (128 in a debug build) exhausted that
stack and killed the provider with SIGBUS, below JSONSerialization's own
512-level limit. The coordinator forwards such bodies: it parses with Go's
decoder and normalizes tool schemas only to depth 64.

- Add `JSONNestingLimit`, a non-recursive scan that counts open containers
  and skips brackets inside strings. Refuse bodies deeper than 64 levels
  before any parse: in the coordinator handler right after decryption
  (`malformed_body`), in `repairedRequestBody` for every other caller, and in
  the local chat, batch, Responses and router paths (HTTP 400).
- Give tool-schema normalization a 100,000-node budget per request. Each
  positional `{}` or boolean became a two-key map, so a few MiB of them
  rewrote into ~85 MB of JSON and ~900 MiB of objects before decoding. Past
  the budget the body is decoded as sent, as one over 4 MiB already is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(provider): GPT-OSS commentary content is on by default

Red first for the default flip the owner asked for (proven fixes ship on,
the switch kept as the kill switch): unset, empty or any value other than
an off word maps a recipientless commentary preamble to content; an off
word (`0`, `off`, `false`, `no`, `none`, `disabled`, any case) keeps
0.10.12's dropped preamble. #2063's byte-for-byte case for the preamble
moves to an explicit kill-switch-off test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(provider): GPT-OSS commentary content on by default

The owner's order for 0.10.13: proven fixes ship on, with the switch as the
kill switch. `HarmonyFinalHeaderFilter.commentaryEnabled`: unset, empty or
any value other than an off word (`off`, `false`, `0`, `none`, `no`,
`disabled`; any case, surrounding space ignored) maps a recipientless
assistant commentary preamble to content; an off word restores 0.10.12
(dropped). Same parsing as DARKBLOOM_GPTOSS_FORCED_TOOLS. Still on the
LaunchAgent passthrough list, so `DARKBLOOM_GPTOSS_COMMENTARY_CONTENT=0`
reaches launchd providers. Docs and the changelog fragment say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(provider): Qwen stray think-close absorption is on by default

Red first for the default flip the owner asked for (proven fixes ship on,
the switch kept as the kill switch): for the Qwen types, unset, empty or any
value other than an off word absorbs a stray `</think>` and selects the
native split for a closed-thought prompt; an off word (`0`, `off`, `false`,
`no`, `none`, `disabled`, any case) keeps 0.10.12's literal close.
`NativeToolStreamRouterTests`' family table now expects `qwen4_exp` to
absorb by default (Nemotron 3.5's listing builds as before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(provider): Qwen stray think-close absorption on by default

The owner's order for 0.10.13: proven fixes ship on, with the switch as the
kill switch. `QwenStrayThinkClose.enabled`: for the Qwen types, unset, empty
or any value other than an off word (`off`, `false`, `0`, `none`, `no`,
`disabled`; any case, surrounding space ignored) absorbs a stray `</think>`
and gives a closed-thought prompt the native split; an off word restores
0.10.12 (literal). Still on the LaunchAgent passthrough list.

Review finding (review-2093, MINOR, now reachable by default): media path 1
resolved its request-owned tool parser after `submitTokenized`; a parser
that failed to resolve left the submitted row to stream-drop termination.
The handler is now resolved before submission, inside the same do/catch
(same inputs, same result). The stale `toolHandler: nil` doc comment says
so. Docs and the changelog fragment updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(provider): stage an update only as the version it is signed as

`latestRelease` takes the release `version` from the coordinator's JSON, and
`checkForUpdate` judges no-downgrade eligibility by it. Staging verified the
bundle, binary and metallib hashes and the pinned code signature, but never
compared that label with the version the app is signed as, and the recovery
record then carried the label. Whoever controls the release response could
offer an older, genuinely signed build under a newer version and have it
installed.

After the deep signature check (and the runtime capability check), staging
now requires the app's sealed `CFBundleShortVersionString` to equal the
release's `version` exactly, under every policy that verifies signatures
(production and the signed test fixture). Release builds set that key to the
registered version, which the coordinator requires to be bare semver, so an
exact string comparison is the contract. `signedVersion(ofApp:)` becomes
static so staging can use the same reader as recovery.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(provider): require the LaunchAgent to forward the SDK feature switches

DARKBLOOM_CBV2_MTP_GRAMMAR (SDK #409) and DARKBLOOM_GEMMA_SCHEMA_COERCION
(SDK #408, provider #2090) are read by the SDK; neither reaches the launchd
provider job today, so neither can be enabled or killed in the installed
service. Red: both keys are missing from LaunchAgent.passthroughEnvKeys.

* test(provider): pin 0.10.12's MiMo refusal class with the budget switch off

review prov-2099 SF3: with DARKBLOOM_NATIVE_REASONING_BUDGET off, a
reasoning object whose max_tokens is not an integer now throws inside the
decoder and skips the effort check, so {max_tokens: null, effort: bogus} is
refused as invalid_tool_payload instead of 0.10.12's
unsupported_reasoning_control. Red on 2ec6d07f98 for every listed value.

* fix(provider): forward the SDK feature switches to the installed service

LaunchAgent.passthroughEnvKeys gains DARKBLOOM_CBV2_MTP_GRAMMAR (SDK #409,
next to DARKBLOOM_CONSTRAINT_SPANS) and DARKBLOOM_GEMMA_SCHEMA_COERCION
(SDK #408 / #2090), so an operator's value, including the 0 rollback, reaches
the launchd provider job. Values are unchanged (still opt-in). Docs: the
grammar-MTP row in the configuration reference; the Gemma switch is forwarded.

* fix(provider): keep 0.10.12's MiMo refusal with the budget switch off

Decode reasoning.max_tokens only when DARKBLOOM_NATIVE_REASONING_BUDGET is
on, and never let a non-integer value throw past the effort check: off, the
key is an unknown key exactly as in 0.10.12 (invalid, then the effort check
classifies the refusal); on, an unusable value is invalid without skipping
the effort check. Accepted budgets are unchanged.

* refactor(provider): build the member comma first and pin the state-limit error

Refactor-pass follow-up. Building the comma after the shared member left its
edge pointing back to an earlier state, so the reverse-order minimum-distance
pass needed an extra sweep per comma on all-required schemas (0.24 s became
0.51 s near the grammar-cost ceiling). Build it first: an all-required
automaton is again identical to the original, node for node.

Tests now use the compiler's real maximum depth (16) and expect the exact
state-limit error; comments state the rule rather than its history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(provider): only Qwen JSON answers may offer free spans to the engine

review prov-2101 SF1: every JSONAnswerConstraint conforms to
CBv2FreeSpanTokenConstraint, and the SDK makes a row MTP history-eligible by
that conformance alone. With DARKBLOOM_CONSTRAINT_SPANS on, a Nemotron
Lightning, Bonsai or GPT-OSS JSON row would seed assistant history every
step instead of chained decode. Red: the Bonsai constraint conforms.

* fix(provider): offer free spans only from Qwen JSON answers

JSONAnswerConstraint no longer conforms to CBv2FreeSpanTokenConstraint; the
new QwenJSONAnswerConstraint subclass does, and JSONAnswerPolicy builds it
for the Qwen family only. With DARKBLOOM_CONSTRAINT_SPANS on, Nemotron
Lightning, Bonsai and GPT-OSS JSON rows therefore keep target-only chained
decode instead of seeding MTP history every step (review prov-2101 SF1).
Qwen behaviour is unchanged; off is unchanged.

* test(provider): Super concurrent images on by default

Red first for the default flip the owner asked for (proven fixes ship on,
the switch kept as the kill switch): with the switch unset or any value
other than an off word, two encoded images share an owner that serves at
least three requests; an off word (`0`, `off`, `false`, any case, trimmed)
keeps 0.10.12's single-media admission, as does a narrower owner.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(provider): Super concurrent images on by default

The owner's order for 0.10.13: proven fixes ship on, with the switch as the
kill switch. `NemotronSuperLocalBridgeBuilder.concurrentImagesEnabled`:
unset, empty or any value other than an off word (`off`, `false`, `0`,
`none`, `no`, `disabled`; any case, trimmed) lets an owner serving at least
three requests take two image rows; an off word restores 0.10.12's
single-media admission. The key joins LaunchAgent.inferencePassthroughEnvKeys
(after the other Super key), so `=0` reaches launchd providers. Docs and the
changelog fragment say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(provider): provider defaults for SDK-read feature switches (none on yet)

SDKFeatureDefaults.apply() sets each switch listed in onByDefault to 1
before the serving process builds an engine or parser, only where the shell
or the LaunchAgent plist sets nothing, so <KEY>=0 stays the kill switch
(0.10.12's behaviour). darkbloom start and benchmark call it; start logs the
switches it turned on. The list is empty here: a switch joins it only with
its hardware evidence. Tests: the projection never overrides an operator
value, and every listed switch is forwarded by the LaunchAgent.

* docs: move the Gemma quoted-number and SDK-default sections off the end of shared docs

The four docs files ASTRA-QUICK's phase-D items (#2091-#2093) also append to
no longer collide at end of file: the Gemma switch row joins the engine and
scheduler table beside DARKBLOOM_GEMMA_JSON_ANSWERS (review prov-2090 NIT 8),
the SDK feature defaults section sits before Native reasoning budgets, and
the inference, hardware-support and cli-reference sections sit beside their
Gemma / LaunchAgent neighbours. Text unchanged apart from the moved row.

* test(provider): GLM-5.3-Flash JSON answers are grammar-constrained behind a switch (red)

GLM's JSON response_format answers are prompt-steered and checked after
generation; under batching about 7 % miss the schema (an invented key, a
missing required key) and become a 422 after the streamed reasoning.

Pins the SDK change that lets GLM's native page-bank engine run token
constraints (mlx-swift-lm structured/glm-native-token-constraints e8b588dd,
on the cumulative SDK #416) and adds, without admitting GLM yet:
- JSONAnswerProfile.glm5Next (byte-level BPE below <|endoftext|> 154820,
  the think markers 154841/154842 as pieces, answers ending with <|user|>
  or <|endoftext|>, vocabulary 154880);
- DARKBLOOM_GLM_JSON_ANSWERS (on only with 1/on/true/yes for now), passed
  to the launchd job;
- EngineV2Bridge.acceptsTokenConstraints, passed from the text path through
  ToolConstraintFactory to JSONAnswerPolicy.
The admission tests fail: GLM is not admitted yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(provider): DARKBLOOM_GLM_JSON_ANSWERS constrains GLM-5.3-Flash JSON answers with the JSON answer grammar

JSONAnswerPolicy admits glm5_next (JSONAnswerProfile.glm5Next) when the
switch is on and the slot's engine runs token constraints
(EngineV2Bridge.acceptsTokenConstraints: the native page-bank profiles the
pinned SDK qualifies; never a cluster pair). The answer is then one JSON
value of the request's schema, as on Qwen, Bonsai and Lightning, so the
misses GLM shows under batching (an invented key, a missing required key,
trailing text) can no longer be sampled. GLM's JSON prompts open a thought,
and the reasoning is constrained too (EOS masked, no turn marker spelled),
so such a request decodes target-only. GLM's withheld answer and its check
are unchanged and still run.

Every request the grammar does not cover (tools, tool_choice, media, a
schema outside the subset after the rewrite, an unpinned tokenizer, an
unrecognized prompt end) keeps today's prompt-steered, checked answer with
a content-free log line. Off by default until proven on hardware.

Docs: the JSON answer grammar's family table, GLM's ids and markers, the
GLM JSON paragraph, the configuration row; a changelog fragment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(provider): on a full Mac, the exit's continuation must not be refused for width (red)

#2100's GPU check (Mac A, Gemma 4-bit, 16 requests on 8 slots) found a
second way the continuation fails: no `admission_timeout`, but exits ended
"continuation refused: token_budget_exhausted: whole-Mac service allowance
exhausted". The bridge waits for the stopped row's share of the whole-Mac
allowance to be released before it submits the continuation; on a full Mac,
work waiting for a slot takes that share first, and the continuation (a new
submission) is refused for width: the held `length`, no answer.

The test fills every whole-Mac slot. An ordinary request is refused as
capacity (503 locally; re-routed upstream); a continuation (submitted with
the exit's admission priority) must reach the engine. Red: it is refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(provider): stray think-close default keeps Qwen3-VL's route; #2057's thinking-off case absorbs

CI of the default-on flip (88c2aeddd4, run 43527020131) failed exactly two
tests, which are this commit's red:
- EngineV2ProductionWiringTests "a plain Qwen3-VL Instruct tail seeds content
  state ahead of output": Qwen3-VL Instruct's bare prompt tail gets a synthetic
  `<think></think>` content seed (ReasoningPromptProbe.plainTailContentModelTypes),
  not a thought its template closed, and the model never reasons; by default it
  took the native split. Qwen3-VL (`qwen3_vl`, `qwen3_vl_moe`) leaves
  QwenStrayThinkClose.modelTypes and keeps its route (tested).
- QwenReasoningBeforeToolsTests "thinking off: a stray </think> stays text"
  (#2057's split route): that literal is exactly what #2093 absorbs, so the
  case now expects the close absorbed and the text around it kept; the kill
  switch keeps the literal (QwenStrayThinkCloseConformanceTests).
Also the review's nits: ToolChoiceEnforcementPolicy's comment and the
changelog's scope wording.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(provider): a native engine that runs token constraints is not refused at submit (refactor pass)

The dedicated refactor pass found the blocker: EngineV2Bridge's
nativeOutputControlRefusal answered every constrained request on a
native-tracked engine with a typed 400 before submit, so with the switch on
an admitted GLM JSON answer was refused instead of constrained. It now
refuses only where the engine does not run constraints
(EngineV2.acceptsTokenConstraints, as logprob rows already key on
acceptsLogprobRows); MiMo and every other native engine still refuse.
NativeOutputControlRefusalTests pins both.

Also from the pass (behavior-preserving): the scheduler reads the JSON flag
once for both bridge queries, the bridge flag's and the launchd key's
comments say exactly when they hold, the GLM tests share one request and
constraint helper. Its notes: protocol-messages and ToolChoiceEnforcement-
Policy no longer say GLM's engine refuses every constraint, and the
DARKBLOOM_JSON_ANSWER_GRAMMAR row says GLM has its own switch.

The real-tokenizer check is GLM's own: the GLM-5.3-Flash template opens a
thought in every generation prompt, so a JSON prompt starts in reasoning
(the shared check expected a thinking-off answer phase and failed on the
real tokenizer locally).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(provider): the exit's continuation takes its stopped row's place in the whole-Mac allowance

The bridge waits for the stopped row's share of the whole-Mac service
allowance to be released before it submits the continuation. On a full Mac
work waiting for a slot takes that share first, and the continuation, a new
submission, was refused for width ("token_budget_exhausted: whole-Mac
service allowance exhausted"): the held `length`, no answer (#2100's GPU
check on Mac A: 2 of 7 exits).

A continuation (`EngineAdmissionPriority` above 0) is no longer refused for
width: `acquireServiceAllowance(takesStoppedRowPlace:)` skips the width
checks and `WholeMacServiceBudget.acquire(overcommit:)` charges it even when
the sum is full. It may exceed the width by itself until it ends; other work
waits meanwhile, and the engine admits it first (#2100). Every other request
is refused as before. Docs and the changelog fragment.

Local: 79/79 (red 2204e67e7f: exactly the new test failed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(provider): apply SDK feature defaults in every process, never persist them

review prov-2109 (delta) SF1/SF2 and nits, before any switch is listed:
- SDKFeatureDefaults.apply() runs in main.swift before any command, so
  single-Mac serving, pair members (start --cluster-member / --distributed),
  workers and benchmarks agree, instead of only start's single-Mac path;
- keys it injected are remembered and LaunchAgent.passthroughEnvironment
  leaves them out, so an installing process never pins today's default into
  the service plist (the operator's own value, 0 included, is still
  forwarded); test: injectedDefaultsAreNeverWrittenIntoAServicePlist;
- an empty value counts as unset (the LaunchAgent drops empty values), so
  foreground and installed service agree; 0 is the kill switch;
- start names the switches it turned on; benchmark prints them on stderr.
The list stays empty: no behaviour change.

* Re-pin the SDK to the phase-D cumulative head with #407

libs/mlx-swift-lm 73dcc01913 = SDK #418: #407 (O5, Gemma reopened
thoughts, opt-in) merged onto #417 (GLM token constraints) and the
cumulative #416 (#409 + #413 + #411 + #408 on SDK main 859f641529).
Gitlink only. #407's parser change is identical to the f96a2ee5f5 pin.
The phase-D pin F re-pins to SDK main once the owner merges #416, #417
and #418 (same tree).

* test(provider): the managed slot's one-image-at-a-time case runs with the kill switch

CI of the default-on flip (61a8fbc88b) failed exactly one test, this
commit's red: NemotronSuperManagedSlotTests
concurrentImageIsRefusedWith429AndInvalidVideoWith400 asserted the old
default (a second image while the first streams gets 429). With concurrent
images on by default the managed slot admits it, so the case now runs with
DARKBLOOM_NEMOTRON_SUPER_CONCURRENT_IMAGES=0 through the fixture's
environment (no process-global state) and keeps its contract: the kill
switch restores 0.10.12's single-media admission, 429 / wait / 400.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(provider): stray think-close scope and the Qwen3-VL exclusion in the architecture doc

Delta review nits (review-2093-on-delta2.md): inference.md still said 'without tools' and did not name the Qwen3-VL exclusion; QwenStrayThinkClose's comment implied both Qwen3-VL types are seeded. Docs and comment only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(provider): HarmonyFinalHeaderFilter comment wording

Delta review nits (review-2092-on.md): the type comment's switch sentence and answerHeader's reflowed doc comment. Comments only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(provider), docs: GLM JSON grammar review — the factory seam, a serving test, the costs (review)

From the independent review (REQUEST CHANGES; narrow, no code defect):
- ToolConstraintFactory.make takes glmJSONAnswers (default the switch), so
  the factory test now proves the engine flag reaches the policy whatever
  the process environment.
- GLMJSONAnswerServingTests: a reasoning-first answer, a miss (typed 422
  under GLM's name, no content quoted) and a cut at the limit through the
  forwarding body with GLM's withheld answer and JSONAnswerOutput both on.
- <|observation|> stops the engine but cannot end an answer (asserted).
- The SDK pin moves to #417's head 5b66768a: a constrained row never chains
  on a native-tracked engine.
- Docs say the costs: a lone GLM JSON request loses MTP for its reasoning
  and answer, so does a plain request sharing a two-row step (GLM drafts
  with at most two rows), and an admitted row donates no prefix
  checkpoint. Three sentences fixed (GLM keeps its withheld answer either
  way; its 422 carries no content; GLM declines widened schemas). The test
  guide, the cli-reference passthrough table and the changelog name GLM.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Move O5's docs and CI step off the shared insertion points

Phase D folds several provider PRs that each appended a section at the
end of the same six docs files, and #2090's O4 conformance step sits
where O5's did. Each O5 docs section moves, unchanged, next to related
content (inference.md: after "Collected and streaming reasoning state";
two headings change level to fit their new parent; anchors are
unchanged). The O5 CI step now follows the desktop control API step,
with the same condition, and the workflow test lists its command there.
No behaviour change; scripts/test-provider-ci-workflow.py gives the same
results before and after.

* fix(provider): the review's findings on the continuation's allowance

The fresh-context review of #2115 (APPROVE WITH NITS):
- Medium: the over-commit can take the allowance's sum past 1. What the
  budget reports is capped at 1 (`snapshot`'s `usedFraction`, which goes out
  as `whole_mac_service_used`, and the deadline work's `serviceFraction`);
  admission keeps the real sum, so other work keeps waiting.
- The bound is stated: each continuation may exceed the width by one row
  until it ends, at most one per stopped row.
- No over-commit beside an exclusive (whole-Mac) charge, such as the idle
  prefill-evidence recovery.
- The pump task resets the continuation's admission priority (a task
  local), so nothing it might start inherits it.
- The test also checks that other work is still refused while the
  continuation runs, that the reported fraction stays capped, and that the
  share is released when it ends. (The bridge's own width checks apply only
  to the real EngineV2, out of a test engine's reach; the GPU check covers
  them.)

Local: 79/79.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(provider): check the signed version before the runtime smoke

Refactor-pass follow-up. Read the sealed version right after the deep
signature check, before `verifyRuntimeCapabilities` runs any staged code, so
a mislabelled release is refused without running its smoke test on every
Mac each update cycle. Accept and refuse are unchanged for every input; only
which error is reported changes when several checks fail. Test and changelog
wording now say exactly what they show.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(provider): one SDK default list per feature (still all empty)

Each later default flip (#2101 spans, #409 grammar MTP, #2090 Gemma quoted
numbers, #2099 reasoning budgets) is then a one-line change of its own list,
so any subset of the flips merges without conflicts. No behaviour change.

* docs: list the grammar-MTP switch after the strict tool grammar row

Keeps the DARKBLOOM_CONSTRAINT_SPANS and DARKBLOOM_CBV2_MTP_GRAMMAR rows apart,
so their default flips merge independently. Text unchanged.

* test(provider): require the spans SDK switch on by default

Red until its flip: SDKFeatureDefaults lists no key for spans yet.

* feat(provider): turn the spans SDK switch on by default (kill switch: =0)

SDKFeatureDefaults lists the key, so every darkbloom process turns it on
unless the operator sets it; =0 (shell or LaunchAgent) restores 0.10.12.
Docs: the configuration default column; changelog line. Ships only with its
hardware evidence in its CONFLICTS.md row.

* test(provider): require the o4 SDK switch on by default

Red until its flip: SDKFeatureDefaults lists no key for o4 yet.

* test(provider): require the grammar SDK switch on by default

Red until its flip: SDKFeatureDefaults lists no key for grammar yet.

* test(provider): require the o8 SDK switch on by default

Red until its flip: SDKFeatureDefaults lists no key for o8 yet.

* feat(provider): turn the o4 SDK switch on by default (kill switch: =0)

SDKFeatureDefaults lists the key, so every darkbloom process turns it on
unless the operator sets it; =0 (shell or LaunchAgent) restores 0.10.12.
Docs: the configuration default column; changelog line. Ships only with its
hardware evidence in its CONFLICTS.md row.

* feat(provider): turn the grammar SDK switch on by default (kill switch: =0)

SDKFeatureDefaults lists the key, so every darkbloom process turns it on
unless the operator sets it; =0 (shell or LaunchAgent) restores 0.10.12.
Docs: the configuration default column; changelog line. Ships only with its
hardware evidence in its CONFLICTS.md row.

* feat(provider): turn the o8 SDK switch on by default (kill switch: =0)

SDKFeatureDefaults lists the key, so every darkbloom process turns it on
unless the operator sets it; =0 (shell or LaunchAgent) restores 0.10.12.
Docs: the configuration default column; changelog line. Ships only with its
hardware evidence in its CONFLICTS.md row.

* Re-pin the SDK to #418's head 16aebe836a (F's tree)

libs/mlx-swift-lm 16aebe836a = SDK #418: #407 (O5) merged onto #417's
head e29eeebd8e, which carries #416 c1f8525d04 and SDK main 4342a661ac
(#414). If the owner merges #416, #417 and #418 into main as plain merge
commits, the final pin F has this tree; the last re-pin to F is then
gitlink only. #407's parser files are unchanged from the f96a2ee5f5 pin.

* Undo "Prepare provider 0.10.13" to fold 2040@03826b100a 2042@09ba436cdc 2047@b55ae64d6a 2051@98a9cded8c 2050@f10799abc1 2048@a849c562bf 2049@15f7d676e9 2052@0d2ec9ebfc 2053@42d9add895 2054@854c1ad495 2046@b4cc61883c 2057@220be61dd4 2058@4c5d7d9823 2063@1815e0773e 2065@585133d832 2045@8d7a6b51bd 2072@1542c6357e 2060@5a94d61d60 2061@1a8734918c 2070@dfb14ce00d 2069@5b4d5bc087 2071@3ce6f5cfdb 2075@b6c797c324 2084@7af346143c 2096@7e9378ad65 2088@001996379f 2100@2e241534b5 2098@d76366162a (it is redone on top)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Prepare provider 0.10.13

Version 0.10.13; the 28 changelog.d fragments rendered into CHANGELOG.md
(scripts/changelog.py render --version 0.10.13 --date 2026-11-14, verbatim, in
filename order) under the candidate heading, with the upgrade and rollout
notes; v0.10.12 marked published (2026-11-12); the 0.10.13 section of
docs/operations/provider-release.md. Base: master 5171ade3b6 (the 0.10.13 release branch's squash).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor: place #2099's lines and the Gemma switch apart from phase C's and Astra's edits

No behaviour change. #2109 now merges cleanly with every phase-C item
(#2096, #2098, #2088, #2100) and with ASTRA-QUICK's #2104 + #2094, in any
order:
- MultiModelBatchSchedulerEngine: the budget's exitThinking = nil follows
  the distributed-pair check instead of the resolve call #2088 edits (both
  only clear exitThinking);
- EngineV2Bridge+Submission: reasoningBudget is assigned after
  hybridPrefixIdentity instead of beside maxTokens, where #2100 adds priority
  (independent fields of the same request);
- the DARKBLOOM_GEMMA_SCHEMA_COERCION passthrough key, configuration row and
  inference section move next to the other SDK-read keys / JSON rows / the
  Qwen JSON section, away from #2098's Gemma prompt-contract additions.

* changelog: drop the duplicated default line of the o4 flip

* test(provider): by default Qwen 3.5 9B and 35B end a looping thought in an answer (red)

The Qwen exit-ON A/B decides the 0.10.13 default for Qwen 3.5 9B
(`qwen3_5`) and 35B (`qwen3_5_moe`). The same families also serve Qwen 3.6
(`qwen3_5_moe`) and the Qwen 3.8 27B builds (`qwen3_5`), which the A/B does
not cover: they must keep today's `length` by default.

- Serving (the scheduler's text path, the default setting): `Qwen3.5-9B`
  and `qwen3.5-35b-a3b` end a looping thought with `\n</think>\n\n` and
  answer; `qwen3.6-35b-a3b-vl-mtp-mxfp8` and both Qwen 3.8 27B builds
  (`ModelRuntimeRequirements.qwen38ConcreteModelIDs`) keep `length`; a list
  set on the Mac (`DARKBLOOM_LOOP_EXIT_THINKING=qwen3_5_moe,qwen3_5`) still
  turns the exit on for every build of its families.
- Policy: both families resolve an exit with the default setting.
- The Qwen 3.6 tests now turn the exit on with an explicit list
  (`qwenOn` = `qwen3_5_moe`), since the default no longer leaves it off.

Red (local, 85 tests): exactly the two default expectations fail (the
9B/35B serving test, `qwenFamilies`' default lines).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(provider): Qwen 3.5 9B and 35B end a looping thought in an answer by default

`qwen3_5` and `qwen3_5_moe` join the exit's default list, for the builds
the GPU A/B proved only (`defaultBuilds`: `Qwen3.5-9B` and `qwen3.5-35b-a3b`,
each with its own `model_type`, as `EngineV2SamplingDefaults`'
`qwen35CardModelTypes`). The same families serve Qwen 3.6 (`qwen3_5_moe`)
and the Qwen 3.8 27B builds (`qwen3_5`): by default their loops keep ending
as `length` until their own A/B (`keepsLengthByDefault`, one line after each
of the scheduler's `servesDistributedPair` lines, text and media paths). A
list set on the Mac (`DARKBLOOM_LOOP_EXIT_THINKING`) names families and
takes every build of each, as before.

The policy test covers the build table (the 9B and 35B on; Qwen 3.6, both
Qwen 3.8 27B builds and another 9B build off; a build only with its own
`model_type`; Gemma and GPT-OSS untouched; a list takes every build).
Docs and the changelog fragment (the A/B's numbers follow its verdict).

Local: 86/86 (red 0fafa5c30d: exactly the two default expectations failed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(provider): the LaunchAgent must forward the O5 switch (red)

An operator's DARKBLOOM_GEMMA_REOPENED_THOUGHTS (0 or 1) reaches a launchd-managed provider only if the plist carries it; the watchdog never parses. Fails until LaunchAgent forwards the key.

* fix(provider): forward the O5 switch to the launchd provider job

DARKBLOOM_GEMMA_REOPENED_THOUGHTS joins LaunchAgent.inferencePassthroughEnvKeys (not the watchdog's), as #2109 does for its SDK switches, so the operator's 0 or 1 reaches a service Mac too. Placed apart from the other phase-D insertions in the list. Docs and changelog no longer say foreground only.

* test(provider): require the O5 SDK switch on by default

Red until SDKFeatureDefaults lists DARKBLOOM_GEMMA_REOPENED_THOUGHTS: the default projection turns it on, an operator's 0 keeps it off, and the LaunchAgent forwards the operator's value (#2116).

* feat(provider): turn the O5 SDK switch on by default (kill switch: =0)

SDKFeatureDefaults lists DARKBLOOM_GEMMA_REOPENED_THOUGHTS (its own list, so this flip stays one change), so every darkbloom process turns it on unless the operator sets it; =0 (shell or LaunchAgent, forwarded since #2116) restores 0.10.12. Docs: the configuration default and rollback; changelog line. Ships only with its Gemma GPU evidence in its CONFLICTS.md row.

* fix(provider): close UTF-16, tool-call-argument and local-route gaps in the JSON limit

Refactor-pass follow-up to the JSON nesting limit.

- Refuse a body holding a NUL byte. Foundation's JSONSerialization and
  JSONDecoder also read UTF-16 and UTF-32 JSON, whose bytes the depth scan
  cannot count: a UTF-16 chat body with a 400-level tool schema passed the
  scan and still crashed the decoder (SIGBUS on dev). Every UTF-16 or UTF-32
  JSON text has a NUL byte; no UTF-8 one does.
- Check each tool call's `arguments` after decoding, on the coordinator path
  (refused as `invalid_tool_arguments`) and on the local chat, batch and
  Responses paths (400). The body scan skips JSON inside strings, and template
  rendering decodes and walks those arguments.
- Cover the SDK's other JSON routes on the local API (completions, tokenizer
  utilities, embeddings) with the same 2 MiB collection and check.
- Cleanups from the review: one refusal message constant, `refuses` naming,
  shared test builders, a router test, and the deepest accepted body decoding
  on a task's stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(provider): gate the Qwen default before the pair check, so it merges with #2109

#2109 (via #2099) adds its own line right after the text path's
`servesDistributedPair` check, where this PR's gate was: the same spot, a
merge conflict. The gate now comes just before that check, on both paths
(synchronous and cheap, it also skips the bridge hop for a gated build).
No behaviour change: each check only clears the exit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(provider): pin inherited injections, per-build defaults and the entry order (red)

review prov-2109-d2. New tests, failing by assertion against today's
behaviour (the new API below keeps it):
- MUST-FIX 1: a darkbloom child (DesktopWorker) inherits KEY=1 from its
  parent's injection and must not take it for the operator's: no plist
  entry, a grandchild still knows, a newer release that drops the key
  unsets it, the operator's own value still wins;
- SF2: SDKFeatureDefaults.apply() runs first in main.swift, before every
  early branch (the native serving qualification serves a model);
- SF3: per-build MTP defaults (spans, grammar MTP) turn on only for the
  listed builds and only when the operator leaves the switch unset;
  reasoning budgets follow a per-family default, the release's own
  injected 1 is not the operator's; the slot factory applies them.
API added with today's behaviour (no-op / unscoped): SDKFeatureDefaults
.plan, .injectedMarkerKey, .applyMTPDefaults, .matches, .followsDefault,
.summary; NativeReasoningBudget.isEnabled(for:).

* test(provider): width 1, a continuation takes its row's place beside the request that took the slot (red)

The delta review of #2115 (APPROVE WITH NITS; Low): the guard that keeps a
continuation from over-committing beside an exclusive charge reads the
charge's fraction (`>= 1`). On a width-1 profile every ordinary charge is
1, so the continuation is refused beside the request that took its stopped
row's slot: #2115's own failure, back on width-1 Macs. The idle
prefill-evidence recovery (`requiresIdle`) must still keep it out, until
its prompt completes (`reduceExclusiveAllowance`), at any width.

Red (local, 80 tests): exactly the new test fails, at both over-commits
(beside the width-1 charge; after the width-1 recovery's prompt completed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(provider): SDK defaults per build, inherited injections, applied first

review prov-2109-d2:
- MUST-FIX 1: apply() records what it injected in
  DARKBLOOM_SDK_DEFAULTS_INJECTED (inherited, never forwarded). A darkbloom
  child (the desktop app's DesktopWorker, cluster parts) treats a marked key
  whose value is still 1 as unset: its own release list decides it again
  and records it as injected, so its LaunchAgent install never persists it;
  a release that no longer lists the key unsets it; an operator value wins.
- SF2: main.swift applies the defaults first, before every early branch
  (the native serving qualification serves with the shipped defaults).
- SF3: defaults turn on only where they were measured.
  DARKBLOOM_CONSTRAINT_SPANS and DARKBLOOM_CBV2_MTP_GRAMMAR are never set
  process-wide: the slot factory turns them on in the engine's
  CBv2MTPConfig for the listed builds (model_type or model-id part) when the
  operator leaves them unset, and logs it; Gemma 4 and Super local MTP keep
  the SDK's reading (the operator's value). Reasoning budgets are admitted
  per family (NativeReasoningBudget.isEnabled(for:)); with a family listed
  the key is set process-wide so every engine accepts budget rows, and the
  provider's own 1 does not count as the operator's.
- start/benchmark name the switches and their builds/families; docs describe
  operator values as kill switches and the per-build defaults.
All lists stay empty here: no behaviour change until a flip folds.

* test(provider): require the spans SDK default, scoped to its evidence (red)

Red until its flip: SDKFeatureDefaults lists nothing for spans yet.

* feat(provider): turn the spans SDK switch on by default where it was measured

SDKFeatureDefaults lists it (scope in its configuration row and changelog);
an operator value wins everywhere, =0 (shell or LaunchAgent) restores 0.10.12.
Ships only with its hardware evidence in its CONFLICTS.md row.

* test(provider): require the grammar SDK default, scoped to its evidence (red)

Red until its flip: SDKFeatureDefaults lists nothing for grammar yet.

* test(provider): require the o4 SDK default, scoped to its evidence (red)

Red until its flip: SDKFeatureDefaults lists nothing for o4 yet.

* feat(provider): turn the grammar SDK switch on by default where it was measured

SDKFeatureDefaults lists it (scope in its configuration row and changelog);
an operator value wins everywhere, =0 (shell or LaunchAgent) restores 0.10.12.
Ships only with its hardware evidence in its CONFLICTS.md row.

* test(provider): require the o8 SDK default, scoped to its evidence (red)

Red until its flip: SDKFeatureDefaults lists nothing for o8 yet.

* feat(provider): turn the o4 SDK switch on by default where it was measured

SDKFeatureDefaults lists it (scope in its configuration row and changelog);
an operator value wins everywhere, =0 (shell or LaunchAgent) restores 0.10.12.
Ships only with its hardware evidence in its CONFLICTS.md row.

* feat(provider): turn the o8 SDK switch on by default where it was measured

SDKFeatureDefaults lists it (scope in its configuration row and changelog);
an operator value wins everywhere, =0 (shell or LaunchAgent) restores 0.10.12.
Ships only with its hardware evidence in its CONFLICTS.md row.

* fix(provider): the delta review's findings on the continuation's allowance

The delta review of #2115 (APPROVE WITH NITS):
- Low: the over-commit guard read the charge's fraction (`>= 1`), so on a
  width-1 profile, whose every ordinary charge is a whole Mac, the
  continuation was refused beside the request that took its row's slot:
  #2115's own failure. The idle prefill-evidence recovery's charge is now
  marked (`Charge.exclusive`, from `requiresIdle`) and cleared when its
  prompt completes (`reduceExclusiveAllowance`, at any width); only that
  keeps a continuation out.
- The budget's `usedFraction` is capped like `snapshot`'s (only tests read
  it; the wire value comes from `snapshot`, `ProviderLoop+Capacity.swift`).
- `shutdown()` awaits every live pump task (`EngineV2Bridge+Lifecycle`), so
  the test's release check is deterministic as written.
- #2115's changelog text moves into its own fragment
  (`loop-guard-exit-thinking-allowance.md`): #2100's fragment goes back to
  its own text, so this PR merges cleanly onto a candidate whose Prepare has
  rendered and deleted #2100's.

Local: 80/80 (red dd92fa8e12: exactly the new width-1 test failed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(changelog): keep #2100's fragment as phase C rendered it

Phase C folded #2100 at `2e241534b5`, and its Prepare rendered and deleted
that commit's fragment. #2100's later fragment edit (the engine evicts an
ordinary running request before a continuation) and this PR's text now
live in this PR's own fragment (`loop-guard-exit-thinking-allowance.md`),
so it merges cleanly onto the prepared candidate as well as in a re-fold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(provider): any list keeps Qwen's exit to proven builds; strict-tool rows keep their length (red)

The fresh-context review of #2125 (REQUEST CHANGES):
- M1: the per-build default applied only when the list equalled the
  default set. The docs' own `…,nemotron_h_omni` recipe (the default list
  plus Super) then turned Qwen's exit on for Qwen 3.6 and both Qwen 3.8 27B
  builds, which the A/B does not cover. The serving test now serves that
  list: the 35B answers, Qwen 3.6 and Qwen 3.8 27B keep `length`; a list
  that names a build by a part of its id (`Qwen3.6`, `qwen3.8-27b`) turns
  it on. The Qwen 3.6 tests name their build (`qwenOn`).
- L1: a row the strict-tool grammar constrains (the 35B takes it by
  default) carried the exit, and the continuation is submitted without the
  grammar, so its call could miss the schema. The guard policy test: such
  a row keeps its guard but not the exit.

Red (local, 87 tests): exactly these two tests fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(cluster): show the other Mac's pairing posture as reported, not verified

`ClusterPairingProvider.verifyAttestation` checks that the other Mac's
attestation is signed by the identity key it pairs with, binds this
ceremony's ephemeral key and is fresh. The signing key comes from the same
blob, so this proves possession of the key, not that a Secure Enclave holds
it: a software P-256 key passes with any claimed posture. The posture gates
nothing (it is shown, persisted and never read back), but
`darkbloom cluster pair` stated the other Mac's SIP, Secure Boot and
sealed-volume status and a "Secure Enclave key pin" as facts.

- Add `ClusterPairingTerminal.reportedPosture`, used by the pairing screen
  and the onboarding pairing event, which marks the posture "reported by the
  other Mac, not verified", and call the other Mac's pin a key pin. This
  Mac's own line still names its Secure Enclave key, which it knows.
- Say what is and is not verified in `ClusterPairingProvider`,
  `ClusterPairingPeerPosture` and the encryption architecture doc.

Binding the key to Apple hardware (for example App Attest over the ceremony
transcript) is a separate feature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(cluster): stop calling the other Mac's paired key a Secure Enclave key

Refactor-pass follow-up. The "Paired" summary, the setup wizard and the
ceremony's proof-failure message still described the other Mac's key as a
Secure Enclave key, which pairing cannot know. They now say the key it pairs
with (or proved it holds); this Mac's statements about its own key are
unchanged. Docs and the changelog describe only what is shown: onboarding
drops the peer lines and shows the code alone, so only `cluster pair` and
the setup wizard show the reported posture. `verifyAttestation`'s doc says
`secureEnclaveAvailable` is the other Mac's own claim.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(provider): exact builds, grammar rides on spans, trusted markers, deadline gate (red)

review prov-2109-d4 (APPROVE WITH NITS), tests first, failing by assertion
against today's behaviour (API reshaped, behaviour kept):
- SF1: a per-build default reaches only the exact model id it was measured
  on (no 8-bit / fine-tune / local-path substring matches);
- SF2: grammar MTP's default applies only where constraint spans are on
  (the measured combination);
- SF3: the deadline-profile gate accepts the release's own injected
  defaults and the marker, still refusing operator values;
- NIT 5/6: a marker is trusted only for keys the provider injects, and the
  marker alone identifies an injected value;
- NIT 7: an operator value in the process environment wins over a slot
  environment that lacks it.

* fix(provider): Qwen's exit keeps to proven builds under any list; strict-tool rows keep their length

The fresh-context review of #2125 (REQUEST CHANGES):
- M1: the build table (`provenBuilds`, was `defaultBuilds`) applies in
  every list, not only when a list equals the default set. Another build
  of a Qwen family takes the exit only when the list names it by a
  case-insensitive part of its id (`qwen3.6`, `qwen3.8-27b`), as
  `QwenStrictToolGrammar`'s lists do (`keepsLength`, was
  `keepsLengthByDefault`). The docs' `…,nemotron_h_omni` recipe therefore
  never turns Qwen's exit on for an unproven build.
- L1: a row the strict-tool grammar constrains keeps its guard but not the
  exit (`GenerationLoopGuardPolicy.resolve`): the continuation is submitted
  without the grammar, so its call could miss the schema.
- N1: the guard-only serving suite pins `exitThinkingSetting = .off`, so a
  runner's DARKBLOOM_LOOP_EXIT_THINKING cannot change it.
- N3/N4: the list test checks content, errors and the guard's telemetry;
  the changelog names every other build and the strict-tool rows.
- L2: the media path's gate stays, unreachable by Qwen today (its media
  prompts carry M-RoPE positions, so no exit resolves there); it keeps the
  rule true if that changes.

Local: 87/87 (red 5eccf91bf9: exactly the two new tests failed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(provider): exact builds, grammar with spans, trusted markers, deadline gate

review prov-2109-d4 (APPROVE WITH NITS):
- SF1: per-build defaults match exact model ids (lowercased), never another
  quantization, a fine-tune or a local path;
- SF2: grammar MTP's default applies only where constraint spans are on,
  the combination that was measured;
- SF3: DeadlineRuntimeEnvironment accepts the marker and the release's own
  injected defaults (profiles are pinned to the provider version), still
  refusing operator values;
- NIT 5/6: the marker is trusted only for injectable keys, and identifies an
  injected value on its own (isInjected), so NativeReasoningBudget and the
  deadline gate agree in any process;
- NIT 7: a switch counts as unset only if unset in the slot's environment
  and in the process's (what the SDK read);
- NIT 4/10: docs no longer call the switches opt-ins where a flip would
  make that wrong; changelog fragments for the mechanism and for
  grammar-aware MTP (opt-in until its flip).

* docs(provider): the second delta review's nits on the continuation's allowance

The fresh-context delta review of #2115 (APPROVE WITH NITS):
- A comment at the over-commit guard: at width 1 a continuation shares the
  Mac with a whole-Mac charge, so that charge's sole-occupancy measurements
  rely on their overlap tracking from then on (the join invalidates the
  evidence guards).
- The changelog fragment: a heading that covers both bullets (the
  allowance; #2100's priority in the engine's eviction order, which phase
  C's rendered entry lacks), the switch as its own bullet, and no internal
  machine name.

No code change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(provider): require the spans SDK default, scoped to its evidence (red)

Red until its flip: SDKFeatureDefaults lists nothing for spans yet.

* test(provider): require the grammar SDK default, scoped to its evidence (red)

Red until its flip: SDKFeatureDefaults lists nothing for grammar yet.

* feat(provider): turn the spans SDK switch on by default where it was measured

SDKFeatureDefaults lists it (scope in its configuration row and changelog);
an operator value wins everywhere, =0 (shell or LaunchAgent) restores 0.10.12.
Ships only with its hardware evidence in its CONFLICTS.md row.

* feat(provider): turn the grammar SDK switch on by default where it was measured

SDKFeatureDefaults lists it (scope in its configuration row and changelog);
an operator value wins everywhere, =0 (shell or LaunchAgent) restores 0.10.12.
Ships only with its hardware evidence in its CONFLICTS.md row.

* test(provider): require the o4 SDK default, scoped to its evidence (red)

Red until its flip: SDKFeatureDefaults lists nothing for o4 yet.

* test(provider): require the o8 SDK default, scoped to its evidence (red)

Red until its flip: SDKFeatureDefaults lists nothing for o8 yet.

* feat(provider): turn the o4 SDK switch on by default where it was measured

SDKFeatureDefaults lists it (scope in its configuration row and changelog);
an operator value wins everywhere, =0 (shell or LaunchAgent) restores 0.10.12.
Ships only with its hardware evidence in its CONFLICTS.md row.

* feat(provider): turn the o8 SDK switch on by default where it was measured

SDKFeatureDefaults lists it (scope in its configuration row and changelog);
an operator value wins everywhere, =0 (shell or LaunchAgent) restores 0.10.12.
Ships only with its hardware evidence in its CONFLICTS.md row.

* test(provider): Super concurrent images' kill switch is forwarded and parsed like the others

Delta review nit (review-2094-on.md): no test asserted the key on LaunchAgent.inferencePassthroughEnvKeys; the off words and empty values are now checked beside GPTOSSForcedToolConstraint.isEnabled's. Test only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(provider): name GPTOSSForcedToolCalls correctly in the kill-switch test

19893d8135 referred to the type as GPTOSSForcedToolConstraint (its file's name); the enum is GPTOSSForcedToolCalls. Test only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(provider): check /apply-template tool-call arguments and test the NUL rule itself

Review follow-up. /apply-template renders its messages' tool calls, decoding each one's arguments, so its body is now decoded and its arguments checked like the chat path. The UTF-16/32 test now holds an escaped quote, so only the NUL rule (not the depth count) can refuse it, and it no longer decodes a body the scan let through. Router comments and the direct-mode doc match what is checked where.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(provider): list entries shaped like a model_type name no Qwen build (red)

The delta review of #2125 (APPROVE WITH NITS), L1: any list entry that is
not a marker family counts as an id part, so `qwen3` (a real model_type),
`qwen`, `mtp` or `4bit`, each part of most catalog ids, would turn Qwen's
exit on for Qwen 3.6 and both Qwen 3.8 27B builds. The policy test: such
entries name no build. Also pinned: a named build without its family stays
off (N1); the default serving test serves the 9B MTP build too (N3); the
wording of `qwenOn`, the docs' "named" Qwen 3.6/3.8 and "its family listed
too" (N1, N4).

Red (local, 88 tests): exactly the policy test fails, at the generic list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(provider): only an id-shaped list entry names a Qwen build

The delta review of #2125 (APPROVE WITH NITS), L1: `keepsLength` counts a
list entry as an id part only when it is shaped like an id (a `.`, `-` or
`/`), never like a `model_type`, so `qwen3`, `mtp` or `4bit` name no build.
The doc comment also says the family must be listed too (N1).

Not changed (N2): the scheduler still opens the splice from its local exit
on a strict-tool row; the guard carries no exit there, so the held `length`
is delivered, as for a loop in the answer (the review verified it).

Local: 88/88 (red 0be4ccd4a9: exactly the policy test failed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(provider): the start line's grammar scope, plist skips marked defaults (red)

review prov-2109-d5 NITs 1, 4, 5 (APPROVE WITH NITS, no must/should-fix):
the start line qualifies grammar MTP's default (it rides on constraint
spans); LaunchAgent.passthroughEnvironment knows a marked value is the
release's even before the process records it; the grammar-with-spans tests
build their configs explicitly (hermetic against a lane's environment).
summary gains an internal overload taking the lists (public default
arguments may reference public declarations only).

* fix(provider): qualify the grammar default on the start line; plist skips marked values

review prov-2109-d5 NITs 1 and 4: the start/benchmark line says grammar
MTP's default applies where constraint spans are on; the LaunchAgent's
passthrough treats a marked value as the release's (isInjected), like
NativeReasoningBudget and the deadline gate.

* test(provider): require the spans SDK default, scoped to its evidence (red)

Red until its flip: SDKFeatureDefaults lists nothing for spans yet.

* feat(provider): turn the spans SDK switch on by default where it was measured

SDKFeatureDefaults lists it (scope in its configuration row and changelog);
an operator value wins everywhere, =0 (shell or LaunchAgent) restores 0.10.12.
Ships only with its hardware evidence in its CONFLICTS.md row.

* test(provider): require the grammar SDK default, scoped to its evidence (red)

Red until its flip: SDKFeatureDefaults lists nothing for grammar yet.

* test(provider): require the o4 SDK default, scoped to its evidence (red)

Red until its flip: SDKFeatureDefaults lists nothing for o4 yet.

* feat(provider): turn the grammar SDK switch on by default where it was measured

SDKFeatureDefaults lists it (scope in its configuration row and changelog);
an operator value wins everywhere, =0 (shell or LaunchAgent) restores 0.10.12.
Ships only with its hardware evidence in its CONFLICTS.md row.

* feat(provider): turn the o4 SDK switch on by default where it was measured

SDKFeatureDefaults lists it (scope in its configuration row and changelog);
an operator value wins everywhere, =0 (shell or LaunchAgent) restores 0.10.12.
Ships only with its hardware evidence in its CONFLICTS.md row.

* test(provider): require the o8 SDK default, scoped to its evidence (red)

Red until its flip: SDKFeatureDefaults lists nothing for o8 yet.

* feat(provider): turn the o8 SDK switch on by default where it was measured

SDKFeatureDefaults lists it (scope in its configuration row and changelog);
an operator value wins everywhere, =0 (shell or LaunchAgent) restores 0.10.12.
Ships only with its hardware evidence in its CONFLICTS.md row.

* test(provider): the delta review's nits on naming a Qwen build

The second delta review of #2125 (APPROVE WITH NITS):
- N2: an id part with only `-` (`35b-a3b-vl`) and one with only `/`
  (`EigenLabs/`) each name their build; the generic list (`qwen3`, `qwen`,
  `mtp`, `4bit`) also leaves Qwen 3.6 at `length`.
- N1/N3: the doc comment and the docs say that a punctuated part such as
  `-4bit` names every build that contains it, and how this differs from
  `QwenStrictToolGrammar`'s lists (which take any part).

No behaviour change. Local: 88/88. (Pushed with the A/B's verdict.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(provider): pin mlx-swift-lm to SDK main f41a5f9a (#416, #417, #418); GLM JSON grammar delta-review nits

The gitlink moves from #417's branch commit 5b66768a to SDK main's merge
commit f41a5f9a (#416 -> #417 -> #418). Since 5b66768a, GLM's path changed
only in comments (CBv2NativeShutdownOutcome, EngineLoopV2) and tests; the
rest is #418's Gemma reopened-thought parsing and #414's CI routing.

From the delta review (APPROVE WITH NITS): the GLM serving test runs with
recordsWithheldOutput as production does, pins the cut policy and asserts
the length finish and a single withheld content delta; the test guide's
command selects the GLM suites; the docs say GLM's two-row drafting limit
is the default rectangular profile's (one row on the serial profile), cite
EngineLoopV2 for the no-chaining rule, and read better.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(provider): pin the SDK to mlx-swift-lm main f41a5f9af3 (#416 + #417 + #418)

The final phase-D SDK pin F: SDK main after the owner merged #416 (the
cumulative SDK this branch pinned at eaed116569, plus main's #414 CI map),
#417 (STRUCTURED: GLM native token constraints) and #418 (AUDIO-407's #407
Gemma reopened-thought conformance), each as a signed merge commit on green.
F's tree equals #418's head tree. eaed116569 and the candidate's pin
859f641529 are both ancestors of F.

SDK library changes since eaed116569 touch only native-tracked engines
(GLM constraint admission; constrained chaining stays off there), Gemma's
reasoning parser behind DARKBLOOM_GEMMA_REOPENED_THOUGHTS (default off) and
a visibility-only GemmaToolFrameScanner change: none of the paths this
branch's switches use (Qwen MTP spans / grammar on untracked engines, the
Gemma argument parser, Super / MiMo reasoning budgets).

* Re-pin the SDK to F: mlx-swift-lm main f41a5f9af3 (#418's merge)

F = SDK main after #416, #417 and #418 (signed merge commits); its tree
2449971832 equals the previous pin 16aebe836a's, so the SDK content is
unchanged. Gitlink only.

* test(provider): require the O5 SDK default in #2109's new shape (red)

Red until SDKFeatureDefaults lists DARKBLOOM_GEMMA_REOPENED_THOUGHTS process-wide and trusts it as injectable: plan() sets it when unset, an operator's 0 stays the kill switch, an injected 1 is never written into a service plist, and an operator's 0 is forwarded.

* feat(provider): turn the O5 SDK switch on by default (kill switch: =0), in #2109's shape

SDKFeatureDefaults: DARKBLOOM_GEMMA_REOPENED_THOUGHTS is a process-wide parser switch with no per-model hook, so it joins onByDefault (its own list, gemmaReopenedThoughts) and injectableKeys (a parent's injection is trusted, never persisted). =0 (darkbloom start re-installs the plist; foreground =0) restores 0.10.12. The #2116 forwarding test now passes injected: [] explicitly. Docs (review of #2127): the configuration default, the service-Mac rollback, the four ordinary-output deltas of the shared state machine (inference.md, changelog), no opt-in wording left. Ships only with its Gemma GPU evidence in #2116's CONFLICTS.md row.

* test(provider): require MiMo reasoning budgets on by default too (red)

Pre-staged: folds only if MiMo is measured in its ON state on Mac B
(budgets 16/128/512 + controls + a pair, off vs on), instead of #2121.

* feat(provider): admit MiMo reasoning budgets by default as well

reasoningBudgetFamilies = [.nemotronSuper, .mimoV26]; docs row and changelog.
Folds only with MiMo's ON-state evidence (instead of #2121).

* Undo "Prepare provider 0.10.13" to fold 2040@03826b100a 2042@09ba436cdc 2047@b55ae64d6a 2051@98a9cded8c 2050@f10799abc1 2048@a849c562bf 2049@15f7d676e9 2052@0d2ec9ebfc 2053@42d9add895 2054@854c1ad495 2046@b4cc61883c 2057@220be61dd4 2058@4c5d7d9823 2063@1815e0773e 2065@585133d832 2045@8d7a6b51bd 2072@1542c6357e 2060@5a94d61d60 2061@1a8734918c 2070@dfb14ce00d 2069@5b4d5bc087 2071@3ce6f5cfdb 2075@b6c797c324 2084@7af346143c 2096@7e9378ad65 2088@001996379f 2100@2e241534b5 2098@d76366162a 2115@69c44ecbfa 2101@acd07059b9 2091@485b0ca973 2092@8bb36c450a 2093@191a07c790 2094@e79d22259c 2089@be1148a798 (it is redone on top)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Fold fixes for provider 0.10.13

- changelog.d/native-reasoning-budget.md: topic heading
- changelog.d/qwen-forced-tool-thinking.md: topic heading
- changelog.d/gptoss-commentary-content.md: topic heading
- changelog.d/qwen-stray-think-close.md: topic heading

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Prepare provider 0.10.13

Version 0.10.13; the 39 changelog.d fragments rendered into CHANGELOG.md
(scripts/changelog.py render --version 0.10.13 --date 2026-11-14, verbatim, in
filename order) under the candidate heading, with the upgrade and rollout
notes; v0.10.12 marked published (2026-11-12); the 0.10.13 section of
docs/operations/provider-release.md. Base: master 1b02e28542 (the 0.10.13 release branch's squash).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(provider): bound coordinator requests waiting for admission

`CoordinatorClient` decodes each `inference_request`'s ciphertext and yields
it into an unbounded event stream; the connection reader forwards it into an
unbounded work stream, where it waits for the work FIFO. The coordinator
keeps at most a provider's width pending, but while admission is stalled
behind a serial model load, requests that expire or are cancelled and
retried keep arriving and stay buffered, each up to a 16 MiB body.

The connection reader now charges each request's ciphertext against a
budget (64 requests, 512 MiB) when it reads it (`queueCoordinatorAdmission`),
and the admission returns the charge (`admitInWorkFIFO(requestId:queuedBytes:)`).
A request past the budget is refused on arrival, never queued, as
`refuseInferenceBeforeDispatch` refuses: `queue_full` on a capacity 429, the
status the engine's own queue-full refusal uses, with its service
reservation released. The coordinator retries it elsewhere and counts it as
a capacity reject, unlike `draining`. The reader never waits for room, so
cancels, attestation challenges and trust updates keep flowing (blocking it,
as first proposed, would let the link's liveness check drop the session).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Undo "Prepare provider 0.10.13" to fold 2040@03826b100a 2042@09ba436cdc 2047@b55ae64d6a 2051@98a9cded8c 2050@f10799abc1 2048@a849c562bf 2049@15f7d676e9 2052@0d2ec9ebfc 2053@42d9add895 2054@854c1ad495 2046@b4cc61883c 2057@220be61dd4 2058@4c5d7d9823 2063@1815e0773e 2065@585133d832 2045@8d7a6b51bd 2072@1542c6357e 2060@5a94d61d60 2061@1a8734918c 2070@dfb14ce00d 2069@5b4d5bc087 2071@3ce6f5cfdb 2075@b6c797c324 2084@7af346143c 2096@7e9378ad65 2088@001996379f 2100@2e241534b5 2098@d76366162a 2115@69c44ecbfa 2101@acd07059b9 2118@42e71bb950 2119@c68d19d634 2120@097047d70c 2091@485b0ca973 2092@8bb36c450a 2093@191a07c790 2094@e87386bb2e 2089@be1148a798 (it is redone on top)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Prepare provider 0.10.13

Version 0.10.13; the 39 changelog.d fragments rendered into CHANGELOG.md
(scripts/changelog.py render --version 0.10.13 --date 2026-11-14, verbatim, in
filename order) under the candidate heading, with the upgrade and rollout
notes; v0.10.12 marked published (2026-11-12); the 0.10.13 section of
docs/operations/provider-release.md. Base: master 7e30bf50e3 (the 0.10.13 release branch's squash).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(provider): free TOMLKit's parse trees with a vendored copy (finding 271)

A paired cluster leader can make the other Mac parse its provider.toml
again with each setup it sends (ClusterConfigurationStore
.updatingProviderData), and TOMLKit 0.6.0 frees nothing it allocates:
not the C++ tree a parse builds, not the nodes it makes for Swift
values, not the malloc'ed buffers its value reads and conversions
return. Every parse anywhere in the provider stayed in memory for the
life of the process, 60-78 KB a call for a few-KB provider.toml.

0.6.0 is the latest TOMLKit release and upstream main frees nothing
either, so there is no release to move to. libs/TOMLKit now holds
TOMLKit 0.6.0 (toml++ v3.4.0, unmodified) with the smallest ownership
change, and provider-swift builds it as a local package:

- TOMLNodeOwner owns one root the bridge allocated and deletes it with
  the new nodeDelete. Every TOMLTable, TOMLArray and TOMLValue holds the
  owner of its node's tree and nested wrappers share their root's, so
  no node inside a tree is deleted on its own and a value read from a
  table outlives the table, as before.
- The bridge's malloc'ed buffers (value reads, keys, values, convert,
  debug descriptions, a parse error's description) are freed once Swift
  has copied them; the new dateTimeFree frees a date-time with its
  offset.
- TOMLDateTime hands its offset to the bridge from call-scoped storage
  instead of allocating it.

The public API and TOMLKit's parsi…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants