Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): serialize checkpoint restores with pending turns #10608

Closedsaphid(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/10608/headopened View on GitHub

Showing 38 changed files with 124 additions and 4 deletions (loading 35).

x
0 of 38 viewed, 38 left
12 additions and 4 deletionsapps/server/integration/orphanedProviderSessionStartup.integration.test.tsModified
View file
@@ -276,12 +276,13 @@
const restartedStoppedBindingThread = Option.getOrThrow(
yield* query.getThreadDetailById(stoppedBindingThreadId),
- const pendingRows = yield* sql<{ readonly threadId: string }>`
- SELECT thread_id AS "threadId"
+ const pendingRows = yield* sql<{ readonly messageId: string }>`
+ SELECT pending_message_id AS "messageId"
FROM projection_turns
WHERE thread_id IN (${threadId}, ${stoppedBindingThreadId})
AND turn_id IS NULL
AND state = 'pending'
+ ORDER BY pending_message_id ASC
const settleExit = yield* Effect.exit(
engine.dispatch({
@@ -323,7 +324,11 @@
sessionStatus: restartedThread.session?.status,
activeTurnId: restartedThread.session?.activeTurnId,
latestTurn: restartedThread.latestTurn,
- pendingTurnCount: pendingRows.length,
+ // This seam mocks OrchestrationReactor, so the provider reactor that
+ // emits correlated restart failures does not consume these requests.
+ // Session reconciliation must leave them intact instead of clearing
+ // unrelated pending work with an uncorrelated terminal status.
+ pendingTurnMessageIds: pendingRows.map((row) => row.messageId),
settleSucceeded: Exit.isSuccess(settleExit),
snoozeSucceeded: Exit.isSuccess(snoozeExit),
newTurnSucceeded: Exit.isSuccess(newTurnExit),