From 4196a4cd76db434854b679035e4146c7f69689ce Mon Sep 17 00:00:00 2001 From: Dotta Date: Thu, 24 Sep 2026 16:06:08 -0700 Subject: [PATCH] test(runner): decouple file evidence from admission timing Pre-capture the real baseline for the file-change assertion so EC2 load cannot turn its 100 ms admission deadline into an unrelated evidence-test failure. Keep the real after-snapshot and exact file assertions. Co-Authored-By: Paperclip --- .../src/live/live-session.test.ts | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/packages/paperclip-runner/src/live/live-session.test.ts b/packages/paperclip-runner/src/live/live-session.test.ts index 4f5ab051ded..999c5a96830 100644 --- a/packages/paperclip-runner/src/live/live-session.test.ts +++ b/packages/paperclip-runner/src/live/live-session.test.ts @@ -24,6 +24,7 @@ import { import { DurableCapabilityLiveSessionStore } from "./durable-live-session-store.js"; import { defaultCapabilityRunnerdBinary } from "./runnerd-codex-transport.js"; import { captureTurnRejection } from "../../test/capture-turn-rejection.js"; +import * as workspaceDiff from "./workspace-diff.js"; class AsyncNotifications implements AsyncIterable { #values: CodexRpcNotification[] = []; @@ -753,20 +754,30 @@ describe("Capability live runnerd and Codex session", () => { const service = new CapabilityLiveSessionService({ transportFactory: fakeTransportFactory(state) }); const session = await service.create({ workingDirectory: root }); - const result = await session.sendMessage("edit the workspace"); - expect(result.snapshot.workspaceDiffs).toHaveLength(1); - expect(result.snapshot.workspaceDiffs?.[0]).toMatchObject({ - turnId: "turn-1", - diff: { - schema: "paperclip.workspace.diff.v1", - source: "runner_verified", - complete: true, - totals: { files: 2 }, - }, - }); - expect(result.snapshot.workspaceDiffs?.[0]?.diff.files.map((file) => file.path)) - .toEqual(["created.ts", "existing.txt"]); - await service.shutdown(session.id); + // Test the file-change evidence, not whether a loaded CI worker scans the + // fixture within the production admission deadline. Keep both snapshots + // real; make only the already-captured baseline immediately available. + const baseline = await workspaceDiff.capturePaperclipWorkspace(root); + const capture = vi.spyOn(workspaceDiff, "capturePaperclipWorkspace") + .mockResolvedValueOnce(baseline); + try { + const result = await session.sendMessage("edit the workspace"); + expect(result.snapshot.workspaceDiffs).toHaveLength(1); + expect(result.snapshot.workspaceDiffs?.[0]).toMatchObject({ + turnId: "turn-1", + diff: { + schema: "paperclip.workspace.diff.v1", + source: "runner_verified", + complete: true, + totals: { files: 2 }, + }, + }); + expect(result.snapshot.workspaceDiffs?.[0]?.diff.files.map((file) => file.path)) + .toEqual(["created.ts", "existing.txt"]); + } finally { + capture.mockRestore(); + await service.shutdown(session.id); + } }); it("suspends after every per-turn response and restores the same provider session", async () => {