Repository navigation
fix(serving): engine admission is an INVARIANT at the spawn, not an unbuilt governor - #3957
Merged
Merged
Conversation
…nbuilt governor
`EphemeralServingLane::spawn` carried this, for months:
/// Budget-gating ("does this fit alongside the live lane?") is the
/// `ResourceGovernor`'s concern (#56); this primitive only stands the lane up.
**`ResourceGovernor` does not exist.** All eight of its mentions in the tree
are doc comments promising a future owner. So the decision was delegated to
nobody, and the only question ever asked before placing another engine on the
device was `first_free_port` — *is a port free?*
A port is cheap and genuinely per-lane. The GPU is one shared thing. Using
port-freeness as a proxy for device capacity let three vision sidecars
co-exist on one GPU: ports 58091/58092/58093, and `first_free_port` means N+1
exists ONLY because N was occupied, so the filenames themselves prove the
concurrency. Each ran at 3.1-8.6 tok/s against 60-80 normal for that box —
not a slow model, three engines time-slicing one device.
The reclaim machinery was never the problem. `lane_registry` records every
lane, `lane_pidfile` adopts-or-reaps the live one, both with real Windows
arms and a shared never-blind-kill rule. The problem is that every reclaim
fires on an EDGE — `sweep_orphans` at daemon init, `sweep_all` at `stop`
(which `reboot` skips by design, keeping the live lane up for adoption),
`Drop` on graceful exit — so nothing bounded engines WITHIN one core's life.
So the question moves to where the decision actually is:
1. **Serialize.** `EPHEMERAL_SPAWN_GATE` holds one cold-spawn at a time,
process-wide. This existed as `EVAL_LANE_SPAWN_GATE` in `cognition::eval`
— at ONE caller, so the vision sidecar inherited nothing from it. A
discipline only one caller opts into is not a discipline. Eval keeps its
gate for the concern that IS its own (same-key racers sharing a warm
lane); the lock order is documented on both, and that nesting is the only
one in the tree.
2. **Census.** `lane_registry::records()` plus the existing
`is_llama_server` identity check, so the decision is taken against lanes
that are actually alive. Dead and pid-recycled records are dropped as
bookkeeping, never signalled. Done INSIDE the spawn because neither
boot-time sweep can see a sibling that appeared five seconds ago.
3. **Admit or refuse.** A late-bound authority the serving daemon installs,
built over the same `live_host_budget` + `footprint_for` pair
`pin_fit_checker` uses so the gate and the planner cannot disagree. It
models CO-RESIDENCE: an ephemeral lane JOINS the live lane, so the
incumbent is spent, never credited back — the one sign flip that separates
this from a pin's arithmetic, and getting it backwards would admit exactly
the second engine this refuses. Refusal is loud, returns an error, and
states every term.
Weights, not weights+KV, as the cost: the same choice `pin_fit_decision`
makes, weights dominate (18.97 GB against a 24.63 GB budget on this host) and
are the term nothing can shrink, while KV is what the planner sizes down
under pressure. It under-states, so the gate errs toward admitting — a guard
against a second ENGINE, not a precise accountant.
Tests: the arithmetic is extracted pure (`lane_admission_decision`) and
pinned four ways — a second engine that does not fit is refused with its
terms named, the live lane is spent rather than credited, siblings weigh (the
measured failure was the THIRD sidecar, each individually affordable), and an
already-overcommitted device floors at zero headroom instead of wrapping. The
census is pinned non-destructive and complete across both roles. And
`the_serving_daemon_installs_the_admission_authority` fails the moment the
install call is deleted — the failure mode #56 actually had.
Full `--lib`: 44 failures, byte-identical to the clean base (GPU, python,
screenshot-binary and Windows path tests on this box). `comm -13` empty.
Closes #3956.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
joelteply
added a commit
that referenced
this pull request
Sep 10, 2026
…3958) Twice on this host (#3955), the node came up with zero lanes and zero citizens and NOTHING red: serving.pin.restored model_id=AtomicChat/Qwen3.8-Flash-Next-GGUF serving.plan.candidate_refused <each of the 3 models on disk> reason="another model is pinned — serving/unpin frees the choice" That model's catalog row says `availability: not_downloaded`. So the planner honoured the pin, refused every candidate that could actually serve, and declined to load weights that do not exist. Every component behaved exactly as designed and the machine was useless. Only a hand-run `serving/unpin` recovered it, both times. **`serving/pin` already refuses this shape** — it fit-gates at set time and returns Denied for a model that is "in the catalog but not downloaded". The hole is RESTORE: a pin read back from the state dir had no check at all, and the world moves after a pin is written (weights evicted, a drive unmounted, the file edited, a downgrade writing a row this build reads differently). So the restore verifies before it honours. An unservable stored pin is IGNORED for that boot with a loud `serving.pin.unservable_ignored`, and the node comes up autonomic instead of dark. The pin FILE is deliberately kept. It is durable operator intent and the model may be pulled later, so it is honoured again on the first boot after the weights land; only `serving/unpin` drops the intent. A fix that silently discarded the operator's choice would be its own bug, and a test asserts the file survives. Second half: the refusal now NAMES the pin. `REFUSED_NOT_PINNED` says "another model is pinned" and never said which, so a dark node emitted three refusals a second, none identifying the thing doing the refusing, and finding it took a grep of a different log for `serving.pin.restored`. A rejection reason that states its category but not its cause turns a read into archaeology. I could not attribute who set the bad pin: no probe and no log line records a pin write, and the only writer of the store is the command that refuses this shape. That absence is itself the finding — but the node must not be brickable regardless of who does it, which is what this fixes. ## A false-passing test, caught and fixed `the_serving_daemon_installs_the_admission_authority` (landed in #3957) was BLIND. `include_str!` pulls in the whole file, tests included, so `src.contains("install_lane_admission(")` matched the assertion's own string literal and stayed green with the production call deleted — a check that cannot fail ([[success-signal-that-cannot-report-failure]]). Found because a sibling assertion tripped over the same self-reference. All source assertions now read `production_source()`, everything before `#[cfg(test)]`, and all three were mutation-tested: deleting the install call, renaming the probe class, and dropping the `pinned` field each turn their test red, and green again when restored. Full `--lib`: 43 failures, a subset of the clean base's 44 (GPU, python, screenshot-binary and Windows path tests on this box). `comm -13` empty. Closes #3955. Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc Co-authored-by: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3956.
The line that was doing the damage
EphemeralServingLane::spawncarried this for months:ResourceGovernordoes not exist. All eight of its mentions in the tree are doc comments promising a future owner. The decision was delegated to nobody, so the only question ever asked before placing another engine on the device wasfirst_free_port— is a port free?A port is cheap and genuinely per-lane. The GPU is one shared thing.
The measurement
VISION_SIDECAR_BASE_PORT = 58091, andfirst_free_portmeans N+1 exists only because N was occupied — the filenames themselves prove the concurrency, no timestamp inference needed. Three engines, one GPU, 3.1–8.6 tok/s each against 60–80 normal for that box. Not a slow model: three engines time-slicing one device.What was NOT wrong
Worth stating, because I went looking for it and it wasn't there:
lane_processis a proper platform adapter with real Windows arms (tasklist,netstat).lane_registryrecords every lane, live and ephemeral.lane_pidfilepins the canonical port and adopts-or-reaps.sweep_orphansis wired. Nothing is unwired and the layering of the primitives is right.The problem is when each reclaim fires — all of them on an edge:
sweep_orphansserving_daemon::initialize— boot onlysweep_allstop_with()— andrebootpasseskeep_lanes = true, returning before itDrop-killNone is an invariant, so nothing bounded engines within one core's life.
The fix — move the question to where the decision is
1. Serialize.
EPHEMERAL_SPAWN_GATEholds one cold-spawn at a time, process-wide. This already existed asEVAL_LANE_SPAWN_GATEincognition::eval— at one caller, so the vision sidecar inherited nothing from it. A discipline only one caller opts into is not a discipline. Eval keeps its gate for the concern that is genuinely its own (same-key racers sharing a warm lane); lock order is documented on both and that nesting is the only one in the tree.2. Census.
lane_registry::records()plus the existingis_llama_serveridentity check, so the decision is taken against lanes that are actually alive. Dead and pid-recycled records are dropped as bookkeeping, never signalled. Done inside the spawn, because neither boot-time sweep can see a sibling that appeared five seconds ago.3. Admit or refuse. A late-bound authority the serving daemon installs, built over the same
live_host_budget+footprint_forpairpin_fit_checkeruses, so the gate and the planner cannot disagree about what fits. It models co-residence: an ephemeral lane JOINS the live lane, so the incumbent is spent, never credited back — that single sign flip is the whole difference from a pin's arithmetic, and getting it backwards would admit exactly the engine this refuses. Refusal is loud, returns an error, and states every term.Weights rather than weights+KV as the cost — the same choice
pin_fit_decisionmakes. Weights dominate (18.97 GB against a 24.63 GB budget on this host) and are the term nothing can shrink; KV is what the planner sizes down under pressure. It under-states, so the gate errs toward admitting: a guard against a second engine, not a precise accountant.Tests
The arithmetic is extracted pure (
lane_admission_decision) and pinned four ways:The census is pinned non-destructive and complete across both roles. And
the_serving_daemon_installs_the_admission_authorityfails the moment the install call is deleted — which is the failure mode #56 actually had.Full
cargo test -p continuum-core --lib: 44 failures, byte-identical to the same run on the clean base (GPU, python, screenshot-binary and Windows path tests on this box).comm -13between the two lists is empty.🤖 Generated with Claude Code
https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc