Skip to content

Commit 1114cf0

Browse files
committed
test(orchestration): stop provider after archive
1 parent 5f369cd commit 1114cf0

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

‎apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4384,6 +4384,70 @@ describe("ProviderCommandReactor", () => {
43844384
}),
43854385
);
43864386

4387+
effectIt.effect("stops a live provider session after the thread is archived", () =>
4388+
Effect.gen(function* () {
4389+
const harness = yield* Effect.promise(() => createHarness());
4390+
const threadId = ThreadId.make("thread-1");
4391+
const now = "2026-01-01T00:00:00.000Z";
4392+
const providerInstanceId = ProviderInstanceId.make("codex_work");
4393+
4394+
yield* harness.engine.dispatch({
4395+
type: "thread.session.set",
4396+
commandId: CommandId.make("cmd-session-set-before-archive"),
4397+
threadId,
4398+
session: {
4399+
threadId,
4400+
status: "ready",
4401+
providerName: "codex",
4402+
providerInstanceId,
4403+
runtimeMode: "approval-required",
4404+
activeTurnId: null,
4405+
lastError: null,
4406+
updatedAt: now,
4407+
},
4408+
createdAt: now,
4409+
});
4410+
harness.runtimeSessions.push({
4411+
provider: ProviderDriverKind.make("codex"),
4412+
providerInstanceId,
4413+
status: "ready",
4414+
runtimeMode: "approval-required",
4415+
threadId,
4416+
resumeCursor: { opaque: "archived-stop" },
4417+
createdAt: now,
4418+
updatedAt: now,
4419+
});
4420+
4421+
yield* harness.engine.dispatch({
4422+
type: "thread.archive",
4423+
commandId: CommandId.make("cmd-archive-before-stop"),
4424+
threadId,
4425+
});
4426+
const activeShell = yield* harness.snapshotQuery.getThreadShellById(threadId);
4427+
expect(Option.isNone(activeShell)).toBe(true);
4428+
4429+
yield* harness.engine.dispatch({
4430+
type: "thread.session.stop",
4431+
commandId: CommandId.make("cmd-stop-after-archive"),
4432+
threadId,
4433+
createdAt: "2026-01-01T00:00:01.000Z",
4434+
});
4435+
4436+
yield* Effect.promise(() => harness.drain());
4437+
4438+
expect(harness.stopSession).toHaveBeenCalledWith({ threadId });
4439+
expect(harness.runtimeSessions).toHaveLength(0);
4440+
const archived = yield* harness.snapshotQuery.getArchivedShellSnapshot();
4441+
const archivedThread = archived.threads.find((entry) => entry.id === threadId);
4442+
expect(archivedThread?.session).toMatchObject({
4443+
status: "stopped",
4444+
providerName: "codex",
4445+
providerInstanceId,
4446+
activeTurnId: null,
4447+
});
4448+
}),
4449+
);
4450+
43874451
effectIt.effect("stops a ready provider session after automatic settlement", () =>
43884452
Effect.gen(function* () {
43894453
const sessionStopped = yield* Deferred.make<void>();

0 commit comments

Comments
 (0)