Skip to content

Cognition becomes a tree: six leaf crates cut out (rooms, vitals, prompt, grounding, engram, capture) - #5588

Merged
joelteply merged 13 commits into
canaryfrom
fable/cut-cognition-rooms
Oct 29, 2026
Merged

joelteply merged 13 commits into
canaryfrom
fable/cut-cognition-rooms

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Joel, 2026-10-29: "the cognition is divisible further. Crates are better as trees"; "a crate line is like a ratchet".

Plan: docs/architecture/COGNITION-CRATE-TREE.md. continuum-cognition (95,596 lines) holds one 26-module cycle (~55.5k lines); the other ~40k lines are acyclic. This PR cuts the first six acyclic leaves, one commit per crate, as pure moves; cognition re-exports each moved module under its old path (pub use continuum_X::m), so no caller outside changes.

crate concern lines tests
continuum-rooms card holders, handoff, room directory/roster, mind room, presence glyphs, room ledger 2,220 25
continuum-vitals health/turn ledgers, turn ingress, grid allocation, activity gate, directed pending, mind events 3,683 37
continuum-prompt prompt assembly and its budgets 4,540 65
continuum-grounding rag budget, cached source, grounding invalidation 2,107 21
continuum-engram engrams, recall metadata/ranking, focus, trace, redaction 4,456 103
continuum-capture the capture of a mind's turns 1,831 18

Crates: +6. continuum-cognition: -18,837 lines.

What the crate lines surfaced (each declared, not hidden):

  • Paths that reached other crates through cognition's glob re-export (pub use continuum_live::* -> engine -> kernel) are explicit: continuum_kernel::{orm, runtime, sdk_codegen, paths}, continuum_engine::{ai, inference, model_registry}, continuum_experience::experience.
  • Seams made pub: BoundedRoomLedger::{entry_or, take}, JsonlPromptCaptureSink::{open_for_persona, with_session}, prompt_capture::legacy_projection, prompt_prefix::{stage_reuse, settle_reuse, observe}, PersonaActUpdate.state.
  • Test-only helpers behind each crate's test-fixtures feature (directed_pending::clear, BoundedRoomLedger::get), enabled only in dev-dependencies.
  • Two hand-built ~/.continuum paths in room_directory now ask the one owner, continuum_kernel::paths::continuum_home() (honours $CONTINUUM_HOME and test homes).
  • rooms and capture take core's build script, the one owner of CONTINUUM_BUILD_GIT_SHA.

Local receipt (M5, tree 20f447d, serving down): continuum-rooms 25/0, vitals 37/0, prompt 65/0, grounding 21/0, engram 103/0, capture 18/0, continuum-cognition 929/0, continuum-mind 1,175/0, source-hygiene 68/0, continuum-core lib + tests build OK. Test count unchanged: canary b5a1527 CI ran cognition 1,198 = 929 + 269 moved; mind 1,171 with 4 filtered (1,175 locally unfiltered).

Next (the tree's order): the remaining acyclic leaves (conversation, tools, admission, response-verbs), then the cycle's back-edges per the doc (ParkListener, ActingCustody, the act vocabulary split), then the faculty crates. Then phase 5 on these crates: repeated shapes move down (home paths, bounded maps, JSON state files).

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

joelteply and others added 10 commits October 29, 2026 08:09
…TION-CRATE-TREE step 2)

Joel, 2026-10-29: "the cognition is divisible further. Crates are better as trees."

A pure move of nine modules (2,220 lines): card_holder, card_facts, handoff,
room_directory, room_substrates, room_roster, mind_room, presence_glyph,
bounded_room_ledger. Cognition re-exports each under its old path (pub use
continuum_rooms::X), so no caller changes. Paths that reached through the glob are
explicit: continuum_experience::experience::ledger, continuum_kernel::runtime::runtime,
continuum_kernel::sdk_codegen. docs/architecture/COGNITION-CRATE-TREE.md is the plan: the
one 26-module cycle, the back-edges and how each breaks, 18 child crates, the cut order.

Crates: +1. continuum-cognition: -2,220 lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…GNITION-CRATE-TREE step 3)

A pure move of nine modules (3,683 lines incl. grid_allocation/tests.rs): health_ledger,
turn_ledger, turn_ingress, grid_allocation, vitals_pulse, activity_gate, directed_pending,
mind_events, pass_intent. Cognition re-exports each under its old path
(pub use continuum_vitals::X), so no caller changes.

Paths that reached through the glob are explicit: crate::inference -> continuum_engine::inference,
crate::runtime -> continuum_kernel::runtime, crate::experience -> continuum_experience::experience;
crate::cognition::turn_ledger/turn_ingress -> crate::turn_ledger/turn_ingress (both moved).
One visibility change the cut forces: PersonaActUpdate.state pub(crate) -> pub, because
cognition's act_observe/apply.rs constructs it.

Crates: +1. continuum-cognition: -3,683 lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…um-cognition (COGNITION-CRATE-TREE step 4)

