Skip to content

fix(working-memory): restore saves pre-custody results through spill and collapses only against the real window - #4982

Merged
joelteply merged 6 commits into
canaryfrom
df0035bf/restore-retains-legacy-results
Oct 12, 2026
Merged

joelteply merged 6 commits into
canaryfrom
df0035bf/restore-retains-legacy-results

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

BigMama's live receipt of #4963 on the 5090 (ea94ab3, 14:08Z): Kimi resumed
clean (0 're-run if needed', 0 tails), but at restore the 'results whose save
failed are kept whole' probe fired, total 2,464 then 13,859 against cap 1,536.
Those entries came from her pre-#4963 snapshot: no handle because they predate
custody, not a failed save. So the probe named a failure that never happened,
and because unsaved entries never collapse they sat over the share for good.

  • persona_workspace saves each handle-less restored entry through
    spill::retain before restore, so it collapses like any saved result and
    the probe names only a real save failure.
  • WorkingMemory::restore collapses only once the served window is known.
    The 1,536 cap was the floor budget (restore runs before
    set_served_window), which folded results her real window holds; the next
    settlement collapses against the served window.

Test: restore_collapses_only_against_a_known_window. Card df0035bf.

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

…and collapses only against the real window

BigMama's live receipt of #4963 on the 5090 (ea94ab3, 14:08Z): Kimi resumed
clean (0 're-run if needed', 0 tails), but at restore the 'results whose save
failed are kept whole' probe fired, total 2,464 then 13,859 against cap 1,536.
Those entries came from her pre-#4963 snapshot: no handle because they predate
custody, not a failed save. So the probe named a failure that never happened,
and because unsaved entries never collapse they sat over the share for good.

- persona_workspace saves each handle-less restored entry through
  spill::retain before restore, so it collapses like any saved result and
  the probe names only a real save failure.
- WorkingMemory::restore collapses only once the served window is known.
  The 1,536 cap was the floor budget (restore runs before
  set_served_window), which folded results her real window holds; the next
  settlement collapses against the served window.

Test: restore_collapses_only_against_a_known_window. Card df0035bf.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply and others added 5 commits October 12, 2026 09:57
…ce held, which settles as it records

CI job 114851650768 at 65881f7: the source folds one of four third-of-share results at
record time, so its snapshot carries 3 whole entries; the test asserted 4.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…ation and pins each before the next save

Codex on #4982:
- The retain loop had no test that ran it.
- Several saves happen before the memory publishes its live set, and the persisted
  checkpoint (the old handle-less snapshot) names none of them, so a later save's
  pressure could evict an earlier file.

spill::retain_handleless now owns the loop. Each saved handle is published live under a
RestorePin (its own holder key space, so it can't replace a memory's set) before the next
save. persona_workspace holds the pin until WorkingMemory::restore has published. The test
runs the loop: each new handle resolves to the exact bytes, an existing handle is kept,
each is pinned as it is saved, the pin withdraws on drop, and a failed save keeps its text
whole with no handle.

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

Codex on #4982 at afae2e7: retain_in returned before the pin was inserted, so a
concurrent evictor could delete a new file in between. The handle is a content hash, known
before the write, so LivePin::retain enters it into the live set eviction reads (same lock,
is_live) and only then writes. On a failed write it removes the entry it added. The restore
path uses it now. The live path (command executor, act/observe) adopting the same primitive
is card 12b080c3, owner Cormac. Not claimed here.

The test now pins the order: the handle is live while its file does not yet exist.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
… unused LivePin::retain waits for 12b080c3

78e1859 raised the unwired-public-machinery ratchet from 61 to 62. LivePin is constructed
only in spill.rs, so its visibility is pub(crate). LivePin::retain had no caller yet; the
live path's adoption (12b080c3) adds it back with its first caller.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…he live-set lock, so an existing file is never deleted while pinned

Codex on #4982 at 8b93e75: FilesystemTierPool checked protect(path), released the lock,
then removed the file. A LivePin taken in that gap on an EXISTING content-addressed file
(same name) had its file deleted while pinned.

The pool now removes through a guarded remover (removing_with -> Removal), replacing the
separate predicate. spill::evict_unless_live reads the checkpoint, then checks the live set
and deletes under the lock LivePin enters with. So a pin lands either before the check
(the file is protected) or after the delete (its write recreates the file).

The test proves the interleaving deterministically: inside the section, the lock a pin
needs is held (try_lock is None). It also checks that a pinned existing file is protected,
and that a pin after the delete rewrites the file.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@github-actions github-actions Bot added size: L and removed size: M labels Oct 12, 2026
@joelteply
joelteply merged commit 6ce4b32 into canary Oct 12, 2026
7 checks passed
@joelteply
joelteply deleted the df0035bf/restore-retains-legacy-results branch October 12, 2026 16:29
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