Skip to content

A stream that ends without a finish reason says so (FinishReason::Unreported), never a defaulted Stop - #5638

Merged
joelteply merged 3 commits into
canaryfrom
fable/stream-end-unreported
Oct 31, 2026
Merged

joelteply merged 3 commits into
canaryfrom
fable/stream-end-unreported

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

How it serves the minds: a receipt must never claim she stopped when the stream just ended. It's how we diagnose empty completions, like Kimi's reasoning-only turns on the 5090, from evidence rather than inference.

Evidence (Codex, 5090 b5a1527, frozen in evidence/2026-10-31-kimi-0554/capture-tail.jsonl)

Cycles 816–818 (maxTokens 348) and 819 (maxTokens 12,288) were reasoning-only: no text, no tool call, finish: stop. A small grant alone doesn't explain them, and the receipt couldn't say whether the backend sent stop or the stream ended without a marker, because both adapters defaulted an absent marker to Stop.

Change

  • ai::types::FinishReason gains Unreported. The OpenAI-style stream and the Anthropic adapter set it when no marker arrived.
  • Consumers: liveness counts an empty unreported end as delivered nothing (unchanged), and the inference-llm translation names it as an error.
  • protocol/typescript/ai/FinishReason.ts gains "unreported".
  • Touched-file cleanup in stream.rs: the over-window probe lists every message size (not the top 6), and the malformed-arguments probe drops its 200-char head (the raw rides whole in the call's result).
  • Named follow-up: there are two FinishReason enums (ai/types.rs, inference/llm_module.rs), which is a duplicate owner.

Tests

cargo test -p continuum-engine --lib 1,405 passed (M5, --features metal, 06:04Z) at eda3f84. The probe-only commit after it doesn't change behaviour, and CI compiles it. Ratchets clean at the head.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

joelteply and others added 2 commits October 31, 2026 01:55
…eported), never a defaulted Stop

Codex's glass box (5090, b5a1527, Kimi cycles 816-819): reasoning-only completions with no text
and no tool call read `finish: stop`, because both adapters defaulted an absent marker to Stop, so
no receipt could tell an explicit stop from a stream that ended without one.

- ai::types::FinishReason gains `Unreported`; the OpenAI-style stream and the Anthropic adapter
  set it when no marker arrived.
- Liveness counts an empty unreported end as delivered nothing (as before); the inference-llm
  translation names it as an error.
- protocol/typescript/ai/FinishReason.ts gains "unreported".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… malformed-arguments probe names the size (the raw rides whole in the result); no head cuts

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply force-pushed the fable/stream-end-unreported branch from 9d72a1e to c754e4d Compare October 31, 2026 06:55
@joelteply

Copy link
Copy Markdown
Contributor Author

Review of #5638 at exact head c754e4d (Cormac): right change. One seam undoes it; small fix, then I approve.

Verified by reading the diff:

  • The adapters no longer default an absent marker to Stop: openai_adapter/stream.rs:537 and anthropic_adapter.rs:455 say Unreported.
  • liveness classifies an empty unreported end as DeliveredNothing.
  • The TypeScript binding is regenerated.
  • The probe's 200-char head cut and the rows' take(6) cap are gone. Both were cuts, so good.

The fix: llm_module_service.rs:481 maps Unreported to inference_llm::FinishReason::Error { reason }. That module enum is the wire type (protocol/typescript/inference_llm/FinishReason.ts) that the inference module's subscribers read. So at the one boundary a client sees, "the backend didn't say why it ended" becomes "it failed". That's the conflation this PR exists to remove (Codex's evidence was a reasoning-only completion reported as a definite end). Please add Unreported to inference_llm::FinishReason, map it through, and add a row to the translate test (llm_module_service.rs ~925), which doesn't cover the new arm today. The existing ToolUse -> Error collapse is pre-existing and not this PR's job, but worth a card if no one owns it.

Everything else I'd keep exactly as is.

@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVE #5638 at exact head 6b546ad (Cormac). Verified git diff c754e4d83 6b546ad80: inference_llm::FinishReason gains Unreported, documented as neither a stop nor an error. translate_adapter_finish_reason maps the adapter's Unreported to it instead of Error { reason }, and translate_finish_reason_covers_all_adapter_variants gains the row. protocol/typescript/inference_llm/FinishReason.ts adds { kind: 'unreported' }. Typed provenance now survives the boundary clients read. An exhaustive match on the module enum elsewhere would fail to compile, so CI at this head is the remaining gate.