A pure move of eight modules (4,540 lines incl. prompt_assembly/tests.rs): prompt_assembly,
framing_echo, not_speech, response_validator, token_budget, prompt_prefix, audience,
context_budget. Cognition re-exports each under its old path (pub use continuum_prompt::X).
Paths that reached through the glob are explicit: continuum_engine::{ai, inference,
model_registry}. Intra-set paths crate::cognition::X become crate::X. prompt_prefix's
stage_reuse, settle_reuse and observe go pub(crate) -> pub (cognition's request.rs calls them
across the new crate boundary); its mod re-export is pub use.

Crates: +1. continuum-cognition: -4,540 lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ut out of continuum-cognition (COGNITION-CRATE-TREE step 6)

A pure move of three modules (2,107 lines): rag_budget (74 + flex_allocate 325 +
substrate_context 687 + tests 404), cached_source (256), grounding_invalidation (361).
Cognition re-exports each under its old path (pub use continuum_grounding::X).
Path rewrites: crate::cognition::{rag_budget,cached_source} -> crate::{...};
crate::runtime::{command_events,message_bus} -> continuum_kernel::runtime::{...}.

Crates: +1. continuum-cognition: -2,107 lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…nition (COGNITION-CRATE-TREE step 7)

A pure move of nine modules (4,456 lines incl. recall_metadata/tests.rs): engram, engram_graph,
recall_metadata, recall_ranker, focus, focus_policy, trace, redaction, home. Cognition re-exports
each under its old path (pub use continuum_engram::X), so no caller changes. Paths that reached
through the glob are explicit: crate::orm -> continuum_kernel::orm, crate::ai::embedding ->
continuum_engine::ai::embedding; crate::cognition::{engram,focus} -> crate::{engram,focus}.

Crates: +1. continuum-cognition: -4,456 lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…m-cognition (COGNITION-CRATE-TREE step 9)

A pure move of four modules (1,831 lines): capture (13), capture_owner (46), prompt_capture
(940), prompt_capture_store (832). capture_owner and prompt_capture_store stay #[path] children of
prompt_capture, as before. Cognition re-exports capture and prompt_capture under their old paths.
Explicit paths: continuum_kernel::paths, continuum_engine::ai::types,
continuum_engine::inference::wire_tap, continuum_rooms::mind_room, crate::capture.
Visibility only: prompt_capture::owner and CaptureOwners go pub (cognition's workspace_capture
reaches them across the new crate seam).

Crates: +1. continuum-cognition: -1,831 lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… the room directory reads the one continuum home

- continuum-rooms and continuum-capture take core's build script, the one owner of
  CONTINUUM_BUILD_GIT_SHA (handoff and prompt captures stamp the build they ran on).
- room_directory read ~/.continuum by hand (dirs::home_dir, two sites): it now asks
  continuum_kernel::paths::continuum_home(), which honours \$CONTINUUM_HOME and a test's home.
- continuum-prompt depends on tracing (probe! expands to it); continuum-engram on thiserror.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ck gains the six crates

Stacking the leaf cuts kept both sides of a mod.rs conflict, so 15 modules were declared as
both pub mod and pub use; the stale pub mod lines are removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
- rooms: BoundedRoomLedger::entry_or and take are pub (rag_source_faculty uses them).
- capture: JsonlPromptCaptureSink::open_for_persona, with_session and legacy_projection are
  pub (persona_workspace, replay, request_replay and a playback test use them).
- vitals: directed_pending::clear is a test fixture behind continuum-vitals/test-fixtures,
  enabled by cognition's dev-dependencies, so no production build links it.

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

Copy link
Copy Markdown
Contributor Author

Source review at 20f447d against b5a1527: no blocking source defect found in the rename-aware extraction, compatibility re-exports, dependency declarations, shared-state placement, or visibility/test-fixture changes. The moved files have no embedded CARGO_MANIFEST_DIR/include paths needing relocation. Author-reported local counts are not independently rerun here.

Merge remains gated on CI repair: Select existing checks job 123483745295 fails its downstream-selection expectation because actual output now includes continuum-rooms, continuum-vitals and continuum-capture. Update the expected dependency closure and rerun the exact head; downstream red aggregate gates do not establish a Rust compilation failure.

The room-directory switch to continuum_home() is an intentional behavior change for CONTINUUM_HOME, beyond the mechanical move. Please keep that distinction in the description and validate persistence/loading under an explicit home. No deployment or live performance verdict is implied by this source review.

@joelteply
joelteply merged commit 48d3e59 into canary Oct 29, 2026
45 checks passed
@joelteply
joelteply deleted the fable/cut-cognition-rooms branch October 29, 2026 16:18
joelteply added a commit that referenced this pull request Oct 29, 2026
Three files #5588 moved carried this branch's edits: cached_source and grounding_invalidation
(now continuum-grounding) and context_budget (now continuum-prompt) take this branch's content
with the new crates' paths.

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 Oct 29, 2026
…e::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
joelteply added a commit that referenced this pull request Nov 3, 2026
…e::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
joelteply added a commit that referenced this pull request Nov 3, 2026
…e::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
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