// The LINT A BUILD ENFORCES refuses a picked read that says an anonymous author's handle or display name (round 3, // review-c3c probe18): build-video.mjs enforcedLint -- the seam the build and every take's render (takeRender.mjs // renderArgv: no --no-lint) go through -- carries post-anon.mjs anonymityProblems' errors, in `umtool lint`'s words; // with no anonymous character it is lintManifest's as it was. And projectAnonymousSet refuses a video with anonymous // characters whose whole manifest cannot be read. Temp dirs only. // // Run: node --test umtool/report-to-video/anon-buildlint.test.mjs import assert from "node:assert/strict"; import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import path from "node:path"; import { after, test } from "node:test"; import { buildVideo, enforcedLint, selectVariant } from "./build-video.mjs"; import { lintManifest, lintManifestFile } from "./lint.mjs"; import { anonymiseManifest } from "./post-anon.mjs"; import { projectAnonymousSet } from "./project-characters-file.mjs"; import { renderArgv } from "../lib/report/takeRender.mjs"; const TMP = await mkdtemp(path.join(tmpdir(), "umtool-anon-buildlint-")); after(() => rm(TMP, { recursive: true, force: true })); const CHARS = { format: "umtool-project-characters", version: 1, characters: [{ id: "anon-1", name: "Real Guy", anonymous: true, shown: "Anon 1", handles: ["realguy"] }] }; const wholeOf = (script) => ({ schemaVersion: 1, title: "T", slug: "t", provenance: {}, render: { width: 1280, height: 720, fps: 30 }, timeline: [{ type: "post", id: "p2", post: "c/2", platform: "x", author: "Pub", handle: "pub", date: "2026-01-01T00:00:00Z", text: "@realguy is lying", url: "https://x.com/pub/status/2", narration: { takes: [{ file: "narration/posts/2/take-1.recorded.wav", engine: "recorded", seconds: 2, script, at: "2026-01-01T00:00:00Z" }], pick: 0 }, }], }); async function project(name, whole, chars = CHARS) { const dir = path.join(TMP, name); await mkdir(path.join(dir, "narration/posts/2"), { recursive: true }); if (chars) await writeFile(path.join(dir, "narration/characters.json"), JSON.stringify(chars)); await writeFile(path.join(dir, "narration/posts/2/take-1.recorded.wav"), "x"); await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify(whole)); return dir; } const seam = async (dir, whole) => { const anonymity = await projectAnonymousSet(dir, whole); const cut = selectVariant(whole, "sourced"); const drawn = anonymiseManifest(cut, anonymity.doc, { set: anonymity.set }); return { drawn, lint: enforcedLint(drawn, { manifestDir: dir, whole, only: null, validators: false }, { cut, anonymity }) }; }; test("probe18: a RECORDED picked read saying an anonymous handle is an ERROR of the build's enforced lint, in umtool lint's words", async () => { const whole = wholeOf("@realguy is lying"); const dir = await project("p18", whole); const { drawn, lint } = await seam(dir, whole); assert.equal(drawn.timeline[0].text, "@Anon_1 is lying", "the card is anonymised -- and the audio would say the handle"); const mine = lint.errors.filter((e) => /Anon 1's handle/.test(e)); assert.equal(mine.length, 1, lint.errors.join("\n")); const file = await lintManifestFile(path.join(dir, "video.manifest.json")); assert.ok(file.errors.includes(mine[0]), "the same error, the same words as umtool lint"); // The display name too. const named = wholeOf("as Real Guy put it"); const d2 = await project("p18-name", named); assert.ok((await seam(d2, named)).lint.errors.some((e) => /Anon 1's display name/.test(e))); }); test("with no anonymous character the enforced lint is lintManifest's, unchanged", async () => { const whole = wholeOf("@realguy is lying"); const dir = await project("plain", whole, null); const { drawn, lint } = await seam(dir, whole); assert.deepEqual(lint, lintManifest(drawn, { manifestDir: dir, whole, only: null, validators: false })); }); test("a take's render refuses it: renderArgv never passes --no-lint, and the build stops on the error", async () => { const argv = renderArgv({ manifestPath: "/p/.take-t1.render.json", outDir: "/p/takes/t1/out", full: false, xfade: false, queueLock: null, estimateMb: 0 }); assert.ok(!argv.includes("--no-lint"), argv.join(" ")); const whole = wholeOf("@realguy is lying"); const dir = await project("take", whole); const renderManifest = path.join(dir, ".take-t1.render.json"); await writeFile(renderManifest, JSON.stringify(whole)); await assert.rejects(buildVideo({ manifestPath: renderManifest, opts: { noNetwork: true, skipFetch: true } }), /lint: .*Anon 1's handle/); }); test("should-fix a: a video with anonymous characters whose video.manifest.json is missing or unreadable is refused", async () => { const dir = path.join(TMP, "nomanifest"); await mkdir(path.join(dir, "narration"), { recursive: true }); await writeFile(path.join(dir, "narration/characters.json"), JSON.stringify(CHARS)); await assert.rejects(projectAnonymousSet(dir, { timeline: [] }), /anonymous characters.*not read: there is none/); await writeFile(path.join(dir, "video.manifest.json"), "{ broken"); await assert.rejects(projectAnonymousSet(dir, { timeline: [] }), /cannot be read/); // No anonymous character: no manifest is no manifest. const d2 = path.join(TMP, "nomanifest-plain"); await mkdir(d2, { recursive: true }); assert.equal((await projectAnonymousSet(d2, { timeline: [] })).set.size, 0); });