From 738900a42b7b1a3548d064b01e554b3449f1911c Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Tue, 3 Nov 2026 07:14:06 -0600 Subject: [PATCH 01/10] =?UTF-8?q?SERVING-ENGINE=20=C2=A77:=20memory=20is?= =?UTF-8?q?=20conserved=20across=20minds,=20and=20the=20engine=20says=20wh?= =?UTF-8?q?at=20it=20holds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Measured on the M5 2026-11-03: the fork's full resident report (draft 3.15 GB, projector 0.90 GB, 94.6 MB per checkpoint x 32 per mind), and why a mind's prompt re-reads (611 consecutive capture pairs: 441 tail, 56 room switches, 40 live values in early blocks, 12 tool surface). Sets the contract across the seam (boundaries in, live holdings out, one ledger) and the order of work. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- docs/architecture/SERVING-ENGINE.md | 83 +++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/docs/architecture/SERVING-ENGINE.md b/docs/architecture/SERVING-ENGINE.md index e1f7dd3988..b20d235c36 100644 --- a/docs/architecture/SERVING-ENGINE.md +++ b/docs/architecture/SERVING-ENGINE.md @@ -185,3 +185,86 @@ gives memory back to the user's app. - The IPC cost is one request per act plus 30-120 token frames a second over a unix socket: microseconds against a 60 s act. - MODULE-ARCHITECTURE §9.2 rule 2 asks for one protocol per seam, local or remote. - The in-process `ServingPort` implementation exists only for the validator and tests. + +## 7. Memory is conserved across minds, and the engine says what it holds (2026-11-03) + +Joel, 2026-11-03: "One slot grows in context and the other shrinks and same for genome sizes. The +goal here is dynamic allocation"; "think harder about conservation around multiple minds or sharing +what you need across api boundaries so that intelligence can manage"; "you just treat llama.cpp +like any other daemon and interface with it. It's fully under your control." The engine is our +daemon. Nothing about a mind's memory is fixed at launch and guessed: the engine reports what it +holds, the core tells it where her prompt's boundaries are, and the core's ledger decides. + +### 7.1 What the engine holds (fork `resident_state`, read live on the M5, 2026-11-03 12:51Z) + +Qwen3.6-35B-A3B, `-c 257214 --parallel 2 --ctx-checkpoints 32`, two 13.9k-token prompts in: + +| Holder | Bytes | Notes | +|---|---|---| +| Target weights | 20.69 GB | mmapped | +| Target KV + recurrent state | 2.14 GB | 8,317 B/token over 257,536 tokens | +| Target compute graph | 1.87 GB | one graph for the shared pool | +| Draft (MTP) context | 3.15 GB | 1.34 weights, 0.53 KV, 1.29 compute: unreported before | +| Projector | 0.90 GB | unreported before | +| One checkpoint | 94.6 MB | x 32 per sequence = 3.03 GB per mind at the ceiling | + +`memory_breakdown` alone covered the first three. The rest was what the plan had been inferring from +the process footprint as a per-lane fixed term (2.8 to 4.5 GB a minute apart). + +### 7.2 Why a mind's prompt re-reads: measured, not assumed + +Engine log, 1,244 checkpoint resumes: 80% resumed within 8k tokens of the end (median 2,431 tokens +re-read, her changing tail). The other 20% fell back to her head-end checkpoint (~11k tokens). +The prompt captures of the four residents (`fixtures/prompt-captures`, 611 consecutive pairs) say why: + +| Where her next prompt first differs | Pairs | +|---|---| +| Her changing tail | 441 | +| Identical | 62 | +| She moved to another room (activity) | 56 | +| Live state in an early block: `room-wall` 12, `recall` 8, `workspace-map` 6, `room-kanban` 4 (a "557 claimable" counter), other 10 | 40 | +| Tool surface changed | 12 | + +Minds share only 6,177 chars of system prompt with each other (it diverges inside it). The +recurring 11,114-token checkpoint is each mind's own head end, not a shared one. + +So the blind every-4k checkpoints were covering three defects upstream of the engine: live values in +blocks meant to be stable, a mind's activities each restarting her view, and an unstable tool +surface (goal 10). + +### 7.3 The contract across the seam + +- **Core to engine, per request:** her prompt's boundaries as token positions: the head end, the + stable end (where her changing tail starts), and each activity's span. The request already + carries `view_messages` spans for this. The engine keeps a checkpoint exactly at the stable end + (one per mind per activity), never by a count or a step. +- **Engine to core, live (`/slots`, read on the server thread):** per sequence, the tokens it holds, + its checkpoints and their bytes, and what is shared with another sequence; on `/props`, every + fixed holder (7.1). A core never infers a holding from the process or the device. +- **The core's ledger, continuous:** weights and the graph are fixed claims; each mind's context is + her grant, growing with her and accommodated proportionally (Joel: "it might still be given less + than that, just try to accommodate"; her budget compresses to the grant); an in-flight turn's grant + never shrinks. Checkpoints and pages are held at their live bytes. Under pressure a cold mind's + unique state pages to RAM, then disk, by her activity temperature, before any grant shrinks. +- **Conservation:** what is identical across sequences is held once. Today that is the first 6k + chars; ordering the shared constitution and the stable tool surface ahead of her identity makes + the shared head the system prompt plus the tools, one KV run and one checkpoint for every mind + (`seq_cp` of the attention cells plus the head checkpoint, §1). Genes follow the same rule: one + copy per adapter, attached to every mind whose focus selects it. + +### 7.4 Order of work + +1. Mind side: no live value in a stable block. The kanban counter, the wall, the workspace map and + recall move to her tail as appended events; a ratchet refuses a live value rendered into a block + before the stable end. Validator: rerun 7.2's classification on fresh captures, early-block + pairs to 0. +2. Mind side: her activities are one view (she is one integrated mind across activities); a move + between rooms appends, it does not restart her. Validator: room-switch pairs re-read only the + switch. +3. Fork: the boundary checkpoint verb (keep one at the stable end the request names) replaces + `--ctx-checkpoints N` / `--checkpoint-min-step`; per-sequence holdings on `/slots` (`resident_state` + and slot `checkpoints`, fork #91, are the first part). +4. Core: the ledger reads live holdings (`ResidentReport`) and sizes the pool from them; every seated + mind is a sequence; the process-footprint inference (`lane_footprint`, `fixed_per_lane_bytes`) is + deleted. +5. Shared head (S7): constitution and tools ahead of identity, one copy for all minds. From 0880df7add64d8f5ae39a0de1fd1b6784469deeb Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Tue, 3 Nov 2026 07:15:19 -0600 Subject: [PATCH 02/10] =?UTF-8?q?SERVING-ENGINE=20=C2=A77.2:=2037=20of=204?= =?UTF-8?q?0=20turnovers=20came=20with=20a=20new=20grant;=20a=20grown=20gr?= =?UTF-8?q?ant=20never=20restarts=20her?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- docs/architecture/SERVING-ENGINE.md | 34 +++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/docs/architecture/SERVING-ENGINE.md b/docs/architecture/SERVING-ENGINE.md index b20d235c36..f50bb7215f 100644 --- a/docs/architecture/SERVING-ENGINE.md +++ b/docs/architecture/SERVING-ENGINE.md @@ -219,18 +219,24 @@ The prompt captures of the four residents (`fixtures/prompt-captures`, 611 conse | Where her next prompt first differs | Pairs | |---|---| -| Her changing tail | 441 | +| Her changing tail (the prompt only appended before it) | 435 | | Identical | 62 | -| She moved to another room (activity) | 56 | -| Live state in an early block: `room-wall` 12, `recall` 8, `workspace-map` 6, `room-kanban` 4 (a "557 claimable" counter), other 10 | 40 | -| Tool surface changed | 12 | +| She moved to another room (activity); 52 of 59 keep her first 3 messages | 59 | +| A turnover: her view restarted, and an early block differs | 29 | +| Live state in an early block with no turnover (`room-kanban`'s "557 claimable" counter, `room-wall`, `workspace-map`, `recall`) | 11 | +| Tool surface changed | 9 | +| A turnover with only later messages different | 6 | + +Of the 40 turnovers, 37 came with a new `context_window` on the request: 10,803, 16,640, 49,152, +69,376, 82,944, 96,256, 128,768 tokens across the day's relaunches. Her grant changed and her view +refit from the start. A grant that grows must never restart her; only a grant below what she holds +does, and then her view compresses to it oldest first (goal 7). Minds share only 6,177 chars of system prompt with each other (it diverges inside it). The recurring 11,114-token checkpoint is each mind's own head end, not a shared one. -So the blind every-4k checkpoints were covering three defects upstream of the engine: live values in -blocks meant to be stable, a mind's activities each restarting her view, and an unstable tool -surface (goal 10). +So the blind every-4k checkpoints were covering defects upstream of the engine: her grant moving +under her (turnovers), live values in blocks meant to be stable, and an unstable tool surface (goal 10). ### 7.3 The contract across the seam @@ -254,13 +260,13 @@ surface (goal 10). ### 7.4 Order of work -1. Mind side: no live value in a stable block. The kanban counter, the wall, the workspace map and - recall move to her tail as appended events; a ratchet refuses a live value rendered into a block - before the stable end. Validator: rerun 7.2's classification on fresh captures, early-block - pairs to 0. -2. Mind side: her activities are one view (she is one integrated mind across activities); a move - between rooms appends, it does not restart her. Validator: room-switch pairs re-read only the - switch. +1. A grant change is not a restart: her view turns over only when her grant falls below what she + holds, and a grown grant is room to append into. Validator: replay the captures with the day's + grants; turnovers with a grown window go to 0. +2. Mind side: no live value in a stable block. The kanban counter, the wall, the workspace map and + recall arrive as appended item versions (the keyed-item contract above), never as an in-place + rewrite; a ratchet refuses one. Validator: rerun 7.2 on fresh captures, in-place early changes + to 0. Her activities stay one view: a move between rooms appends. 3. Fork: the boundary checkpoint verb (keep one at the stable end the request names) replaces `--ctx-checkpoints N` / `--checkpoint-min-step`; per-sequence holdings on `/slots` (`resident_state` and slot `checkpoints`, fork #91, are the first part). From 17e7164cbebce9b71f3cd6dcf65e7fde1945cba2 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Tue, 3 Nov 2026 07:15:58 -0600 Subject: [PATCH 03/10] =?UTF-8?q?SERVING-ENGINE=20=C2=A77.2:=20correct=20t?= =?UTF-8?q?he=20turnover=20causes=20(26=20fills,=2012=20core=20restarts,?= =?UTF-8?q?=202=20window=20changes);=20a=20restart,=20not=20a=20grant,=20s?= =?UTF-8?q?tarts=20her=20over?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous revision read each turnover's window without comparing it to the act before it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- docs/architecture/SERVING-ENGINE.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/architecture/SERVING-ENGINE.md b/docs/architecture/SERVING-ENGINE.md index f50bb7215f..ad0f19ec0a 100644 --- a/docs/architecture/SERVING-ENGINE.md +++ b/docs/architecture/SERVING-ENGINE.md @@ -227,16 +227,17 @@ The prompt captures of the four residents (`fixtures/prompt-captures`, 611 conse | Tool surface changed | 9 | | A turnover with only later messages different | 6 | -Of the 40 turnovers, 37 came with a new `context_window` on the request: 10,803, 16,640, 49,152, -69,376, 82,944, 96,256, 128,768 tokens across the day's relaunches. Her grant changed and her view -refit from the start. A grant that grows must never restart her; only a grant below what she holds -does, and then her view compresses to it oldest first (goal 7). +Of the 40 turnovers, 26 came on the same core at the same window: her view filled its grant, the +codec's one designed re-read. 12 came across a core restart (the day's deploys and rollbacks): her +view is not carried over a restart, so a deploy starts every mind over. 2 came with a changed window +on the same core (one grown, one shrunk). Minds share only 6,177 chars of system prompt with each other (it diverges inside it). The recurring 11,114-token checkpoint is each mind's own head end, not a shared one. -So the blind every-4k checkpoints were covering defects upstream of the engine: her grant moving -under her (turnovers), live values in blocks meant to be stable, and an unstable tool surface (goal 10). +So the blind every-4k checkpoints were covering defects upstream of the engine: a view that does not +survive a restart, live values in blocks meant to be stable, and an unstable tool surface (goal 10). +The fills themselves are by design, and one checkpoint at her stable end serves every act between them. ### 7.3 The contract across the seam @@ -260,9 +261,9 @@ under her (turnovers), live values in blocks meant to be stable, and an unstable ### 7.4 Order of work -1. A grant change is not a restart: her view turns over only when her grant falls below what she - holds, and a grown grant is room to append into. Validator: replay the captures with the day's - grants; turnovers with a grown window go to 0. +1. Her view survives a restart: the epoch (its start, its items' levels, its appends) is durable + state beside her KV page, so a deploy pages her back in where she was instead of starting her + over. Validator: replay the captures across the day's restarts; turnovers at a restart go to 0. 2. Mind side: no live value in a stable block. The kanban counter, the wall, the workspace map and recall arrive as appended item versions (the keyed-item contract above), never as an in-place rewrite; a ratchet refuses one. Validator: rerun 7.2 on fresh captures, in-place early changes From a1b373ed908efd7d59d7f71b9e9e238ebcb88aaf Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Tue, 3 Nov 2026 07:21:01 -0600 Subject: [PATCH 04/10] =?UTF-8?q?SERVING-ENGINE=20=C2=A77.4:=20memory=20us?= =?UTF-8?q?es=20the=20prompt's=20base,=20the=20collapsing=20flexbox;=20a?= =?UTF-8?q?=20dozen=20hand-rolled=20allocators=20converge=20on=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- docs/architecture/SERVING-ENGINE.md | 38 ++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/docs/architecture/SERVING-ENGINE.md b/docs/architecture/SERVING-ENGINE.md index ad0f19ec0a..13095a82ba 100644 --- a/docs/architecture/SERVING-ENGINE.md +++ b/docs/architecture/SERVING-ENGINE.md @@ -259,8 +259,36 @@ The fills themselves are by design, and one checkpoint at her stable end serves (`seq_cp` of the attention cells plus the head checkpoint, §1). Genes follow the same rule: one copy per adapter, attached to every mind whose focus selects it. -### 7.4 Order of work +### 7.4 One base: the collapsing flexbox (Joel: "it's always collapsing flexbox style ... everywhere same base classes and interfaces") +A mind's prompt is already allocated by one base. `flex_allocate` (continuum-grounding, +rag_budget/flex_allocate.rs) grants each claim between its floor and its want by priority, and the +view's `allot` (continuum-context, view/allot.rs) gives each of a claim's items the most detail that +fits, newest first, collapsing the oldest to its summary, its pointer or a fold, each reopenable. +`Motion` (continuum-context, motion.rs) measures what stays the same between starts and orders the +view by it, so the consistent part leads and is kept. + +Memory is the same shape, so it uses the same base, never its own: + +| Prompt | Memory | +|---|---| +| a claim: a source, with floor, want, priority | a mind (her context, her checkpoints, her genes), a cache tier; floor = her in-flight turn, want = her demand, priority = her activity temperature | +| an item: one keyed result, file, card | one keyed run of her context, one checkpoint, one gene | +| Full / Summary / Pointer / Folded | on the GPU / paged to RAM / paged to disk (a page-in reopens it) / dropped, rebuilt from her prompt | +| newest whole, oldest collapses first | hottest resident, coldest pages out first | +| `Motion`: what stays the same between starts leads | what stays the same between her prompts, and between minds, is held once and checkpointed | + +The memory side today has a dozen hand-rolled allocators with their own rules, each a special case +of this: `window_within`, `lanes_that_fit`, `ModelFootprint::pool_within`, `window_allocator::allocate`, +`plan_expert_residency_budgeted`, continuum-kernel's `memory_manager` budgets and `eviction_weight`, +`paging/pool.rs` eviction, the broker's `lane_budgets`, `training_plan::fit`. They converge on the base +and are deleted. The base moves down to one floor crate, generic over the unit (tokens, bytes) and the +item, with the prompt side its first caller unchanged (the pattern-bubbles-up rule). + +### 7.5 Order of work + +0. The base: `flex_allocate`, the claim and level types and `allot`'s collapse move down to one floor + crate, generic over unit and item; every prompt caller migrated, test counts unchanged. 1. Her view survives a restart: the epoch (its start, its items' levels, its appends) is durable state beside her KV page, so a deploy pages her back in where she was instead of starting her over. Validator: replay the captures across the day's restarts; turnovers at a restart go to 0. @@ -271,7 +299,9 @@ The fills themselves are by design, and one checkpoint at her stable end serves 3. Fork: the boundary checkpoint verb (keep one at the stable end the request names) replaces `--ctx-checkpoints N` / `--checkpoint-min-step`; per-sequence holdings on `/slots` (`resident_state` and slot `checkpoints`, fork #91, are the first part). -4. Core: the ledger reads live holdings (`ResidentReport`) and sizes the pool from them; every seated - mind is a sequence; the process-footprint inference (`lane_footprint`, `fixed_per_lane_bytes`) is - deleted. +4. Core: serving's memory is claims and items on the base, fed by the engine's live holdings + (`ResidentReport`); every seated mind is a sequence; the hand-rolled allocators above and the + process-footprint inference (`lane_footprint`, `fixed_per_lane_bytes`) are deleted. `Motion` over + token runs, fed by the divergence point the engine reports per request, places checkpoints and + finds what minds share. 5. Shared head (S7): constitution and tools ahead of identity, one copy for all minds. From 6d42d4ab83c8166b606af3c12085914c4545dccf Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Tue, 3 Nov 2026 07:55:28 -0600 Subject: [PATCH 05/10] ONE-BUDGET slice 3b: a mind's memory in the engine, granted by level and valued by prediction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The engine's reported holdings become claims on cambrian-flex (airc#1630): her context, checkpoint, genes and the prompt cache, each with levels (GPU, RAM, disk, rebuilt) as increments, so caching, collapsing and expansion are one clearing. Values come from prediction (who acts next, where her prompt diverges, how much she appends, what minds share), possible because the core writes her prompt and holds its memory. Lists the sizers it deletes, the order, and the replay validator. SERVING-ENGINE §7.4 points at it; the earlier proposal of a separate `continuum-flex` crate is withdrawn (the one solver already exists). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- docs/architecture/ONE-BUDGET.md | 62 +++++++++++++++++++++++++++++ docs/architecture/SERVING-ENGINE.md | 39 ++++++------------ 2 files changed, 74 insertions(+), 27 deletions(-) diff --git a/docs/architecture/ONE-BUDGET.md b/docs/architecture/ONE-BUDGET.md index 42c226dc95..1a0d41bb24 100644 --- a/docs/architecture/ONE-BUDGET.md +++ b/docs/architecture/ONE-BUDGET.md @@ -395,6 +395,68 @@ with fast decode), replaying captured traces under each: a read stays whole acro has room; no turnover while unclaimed window remains; prefix reuse per act reported. A new machine is covered by its own measured profile, never by a list of boxes. Then one deploy per node and a 15-minute read: reads per edit, writes per hour, act time. +### Slice 3b in detail: a mind's memory in the engine, granted by level and valued by prediction (2026-11-03) + +Joel, 2026-11-03: "One slot grows in context and the other shrinks and same for genome sizes. The goal here is +dynamic allocation"; "Every part of prompts and these kinds of caches need to comply or the whole shebang doesn't +work, plus it's less code and easier"; "it lets you do really advanced prediction when inputs and outputs to LLMs +(or world models) are entirely under the same systems"; "You can then prioritize both caching and collapsing, +expansion, in the flexbox or any of your memory constraints." + +**What the engine holds, by its own report** (fork `resident_state`, CambrianTech/llama.cpp#91, read live on the M5 +2026-11-03 12:51Z, Qwen3.6-35B-A3B at 2 x 128,768): target weights 20.69 GB, target KV and recurrent state 2.14 GB +(8,317 B/token), one compute graph 1.87 GB, the draft model 3.15 GB, the projector 0.90 GB, one checkpoint 94.6 MB +(x 32 per slot at today's `--ctx-checkpoints` = 3.0 GB per mind). Before #91 the plan saw only the first three and +inferred the rest from the process footprint as a per-lane term that read 2.8 to 4.5 GB a minute apart. + +**The claims, on the node's device tier** (one pool on unified memory, normalized per part 2's pool rule): + +| Holder | Claim on `cambrian-flex` | +|---|---| +| Weights, graph, draft, projector of the serving model | `Floor::Required`, the engine's reported bytes | +| A mind's context, resident | `Floor::Required` = what her in-flight turn holds (a grant never shrinks under a running turn); then one indivisible increment per block of her context, valued as below | +| Her checkpoint | one indivisible increment of its reported bytes, at her predicted divergence point | +| Prompt cache | divisible increments, valued by measured restore hits | +| Her genes | one indivisible increment per adapter her focus selects; an adapter shared by several minds is ONE claim | + +**Caching, collapsing, expanding are one decision.** Each item has levels: on the GPU, paged to RAM, paged to disk, +rebuilt from her prompt. A level is an increment on that tier's clearing (the GPU tier, the RAM tier, the disk tier), +with its bytes as width, its value as below and its move (a page-in, a page-out, a re-prefill) as `switch_cost`. +Caching is a level held; collapsing is a grant lowered (a `ShrinkRequested` the holder reports when done); +expanding is a grant raised, which a prediction may raise early (prefetch). No owner has its own victim rule. + +**Values come from prediction, because her inputs and the engine's memory are one system.** The core writes her +prompt and holds the memory it lands in, so the next prompt is mostly known before it is sent: +- *who acts next*: her activity temperature, her tool calls in flight, an unread turn in her room. The value of her + context resident on the GPU is that chance times the prefill seconds a resident page-in saves; +- *where her next prompt diverges*: `Motion` (continuum-context) and her view's stable end. Her checkpoint goes + there, valued by the tokens a resume from it saves; the engine reports each request's actual divergence (`lcp`), so + a miss is measured and names the defect at its source (a live value in a stable block, an unstable tool surface); +- *how much she appends*: `appended_per_act`, so her grant grows ahead of her and a turnover is scheduled when cheap; +- *what minds share*: identical runs across sequences are held once (`seq_cp`), one claim with several owners. +A value without its measurement is the population's for the activity, marked so (provenance), and an unmeasured +claim is granted only its floor. + +**What this deletes:** `window_within`, `lanes_that_fit`, `ModelFootprint::pool_within`, +`window_allocator::allocate`, the process-footprint inference (`lane_footprint`, `fixed_per_lane_bytes`), +`host_prompt_cache_mib`'s own affordable figure, the `--ctx-checkpoints` / `--checkpoint-min-step` derivation, +`gene_residency::victims`, the slots' page victim logic, `coordinator.rs evict_under_pressure`, the persona +allocator's GPU tiers. The fork keeps checkpoints only where the core names them (the boundary rule, fork branch +`fable/boundary-checkpoints`). + +**Order** (each lands before the next, each deletes its sizers): +1. Slice 1's migration: continuum's airc pin moves to include `cambrian-flex` (38a22ab09, 3 commits past the current + pin); the turn's allocation, the view's start grants, the reply claim and grounding claim from it with measured + values; `flex_allocate` and its priorities are deleted. Proven on the proving ground's T0 first. +2. The engine tier: serving's claims above, from the fork's report, as a child tier of the `ResourceDaemon`'s device + tier (slice 2's shape; until slice 2 lands, the serving daemon clears its own grant from the plan's budget). +3. Pages and genes on the same levels; their victim rules deleted. +4. The zero gate: `allocators_outside_the_flexbox` (a sizer outside the solver) at 0, failing on any new one. + +**Validators:** replay the four residents' captures (`fixtures/prompt-captures`) against the fork's measured +holdings: every clearing fits the reported capacity, resumes land at the predicted divergence, and fewer tokens are +re-read than today's 1,244-resume baseline (80% within 8k, 10% past 25k). + ### Acceptance: the user's own load (Joel, 2026-10-30: "What if we start this and someone is playing a video game or starts one later? Or Photoshop") The product runs on someone's computer while they use it. Today (canary, `serving_daemon/reconcile.rs`): diff --git a/docs/architecture/SERVING-ENGINE.md b/docs/architecture/SERVING-ENGINE.md index 13095a82ba..03a0d36f2d 100644 --- a/docs/architecture/SERVING-ENGINE.md +++ b/docs/architecture/SERVING-ENGINE.md @@ -259,36 +259,21 @@ The fills themselves are by design, and one checkpoint at her stable end serves (`seq_cp` of the attention cells plus the head checkpoint, §1). Genes follow the same rule: one copy per adapter, attached to every mind whose focus selects it. -### 7.4 One base: the collapsing flexbox (Joel: "it's always collapsing flexbox style ... everywhere same base classes and interfaces") - -A mind's prompt is already allocated by one base. `flex_allocate` (continuum-grounding, -rag_budget/flex_allocate.rs) grants each claim between its floor and its want by priority, and the -view's `allot` (continuum-context, view/allot.rs) gives each of a claim's items the most detail that -fits, newest first, collapsing the oldest to its summary, its pointer or a fold, each reopenable. -`Motion` (continuum-context, motion.rs) measures what stays the same between starts and orders the -view by it, so the consistent part leads and is kept. - -Memory is the same shape, so it uses the same base, never its own: - -| Prompt | Memory | -|---|---| -| a claim: a source, with floor, want, priority | a mind (her context, her checkpoints, her genes), a cache tier; floor = her in-flight turn, want = her demand, priority = her activity temperature | -| an item: one keyed result, file, card | one keyed run of her context, one checkpoint, one gene | -| Full / Summary / Pointer / Folded | on the GPU / paged to RAM / paged to disk (a page-in reopens it) / dropped, rebuilt from her prompt | -| newest whole, oldest collapses first | hottest resident, coldest pages out first | -| `Motion`: what stays the same between starts leads | what stays the same between her prompts, and between minds, is held once and checkpointed | - -The memory side today has a dozen hand-rolled allocators with their own rules, each a special case -of this: `window_within`, `lanes_that_fit`, `ModelFootprint::pool_within`, `window_allocator::allocate`, -`plan_expert_residency_budgeted`, continuum-kernel's `memory_manager` budgets and `eviction_weight`, -`paging/pool.rs` eviction, the broker's `lane_budgets`, `training_plan::fit`. They converge on the base -and are deleted. The base moves down to one floor crate, generic over the unit (tokens, bytes) and the -item, with the prompt side its first caller unchanged (the pattern-bubbles-up rule). +### 7.4 One solver for prompt and memory (ONE-BUDGET.md) + +Joel: "it's always collapsing flexbox style ... everywhere same base classes and interfaces." The base exists: +`cambrian-flex` (airc `crates/flex`, merged as airc#1630), ONE-BUDGET slice 1. Claims are cleared by measured value +per unit against a scarcity price; an item's levels are indivisible increments with their own value; a move between +levels carries its measured `switch_cost`; custody, provenance and generation fencing are in the type. A mind's prompt +and the engine's memory are two tiers of the same solver, and each keeps only its levels and how to move between them. +The engine-memory slice, with caching, collapsing and expansion as one decision valued by prediction, is ONE-BUDGET.md +"Slice 3b". The hand-rolled memory allocators (`window_within`, `lanes_that_fit`, `pool_within`, +`window_allocator::allocate`, the kernel `memory_manager` budgets, `gene_residency::victims`, the persona allocator's +tiers and the rest) converge on it and are deleted; the gate goes to zero. ### 7.5 Order of work -0. The base: `flex_allocate`, the claim and level types and `allot`'s collapse move down to one floor - crate, generic over unit and item; every prompt caller migrated, test counts unchanged. +0. The base: the prompt's callers move to `cambrian-flex` and `flex_allocate` is deleted (ONE-BUDGET slice 1). 1. Her view survives a restart: the epoch (its start, its items' levels, its appends) is durable state beside her KV page, so a deploy pages her back in where she was instead of starting her over. Validator: replay the captures across the day's restarts; turnovers at a restart go to 0. From 878d75828451f164591938f6b23d0123e9589e4f Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Tue, 3 Nov 2026 08:12:08 -0600 Subject: [PATCH 06/10] ONE-BUDGET slice 3b: the causal floor (her own actions' results are Required at every tier) and a small window as the same clearing at lower capacity; acceptance cases for both Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- docs/architecture/ONE-BUDGET.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/architecture/ONE-BUDGET.md b/docs/architecture/ONE-BUDGET.md index 1a0d41bb24..a1868a5834 100644 --- a/docs/architecture/ONE-BUDGET.md +++ b/docs/architecture/ONE-BUDGET.md @@ -453,6 +453,25 @@ allocator's GPU tiers. The fork keeps checkpoints only where the core names them 3. Pages and genes on the same levels; their victim rules deleted. 4. The zero gate: `allocators_outside_the_flexbox` (a sizer outside the solver) at 0, failing on any new one. +**Her own actions' results are the causal floor** (Joel: "this should help prevent the causal loops too ... anything +where the inference needs to see a state of results from its own actions"). Her newest act, its result, a reply she is +waiting on, and the state her action changed are `Floor::Required` claims at every tier: reserved before anything is +traded, never shrunk, and `Infeasible` (named, refused) when they cannot all fit, never cut. An oversized newest result +claims its summary with its handle as the floor, the rest as an increment (MIND-CONTEXT invariant 2). Everything older +competes by value and collapses to a reopenable level. A loop needs her input to stop reflecting what she did; with the +causal edge in the claim's type, no source's own rule can drop it (Benchy's 125 identical acts, 10-20). + +**A small window is the same clearing at a lower capacity** (Joel: "even intelmacs severely limited context windows +should be doable within an intelligent budgeting flexbox"). The IntelMac's 16,384 tokens per mind holds the causal floor +whole, the stable head once, then the highest-valued increments: her card's files at summary, the room's last turns, +recall at pointers she expands on demand. The M5 at 128,768 clears the same claims to fuller levels. No per-node rule +exists; values are measured per node, so a small node learns which levels its residents reopen. + +**Acceptance cases** (proving ground, then each node's live read): (a) across every captured act of the four residents, +her newest act and result are present whole or at their summary with a handle, at the M5's and the IntelMac's +capacities alike; (b) no two consecutive acts with identical calls and identical inputs (the loop signature) on the +replay; (c) at 16,384 tokens a resident completes a card's read-edit-test cycle on replay with no `Infeasible` clearing. + **Validators:** replay the four residents' captures (`fixtures/prompt-captures`) against the fork's measured holdings: every clearing fits the reported capacity, resumes land at the predicted divergence, and fewer tokens are re-read than today's 1,244-resume baseline (80% within 8k, 10% past 25k). From eafd183741459da8a12f16218e2b04cadd3fcb72 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Tue, 3 Nov 2026 08:20:37 -0600 Subject: [PATCH 07/10] ONE-BUDGET slice 3b: infeasible starts the budgeter's work (repair down measured-damage ladders, then pairwise exchange, then capacity beyond the tier), never stalls her turn Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- docs/architecture/ONE-BUDGET.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/architecture/ONE-BUDGET.md b/docs/architecture/ONE-BUDGET.md index a1868a5834..6c703f09a4 100644 --- a/docs/architecture/ONE-BUDGET.md +++ b/docs/architecture/ONE-BUDGET.md @@ -461,13 +461,35 @@ claims its summary with its handle as the floor, the rest as an increment (MIND- competes by value and collapses to a reopenable level. A loop needs her input to stop reflecting what she did; with the causal edge in the claim's type, no source's own rule can drop it (Benchy's 125 identical acts, 10-20). +**Infeasible is where the budgeter starts working, not where her turn stops** (Joel: "The budgeter must iterate on +things that while infeasible would break what she's doing or themselves entirely, till it hopefully finds a solution +that best fits. It's a bit like a bubble sort"). The solver's pure core still reports `Infeasible`; the tier around it +iterates: +1. **Repair.** Every required claim declares its ladder of viable levels, each with its measured damage (how often a + mind held at that level re-reads, faults or loops: the behaviour model's data): her newest result whole, at its + summary with its handle, at a pointer she opens; her recall at summary, at pointers; a cold mind's context on the + GPU, paged to RAM. While the required floors do not fit, the claim whose next rung costs the least damage steps + down one rung and the tier clears again. Each step strictly lowers demand on finite ladders, so it ends: feasible, + or at every claim's last rung. +2. **Exchange.** On a feasible clearing with indivisible levels the greedy order is a lower bound; passes over pairs + (one claim down a level, another up) keep a swap only when total value rises, until a pass changes nothing. + Value strictly rises on a finite set of states, so it ends, and each pass narrows the reported gap to the bound. +3. **Capacity beyond the tier,** before any refusal: page another mind's cold context out, move pages to RAM, split + her turn (an oversized result read in pages), and on the grid place her where the window is larger. +4. Only then a refusal, naming what she needed and what was tried. + +Both loops are bounded by the claims and their rungs, never by an iteration count someone picked, and each step is in +the clearing's receipt, so the proving ground replays the exact sequence. + **A small window is the same clearing at a lower capacity** (Joel: "even intelmacs severely limited context windows should be doable within an intelligent budgeting flexbox"). The IntelMac's 16,384 tokens per mind holds the causal floor whole, the stable head once, then the highest-valued increments: her card's files at summary, the room's last turns, recall at pointers she expands on demand. The M5 at 128,768 clears the same claims to fuller levels. No per-node rule exists; values are measured per node, so a small node learns which levels its residents reopen. -**Acceptance cases** (proving ground, then each node's live read): (a) across every captured act of the four residents, +**Acceptance cases** (proving ground, then each node's live read): (0) a scenario whose required floors exceed +capacity ends in a clearing (repaired) whose damage is no more than a brute-forced optimum's on small cases, never a +stalled turn; (a) across every captured act of the four residents, her newest act and result are present whole or at their summary with a handle, at the M5's and the IntelMac's capacities alike; (b) no two consecutive acts with identical calls and identical inputs (the loop signature) on the replay; (c) at 16,384 tokens a resident completes a card's read-edit-test cycle on replay with no `Infeasible` clearing. From 782202d11891fab3583dea643541056390298d11 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Tue, 3 Nov 2026 08:24:08 -0600 Subject: [PATCH 08/10] ONE-BUDGET slice 3b: the lane rungs (a larger pool share for one turn, one lane on the whole pool, the pool grown live) before any refusal Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- docs/architecture/ONE-BUDGET.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/architecture/ONE-BUDGET.md b/docs/architecture/ONE-BUDGET.md index 6c703f09a4..4c1dd0fc53 100644 --- a/docs/architecture/ONE-BUDGET.md +++ b/docs/architecture/ONE-BUDGET.md @@ -474,8 +474,14 @@ iterates: 2. **Exchange.** On a feasible clearing with indivisible levels the greedy order is a lower bound; passes over pairs (one claim down a level, another up) keep a swap only when total value rises, until a pass changes nothing. Value strictly rises on a finite set of states, so it ends, and each pass narrows the reported gap to the bound. -3. **Capacity beyond the tier,** before any refusal: page another mind's cold context out, move pages to RAM, split - her turn (an oversized result read in pages), and on the grid place her where the window is larger. +3. **Capacity beyond the tier,** before any refusal, in order of measured cost: page another mind's cold context out; + grant her a larger share of the shared pool for this turn (others' cold pages to RAM, back when her turn ends, a + temporary grant priced by its switch cost); move pages to RAM; split her turn (an oversized result read in pages); + serve her alone on the whole pool, every other mind paged out for one turn (the last rung, Joel: "or reduce to one + lane in worst case scenario"); grow the pool into free memory once the engine resizes live (SERVING-ENGINE S2); + and on the grid place her where the window is larger. Each exists only because every holder is a claim with levels, + a cost and custody: a fixed slot or a private cap anywhere is the one place the budgeter could not move (Joel: "If + we follow rich and strict architectural adherence we can always get ourselves out of a bind"). 4. Only then a refusal, naming what she needed and what was tried. Both loops are bounded by the claims and their rungs, never by an iteration count someone picked, and each step is in From b8de1dbe45da26d533132cdd48ffb0d1a73ab887 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Tue, 3 Nov 2026 10:42:19 -0600 Subject: [PATCH 09/10] ONE-BUDGET + SERVING-ENGINE: a page's level depends on its active genes (one bundle for the restore), attention and recurrent state are separate claims, why the solver lives in airc and how it is developed (Cormac on #5723) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- docs/architecture/ONE-BUDGET.md | 24 ++++++++++++++++++++---- docs/architecture/SERVING-ENGINE.md | 2 +- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/docs/architecture/ONE-BUDGET.md b/docs/architecture/ONE-BUDGET.md index 4c1dd0fc53..b6bef8f9db 100644 --- a/docs/architecture/ONE-BUDGET.md +++ b/docs/architecture/ONE-BUDGET.md @@ -155,7 +155,12 @@ types for network grants and must stay separately capable, so the crate depends (ts-rs behind a feature), the same "bubble down" rule as `airc_core::shown_id`. Its home (settled by Cormac in review): its own crate in the airc workspace, `crates/flex`, package `cambrian-flex`, named for the pattern and neutral to both repos, not inside `airc-core` (which keeps its one job). Continuum depends on it through its existing airc pin; -airc's NETWORK-AUTHORITY consumes it. Slice 1's code therefore lands as an airc PR. Pure: no I/O, no clock, no randomness (THE-PROVING-GROUND P8). Generic over a unit type each +airc's NETWORK-AUTHORITY consumes it. Slice 1's code therefore lands as an airc PR. The cost of that home +(Cormac on #5723): a solver change is an airc PR plus a continuum pin bump, not an edit beside the caller. It is +paid once per API change, not per memory-policy change: policy (values, levels, claims) lives in continuum and calls +the solver; only the solver's own types and clearing live in airc. While a solver change is being developed, a +local `[patch]` in the developer's `.cargo/config.toml` points continuum at their airc checkout, so the edit is +checked in seconds and the pin moves only when the airc PR merges. Pure: no I/O, no clock, no randomness (THE-PROVING-GROUND P8). Generic over a unit type each consumer defines (`Tokens`, `Bytes`, `LaneSeconds`, bytes in flight); continuum-only pieces (where values come from, the behaviour model, ts-rs bindings) stay out of it. @@ -405,7 +410,7 @@ expansion, in the flexbox or any of your memory constraints." **What the engine holds, by its own report** (fork `resident_state`, CambrianTech/llama.cpp#91, read live on the M5 2026-11-03 12:51Z, Qwen3.6-35B-A3B at 2 x 128,768): target weights 20.69 GB, target KV and recurrent state 2.14 GB -(8,317 B/token), one compute graph 1.87 GB, the draft model 3.15 GB, the projector 0.90 GB, one checkpoint 94.6 MB +(8,317 B/token as one figure; it is two holders, below), one compute graph 1.87 GB, the draft model 3.15 GB, the projector 0.90 GB, one checkpoint 94.6 MB (x 32 per slot at today's `--ctx-checkpoints` = 3.0 GB per mind). Before #91 the plan saw only the first three and inferred the rest from the process footprint as a per-lane term that read 2.8 to 4.5 GB a minute apart. @@ -414,11 +419,20 @@ inferred the rest from the process footprint as a per-lane term that read 2.8 to | Holder | Claim on `cambrian-flex` | |---|---| | Weights, graph, draft, projector of the serving model | `Floor::Required`, the engine's reported bytes | -| A mind's context, resident | `Floor::Required` = what her in-flight turn holds (a grant never shrinks under a running turn); then one indivisible increment per block of her context, valued as below | +| A mind's context, resident | `Floor::Required` = what her in-flight turn holds (a grant never shrinks under a running turn); then one indivisible increment per block of her context, valued as below. On a hybrid model the attention cells are per token and may be shared (`seq_cp`); the recurrent state is per sequence and is never shared, so each owner pays her own. The two are separate claims, and the fork's report gives each its own bytes (today it reports one 8,317 B/token figure; the split is a field #91 adds) | | Her checkpoint | one indivisible increment of its reported bytes, at her predicted divergence point | | Prompt cache | divisible increments, valued by measured restore hits | | Her genes | one indivisible increment per adapter her focus selects; an adapter shared by several minds is ONE claim | +**A page's level depends on its genes** (Cormac on #5723). Since fork #90, a paged-out KV page restores only when +every adapter ACTIVE on it (scale != 0) is attached at the same file revision; otherwise the engine refuses it and +she re-prefills cold (IntelMac 2026-11-03, task 519: 1,139 s for 13,144 tokens after a refused restore). So her +page at a resident or paged level and its active genes are one bundle for the restore: the solver may keep the page +paged only while those genes are held at a level that can attach them before the page-in, and the page-in's +`switch_cost` includes attaching any that are not. A page whose genes are lowered below that is valued as what it +then is, a re-prefill, never as the page-in it can no longer be. This is a dependency between claims, the joint form +of `cambrian-flex` part 2 (airc#1632), not a rule inside either owner. + **Caching, collapsing, expanding are one decision.** Each item has levels: on the GPU, paged to RAM, paged to disk, rebuilt from her prompt. A level is an increment on that tier's clearing (the GPU tier, the RAM tier, the disk tier), with its bytes as width, its value as below and its move (a page-in, a page-out, a re-prefill) as `switch_cost`. @@ -433,7 +447,9 @@ prompt and holds the memory it lands in, so the next prompt is mostly known befo there, valued by the tokens a resume from it saves; the engine reports each request's actual divergence (`lcp`), so a miss is measured and names the defect at its source (a live value in a stable block, an unstable tool surface); - *how much she appends*: `appended_per_act`, so her grant grows ahead of her and a turnover is scheduled when cheap; -- *what minds share*: identical runs across sequences are held once (`seq_cp`), one claim with several owners. +- *what minds share*: identical runs of attention cells across sequences are held once (`seq_cp`), one claim with + several owners. The recurrent state at the end of a shared run is per sequence: copied, not shared, and each owner's + own claim. A value without its measurement is the population's for the activity, marked so (provenance), and an unmeasured claim is granted only its floor. diff --git a/docs/architecture/SERVING-ENGINE.md b/docs/architecture/SERVING-ENGINE.md index 03a0d36f2d..9b4986aab3 100644 --- a/docs/architecture/SERVING-ENGINE.md +++ b/docs/architecture/SERVING-ENGINE.md @@ -202,7 +202,7 @@ Qwen3.6-35B-A3B, `-c 257214 --parallel 2 --ctx-checkpoints 32`, two 13.9k-token | Holder | Bytes | Notes | |---|---|---| | Target weights | 20.69 GB | mmapped | -| Target KV + recurrent state | 2.14 GB | 8,317 B/token over 257,536 tokens | +| Target KV + recurrent state | 2.14 GB | 8,317 B/token over 257,536 tokens, reported as one figure. Two holders: attention cells per token (shareable by `seq_cp`) and recurrent state per sequence (never shared); #91 reports them separately | | Target compute graph | 1.87 GB | one graph for the shared pool | | Draft (MTP) context | 3.15 GB | 1.34 weights, 0.53 KV, 1.29 compute: unreported before | | Projector | 0.90 GB | unreported before | From 16abaadd40e03fa16bbf439464e7cfea6441bf52 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Tue, 3 Nov 2026 10:43:51 -0600 Subject: [PATCH 10/10] ONE-BUDGET: the 16,384-token small-window case is a chosen replay capacity, not the IntelMac's grant (that figure was 11-03's publication bug; Cormac on #5723) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- docs/architecture/ONE-BUDGET.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/architecture/ONE-BUDGET.md b/docs/architecture/ONE-BUDGET.md index b6bef8f9db..8af72b9ec1 100644 --- a/docs/architecture/ONE-BUDGET.md +++ b/docs/architecture/ONE-BUDGET.md @@ -504,8 +504,9 @@ Both loops are bounded by the claims and their rungs, never by an iteration coun the clearing's receipt, so the proving ground replays the exact sequence. **A small window is the same clearing at a lower capacity** (Joel: "even intelmacs severely limited context windows -should be doable within an intelligent budgeting flexbox"). The IntelMac's 16,384 tokens per mind holds the causal floor -whole, the stable head once, then the highest-valued increments: her card's files at summary, the room's last turns, +should be doable within an intelligent budgeting flexbox"). A mind granted a small window (16,384 tokens, say: a capacity chosen +for the replay, not a node's measured grant; the IntelMac's "16,384 per mind" on 11-03 was a publication bug) holds +the causal floor whole, the stable head once, then the highest-valued increments: her card's files at summary, the room's last turns, recall at pointers she expands on demand. The M5 at 128,768 clears the same claims to fuller levels. No per-node rule exists; values are measured per node, so a small node learns which levels its residents reopen. @@ -514,7 +515,7 @@ capacity ends in a clearing (repaired) whose damage is no more than a brute-forc stalled turn; (a) across every captured act of the four residents, her newest act and result are present whole or at their summary with a handle, at the M5's and the IntelMac's capacities alike; (b) no two consecutive acts with identical calls and identical inputs (the loop signature) on the -replay; (c) at 16,384 tokens a resident completes a card's read-edit-test cycle on replay with no `Infeasible` clearing. +replay; (c) at a chosen replay capacity of 16,384 tokens a resident completes a card's read-edit-test cycle on replay with no `Infeasible` clearing. **Validators:** replay the four residents' captures (`fixtures/prompt-captures`) against the fork's measured holdings: every clearing fits the reported capacity, resumes land at the predicted divergence, and fewer tokens are