Skip to content

fix(spill): eviction never deletes a saved result a mind points at, live or persisted across a restart (stacked on #4963) - #4975

Merged
joelteply merged 3 commits into
canaryfrom
9197cd01/spill-eviction-respects-live-references
Oct 12, 2026
Merged

joelteply merged 3 commits into
canaryfrom
9197cd01/spill-eviction-respects-live-references

Conversation

@joelteply

@joelteply joelteply commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Why

This is card 9197cd01, the deployment acceptance Codex linked to #4963. That PR saves every tool result so a pointer can reopen it later. But under disk pressure, the tool-output-spill pool deleted spill files oldest-mtime-first, with no idea which handles a mind still pointed at. That held across the restart a deploy performs, too, because then the references exist only on disk.

Stacked on #4963: this branch is current canary + #4963 + the commits below. It doubles as the exact commit the 5090 deploys (4d99b41ee), so its CI is that commit's compile and test check. Merge after #4963; the diff then shrinks to the commits below.

Scope: PARTIAL protection (Codex's review at 4d99b41)

This protects every live and persisted reference that has been PUBLISHED. It does not yet make custody atomic. Three gaps are owned by card 12b080c3 (owner Cormac), and full retention is not claimed until it lands:

  1. The pool checks the guard, then deletes, with a window in between.
  2. A fresh save exists before working memory publishes its reference.
  3. A batch's saved text names each call's handle, but only the batch handle is tracked.

All three bite only under disk pressure (1 GB soft cap).

Change

  • One live-handle set, owned by spill: publish_live_handles(holder, set) / withdraw_live_handles(holder) / is_live(path).
    • Keyed by working-memory instance. Working memory republishes its WHOLE set (ring entries plus collapsed pointers' handles) after every record, collapse and restore, and withdraws it in Drop, so no reference counts can drift.
  • The restart gap (Codex on acdfb01): is_live also protects any handle listed in the file's persona checkpoint, from both the results ring and the collapsed pointers. persona_workspace::persisted_result_handles is cached by the checkpoint's mtime and bounded by her ring.
    • An unreadable checkpoint fails closed: nothing of that persona's is evicted.
    • The loader gains a path-injected core so tests run in a tempdir.
  • FilesystemTierPool::protecting(guard), generic: a protected file is never evicted, however old, and eviction moves on to the next-oldest. The spill pool is built with spill::is_live.
  • tool/output's not-found message now says what a missing handle can mean: a mistyped id, or a file deleted after nothing referenced it any more.

Tests

  • pool: a_protected_file_is_never_evicted_however_old
  • spill: a_referenced_handle_is_live_until_its_holder_withdraws
  • working memory: a_mind_s_saved_handles_are_live_until_it_drops
  • persona_workspace: a_persisted_checkpoint_s_result_handles_are_readable_before_restore (a result collapses into a pointer, the mind is checkpointed and dropped, and its handle is still protected; a newer checkpoint is seen; an unreadable one is an error the guard fails closed on)

Locally: cargo test -p source-hygiene, 28 passed. The core was not compiled locally; CI pending.

Measured

After deploy on the 5090. Check: BigMama posts the running SHA. Then, after the deploy's restart, a result Kimi read before the restart still opens byte-identical through tool/output. Owner: Cormac, with BigMama's capture. Deadline: the first deploy that carries this. Still open: the spill write rate per persona, needed to size the 1 GB cap, measured after deploy with a receipt.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

@joelteply joelteply changed the title fix(spill): a persisted checkpoint's collapsed pointers protect their results too fix(spill): eviction never deletes a saved result a mind points at, live or persisted across a restart (stacked on #4963) Oct 12, 2026
joelteply and others added 3 commits October 12, 2026 04:11
…e mind still points at

Card 9197cd01, the deployment acceptance Astra linked to #4963: the
tool-output spill pool evicted oldest-mtime-first with no knowledge of which
handles a working memory still referenced, so a pointer could name a file that
was gone. #4963 saves every result, which raises the rate.

- spill owns one live-handle set, keyed by working-memory instance:
  publish_live_handles replaces a holder's whole set, withdraw on drop, and
  is_live(path) is the guard. No reference counts to drift.
- WorkingMemory publishes its ring entries' and collapsed pointers' handles
  after every record, collapse and restore, and withdraws them in Drop. The
  collapsed pointer keeps its handle as data, not only rendered text.
- FilesystemTierPool gains a generic `protecting` guard: a protected file is
  never evicted, however old; eviction moves to the next-oldest. The spill
  pool is built with spill::is_live.
- tool/output's not-found message says what a missing handle can now mean: a
  mistyped id, or one deleted after no working memory pointed at it.

Tests: pool a_protected_file_is_never_evicted_however_old; spill
a_referenced_handle_is_live_until_its_holder_withdraws; working memory
a_mind_s_saved_handles_are_live_until_it_drops (live in the ring, live as a
pointer, released on drop).

Stacked on #4963 (735a3183); rebased onto canary once it merges.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…ts across the restart a deploy performs

Astra on card 9197cd01: before a mind restores (the restart a deploy itself
performs), its references exist only in its persisted checkpoint, so eviction
in that window could delete them. spill::is_live also protects any handle the
file's persona checkpoint lists (persona_workspace::persisted_result_handles,
cached by the checkpoint's mtime; bounded by her ring). An unreadable checkpoint
fails closed: nothing of that persona's is evicted. load_volatile gains a
path-injected core so the test runs in a tempdir.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
… results too

Astra on acdfb01: persisted_result_handles read only the results ring, but a
result that collapsed out of it is reopened through its pointer. The persisted
reference set now includes every collapsed pointer's handle (persisted since
#4963 9c69968). Regression: a result collapses into a pointer, the mind is
checkpointed and dropped, and its handle is still protected.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply
joelteply force-pushed the 9197cd01/spill-eviction-respects-live-references branch from 4d99b41 to 4e77aed Compare October 12, 2026 09:12
@github-actions github-actions Bot added size: L and removed size: XL labels Oct 12, 2026
@joelteply
joelteply merged commit c7cbe1b into canary Oct 12, 2026
7 checks passed
@joelteply
joelteply deleted the 9197cd01/spill-eviction-respects-live-references branch October 12, 2026 10:30
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