Skip to content

A restart restores every mind warm: the page store keeps minds' pages for a volume others filled, and a cold boot names why - #5987

Merged
joelteply merged 10 commits into
canaryfrom
fable/a-restart-restores-every-mind-warm
Nov 14, 2026
Merged

joelteply merged 10 commits into
canaryfrom
fable/a-restart-restores-every-mind-warm

Conversation

@joelteply

@joelteply joelteply commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Serves resident minds' speed across a deploy (path step 1 "Fast", order-of-work line 3b): serving should come down and up with every mind restoring her page (~1 s), not re-prefilling her context.

The gap (file:line, canary bd90b99)

The halves the task assumed missing exist and are tested:

  • Save at stop: core/continuum-engine/src/inference/slots/page_io.rs:59-152 (PageIoSettle → checkpoint_every_endpoint → checkpoint_endpoint → EndpointTransition::checkpoint_residents, engine_generation.rs:453), through the fork's existing /slots/{id}?action=save.
  • Key: saved_ledger.rs KvPageContract::fingerprint (model, adapters and draft by path/size/mtime, KV cache type, flash attention). Deliberately not the engine build or window: the engine checks the page's own state magic/version and fit, loudly.
  • Restore before her first act: kv_slot_pool.rs:263 lease_paged / plan_paging → restore inside her first act's admission; test turn_admission/tests/lifecycle.rs every_mind_resumes_where_she_left_off_across_a_stop_and_a_boot.

