Make a retry a node, not a rewrite
Every attempt at a turn is now its own row at the same (branch, depth), with `live` naming the one the story tells. The JSON repeating group on `actions.variants` is read one last time, by a migration that writes it out as the sibling rows it always described, and then goes unread. The snapshots turn around with it: an action carries the state it left behind rather than the state it started from, because attempts at one turn share a starting position and differ exactly in their outcome. Rolling back is "what the node in front left behind", one lookup on the path, and it is what undo and retry now both read. And the memory holdback goes. It existed because retry rewrote a row under a mark that had already moved past it; a retry writes a sibling now, and replacing what a coordinate says withdraws what was derived from it — the same repair undo and delete already made. The assembled prompt is still stored once per turn: it moves with the live flag, so a superseded attempt keeps only the few hundred bytes that were its own. Measured on the 600-action fixture: 700 rows for the same 600-turn story, prompt archive byte-identical at 0.50 MB, index 1.8 kB and page load 62.7 kB unmoved. 347 tests green. `tests/test_story_tree_baseline.py` and `tests/test_retry_variants.py` pass unmodified — SP4 was allowed to move the baseline for the variant-count semantics and did not need to. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Dvvqn9ZDR4ixeFPHNbww7
This commit is contained in:
committed by
Parth
co-authored by
Claude Opus 5
parent
c51531709d
commit
0a12d9cd47
@@ -1692,8 +1692,15 @@ export default function Play() {
|
||||
busy={busy}
|
||||
previewIndex={previewing ? previewing.index : null}
|
||||
onPreview={setPreview}
|
||||
onSwitched={(updated) =>
|
||||
setActions((prev) => prev.map((a) => (a.id === updated.id ? updated : a)))}
|
||||
onSwitched={(updated) => {
|
||||
// Matched on the action we asked about, not on the one
|
||||
// that came back. Since the story tree made every
|
||||
// attempt its own row (phase 14 SP4), switching moves
|
||||
// the story onto a *different* row rather than
|
||||
// rewriting this one, so the reply carries a new id.
|
||||
setActions((prev) => prev.map(
|
||||
(a) => (a.id === action.id ? updated : a)))
|
||||
}}
|
||||
onError={(message) => setToast({ text: message, isError: true })}
|
||||
/>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user