From 304039f613e2ceaf1fed412e281290ee0409a016 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Tue, 3 Nov 2026 10:13:00 -0600 Subject: [PATCH] A new resident binds to her grant on the engine's pool, never the per-sequence share (Cormac's fold-in on #5733) capacity::window_grant gains the process-wide grants seam (install_grants / current_grant, beside install_serving_state), installed by the serving daemon's tick. materialize_adapters takes her grant; no grant yet keeps her provisional window and the re-home reconciler binds her once she has one. The snapshot's served_context_window (the pool divided by its sequences) no longer sizes any mind. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- .../src/capacity/window_grant.rs | 14 +++++++++++++ .../supervisor/materialize_adapters.rs | 21 ++++++++++--------- .../src/modules/serving_daemon/tick.rs | 1 + 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/core/continuum-engine/src/capacity/window_grant.rs b/core/continuum-engine/src/capacity/window_grant.rs index eb73f13979..7ca37eac28 100644 --- a/core/continuum-engine/src/capacity/window_grant.rs +++ b/core/continuum-engine/src/capacity/window_grant.rs @@ -38,6 +38,20 @@ impl PoolGrants { } } +static GRANTS: std::sync::OnceLock>> = std::sync::OnceLock::new(); + +/// Install the serving daemon's grants as the process-wide readable seam, beside +/// `install_serving_state`. Set once; a second call is ignored. `true` iff this call installed it. +pub fn install_grants(rx: tokio::sync::watch::Receiver>) -> bool { + GRANTS.set(rx).is_ok() +} + +/// Her current grant on this node's engine: `None` before the daemon installs its grants, before +/// the engine serves, or while she has none yet. A `watch` borrow, no I/O. +pub fn current_grant(persona: uuid::Uuid) -> Option { + GRANTS.get()?.borrow().as_ref()?.grant_for(persona) +} + /// One mind's current demand on the pool: what her next turn requires, and whether a turn of hers /// is in flight now. #[derive(Debug, Clone, Copy, PartialEq, Eq)] diff --git a/core/continuum-mind/src/persona/supervisor/materialize_adapters.rs b/core/continuum-mind/src/persona/supervisor/materialize_adapters.rs index 1cc0fef37f..7cdefbf357 100644 --- a/core/continuum-mind/src/persona/supervisor/materialize_adapters.rs +++ b/core/continuum-mind/src/persona/supervisor/materialize_adapters.rs @@ -158,23 +158,24 @@ pub async fn materialize_adapters( } } else if profile.tier_category != crate::persona::hw_tier_descriptor::HwTierCategory::Cloud { - let snap = crate::inference::llama_server::current_serving(); - // A ready snapshot always carries a real window (the daemon refuses to - // publish ready with 0). Guard on both so a not-yet-ready/empty - // snapshot never clobbers the provisional window with 0; the re-home - // reconciler corrects the binding once serving is ready. - if snap.ready && snap.served_context_window > 0 { - if snap.served_context_window != profile.context_length { + // Her window is her grant on the engine's pool (`serving_daemon/grants.rs`), never the + // per-sequence share the snapshot publishes (the pool divided by its sequences: 51,507 + // on the M5; Cormac on #5733). No grant yet (the engine not serving, or no one on the + // seat measured) keeps her provisional window; the re-home reconciler binds her to her + // grant once she has one. + if let Some(grant) = crate::capacity::window_grant::current_grant(profile.persona_id) { + if grant != profile.context_length { continuum_base::probe!( class = "persona.upstart.window", persona = %profile.persona_name, persona_id = %profile.persona_id, planned = profile.context_length, - served = snap.served_context_window, - "pinning persona context window to the gateway's real /props slot (was the drifting plan value)", + served = grant, + source = "grant", + "binding persona context window to her grant on the engine's pool", ); } - profile.context_length = snap.served_context_window; + profile.context_length = grant; } } // Register the persona's adapter in the global provider diff --git a/core/continuum-serving/src/modules/serving_daemon/tick.rs b/core/continuum-serving/src/modules/serving_daemon/tick.rs index 6ca3d05093..2634d4929f 100644 --- a/core/continuum-serving/src/modules/serving_daemon/tick.rs +++ b/core/continuum-serving/src/modules/serving_daemon/tick.rs @@ -24,6 +24,7 @@ impl ServiceModule for ServingDaemonModule { // free functions + adapters read "what's live" as a pointer instead of // each probing /v1/models. Set-once (singleton daemon). let _ = crate::inference::llama_server::install_serving_state(self.subscribe_serving()); + let _ = crate::capacity::window_grant::install_grants(self.subscribe_grants()); // THE DEVICE-BUDGET AUTHORITY, wired here rather than promised in a doc comment. // Without it `EphemeralServingLane::spawn` admits every engine with only a // free-port check — which is how three sidecars once shared one GPU. Set-once