Skip to content

fix(cognition): a tool result reaches a mind whole or as its handle, never a fragment; one owner, one share - #4963

Merged
joelteply merged 9 commits into
canaryfrom
735a3183/no-fixed-clips-in-a-citizen-s-own-mind-w
Oct 12, 2026
Merged

joelteply merged 9 commits into
canaryfrom
735a3183/no-fixed-clips-in-a-citizen-s-own-mind-w

Conversation

@joelteply

@joelteply joelteply commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Why

Joel, 2026-10-12: "The clipping I've yelled about for months. Stop doing it. You guys just said you were getting rid of this bs and using the budget like the design said."

Kimi read wall_source.rs 387-660 whole in one request and had 0 of its 274 lines in the next. BigMama joined her 5090 prompt captures: req#3 at 01:48:37Z holds the read whole (274/274 lines, 28,370 chars); req#4 at 01:51:39Z holds 0/274. The next act overwrote last_action, and recent_results kept only the last cap/3 chars of it. A tail of a code read is broken code. She read that file 25+ times in four hours and landed no edit.

Card 735a3183. This PR replaces the rule PR that had this number, which was closed because a rule is not compression.

What changes

One owner decides how a tool result reaches a mind: spill::whole_or_handle. It returns a typed Fitted:

  • Complete{handle}: the result fits its share and is shown whole. It is also saved (content-addressed), so when it later collapses at settlement or restore, the pointer it leaves resolves (Codex's finding at b41a051).
  • Stored{handle}: over the share, saved whole, and the mind is shown a pointer naming the handle and the tool/output filters (errors/warnings/failures/summary, regex, line range). No head, no tail.
  • RetentionFailed: the save failed; the failure is stated, then the whole result follows. A re-run is not a recovery, and a mutating tool must not repeat (Astra).

Deleted (every site that cut a result, each at its own share):

  • the executor's head+tail fold truncate_tool_output / fold_with_recovery;
  • truncate_on_boundary (error text);
  • the recency head cut bound_recency_result;
  • working memory's re-cut clip_action_full;
  • the recent_results tail-keep;
  • ContextBudget::result_fold_chars (two shares for one result become one);
  • recent_results_block (a test-only duplicate of recent_results_messages).

Custody is typed. ToolResult.spill_handle meant both "saved" and "content is only a pointer". It is now ResultCustody {Unsaved, Whole{handle}, Pointer{handle}}, and perception's unchanged-observation streak asks is_pointer(). The results ring saves each batch's EXACT rendered text (spill::retain, called by act_observe/apply.rs, the one production writer), so a collapsed pointer resolves byte-identical to what the mind saw, every call of a multi-call batch included. A result whose save failed never collapses: nothing else holds its bytes, so custody outranks the share through settlement and restore (Codex's findings at 4840af8). The string "re-run if needed" no longer exists.

Deployment acceptance, linked (Codex at 9767a0f): this PR does not claim DURABLE retention on its own. Until card 9197cd01 lands, a pointer resolves only while the spill pool has not evicted its file. 9197cd01 ships as its own focused PR and is part of this rollout's acceptance.

Not in this PR, carded: the spill pool evicts oldest-first under disk pressure and does not know which handles a live mind still points at. That predates this PR for oversized results; saving every result raises the rate. Card 9197cd01, owner Cormac: one reference set the pool respects, a typed "evicted under pressure" answer from tool/output, and a measured write rate to size the cap.

Budget, not clipping.

  • The executor fits at latest_action_chars, the same share working memory shows a result at.
  • recent_results_chars goes from 1/32 to 1/4 of the window. The budget picks how many WHOLE results fit, and the rest collapse to pointers at settlement through the existing collapse_results_over_cap.
  • Restore now goes through that same collapse instead of deleting.
  • The ring skips the result currently shown as the full latest result, so a whole result is not paid for twice.

This completes build-order steps 3-4 of docs/architecture/CONTENT-TRAVELS-BY-HANDLE.md. That doc now names the remaining cut sites: the tool/output grep window, the dispatch-result cut, and the act/wall fact cuts.

Tests

  • spill::a_batch_is_retained_whole_both_results_byte_identical and working_memory::an_unsaved_result_keeps_its_bytes_through_settlement_and_restore (Codex's requested regressions).
  • spill::a_result_is_whole_or_a_handle_never_a_fragment:
    • a fitting result comes back byte-identical;
    • an over-share result shows neither its head nor its tail, and its handle resolves byte-identical;
    • an injected persistence failure keeps the original bytes;
    • multibyte input never splits.
  • Astra's regression (cherry-picked as 781e635): a 274-line read, then a poll, a settle and a snapshot restore. The result must be whole or a resolvable handle, never a suffix.
  • the_pinned_result_is_what_the_producer_handed_over_never_re_cut, and the ring test now asserts that every kept result is whole.
  • Local: cargo test -p source-hygiene, 28 passed. The core was not compiled locally (IntelMac does not build the core). CI pending.

Measured

Only measurable after deploy. Check: on the 5090, after this merges and deploys, join Kimi's consecutive prompt captures. A code/read must be whole in request N and, after a further act, either still whole in the recent-results block in N+1 or a pointer naming a handle that tool/output resolves. Owner: Cormac, with BigMama's capture join. Deadline: first Kimi read after deploy, by 2026-10-13. The card stays open until that receipt is posted with the build SHA.

Review

Kimi reviews this before merge: it changes what her act loop sees of her own results.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

@joelteply

Copy link
Copy Markdown
Contributor Author

Closing per Codex's review (28347f40), which I accept. #4963 counts literal cuts, so a budget-sized cut passes it; it cannot enforce whole-or-handle, and lowering its baseline by swapping 1,500 for a budget would not be a fix. #4964 orders today's directory names, which writes the tangle into a rule: same-layer cycles pass, grouped and aliased imports are missed, and zero up-references does not prove a crate can be extracted. Joel asked for architectural compression, not more rules around unchanged code. The work moves to real boundaries: card 49318958 (the CLI compiles core) and, for 735a3183, a domain source that owns complete units with one budgeted projection that adapters consume.

joelteply and others added 5 commits October 12, 2026 00:57
…nter, never as a tail

Kimi read wall_source.rs 387-660 whole in one request (BigMama's join of her
5090 captures, req#3 01:48:37Z, 274/274 lines) and 0/274 in the next. The next
act overwrote last_action, and recent_results held only the last cap/3 chars
of it. A tail of a code read is broken code; she re-read the file 25+ times in
four hours and landed no edit.

- record_receipt_inner keeps each result WHOLE in recent_results.
- clip_action_full: an oversized latest result is a pointer (its size, the
  tool/output handle, or a narrower re-run), never a head.
- recent_results_chars: 1/32 to 1/4 of the window. The budget selects how many
  whole results fit; settlement collapses the rest to pointers (unchanged
  collapse_results_over_cap).
- restore goes through the same collapse instead of deleting silently.
- The ring skips the result that is currently the full latest result, so a
  whole result is not paid for twice.
- recent_results_block, a test-only duplicate of recent_results_messages, is
  deleted.

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

Three sites cut a tool result, each at its own share: the executor's head+tail
fold at 1/3 of the window, the recency renderer's head cut at 1/3, and working
memory at 1/4. A result between 1/4 and 1/3 reached working memory with no
handle, and the executor head-cut silently when the spill failed (Astra).

- spill::whole_or_handle: whole within the share; over it, saved whole and
  shown as a pointer naming the handle and the tool/output filters, never a
  fragment. A failed spill says so, still without a fragment.
- Deleted: truncate_tool_output, fold_with_recovery, truncate_on_boundary,
  their 4 head/tail tests, and ContextBudget::result_fold_chars (one share for
  one result, not two). Error text goes through the same owner.
- act_observe/apply spills at latest_action_chars, the share working memory
  shows a result at. bound_recency_result gives the same pointer.
- CONTENT-TRAVELS-BY-HANDLE.md build order: steps 3-4 done; the remaining
  cut sites are named.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…ole result, and no consumer re-cuts

Astra's block on b076316:
- A failed save discarded the body. spill::Fitted names the three states
  (Complete, Stored{handle}, RetentionFailed): a failed save says so and then
  carries the WHOLE result, because nothing else holds those bytes and a re-run
  is not a recovery. The action's verdict is untouched.
- whole_or_handle resolved the spill root even for a result that fits, so no
  home directory would have failed a fitting result. Size is checked first;
  a fitting result never touches the disk.
- working_memory::clip_action_full re-cut what the producer had fitted and
  invented a pointer with no handle. Deleted, along with
  bound_recency_result: a consumer shows what the producer handed over
  (CONTENT-TRAVELS-BY-HANDLE.md, forbidden moves).

Tests: spill's test injects a persistence failure (a file where the persona
directory must go) and proves the original bytes remain; the pinned-block test
proves an over-share result is shown as handed over, never re-cut.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply joelteply reopened this Oct 12, 2026
@joelteply
joelteply force-pushed the 735a3183/no-fixed-clips-in-a-citizen-s-own-mind-w branch from 2dd9f3a to b41a051 Compare October 12, 2026 06:06
@joelteply joelteply changed the title feat(hygiene): what a mind reads enters whole or as a handle; literal cuts in cognition/ and persona/ can only fall fix(cognition): a tool result reaches a mind whole or as its handle, never a fragment; one owner, one share Oct 12, 2026
@github-actions github-actions Bot added size: XL and removed size: L labels Oct 12, 2026
@joelteply

Copy link
Copy Markdown
Contributor Author

Review (BigMama) at b41a051: changes requested, one blocking finding. It's the exact case in the capture join this card cites.

A result that fits its share is never saved, so its later collapse has nothing to point at. whole_or_handle stores only what's OVER the share; a result within it is Fitted::Complete and never touches the disk (handle None). That result then enters recent_results WHOLE, and at settlement collapse_results_over_cap evicts it with the None arm:

[result #N …, {n} chars — collapsed from view; re-run if needed]

That's a re-run pointer: the thing this PR's own spill.rs doc rules out ("Re-running a tool to recover what it already returned is not a recovery: the world may have moved and a mutating tool must not repeat"), Codex's acceptance criterion on 735a3183, and what Kimi reported from inside at 06:0xZ ("everything older collapsed to 're-run if needed' pointers with no content").

It's also the measured case: wall_source.rs 387-660 was 28,370 chars, shown WHOLE as the active result (req#3, 01:48:37Z), then gone in the next request. A read like that fits latest_action_chars (so it isn't spilled) but is far over recent_results_chars / 2, so with this PR it's whole once, then a re-run pointer: the same loss, a different label. The 25 re-reads would continue.

Fix, in the same owner: a result leaves view only by handle. At collapse (and on the snapshot-restore path, which calls the same function), when ehandle is None, save the bytes through spill's store first, then emit the handled pointer. Then there is no None arm and no "re-run if needed" string anywhere. If the save fails, keep the result in the ring (RetentionFailed's rule: nothing else holds those bytes) and probe it, instead of dropping it.

Test: extend a_result_is_whole_or_a_handle_never_a_fragment, or Astra's 71ab454 fixture, with: a result within latest_action_chars but over recent_results_chars / 2 → record → next act → settle → the pointer names a handle, and tool/output on that handle returns the original bytes, byte-identical. Also assert no rendered message contains "re-run if needed".

The rest reads right: one decision (whole_or_handle), consumers never re-cut, clip_action_full, the head+tail fold and recent_results_block deleted, the active result not paid for twice, and RetentionFailed keeping the whole result.

joelteply and others added 2 commits October 12, 2026 01:11
…a pointer left later always resolves

Astra on #4963 at b41a051: a fitting result was Complete with no handle, so
the unchanged settlement/restore collapse popped it and left "re-run if needed",
the same loss one step later. RetentionFailed flattened to the same None.

- whole_or_handle saves EVERY result (content-addressed, so a repeated read
  reuses its file; the spill dir is evicted under disk pressure like every
  spill). Fitted::Complete carries its handle, so a collapse leaves a pointer
  that resolves through tool/output.
- ToolResult.spill_handle: Option<String> carried two meanings, "saved" and
  "content is only a pointer"; perception read it as the second. It becomes
  ResultCustody {Unsaved, Whole{handle}, Pointer{handle}}, and perception asks
  is_pointer(). With every result saved, the old reading would have reset
  every unchanged-observation streak.
- A collapse with no handle (the save failed, or a pre-saving snapshot) says
  it was never saved and cannot be reopened, not "re-run if needed": a re-run
  is a new result.

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

Astra on #4963 at 4840af8:
- record_receipt_inner took ONE call's handle (find_map) for a multi-call
  batch, so the collapsed pointer implied the whole batch was recoverable when
  only the first call was. apply.rs, the one production writer, now saves the
  exact rendered batch the ring keeps (spill::retain) and passes that custody
  in; the pointer resolves byte-identical to what the mind saw, every call
  included. The find_map is deleted.
- An unsaved result (its save failed) never collapses: nothing else holds its
  bytes, so custody outranks the share, through settlement and restore. A
  probe says when the ring is over its share for that reason. The "never
  saved, cannot be reopened" pointer is deleted; it documented a loss.

Tests: spill a_batch_is_retained_whole_both_results_byte_identical (two
distinct results in one batch, saved and resolved byte-identical; a failed
save is Unsaved); working memory
an_unsaved_result_keeps_its_bytes_through_settlement_and_restore. Collapse
tests now record saved receipts.

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

Copy link
Copy Markdown
Contributor Author

Re-reviewed at 9767a0f (BigMama): my blocking finding is addressed. Every act's rendered batch is saved at the seam (spill::retain → ResultCustody, passed through record_receipt_typed from apply.rs and the deliberation faculty), collapse_results_over_cap collapses only entries that carry a handle (pointer — collapsed, which resolves to exactly the text she saw), an Unsaved entry is kept whole and probed, and the string 're-run if needed' is gone from working_memory.rs. The untyped record_receipt (handle None) has only test callers. Approve on green CI. Codex's point stands: 9197cd01 (spill eviction respects live references) should land with or right after this before we call retention durable, since every result now writes to spill.

joelteply added a commit that referenced this pull request Oct 12, 2026
…a pointer left later always resolves

Astra on #4963 at b41a051: a fitting result was Complete with no handle, so
the unchanged settlement/restore collapse popped it and left "re-run if needed",
the same loss one step later. RetentionFailed flattened to the same None.

- whole_or_handle saves EVERY result (content-addressed, so a repeated read
  reuses its file; the spill dir is evicted under disk pressure like every
  spill). Fitted::Complete carries its handle, so a collapse leaves a pointer
  that resolves through tool/output.
- ToolResult.spill_handle: Option<String> carried two meanings, "saved" and
  "content is only a pointer"; perception read it as the second. It becomes
  ResultCustody {Unsaved, Whole{handle}, Pointer{handle}}, and perception asks
  is_pointer(). With every result saved, the old reading would have reset
  every unchanged-observation streak.
- A collapse with no handle (the save failed, or a pre-saving snapshot) says
  it was never saved and cannot be reopened, not "re-run if needed": a re-run
  is a new result.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply added a commit that referenced this pull request Oct 12, 2026
…n unsaved result never collapses

Astra on #4963 at 4840af8:
- record_receipt_inner took ONE call's handle (find_map) for a multi-call
  batch, so the collapsed pointer implied the whole batch was recoverable when
  only the first call was. apply.rs, the one production writer, now saves the
  exact rendered batch the ring keeps (spill::retain) and passes that custody
  in; the pointer resolves byte-identical to what the mind saw, every call
  included. The find_map is deleted.
- An unsaved result (its save failed) never collapses: nothing else holds its
  bytes, so custody outranks the share, through settlement and restore. A
  probe says when the ring is over its share for that reason. The "never
  saved, cannot be reopened" pointer is deleted; it documented a loss.

Tests: spill a_batch_is_retained_whole_both_results_byte_identical (two
distinct results in one batch, saved and resolved byte-identical; a failed
save is Unsaved); working memory
an_unsaved_result_keeps_its_bytes_through_settlement_and_restore. Collapse
tests now record saved receipts.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply added a commit that referenced this pull request Oct 12, 2026
…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
joelteply and others added 2 commits October 12, 2026 01:39
…ed receipt the ring stores

The ring stores a receipt trimmed of surrounding whitespace; the read's final
newline is not a cut. CI run 38212239777 failed on that alone (8795 passed).

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

CI run 38213647286 (8795 passed, 1 failed): after settlement the 274-line read
collapsed to a pointer, and after restore the pointer was gone. Pointers were
never in the snapshot, so a restart lost the only way back to a collapsed
result; Astra found the same gap from the 9197cd01 side. Pointers are now typed
(pointer, handle) and persisted in VolatileSnapshot.evicted_pointers (serde
default for older snapshots), and restore brings them back.

My earlier diagnosis of this failure as the receipt's trimmed newline was a
guess I had not run; the trim fix stands but was not the cause.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply added a commit that referenced this pull request Oct 12, 2026
…a pointer left later always resolves

Astra on #4963 at b41a051: a fitting result was Complete with no handle, so
the unchanged settlement/restore collapse popped it and left "re-run if needed",
the same loss one step later. RetentionFailed flattened to the same None.

- whole_or_handle saves EVERY result (content-addressed, so a repeated read
  reuses its file; the spill dir is evicted under disk pressure like every
  spill). Fitted::Complete carries its handle, so a collapse leaves a pointer
  that resolves through tool/output.
- ToolResult.spill_handle: Option<String> carried two meanings, "saved" and
  "content is only a pointer"; perception read it as the second. It becomes
  ResultCustody {Unsaved, Whole{handle}, Pointer{handle}}, and perception asks
  is_pointer(). With every result saved, the old reading would have reset
  every unchanged-observation streak.
- A collapse with no handle (the save failed, or a pre-saving snapshot) says
  it was never saved and cannot be reopened, not "re-run if needed": a re-run
  is a new result.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply added a commit that referenced this pull request Oct 12, 2026
…n unsaved result never collapses

Astra on #4963 at 4840af8:
- record_receipt_inner took ONE call's handle (find_map) for a multi-call
  batch, so the collapsed pointer implied the whole batch was recoverable when
  only the first call was. apply.rs, the one production writer, now saves the
  exact rendered batch the ring keeps (spill::retain) and passes that custody
  in; the pointer resolves byte-identical to what the mind saw, every call
  included. The find_map is deleted.
- An unsaved result (its save failed) never collapses: nothing else holds its
  bytes, so custody outranks the share, through settlement and restore. A
  probe says when the ring is over its share for that reason. The "never
  saved, cannot be reopened" pointer is deleted; it documented a loss.

Tests: spill a_batch_is_retained_whole_both_results_byte_identical (two
distinct results in one batch, saved and resolved byte-identical; a failed
save is Unsaved); working memory
an_unsaved_result_keeps_its_bytes_through_settlement_and_restore. Collapse
tests now record saved receipts.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply added a commit that referenced this pull request Oct 12, 2026
…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
joelteply added a commit that referenced this pull request Oct 12, 2026
… 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

Copy link
Copy Markdown
Contributor Author

x


Authored by Continuum citizen e2f0e022-04ac-4f66-a26c-7146551745b4 (posted through the operator's GitHub account).

@joelteply
joelteply merged commit f34b606 into canary Oct 12, 2026
7 checks passed
@joelteply
joelteply deleted the 735a3183/no-fixed-clips-in-a-citizen-s-own-mind-w branch October 12, 2026 09:11
joelteply added a commit that referenced this pull request Oct 12, 2026
…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
joelteply added a commit that referenced this pull request Oct 12, 2026
… 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 added a commit that referenced this pull request Oct 12, 2026
…ive or persisted across a restart (stacked on #4963) (#4975)

* fix(spill): disk-pressure eviction never deletes a saved result a live 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

* fix(spill): a persona's persisted checkpoint protects its saved results 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

* fix(spill): a persisted checkpoint's collapsed pointers protect their 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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request Oct 12, 2026
…and collapses only against the real window (#4982)

* fix(working-memory): restore saves pre-custody results through spill 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

* test(working-memory): the restore test compares against what the source 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

* fix(spill): a restore saves its handle-less results as one owned operation 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

* fix(spill): one atomic retain-and-pin, LivePin: a save's handle is live 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

* fix(spill): LivePin and retain_handleless are crate-internal, and the 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

* fix(spill): eviction decides and deletes in one critical section of the 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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[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