Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): finalize runs when provider streams stop #15776

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

Showing 12 changed files with 180 additions and 2 deletions (loading 10).

x
0 of 12 viewed, 12 left
30 additions and 0 deletionsapps/server/src/orchestration-v2/testkit/OrchestratorReplayFixtures.integration.test.tsModified
View file
@@ -83,6 +83,35 @@
​
+// These are production Orchestrator admissions, not pre-seeded routing inputs.
+// Raw snapshot-before-terminal ordering is covered at the adapter boundary;
+// here a successful finalization proves the initially unknown root was learned.
+function assertRootIdentityLearnedFromSnapshot(events: ReadonlyArray<OrchestrationV2DomainEvent>) {
+ assert.isTrue(events.some((event) => event.type === "run-attempt.created"));
+ for (const [index, event] of events.entries()) {
+ if (event.type !== "run-attempt.created" && event.type !== "run-attempt.updated") continue;
+ const attempt = event.payload;
+ const admissionIndex = events.findIndex(
+ (candidate) =>
+ candidate.type === "run-attempt.created" && candidate.payload.id === attempt.id,
+ );
+ assert.isAtLeast(admissionIndex, 0, `${attempt.id} needs a production admission`);
+ if (index === admissionIndex) {
+ assert.isNull(attempt.providerTurnId, `${attempt.id} must enter with unknown root identity`);
+ }
+ if (attempt.status !== "completed" && attempt.status !== "interrupted") continue;
+ const snapshotIndex = events.findIndex(
+ (candidate) =>
+ candidate.type === "provider-turn.updated" &&
+ candidate.payload.runAttemptId === attempt.id &&
+ candidate.payload.nodeId === attempt.rootNodeId &&
+ candidate.payload.providerThreadId === attempt.providerThreadId,
+ );
+ assert.isAbove(snapshotIndex, admissionIndex, `${attempt.id} needs an admitted root snapshot`);
+ assert.isBelow(snapshotIndex, index, `${attempt.id} must learn its root before finalization`);