Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(orchestration): per-thread shell deltas, visit throttling, event compaction #4971

Mergedjuliusmarmingemerged 3 commits intot3code/codex-turn-mapping fromrefs/pull/4971/headmerged by juliusmarminge View on GitHub

Showing 17 changed files with 177 additions and 10 deletions (loading 14).

x
0 of 17 viewed, 17 left
139 additions and 0 deletionsapps/server/src/orchestration-v2/FoundationPersistence.test.tsModified
View file
@@ -265,6 +265,145 @@
}),
​
+ it.effect("compacts superseded state events, imported v1 events, and legacy receipts", () =>
+ Effect.gen(function* () {
+ const eventSink = yield* EventSinkV2;
+ const maintenance = yield* ProjectionMaintenanceV2;
+ const sql = yield* SqlClient.SqlClient;
+ const now = yield* DateTime.now;
+ const nowIso = DateTime.formatIso(now);
+ const threadId = ThreadId.make("thread:foundation-compact");
+ const thread = makeThread(threadId, now);
+ const messageId = MessageId.make("message:foundation-compact");
+ const threadStateEvent = (
+ suffix: string,
+ type: "thread.visited" | "thread.metadata-updated",
+ ): OrchestrationV2DomainEvent => ({
+ id: EventId.make(`event:foundation-compact:${suffix}`),
+ type,
+ threadId,
+ providerInstanceId,
+ occurredAt: now,
+ payload: { ...thread, lastVisitedAt: now },
+ });
+ const messageEvent = (suffix: string, text: string): OrchestrationV2DomainEvent => ({
+ id: EventId.make(`event:foundation-compact:${suffix}`),
+ type: "message.updated",
+ threadId,
+ occurredAt: now,