Skip to content

fix(serving): the KV cache type is a DECISION, not a variable a human once exported - #4285

Merged
joelteply merged 5 commits into
canaryfrom
fix/the-kv-cache-type-is-a-decision
Sep 20, 2026
Merged

joelteply merged 5 commits into
canaryfrom
fix/the-kv-cache-type-is-a-decision

Conversation

@joelteply

@joelteply joelteply commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

The defect

A load-bearing decision that only works where a human once exported a variable is not a decision.

  • core/continuum-core/src/inference/llama_server.rs:3490 (pre-change) — SERVING_KV_CACHE_TYPE read raw, .filter(|s| !s.is_empty() && s != "f16"). Unset → no --cache-type-k / --cache-type-v flag at all, so the engine ran its f16 default (65,536 bytes/token for the 27B coder row). SERVING_FLASH_ATTN read three lines below, independently, defaulting to off.
  • core/continuum-core/src/modules/serving_daemon.rs:5529 (pre-change) — kv_cache_quant_divisor() derived the plan's resident-KV divisor from the same key. So the fit math was self-consistent: it simply planned half the capacity. Nothing ever disagreed, so nothing ever complained.

Measured, 2026-09-20 — two of three boxes:

box before after
M5 (metal) key set by hand: --cache-type-k q8_0 --cache-type-v q8_0 --flash-attn on, 2 lanes × 67,072 unchanged, byte-identical
5090 (cuda) key never set → f16 default, a 26,880-token lane (Joel) q8_0 + flash-attn → ~2× the window on the same budget
IntelMac (cpu by plan) no key in config.env, live argv confirms no --cache-type-* and no flash-attn: a 1.5B at -c 32768 --parallel 1 --n-gpu-layers 0 on ~15 GB usable (Cormac) unchanged (f16) pending a measurement — see below; the override produces the number

The decision

core/continuum-core/src/cognition/kv_cache_plan.rs (new) — pure, where the plan lives.

Ask the engine what it ACCEPTS — as a veto, never a promotion. parse_engine_kv_support reads the serving binary's own --help. Some(false) (no --cache-type-k parser in this build) forces f16 unconditionally: handing a build a flag it cannot parse makes the spawn refuse, which is the 2026-08-20 --flash-attn outage's shape. Some(true) says only that the build is capable — it does not promote, because the two inputs answer different questions:

  • --help → can this BUILD accept q8_0 (a build-level fact);
  • the backend table → is q8_0 a good trade on this HARDWARE (a measured, throughput-shaped question).

Conflating them defeats the CPU condition in source: the IntelMac's own llama-server does list q8_0 in its help, so a promoting advertisement would hand that box quantized KV on exactly the unmeasured dequant cost the f16 arm exists to avoid. So quantized = table_says_measured && engine != Some(false). Capability is necessary; it is not sufficient.

The backend table answers the hardware question — what has actually been measured:

backend cache type flash attention divisor
metal, cuda q8_0 on 2
cpu, rocm, vulkan, directml, unknown f16 off 1

