Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): close stale request prompts during recovery and detach #15308

ClosedAdamulek123(GitHub profile, opens in a new tab)wants to merge 8 commits intomain fromrefs/pull/15308/headopened View on GitHub

Showing 7 changed files with 211 additions and 0 deletions (loading 5).

x
0 of 7 viewed, 7 left
197 additions and 0 deletionsapps/server/src/orchestration-v2/FoundationPersistence.test.tsModified
View file
@@ -22,6 +22,7 @@
ProviderThreadId,
RunAttemptId,
RunId,
+ RuntimeRequestId,
ThreadId,
TurnItemId,
} from "@t3tools/contracts";
@@ -338,6 +339,202 @@
).pipe(Effect.provide(TestLayer)),
​
+it.effect.each([
+ { trigger: "startup", runStatus: null },
+ { trigger: "shutdown", runStatus: null },
+ { trigger: "startup", runStatus: "completed" },
+ { trigger: "shutdown", runStatus: "completed" },
+] as const)(
+ "recovers request transcripts through SQLite on $trigger with run status $runStatus",
+ ({ trigger, runStatus }) =>
+ Effect.gen(function* () {
+ const eventSink = yield* EventSink.EventSinkV2;
+ const projections = yield* ProjectionStore.ProjectionStoreV2;
+ const now = yield* DateTime.now;
+ const threadId = ThreadId.make(`thread:request-transcript:${trigger}:${runStatus}`);
+ const runId = runStatus === null ? null : RunId.make(`run:${threadId}`);
+ const events: Array<OrchestrationV2DomainEvent> = [
+ threadCreatedEvent({
+ id: `event:${threadId}:thread`,