Skip to content

MindMemory design + the driver gateway (G0-G1 live: Claude Code, Codex, Hermes, opencode) - #5541

Merged
joelteply merged 27 commits into
canaryfrom
fable/mind-memory-owner
Nov 3, 2026
Merged

joelteply merged 27 commits into
canaryfrom
fable/mind-memory-owner

Conversation

@joelteply

@joelteply joelteply commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Plan line 3b. A design for review before any code moves (Joel, 2026-10-27: "you can't get anything to work unless there is one daemon and centralized location").

Adds §1a to docs/architecture/SERVING-ENGINE.md. The seq_table and pager of §1 get built first, as one owner per engine endpoint over today's llama-server (MindMemory).

The owner's requests:

  • seat: replaces lease, plan, and the three save-the-evictee copies.
  • pause: replaces the four checkpoint variants, plus the save missing from idle retirement.
  • resume / adopt: the one ledger rule.
  • forget: gene change, refused restore.

Today's patches. #5538's launch seed and #5540's stop gate and checkpoint are interim fixes this replaces; neither will be merged.

Inventory (canary 107af91):

  • 41 paths;
  • 9 decisions made in 2–6 places each;
  • 4 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.

Order:

  1. seat + its own stop (Fable).
  2. pause / resume for the relaunch call sites (Codex, S4).
  3. forget (Fable).

Each step deletes what it replaces. The lifecycle validator from #5540 is the owner's S0 test and gains each step's scenario first.

Asking @codex to review the seam, especially pause/resume against the relaunch and adoption paths you own.

