42 lines
1.8 KiB
TypeScript
42 lines
1.8 KiB
TypeScript
import * as fs from "node:fs";
|
|
import * as os from "node:os";
|
|
import * as path from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import { createDistillationReceipt, writeDistillationReceipt } from "./distillation-receipt.js";
|
|
|
|
describe("distillation receipt", () => {
|
|
it("allows open-weight teacher provenance", () => {
|
|
const receipt = createDistillationReceipt({
|
|
dataset: "math_train_sample.json",
|
|
output: "distill.json",
|
|
teacherModel: "qwen3:4b",
|
|
provider: "ollama",
|
|
teacherKind: "open-weight",
|
|
samples: 10,
|
|
now: new Date("2026-06-27T00:00:00.000Z"),
|
|
});
|
|
|
|
expect(receipt.schema).toBe("fable.distillation.receipt.v1");
|
|
expect(receipt.decision).toBe("ok");
|
|
expect(receipt.reasons).toEqual([]);
|
|
});
|
|
|
|
it("flags closed or unknown teachers for review", () => {
|
|
const closed = createDistillationReceipt({ dataset: "x", output: "y", teacherModel: "claude", provider: "openrouter", teacherKind: "closed-frontier" });
|
|
const unknown = createDistillationReceipt({ dataset: "x", output: "y", teacherModel: "mystery", provider: "other" });
|
|
|
|
expect(closed.decision).toBe("needs-review");
|
|
expect(closed.reasons.join("\n")).toContain("closed-frontier teacher output");
|
|
expect(unknown.decision).toBe("needs-review");
|
|
expect(unknown.reasons.join("\n")).toContain("teacher kind unknown");
|
|
});
|
|
|
|
it("writes a JSON receipt", () => {
|
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "distill-receipt-"));
|
|
const file = path.join(dir, "receipt.json");
|
|
writeDistillationReceipt(file, createDistillationReceipt({ dataset: "x", output: "y", teacherModel: "qwen", provider: "ollama", teacherKind: "open-weight" }));
|
|
|
|
expect(fs.readFileSync(file, "utf-8")).toContain("fable.distillation.receipt.v1");
|
|
});
|
|
});
|