Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): restore queued turn identity after restart #10611

Closedsaphid(GitHub profile, opens in a new tab)wants to merge 9 commits intomain fromrefs/pull/10611/headopened View on GitHub

Showing 43 changed files with 130 additions and 8 deletions (loading 40).

x
0 of 43 viewed, 43 left
18 additions and 8 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,9 +324,15 @@
sessionStatus: restartedThread.session?.status,
activeTurnId: restartedThread.session?.activeTurnId,
latestTurn: restartedThread.latestTurn,
- pendingTurnCount: pendingRows.length,
- settleSucceeded: Exit.isSuccess(settleExit),
- snoozeSucceeded: Exit.isSuccess(snoozeExit),
+ // 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),
+ // The provider reactor is intentionally mocked above, so both