Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 2833752c7e21ae5ff97ab4ea8a20dfef444a4101
parent a8ff102ed0be7f58a272fbba0e7e31981a65e257
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 12 Nov 2026 13:12:46 -0500

umtool, common: the build ENFORCES the anonymity lint (round 3) -- build-video.mjs enforcedLint, the seam the build and every take's render go through, carries post-anon.mjs anonymityProblems' errors (judged on the cut as written, with the project's set; the same words as umtool lint; --no-lint the only override; with no anonymous character lintManifest's result unchanged); projectAnonymousSet refuses a video with anonymous characters whose video.manifest.json is missing or unreadable; readAnonymous hands a read the whole set (its postIds: a spoken status link of an anonymous author's post is collapsed); a --post-take part's words are its source take's `said`; the editor's cast-assign scrub also covers display names, bare handles (the spoken rewrite's rule), /status and /i/web/status links of their posts and percent-encoded handles. Probe18 is a test at the enforced-lint seam and through a take's render manifest

Co-Authored-By: Claude <noreply@anthropic.com>

Diffstat:
Mcommon/lib/report/draft/tasks/castAssign.test.ts | 4++++
Mcommon/lib/report/draft/tasks/castAssign.ts | 86+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
Meditor/CHANGELOG.md | 1+
Mumtool/docs/knobs.md | 3++-
Mumtool/lib/report/anonRead.test.mjs | 11++++++++++-
Mumtool/lib/report/postRedaction.mjs | 3++-
Mumtool/lib/report/postThreadRead.mjs | 3++-
Aumtool/report-to-video/anon-buildlint.test.mjs | 88+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/build-video.mjs | 19++++++++++++++++---
Mumtool/report-to-video/project-characters-file.mjs | 12+++++++++++-
10 files changed, 214 insertions(+), 16 deletions(-)

diff --git a/common/lib/report/draft/tasks/castAssign.test.ts b/common/lib/report/draft/tasks/castAssign.test.ts @@ -157,6 +157,10 @@ test("the answers are written inside the project only: a narration symlink, a sy test("re-check d: an anonymous author's handle in anyone's words never reaches a model -- @mentions and their URLs", async () => { const anon = new Map([["realguy", "Anon 1"]]); assert.equal(scrubAnonymous("@realguy is lying, see https://x.com/RealGuy/status/1 and x.com/public", anon), "@Anon_1 is lying, see x.com/… and x.com/public"); + // Round 3: a display name, a bare handle, an /i/web/status link of one of their posts, a percent-encoded handle. + const extras = { names: new Map([["Real Guy", "Anon 1"]]), postIds: new Set(["1850000000000000000"]) }; + assert.equal(scrubAnonymous("Real Guy said, realguy agrees: https://x.com/i/web/status/1850000000000000000 https://x.com/%72ealguy", anon, extras), "Anon 1 said, Anon 1 agrees: x.com/… x.com/…"); + assert.equal(scrubAnonymous("the news https://example.com/a", new Map([["news", "Anon N"]])), "the news https://example.com/a", "a common word is never matched bare"); const dir = await project("scrub"); const m = JSON.parse(await readFile(path.join(dir, "video.manifest.json"), "utf8")); m.timeline[0].text = "@realguy is lying"; diff --git a/common/lib/report/draft/tasks/castAssign.ts b/common/lib/report/draft/tasks/castAssign.ts @@ -145,21 +145,91 @@ export async function anonymousAuthorsOf(dir: string, manifest: Record<string, u const escRe = (s: string) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); const pseudonym = (shown: string) => shown.replace(/[^A-Za-z0-9_]+/g, "_").replace(/^_+|_+$/g, "").slice(0, 64) || "anon"; +/** Words a handle is never matched bare for (umtool post-anon.mjs bareSayable's rule: 4+ characters, not a common word). */ +const COMMON = new Set(("able about above after again against also always among another answer anything around away back because become been " + + "before being below best better between both bring build call came come could daily dark days dead does done down each early easy even ever " + + "every face fact fair fall family fast feel fine first five follow food free from front full game girl give good great green group grow " + + "half hand happy hard have head hear heart help here high hold home hope hour house idea info into just keep kind king know land last late " + + "learn left less life light like line list little live long look lord love made main make many mark mind more most move much music must " + + "name near need never news next nice night none note nothing only open other over page part past people place plan play point post power " + + "real really right road room said same save says seen self send shop show side sign since some song soon sound start stay still stop " + + "story such sure take talk team tell than that their them then there these they thing think this those time today told took tour town " + + "true truth turn very view wait walk want watch water week well went were what when where which while white whole wild will with word " + + "work world year yes young your guest host stranger friend other someone person people anon user admin official media " + + "daily truth movie music sport sports games radio show channel stream live video clip").split(/\s+/)); +const PLATFORMS = new Set(["x.com", "twitter.com", "nitter.net", "xcancel.com", "fxtwitter.com", "vxtwitter.com", "fixupx.com", "bsky.app", "threads.net", "threads.com", "truthsocial.com", "youtube.com", "instagram.com", "tiktok.com"]); +const decode = (s: string) => { + try { + return decodeURIComponent(s); + } catch { + return s; + } +}; + +/** What scrubAnonymous needs beside the handles: the anonymous authors' display names and the ids of their posts. */ +export type AnonymousExtras = { names?: Map<string, string>; postIds?: Set<string> }; + /** - * An author's words as they may reach a model: an @mention of an anonymous author made the pseudonym ("@Anon_1"), - * a platform URL naming one collapsed to its host -- umtool's post-anon.mjs rule, in one pass. + * An author's words as they may reach a model -- umtool's post-anon.mjs rule, in one pass: a URL of an anonymous + * author's (a platform's account segment, decoded; or `/status/<id>`, `/i/web/status/<id>`, `/post/<id>` of one of + * their posts) collapsed to its host; an @mention made the pseudonym ("@Anon_1"); a bare handle (4+ characters, not a + * common word) and a display name of theirs made the shown name. */ -export function scrubAnonymous(text: string, anon: Map<string, string>): string { +export function scrubAnonymous(text: string, anon: Map<string, string>, extra: AnonymousExtras = {}): string { if (!text || !anon.size) return text; - const hs = [...anon.keys()].sort((a, b) => b.length - a.length).map(escRe).join("|"); - const re = new RegExp(String.raw`(?<![\w.@])@(${hs})(?![A-Za-z0-9_]|\.[A-Za-z0-9])|(?<![\w@.\-/])(?:https?:\/\/)?(?:(?:www|mobile|m)\.)?((?:x|twitter|nitter|xcancel|fxtwitter|vxtwitter|fixupx|truthsocial|youtube|instagram|tiktok)\.(?:com|net)|bsky\.app|threads\.(?:net|com))\/(?:profile\/|@)?(${hs})(?![A-Za-z0-9_]|\.[A-Za-z0-9])[^\s]*`, "giu"); - return text.replace(re, (all, at: string | undefined, host: string | undefined) => (at ? `@${pseudonym(anon.get(at.toLowerCase()) ?? "Anon")}` : host ? `${host.toLowerCase()}/…` : all)); + const hs = [...anon.keys()].sort((a, b) => b.length - a.length).map(escRe); + const bare = hs.filter((h) => h.replace(/\\/g, "").length >= 4 && !COMMON.has(h.replace(/\\/g, ""))); + const names = [...(extra.names ?? new Map()).keys()].filter((n) => n.length >= 3).sort((a, b) => b.length - a.length).map(escRe); + const alts = [String.raw`(?<![\w@.\-/])(?:https?:\/\/)?(?:(?:www|mobile|m)\.)?(?<host>(?:[a-z0-9-]+\.)+[a-z]{2,})(?<path>\/[^\s<>"']*)?`, String.raw`(?<![\w.@])@(?<at>${hs.join("|")})(?![A-Za-z0-9_]|\.[A-Za-z0-9])`]; + if (bare.length) alts.push(String.raw`(?<![\w.@/])(?<bare>${bare.join("|")})(?![\w]|\.[A-Za-z0-9])`); + if (names.length) alts.push(String.raw`(?<![\p{L}\p{N}_])(?<name>${names.join("|")})(?![\p{L}\p{N}_])`); + const re = new RegExp(alts.join("|"), "giu"); + return text.replace(re, (...args) => { + const all = args[0] as string; + const g = args.at(-1) as Record<string, string | undefined>; + if (g.host !== undefined) { + const host = g.host.toLowerCase(); + const path = decode(g.path ?? ""); + const status = path.match(/\/(?:status|statuses|post|posts|video|reel|p)\/([A-Za-z0-9_-]+)/)?.[1]?.toLowerCase(); + const segs = path.split(/[/?#]/).filter(Boolean); + const seg = handleKey(host === "bsky.app" && segs[0]?.toLowerCase() === "profile" ? segs[1] : segs[0]?.replace(/^@/, "")); + const from = handleKey(path.match(/(?:from:|screen_name=)@?([A-Za-z0-9_.-]+)/i)?.[1]); + const theirs = (status && extra.postIds?.has(status)) || (PLATFORMS.has(host) && (anon.has(seg) || anon.has(from))); + return theirs ? `${host}/…` : all; + } + if (g.at) return `@${pseudonym(anon.get(g.at.toLowerCase()) ?? "Anon")}`; + if (g.bare) return anon.get(g.bare.toLowerCase()) ?? all; + if (g.name) { + const hit = [...(extra.names ?? new Map()).entries()].find(([n]) => n.toLowerCase() === g.name!.toLowerCase()); + return hit ? hit[1] : all; + } + return all; + }); +} + +/** The anonymous authors' display names (`name -> shown`) and their posts' ids, from the cut: scrubAnonymous's extras. */ +export function anonymousExtrasOf(manifest: Record<string, unknown>, anon: Map<string, string>): AnonymousExtras { + const names = new Map<string, string>(); + const postIds = new Set<string>(); + const status = (u: unknown) => (typeof u === "string" ? u.match(/\/(?:status|statuses|post|posts|video|reel|p)\/([A-Za-z0-9_-]+)/)?.[1] ?? "" : ""); + for (const e of (Array.isArray(manifest.timeline) ? manifest.timeline : []) as Record<string, unknown>[]) { + if (e?.type !== "post") continue; + const who = [e, ...((Array.isArray(e.parents) ? e.parents : []) as Record<string, unknown>[]), ...((Array.isArray(e.links) ? e.links : []) as Record<string, unknown>[]), e.quoted as Record<string, unknown>].filter((w) => w && typeof w === "object"); + for (const w of who) { + const shown = anon.get(handleKey(w.handle)); + if (!shown) continue; + if (typeof w.author === "string" && w.author.trim().length >= 3 && w.author.trim().toLowerCase() !== shown.toLowerCase()) names.set(w.author.trim(), shown); + for (const v of [w === e ? String(e.post ?? "").split("/").pop() : "", typeof w.id === "string" ? w.id : "", status(w.url)]) if (v && v.length >= 4) postIds.add(v.toLowerCase()); + } + } + return { names, postIds }; } /** The authors to ask about, from the cut's post items: each one's display name, bio (when captured) and words. */ export function castAuthors(manifest: Record<string, unknown>, handles?: string[], { except = new Map<string, string>() }: { except?: Map<string, string> } = {}): CastAuthor[] { const want = handles?.length ? new Set(handles.map(handleKey)) : null; const out = new Map<string, CastAuthor>(); + const extras = anonymousExtrasOf(manifest, except); for (const e of (Array.isArray(manifest.timeline) ? manifest.timeline : []) as Post[]) { if (e?.type !== "post") continue; const h = handleKey(e.handle); @@ -167,8 +237,8 @@ export function castAuthors(manifest: Record<string, unknown>, handles?: string[ const a = out.get(h) ?? { handle: h, name: "", bio: "", posts: [] }; if (!a.name) a.name = plainLine(e.author, NAME_MAX); // An anonymous author's handle in anyone's words never reaches a model (scrubAnonymous). - if (!a.bio) a.bio = plainLine(scrubAnonymous([e.pronouns, e.bio].filter((x) => typeof x === "string").join(" "), except), 300); - const text = plainLine(scrubAnonymous(typeof e.text === "string" ? e.text : "", except), 400); + if (!a.bio) a.bio = plainLine(scrubAnonymous([e.pronouns, e.bio].filter((x) => typeof x === "string").join(" "), except, extras), 300); + const text = plainLine(scrubAnonymous(typeof e.text === "string" ? e.text : "", except, extras), 400); if (text && a.posts.length < 3) a.posts.push(text); out.set(h, a); } diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## [Unreleased] +- **umtool: a build and a take refuse a picked read that says an anonymous author's handle or name.** `umtool lint` reported it, but the lint a build enforces (and so every take's render) did not, so a recorded "@realguy is lying" rendered with the card anonymised and the audio saying the handle. The enforced lint now carries the same error in the same words; `--no-lint` is still the only override, and a video with no anonymous character lints exactly as before. Also: a video with anonymous characters whose `video.manifest.json` is missing or unreadable is refused rather than read with an empty set; a read collapses a status link to an anonymous author's post; a `--post-take` part takes its words from what the source take said; and the words sent to a model lose an anonymous author's display name, bare handle, `/i/web/status/` links and percent-encoded handles too. - **umtool: anonymity covers the whole project, every link, the podcast and the previews; old reads keep their speed.** Re-checking the anonymous characters found several gaps. An item that named one in another variant, or one dropped by a ruling, `--only`, a window or a take, left the author in clear. The deck's corner QR on an anonymous author's post item still led to the real post. Links were rewritten with the status id kept. The podcast's show notes and the chrome preview, still and onscreen routes had no pass at all. Now: - The set is built from the whole project manifest (and a take's), and the build, the chrome composer, the podcast, Play, Present and the previews all take it from one function. - An anonymous author's item draws no QR and no cite or archive link. diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -1541,9 +1541,10 @@ characters are never shown alike (refused); one with no `shown` gets a distinct | YouTube / social drafts (the editor's media tasks) | **not affected**: they read clips and the report, never the post items' authors | | a SYNTHESIZED read (a single take, a thread read's parts; the bench's Re-take) | **covered**: the @handle -- and the bare handle, when 4+ characters and not a common word -- said as the shown name; a single take keeps what it SAID (`said`) when that differs from its script | | a short or common-word handle said bare | **warned** (lint): said as written | -| a recorded take, or one made before, that says a handle or the display name | **refused**: a lint ERROR on the picked read, judged on what it SAID (`said`, else its script; a thread's parts) -- a take refuses it: read or record it again | +| a recorded take, or one made before, that says a handle or the display name | **refused**: an ERROR on the picked read, judged on what it SAID (`said`, else its script; a thread's parts) -- in `umtool lint` and in the lint every build and every take's render ENFORCES (build-video.mjs `enforcedLint`; `--no-lint` the only override): read or record it again | | a shown name (or its pseudonym) that is a real author's handle or name, or another character's handle | **refused** (the writer, the build, Play) | | `characters.json` unreadable, or refused | **refused**: the build, Play's card and a read | +| `video.manifest.json` missing or unreadable while the video has an anonymous character | **refused** (projectAnonymousSet: the whole manifest is what says who they cover) | | a display name written out inside post words | **warned** (lint): not rewritten -- edit the words or redact the name | | names or handles inside attachments (pictures, receipts, a screenshot's own reply line) | **not covered**: yours to check (lint says so) | | `umtool export --format chapters` | **not covered**: it reads the manifest as written | diff --git a/umtool/lib/report/anonRead.test.mjs b/umtool/lib/report/anonRead.test.mjs @@ -43,7 +43,8 @@ const manifest = async () => JSON.parse(await readFile(path.join(DIR, "video.man test("a synthesized read says the shown name: a single take and a thread read's parts; the take records the handles", async () => { const red = await projectRedaction(DIR, await manifest()); - assert.deepEqual(red.anon, { realguy: "Anon 1" }); + assert.deepEqual(Object.fromEntries(red.anon), { realguy: "Anon 1" }); + assert.ok(red.anon.postIds instanceof Set, "the whole set: its post ids too"); const asked = []; const m = await manifest(); const t = await makeTake(project, m.timeline[0], { render: m.render, ask: stubAsk(asked), redaction: red }); @@ -126,3 +127,11 @@ test("must-fix 6 (ii): every take maker records where its speed came from -- the assert.equal((await makeTake(project, e, { render: m.render, speed: 1.3, ask: stubAsk(asked), redaction: null })).take.speedAsked, true); assert.equal((await makeTake(project, { ...e, narration: { ...e.narration, speed: 1.1 } }, { render: m.render, ask: stubAsk(asked), redaction: null })).take.speedAsked, "item"); }); + +test("round 3 c: a --post-take part's words are what its source take SAID", async () => { + const { threadReadPlan, postTakeOf } = await import("./postThreadRead.mjs"); + const src = { file: "narration/posts/x/take-1.kokoro.wav", engine: "kokoro", voice: "am_michael", seconds: 2, script: "Thanks @RealGuy.", said: "Thanks Anon 1." }; + const e = post("p-9", "host", "Host", { narration: { script: "Thanks @RealGuy.", takes: [src], pick: 0 } }); + const plan = threadReadPlan(manifestOf([e]), e, { map: {}, cast: {}, postTake: postTakeOf(e, 1) }); + assert.equal(plan.pieces.find((p) => p.role === "post").text, "Thanks Anon 1."); +}); diff --git a/umtool/lib/report/postRedaction.mjs b/umtool/lib/report/postRedaction.mjs @@ -31,5 +31,6 @@ export async function readAnonymous(dir, manifest) { const read = await readProjectCharacters(dir); if (read.error) throw new Error(`this video's characters are not read (${read.error}): an anonymous author's handle could be said aloud -- fix narration/characters.json first`); const set = anonymousHandles(read.doc, manifest); - return set.size ? Object.fromEntries(set) : null; + // The set itself: its `postIds` too, so a status URL of an anonymous author's post is collapsed in a read. + return set.size ? set : null; } diff --git a/umtool/lib/report/postThreadRead.mjs b/umtool/lib/report/postThreadRead.mjs @@ -228,7 +228,8 @@ export function threadReadPlan(manifest, e, { red = null, map = {}, cast = {}, i if (postTake) { const at = pieces.findIndex((p) => p.role === "post"); const t = postTake.take; - const words = norm(t.script) || pieces[at].text; + // Its words as the take SAID them (`said`: a synthesized take that said an anonymous handle as the shown name), else its script. + const words = norm(t.said) || norm(t.script) || pieces[at].text; pieces[at] = { role: "post", handle: pieces[at].handle, date: pieces[at].date, voice: takeVoiceOf(t), from: "take", written: words, text: words, lexicon: [], slurs: t.slurs ?? null, take: { n: postTake.n, id: takeIdOf(t), file: t.file, ...(t.engine ? { engine: t.engine } : {}) }, diff --git a/umtool/report-to-video/anon-buildlint.test.mjs b/umtool/report-to-video/anon-buildlint.test.mjs @@ -0,0 +1,88 @@ +// 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); +}); diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs @@ -252,7 +252,7 @@ function postJoinFrom(timeline, id, render, groups, depth = 0) { import { readPostRedaction } from "./post-redact-files.mjs"; import { dropMarks, redactEntry } from "./post-redact.mjs"; import { avatarUrls } from "./post-avatars.mjs"; -import { anonymiseManifest } from "./post-anon.mjs"; +import { anonymiseManifest, anonymityProblems } from "./post-anon.mjs"; import { projectAnonymousSet, readProjectCharactersFor } from "./project-characters-file.mjs"; export { readProjectCharactersFor }; @@ -6592,6 +6592,19 @@ export async function prepareLocalMedia(timeline, manifestDir, render = {}) { if (errors.length) throw new Error(`manifest: ${errors.join("; ")}`); } +/** + * THE LINT A BUILD ENFORCES (a take's render is this build): lint.mjs lintManifest over what is drawn, and the + * ANONYMITY errors `umtool lint` reports (post-anon.mjs anonymityProblems: a picked read that says an anonymous + * author's handle or display name), judged on the cut as written (`cut`: before the pass) with the project's set. + * With no anonymous handle, lintManifest's result as it was. `--no-lint` is the only override. + */ +export function enforcedLint(manifest, lintOpts, { cut, anonymity }) { + const base = lintManifest(manifest, lintOpts); + if (!anonymity?.set?.size) return base; + const anon = anonymityProblems(cut, anonymity.doc, { set: anonymity.set }); + return anon.errors.length ? { ...base, errors: [...base.errors, ...anon.errors] } : base; +} + export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly } = {}) { const variant = opts.variant ?? "sourced"; // A vertical short (`--short <id>`, release 36 lane C) is that one clip, @@ -6705,11 +6718,11 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly // narration has a review, unless --narration-unreviewed. const lint = opts.noLint || basic ? { errors: [], warnings: [] } - : lintManifest(manifest, { + : enforcedLint(manifest, { manifestDir, whole, only: only ?? null, validators: false, draftsReview: await readDraftsReview(manifestDir), narrationUnreviewed: opts.narrationUnreviewed === true, final: opts.final === true, draftsUnreviewed: opts.draftsUnreviewed === true, - }); + }, { cut: selectVariant(ruled.manifest, variant), anonymity }); // Where each post's QR goes: its page on the archive (`posts.links` // "archive", the default), which needs the archive channel that keeps it. diff --git a/umtool/report-to-video/project-characters-file.mjs b/umtool/report-to-video/project-characters-file.mjs @@ -46,6 +46,16 @@ export async function readProjectCharactersFor(manifestDir) { export async function projectAnonymousSet(manifestDir, whole = null) { const { anonymousHandles } = await import("./post-anon.mjs"); const doc = await readProjectCharactersFor(manifestDir); - const project = await readFile(path.join(manifestDir, "video.manifest.json"), "utf8").then(JSON.parse, () => null); + const file = path.join(manifestDir, "video.manifest.json"); + let project = null; + let why = null; + try { + project = JSON.parse(await readFile(file, "utf8")); + } catch (e) { + why = e?.code === "ENOENT" ? "there is none" : `it cannot be read (${e instanceof Error ? e.message : e})`; + } + // With an anonymous character in the video, the whole manifest is what says who it covers: without it, refused. + const anonymous = (Array.isArray(doc?.characters) ? doc.characters : []).some((c) => c?.anonymous === true); + if (why && anonymous) throw new Error(`this video has anonymous characters, but its video.manifest.json -- the whole cut, which says who they cover -- is not read: ${why}`); return { doc, set: anonymousHandles(doc, ...[project, whole].filter(Boolean)) }; }