Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): compact superseded turn-item snapshots #20990

MergedJustYannicc(GitHub profile, opens in a new tab)merged 111 commits intomain fromrefs/pull/20990/headmerged by Yash-Singh1(GitHub profile, opens in a new tab) View on GitHub

Showing 3 changed files with 12 additions and 6 deletions (loading 1).

x
0 of 3 viewed, 3 left
1 addition and 0 deletionsapps/server/src/orchestration-v2/FoundationPersistence.test.tsModified
View file
@@ -931,6 +931,7 @@
messageEvent("message-1", "streaming"),
nodeEvent("node-1", "running"),
itemEvent("item-1", "streaming"),
+ itemEvent("item-middle", "still streaming"),
...Array.from({ length: 501 }, (_, index) =>
threadStateEvent(`history-${index}`, "thread.visited"),
11 additions and 6 deletionsapps/server/src/orchestration-v2/ProjectionMaintenance.tsModified
View file
@@ -222,13 +222,12 @@
​
const supersedableThreadEventTypes = new Set(SUPERSEDABLE_THREAD_EVENT_TYPES);
const readStateThreadEventTypes = new Set(READ_STATE_THREAD_EVENT_TYPES);
- // Keep subagent.updated and turn-item.updated rows: slimmed payloads reference their prompts.
- // Bound each reader request and writer delete, including when the reader
- // worker is unavailable and discovery falls back to the writer.
+ // Subagent snapshots stay intact because later rows can reference an earlier prompt.
+ // Commanded turn items stay for command-result replay.
+ // Small pages bound work on the reader worker and synchronous fallback.
const COMPACTION_PAGE_SIZE = 50;
​
- /** Retain newest and oldest keyed events to preserve client insertion order; page all events to bound sparse scans.
- * Keep turn-item.updated because replay assigns positions on first write. */
+ // Keep first/latest keyed events for replay order; page every event to bound sparse scans.
const compactEventStore = Effect.fn("ProjectionMaintenance.compactEventStore")(function* (
betweenPages: Effect.Effect<void> = Effect.void,
) {