From 4449ecb1fb8ce13d34ee7e6e8e2837d602227052 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Mon, 16 Nov 2026 14:51:53 -0600 Subject: [PATCH 01/10] The engine keeps every resident mind as a sequence and switches minds by moving it: launch with --minds, name the mind on each turn, stream her in while she waits (fork #139) Serves the residents' acts directly (plan path step 1, "Fast"; order line 3b): on the M5 today a mind switch serialized her whole state into the engine's prompt cache (up to 2.35 GB a switch) and dropped her when she did not fit (10 times, 8.7 GB), so the arriving mind re-prefilled at swap speed. Fork #139 makes a switch a sequence move (0.16 ms parked, ~10 ms through flash, 0.16 ms when streamed in ahead); this is the core's half that turns it on. - Launch: an engine whose --help lists --minds (probed beside --train-dir; an older engine never sees the flag) starts with --minds beside --kv-unified: one parked sequence id per lane (shared_pool owns it). - Request: a keyed turn carries "page" = PageKey::engine_id() beside id_slot: a mind is her persona id, a fork is derived from (persona, room) in its own namespace (v5), so it can never equal a mind's. - Stream-in: before a keyed turn waits for admission, POST /minds/prefetch for her (inference::minds, fire and forget, probed; 404 = an engine without minds), so her state is in the pool when her lane frees. Not in this PR (Codex, agreed split): reading /props.context_geometry.resident_minds before dispatch to skip the core's own save/erase/restore around switches and learning, and learning with side_sequence + learn_pin. Tests: the shared-pool launch test asserts --minds equals the plan's lanes. Compiled by CI (no build beside the M5's serving lanes). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- .../src/ai/openai_adapter/stream.rs | 10 ++++++ .../src/inference/llama_server/genome.rs | 17 ++++++++-- .../src/inference/llama_server/kv_support.rs | 4 ++- .../src/inference/llama_server/prepare.rs | 3 +- .../src/inference/llama_server/shared_pool.rs | 13 +++++-- .../llama_server/tests/engine_install.rs | 4 ++- .../inference/llama_server/tests/reconcile.rs | 6 ++-- core/continuum-engine/src/inference/minds.rs | 34 +++++++++++++++++++ core/continuum-engine/src/inference/mod.rs | 1 + .../src/inference/slots/page_key.rs | 19 +++++++++++ 10 files changed, 100 insertions(+), 11 deletions(-) create mode 100644 core/continuum-engine/src/inference/minds.rs diff --git a/core/continuum-engine/src/ai/openai_adapter/stream.rs b/core/continuum-engine/src/ai/openai_adapter/stream.rs index 17cd348388..598d94f4de 100644 --- a/core/continuum-engine/src/ai/openai_adapter/stream.rs +++ b/core/continuum-engine/src/ai/openai_adapter/stream.rs @@ -212,6 +212,11 @@ impl OpenAICompatibleAdapter { })?; // The endpoint's own permits, shared by every adapter and the learner (card 23069702). let endpoint_permits = crate::inference::slots::directory().endpoint(root).concurrency().bound(); + // Her state streams in while she waits for a lane (fork #139: a mind on flash is inserted into a + // parked sequence now, so her switch is a sequence move). Not awaited: it never delays her turn. + if let Some(key) = turn_key.filter(|_| class.holds_a_page()) { + crate::inference::minds::prefetch(self.client.clone(), root.to_string(), key); + } let adm = crate::inference::turn_admission::admit_turn( endpoint_permits, class, @@ -273,6 +278,11 @@ impl OpenAICompatibleAdapter { if let Some(slot) = placement { if let Some(obj) = body.as_object_mut() { obj.insert("id_slot".to_string(), json!(slot)); + // the mind this turn is (fork #139): the engine switches minds on a lane by sequence moves, + // never through its prompt cache; an engine without minds ignores the field + if let (true, Some(key)) = (keyed_turn, turn_key.as_ref()) { + obj.insert("page".to_string(), json!(key.engine_id().simple().to_string())); + } } if let (true, Some(persona)) = ( keyed_turn, diff --git a/core/continuum-engine/src/inference/llama_server/genome.rs b/core/continuum-engine/src/inference/llama_server/genome.rs index f71995c27b..0dc00be60a 100644 --- a/core/continuum-engine/src/inference/llama_server/genome.rs +++ b/core/continuum-engine/src/inference/llama_server/genome.rs @@ -21,7 +21,7 @@ pub(super) static ENGINE_PROBES: parking_lot::Mutex Option { /// PURE: what the record says about `bin`: its answer, no when it did not answer, nothing when it /// was never asked. pub(super) fn answer_for(probes: &BTreeMap, bin: &str) -> Option { - probes.get(bin).map(|outcome| matches!(outcome, ProbeOutcome::Answered { train_dir: true })) + probes.get(bin).map(|outcome| matches!(outcome, ProbeOutcome::Answered { train_dir: true, .. })) } /// PURE: what a decision may rest on: `bin`'s answer when it answered, else nothing (never asked, /// or asked without an answer), and the caller asks it now. pub(super) fn train_dir_known(probes: &BTreeMap, bin: &str) -> Option { match probes.get(bin) { - Some(ProbeOutcome::Answered { train_dir }) => Some(*train_dir), + Some(ProbeOutcome::Answered { train_dir, .. }) => Some(*train_dir), _ => None, } } @@ -63,6 +63,17 @@ pub(super) fn engine_help_lists_train_dir(help: &str) -> bool { help.lines().any(|l| l.trim_start().starts_with("--train-dir")) } +/// The engine keeps resident minds as parked sequences (`--minds`, fork #139): a mind switch is a sequence +/// move, never a serialization. +pub(super) fn engine_help_lists_minds(help: &str) -> bool { + help.lines().any(|l| l.trim_start().starts_with("--minds")) +} + +/// Whether `bin` accepts `--minds`. "Not asked yet" reads as no: an older engine refuses to start with it. +pub fn engine_accepts_minds(bin: &str) -> bool { + matches!(ENGINE_PROBES.lock().get(bin), Some(ProbeOutcome::Answered { minds: true, .. })) +} + /// Where every lane's `POST /train` writes its adapters (`--train-dir`). One directory /// for all lanes: a job names its output `.gguf`, and the engine trainer moves diff --git a/core/continuum-engine/src/inference/llama_server/kv_support.rs b/core/continuum-engine/src/inference/llama_server/kv_support.rs index b957de4dc4..b53021c899 100644 --- a/core/continuum-engine/src/inference/llama_server/kv_support.rs +++ b/core/continuum-engine/src/inference/llama_server/kv_support.rs @@ -16,6 +16,7 @@ pub(super) async fn ensure_engine_kv_support_recorded(bin: &str, mut command: to return; } let mut train_dir = false; + let mut minds = false; command.arg("--help"); // owned (continuum_process::run_owned): a help probe that hangs is ended with anything it started let probe = continuum_process::run_owned(command, Some(Duration::from_secs(10)), "engine-help-probe", std::sync::Arc::default()).await; @@ -30,6 +31,7 @@ pub(super) async fn ensure_engine_kv_support_recorded(bin: &str, mut command: to text.push('\n'); text.push_str(&String::from_utf8_lossy(&out.stderr.bytes)); train_dir = engine_help_lists_train_dir(&text); + minds = super::genome::engine_help_lists_minds(&text); match crate::inference::kv_cache_plan::parse_engine_kv_support(&text) { Some(v) => ("answered", Some(v), String::new()), None => ("did_not_enumerate", None, String::new()), @@ -40,7 +42,7 @@ pub(super) async fn ensure_engine_kv_support_recorded(bin: &str, mut command: to crate::inference::kv_cache_plan::record_engine_quantized_kv_support(support); // None = unanswered: the backend table decides // This binary's entry alone, written whole: what it said, or that it did not answer. let outcome_of_probe = match matches!(outcome, "answered" | "did_not_enumerate") { - true => super::genome::ProbeOutcome::Answered { train_dir }, + true => super::genome::ProbeOutcome::Answered { train_dir, minds }, false => super::genome::ProbeOutcome::Unanswered, }; super::genome::ENGINE_PROBES.lock().insert(bin.to_owned(), outcome_of_probe); diff --git a/core/continuum-engine/src/inference/llama_server/prepare.rs b/core/continuum-engine/src/inference/llama_server/prepare.rs index 2b76d8ecf0..a52ac93fc4 100644 --- a/core/continuum-engine/src/inference/llama_server/prepare.rs +++ b/core/continuum-engine/src/inference/llama_server/prepare.rs @@ -306,7 +306,8 @@ impl LlamaServerProcess { max_ubatch: target.model.serving.max_ubatch, reasoning_budget: target.model.serving.reasoning_budget, }); - let mut invocation = super::shared_pool::on_shared_pool(invocation); + let minds = super::genome::engine_accepts_minds(&bin).then_some(lanes); + let mut invocation = super::shared_pool::on_shared_pool(invocation, minds); // MoE glass-box env seam (#278): when expert paging is active, the DAEMON // hands the fork its capture + plan file locations. Previously these envs // existed only when an operator hand-exported them before booting the diff --git a/core/continuum-engine/src/inference/llama_server/shared_pool.rs b/core/continuum-engine/src/inference/llama_server/shared_pool.rs index 45b6ce0d2b..beac0b91d8 100644 --- a/core/continuum-engine/src/inference/llama_server/shared_pool.rs +++ b/core/continuum-engine/src/inference/llama_server/shared_pool.rs @@ -22,11 +22,20 @@ const SHARED_POOL_SHORT: &str = "-kvu"; /// tokens, Aris 20,962 at 38 tok/s, Aiko 62,026), while back-to-back turns reused 28-38k each. const KEEP_IDLE_SLOTS: &str = "--no-cache-idle-slots"; +/// The engine's resident minds beside its lanes (fork #139): each a parked sequence of the pool, so a +/// mind switch is a sequence move in milliseconds (parked) or through flash, never a serialization. +const RESIDENT_MINDS: &str = "--minds"; + /// Launch on the shared pool: every sequence draws on all of `-c`, and an idle one keeps what -/// she holds until the core pages her. -pub(super) fn on_shared_pool(mut invocation: LaneInvocation) -> LaneInvocation { +/// she holds until the core pages her. `minds`: parked sequence ids beside the lanes, given only to an engine +/// that lists `--minds`; the plan's lane count, one parked id per lane (a mind leaving any lane always has one). +pub(super) fn on_shared_pool(mut invocation: LaneInvocation, minds: Option) -> LaneInvocation { invocation.args.push(SHARED_POOL.to_string()); invocation.args.push(KEEP_IDLE_SLOTS.to_string()); + if let Some(n) = minds.filter(|n| *n > 0) { + invocation.args.push(RESIDENT_MINDS.to_string()); + invocation.args.push(n.to_string()); + } invocation } diff --git a/core/continuum-engine/src/inference/llama_server/tests/engine_install.rs b/core/continuum-engine/src/inference/llama_server/tests/engine_install.rs index 3b48c07efa..e3f69e3b33 100644 --- a/core/continuum-engine/src/inference/llama_server/tests/engine_install.rs +++ b/core/continuum-engine/src/inference/llama_server/tests/engine_install.rs @@ -120,8 +120,10 @@ fn the_engine_launches_on_one_shared_pool() { Path::new("fixture.gguf"), planned.model_id(), "127.0.0.1", 1, planned.parallel_lanes(), planned.served_total_ctx(), planned.host_prompt_cache_mib, Path::new("pages"), - )); + ), Some(planned.parallel_lanes())); assert_eq!(invocation.value_of("-c"), Some("290560")); assert_eq!(invocation.value_of("--parallel"), Some("5")); + // what this catches: a mind switch serialized through the prompt cache because the engine had no parked ids + assert_eq!(invocation.value_of("--minds"), Some("5"), "an engine that lists --minds keeps one parked id per lane"); assert_eq!(super::super::shared_pool::pool_launch(&invocation.args), super::super::PoolLaunch::Shared, "the launch and the read-back agree"); } diff --git a/core/continuum-engine/src/inference/llama_server/tests/reconcile.rs b/core/continuum-engine/src/inference/llama_server/tests/reconcile.rs index a48b989338..e5e7bca91d 100644 --- a/core/continuum-engine/src/inference/llama_server/tests/reconcile.rs +++ b/core/continuum-engine/src/inference/llama_server/tests/reconcile.rs @@ -378,7 +378,7 @@ fn an_adopted_engines_report_reads_back_as_the_genes_it_holds() { #[test] fn a_train_dir_answer_is_about_the_binary_asked_and_no_other() { let probes = std::collections::BTreeMap::from([ - ("/slots/engine-a/llama-server".to_string(), ProbeOutcome::Answered { train_dir: true }), + ("/slots/engine-a/llama-server".to_string(), ProbeOutcome::Answered { train_dir: true, minds: false }), ("/slots/engine-b/llama-server".to_string(), ProbeOutcome::Unanswered), ]); assert_eq!(answer_for(&probes, "/slots/engine-a/llama-server"), Some(true)); @@ -394,8 +394,8 @@ fn a_train_dir_answer_is_about_the_binary_asked_and_no_other() { #[test] fn an_in_place_decision_rests_only_on_an_answer() { let probes = std::collections::BTreeMap::from([ - ("answered-yes".to_string(), ProbeOutcome::Answered { train_dir: true }), - ("answered-no".to_string(), ProbeOutcome::Answered { train_dir: false }), + ("answered-yes".to_string(), ProbeOutcome::Answered { train_dir: true, minds: false }), + ("answered-no".to_string(), ProbeOutcome::Answered { train_dir: false, minds: false }), ("timed-out".to_string(), ProbeOutcome::Unanswered), ]); assert_eq!(train_dir_known(&probes, "answered-yes"), Some(true)); diff --git a/core/continuum-engine/src/inference/minds.rs b/core/continuum-engine/src/inference/minds.rs new file mode 100644 index 0000000000..e52d994e20 --- /dev/null +++ b/core/continuum-engine/src/inference/minds.rs @@ -0,0 +1,34 @@ +//! Resident minds on the engine (fork #139): a mind switch is a sequence move, never a serialization. +//! +//! The engine keeps every mind it serves as a sequence of its unified KV pool (parked when another mind holds +//! the lane) or, when the pool needs her cells, as a page on flash that it maps back in. A turn names its mind +//! (`"page"`, [`super::slots::PageKey::engine_id`]) so the engine moves the right sequence; and while she waits +//! for a lane, her state is streamed in ahead of her turn, the way a game engine streams what the camera needs +//! next, so her switch is the sub-millisecond sequence move. + +use super::slots::PageKey; + +/// Ask the engine at `root` to bring `key`'s mind into its pool now (`POST /minds/prefetch`). Fire and forget: +/// it never delays her turn. An engine that keeps no minds answers 404, which is not a failure. +pub(crate) fn prefetch(client: reqwest::Client, root: String, key: PageKey) { + tokio::spawn(async move { + let url = format!("{}/minds/prefetch", root.trim_end_matches('/')); + let body = serde_json::json!({ "page": key.engine_id().simple().to_string() }); + let outcome = client.post(&url).json(&body).send().await; + let (status, message) = match outcome { + Ok(response) => { + let status = response.status().as_u16(); + let text = response.text().await.unwrap_or_default(); // unwrap_or_default: an unreadable body still has its status + (status, text) + } + Err(e) => (0, e.to_string()), + }; + continuum_base::probe!( + class = "inference.minds.prefetch", + page = %key, + status = u64::from(status), + reply = message.as_str(), + "her state streamed in ahead of her turn (404: the engine keeps no minds)" + ); + }); +} diff --git a/core/continuum-engine/src/inference/mod.rs b/core/continuum-engine/src/inference/mod.rs index 50d05004e3..ff2626e117 100644 --- a/core/continuum-engine/src/inference/mod.rs +++ b/core/continuum-engine/src/inference/mod.rs @@ -39,6 +39,7 @@ pub mod handle_store; pub mod kv_cache_plan; pub mod kv_quant; pub mod lane_args; +pub mod minds; pub mod lane_demand; pub mod lane_health; pub mod lane_send; diff --git a/core/continuum-engine/src/inference/slots/page_key.rs b/core/continuum-engine/src/inference/slots/page_key.rs index 3f79762231..f978d18c90 100644 --- a/core/continuum-engine/src/inference/slots/page_key.rs +++ b/core/continuum-engine/src/inference/slots/page_key.rs @@ -90,6 +90,25 @@ impl PageKey { } } +/// The namespace a fork's engine id is derived in, so it can never equal a mind's (her persona id). +const FORK_ENGINE_NAMESPACE: Uuid = Uuid::from_u128(0x0dcaba2a_7457_5f3c_9be6_64cb21c5bfea); + +impl PageKey { + /// The 128-bit id the engine keeps this page's resident mind under (fork #139: `"page"` on a request, + /// `/minds/prefetch`). A mind is her persona; a fork is derived from (persona, room) in its own namespace. + pub fn engine_id(&self) -> Uuid { + match self { + Self::Mind(m) => m.persona(), + Self::Fork(k) => { + let mut name = [0u8; 32]; + name[..16].copy_from_slice(k.persona.as_bytes()); + name[16..].copy_from_slice(k.room.as_bytes()); + Uuid::new_v5(&FORK_ENGINE_NAMESPACE, &name) + } + } + } +} + /// For probes only; never a key. impl fmt::Display for PageKey { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { From 4809c0abb6d06b6e4bb3d28e47b162a5664c8f1d Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Mon, 16 Nov 2026 15:00:49 -0600 Subject: [PATCH 02/10] Resident minds, review fixes (Codex on #6087): prefetch only to an engine that declared them, bound to its pid and deduped; --minds is the seated minds plus one learner; the pool geometry counts parked ids - The pool's geometry check required sequence_capacity == slots: an engine keeping resident minds reports lanes + parked ids, so the pin would have made the core reject its pool. ContextGeometry reads resident_minds {lanes, parked_ids} (declared on /props) and the check is slots + parked ids. - Discovery records resident_minds per engine from the same /props body (resident_minds_by_root); the prefetch is sent only to an engine that declared it (never a 404 guess), carries the slot pool's engine pid (the engine refuses a stream meant for a replaced process, fork #139), and is deduplicated per (engine, mind) until its reply returns. - ServingTarget.minds = the seated minds + 1 side sequence for learning at the resident launch (launch.rs); 0 on every single-purpose lane (eval, vision sidecar, fixtures). --minds takes it, only for an engine that lists it. Compiled by CI (no build beside the M5's serving lanes). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- .../cognition/eval/spawn_gene_eval_lane.rs | 3 ++ .../src/ai/openai_adapter/stream.rs | 4 +- .../src/inference/llama_server/prepare.rs | 2 +- .../src/inference/llama_server/shared_pool.rs | 2 +- .../src/inference/llama_server/target.rs | 3 ++ .../inference/llama_server/test_fixtures.rs | 1 + .../src/inference/llama_server/tests.rs | 1 + core/continuum-engine/src/inference/minds.rs | 54 +++++++++++++------ core/continuum-engine/src/inference/slots.rs | 1 + .../src/inference/slots/discover.rs | 16 ++++++ .../src/inference/vision_sidecar.rs | 1 + .../src/inference/weight_residency.rs | 23 +++++++- .../src/modules/serving_daemon/launch.rs | 3 ++ .../src/modules/serving_daemon/tests.rs | 2 +- .../serving_daemon/tests/engine_admission.rs | 2 + 15 files changed, 97 insertions(+), 21 deletions(-) diff --git a/core/continuum-academy/src/cognition/eval/spawn_gene_eval_lane.rs b/core/continuum-academy/src/cognition/eval/spawn_gene_eval_lane.rs index cd62f8902d..3dd16b00e6 100644 --- a/core/continuum-academy/src/cognition/eval/spawn_gene_eval_lane.rs +++ b/core/continuum-academy/src/cognition/eval/spawn_gene_eval_lane.rs @@ -55,6 +55,7 @@ pub(super) async fn spawn_gene_eval_lane(gene: &EvalGene) -> Result Result) -> LaneInvocation { invocation.args.push(SHARED_POOL.to_string()); invocation.args.push(KEEP_IDLE_SLOTS.to_string()); diff --git a/core/continuum-engine/src/inference/llama_server/target.rs b/core/continuum-engine/src/inference/llama_server/target.rs index a069f8a52d..2d3218258d 100644 --- a/core/continuum-engine/src/inference/llama_server/target.rs +++ b/core/continuum-engine/src/inference/llama_server/target.rs @@ -43,6 +43,9 @@ pub struct ServingTarget { /// lanes` of KV against the host budget, so `-c (context_window * lanes)` /// is memory-safe by the planner's own arithmetic. pub lanes: u32, + /// Resident minds the engine keeps beside its lanes as parked sequences (`--minds`, fork #139): the seated + /// minds plus one side sequence for learning. 0: none (a single-purpose lane). + pub minds: u32, /// The trained LoRA genome layers to load into the serving catalog at spawn /// (`llama-server --lora ` per entry). This is the SET — which genes /// are *loadable*; the per-request `"lora":[{id,scale}]` body field decides diff --git a/core/continuum-engine/src/inference/llama_server/test_fixtures.rs b/core/continuum-engine/src/inference/llama_server/test_fixtures.rs index 89c4fe6615..557127ace2 100644 --- a/core/continuum-engine/src/inference/llama_server/test_fixtures.rs +++ b/core/continuum-engine/src/inference/llama_server/test_fixtures.rs @@ -15,6 +15,7 @@ pub fn generation_has_exited(generation: &crate::inference::slots::EngineGenerat pub(super) fn target(id: &str) -> ServingTarget { use crate::model_registry::types::{Arch, MultiPartyChatStrategy}; ServingTarget { + minds: 0, // a single-purpose lane keeps no resident minds host_prompt_cache_mib: crate::inference::lane_args::CACHE_RAM_MIB, model: Model { weights_bytes: None, diff --git a/core/continuum-engine/src/inference/llama_server/tests.rs b/core/continuum-engine/src/inference/llama_server/tests.rs index 3ab581540f..a08117837e 100644 --- a/core/continuum-engine/src/inference/llama_server/tests.rs +++ b/core/continuum-engine/src/inference/llama_server/tests.rs @@ -209,6 +209,7 @@ impl LlamaServerControl for FakeControl { allocated_tokens: u64::from(self.served_window.saturating_mul(lanes)), max_tokens_per_sequence: u64::from(self.served_window), sequence_capacity: u64::from(lanes), + resident_minds: None, }) } async fn served_lanes(&self) -> Result { diff --git a/core/continuum-engine/src/inference/minds.rs b/core/continuum-engine/src/inference/minds.rs index e52d994e20..37fda47867 100644 --- a/core/continuum-engine/src/inference/minds.rs +++ b/core/continuum-engine/src/inference/minds.rs @@ -1,34 +1,58 @@ //! Resident minds on the engine (fork #139): a mind switch is a sequence move, never a serialization. //! -//! The engine keeps every mind it serves as a sequence of its unified KV pool (parked when another mind holds -//! the lane) or, when the pool needs her cells, as a page on flash that it maps back in. A turn names its mind -//! (`"page"`, [`super::slots::PageKey::engine_id`]) so the engine moves the right sequence; and while she waits -//! for a lane, her state is streamed in ahead of her turn, the way a game engine streams what the camera needs -//! next, so her switch is the sub-millisecond sequence move. +//! An engine that declares `resident_minds` on `/props` keeps every mind it serves as a sequence of its unified +//! KV pool (parked when another mind holds the lane) or, when the pool needs her cells, as a page on flash it maps +//! back in. A turn names its mind (`"page"`, [`super::slots::PageKey::engine_id`]) so the engine moves the right +//! sequence; and while she waits for a lane, her state is streamed in ahead of her turn, the way a game engine +//! streams what the camera needs next, so her switch is the sub-millisecond sequence move. use super::slots::PageKey; +use std::collections::HashSet; +use std::sync::{Mutex, OnceLock}; -/// Ask the engine at `root` to bring `key`'s mind into its pool now (`POST /minds/prefetch`). Fire and forget: -/// it never delays her turn. An engine that keeps no minds answers 404, which is not a failure. -pub(crate) fn prefetch(client: reqwest::Client, root: String, key: PageKey) { +/// Streams in flight, one per (engine root, mind): a mind waiting on several turns streams once. +fn in_flight() -> &'static Mutex> { + static SET: OnceLock>> = OnceLock::new(); + SET.get_or_init(Mutex::default) +} + +/// Ask the engine at `root` (process `engine_pid`, from the slot pool's incarnation) to bring `key`'s mind into +/// its pool now (`POST /minds/prefetch`). Only an engine that DECLARED resident minds is asked (never a 404 +/// guess); the engine refuses a request meant for another process (`engine_pid`), so a stream never lands on a +/// replacement engine; one stream per (engine, mind) at a time. It never delays her turn. +pub(crate) fn prefetch(client: reqwest::Client, root: String, engine_pid: u32, key: PageKey) { + if !super::slots::resident_minds_by_root().contains_key(&root) { + return; // this engine pages minds through the core: nothing to stream + } + let id = key.engine_id(); + match in_flight().lock() { + Ok(mut set) => { + if !set.insert((root.clone(), id)) { + return; // already streaming her in + } + } + Err(_) => return, // a poisoned set: no stream, her turn is not delayed + } tokio::spawn(async move { let url = format!("{}/minds/prefetch", root.trim_end_matches('/')); - let body = serde_json::json!({ "page": key.engine_id().simple().to_string() }); - let outcome = client.post(&url).json(&body).send().await; - let (status, message) = match outcome { + let body = serde_json::json!({ "page": id.simple().to_string(), "engine_pid": engine_pid }); + let (status, reply) = match client.post(&url).json(&body).send().await { Ok(response) => { let status = response.status().as_u16(); - let text = response.text().await.unwrap_or_default(); // unwrap_or_default: an unreadable body still has its status - (status, text) + (status, response.text().await.unwrap_or_default()) // unwrap_or_default: an unreadable body keeps its status } Err(e) => (0, e.to_string()), }; + if let Ok(mut set) = in_flight().lock() { + set.remove(&(root.clone(), id)); + } continuum_base::probe!( class = "inference.minds.prefetch", page = %key, + engine_pid = u64::from(engine_pid), status = u64::from(status), - reply = message.as_str(), - "her state streamed in ahead of her turn (404: the engine keeps no minds)" + reply = reply.as_str(), + "her state streamed in ahead of her turn (the engine's reply names where she is)" ); }); } diff --git a/core/continuum-engine/src/inference/slots.rs b/core/continuum-engine/src/inference/slots.rs index cf0919c88a..871389cbec 100644 --- a/core/continuum-engine/src/inference/slots.rs +++ b/core/continuum-engine/src/inference/slots.rs @@ -73,6 +73,7 @@ mod adopted_replacement; mod discover; pub use discover::{PoolDiscoveryMiss, PropsAbsent}; pub(crate) use discover::served_ctx_by_root; +pub(crate) use discover::resident_minds_by_root; mod checkpoint_failure; pub use checkpoint_failure::{CheckpointFailure, OwnedCheckpointRefusal, SaveFailure}; use checkpoint_failure::CheckpointSave; diff --git a/core/continuum-engine/src/inference/slots/discover.rs b/core/continuum-engine/src/inference/slots/discover.rs index 6b82d6e848..31f96977b1 100644 --- a/core/continuum-engine/src/inference/slots/discover.rs +++ b/core/continuum-engine/src/inference/slots/discover.rs @@ -116,6 +116,13 @@ pub(crate) fn served_ctx_by_root() -> &'static dashmap::DashMap { CTX.get_or_init(dashmap::DashMap::new) } +/// Which engines declared that they own mind switches (`/props.context_geometry.resident_minds`, fork #139), +/// recorded from the same `/props` body that installs the pool. Absent: not declared (the core pages minds). +pub(crate) fn resident_minds_by_root() -> &'static dashmap::DashMap { + static MINDS: std::sync::OnceLock> = std::sync::OnceLock::new(); + MINDS.get_or_init(dashmap::DashMap::new) +} + /// Does this `/props` status PROVE the endpoint does not exist — the only verdict /// allowed to latch the slot directory Unsupported for the process's life? 404/501 /// are the server saying "no such surface"; everything else (above all the 503 of a @@ -186,6 +193,15 @@ impl SlotDirectory { { served_ctx_by_root().insert(root.to_owned(), n_ctx as u32); } + // whether this engine owns mind switches, declared in the same body (never inferred from a 404) + match crate::inference::weight_residency::ContextGeometry::from_props(&body).and_then(|g| g.resident_minds) { + Some(minds) => { + resident_minds_by_root().insert(root.to_owned(), minds); + } + None => { + resident_minds_by_root().remove(root); + } + } // Missing geometry is not proof that activity paging is unsupported. let n_slots = match body.get("total_slots").and_then(|v| v.as_u64()) { Some(n) if n > 0 => n as u32, diff --git a/core/continuum-engine/src/inference/vision_sidecar.rs b/core/continuum-engine/src/inference/vision_sidecar.rs index b0fb84abe5..4b1875b70d 100644 --- a/core/continuum-engine/src/inference/vision_sidecar.rs +++ b/core/continuum-engine/src/inference/vision_sidecar.rs @@ -247,6 +247,7 @@ pub async fn ensure_sidecar( } let target = ServingTarget { + minds: 0, // a single-purpose lane keeps no resident minds // Single-purpose lane: no citizen population to derive from — the // declared cold-start prior is the honest value (restore-economy 1.b). host_prompt_cache_mib: crate::inference::lane_args::CACHE_RAM_MIB, diff --git a/core/continuum-engine/src/inference/weight_residency.rs b/core/continuum-engine/src/inference/weight_residency.rs index 269e355355..69fdafe64f 100644 --- a/core/continuum-engine/src/inference/weight_residency.rs +++ b/core/continuum-engine/src/inference/weight_residency.rs @@ -177,6 +177,16 @@ pub struct ContextGeometry { pub allocated_tokens: u64, pub max_tokens_per_sequence: u64, pub sequence_capacity: u64, + /// The engine keeps resident minds as parked sequences beside its lanes (fork #139): a mind switch is a + /// sequence move it owns. `None`: it does not (the core pages minds itself). Declared, never inferred. + pub resident_minds: Option, +} + +/// What an engine that owns mind switches reports: its lanes and the parked sequence ids beside them. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct ResidentMinds { + pub lanes: u64, + pub parked_ids: u64, } impl ContextGeometry { @@ -197,10 +207,19 @@ impl ContextGeometry { pub fn from_props(props: &serde_json::Value) -> Option { let geometry = props.get("context_geometry")?; let read = |field: &str| geometry.get(field)?.as_u64(); + let minds = geometry.get("resident_minds"); + let resident_minds = match minds.and_then(|m| m.get("enabled")).and_then(|e| e.as_bool()) { + Some(true) => Some(ResidentMinds { + lanes: minds.and_then(|m| m.get("lanes")).and_then(|v| v.as_u64())?, + parked_ids: minds.and_then(|m| m.get("parked_ids")).and_then(|v| v.as_u64())?, + }), + _ => None, + }; let reported = Self { allocated_tokens: read("allocated_tokens")?, max_tokens_per_sequence: read("max_tokens_per_sequence")?, sequence_capacity: read("sequence_capacity")?, + resident_minds, }; (reported.allocated_tokens > 0 && reported.sequence_capacity > 0 @@ -215,7 +234,9 @@ impl ContextGeometry { /// pool is larger (IntelMac 2026-11-03: n_ctx 32,768 beside 65,536; Cormac on #5722). fn allocated_capacity(props: &serde_json::Value, slots: u32, n_ctx_per_slot: u32) -> Option { let geometry = ContextGeometry::from_props(props)?; - (geometry.sequence_capacity == u64::from(slots) && u64::from(n_ctx_per_slot) <= geometry.max_tokens_per_sequence) + // an engine keeping resident minds holds its lanes AND their parked ids as sequences + let parked = geometry.resident_minds.map_or(0, |m| m.parked_ids); + (geometry.sequence_capacity == u64::from(slots) + parked && u64::from(n_ctx_per_slot) <= geometry.max_tokens_per_sequence) .then_some(geometry.allocated_tokens) } diff --git a/core/continuum-serving/src/modules/serving_daemon/launch.rs b/core/continuum-serving/src/modules/serving_daemon/launch.rs index 66a58a0a0d..35483bd92b 100644 --- a/core/continuum-serving/src/modules/serving_daemon/launch.rs +++ b/core/continuum-serving/src/modules/serving_daemon/launch.rs @@ -219,7 +219,10 @@ impl ServingDaemonModule { return None; } } + // the engine keeps every seated mind resident beside its lanes, plus one side sequence for learning + let minds = u32::try_from(self.seated_needs(&model).len()).map_or(u32::MAX, |n| n.saturating_add(1)); let target = ServingTarget { + minds, host_prompt_cache_mib, model, context_window: per_sequence, diff --git a/core/continuum-serving/src/modules/serving_daemon/tests.rs b/core/continuum-serving/src/modules/serving_daemon/tests.rs index 94b80fbab8..af17fd6f73 100644 --- a/core/continuum-serving/src/modules/serving_daemon/tests.rs +++ b/core/continuum-serving/src/modules/serving_daemon/tests.rs @@ -147,7 +147,7 @@ impl LlamaServerControl for FakeServer { } async fn served_geometry(&self) -> Result { // One sequence's worth of the fixed window above: the share these tests publish. - Ok(crate::inference::weight_residency::ContextGeometry { allocated_tokens: 11008, max_tokens_per_sequence: 11008, sequence_capacity: 1 }) + Ok(crate::inference::weight_residency::ContextGeometry { allocated_tokens: 11008, max_tokens_per_sequence: 11008, sequence_capacity: 1, resident_minds: None }) } async fn served_lanes(&self) -> Result { // 0 = "this fake's /props names no slot count", i.e. nothing to compare diff --git a/core/continuum-serving/src/modules/serving_daemon/tests/engine_admission.rs b/core/continuum-serving/src/modules/serving_daemon/tests/engine_admission.rs index 612006639b..d2ffb21b09 100644 --- a/core/continuum-serving/src/modules/serving_daemon/tests/engine_admission.rs +++ b/core/continuum-serving/src/modules/serving_daemon/tests/engine_admission.rs @@ -107,6 +107,7 @@ fn the_sidecar_headroom_is_planned_not_a_relaunch_window_free_read() { model.weights_bytes = Some(21 * 1024 * 1024 * 1024); model.context_window = 262_144; let target = ServingTarget { + minds: 0, // a single-purpose lane keeps no resident minds host_prompt_cache_mib: 2505, model, context_window: 59_392, @@ -132,6 +133,7 @@ fn the_sidecar_headroom_is_planned_not_a_relaunch_window_free_read() { let mut blind = target.model.clone(); blind.weights_bytes = None; let blind_target = ServingTarget { + minds: 0, // a single-purpose lane keeps no resident minds model: blind, ..target.clone() }; From 02bba514d954bb1ce7d256a138f89b5d12cf8a08 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Mon, 16 Nov 2026 15:12:29 -0600 Subject: [PATCH 03/10] Resident minds, Codex's second review: the descriptor is published with the pool, the prefetch is the waiting turn's, and the engine's own token binds it - Discovery race: the resident-minds declaration now lives on the slot pool, set on the candidate before it is published and checked against an installed pool (MindsMismatch), after the superseded-generation check. The root-keyed map is gone. - Identity: the engine draws an incarnation token (fork #139, resident_minds.incarnation); the prefetch carries it and a replaced engine refuses it. No OS pid. - Ownership: the prefetch is a future the turn awaits inside its own lane wait (biased select: admission first, so a turn admitted at once never streams); admitted or cancelled, it is dropped with the wait. No detached task. - --minds: the resident controller holds it (LlamaServerControl::seat_minds, default no-op; set by the serving daemon to the seated minds + 1 learner); ephemeral lanes never set it, so ServingTarget is unchanged. - ContextGeometry decodes /props.context_geometry once into a typed struct; page_key builds the fork id without slicing; prepare drops a redundant cfg!(windows) (the install receipt exists only on Windows already). Compiled by CI (no build beside the M5's serving lanes). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- .../cognition/eval/spawn_gene_eval_lane.rs | 3 - .../src/ai/openai_adapter/stream.rs | 27 +++++--- .../src/inference/llama_server/control.rs | 4 ++ .../inference/llama_server/control_impl.rs | 4 ++ .../src/inference/llama_server/prepare.rs | 6 +- .../src/inference/llama_server/process.rs | 5 ++ .../src/inference/llama_server/shared_pool.rs | 6 +- .../src/inference/llama_server/target.rs | 3 - .../inference/llama_server/test_fixtures.rs | 1 - .../llama_server/tests/engine_install.rs | 2 +- core/continuum-engine/src/inference/minds.rs | 68 ++++++------------- core/continuum-engine/src/inference/slots.rs | 1 - .../src/inference/slots/citizen_slots.rs | 3 + .../src/inference/slots/discover.rs | 32 ++++----- .../src/inference/slots/kv_slot_pool.rs | 7 ++ .../src/inference/slots/page_key.rs | 5 +- .../src/inference/vision_sidecar.rs | 1 - .../src/inference/weight_residency.rs | 52 +++++++++----- .../src/modules/serving_daemon/launch.rs | 5 +- .../serving_daemon/tests/engine_admission.rs | 2 - 20 files changed, 124 insertions(+), 113 deletions(-) diff --git a/core/continuum-academy/src/cognition/eval/spawn_gene_eval_lane.rs b/core/continuum-academy/src/cognition/eval/spawn_gene_eval_lane.rs index 3dd16b00e6..cd62f8902d 100644 --- a/core/continuum-academy/src/cognition/eval/spawn_gene_eval_lane.rs +++ b/core/continuum-academy/src/cognition/eval/spawn_gene_eval_lane.rs @@ -55,7 +55,6 @@ pub(super) async fn spawn_gene_eval_lane(gene: &EvalGene) -> Result Result admit.await, + Some((key, minds)) => { + // Admission first: a turn admitted at once never streams. The stream lives only while she + // waits, and is dropped with her wait (admitted or cancelled), so it never outlives its turn. + let mut admit = std::pin::pin!(admit); + let stream = crate::inference::minds::prefetch(&self.client, root, minds, key); + tokio::select! { + biased; + adm = &mut admit => adm, + () = stream => admit.await, + } + } + } .map_err(crate::ai::inference_error::InferenceError::Unavailable)?; let scratch = adm.scratch_slot(); // Only a turn that names its page owns a slot. A Turn with no persona (or a Fork diff --git a/core/continuum-engine/src/inference/llama_server/control.rs b/core/continuum-engine/src/inference/llama_server/control.rs index 7b5e83a6e8..c91d7d5465 100644 --- a/core/continuum-engine/src/inference/llama_server/control.rs +++ b/core/continuum-engine/src/inference/llama_server/control.rs @@ -255,6 +255,10 @@ pub trait LlamaServerControl: Send + Sync { None } + /// The resident minds the next launch keeps beside its lanes (`--minds`, fork #139): the seated minds plus + /// the learner's side sequence. Only the resident lane's controller holds them; no other lane is asked. + fn seat_minds(&self, _minds: std::num::NonZeroU32) {} + async fn serve_if_current( &self, target: &ServingTarget, diff --git a/core/continuum-engine/src/inference/llama_server/control_impl.rs b/core/continuum-engine/src/inference/llama_server/control_impl.rs index 53c48b37f6..63a74671a9 100644 --- a/core/continuum-engine/src/inference/llama_server/control_impl.rs +++ b/core/continuum-engine/src/inference/llama_server/control_impl.rs @@ -477,6 +477,10 @@ impl LlamaServerControl for LlamaServerProcess { self.last_started.lock().clone() } + fn seat_minds(&self, minds: std::num::NonZeroU32) { + self.seated_minds.store(minds.get(), std::sync::atomic::Ordering::Relaxed); + } + async fn serve_if_current( &self, target: &ServingTarget, diff --git a/core/continuum-engine/src/inference/llama_server/prepare.rs b/core/continuum-engine/src/inference/llama_server/prepare.rs index bec95445d4..ba85a38141 100644 --- a/core/continuum-engine/src/inference/llama_server/prepare.rs +++ b/core/continuum-engine/src/inference/llama_server/prepare.rs @@ -306,7 +306,8 @@ impl LlamaServerProcess { max_ubatch: target.model.serving.max_ubatch, reasoning_budget: target.model.serving.reasoning_budget, }); - let minds = super::genome::engine_accepts_minds(&bin).then_some(target.minds); + let seated = std::num::NonZeroU32::new(self.seated_minds.load(std::sync::atomic::Ordering::Relaxed)); + let minds = seated.filter(|_| super::genome::engine_accepts_minds(&bin)); let mut invocation = super::shared_pool::on_shared_pool(invocation, minds); // MoE glass-box env seam (#278): when expert paging is active, the DAEMON // hands the fork its capture + plan file locations. Previously these envs @@ -493,7 +494,8 @@ impl LlamaServerProcess { let ambiguous_adapter = lora_paths .iter() .any(|p| p.to_str().is_none_or(|p| p.contains(','))); - let local_inputs = if !cfg!(windows) || engine_install.is_none() { + // the receipt is made only where the engine contract exists (`EngineInstallReceipt::load`): none elsewhere + let local_inputs = if engine_install.is_none() { Err( "exact restoration requires original Windows application and local input pins" .into(), diff --git a/core/continuum-engine/src/inference/llama_server/process.rs b/core/continuum-engine/src/inference/llama_server/process.rs index 266f588e69..ddc2958017 100644 --- a/core/continuum-engine/src/inference/llama_server/process.rs +++ b/core/continuum-engine/src/inference/llama_server/process.rs @@ -93,6 +93,9 @@ pub struct LlamaServerProcess { /// what the running process was given, read by the serving daemon into the /// snapshot — never the plan's latest derivation of what it would give. pub(super) launched_prompt_cache_mib: std::sync::atomic::AtomicU32, + /// Resident minds the next launch keeps beside its lanes as parked sequences (`--minds`, fork #139), seated + /// by the serving daemon ([`super::LlamaServerControl::seat_minds`]). 0: none (every ephemeral lane). + pub(super) seated_minds: std::sync::atomic::AtomicU32, } @@ -160,6 +163,7 @@ impl LlamaServerProcess { smoke_proven_thinking: std::sync::atomic::AtomicBool::new(false), mmproj_on_lane: std::sync::atomic::AtomicU8::new(0), launched_prompt_cache_mib: std::sync::atomic::AtomicU32::new(0), + seated_minds: std::sync::atomic::AtomicU32::new(0), } } @@ -198,6 +202,7 @@ impl LlamaServerProcess { smoke_proven_thinking: std::sync::atomic::AtomicBool::new(false), mmproj_on_lane: std::sync::atomic::AtomicU8::new(0), launched_prompt_cache_mib: std::sync::atomic::AtomicU32::new(0), + seated_minds: std::sync::atomic::AtomicU32::new(0), } } diff --git a/core/continuum-engine/src/inference/llama_server/shared_pool.rs b/core/continuum-engine/src/inference/llama_server/shared_pool.rs index 29b68253b8..dbb89cc45f 100644 --- a/core/continuum-engine/src/inference/llama_server/shared_pool.rs +++ b/core/continuum-engine/src/inference/llama_server/shared_pool.rs @@ -28,11 +28,11 @@ const RESIDENT_MINDS: &str = "--minds"; /// Launch on the shared pool: every sequence draws on all of `-c`, and an idle one keeps what /// she holds until the core pages her. `minds`: parked sequence ids beside the lanes, given only to an engine -/// that lists `--minds`: the seated minds plus one side sequence for learning (`ServingTarget::minds`). -pub(super) fn on_shared_pool(mut invocation: LaneInvocation, minds: Option) -> LaneInvocation { +/// that lists `--minds`: the seated minds plus one side sequence for learning (`LlamaServerControl::seat_minds`). +pub(super) fn on_shared_pool(mut invocation: LaneInvocation, minds: Option) -> LaneInvocation { invocation.args.push(SHARED_POOL.to_string()); invocation.args.push(KEEP_IDLE_SLOTS.to_string()); - if let Some(n) = minds.filter(|n| *n > 0) { + if let Some(n) = minds { invocation.args.push(RESIDENT_MINDS.to_string()); invocation.args.push(n.to_string()); } diff --git a/core/continuum-engine/src/inference/llama_server/target.rs b/core/continuum-engine/src/inference/llama_server/target.rs index 2d3218258d..a069f8a52d 100644 --- a/core/continuum-engine/src/inference/llama_server/target.rs +++ b/core/continuum-engine/src/inference/llama_server/target.rs @@ -43,9 +43,6 @@ pub struct ServingTarget { /// lanes` of KV against the host budget, so `-c (context_window * lanes)` /// is memory-safe by the planner's own arithmetic. pub lanes: u32, - /// Resident minds the engine keeps beside its lanes as parked sequences (`--minds`, fork #139): the seated - /// minds plus one side sequence for learning. 0: none (a single-purpose lane). - pub minds: u32, /// The trained LoRA genome layers to load into the serving catalog at spawn /// (`llama-server --lora ` per entry). This is the SET — which genes /// are *loadable*; the per-request `"lora":[{id,scale}]` body field decides diff --git a/core/continuum-engine/src/inference/llama_server/test_fixtures.rs b/core/continuum-engine/src/inference/llama_server/test_fixtures.rs index 557127ace2..89c4fe6615 100644 --- a/core/continuum-engine/src/inference/llama_server/test_fixtures.rs +++ b/core/continuum-engine/src/inference/llama_server/test_fixtures.rs @@ -15,7 +15,6 @@ pub fn generation_has_exited(generation: &crate::inference::slots::EngineGenerat pub(super) fn target(id: &str) -> ServingTarget { use crate::model_registry::types::{Arch, MultiPartyChatStrategy}; ServingTarget { - minds: 0, // a single-purpose lane keeps no resident minds host_prompt_cache_mib: crate::inference::lane_args::CACHE_RAM_MIB, model: Model { weights_bytes: None, diff --git a/core/continuum-engine/src/inference/llama_server/tests/engine_install.rs b/core/continuum-engine/src/inference/llama_server/tests/engine_install.rs index e3f69e3b33..b3732ec210 100644 --- a/core/continuum-engine/src/inference/llama_server/tests/engine_install.rs +++ b/core/continuum-engine/src/inference/llama_server/tests/engine_install.rs @@ -120,7 +120,7 @@ fn the_engine_launches_on_one_shared_pool() { Path::new("fixture.gguf"), planned.model_id(), "127.0.0.1", 1, planned.parallel_lanes(), planned.served_total_ctx(), planned.host_prompt_cache_mib, Path::new("pages"), - ), Some(planned.parallel_lanes())); + ), std::num::NonZeroU32::new(planned.parallel_lanes())); assert_eq!(invocation.value_of("-c"), Some("290560")); assert_eq!(invocation.value_of("--parallel"), Some("5")); // what this catches: a mind switch serialized through the prompt cache because the engine had no parked ids diff --git a/core/continuum-engine/src/inference/minds.rs b/core/continuum-engine/src/inference/minds.rs index 37fda47867..a3a27a2182 100644 --- a/core/continuum-engine/src/inference/minds.rs +++ b/core/continuum-engine/src/inference/minds.rs @@ -3,56 +3,26 @@ //! An engine that declares `resident_minds` on `/props` keeps every mind it serves as a sequence of its unified //! KV pool (parked when another mind holds the lane) or, when the pool needs her cells, as a page on flash it maps //! back in. A turn names its mind (`"page"`, [`super::slots::PageKey::engine_id`]) so the engine moves the right -//! sequence; and while she waits for a lane, her state is streamed in ahead of her turn, the way a game engine -//! streams what the camera needs next, so her switch is the sub-millisecond sequence move. +//! sequence; and while she waits for a lane her state streams in, the way a game engine streams what the camera +//! needs next, so her switch is the sub-millisecond sequence move. use super::slots::PageKey; -use std::collections::HashSet; -use std::sync::{Mutex, OnceLock}; +use super::weight_residency::ResidentMinds; -/// Streams in flight, one per (engine root, mind): a mind waiting on several turns streams once. -fn in_flight() -> &'static Mutex> { - static SET: OnceLock>> = OnceLock::new(); - SET.get_or_init(Mutex::default) -} - -/// Ask the engine at `root` (process `engine_pid`, from the slot pool's incarnation) to bring `key`'s mind into -/// its pool now (`POST /minds/prefetch`). Only an engine that DECLARED resident minds is asked (never a 404 -/// guess); the engine refuses a request meant for another process (`engine_pid`), so a stream never lands on a -/// replacement engine; one stream per (engine, mind) at a time. It never delays her turn. -pub(crate) fn prefetch(client: reqwest::Client, root: String, engine_pid: u32, key: PageKey) { - if !super::slots::resident_minds_by_root().contains_key(&root) { - return; // this engine pages minds through the core: nothing to stream - } - let id = key.engine_id(); - match in_flight().lock() { - Ok(mut set) => { - if !set.insert((root.clone(), id)) { - return; // already streaming her in - } - } - Err(_) => return, // a poisoned set: no stream, her turn is not delayed - } - tokio::spawn(async move { - let url = format!("{}/minds/prefetch", root.trim_end_matches('/')); - let body = serde_json::json!({ "page": id.simple().to_string(), "engine_pid": engine_pid }); - let (status, reply) = match client.post(&url).json(&body).send().await { - Ok(response) => { - let status = response.status().as_u16(); - (status, response.text().await.unwrap_or_default()) // unwrap_or_default: an unreadable body keeps its status - } - Err(e) => (0, e.to_string()), - }; - if let Ok(mut set) = in_flight().lock() { - set.remove(&(root.clone(), id)); - } - continuum_base::probe!( - class = "inference.minds.prefetch", - page = %key, - engine_pid = u64::from(engine_pid), - status = u64::from(status), - reply = reply.as_str(), - "her state streamed in ahead of her turn (the engine's reply names where she is)" - ); - }); +/// Bring `key`'s mind into the pool of the engine at `root` (`POST /minds/prefetch`), carrying the incarnation +/// token that engine declared (`minds`), so a replaced engine refuses it. The turn waiting for a lane owns this +/// future: admitted, or cancelled, it is dropped with her wait; it never runs for a turn that did not wait. +pub(crate) async fn prefetch(client: &reqwest::Client, root: &str, minds: ResidentMinds, key: PageKey) { + let url = format!("{}/minds/prefetch", root.trim_end_matches('/')); + let body = serde_json::json!({ "page": key.engine_id().simple().to_string(), "incarnation": minds.incarnation }); + let outcome = match client.post(&url).json(&body).send().await { + Ok(response) => response.status().as_u16().to_string(), + Err(e) => e.to_string(), + }; + continuum_base::probe!( + class = "inference.minds.prefetch", + page = %key, + outcome = outcome.as_str(), + "her state streamed in while she waited for a lane (the engine's reply names where she is)" + ); } diff --git a/core/continuum-engine/src/inference/slots.rs b/core/continuum-engine/src/inference/slots.rs index 871389cbec..cf0919c88a 100644 --- a/core/continuum-engine/src/inference/slots.rs +++ b/core/continuum-engine/src/inference/slots.rs @@ -73,7 +73,6 @@ mod adopted_replacement; mod discover; pub use discover::{PoolDiscoveryMiss, PropsAbsent}; pub(crate) use discover::served_ctx_by_root; -pub(crate) use discover::resident_minds_by_root; mod checkpoint_failure; pub use checkpoint_failure::{CheckpointFailure, OwnedCheckpointRefusal, SaveFailure}; use checkpoint_failure::CheckpointSave; diff --git a/core/continuum-engine/src/inference/slots/citizen_slots.rs b/core/continuum-engine/src/inference/slots/citizen_slots.rs index 9d93787cba..97d504b1e8 100644 --- a/core/continuum-engine/src/inference/slots/citizen_slots.rs +++ b/core/continuum-engine/src/inference/slots/citizen_slots.rs @@ -194,6 +194,9 @@ pub struct KvSlotPool { /// one it verified (`slots/discover.rs`), with or without a page ledger: the identity every /// endpoint admission on this pool is bound to (`EndpointAdmission::incarnation`). pub(super) incarnation: std::sync::OnceLock<(u32, u64)>, + /// The engine's resident minds (fork #139), from the same `/props` that installed this pool and set before + /// the pool is published: a pool and its paging authority are visible together or not at all. + pub(super) resident_minds: std::sync::OnceLock, /// Numbers each change of [`Self::saved`] for the ledger, so a write taken outside the /// lock never replaces a newer one ([`Self::ledger_snapshot`]). pub(super) ledger_generation: AtomicU64, diff --git a/core/continuum-engine/src/inference/slots/discover.rs b/core/continuum-engine/src/inference/slots/discover.rs index 31f96977b1..de1423dfce 100644 --- a/core/continuum-engine/src/inference/slots/discover.rs +++ b/core/continuum-engine/src/inference/slots/discover.rs @@ -42,6 +42,9 @@ pub enum PoolDiscoveryMiss { /// The pool already installed for this server disagrees with what `/props` reports. #[error("installed pool has {installed} slots, props reports {props}")] GeometryMismatch { installed: u32, props: u32 }, + /// The installed pool's resident-minds declaration (or its incarnation token) is not this `/props`'s. + #[error("installed pool's resident minds disagree with props")] + MindsMismatch, /// The page-admission negotiation refused this pool. #[error("page admission refused this pool")] PageAdmissionRefused, @@ -71,6 +74,7 @@ impl PoolDiscoveryMiss { Self::NoGeometry => "no_geometry", Self::Superseded => "superseded", Self::GeometryMismatch { .. } => "geometry_mismatch", + Self::MindsMismatch => "minds_mismatch", Self::PageAdmissionRefused => "page_admission_refused", } } @@ -116,13 +120,6 @@ pub(crate) fn served_ctx_by_root() -> &'static dashmap::DashMap { CTX.get_or_init(dashmap::DashMap::new) } -/// Which engines declared that they own mind switches (`/props.context_geometry.resident_minds`, fork #139), -/// recorded from the same `/props` body that installs the pool. Absent: not declared (the core pages minds). -pub(crate) fn resident_minds_by_root() -> &'static dashmap::DashMap { - static MINDS: std::sync::OnceLock> = std::sync::OnceLock::new(); - MINDS.get_or_init(dashmap::DashMap::new) -} - /// Does this `/props` status PROVE the endpoint does not exist — the only verdict /// allowed to latch the slot directory Unsupported for the process's life? 404/501 /// are the server saying "no such surface"; everything else (above all the 503 of a @@ -193,15 +190,6 @@ impl SlotDirectory { { served_ctx_by_root().insert(root.to_owned(), n_ctx as u32); } - // whether this engine owns mind switches, declared in the same body (never inferred from a 404) - match crate::inference::weight_residency::ContextGeometry::from_props(&body).and_then(|g| g.resident_minds) { - Some(minds) => { - resident_minds_by_root().insert(root.to_owned(), minds); - } - None => { - resident_minds_by_root().remove(root); - } - } // Missing geometry is not proof that activity paging is unsupported. let n_slots = match body.get("total_slots").and_then(|v| v.as_u64()) { Some(n) if n > 0 => n as u32, @@ -213,13 +201,23 @@ impl SlotDirectory { // The directory arbitrates the probe race: only the first writer installs the pool, once // per SERVER, and it installs it with its page store already settled. A pool known here // was published by that writer, so no caller ever admits against an undecided store. + // whether this engine owns mind switches, declared in the same body (never inferred from a 404) + let minds = crate::inference::weight_residency::ContextGeometry::from_props(&body).and_then(|g| g.resident_minds); let pool = match existing_pool { Some(pool) => pool, - None => self.install_settled_pool(root, n_slots, |pool| settle_adopted_page_store(pool, root)), + None => self.install_settled_pool(root, n_slots, |pool| { + if let Some(minds) = minds { + let _ = pool.resident_minds.set(minds); // a fresh candidate no other caller sees: the first set + } + settle_adopted_page_store(pool, root) + }), }; if pool.n_slots() != n_slots { return Err(Miss::GeometryMismatch { installed: pool.n_slots(), props: n_slots }); // they must agree } + if pool.resident_minds() != minds { + return Err(Miss::MindsMismatch); // the installed pool's paging authority belongs to another engine + } if !self.negotiate_page_admission(root, &pool, discovery_generation, body.get("slot_save_size_version")).await { return Err(Miss::PageAdmissionRefused); } diff --git a/core/continuum-engine/src/inference/slots/kv_slot_pool.rs b/core/continuum-engine/src/inference/slots/kv_slot_pool.rs index 7a03e90118..3e05c83f01 100644 --- a/core/continuum-engine/src/inference/slots/kv_slot_pool.rs +++ b/core/continuum-engine/src/inference/slots/kv_slot_pool.rs @@ -63,6 +63,7 @@ impl KvSlotPool { scratch_released: Arc::new(tokio::sync::Notify::new()), ledger: std::sync::OnceLock::new(), incarnation: std::sync::OnceLock::new(), + resident_minds: std::sync::OnceLock::new(), ledger_generation: AtomicU64::new(0), sequences: Mutex::new(LiveSequences::default()), } @@ -130,6 +131,12 @@ impl KvSlotPool { self.incarnation.get().copied() } + /// Whether this pool's engine owns mind switches (fork #139), as its `/props` declared when the pool was + /// installed. `None`: the core pages minds itself. + pub(crate) fn resident_minds(&self) -> Option { + self.resident_minds.get().copied() + } + pub fn n_slots(&self) -> u32 { self.n_slots } diff --git a/core/continuum-engine/src/inference/slots/page_key.rs b/core/continuum-engine/src/inference/slots/page_key.rs index f978d18c90..d567d4c699 100644 --- a/core/continuum-engine/src/inference/slots/page_key.rs +++ b/core/continuum-engine/src/inference/slots/page_key.rs @@ -100,10 +100,7 @@ impl PageKey { match self { Self::Mind(m) => m.persona(), Self::Fork(k) => { - let mut name = [0u8; 32]; - name[..16].copy_from_slice(k.persona.as_bytes()); - name[16..].copy_from_slice(k.room.as_bytes()); - Uuid::new_v5(&FORK_ENGINE_NAMESPACE, &name) + Uuid::new_v5(&FORK_ENGINE_NAMESPACE, &[*k.persona.as_bytes(), *k.room.as_bytes()].concat()) } } } diff --git a/core/continuum-engine/src/inference/vision_sidecar.rs b/core/continuum-engine/src/inference/vision_sidecar.rs index 4b1875b70d..b0fb84abe5 100644 --- a/core/continuum-engine/src/inference/vision_sidecar.rs +++ b/core/continuum-engine/src/inference/vision_sidecar.rs @@ -247,7 +247,6 @@ pub async fn ensure_sidecar( } let target = ServingTarget { - minds: 0, // a single-purpose lane keeps no resident minds // Single-purpose lane: no citizen population to derive from — the // declared cold-start prior is the honest value (restore-economy 1.b). host_prompt_cache_mib: crate::inference::lane_args::CACHE_RAM_MIB, diff --git a/core/continuum-engine/src/inference/weight_residency.rs b/core/continuum-engine/src/inference/weight_residency.rs index 69fdafe64f..5bfbd532c3 100644 --- a/core/continuum-engine/src/inference/weight_residency.rs +++ b/core/continuum-engine/src/inference/weight_residency.rs @@ -182,11 +182,31 @@ pub struct ContextGeometry { pub resident_minds: Option, } -/// What an engine that owns mind switches reports: its lanes and the parked sequence ids beside them. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +/// What an engine that owns mind switches reports: its lanes, the parked sequence ids beside them, and the token +/// it drew for this incarnation (a prefetch carries it back, so a replaced engine refuses a stream meant for another). +#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Deserialize)] pub struct ResidentMinds { pub lanes: u64, pub parked_ids: u64, + pub incarnation: u64, +} + +/// `/props.context_geometry` as the fork writes it, decoded once. +#[derive(serde::Deserialize)] +struct GeometryWire { + allocated_tokens: u64, + max_tokens_per_sequence: u64, + sequence_capacity: u64, + #[serde(default)] + resident_minds: Option, +} + +/// `resident_minds`: with `enabled` false (no `--minds`) the rest means nothing. +#[derive(serde::Deserialize)] +struct MindsWire { + enabled: bool, + #[serde(flatten)] + minds: Option, } impl ContextGeometry { @@ -205,20 +225,17 @@ impl ContextGeometry { /// `None` when the engine reports no geometry (not our fork) or one that does not hold /// together: zero tokens, no sequence, or one sequence allowed more than the pool. pub fn from_props(props: &serde_json::Value) -> Option { - let geometry = props.get("context_geometry")?; - let read = |field: &str| geometry.get(field)?.as_u64(); - let minds = geometry.get("resident_minds"); - let resident_minds = match minds.and_then(|m| m.get("enabled")).and_then(|e| e.as_bool()) { - Some(true) => Some(ResidentMinds { - lanes: minds.and_then(|m| m.get("lanes")).and_then(|v| v.as_u64())?, - parked_ids: minds.and_then(|m| m.get("parked_ids")).and_then(|v| v.as_u64())?, - }), - _ => None, + use serde::Deserialize as _; + let wire = GeometryWire::deserialize(props.get("context_geometry")?).ok()?; + let resident_minds = match wire.resident_minds { + Some(MindsWire { enabled: true, minds: Some(minds) }) => Some(minds), + Some(MindsWire { enabled: true, minds: None }) => return None, // declared but not whole: no geometry to trust + Some(MindsWire { enabled: false, .. }) | None => None, }; let reported = Self { - allocated_tokens: read("allocated_tokens")?, - max_tokens_per_sequence: read("max_tokens_per_sequence")?, - sequence_capacity: read("sequence_capacity")?, + allocated_tokens: wire.allocated_tokens, + max_tokens_per_sequence: wire.max_tokens_per_sequence, + sequence_capacity: wire.sequence_capacity, resident_minds, }; (reported.allocated_tokens > 0 @@ -235,8 +252,11 @@ impl ContextGeometry { fn allocated_capacity(props: &serde_json::Value, slots: u32, n_ctx_per_slot: u32) -> Option { let geometry = ContextGeometry::from_props(props)?; // an engine keeping resident minds holds its lanes AND their parked ids as sequences - let parked = geometry.resident_minds.map_or(0, |m| m.parked_ids); - (geometry.sequence_capacity == u64::from(slots) + parked && u64::from(n_ctx_per_slot) <= geometry.max_tokens_per_sequence) + let sequences = match geometry.resident_minds { + Some(minds) => u64::from(slots) + minds.parked_ids, + None => u64::from(slots), + }; + (geometry.sequence_capacity == sequences && u64::from(n_ctx_per_slot) <= geometry.max_tokens_per_sequence) .then_some(geometry.allocated_tokens) } diff --git a/core/continuum-serving/src/modules/serving_daemon/launch.rs b/core/continuum-serving/src/modules/serving_daemon/launch.rs index 35483bd92b..6b8ffa1faa 100644 --- a/core/continuum-serving/src/modules/serving_daemon/launch.rs +++ b/core/continuum-serving/src/modules/serving_daemon/launch.rs @@ -220,9 +220,10 @@ impl ServingDaemonModule { } } // the engine keeps every seated mind resident beside its lanes, plus one side sequence for learning - let minds = u32::try_from(self.seated_needs(&model).len()).map_or(u32::MAX, |n| n.saturating_add(1)); + if let Some(minds) = u32::try_from(self.seated_needs(&model).len()).ok().and_then(|n| n.checked_add(1)).and_then(std::num::NonZeroU32::new) { + self.server.seat_minds(minds); + } let target = ServingTarget { - minds, host_prompt_cache_mib, model, context_window: per_sequence, diff --git a/core/continuum-serving/src/modules/serving_daemon/tests/engine_admission.rs b/core/continuum-serving/src/modules/serving_daemon/tests/engine_admission.rs index d2ffb21b09..612006639b 100644 --- a/core/continuum-serving/src/modules/serving_daemon/tests/engine_admission.rs +++ b/core/continuum-serving/src/modules/serving_daemon/tests/engine_admission.rs @@ -107,7 +107,6 @@ fn the_sidecar_headroom_is_planned_not_a_relaunch_window_free_read() { model.weights_bytes = Some(21 * 1024 * 1024 * 1024); model.context_window = 262_144; let target = ServingTarget { - minds: 0, // a single-purpose lane keeps no resident minds host_prompt_cache_mib: 2505, model, context_window: 59_392, @@ -133,7 +132,6 @@ fn the_sidecar_headroom_is_planned_not_a_relaunch_window_free_read() { let mut blind = target.model.clone(); blind.weights_bytes = None; let blind_target = ServingTarget { - minds: 0, // a single-purpose lane keeps no resident minds model: blind, ..target.clone() }; From 99ea7c105e5f1f239e8e2fe36266fa16bd5ba7b0 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Mon, 16 Nov 2026 15:16:56 -0600 Subject: [PATCH 04/10] Resident minds: the pool is built with its minds descriptor (no fallible set whose result is dropped; swallowed_errors ratchet) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- .../src/inference/slots/citizen_slots.rs | 6 +++--- core/continuum-engine/src/inference/slots/discover.rs | 10 +++------- .../src/inference/slots/kv_slot_pool.rs | 10 ++++++++-- .../src/inference/slots/tests/discover.rs | 4 ++-- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/core/continuum-engine/src/inference/slots/citizen_slots.rs b/core/continuum-engine/src/inference/slots/citizen_slots.rs index 97d504b1e8..16afe8a1fd 100644 --- a/core/continuum-engine/src/inference/slots/citizen_slots.rs +++ b/core/continuum-engine/src/inference/slots/citizen_slots.rs @@ -194,9 +194,9 @@ pub struct KvSlotPool { /// one it verified (`slots/discover.rs`), with or without a page ledger: the identity every /// endpoint admission on this pool is bound to (`EndpointAdmission::incarnation`). pub(super) incarnation: std::sync::OnceLock<(u32, u64)>, - /// The engine's resident minds (fork #139), from the same `/props` that installed this pool and set before - /// the pool is published: a pool and its paging authority are visible together or not at all. - pub(super) resident_minds: std::sync::OnceLock, + /// The engine's resident minds (fork #139), from the same `/props` that installed this pool, given when the + /// pool is built: a pool and its paging authority are visible together or not at all. + pub(super) resident_minds: Option, /// Numbers each change of [`Self::saved`] for the ledger, so a write taken outside the /// lock never replaces a newer one ([`Self::ledger_snapshot`]). pub(super) ledger_generation: AtomicU64, diff --git a/core/continuum-engine/src/inference/slots/discover.rs b/core/continuum-engine/src/inference/slots/discover.rs index de1423dfce..7071cf9e56 100644 --- a/core/continuum-engine/src/inference/slots/discover.rs +++ b/core/continuum-engine/src/inference/slots/discover.rs @@ -205,12 +205,7 @@ impl SlotDirectory { let minds = crate::inference::weight_residency::ContextGeometry::from_props(&body).and_then(|g| g.resident_minds); let pool = match existing_pool { Some(pool) => pool, - None => self.install_settled_pool(root, n_slots, |pool| { - if let Some(minds) = minds { - let _ = pool.resident_minds.set(minds); // a fresh candidate no other caller sees: the first set - } - settle_adopted_page_store(pool, root) - }), + None => self.install_settled_pool(root, n_slots, minds, |pool| settle_adopted_page_store(pool, root)), }; if pool.n_slots() != n_slots { return Err(Miss::GeometryMismatch { installed: pool.n_slots(), props: n_slots }); // they must agree @@ -243,9 +238,10 @@ impl SlotDirectory { &self, root: &str, n_slots: u32, + minds: Option, settle: impl FnOnce(&KvSlotPool) -> SettledPageStore, ) -> Arc { - let candidate = Arc::new(KvSlotPool::new(root, n_slots)); + let candidate = Arc::new(KvSlotPool::new(root, n_slots).with_resident_minds(minds)); let settled = settle(&candidate); let pool = self.install_pool(root, || Arc::clone(&candidate)); if Arc::ptr_eq(&pool, &candidate) { diff --git a/core/continuum-engine/src/inference/slots/kv_slot_pool.rs b/core/continuum-engine/src/inference/slots/kv_slot_pool.rs index 3e05c83f01..2abf898df3 100644 --- a/core/continuum-engine/src/inference/slots/kv_slot_pool.rs +++ b/core/continuum-engine/src/inference/slots/kv_slot_pool.rs @@ -63,7 +63,7 @@ impl KvSlotPool { scratch_released: Arc::new(tokio::sync::Notify::new()), ledger: std::sync::OnceLock::new(), incarnation: std::sync::OnceLock::new(), - resident_minds: std::sync::OnceLock::new(), + resident_minds: None, ledger_generation: AtomicU64::new(0), sequences: Mutex::new(LiveSequences::default()), } @@ -134,7 +134,13 @@ impl KvSlotPool { /// Whether this pool's engine owns mind switches (fork #139), as its `/props` declared when the pool was /// installed. `None`: the core pages minds itself. pub(crate) fn resident_minds(&self) -> Option { - self.resident_minds.get().copied() + self.resident_minds + } + + /// This pool, for an engine that declared resident minds on the `/props` that installs it. + pub(super) fn with_resident_minds(mut self, minds: Option) -> Self { + self.resident_minds = minds; + self } pub fn n_slots(&self) -> u32 { diff --git a/core/continuum-engine/src/inference/slots/tests/discover.rs b/core/continuum-engine/src/inference/slots/tests/discover.rs index d0285719f0..46fd2bae9a 100644 --- a/core/continuum-engine/src/inference/slots/tests/discover.rs +++ b/core/continuum-engine/src/inference/slots/tests/discover.rs @@ -102,7 +102,7 @@ async fn an_admission_racing_the_ledger_adoption_restores_her_page() -> Result<( let first_probe = tokio::task::spawn_blocking({ let (dir, pages) = (Arc::clone(&dir), pages.path().to_path_buf()); move || { - dir.install_settled_pool(root, 2, |pool| { + dir.install_settled_pool(root, 2, None, |pool| { let _ = reading.send(()); let _ = resume.recv(); // test: held until the admission has looked let (adoption, snapshot) = @@ -125,7 +125,7 @@ async fn an_admission_racing_the_ledger_adoption_restores_her_page() -> Result<( assert!(pool.plan_paging(slot, aris).restore, "her first turn after the restart restores, never a cold prefill"); // A second settled install (a racing probe) loses: the published pool and its settlement stand. - let second = dir.install_settled_pool(root, 2, |_| SettledPageStore { adoption: Err(NotAdopted::NoLiveLaneRecord), snapshot: None }); + let second = dir.install_settled_pool(root, 2, None, |_| SettledPageStore { adoption: Err(NotAdopted::NoLiveLaneRecord), snapshot: None }); assert!(Arc::ptr_eq(&second, &pool), "one pool per root"); Ok(()) } From d5c4e5dcacb7b2b1be2b11ab62d92a62e7b7f736 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Mon, 16 Nov 2026 20:53:26 -0600 Subject: [PATCH 05/10] Pin the engine to fork #139's head (0df8dc443): the core's resident-minds side runs against the engine that switches minds, so CI tests the pair, not two halves apart #139 is the shipping line (f39cf25fb) plus resident minds: a mind switch is a sequence move in milliseconds through the pool and flash, prefetch from flash while others decode, typed receipts, incarnation, learn pins. Re-pinned to the shipping line's merge commit once #139 lands. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- core/vendor/LLAMA_CPP_PIN | 2 +- core/vendor/llama.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/vendor/LLAMA_CPP_PIN b/core/vendor/LLAMA_CPP_PIN index 5f0a504f5f..3036fa5ccd 100644 --- a/core/vendor/LLAMA_CPP_PIN +++ b/core/vendor/LLAMA_CPP_PIN @@ -1 +1 @@ -f39cf25fbd3d95c69302fdf38d43dae2002b5f3e +0df8dc443f60bdbeba8fb1a93e4182e2dea8f77f diff --git a/core/vendor/llama.cpp b/core/vendor/llama.cpp index f39cf25fbd..0df8dc443f 160000 --- a/core/vendor/llama.cpp +++ b/core/vendor/llama.cpp @@ -1 +1 @@ -Subproject commit f39cf25fbd3d95c69302fdf38d43dae2002b5f3e +Subproject commit 0df8dc443f60bdbeba8fb1a93e4182e2dea8f77f From 37a354cf281dfcc7d5f6d672ac063879e7c217f9 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Mon, 16 Nov 2026 20:59:58 -0600 Subject: [PATCH 06/10] Re-pin the engine to fork #139 945a742c3b (Codex's four P1s fixed) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- core/vendor/LLAMA_CPP_PIN | 2 +- core/vendor/llama.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/vendor/LLAMA_CPP_PIN b/core/vendor/LLAMA_CPP_PIN index 3036fa5ccd..6705f90528 100644 --- a/core/vendor/LLAMA_CPP_PIN +++ b/core/vendor/LLAMA_CPP_PIN @@ -1 +1 @@ -0df8dc443f60bdbeba8fb1a93e4182e2dea8f77f +945a742c3bc5b3e94845356b828e22422a53b52b diff --git a/core/vendor/llama.cpp b/core/vendor/llama.cpp index 0df8dc443f..945a742c3b 160000 --- a/core/vendor/llama.cpp +++ b/core/vendor/llama.cpp @@ -1 +1 @@ -Subproject commit 0df8dc443f60bdbeba8fb1a93e4182e2dea8f77f +Subproject commit 945a742c3bc5b3e94845356b828e22422a53b52b From 14fd635dfbb54cf088b3c68473e0c7939ce8bd04 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Mon, 16 Nov 2026 23:24:55 -0600 Subject: [PATCH 07/10] A pool records its engine's declared minds once; an owned spawn's pool no longer mismatches forever (M5 outage 2026-11-17 04:20Z) An owned spawn publishes its pool at readiness (engine_generation.rs EndpointTransition::ready) from its launch contract, which carries no minds declaration, so the pool held resident_minds = None; discovery compared that None to the engine's declared minds and returned MindsMismatch on every request for the engine's life (every resident's deliberation refused, ~10 /props re-probes a second; the M5 after a --prebuilt restore spawned the engine itself). 03:03Z worked because that engine's pool was installed by discovery, which records minds from /props. The pool's resident minds are now a set-once record of the engine's own declaration (OnceLock, the same shape as its incarnation): discovery records it when it installs a pool; a pool an owned spawn published has no record until its first discovery records the engine's declaration; only a recorded, DIFFERENT declaration is MindsMismatch. With the record set, discovery reaches page admission and the steady-state fast path instead of re-probing. Not compiled locally (the M5 is a serving node); CI is the check. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- .../src/inference/slots/citizen_slots.rs | 7 +++--- .../src/inference/slots/discover.rs | 2 +- .../src/inference/slots/kv_slot_pool.rs | 19 +++++++++++----- .../src/inference/slots/tests/discover.rs | 22 +++++++++++++++++++ 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/core/continuum-engine/src/inference/slots/citizen_slots.rs b/core/continuum-engine/src/inference/slots/citizen_slots.rs index 16afe8a1fd..aa37ed20f8 100644 --- a/core/continuum-engine/src/inference/slots/citizen_slots.rs +++ b/core/continuum-engine/src/inference/slots/citizen_slots.rs @@ -194,9 +194,10 @@ pub struct KvSlotPool { /// one it verified (`slots/discover.rs`), with or without a page ledger: the identity every /// endpoint admission on this pool is bound to (`EndpointAdmission::incarnation`). pub(super) incarnation: std::sync::OnceLock<(u32, u64)>, - /// The engine's resident minds (fork #139), from the same `/props` that installed this pool, given when the - /// pool is built: a pool and its paging authority are visible together or not at all. - pub(super) resident_minds: Option, + /// The engine's resident minds (fork #139) as its `/props` declared them, recorded ONCE: by discovery when it + /// installs the pool, or by the first discovery of a pool an owned spawn published (a spawn knows its launch + /// contract, not the engine's declaration). Unset means not yet declared, never "no minds". + pub(super) resident_minds: std::sync::OnceLock>, /// Numbers each change of [`Self::saved`] for the ledger, so a write taken outside the /// lock never replaces a newer one ([`Self::ledger_snapshot`]). pub(super) ledger_generation: AtomicU64, diff --git a/core/continuum-engine/src/inference/slots/discover.rs b/core/continuum-engine/src/inference/slots/discover.rs index 7071cf9e56..357d11ba0f 100644 --- a/core/continuum-engine/src/inference/slots/discover.rs +++ b/core/continuum-engine/src/inference/slots/discover.rs @@ -210,7 +210,7 @@ impl SlotDirectory { if pool.n_slots() != n_slots { return Err(Miss::GeometryMismatch { installed: pool.n_slots(), props: n_slots }); // they must agree } - if pool.resident_minds() != minds { + if !pool.declare_resident_minds(minds) { return Err(Miss::MindsMismatch); // the installed pool's paging authority belongs to another engine } if !self.negotiate_page_admission(root, &pool, discovery_generation, body.get("slot_save_size_version")).await { diff --git a/core/continuum-engine/src/inference/slots/kv_slot_pool.rs b/core/continuum-engine/src/inference/slots/kv_slot_pool.rs index 2abf898df3..7200e3d259 100644 --- a/core/continuum-engine/src/inference/slots/kv_slot_pool.rs +++ b/core/continuum-engine/src/inference/slots/kv_slot_pool.rs @@ -63,7 +63,7 @@ impl KvSlotPool { scratch_released: Arc::new(tokio::sync::Notify::new()), ledger: std::sync::OnceLock::new(), incarnation: std::sync::OnceLock::new(), - resident_minds: None, + resident_minds: std::sync::OnceLock::new(), ledger_generation: AtomicU64::new(0), sequences: Mutex::new(LiveSequences::default()), } @@ -131,18 +131,25 @@ impl KvSlotPool { self.incarnation.get().copied() } - /// Whether this pool's engine owns mind switches (fork #139), as its `/props` declared when the pool was - /// installed. `None`: the core pages minds itself. + /// Whether this pool's engine owns mind switches (fork #139), as its `/props` declared. `None`: the core + /// pages minds itself, or the engine has not declared yet. pub(crate) fn resident_minds(&self) -> Option { - self.resident_minds + self.resident_minds.get().copied().flatten() } /// This pool, for an engine that declared resident minds on the `/props` that installs it. - pub(super) fn with_resident_minds(mut self, minds: Option) -> Self { - self.resident_minds = minds; + pub(super) fn with_resident_minds(self, minds: Option) -> Self { + let _ = self.resident_minds.set(minds); // a fresh pool: the first and only declaration self } + /// Record the engine's declared minds on first sight, or check them against the record: `false` only when + /// this pool already recorded a DIFFERENT declaration (its paging authority belongs to another engine). A pool + /// an owned spawn published has no record yet; its first discovery records the engine's own declaration. + pub(super) fn declare_resident_minds(&self, minds: Option) -> bool { + *self.resident_minds.get_or_init(|| minds) == minds + } + pub fn n_slots(&self) -> u32 { self.n_slots } diff --git a/core/continuum-engine/src/inference/slots/tests/discover.rs b/core/continuum-engine/src/inference/slots/tests/discover.rs index 46fd2bae9a..eb46e39411 100644 --- a/core/continuum-engine/src/inference/slots/tests/discover.rs +++ b/core/continuum-engine/src/inference/slots/tests/discover.rs @@ -129,3 +129,25 @@ async fn an_admission_racing_the_ledger_adoption_restores_her_page() -> Result<( assert!(Arc::ptr_eq(&second, &pool), "one pool per root"); Ok(()) } + +// what this catches: the M5 2026-11-17 04:20Z outage (regression for core 37a354cf2, #6087). An owned spawn +// publishes its pool at readiness from its launch contract, which carries no minds declaration; discovery then +// compared that pool's "no minds" to the engine's declared minds and refused EVERY generation (minds_mismatch, +// ~10 re-probes a second) for the engine's whole life. The pool's minds are a set-once record of the engine's +// own declaration: a pool with no record takes the first; only a recorded, different declaration mismatches. +#[test] +fn a_pool_records_the_engines_declared_minds_once() { + use crate::inference::weight_residency::ResidentMinds; + let minds = Some(ResidentMinds { lanes: 5, parked_ids: 5, incarnation: 4_077_290_934_432_821_903 }); + let other = Some(ResidentMinds { lanes: 5, parked_ids: 5, incarnation: 7 }); + + let owned = KvSlotPool::new("owned", 5); // as an owned spawn publishes it: no declaration yet + assert_eq!(owned.resident_minds(), None, "undeclared reads as no minds, never as a recorded none"); + assert!(owned.declare_resident_minds(minds), "the first discovery records the engine's declaration"); + assert_eq!(owned.resident_minds(), minds); + assert!(owned.declare_resident_minds(minds), "the same engine's declaration agrees"); + assert!(!owned.declare_resident_minds(other), "another engine's declaration is the mismatch"); + + let discovered = KvSlotPool::new("discovered", 5).with_resident_minds(None); // installed by a /props with no minds + assert!(!discovered.declare_resident_minds(minds), "a recorded 'no minds' is a declaration, not a blank"); +} From 5b2f48ae7e04ea2b74d70ecd6f627a641df9d4d3 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Mon, 16 Nov 2026 23:34:26 -0600 Subject: [PATCH 08/10] Page admission only on a declared pool; owned spawn -> discovery -> admission regression (Codex's 14fd635df review) - discover_page_admission (the lifecycle-checkpoint path, which can precede the first adapter discovery) now records the engine's declared minds from the same /props body before it grants page admission. Granted admission is discover_pool's fast path, so an owned pool admitted there undeclared would have been read as core-paged minds (stream.rs takes pool.resident_minds() only from a pool discover_pool returned). Both admission grants now follow the declaration; those two are the only writers of page admission (engine_generation.rs; readiness clears it). - with_resident_minds builds the record with OnceLock::from (no discarded set result: source-hygiene swallowed_errors). - slots/tests/discover.rs an_owned_spawn_learns_its_engines_minds_at_discovery: a fake engine declaring resident minds on /props, an owned ready generation, then discover_pool must accept the owned pool, record the declaration, grant admission, and the fast path must return the same declared pool (before the fix: MindsMismatch on every discovery). Not compiled locally (the M5 is a serving node); CI is the check. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- .../src/inference/slots/engine_generation.rs | 7 +++ .../src/inference/slots/kv_slot_pool.rs | 4 +- .../src/inference/slots/tests/discover.rs | 55 +++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/core/continuum-engine/src/inference/slots/engine_generation.rs b/core/continuum-engine/src/inference/slots/engine_generation.rs index 986e4978d1..f8d6bd77c8 100644 --- a/core/continuum-engine/src/inference/slots/engine_generation.rs +++ b/core/continuum-engine/src/inference/slots/engine_generation.rs @@ -764,6 +764,13 @@ impl SlotDirectory { if body.get("total_slots").and_then(serde_json::Value::as_u64) != Some(pool.n_slots() as u64) { return Err("page-write capabilities do not identify this pool geometry".into()); } + // Admission is granted only on a pool whose minds the engine has declared: this path can precede the first + // adapter discovery (a lifecycle checkpoint), and a granted admission is discovery's fast path, so an + // undeclared pool admitted here would be read as core-paged minds (M5 2026-11-17). + let minds = crate::inference::weight_residency::ContextGeometry::from_props(&body).and_then(|g| g.resident_minds); + if !pool.declare_resident_minds(minds) { + return Err("the engine's declared resident minds differ from this pool's record".into()); + } if !self.negotiate_page_admission(root, &pool, generation, body.get("slot_save_size_version")).await { return Err("engine changed during page-write discovery".into()); } diff --git a/core/continuum-engine/src/inference/slots/kv_slot_pool.rs b/core/continuum-engine/src/inference/slots/kv_slot_pool.rs index 7200e3d259..d5ac3b753a 100644 --- a/core/continuum-engine/src/inference/slots/kv_slot_pool.rs +++ b/core/continuum-engine/src/inference/slots/kv_slot_pool.rs @@ -138,8 +138,8 @@ impl KvSlotPool { } /// This pool, for an engine that declared resident minds on the `/props` that installs it. - pub(super) fn with_resident_minds(self, minds: Option) -> Self { - let _ = self.resident_minds.set(minds); // a fresh pool: the first and only declaration + pub(super) fn with_resident_minds(mut self, minds: Option) -> Self { + self.resident_minds = std::sync::OnceLock::from(minds); // a fresh pool: born holding its first and only declaration self } diff --git a/core/continuum-engine/src/inference/slots/tests/discover.rs b/core/continuum-engine/src/inference/slots/tests/discover.rs index eb46e39411..b3e8f6426e 100644 --- a/core/continuum-engine/src/inference/slots/tests/discover.rs +++ b/core/continuum-engine/src/inference/slots/tests/discover.rs @@ -151,3 +151,58 @@ fn a_pool_records_the_engines_declared_minds_once() { let discovered = KvSlotPool::new("discovered", 5).with_resident_minds(None); // installed by a /props with no minds assert!(!discovered.declare_resident_minds(minds), "a recorded 'no minds' is a declaration, not a blank"); } + +// what this catches: the M5 2026-11-17 outage end to end (owned spawn -> discovery -> admission). A core that +// spawns its engine publishes the pool at readiness from its launch contract; the engine declares its resident +// minds only on /props. Discovery must accept that owned pool, record the engine's declaration on it, and grant +// page admission, so the fast path afterwards returns the same, DECLARED pool (never an undeclared one read as +// core-paged minds). Before the fix every discovery here returned MindsMismatch. +#[tokio::test] +async fn an_owned_spawn_learns_its_engines_minds_at_discovery() { + use crate::inference::weight_residency::ResidentMinds; + let props = serde_json::json!({ + "total_slots": 2, + "context_geometry": { + "allocated_tokens": 8192, "max_tokens_per_sequence": 4096, "sequence_capacity": 4, + "resident_minds": {"enabled": true, "lanes": 2, "parked_ids": 2, "parked_free": 2, "incarnation": 42} + } + }); + let app = axum::Router::new() + .route("/props", axum::routing::get(move || { let props = props.clone(); async move { axum::Json(props) } })); + let namespace = format!("/{}", uuid::Uuid::new_v4()); // a recycled port is not this fixture engine + let app = axum::Router::new().nest(&namespace, app); + let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.expect("test: bind"); + let root = format!("http://{}{namespace}", listener.local_addr().expect("test: addr")); + let server = tokio::spawn(async move { axum::serve(listener, app).await.expect("test: serve") }); + + // the owned spawn: a ready generation publishes the pool from the launch contract + let dir = tempfile::tempdir().expect("test: page dir"); + let endpoint = directory().endpoint(&root); + let contract = KvPageContract { + model_id: "fixture".into(), + model: "fixture.gguf".into(), + adapters: vec![], + page_dir: Some(dir.path().to_path_buf()), + context: 8192, + slots: 2, + cache_type: Some("q8_0".into()), + flash_attn: Some(true), + revisions: Some(vec![("fixture.gguf".into(), 73, std::time::SystemTime::UNIX_EPOCH)]), + }; + let transition = endpoint.transition().await; + let generation = transition.start_generation().expect("test: generation"); + transition.ready(&root, &generation, contract).expect("test: ready"); + drop(transition); + let owned = endpoint.admit().await.expect("test: ready pool").pool.expect("test: managed pool"); + assert_eq!(owned.resident_minds(), None, "the spawn knows its contract, not the engine's declaration"); + + let declared = Some(ResidentMinds { lanes: 2, parked_ids: 2, incarnation: 42 }); + let client = reqwest::Client::new(); + let pool = directory().discover_pool(&client, &root).await.expect("discovery accepts the owned pool"); + assert!(Arc::ptr_eq(&pool, &owned), "the owned pool is the one discovered, not a replacement"); + assert_eq!(pool.resident_minds(), declared, "discovery recorded the engine's own declaration"); + assert!(directory().page_admission_known(&root), "page admission granted after the declaration"); + let again = directory().discover_pool(&client, &root).await.expect("the fast path"); + assert!(Arc::ptr_eq(&again, &owned) && again.resident_minds() == declared, "the fast path returns the declared pool"); + server.abort(); +} From 4944fb7145e500ec296eaf53429d3bab47def94a Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Mon, 16 Nov 2026 23:38:20 -0600 Subject: [PATCH 09/10] Regression: a lifecycle page admission first still declares the engine's minds (Codex on 5b2f48ae7) a_lifecycle_admission_first_still_declares_the_engines_minds: owned spawn, then discover_page_admission (the checkpoint path) FIRST, then the adapter's discover_pool fast path; the admitted owned pool must carry the engine's declared minds. This is the case the adapter-first test could not catch (it would pass with the lifecycle declaration omitted). Both tests share one fixture (owned_spawn_declaring_minds: fake engine /props declaring minds + an owned ready generation). Not compiled locally (serving node); CI is the check. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- .../src/inference/slots/tests/discover.rs | 43 +++++++++++++------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/core/continuum-engine/src/inference/slots/tests/discover.rs b/core/continuum-engine/src/inference/slots/tests/discover.rs index b3e8f6426e..98d533072f 100644 --- a/core/continuum-engine/src/inference/slots/tests/discover.rs +++ b/core/continuum-engine/src/inference/slots/tests/discover.rs @@ -152,14 +152,9 @@ fn a_pool_records_the_engines_declared_minds_once() { assert!(!discovered.declare_resident_minds(minds), "a recorded 'no minds' is a declaration, not a blank"); } -// what this catches: the M5 2026-11-17 outage end to end (owned spawn -> discovery -> admission). A core that -// spawns its engine publishes the pool at readiness from its launch contract; the engine declares its resident -// minds only on /props. Discovery must accept that owned pool, record the engine's declaration on it, and grant -// page admission, so the fast path afterwards returns the same, DECLARED pool (never an undeclared one read as -// core-paged minds). Before the fix every discovery here returned MindsMismatch. -#[tokio::test] -async fn an_owned_spawn_learns_its_engines_minds_at_discovery() { - use crate::inference::weight_residency::ResidentMinds; +/// A fake engine declaring resident minds on `/props`, and this core's owned spawn of it: a ready generation +/// whose pool was published from the launch contract (no minds declaration yet). +async fn owned_spawn_declaring_minds() -> (String, Arc, tempfile::TempDir, tokio::task::JoinHandle<()>) { let props = serde_json::json!({ "total_slots": 2, "context_geometry": { @@ -175,7 +170,6 @@ async fn an_owned_spawn_learns_its_engines_minds_at_discovery() { let root = format!("http://{}{namespace}", listener.local_addr().expect("test: addr")); let server = tokio::spawn(async move { axum::serve(listener, app).await.expect("test: serve") }); - // the owned spawn: a ready generation publishes the pool from the launch contract let dir = tempfile::tempdir().expect("test: page dir"); let endpoint = directory().endpoint(&root); let contract = KvPageContract { @@ -195,14 +189,39 @@ async fn an_owned_spawn_learns_its_engines_minds_at_discovery() { drop(transition); let owned = endpoint.admit().await.expect("test: ready pool").pool.expect("test: managed pool"); assert_eq!(owned.resident_minds(), None, "the spawn knows its contract, not the engine's declaration"); + (root, owned, dir, server) +} + +const DECLARED: crate::inference::weight_residency::ResidentMinds = + crate::inference::weight_residency::ResidentMinds { lanes: 2, parked_ids: 2, incarnation: 42 }; - let declared = Some(ResidentMinds { lanes: 2, parked_ids: 2, incarnation: 42 }); +// what this catches: the M5 2026-11-17 outage end to end (owned spawn -> adapter discovery -> admission). The +// owned pool must be accepted, record the engine's declaration and be admitted, and the fast path afterwards +// returns the same DECLARED pool. Before the fix every discovery here returned MindsMismatch. +#[tokio::test] +async fn an_owned_spawn_learns_its_engines_minds_at_discovery() { + let (root, owned, _dir, server) = owned_spawn_declaring_minds().await; let client = reqwest::Client::new(); let pool = directory().discover_pool(&client, &root).await.expect("discovery accepts the owned pool"); assert!(Arc::ptr_eq(&pool, &owned), "the owned pool is the one discovered, not a replacement"); - assert_eq!(pool.resident_minds(), declared, "discovery recorded the engine's own declaration"); + assert_eq!(pool.resident_minds(), Some(DECLARED), "discovery recorded the engine's own declaration"); assert!(directory().page_admission_known(&root), "page admission granted after the declaration"); let again = directory().discover_pool(&client, &root).await.expect("the fast path"); - assert!(Arc::ptr_eq(&again, &owned) && again.resident_minds() == declared, "the fast path returns the declared pool"); + assert!(Arc::ptr_eq(&again, &owned) && again.resident_minds() == Some(DECLARED), "the fast path returns the declared pool"); + server.abort(); +} + +// what this catches: the lifecycle path granting page admission FIRST (a checkpoint before any adapter request) +// on an owned pool without the engine's minds declaration; the adapter's discovery then takes the fast path and +// would read the undeclared pool as core-paged minds (Codex on 5b2f48ae7). The lifecycle grant must declare. +#[tokio::test] +async fn a_lifecycle_admission_first_still_declares_the_engines_minds() { + let (root, owned, _dir, server) = owned_spawn_declaring_minds().await; + let client = reqwest::Client::new(); + directory().discover_page_admission(&client, &root).await.expect("the lifecycle path grants page admission"); + assert_eq!(owned.resident_minds(), Some(DECLARED), "the lifecycle grant recorded the engine's declaration"); + let pool = directory().discover_pool(&client, &root).await.expect("the adapter's fast path"); + assert!(Arc::ptr_eq(&pool, &owned), "the fast path returned the admitted owned pool"); + assert_eq!(pool.resident_minds(), Some(DECLARED), "never an undeclared pool read as core-paged minds"); server.abort(); } From 338493157a775361c4c4c9fa8b01a3df4480c7fe Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Mon, 16 Nov 2026 23:49:06 -0600 Subject: [PATCH 10/10] Test fixture props are typed, not JSON keyed by name (source-hygiene string_identities_in_tests 184 -> 187) The fake engine's /props in the owned-spawn discovery tests is a typed Serialize struct mirroring the fork's context_geometry.resident_minds shape, instead of a json! map read by field name. Not compiled locally (serving node); CI is the check. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- .../src/inference/slots/tests/discover.rs | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/core/continuum-engine/src/inference/slots/tests/discover.rs b/core/continuum-engine/src/inference/slots/tests/discover.rs index 98d533072f..07923519b2 100644 --- a/core/continuum-engine/src/inference/slots/tests/discover.rs +++ b/core/continuum-engine/src/inference/slots/tests/discover.rs @@ -155,13 +155,22 @@ fn a_pool_records_the_engines_declared_minds_once() { /// A fake engine declaring resident minds on `/props`, and this core's owned spawn of it: a ready generation /// whose pool was published from the launch contract (no minds declaration yet). async fn owned_spawn_declaring_minds() -> (String, Arc, tempfile::TempDir, tokio::task::JoinHandle<()>) { - let props = serde_json::json!({ - "total_slots": 2, - "context_geometry": { - "allocated_tokens": 8192, "max_tokens_per_sequence": 4096, "sequence_capacity": 4, - "resident_minds": {"enabled": true, "lanes": 2, "parked_ids": 2, "parked_free": 2, "incarnation": 42} - } - }); + // the fork's /props shape for an engine with resident minds, typed (as the engine writes it) + #[derive(serde::Serialize, Clone)] + struct Minds { enabled: bool, lanes: u64, parked_ids: u64, parked_free: u64, incarnation: u64 } + #[derive(serde::Serialize, Clone)] + struct Geometry { allocated_tokens: u64, max_tokens_per_sequence: u64, sequence_capacity: u64, resident_minds: Minds } + #[derive(serde::Serialize, Clone)] + struct Props { total_slots: u32, context_geometry: Geometry } + let props = Props { + total_slots: 2, + context_geometry: Geometry { + allocated_tokens: 8192, + max_tokens_per_sequence: 4096, + sequence_capacity: 4, + resident_minds: Minds { enabled: true, lanes: 2, parked_ids: 2, parked_free: 2, incarnation: 42 }, + }, + }; let app = axum::Router::new() .route("/props", axum::routing::get(move || { let props = props.clone(); async move { axum::Json(props) } })); let namespace = format!("/{}", uuid::Uuid::new_v4()); // a recycled port is not this fixture engine