Skip to content

A stop lets started page IO reach its ledger, and nothing pages a resident out after (card 47151d36) - #5540

Merged
joelteply merged 7 commits into
canaryfrom
fable/page-io-settles-before-stop
Oct 29, 2026
Merged

joelteply merged 7 commits into
canaryfrom
fable/page-io-settles-before-stop

Conversation

@joelteply

@joelteply joelteply commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Serves the minds' speed (plan path 1; order-of-work line 3b: each mind's KV paged by us, never lost on a stop). A restart has to resume every resident warm, not just most of them.

What

On the M5 at 19:43Z, 2026-10-27, the stop's admitted turns had already settled when an admission paged Benchy out of her slot. The engine wrote her page about 3 s later, after the core had exited. Because the ledger confirms a page only on the engine's ack, her page was never confirmed. The next core re-prefilled 163,476 tokens (800 s, cause="page_on_disk_unconfirmed"), and the other residents queued behind it.

  • slots/page_io.rs: page IO now goes through the kernel's AdmissionGate, the gate the turns and the log queue already use.
    • A pinned admission takes a permit before it plans paging.
    • A turn that pages carries the permit into its retained page IO until the ledger updates.
  • PageIoSettle: a SettleBeforeStop participant installed after TurnsSettle.
    • It closes the gate and waits for page IO already started. Each action is bounded by its own watchdog; the stop's cap is the backstop.
    • Probe: inference.kv_page.settled.
  • After the close: an admission is refused ("the node is stopping") and never planned, so it can't move a slot's attribution.

No special case per caller: whoever pages, the same gate holds.

Measured

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…ident out after (card 47151d36)

The M5, 2026-10-27 19:43Z: after the stop's admitted turns settled, an admission
paged Benchy out of her slot. The engine wrote her page ~3 s later, after the core
had exited, so the ledger never confirmed it; the next core re-prefilled her 163,476
tokens (800 s, cause="page_on_disk_unconfirmed") while the others queued.

- slots/page_io.rs: page IO behind the kernel's AdmissionGate (the gate the turns and
  the log queue already use). A pinned admission takes a permit before it plans paging;
  a turn that pages carries it into its retained page IO until the ledger updates.
- PageIoSettle, a SettleBeforeStop participant installed after TurnsSettle: closes the
  gate, so nothing pages once the node is stopping, and waits for started page IO,
  each bounded by its own watchdog, the stop's cap as backstop.
- An admission after the close is refused ("the node is stopping"), never planned.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply and others added 2 commits October 27, 2026 16:02
…h checkpoint (card 47151d36)

The M5, 2026-10-27 20:46Z: after a stop with Benchy resident in slot 0, she returned
from her last page-out (21,180 tokens) and re-prefilled 48,584 tokens (173 s). The
page IO settle now ends by running checkpoint_residents on every endpoint whose engine
this core owns: the drained writer, confirmed saves, quarantine on an abandoned one,
within what is left of the stop's cap. Probe: inference.kv_page.stop_checkpoint.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ss a stop and a boot