The CPU arm is f16 pending a MEASUREMENT, not because the CPU backend is incapable (Cormac's condition on this PR). It can do quantized KV, and the capacity case is real — the IntelMac would go 1 × 32k → 1 × 64k. But capacity is not the only axis: quantized KV costs dequantization work on every read, and that box is already bottlenecked on prefill at ~25 tok/s, so a bigger window at a lower token rate can be a net loss. Nobody has measured it. The code comment, the module header and the_cpu_arm_stays_f16_until_the_dequant_cost_is_measured all say exactly that, so the next person does not "fix" it back without the number — and the operator override is how the number gets made (Cormac runs q8_0 there on the hour).

rocm / vulkan / directml stay conservative until an engine advertises or someone measures them there — and f16 on any of these is a decision that gets probed as one (serving.kv_cache.decided, backend=cpu|vulkan, engine_advertised=None), never a silence.

Cache type and flash attention are one choice in one struct (KvCachePlan { cache_type, flash_attn, bytes_per_token_divisor, source, backend }), because quantized KV rides llama.cpp's fused-attention path: q8_0 with --flash-attn off is a misconfiguration, not a half-fix. An operator who writes only SERVING_KV_CACHE_TYPE=q8_0 gets the fused path with it.

The override rule

SERVING_KV_CACHE_TYPE and SERVING_FLASH_ATTN are demoted from source to override:

  • unset → the decision applies;
  • set and different from the decision → honored, and reported source=override with both values in the receipt;
  • set and merely restating the decision (the M5's existing keys) → still decided; a key that agrees is a no-op, not a wolf.

One resolved value, two consumers

  • llama_server.rs:3558-3560 — kv_plan.launcher_cache_type() + kv_plan.flash_attn become the --cache-type-k/v and --flash-attn flags.
  • serving_daemon.rs:5528 — kv_cache_quant_divisor() is now crate::cognition::kv_cache_plan::resolve().bytes_per_token_divisor.

They shared a key before; they now share the decision. the_launcher_flag_and_the_plan_divisor_cannot_disagree asserts on the shared struct, never on two independent reads — a box that served q8_0 while planning f16 would over-commit its budget by 2×, and a box that plans q8_0 while serving f16 is the 5090's 26,880-token lane.

grep SERVING_KV_CACHE_TYPE across the crate now finds exactly one reader: kv_cache_plan::resolve.

The receipt

  • serving.kv_cache.decided (llama_server.rs:3571) — at every spawn: model, cache_type, source, backend, engine_advertised, flash_attn, divisor, kv_bytes_per_token (the plan's own post-divisor rate via footprint_for), kv_rate_answered, window (per-lane, the number the plan sized from that rate), lanes, total_ctx. A half-size lane can never again be invisible.
  • serving.kv_cache.backend (kv_cache_plan.rs:346, recorded from ipc/mod.rs:1285 — the single gpu::monitor::detect() site, no second probe).
  • serving.kv_cache.engine_support (llama_server.rs:616) — the --help ask, once per process, bounded at 10 s, with a named outcome (answered | did_not_enumerate | probe_failed | probe_timeout).

All three added to docs/architecture/RTOS-DEBUGGER-PROBES.md.

Tests

Extended the module's single #[cfg(test)] mod tests (no new test mods anywhere). Each has a // what this catches: naming the incident:

  • a_cuda_host_with_no_env_decides_q8_0_with_flash_attention — references the 5090's 26,880-token lane and pins bytes_per_token(65_536) == 32_768.
  • metal_decides_exactly_what_the_m5_already_runs — the no-op requirement; the M5's existing keys resolve identically and are not reported as an override.
  • the_cpu_arm_stays_f16_until_the_dequant_cost_is_measured — the IntelMac: f16 by default with the reason named (unmeasured dequant cost against a ~25 tok/s prefill), and the override yielding q8_0 + the fused path, which is how the measurement gets taken.
  • unmeasured_backends_stay_on_f16_and_pass_no_flag — cpu / vulkan / rocm / directml / unknown omit the flag entirely (byte-identical invocation).
  • the_engines_advertisement_is_a_veto_never_a_promotion — on the real --help text: an advertising build on unmeasured hardware (cpu, vulkan) stays f16; a non-advertising build on measured hardware (cuda, metal) is held back to f16; None is never read as "no".
  • an_explicit_f16_override_on_cuda_is_honored_and_named_an_override.
  • the_launcher_flag_and_the_plan_divisor_cannot_disagree — asserts on the shared struct across 8 backend/engine/override combinations.
  • a_quantized_override_carries_flash_attention_even_where_it_was_not_decided.
  • kv_divisor_reflects_cache_type_conservatively (moved here from serving_daemon, where its private kv_divisor_for no longer lives), the_platform_strings_the_substrate_actually_emits_all_parse, cpu_by_plan_wins_over_a_detected_metal_device.
  • serving_daemon's own new test asserts its divisor is the resolved decision's divisor.

Blast radius

Metal boxes are unchanged. The decision reproduces exactly what the M5 runs today (q8_0 + --flash-attn on), with or without its existing config.env keys — this is a no-op there and a doubling on the 5090. Every backend we have not measured — cpu included — keeps the pre-change invocation byte-for-byte (no --cache-type-*, no --flash-attn, divisor 1), so the only behavioural change on this PR is the CUDA one.

CONTINUUM_SERVING_PLACEMENT=cpu wins over the detected device, so the #3729 Intel-Mac arm (Metal device listed, Metal-less server, lane on the CPU) is decided as the CPU lane it actually is.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

… once exported — two of three boxes served half their KV budget

`SERVING_KV_CACHE_TYPE` unset meant no `--cache-type-k/v` flag at all
(llama_server.rs:3490) AND a resident-KV divisor of 1 in the plan
(serving_daemon.rs:5529) — read from the SAME key, so the arithmetic was
self-consistent and simply planned half the capacity. Nothing ever disagreed,
so nothing ever complained.

The M5 had the key set by hand (q8_0 + flash-attn, 2 x 67,072). The 5090 never
did — Joel measured a 26,880-token lane there. Nor did the CPU-serving IntelMac
— Cormac's live argv confirms no cache-type flags, a 1.5B at -c 32768
--parallel 1 on ~15 GB usable.

Now the substrate decides: the engine's own advertised `--cache-type-k` values
where its `--help` enumerates them, an explicit backend table (metal, cuda AND
cpu quantized-capable) otherwise. Cache type and flash attention are ONE choice
in one struct — q8_0 without the fused path is a misconfiguration, not a
half-fix — and the launcher's flags and the plan's divisor are two projections
of that same resolved value, so they cannot disagree by construction.

`SERVING_KV_CACHE_TYPE` / `SERVING_FLASH_ATTN` are now operator OVERRIDES:
honored, and named `source=override` in the receipt.

Receipt: `serving.kv_cache.decided` at every spawn carries the type, the source,
the backend, the engine's advertisement, the bytes/token and the window the plan
sized from it. Plus `serving.kv_cache.backend` (recorded once at the single GPU
detect site) and `serving.kv_cache.engine_support` (the bounded, named-outcome
`--help` ask). All three in RTOS-DEBUGGER-PROBES.md.

Metal boxes are UNCHANGED: the decision reproduces exactly what the M5 already
runs.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply and others added 2 commits September 20, 2026 17:14
…pr out of the macro

A closure with a &str parameter returning a &str borrowed from a CAPTURE infers
one lifetime across both and does not compile; the pick is a free fn with an
explicit borrow from the parsed config instead.

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

Copy link
Copy Markdown
Contributor Author

APPROVE with one condition — reviewed at exact head 9b75e7a (cargo jobs running at read time), as the operator of the fleet's only CPU-backend box.

Right: the KV cache type is a DECISION with one resolved value (KvCachePlan: type, flash-attn, divisor, source, backend) read by both the launcher flags and the fit math, so a box can no longer serve at one density and plan at another; the env key survives only as an operator override and is probed when it differs; the engine's own --help is the capability oracle for quantized KV (parse_engine_kv_support, allowed values + --flash-attn), not a guess; serving.kv_cache.* names type, source, bytes/token and the resulting window, so a half-size lane is never invisible again. Metal unchanged by construction. This is the 5090's 26,880-token lane and it is bigger than that box.

The condition is the CPU arm. ServingBackend::supports_quantized_kv returns true for Cpu, so this box (the IntelMac: --n-gpu-layers 0, Metal refused, 25 tok/s prefill measured today) is DECIDED onto q8_0 + flash-attn on the first deploy. The engine SUPPORTS it — that is what the help oracle says — but the decision here is about speed on a box whose whole problem is prefill seconds, and llama.cpp's CPU flash-attention path is not the same kernel as Metal's or CUDA's: a slower prefill at double the window is a slower turn, not a wider seat. Nothing in the PR measures it, and the receipt names the window, not the rate. Ask: Cpu decides f16 (the divisor 1 it has today) until a measurement says otherwise — one match arm — with the override still available; I will run this box under SERVING_KV_CACHE_TYPE=q8_0 on the hour after the deploy, read inference.prefill.complete ingest_tok_per_s and delib.generate.cache decode_ms against today's 25 / 2.6, and the number flips the default in a one-line follow-up if it holds. Metal and CUDA are decided as written; the 5090 gets its lanes tonight either way.

joelteply and others added 2 commits September 20, 2026 17:33
…y new unwrap carries its reason

Cormac's condition on #4285: `supports_quantized_kv` had Cpu → q8_0 + flash-attn on
the capacity argument alone. Capacity is not the only axis. Quantized KV costs
dequantization work on every read, and the one CPU-serving box in this fleet (the
IntelMac, #3729) is already bottlenecked on prefill at ~25 tok/s — a doubled window
bought at a lower token rate can be a net loss there, and nobody has measured it.

So the CPU arm is f16 — NOT because the CPU backend cannot do quantized KV (it can),
but because the trade is unmeasured on that hardware. The code comment, the module
header and the test all say exactly that, so the next person does not "fix" it back
without the number. The operator override remains the path to producing it: run q8_0
on that box for an hour, get the measurement, then flip the arm on evidence.

New test `the_cpu_arm_stays_f16_until_the_dequant_cost_is_measured` pins both halves:
the f16 default, and the override that yields q8_0 + the fused path it requires.

Also: the four new `unwrap_or*` sites in kv_cache_plan.rs now carry same-line
justifications (the unwrap-justification ratchet, 2265 > baseline 2264). Each names
why the default is a DECIDED answer for that case rather than a stand-in for a
missing reading.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… — it would have defeated the CPU condition in source

`--help` answers "can this BUILD accept --cache-type-k q8_0" — a build-level fact.
The backend table answers "is q8_0 a good trade on this HARDWARE" — a measured,
throughput-shaped question. Treating a `Some(true)` as a promotion conflates them,
and the IntelMac is the proof: its own llama-server DOES list q8_0 in its help, so
the advertisement would have handed that box quantized KV on exactly the unmeasured
dequant cost the f16 arm exists to avoid — undoing Cormac's condition the moment the
help probe answered.

So: `quantized = table_says_measured && engine != Some(false)`. Capability is
necessary; it is not sufficient. `Some(false)` still vetoes unconditionally — passing
a flag a build has no parser for makes the spawn refuse, which is the 2026-08-20
--flash-attn outage's shape.

Test renamed and rewritten to pin both directions:
`the_engines_advertisement_is_a_veto_never_a_promotion`.

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

Copy link
Copy Markdown
Contributor Author

REVIEWED at 5400d12 by Fable (team lead). Cormac condition is met, with evidence, so I am arming this — Cormac, override me at this head if you read it differently.

His condition was that the CPU arm decides f16 until the dequantization cost is measured against that box roughly 25 tok/s prefill. supports_quantized_kv is metal and cuda only, the CPU arm is f16 pending a measurement rather than for incapacity (said in the doc comment, the module header and the PR body), and the_cpu_arm_stays_f16_until_the_dequant_cost_is_measured pins it along with the override path he will use to take the measurement.

The thing I want on the record, because neither of us flagged it and it would have silently undone that condition: as first written the engine --help advertisement PROMOTED. The IntelMac llama-server does list q8_0, so the moment that probe answered, the CPU box would have been handed quantized KV anyway. It is now a veto — --help answers "can this build accept the flag", the table answers "is this a good trade on this hardware", and only the latter can promote. That distinction between capability and advisability is the correct one and it is the difference between a condition honored and a condition bypassed by a probe.

Blast radius as claimed and as I read it: metal byte-identical to what the M5 runs now, every unmeasured backend including cpu byte-identical to today, cuda the only behavioural change. So this doubles the 5090 KV budget and touches nothing else — which is what a p0 on a live fleet should look like.

Also right: one reader of the key left in the crate, the launcher flag and the plan divisor asserted equal across eight combinations on the shared struct rather than as two independent reads, and source = Override only when the resolved pair actually differs, so the M5 existing keys read as decided instead of raising a false alarm.

APPROVE at 5400d12 — arming.

@joelteply
joelteply merged commit 3643dd8 into canary Sep 20, 2026
6 checks passed
@joelteply
joelteply deleted the fix/the-kv-cache-type-is-a-decision branch September 20, 2026 22:57
joelteply added a commit that referenced this pull request Sep 20, 2026
…ator daemon speaks canary's vocabulary (card 10bba591)

Rebased onto canary (the window allocator #4260, the KV cache decision #4285, the
workspace transfer #4278, `roles_from` over `CitizenRecipe` #4271). Cormac's note on
#4281 was to fold rather than keep a parallel notion; this does that:

- `roles_from_ids` (mine, over `RoleId`) is DELETED. The daemon calls canary's
  `roles_from` over `CitizenRecipe`, so a role's declared `CitizenRequirement` reaches
  the grid allocator as authored instead of being flattened to a measured window.
- `experience::source`: `resident_citizens` / `resident_citizens_embedded` are now the
  ONE fold over the default recipe; `resident_roles` is their projection (`.map(role)`).
  Before this the only reader dropped the requirement on the way out, so #4271's field
  could not reach the allocator at all. Boot reads the citizens once and hands the
  spawner their roles.
- `window_allocator::requirements_for(personas, working_set)` + `largest_known(reqs)`:
  the ONE derivation of what a seat's minds require (untrimmed demand × SENT_HEADROOM,
  `Unknown` until she has turned). The serving daemon's inline copy is replaced by the
  call; the grid daemon's own `sent_median_of + prompt_floor_of` is gone — an
  UNDECLARED role now stands at the largest `LaneRequirement` the seat knows, which is
  exactly what an `Unknown` resolves to in her allocator. One vocabulary, two callers.
- An opportunity move now passes `workspace_transfer::move_blocker_bounded` before the
  reservation ask, like the fall-home / return / spill paths (#4278, card 73eefbbb): a
  better seat is still there next tick, her unpushed work is not.
- Health line merged with canary's `think-only`; the fixture and args carry both.
- New surface is `pub(crate)` (the daemon's types, the opportunity rule, the turn
  ledger, the grid-roster seam) so the crate's public reachability is unchanged.
  `GridRoster` / `BetterBy` stay `pub` in `cognition::grid_allocation` beside their
  neighbours — they appear in that module's own `pub fn` signatures.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Sep 20, 2026
…ator daemon speaks canary's vocabulary (card 10bba591)

Rebased onto canary (the window allocator #4260, the KV cache decision #4285, the
workspace transfer #4278, `roles_from` over `CitizenRecipe` #4271). Cormac's note on
#4281 was to fold rather than keep a parallel notion; this does that:

- `roles_from_ids` (mine, over `RoleId`) is DELETED. The daemon calls canary's
  `roles_from` over `CitizenRecipe`, so a role's declared `CitizenRequirement` reaches
  the grid allocator as authored instead of being flattened to a measured window.
- `experience::source`: `resident_citizens` / `resident_citizens_embedded` are now the
  ONE fold over the default recipe; `resident_roles` is their projection (`.map(role)`).
  Before this the only reader dropped the requirement on the way out, so #4271's field
  could not reach the allocator at all. Boot reads the citizens once and hands the
  spawner their roles.
- `window_allocator::requirements_for(personas, working_set)` + `largest_known(reqs)`:
  the ONE derivation of what a seat's minds require (untrimmed demand × SENT_HEADROOM,
  `Unknown` until she has turned). The serving daemon's inline copy is replaced by the
  call; the grid daemon's own `sent_median_of + prompt_floor_of` is gone — an
  UNDECLARED role now stands at the largest `LaneRequirement` the seat knows, which is
  exactly what an `Unknown` resolves to in her allocator. One vocabulary, two callers.
- An opportunity move now passes `workspace_transfer::move_blocker_bounded` before the
  reservation ask, like the fall-home / return / spill paths (#4278, card 73eefbbb): a
  better seat is still there next tick, her unpushed work is not.
- Health line merged with canary's `think-only`; the fixture and args carry both.
- New surface is `pub(crate)` (the daemon's types, the opportunity rule, the turn
  ledger, the grid-roster seam) so the crate's public reachability is unchanged.
  `GridRoster` / `BetterBy` stay `pub` in `cognition::grid_allocation` beside their
  neighbours — they appear in that module's own `pub fn` signatures.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Sep 21, 2026
…ry join and plan change; a mind moves to a strictly better seat between turns (card 10bba591) (#4281)

* feat(grid): the allocator daemon — the grid re-seats its minds on every join and plan change, and a mind moves to a strictly better seat between turns (card 10bba591)

Before this the pure allocator had no live caller: minds moved only on FAILURE (a
lane wait past a bound, a seat window below the turn), nobody re-ran the allocation
when a node joined or a plan changed, so a mind on a 32k seat stayed there when a 70k
seat appeared. Joel: "Can it grow to higher capacity as both the M5 and the 5090 come
online, ideally no time lost."

- modules/grid_allocator.rs: `GridAllocatorModule`, the canonical shape — own task,
  `tokio::time::interval` at the gossip beat, woken early by the ledger's new
  `heard_notify` and the plan watch, body under `catch_unwind` with quarantine after
  three panics, an atomic key gate so an unchanged grid publishes nothing, a
  process-global `watch::Sender<Option<Arc<Published>>>`. Inputs are what exists:
  `LanePlan::of` the published ServingPlan + the measured decode, the gossip ledger's
  foreign offers (same rows the grid module folds — no second listener), the live
  roster with the recipe's roles (`roles_from_ids`, the canary-side fold; #4271's
  declared requirements slot in), the operator's hold. Peers' residents are seated as
  anonymous minds homed there so a full peer never reads as open seats. Publishes the
  dormant order (oldest last turn first) and a clip interval derived from the slack.
  Probes: grid.allocation.published, grid.dormant.oldest_turn_age_ms.
- persona/placement_switch.rs: `decide_opportunity` (pure) + `follow_the_allocation`
  — a strictly better seat (requirement, then the allocator's capability / lanes /
  window order) moves her between turns only, inside a cooldown derived from her
  measured turn cadence (never a new constant); a remote seat asks for its slot first,
  a home seat retires her override (`come_home_for_good`). Probe
  placement.move.opportunity. Failure moves now count too.
- cognition/resource_admission.rs: `begin_turn` RAII guard replaces the bare stamp —
  in-flight mark + measured `TurnShape` (turn, cadence) per mind.
- persona/spawner_module.rs + host.rs + ipc/mod.rs: the allocation owns this node's
  lane-side seat count once published (`GridRoster`, told each reconciler pass; the
  reconciler now also wakes on a publish); the warm-slot bound is the prior before it;
  the population bound stays the spawner's.
- modules/citizen_health.rs: the hour line gains "moves: N on opportunity / M on
  failure" and "oldest dormant turn".
- cognition/grid_allocation.rs: `LanePlan::better_than` / `BetterBy`, `GridRoster`,
  `roles_from_ids`.

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

* docs(probes): name the grid allocator and opportunity-move probe classes in the manual

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

* refactor(grid): one requirement notion, one citizens fold — the allocator daemon speaks canary's vocabulary (card 10bba591)

Rebased onto canary (the window allocator #4260, the KV cache decision #4285, the
workspace transfer #4278, `roles_from` over `CitizenRecipe` #4271). Cormac's note on
#4281 was to fold rather than keep a parallel notion; this does that:

- `roles_from_ids` (mine, over `RoleId`) is DELETED. The daemon calls canary's
  `roles_from` over `CitizenRecipe`, so a role's declared `CitizenRequirement` reaches
  the grid allocator as authored instead of being flattened to a measured window.
- `experience::source`: `resident_citizens` / `resident_citizens_embedded` are now the
  ONE fold over the default recipe; `resident_roles` is their projection (`.map(role)`).
  Before this the only reader dropped the requirement on the way out, so #4271's field
  could not reach the allocator at all. Boot reads the citizens once and hands the
  spawner their roles.
- `window_allocator::requirements_for(personas, working_set)` + `largest_known(reqs)`:
  the ONE derivation of what a seat's minds require (untrimmed demand × SENT_HEADROOM,
  `Unknown` until she has turned). The serving daemon's inline copy is replaced by the
  call; the grid daemon's own `sent_median_of + prompt_floor_of` is gone — an
  UNDECLARED role now stands at the largest `LaneRequirement` the seat knows, which is
  exactly what an `Unknown` resolves to in her allocator. One vocabulary, two callers.
- An opportunity move now passes `workspace_transfer::move_blocker_bounded` before the
  reservation ask, like the fall-home / return / spill paths (#4278, card 73eefbbb): a
  better seat is still there next tick, her unpushed work is not.
- Health line merged with canary's `think-only`; the fixture and args carry both.
- New surface is `pub(crate)` (the daemon's types, the opportunity rule, the turn
  ledger, the grid-roster seam) so the crate's public reachability is unchanged.
  `GridRoster` / `BetterBy` stay `pub` in `cognition::grid_allocation` beside their
  neighbours — they appear in that module's own `pub fn` signatures.

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

* fix(grid): the local offer's decode reads canary's `tps_for` — `measured_tps_for` went with the #4194 revert

CI (the compiler) caught the one symbol the rebase carried over from the reverted
output-allowance work. `decode_knee::tps_for` is the rate this box measured at the
LIGHTEST trusted concurrency; the plan's own lane count already respects the measured
knee (`plan_serving` applies `knee_lanes`), so "every lane here decodes at or above
the floor" is the plan's statement and this number says how fast. `None` (never
measured) stays an absence the allocator does not read as a refusal.

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

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
joelteply added a commit that referenced this pull request Sep 21, 2026
…d make NOW — last deploy's cache type is a stale lane, relaunched once and named (card 977842fd) (#4288)

The composition of two correct changes: the KV cache type is applied at engine SPAWN
(#4285), an engine now survives a core stop (#4284), and the adopt rail compared model +
window + lanes + sight — never the KV decision. Measured on the 5090, 2026-09-21 00:33Z:
the new core read the q8_0 decision, found its healthy f16 engine at 26,880, adopted it,
and the decision never reached the process it was written to change; three minds fell
home from that seat within seven minutes ("seat window below her turn").

- `lane_process::LaunchKv` + `launch_kv_in(argv)`: the running engine's cache type and
  flash-attention read off its OWN argv (`--cache-type-k`, `--flash-attn on|off|auto`,
  bare and `=` forms) — the same recovery the `--cache-ram` grant already uses for an
  adopted lane. No flag = the engine's f16 default, a value.
- `LlamaServerControl::launch_kv()`: the real control resolves the live lane's pid from
  the registry and reads its argv; a fake models it (`launched_with`); unknown = `None`.
- `ensure_model_serving`: `kv_ok` beside `window_ok` / `lanes_ok` / `sight_ok` — the
  running decision against `kv_cache_plan::resolve()` (what a spawn would do now). A
  mismatch is `serving.grow` with both geometries named, then the relaunch the other
  axes already take; a window drift still adopts (#4284's warm-lane economy stands);
  an unknown launch is not a mismatch.

Pinned: an engine on the other decision → Spawned once; the same decision → AlreadyServing,
0 respawns; unknown → AlreadyServing. `launch_kv_in` on every flag shape.

Receipt: lib `inference::llama_server::tests` 59 passed / 0 failed (+ lane_process),
REAL_EXIT 0. On the 5090 after this lands: `serving.grow kv_ok=false planned_kv=q8_0
running_kv=f16` once, then a lane at roughly double the window.

Faster or slower: one argv read per ensure pass on an adopted lane; a stale lane costs
ONE relaunch, which is the cost of the decision reaching the engine at all.


Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant