Skip to content

Commit d188834

Browse files
committed
test(server): keep the liveness probe out of Codex replay tests
Replays follow a recorded conversation, so the replay harness answers the probe itself. The compaction tests now set their clock before the session opens; jumping decades afterwards made the probe catch up minute by minute. Also restores the Path and ServerConfig imports the merge with main dropped, and writes writeReleaseRecords with Effect.fn for main's new lint rule.
1 parent 86a8787 commit d188834

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import * as Exit from "effect/Exit";
4040
import * as Option from "effect/Option";
4141
import * as Predicate from "effect/Predicate";
4242
import * as FileSystem from "effect/FileSystem";
43+
import * as Path from "effect/Path";
4344
import { MCP_APP_OUTPUT_KEY, readMcpAppReference } from "@t3tools/shared/mcpApp";
4445
import { resolveAttachmentPathById } from "../../attachmentStore.ts";
4546
import * as Fiber from "effect/Fiber";
@@ -64,6 +65,7 @@ import * as Orchestrator from "../Orchestrator.ts";
6465
import * as ProviderReplayHarness from "../testkit/ProviderReplayHarness.ts";
6566
import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
6667
import type * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
68+
import * as ServerConfig from "../../config.ts";
6769
import * as CodexAdapterV2 from "./CodexAdapterV2.ts";
6870
import { makeReplayServerConfig, withCodexReplayChildMetadata } from "./CodexAdapterV2.testkit.ts";
6971
import * as CodexAdapterV2Testkit from "./CodexAdapterV2.testkit.ts";
@@ -1210,10 +1212,13 @@ describe("CodexAdapterV2 post-settle continuation", () => {
12101212
(client) =>
12111213
({
12121214
...client,
1215+
// Liveness probes follow the clock, not the recorded conversation.
12131216
request: (method, params) =>
1214-
onRequest(method, params).pipe(
1215-
Effect.andThen(client.request(method, params)),
1216-
),
1217+
method === "thread/loaded/list"
1218+
? Effect.succeed({ data: [] } as never)
1219+
: onRequest(method, params).pipe(
1220+
Effect.andThen(client.request(method, params)),
1221+
),
12171222
}) satisfies CodexClient.CodexAppServerClient["Service"],
12181223
),
12191224
Effect.provide(context),
@@ -2235,6 +2240,8 @@ describe("CodexAdapterV2 post-settle continuation", () => {
22352240
],
22362241
});
22372242
const compactionStarted = yield* Deferred.make<ProviderTurnId>();
2243+
// Before the session opens, so its liveness timer does not replay the jump.
2244+
yield* TestClock.setTime(1782622445000);
22382245
const harness = yield* makeCodexReplayHarness(transcript, (event) =>
22392246
event.type === "turn_item.updated" &&
22402247
event.turnItem.nativeItemRef?.nativeId === "unfinished-item" &&
@@ -2243,7 +2250,6 @@ describe("CodexAdapterV2 post-settle continuation", () => {
22432250
? Deferred.succeed(compactionStarted, event.turnItem.providerTurnId)
22442251
: Effect.void,
22452252
);
2246-
yield* TestClock.setTime(1782622445000);
22472253
yield* harness.runtime.startTurn(
22482254
makeCodexTestTurnInput({
22492255
threadId: harness.threadId,

‎apps/server/src/orchestration-v2/ProviderSessionManager.ts‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -819,14 +819,14 @@ export const layerWithOptions = (
819819
{ discard: true },
820820
);
821821

822-
const writeReleaseRecords = (input: {
823-
readonly entry: LiveSessionEntry;
824-
readonly reason: ProviderSessionReleaseReason;
825-
readonly detail?: string;
826-
readonly releasedBackgroundTasks: ReadonlyArray<ReleasedBackgroundTasks>;
827-
readonly releasedAt: DateTime.Utc;
828-
}) =>
829-
Effect.gen(function* () {
822+
const writeReleaseRecords = Effect.fn("ProviderSessionManager.writeReleaseRecords")(
823+
function* (input: {
824+
readonly entry: LiveSessionEntry;
825+
readonly reason: ProviderSessionReleaseReason;
826+
readonly detail?: string;
827+
readonly releasedBackgroundTasks: ReadonlyArray<ReleasedBackgroundTasks>;
828+
readonly releasedAt: DateTime.Utc;
829+
}) {
830830
// The open lock protects status ownership, including after a replacement closes.
831831
const key = sessionKey(input.entry.runtime.providerSessionId);
832832
const ownsStatus = (yield* Ref.get(latestOpened)).get(key) === input.entry.runtime;
@@ -850,7 +850,8 @@ export const layerWithOptions = (
850850
updated.delete(key);
851851
return updated;
852852
});
853-
});
853+
},
854+
);
854855

855856
// Retry after removal from the live map; later releases cannot clear stale ready sessions and approvals.
856857
const retryReleaseRecords = (input: Parameters<typeof writeReleaseRecords>[0]) => {

0 commit comments

Comments
 (0)