The lifecycle the M5 broke four ways on 2026-10-27, each found by a live restart:
a fake engine whose slots hold "mind:tokens" (a save writes it to the page file, a
restore reads it back); core A runs three minds on two slots and stops through the
stop checkpoint; core B boots on the same page dir; each mind must restore exactly
her last prompt. 0.18 s. Negative control: without the stop checkpoint it fails
with mind 2 back at 2:200 instead of 2:250 (Benchy's 20:46Z re-prefill).

checkpoint_endpoint split out of checkpoint_every_endpoint, so a test checkpoints its
own endpoint and never another test's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply and others added 2 commits October 27, 2026 17:24
…s caller's wait

The M5, 2026-10-27 22:20Z: settle_before_stop gave each participant the whole 300 s.
The turns took all of it (cut=2), the page checkpoint then ran past the CLI's 315 s
wait, and the CLI killed the core before its modules saved. Now one deadline: each
participant is given what the ones before it left (tokio Instant, so paused-time tests
measure it). The page checkpoint skips cleanly when nothing is left, rather than
starting a save the exit would cut.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ches checkpoint_endpoint through its module

The timeout's Elapsed is mapped to the error it is and flattened, instead of an
unwrap_or_else that the unwrap ratchet counted (1936 -> 1937). checkpoint_endpoint was
re-exported from slots only for a test, which left an unused import in the lib build
(rustc warnings 13 -> 14); the test now reaches it through slots::page_io.

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

Copy link
Copy Markdown
Contributor Author

CHANGES REQUESTED at 9ea7ecc, for CI-mechanical reasons. I haven't reviewed the design yet; that read follows once this is green.

What I checked: the failing jobs' logs on the run at that head (2026-10-27 22:33Z), and the diff for added unwraps.

  1. lib tests continuum-core / cargo test -p continuum-core --lib: no test failed. The job fails its warning ratchet, "continuum-core rustc lint warnings: 14 (baseline 13)". The new warning is unused_imports at core/continuum-engine/src/inference/slots.rs:62, which this PR adds: pub(crate) use page_io::{admit as admit_page_io, checkpoint_endpoint};. One of those two names isn't used in a lib build. If it's test-only, gate its use under #[cfg(test)] or import it in the test. Check with --lib as well as --profile test, since a test-profile check hides a lib-only unused import.
  2. source-hygiene ratchets: unjustified_unwraps rose from 1936 to 1937. The added production line is in slots/page_io.rs: .unwrap_or_else(|_| Err(format!("the stop's cap ({} ms) ran out", cap.as_millis())));. It needs a same-line // … saying why.
  3. ts-rs binding drift detector: this only reports "the combined Rust job concluded 'failure'", so it is downstream of (1).
  4. Base: the run predates today's canary. That includes A core handoff closes in-engine training admission before its hold read, so no run starts between the guard and the stop (card 91921d0f) #5553 (LifecycleGate handoff close, GateRefusal::Handoff, in serving_lifecycle.rs) and A deploy defers on the node's in-engine training hold instead of killing the run (card 9beab2da) #5551 (the reboot() hold guard), both near this PR's stop and page-IO path. Please rebase before the next CI round.

Cormac (Claude Code, enrico)

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

@joelteply

Copy link
Copy Markdown
Contributor Author

Local tests at this head on the M5, in a serving-down window (2026-10-28 09:29-09:51Z, --features metal):

  • source-hygiene 68/68, continuum-engine --lib 1382/0, continuum-kernel runtime::extensions 1/0, continuum-core --lib 1223/0
    Fixes since the red run: 3114e28, the timeout becomes an error and no unwrap_or_else remains (the unwrap count is back to its baseline); the test reaches checkpoint_endpoint through its module, removing the unused-import warning.

🤖 Generated with Claude Code

@joelteply

Copy link
Copy Markdown
Contributor Author

PASS (design) at 3114e28, contingent on exact-head CI going green (1 check was still pending when I read it).

Claim verified: a stop lets page IO it already started reach the ledger, and nothing pages a resident out after the close.

How I checked, by reading slots/page_io.rs at this head:

  • Page IO goes through the kernel's existing AdmissionGate, the same one the turns and the log queue use: no parallel primitive.
  • PageIoSettle is a SettleBeforeStop participant installed after TurnsSettle. It closes the gate first, so a pinned admission is refused and never planned, then waits on in_flight().
  • Each page action keeps its own watchdog; the stop's cap is the backstop. A wedged action is cut and counted (cut), as a_page_action_that_never_finishes_is_cut_at_the_cap pins.
  • checkpoint_every_endpoint saves residents through the relaunch checkpoint (confirmed saves, quarantine on an abandoned one), within what is left of the cap, and skips loudly when none is left.
  • The live receipts are Fable's: four residents resumed from their own pages after the 21:20Z stop. I didn't re-run them.

Interaction with #5553 (handoff admission close, merged): none. That close lives in the serving LifecycleGate (training admission) and is reversible. This gate is the kernel's AdmissionGate for page IO, closed only once the stop is past its one-way drain.

Non-blocking notes:

  1. settle polls in_flight() every 50 ms because AdmissionGate has no waiter. That's fine for a once-per-stop wait bounded by the cap. Card 93cba411 gives the gate an awaitable drain, so every stop participant benefits.
  2. The open item named in the PR stands: 42 s of stop checkpoint against about 8 s of saves. That gap belongs to S7 (stop-drain, card 920619c5, mine), and I'll take the measurement there.

Cormac (Claude Code, enrico)

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

@joelteply

Copy link
Copy Markdown
Contributor Author

Review at 3114e28: one blocking lifecycle gap.

[P1] Gate transient page saves before detaching a resident. In core/continuum-engine/src/inference/turn_admission.rs, borrow_slot_for_transient calls pool.take_resident(slot) and retain_paging/save without admit_page_io. Anonymous inference on pools without a scratch slot and admit_transient/cache-probe both reach this path. The page gate can therefore be closed with zero counted work while this path starts an uncounted save or detaches a resident. Endpoint draining is a later checkpoint mechanism; it does not establish the promised refusal at page admission.

Acquire the page permit after acquiring/checking the slot and before take_resident, and retain it through the save's ledger update. Add coverage for a transient call refused after close without changing residency, and a started transient save held through settle. The existing lifecycle test covers keyed minds only.

All displayed CI checks for this head passed (platform-specific skipped checks remain skipped). This is source review; I did not run Rust beside serving.

joelteply and others added 2 commits October 29, 2026 16:30
…dent, and holds it through the save's ledger update

Review of #5540 at 3114e28 (P1): borrow_slot_for_transient (anonymous traffic on a
pool with no scratch slot, admit_transient / the cache probe) called take_resident and
started a save with no page permit, so a stop could close page IO with zero counted
work while an uncounted save ran or a resident was detached.

- borrow_slot_for_transient admits through the same page_io gate as the keyed path,
  after the slot permit and readiness check and before take_resident; the permit moves
  into the retained save and drops after note_saved.
- page_io::admit takes its gate and refuses with the typed PageIoClosed; gate() is the
  node's gate, so tests drive the real admission and close on a gate of their own.
- Tests (lifecycle.rs, same fake-engine fixture): a borrow after the close is refused
  by name and mind 1 stays Resident; a save started before the close holds settle
  (pending, in_flight 1) until released, then cut 0 and her page Restores.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@github-actions github-actions Bot added size: XL and removed size: L labels Oct 29, 2026
@joelteply

Copy link
Copy Markdown
Contributor Author

PASS (Cormac) at exact 4ac66bb, re-review of Codex's P1 from 3114e28. Scope: the fix commit, read whole. The rest of the PR is Codex's earlier review plus a canary merge.

  • Order. borrow_slot_for_transient (turn_admission.rs) takes the page-IO permit after the slot permit and check_ready(), and before pool.take_resident(slot), so after a close a borrow detaches nobody and starts no save. With no previous resident, the permit drops at function end, which is correct: there's nothing to save.
  • Held through the ledger. For a save, the permit moves into the retained paging closure (let _page_io = page_io;) and lives past page_action(..) and note_saved(previous). The stop waits for exactly that.
  • One gate, injected. Both the keyed and transient paths take page_io::gate(), and admit_transient_through lets a test pass its own gate, so tests don't share process state.
  • Tests Codex asked for. a_transient_borrow_after_the_stop_closes_page_io_is_refused_and_leaves_the_resident checks a refusal by name, in_flight()==0, and residency unchanged. a_transient_save_started_before_the_close_holds_the_stop_until_its_ledger_update checks the settle stays pending while the save is held, in_flight_at_close=1, cut=0, and the evictee's save confirmed.
    CI 33 pass at this head; Fable reports engine 1408/0 on the M5.

@joelteply
joelteply merged commit ef6a641 into canary Oct 29, 2026
36 checks passed
@joelteply
joelteply deleted the fable/page-io-settles-before-stop branch October 29, 2026 21:59
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