@joelteply
joelteply merged commit 39fe202 into canary Oct 31, 2026
76 of 79 checks passed
@joelteply
joelteply deleted the fable/stream-end-unreported branch October 31, 2026 07:32
joelteply added a commit that referenced this pull request Oct 31, 2026
…packed, restored beside its 5 GiB download on a root disk that ran out (card 27a4a3b0) (#5650)

* CI builds on the runner's scratch disk: the shared target is 24 GB unpacked, restored beside its 5 GiB download on a root disk that ran out (card 27a4a3b0)

Warm run 41193606500 (f0f786d, 2026-10-31) leaves target at 24G after pruning 5.79 GB of test
executables. Every Linux crate job restores it, plus its 5 GiB tarball, onto / and builds its
tests on top; on 10-31 that hit "No space left on device" mid-setup or mid-build on #5638, #5649
(twice) and #5641 (job 124526077711 died inside rust-ci-setup), each costing a rerun and hiding
the real result.

rust-ci-setup now puts CARGO_TARGET_DIR on /mnt (the runner's scratch disk), refusing loudly if
/mnt is not a separate mount, and logs df for both disks. The cache's restore and save path is
/mnt/target in both the setup action and the warm workflow, so they stay one cache. Nothing else
names the target dir: the lib-test artifact script and the evidence upload read cargo's own
target_directory, and the freshness settle only skips a workspace-local `target`.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* ci-cargo-freshness: drop the workspace-local 'target' skips; the build lives on the scratch disk now (Fable on #5650)

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* rust-ci-setup: log the runner's disks and its largest preinstalled trees (diagnostic: /mnt is not a separate disk on the current ubuntu-latest image)

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* rust-ci-setup: build where the runner has room, at one path (/ci-target, bind-mounted onto /mnt on the 24.04 image when its scratch disk has more space); the 26.04 image has one 145G disk with 87G free, measured on this PR's run

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request Nov 3, 2026
…or or a stream with no finish reason fails the call, never `end_turn` / `stop`

Canary's `FinishReason::Unreported` (#5638) says a stream ended without the backend saying why; the
gateway's `stop_reason` / `finish_reason` mapped it (and `Error`) to `end_turn` / `stop`, the false
stop #5638 removed (the triage of this PR against canary, 11-03). A typed `Finish { Stop, Length,
ToolUse }` is now the only ending an encoder's `answer` / `finished` takes, built once by
`Finish::reported`; `Error` and `Unreported` take the failed path (a streamed `failed`, or 502 with
the engine's kind). Each format maps `Finish` exhaustively. Test: neither is a finish, and Stop /
Length map to each format's own word.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Nov 3, 2026
…or or a stream with no finish reason fails the call, never `end_turn` / `stop`

Canary's `FinishReason::Unreported` (#5638) says a stream ended without the backend saying why; the
gateway's `stop_reason` / `finish_reason` mapped it (and `Error`) to `end_turn` / `stop`, the false
stop #5638 removed (the triage of this PR against canary, 11-03). A typed `Finish { Stop, Length,
ToolUse }` is now the only ending an encoder's `answer` / `finished` takes, built once by
`Finish::reported`; `Error` and `Unreported` take the failed path (a streamed `failed`, or 502 with
the engine's kind). Each format maps `Finish` exhaustively. Test: neither is a finish, and Stop /
Length map to each format's own word.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Nov 3, 2026
…x, Hermes, opencode) (#5541)

* SERVING-ENGINE §1a: MindMemory, the one owner of a mind's KV memory, before any more path fixes

The 2026-10-27 inventory: 41 paths, 9 decisions made in 2-6 places each, four
gaps (idle retirement saves nobody, cache_probe pages outside the ledger, an in-place
gene change keeps stale KV restorable, a dead page-store trim). The seq_table and
pager of §1 are built first over today's llama-server: seat / pause / resume / adopt /
forget, each decision once inside, every lifecycle path a request, the guards deleted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* DRIVER-GATEWAY.md: one door every agent can call, with warm memory and learning

Plan line 16, the Serving seam of REPO-GENOME-AND-COURSES §17. One Gateway module on
a stable port; Anthropic Messages, OpenAI Chat Completions and OpenAI Responses as
adapters holding only the diff; a session is a driver mind seated through MindMemory
(warm KV, never transient, one scheduler); every exchange captured as perception under
scope rules. Slices G0-G4 with validators and live gates; G0-G1 start now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* SERVING-ENGINE §1a: the MindMemory API, with Codex's seam requirements in its types

PauseReceipt bound to the engine (generation plus verified incarnation), never
replayable; seats close before detach or save; pause returns only with no page IO in
flight (unresolved IO named and quarantined); receipts separate confirmed saves, named
losses and unresolved IO; resume refuses a Stop pause; attach verifies an adopted
engine's incarnation; snapshot for the one scheduler. Validator drives the real
retirement callers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* continuum-gateway: one door every external agent calls (DRIVER-GATEWAY G0-G1)

Anthropic Messages (Claude Code), OpenAI Chat Completions (Hermes, opencode) and
OpenAI Responses (Grok Build, Codex CLI) as adapters holding only their diff over the
engine's one request and stream; real SSE streaming; tools pass through both ways;
GET /v1/models; a stable port (CONTINUUM_GATEWAY_PORT, default 8976); gateway/status
and gateway/env. Replaces continuum-core/src/http's Anthropic-only endpoint, which
dropped every tool and faked streaming (758 lines deleted with its commands).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* continuum-gateway: tracing for its probes; the test imports ToolChoice

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* continuum-gateway: one rule for where system text goes, for every format

Claude Code sends a system message after the user's turn (its hook and environment
context), Codex sends developer items, Hermes mid-run notices; the engine's templates
take one system message, first ('System message must be at the beginning', the M5,
2026-10-27 22:48Z). place_system: leading system/developer text joins the system prompt,
a later one stays in order as a user turn marked as system text. Replaces the two
copies chat and responses each had.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* DRIVER-GATEWAY: one glass box for every system (G1.5, before G2)

Joel: replay and glass boxing should be straightforward regardless of system. The capture
owner moves below cognition, keyed by mind; the deliberation faculty and the gateway both
write schema-v4 submitted/completed records, so the act inspector, replay and playback
work on Claude Code, Codex, Grok Build, Hermes or opencode unchanged, and a captured agent
session becomes a dyno validator for our engine.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* DRIVER-GATEWAY: learning and the genome ride the same capture seam (layering table)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* DRIVER-GATEWAY G-lean: a Serving-only continuum-serve binary for drivers, learning opt-in

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* Plan lines 3b and 16: MindMemory first, the driver gateway live; continuum-gateway a declared workspace member

3b: MindMemory (SERVING-ENGINE §1a) comes before the fork verbs, Codex owning the
lifecycle callers. 16: the gateway is live on the M5 (four agents fixed a real bug through
it); next G1.5 one capture for every system, then G2 warm sessions; a lean
continuum-serve install. Root Cargo.toml and Cargo.lock now carry the gateway crate the
earlier commits added under core/.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* DRIVER-GATEWAY G5: org genomes, a repo's gene learned from every member's sessions and worn by all

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* A driver session is a mind: warm, paged and recorded in the one capture (G2-lite)

- `driver` is a Turn in the engine's one purpose->class map (DRIVER_PURPOSE), and the
  gateway sends the session id as the request's mind: a session gets a leased, pinned
  slot, a confirmed save on eviction and a restore on return, as a resident does.
- The session id is the conversation's stable head (system prompt + first user turn),
  until MindMemory seats sessions explicitly; `x-continuum-session: off` opts out.
- Every call is recorded through continuum-capture, keyed by session, so the act
  inspector and replay read an agent's session as they read a resident's acts.
- Usage reports reuse in each format's own field: prompt_tokens_details.cached_tokens
  (Chat), cache_read_input_tokens (Anthropic), input_tokens_details.cached_tokens
  (Responses).

Tested: continuum-gateway 4 passed (incl. one session per agent session, another task
another session); continuum-engine slots 43 passed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* The MTP draft runs only while a turn decodes alone (adaptive speculation)

Measured on the M5 2026-10-28 02:21Z, our llama-server alone, Qwen3.6-35B-A3B: one stream
80 t/s with the draft vs 57 without; two streams 84 vs 89 aggregate; four 91 vs 122. Stock
llama.cpp batches like our server without a draft (llama-batched-bench 59/90/124), so
nothing serializes: the draft's extra verify tokens make a bigger MoE batch read more
experts. The adapter sets speculative.n_max = 0 per request when other turns hold the
engine (permit_target - available - 1), inside the block that only runs against our own
engine; alone, the engine's draft stays. Policy and receipts in inference::speculation.

Tested: continuum-engine speculation/openai_adapter/request_body 46 passed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* SERVING-ENGINE §1b: what concurrent minds cost on the M5, measured by layer (decode, draft, page IO, memory)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* The gateway's wire reads the clock through EpochMs and missing fields through serde's index, and the selector test knows the gateway's crates

Source hygiene: the two private now_s() clocks become EpochMs::now().secs() (the same
pre-1970 policy); get(k).unwrap_or(&Value::Null) becomes &v[k], which is Null for a
missing key by definition; wire/tests.rs is marked #![cfg(test)] and owns its Frame::json
helper, so test expects stop counting as production (unwraps 1936 -> 1942 becomes a net fall).
Selector: an engine change now also runs continuum-gateway and continuum-capture, which
build on the engine.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* The gateway's session memory is opt-in until MindMemory seats driver minds: on by default it queued drivers behind resident pins (61 s vs 18 s a step)

Cormac's change request on #5541 at 6f102b6, on Fable's own measurement (card e3ce65f9).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* SERVING-ENGINE §1c: the engine is fed by queues and signals, never held by permits

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* SERVING-ENGINE §1c: GCD-style classes, every task completes, background is throttled never starved

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* The gateway records into canary's one capture crate (continuum_capture::prompt_capture)

#5541 had cut its own continuum-capture on 10-28; #5588 cut the same modules into canary's. This
branch replays #5541 onto canary without its duplicate cut (fbbb222); the gateway's one import
moves to canary's path, and its manifest names the crate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* The gateway's streamed answer owns its generation: an agent that leaves cancels it, a slow one holds it, an unopened capture refuses the call (Codex on #5541 at 34672ec)

- answer.rs: the SSE body polls the generation itself, with no spawned task and no gateway
  queue. The agent leaving drops the body, which drops the generation future: the engine's
  one cancellation path (the adapter future's TurnAdmission releases its slot pin and permit
  on Drop; llama-server answers the closed connection with `srv stop: cancel task`), and the
  capture lease inside it records the call cancelled at that moment, never while the engine
  still runs.
- Backpressure: the generation is polled only once the agent has taken every encoded frame,
  so what waits is one poll's chunks (one read of the engine's SSE connection, one token per
  event) plus one chunk's frames. The engine's sink stays its contract's unbounded sender,
  drained before every poll; the unbounded event channel is gone.
- session::record refuses the call (503, `capture_unavailable` in each format's error
  shape) when its capture cannot be opened, instead of serving it unrecorded.

Tests (gateway): disconnect before the first chunk and midstream each free the generation's
slot permit; a stalled agent holds generation within one chunk; a finished answer sends its
last chunks before its close; an unopened capture refuses the call. Not compiled here
(serving node): to be run in the test window.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* The CI selector fixture: an experience change also selects the gateway (it rides capture, which rides rooms)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* The gateway owns its listener, refuses what it cannot read, and bounds a slow agent at the engine's producer (Codex on 856ee2b)

Listener lifecycle (continuum-gateway listener.rs, module.rs): the module holds the
serve task's JoinHandle with a graceful-shutdown signal in its own state. A bind
failure fails initialization. Status reads the live task, so it reads false once the
listener exits. drain closes admission and waits for the calls in flight; shutdown
abandons what is still in flight (each agent is told the node is stopping; the
generation is dropped, the engine's cancellation path) and joins the task. A dropped
listener aborts its task, and a reinitialize after a stop binds the same port.

Checked decoders (wire/decode.rs): every format's tools, token limits, sampling,
stream flag and tool_choice go through shared decoders. A malformed or unserved tool
entry, a token limit outside 1..=u32::MAX, a non-string stop member, or an
out-of-range temperature/top_p refuses the call before selection or generation. The
per-format adapters keep only the real differences: tool shapes, field names and the
temperature ceiling.

Backpressure (continuum-engine ai/stream_sinks.rs deliver): every producer on the
local serving path (sse_stream, the trait's default generate_stream) yields after each
chunk it sends, so one poll of a generation sends at most one chunk. A ready burst of
64 events in one network read, through the real consume_sse_stream, never leaves
more than one chunk waiting. The gateway's Answer tests now drive a ready-burst
producer through deliver.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* A gateway stop cuts every connection, so an agent that stops reading cannot hold its generation past it (Codex on f2a3600)

An agent that stays connected but stops reading fills its socket, hyper stops polling
the response body, and the abandon signal the body would read is never read. Its
generation (the engine's TurnAdmission, the capture lease) and its connection task
then outlived the stop.

Every accepted socket is now wrapped in a Severable connection (continuum-gateway
sever.rs) that polls the listener's abandon signal on every read and write. Shutdown
raises the signal, so a stalled connection's task is woken and its writes fail. Hyper
ends the connection and drops the body, with the generation inside it. axum's
graceful serve returns only after every connection task has ended, so the listener's
exit means no connection, body or lease survived. The generation stays owned by the
body; no producer is detached.

Regression over real HTTP (module.rs): a long streamed answer through the real Answer
and SSE response; a client that sends its request and never reads until both sockets
are full; then drain and shutdown, each under the runtime's SHUTDOWN_PHASE. Drain runs
to its bound. Shutdown completes within it with the admission released, the capture
stand-in settled and no live task left. The disconnect and ready-burst tests are kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* The gateway's stop signal and words move to a bottom module, breaking the four-module cycle; the burst test counts events

modules_in_cycles rose 26 -> 30 at 0a93607. The gateway's production graph had one
strongly connected component {answer, server, listener, sever}:
  answer -> server -> answer                 (answer read server::STOPPING)
  listener -> sever -> listener              (sever read listener::Signal)
  server -> listener -> sever -> server      (server read Signal, sever read STOPPING)
Signal and STOPPING are what the module says to everything it stops. They now live in
stop.rs, which depends on no crate module. answer, sever, listener and server import
them from there, and the graph is acyclic: answer -> {route, stop, wire},
sever -> {stop}, listener -> {sever, stop}, server -> {answer, route, session, stop,
wire}, module -> {listener, route, server, stop}.

The source guard read the burst test's `TOKENS = 64` as a context-size constant. It
counts SSE events in the burst, so it is now BURST_EVENTS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* The gateway presents only a finish the engine reported: an engine error or a stream with no finish reason fails the call, never `end_turn` / `stop`

Canary's `FinishReason::Unreported` (#5638) says a stream ended without the backend saying why; the
gateway's `stop_reason` / `finish_reason` mapped it (and `Error`) to `end_turn` / `stop`, the false
stop #5638 removed (the triage of this PR against canary, 11-03). A typed `Finish { Stop, Length,
ToolUse }` is now the only ending an encoder's `answer` / `finished` takes, built once by
`Finish::reported`; `Error` and `Unreported` take the failed path (a streamed `failed`, or 502 with
the engine's kind). Each format maps `Finish` exhaustively. Test: neither is a finish, and Stop /
Length map to each format's own word.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* Cargo.lock: continuum-gateway depends on continuum-capture (the lock the rebase left unstaged)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* Driver gateway meets the ratchets: required request fields decoded by type, no re-imposed temperature ceilings, DRIVER_PURPOSE beside the one purpose->class map

- decode::fields deserializes each wire's Required struct (model, messages, max_tokens as
  NonZeroU32, Responses' input as Text | Items): a missing field fails in serde, never a
  hand-written presence check (required_input_complaints 82 -> 76, its base).
- temperature: any non-negative value the engine's f32 sampler holds; the engine owns what it can
  sample, so ANTHROPIC/OPENAI_TEMPERATURE_MAX are gone (self_sized in touched files -> 0).
- DRIVER_PURPOSE moves from request_body.rs (left untouched with its reasoning budgets) into
  citizen_slots.rs beside the map that classifies it; one clippy nonminimal_bool fixed there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant