Skip to content

A restart continues a mind's prompt-capture segment instead of rolling it away - #5428

Merged
joelteply merged 3 commits into
canaryfrom
fable/captures-survive-restart
Oct 25, 2026
Merged

joelteply merged 3 commits into
canaryfrom
fable/captures-survive-restart

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

How this serves the minds: every resident's real act history survives a restart. That history is the corpus the replay arena tests every context algorithm on, before any of them touches a live mind (Joel: "set up some kind of validation scenario to demonstrate our algorithm works").

Measured

`Store::open` rotated on every open, so each core restart moved the current segment to `.prev` and deleted the older one.

  • The M5's eight restarts on 2026-10-25 left 4-8 acts per resident, too few to replay.
  • Aiko's 43-act morning was gone by evening.

Change

`Store::open` resumes a whole current segment that still has room: same generation, positioned at the end, every row readable. A segment with any integrity issue, a full one or a missing one rotates exactly as before. Bounds are unchanged: two segments, at most 256 MiB.

Tests

  • New: `a_reopened_store_continues_its_whole_segment`.
  • Updated: `concurrent_capture_wrappers_share_one_owner_and_keep_distinct_sessions`. It asserted the old contract (a new owner after the last drop rotates, 4 files). Now it asserts the segment continues (2 files) with all 4 rows readable and no issues.
  • CI runs the suites; local windows on the M5 restart its residents.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

joelteply and others added 2 commits October 25, 2026 15:23
…g it away

Store::open rotated on every open, so each core restart moved the current segment to .prev
and deleted the older one: the M5's eight restarts on 2026-10-25 left 4-8 acts per resident,
too few for the replay validator (Aiko's 43-act morning was gone). Open now resumes a whole
current segment with room (same generation, every row readable); any integrity issue, a full
segment or none rotates exactly as before. Bounds unchanged (two segments).

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

Copy link
Copy Markdown
Contributor Author

Cormac on 9e800d8: no blocking findings; my exact-head PASS waits on CI.

Why it's safe to resume: Segment::open already refuses a torn segment. An incomplete index tail, or a payload length that doesn't equal the indexed end, is an issue, and then resume returns false and the store rotates exactly as before. So a crash between write and flush never gets appended after. Full segments (entries or bytes at the bound) also rotate, and keeping the generation keeps references taken before a restart readable. The two tests pin a continued segment, no .prev, and every row readable.

Nonblocking: cross-process exclusivity. resume assumes one core owns a home's capture directory. There's no file lock, so if an old and a new core ever overlap on one home (a restart that starts the new process before the old one exits), both now append to the same segment. Rotation used to split them into separate files. The next open would detect the interleaving and rotate, so it's a lost segment rather than silent corruption, but an advisory lock on open (flock, through continuum-host if it needs an OS seam) would make the assumption explicit.

@joelteply

Copy link
Copy Markdown
Contributor Author

Cormac: PASS at exactly 731f6f4.

  • I read the change since my 9e800d8 review with git diff 9e800d826 731f6f47d. It is one line in a test (prompt_capture.rs:905), where page(...) becomes store::page(...) so the call no longer resolves to the local page variable. Production code is unchanged from what I reviewed.
  • CI at 731f6f4: all 11 non-skipped checks pass, including the lib tests for continuum-cognition, continuum-core and continuum-mind, the source-hygiene ratchets, and the Windows check.
  • The only comment on this PR is my own, so nothing is left open.

@joelteply
joelteply merged commit 9feb1e4 into canary Oct 25, 2026
15 checks passed
@joelteply
joelteply deleted the fable/captures-survive-restart branch October 25, 2026 22:08
joelteply added a commit that referenced this pull request Oct 26, 2026
…refill priced, policies compared (#5432)

* The replay arena: real results restored, her re-reads counted, prefill priced, policies compared on one line each

The captures hold what was sent, so a result canary collapsed had no body and a policy that
would have kept it could not be judged. The arena (examples/replay/arena.rs) restores each
result's whole text from the request where it was the pinned newest result, gives it its
summary level (continuum_context::levels), counts her re-reads of a file read before and
whether the policy's previous prompt still held it (whole or outline), and prices fresh
prefill at a measured rate. `--arena <prefill tok/s>` runs the core's rule at growing shares
1/2, 1/3, 1/4, 1/6.

First run (the M5's captures, 12 residents, 86 acts, 150 tok/s, 2026-10-25): prefill 54.5 /
51.0 / 49.5 / 47.2 s per act, turnovers 20 / 19 / 18 / 16; re-reads 8, of which 5 had the
earlier read still in her prompt under every share. Thin: restarts had rotated the captures
(#5428 keeps them).

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

* Rename the replay arena to the context validator (--validate): an arena is a place residents go

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

* validate: the missing-argument message names --validate

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

* validate: --reply replays with another reply reserve

On the M5's captures (13 residents, 143 acts, 150 tok/s, 2026-10-25), with completions
measured at p50 16 / p95 447 / p99 1,078 / max 7,026 tokens against a 12,288 reserve:
reply 12,288 at share 1/2 (today) prefills 58.8 s/act and holds the earlier read for 9 of 15
re-reads; reply 4,096 at share 1/6 prefills 54.4 s/act and holds 13 of 15.

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

* validate: the act is the request's last assistant turn, its reads paired with their results by tool_use_id, read tools matched by exact name (Codex, Cormac on #5432)

Rerun on the M5's captures (362 acts, 89 re-reads, prefill at the engine's measured 450 tok/s
median since the right-sized launch, 2026-10-26): share 1/2 24.1 s/act, earlier read still held
for 44 of 89 re-reads; 1/4 21.7 s, 28; 1/6 20.8 s, 24. Shrinking restarts saves <=14% of
prefill and loses up to half of what she keeps: the half share stays.

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

* validate: restoration refuses ambiguity (exactly one new action owns a result; two, or a capture gap, are counted and not restored); ids must be non-empty to pair; 'held' is a retention proxy; the rate is validated; fixtures (Codex on #5432)

Rerun on the M5's captures (488 acts, 92 re-reads, 450 tok/s): 25 acts ambiguous and not
restored. Share 1/2: 21.5 s/act, earlier read retained for 49 of 92 re-reads; 1/3 19.9 s, 36;
1/4 19.0 s, 25; 1/6 18.0 s, 25. The half share stays.

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

* validate: restoration is chained by capture identity (same session, next act cycle); a single new key after a skipped capture is ambiguous, with Cormac's fixture

Captures carry only the latest act as a tool call (older turns are rendered text), so the chain is the
capture's (session_id, cycle_id): every act capture on the M5 steps by exactly 1 within a session.
Rerun (593 acts, 125 re-reads, 450 tok/s): 30 ambiguous; share 1/2 21.6 s/act retains 65/125,
1/3 19.9 s 49, 1/4 19.2 s 37, 1/6 18.4 s 35. The half share stays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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