Stop paying twice for a block a retry can still throw away

A memory whose block ends on the newest action is the one memory a player
can reach: retry and take-switching both refuse anything else. Each retry
of that turn withdrew the memory and wrote it again, and a block closes
every six actions while a normal turn writes two, so that was one turn in
three.

SETTLE_SLACK asks for one action past a block before the block is
summarized. The block is still MEMORY_INTERVAL actions; only the moment
moves. This is not the pre-SP4 holdback returning: that one was about a
retry rewriting text in place, which sibling attempts and forget_node
settled, and correctness still rests on the withdrawal rather than on the
slack. Undo and delete can carry a summarized node back to the tip, so the
withdrawal path stays reachable, just rarely.

The slack buys nothing back. The block that just closed is still in the
history window in full, so a memory of it says what the model can already
read.

Tests: the settling suite asserts the new rule and that a retry at the tip
finds nothing to withdraw; the rewrite suite builds thirteen actions so
both of its blocks settle; the one path test that ended on a block boundary
sets the slack to zero, because it is about which actions a block is read
from rather than about when a block forms. 632 green.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015NcrxCJjqgDvAkamKeLWdn
This commit is contained in:
Claude
2026-09-01 19:30:56 +05:30
committed by Parth
parent 745a4ea9f3
commit d72f7c1bda
9 changed files with 178 additions and 31 deletions
+16 -4
View File
@@ -392,7 +392,7 @@ raw turns → memories → story summary
| Layer | Cadence | Purpose |
|---|---|---|
| **Memory** | Every 6 actions, starting at 12 | One or two past-tense sentences of concrete fact. |
| **Memory** | Every 6 actions, starting at 12, once one action sits past the block | One or two past-tense sentences of concrete fact. |
| **Story summary** | Every 15 actions | A single ≤250-word overview of the whole plot, rewritten by folding in the new memories. |
| **Retrieval** | Every turn | Embed the last 4 actions (≤600 tokens), cosine-rank the bank, inject the top K (default 5). |
@@ -413,8 +413,18 @@ This is also how repair works. When a turn's text is replaced or removed (a retr
a deleted action), `forget_node` withdraws the memory attached to that coordinate and
rewinds both marks to just before the stretch it covered, so the ground is summarized again
from what the story now says. An earlier version instead held the newest action back a turn
so it could never be summarized before it stopped being retryable. That is no longer
needed, because the repair exists whether or not the invalidation happens at the tip.
so it could never be summarized before it stopped being retryable. Correctness no longer
rests on that, because the repair exists whether or not the invalidation happens at the tip.
**A block still waits for one action to settle past it** (`SETTLE_SLACK`), and that is a
cost rule rather than a correctness one. Retry and take-switching both refuse anything but
the newest action, so a memory whose block ends on the tip is the one memory a player can
still throw away: every retry of that turn writes it, withdraws it, and writes it again. A
block closes every 6 actions and a normal turn writes 2, so without the slack that is one
turn in three. The slack costs nothing in return, because the block that just closed is
still in the history window in full — a memory of it says what the model can already read.
Memories earn their place once the raw text has scrolled out, which is never the turn the
block closed.
**Cursors only advance on success.** Every AI call in this module is best-effort. If
summarization fails, the function returns and the cursor is unchanged, so the same block is
@@ -724,7 +734,9 @@ is ambiguous once two branches both have a node 41.
`position_of_index`, `note_action_removed`, `settled_story_actions` and the cursor-rewind
machinery were **deleted**, not left unused. So was the one-turn memory holdback that
existed because a retry could rewrite an action the mark had already passed.
existed because a retry could rewrite an action the mark had already passed. (`SETTLE_SLACK`
later put one action of slack back, for what redoing a block costs rather than for what it
could get wrong. See "The memory system".)
### Derived work attaches to the node that produced it