Skip to content

Commit d8d9bec

Browse files
committed
test: stabilize release gate coverage
1 parent eb7a30b commit d8d9bec

5 files changed

Lines changed: 233 additions & 221 deletions

File tree

apps/server/integration/orchestrationEngine.integration.test.ts

Lines changed: 172 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -330,185 +330,188 @@ it.live.skipIf(!process.env.CODEX_BINARY_PATH)(
330330
),
331331
);
332332

333-
it.live("runs multi-turn file edits and persists checkpoint diffs", () =>
334-
withHarness((harness) =>
335-
Effect.gen(function* () {
336-
yield* seedProjectAndThread(harness);
333+
it.live(
334+
"runs multi-turn file edits and persists checkpoint diffs",
335+
() =>
336+
withHarness((harness) =>
337+
Effect.gen(function* () {
338+
yield* seedProjectAndThread(harness);
337339

338-
yield* harness.adapterHarness!.queueTurnResponseForNextSession({
339-
events: [
340-
{
341-
type: "turn.started",
342-
...runtimeBase("evt-multi-1", "2026-02-24T10:01:00.000Z"),
343-
threadId: THREAD_ID,
344-
turnId: FIXTURE_TURN_ID,
345-
},
346-
{
347-
type: "tool.started",
348-
...runtimeBase("evt-multi-2", "2026-02-24T10:01:00.100Z"),
349-
threadId: THREAD_ID,
350-
turnId: FIXTURE_TURN_ID,
351-
toolKind: "command",
352-
title: "Edit file",
353-
detail: "README.md",
354-
},
355-
{
356-
type: "tool.completed",
357-
...runtimeBase("evt-multi-3", "2026-02-24T10:01:00.200Z"),
358-
threadId: THREAD_ID,
359-
turnId: FIXTURE_TURN_ID,
360-
toolKind: "command",
361-
title: "Edit file",
362-
detail: "README.md",
363-
},
364-
{
365-
type: "message.delta",
366-
...runtimeBase("evt-multi-4", "2026-02-24T10:01:00.300Z"),
367-
threadId: THREAD_ID,
368-
turnId: FIXTURE_TURN_ID,
369-
delta: "Updated README to v2.\n",
370-
},
371-
{
372-
type: "turn.completed",
373-
...runtimeBase("evt-multi-5", "2026-02-24T10:01:00.400Z"),
374-
threadId: THREAD_ID,
375-
turnId: FIXTURE_TURN_ID,
376-
status: "completed",
377-
},
378-
],
379-
mutateWorkspace: ({ cwd }) =>
380-
Effect.sync(() => {
381-
fs.writeFileSync(path.join(cwd, "README.md"), "v2\n", "utf8");
382-
}),
383-
});
340+
yield* harness.adapterHarness!.queueTurnResponseForNextSession({
341+
events: [
342+
{
343+
type: "turn.started",
344+
...runtimeBase("evt-multi-1", "2026-02-24T10:01:00.000Z"),
345+
threadId: THREAD_ID,
346+
turnId: FIXTURE_TURN_ID,
347+
},
348+
{
349+
type: "tool.started",
350+
...runtimeBase("evt-multi-2", "2026-02-24T10:01:00.100Z"),
351+
threadId: THREAD_ID,
352+
turnId: FIXTURE_TURN_ID,
353+
toolKind: "command",
354+
title: "Edit file",
355+
detail: "README.md",
356+
},
357+
{
358+
type: "tool.completed",
359+
...runtimeBase("evt-multi-3", "2026-02-24T10:01:00.200Z"),
360+
threadId: THREAD_ID,
361+
turnId: FIXTURE_TURN_ID,
362+
toolKind: "command",
363+
title: "Edit file",
364+
detail: "README.md",
365+
},
366+
{
367+
type: "message.delta",
368+
...runtimeBase("evt-multi-4", "2026-02-24T10:01:00.300Z"),
369+
threadId: THREAD_ID,
370+
turnId: FIXTURE_TURN_ID,
371+
delta: "Updated README to v2.\n",
372+
},
373+
{
374+
type: "turn.completed",
375+
...runtimeBase("evt-multi-5", "2026-02-24T10:01:00.400Z"),
376+
threadId: THREAD_ID,
377+
turnId: FIXTURE_TURN_ID,
378+
status: "completed",
379+
},
380+
],
381+
mutateWorkspace: ({ cwd }) =>
382+
Effect.sync(() => {
383+
fs.writeFileSync(path.join(cwd, "README.md"), "v2\n", "utf8");
384+
}),
385+
});
384386

385-
yield* startTurn({
386-
harness,
387-
commandId: "cmd-turn-start-multi-1",
388-
messageId: "msg-user-multi-1",
389-
text: "Make first edit",
390-
});
391-
yield* harness.waitForReceipt(
392-
(receipt): receipt is CheckpointDiffFinalizedReceipt =>
393-
receipt.type === "checkpoint.diff.finalized" &&
394-
receipt.threadId === THREAD_ID &&
395-
receipt.checkpointTurnCount === 1,
396-
);
387+
yield* startTurn({
388+
harness,
389+
commandId: "cmd-turn-start-multi-1",
390+
messageId: "msg-user-multi-1",
391+
text: "Make first edit",
392+
});
393+
yield* harness.waitForReceipt(
394+
(receipt): receipt is CheckpointDiffFinalizedReceipt =>
395+
receipt.type === "checkpoint.diff.finalized" &&
396+
receipt.threadId === THREAD_ID &&
397+
receipt.checkpointTurnCount === 1,
398+
);
397399

398-
yield* harness.waitForThread(
399-
THREAD_ID,
400-
(entry) => entry.checkpoints.length === 1 && entry.session?.threadId === "thread-1",
401-
);
400+
yield* harness.waitForThread(
401+
THREAD_ID,
402+
(entry) => entry.checkpoints.length === 1 && entry.session?.threadId === "thread-1",
403+
);
402404

403-
yield* harness.adapterHarness!.queueTurnResponse(THREAD_ID, {
404-
events: [
405-
{
406-
type: "turn.started",
407-
...runtimeBase("evt-multi-6", "2026-02-24T10:02:00.000Z"),
408-
threadId: THREAD_ID,
409-
turnId: FIXTURE_TURN_ID,
410-
},
411-
{
412-
type: "message.delta",
413-
...runtimeBase("evt-multi-7", "2026-02-24T10:02:00.100Z"),
414-
threadId: THREAD_ID,
415-
turnId: FIXTURE_TURN_ID,
416-
delta: "Updated README to v3.\n",
417-
},
418-
{
419-
type: "turn.completed",
420-
...runtimeBase("evt-multi-8", "2026-02-24T10:02:00.200Z"),
421-
threadId: THREAD_ID,
422-
turnId: FIXTURE_TURN_ID,
423-
status: "completed",
424-
},
425-
],
426-
mutateWorkspace: ({ cwd }) =>
427-
Effect.sync(() => {
428-
fs.writeFileSync(path.join(cwd, "README.md"), "v3\n", "utf8");
429-
}),
430-
});
405+
yield* harness.adapterHarness!.queueTurnResponse(THREAD_ID, {
406+
events: [
407+
{
408+
type: "turn.started",
409+
...runtimeBase("evt-multi-6", "2026-02-24T10:02:00.000Z"),
410+
threadId: THREAD_ID,
411+
turnId: FIXTURE_TURN_ID,
412+
},
413+
{
414+
type: "message.delta",
415+
...runtimeBase("evt-multi-7", "2026-02-24T10:02:00.100Z"),
416+
threadId: THREAD_ID,
417+
turnId: FIXTURE_TURN_ID,
418+
delta: "Updated README to v3.\n",
419+
},
420+
{
421+
type: "turn.completed",
422+
...runtimeBase("evt-multi-8", "2026-02-24T10:02:00.200Z"),
423+
threadId: THREAD_ID,
424+
turnId: FIXTURE_TURN_ID,
425+
status: "completed",
426+
},
427+
],
428+
mutateWorkspace: ({ cwd }) =>
429+
Effect.sync(() => {
430+
fs.writeFileSync(path.join(cwd, "README.md"), "v3\n", "utf8");
431+
}),
432+
});
431433

432-
yield* startTurn({
433-
harness,
434-
commandId: "cmd-turn-start-multi-2",
435-
messageId: "msg-user-multi-2",
436-
text: "Make second edit",
437-
});
438-
const secondReceipt = yield* harness.waitForReceipt(
439-
(receipt): receipt is CheckpointDiffFinalizedReceipt =>
440-
receipt.type === "checkpoint.diff.finalized" &&
441-
receipt.threadId === THREAD_ID &&
442-
receipt.checkpointTurnCount === 2,
443-
);
444-
if (secondReceipt.type !== "checkpoint.diff.finalized") {
445-
throw new Error("Expected checkpoint.diff.finalized receipt.");
446-
}
447-
assert.equal(secondReceipt.status, "ready");
448-
yield* harness.waitForReceipt(
449-
(receipt): receipt is TurnProcessingQuiescedReceipt =>
450-
receipt.type === "turn.processing.quiesced" &&
451-
receipt.threadId === THREAD_ID &&
452-
receipt.checkpointTurnCount === 2,
453-
);
434+
yield* startTurn({
435+
harness,
436+
commandId: "cmd-turn-start-multi-2",
437+
messageId: "msg-user-multi-2",
438+
text: "Make second edit",
439+
});
440+
const secondReceipt = yield* harness.waitForReceipt(
441+
(receipt): receipt is CheckpointDiffFinalizedReceipt =>
442+
receipt.type === "checkpoint.diff.finalized" &&
443+
receipt.threadId === THREAD_ID &&
444+
receipt.checkpointTurnCount === 2,
445+
);
446+
if (secondReceipt.type !== "checkpoint.diff.finalized") {
447+
throw new Error("Expected checkpoint.diff.finalized receipt.");
448+
}
449+
assert.equal(secondReceipt.status, "ready");
450+
yield* harness.waitForReceipt(
451+
(receipt): receipt is TurnProcessingQuiescedReceipt =>
452+
receipt.type === "turn.processing.quiesced" &&
453+
receipt.threadId === THREAD_ID &&
454+
receipt.checkpointTurnCount === 2,
455+
);
454456

455-
const secondTurnThread = yield* harness.waitForThread(
456-
THREAD_ID,
457-
(entry) =>
458-
entry.latestTurn?.turnId === "turn-2" &&
459-
entry.checkpoints.length === 2 &&
460-
entry.checkpoints.some((checkpoint) => checkpoint.checkpointTurnCount === 2),
461-
);
462-
const secondCheckpoint = secondTurnThread.checkpoints.find(
463-
(checkpoint) => checkpoint.checkpointTurnCount === 2,
464-
);
465-
assert.equal(
466-
secondCheckpoint?.files.some((file) => file.path === "README.md"),
467-
true,
468-
);
457+
const secondTurnThread = yield* harness.waitForThread(
458+
THREAD_ID,
459+
(entry) =>
460+
entry.latestTurn?.turnId === "turn-2" &&
461+
entry.checkpoints.length === 2 &&
462+
entry.checkpoints.some((checkpoint) => checkpoint.checkpointTurnCount === 2),
463+
);
464+
const secondCheckpoint = secondTurnThread.checkpoints.find(
465+
(checkpoint) => checkpoint.checkpointTurnCount === 2,
466+
);
467+
assert.equal(
468+
secondCheckpoint?.files.some((file) => file.path === "README.md"),
469+
true,
470+
);
469471

470-
const checkpointRows = yield* harness.checkpointRepository.listByThreadId({
471-
threadId: THREAD_ID,
472-
});
473-
assert.deepEqual(
474-
checkpointRows.map((row) => row.checkpointTurnCount),
475-
[1, 2],
476-
);
472+
const checkpointRows = yield* harness.checkpointRepository.listByThreadId({
473+
threadId: THREAD_ID,
474+
});
475+
assert.deepEqual(
476+
checkpointRows.map((row) => row.checkpointTurnCount),
477+
[1, 2],
478+
);
477479

478-
const incrementalDiff = yield* harness.checkpointStore.diffCheckpoints({
479-
cwd: harness.workspaceDir,
480-
fromCheckpointRef: checkpointRefForThreadTurn(THREAD_ID, 1),
481-
toCheckpointRef: checkpointRefForThreadTurn(THREAD_ID, 2),
482-
fallbackFromToHead: false,
483-
});
484-
assert.equal(incrementalDiff.includes("README.md"), true);
480+
const incrementalDiff = yield* harness.checkpointStore.diffCheckpoints({
481+
cwd: harness.workspaceDir,
482+
fromCheckpointRef: checkpointRefForThreadTurn(THREAD_ID, 1),
483+
toCheckpointRef: checkpointRefForThreadTurn(THREAD_ID, 2),
484+
fallbackFromToHead: false,
485+
});
486+
assert.equal(incrementalDiff.includes("README.md"), true);
485487

486-
const fullDiff = yield* harness.checkpointStore.diffCheckpoints({
487-
cwd: harness.workspaceDir,
488-
fromCheckpointRef: checkpointRefForThreadTurn(THREAD_ID, 0),
489-
toCheckpointRef: checkpointRefForThreadTurn(THREAD_ID, 2),
490-
fallbackFromToHead: false,
491-
});
492-
assert.equal(fullDiff.includes("README.md"), true);
488+
const fullDiff = yield* harness.checkpointStore.diffCheckpoints({
489+
cwd: harness.workspaceDir,
490+
fromCheckpointRef: checkpointRefForThreadTurn(THREAD_ID, 0),
491+
toCheckpointRef: checkpointRefForThreadTurn(THREAD_ID, 2),
492+
fallbackFromToHead: false,
493+
});
494+
assert.equal(fullDiff.includes("README.md"), true);
493495

494-
assert.equal(
495-
gitShowFileAtRef(
496-
harness.workspaceDir,
497-
checkpointRefForThreadTurn(THREAD_ID, 1),
498-
"README.md",
499-
),
500-
"v2\n",
501-
);
502-
assert.equal(
503-
gitShowFileAtRef(
504-
harness.workspaceDir,
505-
checkpointRefForThreadTurn(THREAD_ID, 2),
506-
"README.md",
507-
),
508-
"v3\n",
509-
);
510-
}),
511-
),
496+
assert.equal(
497+
gitShowFileAtRef(
498+
harness.workspaceDir,
499+
checkpointRefForThreadTurn(THREAD_ID, 1),
500+
"README.md",
501+
),
502+
"v2\n",
503+
);
504+
assert.equal(
505+
gitShowFileAtRef(
506+
harness.workspaceDir,
507+
checkpointRefForThreadTurn(THREAD_ID, 2),
508+
"README.md",
509+
),
510+
"v3\n",
511+
);
512+
}),
513+
),
514+
30_000,
512515
);
513516

514517
it.live("tracks approval requests and resolves pending approvals on user response", () =>

apps/server/src/git/Layers/GitCore.test.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,19 @@ it.layer(TestLayer)("git integration", (it) => {
199199
}),
200200
);
201201

202-
it.effect("does not include detached HEAD pseudo-refs as branches", () =>
203-
Effect.gen(function* () {
204-
const tmp = yield* makeTmpDir();
205-
yield* initRepoWithCommit(tmp);
206-
yield* git(tmp, ["checkout", "--detach", "HEAD"]);
202+
it.effect(
203+
"does not include detached HEAD pseudo-refs as branches",
204+
() =>
205+
Effect.gen(function* () {
206+
const tmp = yield* makeTmpDir();
207+
yield* initRepoWithCommit(tmp);
208+
yield* git(tmp, ["checkout", "--detach", "HEAD"]);
207209

208-
const result = yield* (yield* GitCore).listBranches({ cwd: tmp });
209-
expect(result.branches.some((branch) => branch.name.startsWith("("))).toBe(false);
210-
expect(result.branches.some((branch) => branch.current)).toBe(false);
211-
}),
210+
const result = yield* (yield* GitCore).listBranches({ cwd: tmp });
211+
expect(result.branches.some((branch) => branch.name.startsWith("("))).toBe(false);
212+
expect(result.branches.some((branch) => branch.current)).toBe(false);
213+
}),
214+
30_000,
212215
);
213216

214217
it.effect("keeps current branch first and sorts the remaining branches by recency", () =>

0 commit comments

Comments
 (0)