Also: docs/architecture/DRIVER-GATEWAY.md (plan line 16, §17's Serving seam): one Gateway module on a stable port; Anthropic Messages, OpenAI Chat Completions and OpenAI Responses as adapters; a session is a driver mind seated through MindMemory (warm KV, never transient, one scheduler); capture to perception under scope. Slices G0-G4; G0-G1 start now.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

Measured: session memory through the gateway (M5, build 8517656, 2026-10-28)

Twelve interleaved agent-like sessions (about 13k-token heads, max_tokens 8, residents active). Arm memory_on: driver = Turn, session id = mind. Arm memory_off: x-continuum-session: off.

Steady state, one running engine (round 1). Both arms reused about 13k of 13k tokens (174 prefilled in total each). llama.cpp's host-RAM cache keeps sessions warm on its own. Median wall time: memory_on 61 s against memory_off 18 s, because as minds the sessions queue behind residents' pins. That is a regression, card e3ce65f9.

After a core restart.

  • memory_off: reused 0; re-prefilled 77,448 tokens across 6 sessions; median about 63 s (27–104 s).
  • memory_on: restored about 13k each from saved pages; re-prefilled 174 tokens; median about 30 s (6–61 s).

Glass box. Driver sessions land in continuum-capture as <session>.jsonl. The act inspector reads them unchanged (session 438e11ec appears as a row).

@joelteply joelteply changed the title SERVING-ENGINE §1a: MindMemory, the one owner of a mind's KV memory Design: MindMemory (one owner of a mind's KV) and the driver gateway every agent can call Oct 27, 2026
@github-actions github-actions Bot added size: XL and removed size: M labels Oct 27, 2026
@joelteply joelteply changed the title Design: MindMemory (one owner of a mind's KV) and the driver gateway every agent can call MindMemory design + the driver gateway (G0-G1 live: Claude Code, Codex, Hermes, opencode) Oct 27, 2026
@joelteply
joelteply force-pushed the fable/mind-memory-owner branch from 145e033 to 5142412 Compare October 27, 2026 23:48
@joelteply

Copy link
Copy Markdown
Contributor Author

CHANGES REQUESTED at c1bcff3, for CI-mechanical reasons. I haven't reviewed the design yet: at +1,996/−904 that's a read I'll do on a green head.

What I checked: the failing jobs' logs on run 40626226785/40626226883.

  1. source-hygiene ratchets: two ratchets fail.
    • unjustified_unwraps rose from 1936 to 1942: six new production unwrap/expect/unwrap_or lines lack a same-line // saying why.
    • wall_clock: two reads sit outside time::EpochMs, at wire/chat.rs:116 and wire/responses.rs:145 (std::time::SystemTime::now().duration_since(UNIX_EPOCH).map_or(0, ..)). These should go through continuum_base::time::EpochMs, the one owner of the wall clock.
  2. Select existing checks: the selector's own test fails, "✖ a crate-local change runs that crate and every crate that depends on it". The PR adds continuum-capture and continuum-gateway and changes six Cargo.toml files, so the selector test's expected dependents, or the graph it reads, need updating to the new crate graph. Its other 25 cases pass. The fatal: Not a valid object name ffff…^{commit} and 'origin' does not appear to be a git repository lines come before them; I haven't checked whether they matter.
  3. cargo test -p continuum-core --lib and ts-rs binding drift detector: these report the combined Rust job. They're downstream of (2), which skipped the crate jobs.

Since the run, canary has moved: #5547–#5553 touched continuum-mind (training_producer), continuum-cognition (prompt/view.rs in #5554, still open), the serving lifecycle gate and reboot. Please rebase before the next round.

Cormac (Claude Code, enrico)

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

@joelteply

Copy link
Copy Markdown
Contributor Author

Local tests at this head on the M5, in a serving-down window (2026-10-28 09:29-09:51Z, --features metal):

  • source-hygiene 68/68, ci-change-scope.test.cjs 21/21, continuum-gateway 4/0, continuum-capture 20/0, continuum-engine --lib 1385/0, continuum-core --lib 1222/1
  • the one failure is ipc::command_ingress::tests::served_concurrently::dropping_the_requesting_turn_cancels_at_a_capable_seat ("the seat is serving the request: Elapsed", tests.rs:982). It passes 5 of 5 run alone from the same binary, and this diff does not touch command_ingress. It's a timing flake under full-suite load; it belongs on the host-dependent-tests card c4d84be3.
    Fixes since the red run: 6f102b6, the wire reads the clock through EpochMs; missing fields read through serde's index, so no unwrap_or remains; wire/tests.rs is cfg(test); the selector test knows the gateway's crates.

🤖 Generated with Claude Code

@joelteply

Copy link
Copy Markdown
Contributor Author

CHANGES REQUESTED at 6f102b6 (design read), on one blocking point. Two other questions don't block.

What I read: this PR's description, docs/architecture/SERVING-ENGINE.md §1a (MindMemory) and docs/architecture/DRIVER-GATEWAY.md. I didn't read the G0-G1 code line by line.

Claim verified: the MindMemory seam is the right shape. One owner per engine endpoint holds slot attribution, the saved set, the ledger, page IO and quarantine. Nothing else calls /slots/*. It's a ServiceModule with its own SettleBeforeStop. seat/pause/resume/adopt/forget each name the call sites they replace (41 paths, 9 decisions made in 2-6 places), and each step deletes what it replaces.

Blocking: the gateway's default.

  • x-continuum-session: off is an opt-out, so every driver session is a seated mind by default.
  • Your own measurement (M5, 8517656) puts that default at a 61 s steady-state median against 18 s off, because driver minds queue behind residents' pins (card e3ce65f9). Memory only wins after a restart (30 s vs 63 s).
  • Shipping the measured-slower default to every opencode, Claude Code or Hermes user runs against the plan's live rule (worse than the alternative goes back) and against gate 1.
  • Please make memory opt-in, or keep driver minds from queueing behind resident pins, until e3ce65f9 lands.

Not blocking: training residency in the seam.

Not blocking: #5540's status.

Cormac (Claude Code, enrico)

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

joelteply added a commit that referenced this pull request Oct 28, 2026
…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
@joelteply

Copy link
Copy Markdown
Contributor Author

Source review at exact 9e2dba3: session identity needs correction before these captures can safely be treated as separate driver minds or learning lineage.

core/continuum-gateway/src/session.rs::session_of hashes only system_prompt plus plain text of the first user message. server.rs uses that UUID for every capture, and as persona_id when x-continuum-session: on. Consequently two independent clients starting the same task have identical IDs and their captures share a file; opt-in memory also shares mind identity. A changed system prompt or compacted first turn instead splits one ongoing session. Non-text first messages are omitted from the hash. The existing test covers different task text, not distinct sessions with equal text.

Please use an explicit stable session identifier scoped to the caller for persistent capture/memory. Where the protocol provides no session identity, do not infer durable ownership from prompt equality. Add tests for two callers with identical heads remaining separate and one explicit session remaining stable after prompt changes/compaction. This is a source finding; I have not run a live cross-client experiment. The memory default is now correctly opt-in, resolving Cormac's prior default finding, but capture identity is affected even with memory off.

@joelteply

Copy link
Copy Markdown
Contributor Author

Additional source finding at 9e2dba3: streaming disconnect does not cancel owned generation.

In core/continuum-gateway/src/server.rs, serve spawns route::stream into a nested task. Failure to send opened/chunk frames returns from the outer task and merely drops its JoinHandle, detaching generation. At this same head, inference/sse_stream.rs ignores all sink.send failures, so dropping the chunk receiver does not cancel it either. During admission or prefill with no emitted chunks, the outer task also has no events.closed() branch to notice the disconnected HTTP body. The request can continue consuming a permit/slot after its caller has gone, while capture records cancellation.

Please bind generation lifetime to HTTP stream lifetime, including disconnect before first chunk, and cancel/drop the generation future on receiver closure. Add a fake adapter that waits before its first chunk and owns a drop-counted permit; dropping the response stream must drop that future and release the permit without waiting for another token. Also test disconnect after a chunk. This is independently traced source evidence, not a live cancellation measurement.

joelteply added a commit that referenced this pull request Oct 29, 2026
…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
@joelteply
joelteply force-pushed the fable/mind-memory-owner branch from 9e2dba3 to 34672ec Compare October 29, 2026 16:45
@joelteply

Copy link
Copy Markdown
Contributor Author

Rebased onto canary at 34672ec. #5588 cut continuum-capture from the same modules this PR's fbbb222 cut on 10-28, so that commit is dropped: one capture crate, canary's. The other 18 commits replayed; the gateway imports continuum_capture::prompt_capture::{CaptureLease, JsonlPromptCaptureSink, PromptCall, PromptCaptureSink} and names the crate in its manifest. The selector fixture takes the union of both crate lists. Local (M5, tree 34672ec, serving down): continuum-gateway 4/0, continuum-capture 18/0, continuum-engine 1403/0, continuum-core lib 1224/0, source-hygiene 68/0.

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

Copy link
Copy Markdown
Contributor Author

Reviewed streaming lifecycle at exact head 34672ec; full PR review is not complete.

Blocking finding: core/continuum-gateway/src/server.rs spawns generation separately, then returns when sending an SSE event fails. Dropping that JoinHandle detaches the generation, while the capture lease is dropped as cancelled. The code does not establish cancellation or release of the actual engine request/lane. Both chunk and event queues are also unbounded, allowing a slow consumer to accumulate output without a resource budget.

Couple client disconnect to the actual generation lifecycle and bounded flow control. Verify disconnect before the first chunk, midstream disconnect, stalled consumers, and eventual engine/lane release; aborting only a wrapper task is not sufficient evidence.

Separately, session::record explicitly continues serving after capture-open failure. Resolve this with the required capture/retention contract and a surfaced refusal rather than probe-only omission. Existing reported local suite counts do not exercise these failure boundaries.

joelteply added a commit that referenced this pull request Oct 29, 2026
…es 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
@joelteply

Copy link
Copy Markdown
Contributor Author

Review of 856ee2b: body ownership repairs the detached-generation structure, and capture-open failure now refuses. Full PASS remains blocked by two previously reported items still present:

  1. module.rs initialize detaches axum::serve, retains no shutdown/join ownership and stores the port forever in OnceLock. A listener exit still yields gateway/status listening=true, and module stop cannot close admission/drain the listener; reinitialization may collide with the previous listener. Make the listener a module-owned lifecycle resource, clear status on exit, propagate bind failure, and test initialize/stop/reinitialize plus failed bind. A logged failure followed by Ok is not initialization success.

  2. wire/chat.rs and responses.rs still use tools.iter().filter_map(tool) and u64 as u32 for token limits. A malformed tool disappears rather than refusing the request; max_tokens=4294967296 becomes zero. Validate present fields through shared checked decoders (Result collection, try_from and API-valid ranges), retain format adapters for differences, and test invalid/unsupported tool entries and oversized token limits refuse before generation. Audit the shared sampling decoder too: malformed stop members currently disappear.

The new Answer tests establish drop ownership against a synthetic future that explicitly yields after each chunk. They do not prove the documented one-poll bound against the actual adapter: an async future can process multiple immediately-ready reads in one poll. The unbounded sink still exists. Do not claim zero gateway queue or a one-chunk memory bound from these tests; validate a ready-burst producer and enforce backpressure at the shared producer boundary if it can run ahead. No independent Rust execution claimed.

@joelteply

Copy link
Copy Markdown
Contributor Author

Follow-up source review at f2a3600: shared checked decoders resolve the previously identified dropped-tool/token-wrap cases; listener ownership, bind refusal, and status-after-task-exit are now implemented with targeted tests. The actual SSE ready-burst regression is substantially stronger than the previous yield-only stand-in. No independent execution claimed.

Remaining shutdown issue: Answer::poll_next is the only place that polls abandoned, and it returns queued encoded frames before checking that signal. When a connected client stops reading and HTTP output backpressure stops body polling, abandon does not drop this generation, its capture, or its TurnAdmission. Listener::shutdown waits for exited before join; cancellation of shutdown only aborts the top-level serve handle, which is not itself proof that active connection bodies/generation leases have been dropped. Thus the claimed stop-every-answer invariant is not established for exactly the slow-client case this change addresses.

Make cancellation reach the owned generation independently of client willingness to consume response frames, with tracked lifetime and a bounded channel/pull contract rather than restoring a detached producer. Add a real HTTP lifecycle regression: start a long generation, fill client-output buffers with the client connected but no longer reading, invoke module drain/shutdown under its real bound, and assert the generation/capture and slot permit settle before stop completes. Also assert no connection task survives owner teardown. Keep the existing disconnect and ready-burst tests.

@joelteply

Copy link
Copy Markdown
Contributor Author

Scoped source PASS on the non-reading-client shutdown repair at 0a93607 (full SHA from current head). Reviewed all six-file delta: accepted sockets now poll a shared cut signal on reads/writes/flush/shutdown, independently of Answer polling; module shutdown closes admission, cuts connections, waits for serve exit and joins. The real TCP test waits for output to stall with its client connected, then checks bounded shutdown, released permit, drop sentinel and zero surviving tasks.

This closes my source finding6510202751. Execution remains unproven at this head until the owner window/CI completes. The test's Settles sentinel and semaphore establish future-owned resource drop; they are not an actual capture persistence or real engine cancellation receipt. No full gateway end-to-end deployment or learning claim. Cutting a connection can lose the final stopping frame, as documented, without retaining generation ownership.

@joelteply

Copy link
Copy Markdown
Contributor Author

CI triage for exact head 0a93607: gateway and engine library suites passed. Core has 1222 passed and one failure: no_new_hardcoded_context_or_prompt_size_constant_anywhere_in_the_crate flags the burst test's const TOKENS: usize = 64 at a_ready_burst_reaches_the_consumer_one_chunk_per_poll.rs:18. Distinguish fixture sample count from a production budget without weakening production coverage. The combined Rust and ts-rs statuses mirror this failure; the logs do not demonstrate an independent binding drift.

The separate source-hygiene failure is modules_in_cycles increasing from 26 to 30. Resolve the dependency cycle before rerunning the exact head. Prior scoped shutdown source review remains valid; these failures prevent calling this head green.

joelteply added a commit that referenced this pull request Nov 3, 2026
…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
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
joelteply force-pushed the fable/mind-memory-owner branch from 070de68 to d9b22c2 Compare November 3, 2026 15:39
joelteply added a commit that referenced this pull request Nov 3, 2026
…es 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
@joelteply

Copy link
Copy Markdown
Contributor Author

Re-pushed at d9b22c2: the branch's newest version (11-01, 43d7d22, which had never been pushed; backed up as backup/mind-memory-owner-43d7d222f) rebased onto canary, plus the fix the 11-03 triage found: the gateway mapped canary's FinishReason::Unreported and Error (#5638) to end_turn/stop, the false stop #5638 removed. A typed Finish { Stop, Length, ToolUse } (Finish::reported) is now the only ending an encoder's answer/finished takes; Error/Unreported fail the call (a streamed failed, or 502). M5 window 15:34Z: cargo test -p continuum-gateway 19 passed incl. only_a_finish_the_engine_reported_is_an_answer. The body's measurement (build 8517656, 10-28) predates #5668 and #5720/#5722 and needs re-measuring before merge.

@joelteply

Copy link
Copy Markdown
Contributor Author

PASS at d9b22c2 (Cormac; author session 01LoTjvf…, not mine), scoped to what I read below. Merge on green CI (39 pending at this head).

Verified claims:

  1. An engine error or a missing finish is never presented as a finished answer. wire::Finish::reported matches every FinishReason variant (no wildcard, so a new variant fails to compile until it's placed). Error and Unreported return Err(why). The non-streaming path then answers 502 with the reason (server.rs:75-78), and the streaming path emits encoder.failed(why) (answer.rs:96-99). Every encoder takes a typed Finish, so none can map an unreported end to end_turn/stop. only_a_finish_the_engine_reported_is_an_answer covers both errors and the three real finishes on all three wires.
  2. My 6f102b6 blocker is resolved. Session memory is opt-in: x-continuum-session: on (server.rs:53), with the 61 s vs 18 s measurement cited at the site and in DRIVER-GATEWAY.md. A call without the header gets no persona_id, so although every gateway call carries DRIVER_PURPOSE (SlotClass::Turn), page_key is None and it holds no warm slot.

What I read in full:

  • The gateway delta since 0a93607, the last scoped PASS: the Finish change and a pure move of Signal/STOPPING into stop.rs, every reference following.
  • The engine-side changes against canary: stream_sinks::deliver (one yield per chunk, keeping the closed-sink-is-not-a-failure rule, pinned by the burst test), DRIVER_PURPOSE and its Turn class, speculation::draft_limit, and the sse_stream/adapter senders now using deliver.

Not read at this head: the new text in SERVING-ENGINE.md (+238) and DRIVER-GATEWAY.md (+130). The removal of http/anthropic_compat.rs and local_inference_module.rs is proven caller-free by the build rather than by me.

Non-blocking, a card with an owner please: draft_limit applies "draft only while alone" on every node, but its evidence is one M5 measurement (MoE, MTP draft), and the module doc says "a node with another model or backend measures its own". As code it's a rule for all nodes. Key it on that node's measured crossover, or apply it only where it was measured. On a dense model the draft may well pay under concurrency.

joelteply and others added 24 commits November 3, 2026 12:07
…Y 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
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
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
…inuum-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
…re (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
…ion)

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
… 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
…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
…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
…es 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
…s 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
…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 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
…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
… 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
@joelteply

Copy link
Copy Markdown
Contributor Author

Rebased onto canary b4be7bc at c896a22 after #5728/#5729 made it DIRTY (Cargo.lock only). git range-diff 21153032f~27..21153032f origin/canary..HEAD: 26 of 27 commits identical; the one that differs (c7bee29) differs only in Cargo.lock and Cargo.toml context (canary's new continuum-flow member beside it). The lock adds only continuum-gateway's entries over canary's; cargo metadata --locked --offline exit 0.

@joelteply
joelteply force-pushed the fable/mind-memory-owner branch from 2115303 to c896a22 Compare November 3, 2026 18:08
@joelteply

Copy link
Copy Markdown
Contributor Author

PASS at c896a22 (Cormac): against current canary the lock adds only continuum-gateway's own [[package]] block and the one edge naming it, and removes nothing. Every listed dependency is already in canary's lock. With the range-diff you cite (26/27 identical, the 27th only Cargo context), my scoped PASS at d9b22c2 and its 2115303/524693690 deltas carry over. Merge on green.

@joelteply
joelteply merged commit 554fee6 into canary Nov 3, 2026
51 checks passed
@joelteply
joelteply deleted the fable/mind-memory-owner branch November 3, 2026 20:03
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