What actually lost the minds' state on the M5 (core log ~/.continuum/logs/continuum-core-server.log*, engine log llama-server-58057.log):

  1. The page store deleted paged-out minds' confirmed pages under volume pressure it did not cause. page_store_pool.rs pressure() = max(own, volume); the broker (broker.rs evict_amount_for) asks 10% of capacity (9,946,101,555 B) at High. The volume was 0.85 (143 GiB free of 926) and the store held ~2.6 GB of a 92.6 GiB budget, yet rung 3 forgot 29 minds' pages between 22:40Z and 00:50Z (inference.kv_page.store_evicted cold_minds_forgotten=1, roughly every time a mind left her slot). Right now only 2 of 4 residents have a page on disk.
  2. The 23:45Z deploy restored nothing, and nothing said why. ledger_attached carried=false loaded=0 at 23:45:39Z, then every first act was cold_turn cause="no_page" (11,148 and 23,060-token cold prefills in the engine log). SavedLedger::load returned empty on a missing ledger silently (saved_ledger.rs, Err(NotFound) => return LoadedLedger::default()), and its other refusals were strings.
  3. The 23:40Z stop left no checkpoint receipt. inference.kv_page.settled at 23:40:21Z, then neither stop_checkpoint nor stop_checkpoint_skipped. checkpoint_every_endpoint skipped an endpoint with no owned generation (an adopted engine) silently (continue; // never launched here). The log also ends at system:shutdown 23:42:00Z, so whether a receipt was written and then lost in the tail can't be told from here (inference, unverified).

The fork needs nothing new: save and restore are its existing routes, already exercised live (receipts below).

Simulator first: dyno 11 (capacity/dyno/restart.rs, fixtures/dyno/2026-11-13-restart.json)

Every input is a receipt: the four residents' slot tokens (73,826 / 36,893 / 90,853 / 51,749), the aggregate four-mind cold prefill after the 00:18Z relaunch (632 tok/s), page bytes per token (32,273 B), restore rate (1,464,377 B/ms) and save rate (603,433 B/ms) from live kv_page.action receipts, and the store/volume pressure.

4 residents, 253,321 tokens re-prefilled last mind acting again added to the stop
before: cold (what 23:45Z did) 253,321 tokens ~401 s (first at ~234 s) 0
after: restored 0 ~5.6 s ~13.5 s (four saves)

A paged-out mind under the recorded pressure: before (the store yields) she re-prefills 36,893 tokens (~58 s); after (the store keeps her page) she restores like the residents.

Concurrency and events (Joel 2026-11-14; RTOS rule 10, #5986)

  • Stop: engine_generation::checkpoint_pool issues every resident's save at once and joins on their receipts. Before, it awaited one slot after another. page_io also checkpoints every endpoint at once.
  • Drain: page_io::settle waits on the admission gate's drain event, the new AdmissionGate::drained (a Notify fired when the last permit releases). Before, it polled every 50 ms under a deadline. The stop's checkpoint no longer runs under tokio::time::timeout(cap) and no longer skips on a spent budget. A page action that never answers ends through kv_page_action's own error events.
  • Start: restores were already per mind. Each mind's first act restores her own page inside her own admission and waits on that receipt only.
  • The engine's real parallelism is 1. The pinned fork (cd2e16d87) runs page tasks one at a time on its single task loop: tools/server/server-queue.cpp:138-153 (process_new_tasks), save at server-context.cpp:2809/2960, restore at 2996/3076. Measured 2026-11-14 00:18:13Z: two restores the core issued at once, Aris (engine_ms=1012) and Benchy (wait_ms=1024). Benchy waited for Aris's engine time.
  • What the fork needs so overlapped page IO pays off: snapshot the sequence to host on the loop (llama_state_seq_get_data, a memcpy on unified memory), then write the file and its sidecars on a worker. For a restore, read the file on a worker, then llama_state_seq_set_data on the loop. The core side needs no change for that.
dyno 11, 4 residents stop (saves) last mind acting each mind
cold (before) 0 ~401 s 234-401 s, 253,321 tokens re-prefilled
restored, today's 1-lane fork ~13.5 s (sum) ~5.6 s behind the restores issued before hers
restored, an overlapping fork ~4.9 s (largest save, Atlas 90,853 tokens) ~2.0 s only her own restore (0.8-2.0 s)

The fix (at the existing owners, no parallel path)

  • page_store_pool.rs: rung 3 (confirmed minds' pages) yields only to the store's own pressure (High+) or a Critical volume (ColdPages::under). Dead pages (unserved dirs, unconfirmed) still go under any pressure, so the class keeps its eviction story. A keep is a typed Decline::MindsPagesKept, probed only when it changes (no 5 s narration).
  • broker.rs: High relieves the first pool, in pressure order, that frees bytes. A pool that keeps what it holds passes the request on instead of stalling relief. This also removes the unwrap_or(&[]) fallback.
  • saved_ledger.rs: a typed LedgerUnread {Missing, Unreadable, Malformed, LegacyUndated, OtherPageFormat} on LoadedLedger, and a missing ledger is probed (inference.kv_page.ledger_unread why="missing"). A cold boot is never silent.
  • page_io.rs: the stop names every endpoint it did not checkpoint, with a typed StopCheckpointSkip {Adopted, NoPagedEngine} and the resident count. It also probes stop_checkpoint_started before the drain, so a stop cut mid-checkpoint still says whom it was saving.
  • Docs: the CONTINUUM-ENGINE.md §7.0 scenario row, the dyno table row 11, the eviction-decision and broker-wiring comments.

Tests

  • slots/tests/ledger.rs a_restart_names_why_its_ledger_restored_nothing: key mismatch → OtherPageFormat (typed discard, nothing offered); missing → Missing; malformed → Malformed; matching key → no reason, her page offered.
  • page_store_pool.rs a_hot_volume_takes_dead_pages_but_keeps_minds_pages_across_a_restart: under the M5's recorded pressure, dead pages go, the paged-out mind's page stays confirmed, and a restarted pool's ledger offers it (she restores). the_stores_own_pressure_or_a_critical_volume_still_takes_minds_pages covers both Yield arms.
  • broker.rs high_pressure_moves_past_a_pool_that_frees_nothing.
  • Dyno 11: a_restart_with_four_resident_minds_restores_instead_of_re_prefilling, a_paged_out_mind_keeps_her_page_under_the_recorded_pressure.
  • Matching key → restore before her first act with no re-prefill of the restored prefix: already pinned by every_mind_resumes_where_she_left_off_across_a_stop_and_a_boot (real admission, fake engine), unchanged.

Lines

+312 / -45 across 12 files (incl. a 141-line dyno module, a 30-line fixture and ~120 lines of tests). Removed: the High-tier first()/unwrap_or(&[]) path, the string-typed ledger refusal reasons, and the silent NotFound and continue returns. No file over 1,000 lines touched (largest: engine_generation.rs, 935).

Not compiled locally

The M5 is serving live minds, so per the rules nothing was built here. CI is the compiler.

Measured: live receipt (after deploy; owner: whoever deploys this, by the next deploy)

  • Before (2026-11-13 23:45Z deploy, M5, canary at that time): first acts cold_turn cause="no_page" for every mind; 11,148 / 23,060 / 14,217-token cold prefills in the first minutes; prefix reuse 70% → 57% in the hour after (from the brief).

  • After: on the next deploy, read the following:

    • inference.kv_page.stop_checkpoint_started / stop_checkpoint ok=true, or stop_checkpoint_skipped reason= at the stop;
    • ledger_attached loaded=N (N = residents) or ledger_unread why= at the boot;
    • per mind, kv_page.action action=restore before her first act, with cold_turn absent;
    • over the next hour, store_evicted cold_minds_forgotten stays 0 while the volume is below 0.95.

    Target: tokens re-prefilled per mind ≈ her new tail only, time to first act ≈ restore ms (~1 s per mind).

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

… for a volume others filled, and a cold boot names why

Serves resident minds' speed across a deploy (path step 1, order-of-work line 3b): a
restart should cost a mind a ~1 s page restore, not a full re-prefill of her context.

The save at stop, the format-keyed ledger and the restore before her first act already
exist and are tested (page_io::checkpoint_every_endpoint, SavedLedger fingerprint,
every_mind_resumes_where_she_left_off_across_a_stop_and_a_boot). What failed on the M5
2026-11-13: the KV page store gave 29 paged-out minds' confirmed pages to a High-tier
volume request (volume 0.85, store 3% of its budget) between 22:40Z and 00:50Z, and the
23:45Z boot's ledger restored nothing (ledger_attached loaded=0, every first act
cold_turn cause="no_page"), with no reason anywhere.

- page_store_pool: confirmed minds' pages (rung 3) yield only to the store's own
  budget pressure (High+) or a Critical volume (ColdPages); dead pages still go under
  any pressure; a keep is a typed decline (minds_pages_kept), probed on change only.
- broker: High relieves the first pool, in pressure order, that frees bytes, so a pool
  that keeps what it holds passes the request on (drops the unwrap_or(&[]) fallback).
- saved_ledger: why a ledger restored nothing is a typed LedgerUnread; a missing
  ledger is probed instead of silently returning empty.
- page_io: the stop names every endpoint it did not checkpoint (adopted engine, no
  paged engine) and probes before the drain, so a cut stop still says whom it saved.
- dyno 11 (restart.rs + fixtures/dyno/2026-11-13-restart.json): four recorded residents
  (253,321 tokens) cold: last acting at ~401 s; warm: 0 re-prefilled, ~5.6 s of restores
  plus ~13.5 s in the stop; a paged-out mind keeps her page under the recorded pressure.

Not compiled locally (the M5 is serving); CI is the compiler.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply and others added 9 commits November 13, 2026 19:10
…atch; ratchets fixed

Joel (2026-11-14): independent work runs concurrently, never serial minutes; RTOS rule 10
(#5986): no timeout or sleep decides flow in the save/restore path.

- engine_generation::checkpoint_pool issues every resident's save at once and joins on
  their receipts (was one await per slot). page_io checkpoints every endpoint at once.
- page_io::settle waits on the admission gate's drain event (new AdmissionGate::drained,
  a Notify fired when the last permit releases) instead of a 50 ms poll under a deadline;
  the stop's checkpoint no longer runs under tokio::time::timeout(cap) and no longer skips
  on a spent budget. A page action that never answers ends through kv_page_action's own
  error events.
- Restores were already per mind: each mind's first act restores her own page inside her
  own admission and waits on that receipt only.
- The fork serializes page tasks: one task loop (tools/server/server-queue.cpp:138-153,
  save server-context.cpp:2809/2960, restore 2996/3076 at cd2e16d87). Measured 00:18:13Z:
  two restores issued at once, Benchy wait_ms 1,024 = Aris engine_ms 1,012.
- dyno 11 models the engine's page lanes: one lane (today) stop 13.5 s, restores to 5.6 s;
  overlapped, stop = largest save 4.9 s and each mind only her own restore (max 2.0 s).
- Ratchets: the ledger writes through durable::write_replace (no fs::write); restart.rs is
  #![cfg(test)] (one test mod in dyno.rs); the broker's unwrap_or carry their reasons.

Not compiled locally (the M5 is serving); CI is the compiler.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…oint, Ratio, Result ledger

Review of #5987 (~/.continuum/evidence/js-shaped-rust-2026-11-14/review.md):
- #4 page_store_pool: Ratio newtype built only from a part and a nonzero whole; StorePressure
  { own, volume: Option<Ratio> }; an unread pressure never keeps (ColdPages::Yield); no .max(1)
  or map_or(0.0). The dyno fixture records bytes, not ratios.
- #5 CheckpointFailure<E: Error> (own file, thiserror): Engine(E) | Admission(String) |
  Save { slot, kind: SaveFailure::{Rejected, Unresolved, Uncertain} }; no format! sentences.
  checkpoint_residents returns OwnedCheckpointRefusal variants instead of strings;
  AdoptedCheckpointRefusal::Save carries { slot, kind }.
- #6 page_io::checkpoint_endpoint -> StopCheckpoint { Ended, EngineChanged, Saved,
  Failed(CheckpointFailure) }; no Err(()) -> String, no Option wrapper.
- #7 PageAction { Save, Restore, Erase } (serde lowercase on the wire via .query());
  every kv_page_action / page_action caller, the receipt judge and UnresolvedPage migrated.
- #21 SavedLedger::load -> Result<LoadedLedger, LedgerUnread>; Unreadable(io::ErrorKind).
- #22 CheckpointSave: consuming confirmed()/rejected(); unanswered drop quarantines.
- #23 stop probes keep residents as Probed<u64>.
- #24 broker sorts with total_cmp.
- low: probes record the enums with Debug; the as_str tables are deleted.

Not compiled locally (the M5 is serving); CI is the compiler.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
Saves are now issued at once, so the cancellation case waits for slot 1's held save
and slot 0's confirmation before it cuts, instead of relying on serial order.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…tores-every-mind-warm

# Conflicts:
#	core/continuum-engine/src/inference/slots/page_io.rs
#	core/continuum-engine/src/inference/turn_admission/tests/lifecycle.rs
#	core/continuum-engine/src/inference/turn_admission/tests/restore_refusal.rs
#	core/continuum-kernel/src/runtime/admission_gate.rs
@joelteply
joelteply merged commit cd75678 into canary Nov 14, 2026
37 checks passed
@joelteply
joelteply deleted the fable/a-restart-restores-every-mind-warm branch November 14, 2026 07:16
joelteply added a commit that referenced this pull request Nov 14, 2026
…6004)

Live receipt for #5987 on the M5 (canary 7f875cc, 2026-11-14 07:48-07:53Z): the stop's
checkpoint saved one resident of four (07:48:28Z, slot 3, Benchy); the new engine (fork pin
b5534b531) and core attached the ledger (loaded=1) and restored Benchy, while Aiko, Aris and
Atlas came up cold (cold_turn cause="no_page"). The key matched (same fingerprint; Benchy
restored) and the page store evicted nothing (every pass declined page_io_busy). The cause:
the stop condemns acts in flight (#5988), and a cut act's drop forgets her attribution
(TurnAdmission::drop -> forget_resident), so checkpoint_pool, which saved only `holders`,
had nobody to save in those slots.

KvSlotPool::stop_residents is the checkpoint's resident set: every attributed resident, plus
each slot still holding a sequence of a mind attributed nowhere (LiveSequences::held): a
confirmed sequence when at least as new as her page, an unconfirmed one (her cut act) only
when she has no page. One save per page.

Test: a_mind_whose_act_the_stop_cut_is_saved_and_restores_after_the_boot (engine A, a cut
act, the stop, engine B and a new core: both minds restore what their slots held).

Not compiled locally (the M5 is serving); CI is the compiler.


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

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant