Repository navigation
Capture a deeper matching prefix after a short rewind - #6174
Merged
joelteply merged 59 commits intoNov 21, 2026
Merged
Conversation
…ison Compare token history once when binding a resident
Keep native checkpoint custody in resident history
…oint Retain earlier learned checkpoints across deeper captures
…ceipt Identify offered functions in native empty-turn receipts
Pin Qwen tool argument ordering verified on the M5
Keep paused one-off state only while its request owns it
Serve overdue resident turns at frame boundaries
Release blocking inference workers after turn submission
joelteply
commented
Nov 20, 2026
joelteply
left a comment
Contributor
Author
There was a problem hiding this comment.
Fable review at exact head e084e38: changes requested (two points), both from your own trace.
Read: driver.rs::resume at this head. A rewind to from that must prefill across a deeper matching prefix (shared > from, shared < view) now learns boundaries[1] = shared. prefill_chunk stops there, and keep_checkpoint(index 1) takes it.
- The capture has no minimum gain. Your 22:21Z trace shows several deep rewinds that captured one token later than they started (
shared = from + 1). A capture costscheckpoint_ms, which was 2-17 ms per take in the 48a1 window. At the measured ~704 tok/s fresh prefill, it only pays for itself whenshared - fromexceeds roughly 2-12 tokens. Proposal: learn only whenshared - fromexceeds the tokens the measured checkpoint time would prefill, using this mind's lastcheckpoint_msand the frame's prefill rate rather than a constant. Otherwise a one-token step costs a native take and gains nothing. - The capture displaces the checkpoint the rewind just used. When
fromis the learned slot's own end,keep_checkpoint(1, shared)reuses that slot's buffer, so the shallower checkpoint is gone. The next turnover that diverges beforesharedbut after the oldfrommisses again and restarts. This is the head-level case #6171 was built for. With two slots and two kinds of divergence (a view turnover near the head, a mid-view change), each capture evicts the checkpoint the other kind needs. Options, in order of preference:- (a) a small set of learned checkpoints, evicted by measured value (re-prefill tokens saved × uses) under the footprint the registry already counts per checkpoint;
- (b) never replace the slot the current rewind used, and learn deeper only into a free slot.
Either way, add a probe counting learned captures and their later use, so the value is a receipt, not an assumption.
The selection rule itself (choose picks the furthest valid checkpoint) is unchanged and correct. Only the capture policy needs these two fixes.
Remove a token buffer copy from each native prefill chunk
…aches, keyed by its request id The M5, 2026-11-21: Aris entered generate_text at 00:48:32 and was dropped 1,499 s later with no record of whether the engine ever held her turn; the driver logged nothing at admission, so the stall could not be placed (and was first misattributed to the grants). Now each transition is recorded once, keyed by the submitted request's id (`RequestId`, the adapter request_id, the one id crossing from her deliberation into the engine): - inference.generate.enter: gains `request`. - inference.generate.worker_started: the blocking worker began (a full pool delays this). - inference.generate.genes_ready: her genes are loaded (a gene load delays this). - persona.engine.enqueued: handed to the scheduler (prompt tokens, time since submit began). - persona.engine.admitted: the driver took it into its queue (queue depth, prompt tokens, ms since it was handed over: the driver's own latency to take requests). - persona.engine.first_frame: its first frame (ms since admission, reused tokens now known, prompt tokens, whether reaching her took a switch). - persona.generation.dropped: gains `request`, so a drop names the last transition it reached. The driver's two facts go through its record stage (one flow event each), not inline on the driver thread. Unknown stays unknown: a request sent with no id logs None. Checks (exit statuses captured from cargo, not a pipeline): cargo check -p continuum-engine -p continuum-cognition --tests: 0, no warnings in touched files; persona_scheduler tests 11 pass; cognition settle + generation_drop tests 23 pass; ratchets vs origin/codex/frame-prefill-estimate: 0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…art apart from first progress, one key shape, the engine incarnation
- since_enter is measured from an instant taken at the top of generate_text (it was gen_start,
started later, so it hid every step between entry and generation).
- first_frame was emitted before the first chunk ran, so a blocked or failed chunk still read as
advancement. Now frame_started (bound, prefill start known) and first_progress (the first step
that succeeded natively, once, with its duration and whether it was prefill) are separate;
Milestones (Admitted -> Started -> Progressed, an enum, not flags) decides each once, with a
validator: a failed first step starts without progress; a multi-chunk turn reports progress once.
- The request key logs as Some("…") at every site (the driver read Some(RequestId("…"))), so the
adapter and driver ends join exactly; RequestId::as_str, and its unused Display deleted.
- Every engine transition carries the incarnation of the engine that served it (the record stage
already owns it), so a stale binding shows.
- One Driver::transition replaces the hand-built transition at each site.
check 0; persona_scheduler tests 12 pass (the milestone validator added); ratchets vs
origin/codex/frame-prefill-estimate 0 (state_as_flags caught Milestones as two bools: now an enum).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
A turn reports every transition from generate_text to its first engine frame, keyed by its request id
…on't cut it up, run single lane; context switching is faster") The frame policy gave every ready turn a slice of a one-second service budget, so a turn in progress was cut into frames shared with every other ready mind. Measured on the M5 (56913f6, 2026-11-21 04:14-04:29 UTC): 20 to 520 switches per turn at 12 to 25 ms each, up to 8.5 s of switch_ms inside one turn, and warm turns waiting ~600 ms for a slice before their first frame. Now the bound mind's started turn (prefilling or decoding) keeps the Core until it ends. When none is in progress, the next is the least remaining work discounted by wait (a long wait still comes forward; no mind starves), a tie keeping the bound mind. Each prefill chunk is the engine's full batch, bounded only by her checkpoint boundary. Deleted: SERVICE_BUDGET_MS and share_ms; the bound-time input to pick; Driver::bound_since; Driver::prefill_sample and its two updates; the `ready` count threaded through pick, step and prefill_chunk; Candidate::decoding (now `started`). driver.rs 941 -> 928 lines. The 2026-11-18 reason for slicing (short tails waiting 300-360 s behind cold prefills) is named in frame.rs; the 11-21 read shows 71-98% reuse on most turns. Whether a cold prompt still needs its own handling is measured on deploy, not assumed. check 0; persona_scheduler tests 12 pass (pick test rewritten for the new rule); ratchets vs origin/codex/frame-prefill-estimate 0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ir transitions by identity (Codex on #6207: terminal rows lacked it) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…literals #6207 missed compile - persona.engine.refused: a turn that ends without an answer (refused, failed, or a caller that hung up) now writes a terminal transition with its typed reason and time since admission; it wrote only a warning before, so it vanished from the receipts (independent review of #6179, finding 6). Every admitted turn ends in exactly one of this or persona.engine.turn. - core/continuum-core/tests/{qwen35_chat_pipeline_full,llamacpp_metal_throughput}.rs: four TurnPrompt literals lacked #6207's `request` field, so those (ignored) test targets did not compile; CI's lib-test jobs never built them, and I had checked only the engine and cognition crates (finding 1, my miss). cargo check -p continuum-engine -p continuum-core --tests: 0; persona_scheduler tests 12 pass; ratchets vs origin/codex/frame-prefill-estimate: 0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…osed, each with exactly one terminal record; a stop is acknowledged after its records are written Codex on ce8a894: a graceful stop drained admitted turns with only an Emit error, and the closed-submission path returned with turns still admitted: both left no terminal record. - driver/ending.rs (new): `Ending` (Answered, Refused(TurnError), Stopping, Closed) and `Driver::end`, the one place an admitted turn leaves the engine: it writes the turn row (answered) or persona.engine.refused with the reason, releases a one-off, and tells the caller. The loop's answer and error arms, the stop's drain and the closed channel all go through it. - A stop is handed back from `take` (`Stop`) and acknowledged by the loop only after `settle_records`: both outboxes drained, then a record-stage `Barrier` answered (FIFO), so its last records are written before the acknowledgement. The closed path settles them too. - `Advanced::Done` carries exactly an answer (`tokens_generated`, `elapsed_ms`) instead of any TokenEvent; the turn row moved from `step` into `end`. - driver.rs: 1008 -> 942 lines after the split (the 1,000-line gate). check -p continuum-engine --tests 0; check -p continuum-core --tests 0; persona_scheduler tests 12 pass; ratchets vs origin/codex/frame-prefill-estimate 0. Live stop replay follows on the PR. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…en; a stalled caller never holds it Codex on 8e597e1: (1) a record stage that ended before answering the barrier still yielded a fully settled acknowledgement; (2) settle_records joined Emit's drain, so a caller that stopped reading her answer held the whole stop. - `settle` (driver/ending.rs), a function of the two outboxes: Emit is flushed but never awaited; the record outbox is drained, then the barrier awaited; a record stage that ended reads `Records::Unconfirmed` (probe persona.engine.records_unconfirmed). - `Suspended` carries `records: Records`. The suspend now returns `Suspension` (what it did natively); the acknowledgement assembles `Suspended` with the records outcome, so no placeholder is written and overwritten. The stop's custody report keeps its state (records are telemetry, never custody) and appends "the records of the turns it ended were not confirmed written" when so. - Tests (driver/ending_tests.rs, real flow stages): records read Written only when the record stage confirms them, Unconfirmed when it ended first; a stalled Emit sink with queued output never holds the settle, and its output is left for its caller. Mutation-checked: forcing Written fails the first. check -p continuum-engine -p continuum-core --tests 0; persona_scheduler tests 14 pass; ratchets 0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ically as her live turn (Joel, 2026-11-21: "Replay should be as realistic as regular mode") cognition/replay-request gave every replay a fresh persona id, so the engine served it as a stranger with nothing cached: every replayed turn was a cold prefill, unlike live turns that reuse 71-98% of their prompt (the M5 windows of 2026-11-21). - `identity`: `isolated` (the default, unchanged: a fresh mind, cold) or `resident` (the source persona's own mind, so her parked blocks are reused exactly as her next live turn would reuse them). - The engine's identity and the capture's owner are now separate: the capture is always owned by a fresh replay identity, so a replay never enters her prompt history or her learning, whichever mind served it. - The result names the identity it was served as. - A resident replay interleaving with her live loop is safe (one serial queue per mind; reuse is checked against the actual prompt) but spoils a measurement, so a measuring run holds and despawns her first. No cross-layer hosting check (cognition must not import mind). The validator (request_replay tests) extends the isolation test: a resident replay is served as her own mind and its capture is still owned by a separate replay identity. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ckpoint a stop saves from it), never her memory, history or learning (Codex on 6505cb4) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…efaulted field, not an Option - persona.engine.decode_refused (continuum-persona-llama unified_tier): when llama_decode refuses a step, the probe records the step (from, tokens), the context geometry (n_ctx, n_ctx_seq, n_seq_max, n_batch, n_ubatch) and every execution stream's occupant and highest position. The M5, 2026-11-21: cold 26-36k resident replays were refused "no KV slot" (llama_decode returned 1) about 31 s into prefill, and the source alone cannot tell other streams' cells, full-batch chunks or fragmentation apart (Codex's request: measure before inferring a cause). Its first dependency on continuum-base (the floor) and tracing. - ReplayRequestParams::identity is `ReplayIdentity` with a serde default (absent = isolated) instead of `Option` + unwrap_or_default at two sites (the unwrap ratchet). check -p continuum-persona-llama -p continuum-engine -p continuum-cognition --tests 0; request_replay tests pass; persona-llama builds with metal; ratchets vs origin/fable/run-to-end 0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…e numbers The M5, 2026-11-21 (persona.engine.decode_refused, e61b5cf): a 26,633-token resident replay was admitted to a 24,576-token stream (n_ctx 49,152 / n_seq_max 2), prefilled for ~31 s, and refused by the engine at the chunk that crossed the end (from 22,623 + 2,048 tokens). The engine spent the work and then failed; the object model's Core answers Infeasible when a need exceeds its cap. - admission.rs (new): `StreamCapacity` (the applied geometry's n_ctx_seq) admits a prompt only with room for one generated token, else `Infeasible { prompt_tokens, capacity }` (typed, with Display). - The driver holds its `StreamCapacity` from the geometry it applied, checks every turn at `admit`, tells the caller with the numbers, and records persona.engine.infeasible keyed by the request id. A refused turn was never admitted, so it has no other transition. - Live deliberation already fits prompts to the published n_ctx_seq (delib.turn.demand context_window=24576 tonight); this guards every caller that does not fit its own: replays, and external drivers. persona_scheduler tests 15 pass (the admission validator added); check engine + core tests 0; ratchets vs origin/fable/run-to-end 0; driver.rs 953 lines. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
Replay as realistic as live (identity=resident); refused decodes say what the engine held; the Core refuses an oversized prompt at the door
…, no "written" the log never confirmed Codex's full review at 162fbe5, each finding with a validator that fails on the old code: - P1 frame.rs: the cost was integer division, so an aged and a fresh one-token tail both cost zero and affinity won every tie; a bound mind that kept arriving starved an older one. Costs now compare exactly (cross-multiplied); an equal cost goes to the longer wait; only a full tie keeps the bound mind. Validator: repeated arrivals of the bound mind, the older mind served on its first round. - P2 driver.rs + ending.rs: when every submission handle dropped, the loop flushed Emit once and dropped what a full Emit still held with the driver, answer ends included. `Driver::close` ends every turn, settles records, and hands Emit to a drain owner on the stage runtime (`hand_off`), in order; the engine thread never waits on Emit and the stop acknowledgement stays independent. Validator: a saturated Emit stage, its outbox handed off, all eight outputs in order. - P2 record.rs / probe_file_sink.rs: `Records::Written` confirmed only that the tracing callbacks returned, and the sink dropped write/flush errors. The probe floor now owns one count of failed probe-log writes (continuum-base `probe_writes`), the sink counts each line it cannot write, and a settle reads `Records::Processed { write_failures }` since the previous settle; durability is never claimed. Validator: a sink on a disk that refuses writes counts the failure; a settle reports a failure counted in its window, once. Touched files leave clean: the probe sink's unbounded single-file `new` had no production caller (boot rolls) and is deleted, its 12 tests move to the rolling constructor; its serialization names its disk boundary; `DEFAULT_MAX_LOG_FILES` is now the appender's `KEEP` (8, what the broker's rotation pool budgets), not a second count of 7. engine persona_scheduler 18 pass, kernel probe_file_sink 16, base probe_writes 1; mutation of the tie order and of the hand-off each fails its validator; check engine/kernel/core tests 0; ratchets vs origin/codex/frame-prefill-estimate 0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ded off reach their callers Codex on 8f386fb: `Driver::close` hands a full Emit outbox to its drain owner, then the driver thread called `StageWorker::stop()` on both stages before that task necessarily ran, so the ends it had not yet pushed came back `Stopped` and were dropped. A stage already ends by itself once its last producer is gone and it has handled what it took, and after `run` returns the only producers left are the driver's (dropped) and the drain owner's (dropped when drained), so the thread now waits on `driver::finish`, which joins both stages and never stops them. Startup failures and early returns drop their inputs too, so the join always returns. Validator: a full Emit handed off, then `finish` exactly as the thread runs it: all eight ends reach the caller in order. Mutating `finish` to stop before joining fails it. persona_scheduler 19 pass; check engine + core tests 0; ratchets vs origin/codex/frame-prefill-estimate 0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
The Core runs a turn to its end: no slicing; prefill at full batch; the slicing machinery deleted
Fit native context memory to the physical stream layout
Give overdue turns priority at the next scheduling boundary
Compute the prefill estimate once per waiting turn
joelteply
merged commit Nov 21, 2026
68af909
into
codex/provider-query-snapshot
88 of 91 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ten M5 turns reused 95 tokens despite 88,711 matching prefix tokens in aggregate. Each had a later view boundary and no learned boundary. A successful rewind previously skipped adaptive checkpoint capture. The driver now requests capture when prefill from a valid shallower rewind will cross a deeper same-basis match before the view boundary. Actual reuse still goes through native lineage validation. Existing checkpoint storage and memory bounds are unchanged.
Local deployment before check-in: M5 executable SHA256 ae219c938d11f7a3c96a07ec8e55bc4d3352fe65ef9125cf34e114061b62a380, four residents restored, one decode lane at 24576. Five-minute guard: 17 generate entries, six acts, zero inference failures. The 900 s comparison and native fault replay are pending. Stacked on #6173.