import { describe, expect, it } from "vitest"; import { workerCheckpointPayloadSchema, workerCheckpointToolStepSchema, } from "@tasks/shared/worker"; describe("worker checkpoint schemas", () => { it("accepts path + hash tool steps without file contents", () => { const step = workerCheckpointToolStepSchema.parse({ seq: 1, tool: "write_file", args: { path: "apps/worker/src/x.ts", contentHash: "a".repeat(64), }, ok: true, resultDigest: "ok:deadbeefdeadbeef", }); expect(step.args).not.toHaveProperty("content"); expect(JSON.stringify(step)).not.toMatch(/api[_-]?key/i); }); it("rejects oversized tool history beyond the bound", () => { const history = Array.from({ length: 51 }, (_, i) => ({ seq: i + 1, tool: "read_file" as const, args: { path: `f-${i}.ts` }, ok: true, })); expect(() => workerCheckpointPayloadSchema.parse({ toolHistory: history, filesTouched: [], branch: "worker/x", worktreePath: "/tmp/wt", }), ).toThrow(); }); });