test: require explicit final checkpoints in warm qualification

Expose the existing finalization timestamp through the scoped sync API and reject periodic-only or out-of-run saves.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-09-09 00:06:05 -05:00
1 parent 1d6ee1a642
commit a24d331c41
6 files changed
+91 -1

No files matched your search

@@ -66,3 +66,21 @@ it.each([
expect.objectContaining({ runId: "saved-run", state: priorState, lastSavedAt: "2026-09-08T12:00:00.000Z" }),
]);
});
it.each([undefined, "2026-09-09T04:00:00.000Z"])(
"distinguishes periodic saves from explicit finalization (%s)",
async (finalCheckpointAt) => {
const saved = {
folderRun: { runId: "run", manifest: { agentId: "agent", sandboxKey: "sandbox", finalCheckpointAt },
state: "saved", lastSavedAt: new Date("2026-09-09T04:00:00Z"), error: null, refreshRequested: false },
status: "succeeded",
};
const query = { from: () => query, innerJoin: () => query, where: () => query,
orderBy: () => query, limit: async () => [saved] };
const app = express();
app.use("/api", workFolderRoutes({ select: () => query } as unknown as Db));
const response = await request(app).get("/api/companies/11111111-1111-4111-8111-111111111111/work-folders/task/22222222-2222-4222-8222-222222222222/sync").expect(200);
expect(response.body).toEqual([expect.objectContaining({ runId: "run", state: "saved", active: false,
lastSavedAt: "2026-09-09T04:00:00.000Z", finalCheckpointAt: finalCheckpointAt ?? null })]);
},
);
+1
View File
@@ -95,6 +95,7 @@ export function workFolderRoutes(db: Db, provider?: StorageProvider) {
const interrupted = !active && (row.state === "starting" || row.state === "saving");
return { runId: row.runId, agentId: row.manifest.agentId, state: interrupted ? "failed" : row.state,
lastSavedAt: row.lastSavedAt, error: interrupted ? row.error ?? "Run ended before its final file save completed." : row.error,
finalCheckpointAt: row.manifest.finalCheckpointAt ?? null,
refreshRequested: row.refreshRequested, active };
};
const leases = new Set<string>();