fix(server): reconcile active sessions after restart #7463
Closedayubun(GitHub profile, opens in a new tab)wants to merge 1 commit into
main fromrefs/pull/7463/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
ayubun(GitHub profile, opens in a new tab) changed the title
ayubun(GitHub profile, opens in a new tab) changed the title
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/server/src/serverRuntimeStartup.ts lines 320 to 326Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -292,0 +305,21 @@305+ ...binding,306+ status: "stopped",307+ runtimePayload: { activeTurnId: null },308+ });309+ }310+ }).pipe(311+ Effect.catch((error) =>312+ Effect.logWarning("provider session startup reconciliation failed to reconcile binding", {313+ error,314+ threadId: id,315+ }),316+ ),317+ );318+319+ yield* dispatch({320+ type: "thread.session.set",321+ commandId: CommandId.make(yield* (yield* Crypto.Crypto).randomUUIDv4),322+ threadId: id,323+ session: { ...session, status: "stopped", activeTurnId: null },324+ createdAt: DateTime.formatIso(yield* DateTime.now),325+ });
- apps/server/src/serverRuntimeStartup.test.ts lines 156 to 156OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -72,0 +136,21 @@136+ sessionThread(ThreadId.make("thread-startup-ready"), "ready"),137+ ]),138+ ),139+ Effect.provideService(ProviderSessionDirectory.ProviderSessionDirectory, {140+ getBinding: (candidate: ThreadId) =>141+ candidate === threadId142+ ? Effect.succeed(143+ Option.some({144+ threadId,145+ provider: ProviderDriverKind.make("codex"),146+ providerInstanceId: ProviderInstanceId.make("codex"),147+ status: "running",148+ resumeCursor,149+ }),150+ )151+ : Effect.fail(bindingFailure),152+ upsert: (binding: ProviderSessionDirectory.ProviderRuntimeBinding) =>153+ Effect.sync(() => upserts.push(binding)).pipe(154+ Effect.andThen(Effect.fail(bindingWriteFailure)),155+ ),156+ } satisfies Partial<ProviderSessionDirectory.ProviderSessionDirectoryShape> as never),apps/server/src/serverRuntimeStartup.test.ts lines 204 to 204OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -72,0 +184,21 @@184+ ),185+ );186+});187+188+it.effect("fails startup reconciliation when a session cannot be settled", () => {189+ const threadId = ThreadId.make("thread-startup-reconcile-failure");190+ const failure = new OrchestrationCommandInvariantError({191+ commandType: "thread.session.set",192+ detail: "simulated reconciliation failure",193+ });194+195+ return ServerRuntimeStartup.reconcileProviderSessions.pipe(196+ Effect.provideService(197+ ProjectionSnapshotQuery.ProjectionSnapshotQuery,198+ queryWithThreads([199+ sessionThread(threadId, "running", TurnId.make("turn-startup-reconcile-failure")),200+ ]),201+ ),202+ Effect.provideService(ProviderSessionDirectory.ProviderSessionDirectory, {203+ getBinding: () => Effect.succeed(Option.none()),204+ } satisfies Partial<ProviderSessionDirectory.ProviderSessionDirectoryShape> as never),
juliusmarminge closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
6a92ee44-e5e6-49c9-9981-0189a4dacbf1You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share