// Release 36 lane D: how a labels pass batches the proposals. import { test } from "node:test"; import assert from "node:assert/strict"; import { batchesOf, LOCAL_BATCH_MAX } from "./clipsSuggest"; import type { SuggestInput } from "../../../clips/suggest.mjs"; const items = (n: number, words = 20): SuggestInput[] => Array.from({ length: n }, (_, i) => ({ id: `p${String(i + 1).padStart(3, "0")}`, start: i * 30, end: i * 30 + 12, score: 0.5, used: false, kinds: ["laugh"], lines: [{ role: "host", speaker: 0, text: Array.from({ length: words }, (_, k) => `w${k}`).join(" ") }], })); test("batches: 30 a call on the API; at most 20 locally, and fewer when the prompt cap is reached", () => { assert.deepEqual(batchesOf(items(70), "claude-sonnet-5-5").map((b) => b.length), [30, 30, 10]); assert.equal(LOCAL_BATCH_MAX, 20); assert.deepEqual(batchesOf(items(45), "qwen3:8b").map((b) => b.length), [20, 20, 5]); const long = batchesOf(items(45, 600), "qwen3:8b"); assert.ok(long.length > 3 && long.every((b) => b.length >= 1 && b.length < 20), JSON.stringify(long.map((b) => b.length))); assert.deepEqual(long.flat().map((i) => i.id), items(45).map((i) => i.id)); });