Archilyzer · Source

archilyzer

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

commit ed72655a62afbc65b65e46bf299e571eaa4d530e
parent 4228ac4b296776fd48148e5bac427be95d68b9cc
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 12 Nov 2026 18:28:28 -0500

umtool screens, review 2: the build refuses a stale or shape-saying screen read, judged on the cut as written

Must-fixes (each pinned by a test made failing first: report-to-video/post-screens-review2.test.mjs,
lib/report/postScreens.test.mjs):
1 Staleness is judged on the cut AS WRITTEN: build-video.mjs enforcedLint now carries
  post-thread.mjs validateScreenReads(cut) -- before this the build ran no screen guard at
  all -- and the anonymity pass rewrites a take's stored line/speaker as it rewrites the
  lines, so the drawn copy is self-consistent. Pinned at the enforced-lint seam and
  through a take's render manifest.
2 A line take must say its line word for word (one short plain word more, one fewer),
  with no shape, @handle, anonymous handle or redacted term (postThreadRead.mjs
  saysLine); every screen part that SAYS a shape is refused by the enforced lint.
3 Dates only when plausible (a 3-2-4 group never is); a decimal touching a run's
  separator or a digit is part of the run (post-screens.mjs shapeSpans).
Should-fixes: a part stores its speaker (a who-only edit is refused); cvv, cvc, security
code, exp, dob/born/birthday; digits split across two lines are a lint warning;
normalizeParts keeps line and speaker; screenDrawErrors in the enforced lint.

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

Diffstat:
Mumtool/docs/report-video.md | 23++++++++++++++---------
Mumtool/lib/report/postNarrationCli.mjs | 3+++
Mumtool/lib/report/postScreens.test.mjs | 26+++++++++++++++++++++++++-
Mumtool/lib/report/postThreadRead.mjs | 41+++++++++++++++++++++++++----------------
Mumtool/report-to-video/build-video.mjs | 10+++++++++-
Mumtool/report-to-video/post-anon.mjs | 12++++++++++++
Mumtool/report-to-video/post-narration.mjs | 3++-
Mumtool/report-to-video/post-screens-review.test.mjs | 2+-
Aumtool/report-to-video/post-screens-review2.test.mjs | 155+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/post-screens.mjs | 39+++++++++++++++++++++++++++++++--------
Mumtool/report-to-video/post-thread.mjs | 64+++++++++++++++++++++++++++++++++++++++++++++++++++++-----------
11 files changed, 330 insertions(+), 48 deletions(-)

diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -1445,11 +1445,13 @@ The page's own fonts and palette; lines at 30 px of a 1080 frame. **What is never drawn or said.** A line marked `redact: true`; and, marked or not, in a line's words, its speaker, its time and the screen's title: an e-mail address (any script, or spelt out "x at y dot com"), a phone-style run of nine digits or more (a card, a phone, a spaced SSN; dashes, dots, middle dots, slashes, fullwidth digits) or a local number -(555 1234), the value after order / confirmation / tracking / reference / account / card / code ("is", ":", "#", -"ending in" between) or a "#1234", a token of six digits or more -- never an amount ($104.90, 1,000,000), a decimal, a -date (11/02/2026, 2026-11-02) or a time (`shapeSpans`) -- masked with the redaction's bar, dropped from the read; the +(555 1234), the value after order / confirmation / tracking / reference / account / card / code / cvv / exp / date of +birth ("is", ":", "#", "ending in" between) or a "#1234", a token of six digits or more -- never an amount ($104.90, +1,000,000), a free-standing decimal, a PLAUSIBLE date (a 19xx/20xx year with a month and a day, or a month and a day +then a year: 11/02/2026, 2026-11-02; a 3-2-4 group is never one) or a time (`shapeSpans`) -- masked with the redaction's bar, dropped from the read; the lint names the line (never the value). A pasted `who: words` never splits a shape into a speaker ("Order number: 4419" -stays one line). The project's redaction terms and slur filter mark a screen's words and speakers as a post's. +stays one line); two adjacent lines whose digits together make a shape ("4111 1111" / "1111 1111") are a lint +WARNING naming the lines. The project's redaction terms and slur filter mark a screen's words and speakers as a post's. A speaker who is not the post's author is named when the item names them a subject or says `redact: false`, else blurred (the lint says so); an anonymous one is drawn under the shown name and the words' @handles anonymised (post-anon.mjs); a `who` written as an anonymous author's display name is an ERROR. @@ -1457,12 +1459,15 @@ blurred (the lint says so); an anonymous one is drawn under the shown name and t **The guard and the lint.** A part that reads a line the screen does not read (left out, redacted, `read: "none"`) or a screen the item does not carry is REFUSED by the build (`threadReadErrors`), with the fix -- the writer lets the screen change first (the read is re-made from it). So is a part whose line CHANGED since the read (`screenLineChanged`: each -part stores the line it was made from, `parts[k].line`; edited, removed or moved, the old audio never plays under new -lit text); a read whose screens changed while it was being made is not kept; a `--line-take` whose take does not say -its line is refused (the part's words are the take's own, so every check reads what the audio says), and is re-attached -on the next read only while its line says the same. An excerpt no longer in its line as drawn (after the redaction and +part stores the line and the speaker it was made from, `parts[k].line` / `.speaker`; edited, removed, moved or given to +another speaker, the old audio never plays under new lit text), and a part that SAYS a shape. The BUILD's enforced lint +(build-video.mjs enforcedLint: every build and every take's render) refuses them (`validateScreenReads`), judged on the +cut AS WRITTEN -- never the anonymised copy it draws. A read whose screens changed while it was being made is not kept; a +`--line-take` is refused unless its take says its line word for word (one short plain word more and one fewer of slack), +holding no shape, no @handle, no anonymous handle and no redacted term (its part's words are the take's own, so every +check reads what the audio says); it is re-attached on the next read only while its line says the same. An excerpt no longer in its line as drawn (after the redaction and anonymity passes, which rewrite excerpts as they rewrite lines) is never drawn whole: the line is left out and the -segment refused (`screenDrawErrors`). WARNINGS: a transcription not checked; a masked shape; read lines the picked +build refused up front (`screenDrawErrors`, in the enforced lint; again in the segment for the redaction's). WARNINGS: a transcription not checked; a masked shape; read lines the picked take does not read ("make the read"); screens on an item not narrated (not drawn: a screen is drawn and read with the item's read); a speaker blurred by the privacy rule; a screenshot of a post naming an archived one. diff --git a/umtool/lib/report/postNarrationCli.mjs b/umtool/lib/report/postNarrationCli.mjs @@ -235,6 +235,9 @@ export function normalizeParts(raw) { ...(typeof p.voice === "string" && /^[A-Za-z0-9][A-Za-z0-9_.+-]{0,63}$/.test(p.voice) ? { voice: p.voice } : {}), ...(typeof p.engine === "string" && /^(orpheus|kokoro|espeak-ng)$/.test(p.engine) ? { engine: p.engine } : {}), ...(Number.isInteger(p.piece) && p.piece >= 0 ? { piece: p.piece } : {}), + // A screen line's part (post-screens.mjs): the line and the speaker it was made from (the stale-read guard's). + ...(typeof p.line === "string" ? { line: p.line } : {}), + ...(typeof p.speaker === "string" ? { speaker: p.speaker } : {}), })); } diff --git a/umtool/lib/report/postScreens.test.mjs b/umtool/lib/report/postScreens.test.mjs @@ -13,7 +13,8 @@ import { VOICE_A, VOICE_B, syntheticVoice, withSilence } from "yt-dlp-transcript import { postsCommand } from "./postsCli.mjs"; import { applyPairs, defaultLineTakes, defaultPostTake, lineOfText, linesOfText, screenReadOptions } from "./postScreensCli.mjs"; import { withoutLines } from "umtool-report-to-video/post-screens"; -import { characterNames, joinTimes, readParts, threadReadPlan, threadTake } from "./postThreadRead.mjs"; +import { characterNames, joinTimes, readParts, saysLine, threadReadPlan, threadTake } from "./postThreadRead.mjs"; +import { normalizeParts } from "./postNarrationCli.mjs"; import { threadArgsOf } from "./postSay.mjs"; import { threadArgvOf } from "./castProject.mjs"; import { updatePostItem } from "./manifest.mjs"; @@ -258,3 +259,26 @@ test("SHOULD g: an item WITHOUT screens: removing or hiding an attachment is not await updatePostItem(p.dir, "p-2117", { media: { 1: null } }); assert.equal((await read(p)).timeline[0].media.length, 1); }); + +// --------------------------------------------------------------------------- +// REVIEW 2 (12 Nov). +// --------------------------------------------------------------------------- + +test("MUST 2 (q1): a line take must say the line -- at most one word more or less, never a shape, a handle or a redacted term", () => { + const line = "please call me at tonight after work ok"; + assert.equal(saysLine("please call me at 555 201 4477 tonight after work ok", line), false, "the masked number said"); + assert.equal(saysLine("a b c d e f my ssn is 123456789", "a b c d e f"), false, "extra words"); + assert.equal(saysLine("please call me at @secretkid tonight after work ok", line), false, "a handle"); + assert.equal(saysLine("please call me at secretkid tonight after work ok", line), false, "a name-like extra word, with no set given (q1)"); + assert.equal(saysLine("please call me at secretkid tonight after work ok", line, { handles: ["secretkid"] }), false, "an anonymous handle, bare"); + assert.equal(saysLine("please call me at Jenny tonight after work ok", line, { terms: ["Jenny"] }), false, "a redaction term"); + assert.equal(saysLine("please call me at tonight after work, okay", line), true, "one word off (ASR slack)"); + assert.equal(saysLine("please call me tonight after work ok", line), true, "one word fewer"); + assert.equal(saysLine("please call me tonight after ok", line), false, "two fewer"); +}); + +test("SHOULD (re-import): the batch import keeps a part's line and speaker", () => { + const [p] = normalizeParts([{ n: 1, para: 100, text: "x", start: 0, seconds: 1, role: "screen:s1:0", line: "hop on it", speaker: "TheQuartering" }]); + assert.equal(p.line, "hop on it"); + assert.equal(p.speaker, "TheQuartering"); +}); diff --git a/umtool/lib/report/postThreadRead.mjs b/umtool/lib/report/postThreadRead.mjs @@ -63,7 +63,7 @@ import { cardText, parentsOf } from "umtool-report-to-video/post-item"; import { planContext } from "umtool-report-to-video/post-conversation"; import { spokenRead } from "umtool-report-to-video/post-redact"; import { readSpeedOf, resolvePieceVoice } from "umtool-report-to-video/post-say"; -import { SCREEN_LINE_GAP, parseScreenRole, screenWho } from "umtool-report-to-video/post-screens"; +import { SCREEN_LINE_GAP, parseScreenRole, screenWho, shapeSpans } from "umtool-report-to-video/post-screens"; import { readManifest } from "../projects/report.mjs"; import { withEditNotes } from "./edit-guard.mjs"; import { manifestToken, updatePostNarration } from "./manifest.mjs"; @@ -234,16 +234,17 @@ export function threadReadPlan(manifest, e, { red = null, map = {}, cast = {}, i // (`said`, else its script -- as --post-take's are), so every check that reads a read's words reads the audio's. // A take that does not say the line is REFUSED, never played as it. const words = norm(lt.take.said) || norm(lt.take.script); - if (!saysLine(words, said.text)) { + const anonHandles = red?.anon instanceof Map ? [...red.anon.keys()] : Object.keys(red?.anon ?? {}).filter((x) => x !== "postIds"); + if (!saysLine(words, said.text, { handles: anonHandles, terms: (red?.terms ?? []).map((x) => (typeof x === "string" ? x : x?.term)).filter(Boolean) })) { const sp = /^screen:([a-z0-9-]+):(\d+)$/.exec(p.role); throw new ThreadReadError(`--line-take ${p.role}=${lt.n}: its take does not say line ${sp[2]} of screen ${sp[1]} (its words are another line's, or the line changed) -- record that line, or name the take that reads it`); } - pieces.push({ role: p.role, handle, who: p.who, date: null, voice: takeVoiceOf(lt.take), from: "take", written, line: written, text: words, lexicon: [], slurs: lt.take.slurs ?? null, take: { n: lt.n, id: takeIdOf(lt.take), file: lt.take.file, ...(lt.take.engine ? { engine: lt.take.engine } : {}) } }); + pieces.push({ role: p.role, handle, who: p.who, speaker: str(p.who), date: null, voice: takeVoiceOf(lt.take), from: "take", written, line: written, text: words, lexicon: [], slurs: lt.take.slurs ?? null, take: { n: lt.n, id: takeIdOf(lt.take), file: lt.take.file, ...(lt.take.engine ? { engine: lt.take.engine } : {}) } }); continue; } const v = resolvePieceVoice({ handle, role: sw.self ? "post" : p.role }, { map, cast, item, overrides, self: str(e.handle), voice: null, narrator, engine: eng }); const spd = readSpeedOf({ flag: speed, preset: v.speed ?? null, own: sw.self ? e.narration?.speed ?? null : null, engine: v.engine }); - pieces.push({ role: p.role, handle, who: p.who, date: null, line: written, voice: v.voice, engine: v.engine, from: v.from, ...(spd !== null ? { speed: spd } : {}), ...(v.character ? { character: v.character } : {}), written, text: said.text.trim(), lexicon: said.lexicon ?? [], slurs: said.slurs, ...(said.anonymised ? { anonymised: said.anonymised } : {}) }); + pieces.push({ role: p.role, handle, who: p.who, speaker: str(p.who), date: null, line: written, voice: v.voice, engine: v.engine, from: v.from, ...(spd !== null ? { speed: spd } : {}), ...(v.character ? { character: v.character } : {}), written, text: said.text.trim(), lexicon: said.lexicon ?? [], slurs: said.slurs, ...(said.anonymised ? { anonymised: said.anonymised } : {}) }); continue; } const written = p.role === "post" ? own || script || "" : draftScript(p.text).script; @@ -307,22 +308,30 @@ export function characterNames(L) { } /** - * Whether a take's words SAY a line, pure: the line's words and the take's agree (normalized words, in either order of - * the two) on at least 60 % of the longer -- a take of another line, of the post, or of an older line does not. + * Whether a take's words SAY a line, pure: word for word (normalized), with at most ONE word more (a short plain + * word: at most five lower-case letters) and one word fewer (a recording's or a transcript's slack) -- and the take holds no shape (an e-mail, a number: shapeSpans), no @handle, + * no anonymous handle (`handles`) and no redacted term (`terms`) anywhere in what it says. A take of another line, of + * the post, of an older line, or one that says what the card masks, does not. */ -export function saysLine(takeWords, lineWords) { - const keys = (t) => str(t).toLowerCase().split(/\s+/).map((w) => w.replace(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, "")).filter(Boolean); +export function saysLine(takeWords, lineWords, { handles = [], terms = [] } = {}) { + if (shapeSpans(str(takeWords)).length) return false; + const keys = (t) => str(t).toLowerCase().split(/\s+/).map((w) => w.replace(/^[^\p{L}\p{N}@]+|[^\p{L}\p{N}]+$/gu, "")).filter(Boolean); const a = keys(takeWords); const b = keys(lineWords); if (!a.length || !b.length) return false; + const banned = new Set(handles.map((h) => String(h).replace(/^@+/, "").toLowerCase())); + const termRes = terms.map((t) => new RegExp(`(?<![\\p{L}\\p{N}])${String(t).replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\p{L}\\p{N}])`, "iu")); + if (a.some((w) => w.startsWith("@") || banned.has(w)) || termRes.some((re) => re.test(str(takeWords)))) return false; const pool = new Map(); - for (const w of a) pool.set(w, (pool.get(w) ?? 0) + 1); - let common = 0; - for (const w of b) if ((pool.get(w) ?? 0) > 0) { - common += 1; - pool.set(w, pool.get(w) - 1); + for (const w of b) pool.set(w, (pool.get(w) ?? 0) + 1); + const extras = []; + for (const w of a) { + if ((pool.get(w) ?? 0) > 0) pool.set(w, pool.get(w) - 1); + else extras.push(w); } - return common / Math.max(a.length, b.length) >= 0.6; + const missing = [...pool.values()].reduce((x, y) => x + y, 0); + // The one word of slack is a SHORT plain word ("okay" for "ok", "uh"): never a name, a handle or a number. + return extras.length <= 1 && extras.every((w) => /^\p{Ll}{1,5}$/u.test(w)) && missing <= 1; } /** A take's voice as a thread read's label says it: its voice (or recorded label) without an engine ("am_michael", "operator"). */ @@ -350,7 +359,7 @@ export function postTakeOf(e, n) { export function readParts(plan) { return plan.pieces.flatMap((pc, piece) => { // A screen line's parts carry the line they were made from (`line`): the guard holds the read to the line as it is. - const line = typeof pc.line === "string" ? { line: pc.line } : {}; + const line = typeof pc.line === "string" ? { line: pc.line, speaker: str(pc.speaker) } : {}; if (pc.take) return [{ piece, para: 0, role: pc.role, voice: pc.voice, text: pc.text, file: pc.take.file, take: pc.take.id, key: null, ...line }]; const eng = pc.engine ?? plan.engine; return scriptParts(pc.text).map((q) => ({ piece, para: q.para, role: pc.role, voice: pc.voice, engine: eng, ...(pc.speed !== undefined ? { speed: pc.speed } : {}), text: q.text, key: partKey(eng, pc.voice, q.text, pc.speed ?? null), ...line })); @@ -375,7 +384,7 @@ export function joinTimes(parts, seconds, { fileOf = (p) => (p.take ? p.file : ` t += gap; const s = Number(seconds[i]); // A part from a take (--post-take) says which (`take`: its id); a synthesized one its parts-cache file and voice. - const row = { n: i + 1, para: p.piece * 100 + p.para, text: p.text, ...(typeof p.line === "string" ? { line: p.line } : {}), voice: p.voice, ...(p.engine ? { engine: p.engine } : {}), ...(typeof p.speed === "number" ? { speed: p.speed } : {}), role: p.role, piece: p.piece, file: fileOf(p), ...(p.take ? { take: p.take } : {}), start: r3(t), seconds: r3(s), gapBefore: gap }; + const row = { n: i + 1, para: p.piece * 100 + p.para, text: p.text, ...(typeof p.line === "string" ? { line: p.line, speaker: str(p.speaker) } : {}), voice: p.voice, ...(p.engine ? { engine: p.engine } : {}), ...(typeof p.speed === "number" ? { speed: p.speed } : {}), role: p.role, piece: p.piece, file: fileOf(p), ...(p.take ? { take: p.take } : {}), start: r3(t), seconds: r3(s), gapBefore: gap }; t += s; return row; }); diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs @@ -869,6 +869,8 @@ export { tightestContaining, windowContains, windowsFromNames, } from "./sources.mjs"; import { tmpPathFor } from "yt-dlp-transcript-common/lib/atomicFile.mjs"; +import { validateScreenReads } from "./post-thread.mjs"; +import { screenDrawErrors } from "./post-screens.mjs"; // The yt-dlp argv for one clip window. The platform's fixed args come from // common's table (`platformArgsForUrl`) -- the same copy every editor spawn @@ -6599,7 +6601,13 @@ export async function prepareLocalMedia(timeline, manifestDir, render = {}) { * 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); + const base0 = lintManifest(manifest, lintOpts); + // ITS SCREENS (post-screens.mjs, post-thread.mjs): a screen part whose line changed since the read, that the screen does + // not read, or that SAYS a shape -- judged on the cut AS WRITTEN (the anonymised copy rewrites the lines it draws) -- + // and an excerpt that is not in its line as drawn. A cut with no screens: lintManifest's as it was. + const mine = (m) => (lintOpts?.only ? { ...m, timeline: (m?.timeline ?? []).filter((e) => e?.id === lintOpts.only) } : m); + const screenErr = [...validateScreenReads(mine(cut ?? manifest)), ...(mine(manifest)?.timeline ?? []).flatMap((e) => (e?.type === "post" && Array.isArray(e.screens) ? screenDrawErrors(e) : []))]; + const base = screenErr.length ? { ...base0, errors: [...base0.errors, ...screenErr] } : base0; 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; diff --git a/umtool/report-to-video/post-anon.mjs b/umtool/report-to-video/post-anon.mjs @@ -341,6 +341,18 @@ export function anonymiseEntry(e0, set) { return { ...sc, lines, ...(title !== undefined ? { title } : {}), ...(readChanged ? { read } : {}) }; }); if (changed) edit().screens = screens; + // Its takes' screen parts record the line and the speaker they were made from: rewritten as the lines are, so the + // drawn copy is judged against itself (the build judges staleness on the cut as written: post-thread.mjs). + const takes = Array.isArray(e.narration?.takes) ? e.narration.takes : null; + if (takes?.some((t) => Array.isArray(t?.parts) && t.parts.some((pt) => isObj(pt) && (typeof pt.line === "string" || typeof pt.speaker === "string")))) { + const next = takes.map((t) => (Array.isArray(t?.parts) ? { ...t, parts: t.parts.map((pt) => { + if (!isObj(pt) || (typeof pt.line !== "string" && typeof pt.speaker !== "string")) return pt; + const sp = typeof pt.speaker === "string" ? of(pt.speaker) ?? anonymiseWords(pt.speaker, set) : undefined; + return { ...pt, ...(typeof pt.line === "string" ? { line: anonymiseWords(pt.line, set) } : {}), ...(sp !== undefined ? { speaker: sp } : {}) }; + }) } : t)); + const o = edit(); + o.narration = { ...e.narration, takes: next }; + } } // The words the card draws. const w = withWords(out ?? e, set); diff --git a/umtool/report-to-video/post-narration.mjs b/umtool/report-to-video/post-narration.mjs @@ -202,7 +202,7 @@ const STEP_KEYS = new Set(["op", "engine", "voice", "pitch", "semitones", "param // `tempo`: the part's reading speed in the take's file against its first read (a `tempo` step's; absent: 1). // `speed`: the speed the part was synthesized at (its character's preset's, or the read's --speed; absent: 1). // `take`: a thread read's part that IS one of the item's takes (postThreadRead.mjs --post-take): that take's id. -const PART_KEYS = new Set(["n", "para", "text", "file", "start", "seconds", "gapBefore", "note", "at", "jobId", "role", "voice", "engine", "piece", "tempo", "speed", "take", "line"]); +const PART_KEYS = new Set(["n", "para", "text", "file", "start", "seconds", "gapBefore", "note", "at", "jobId", "role", "voice", "engine", "piece", "tempo", "speed", "take", "line", "speaker"]); const VOICE_RE = /^[A-Za-z0-9][A-Za-z0-9_.+-]{0,63}$/; /** Orpheus's expressive tags (narration.mjs NARRATION_TAGS, the editor's list). */ const TAGS = ["laugh", "chuckle", "sigh", "cough", "sniffle", "groan", "yawn", "gasp"]; @@ -712,6 +712,7 @@ export function validatePostNarration(e) { if (!(fin(p.seconds) && p.seconds > 0)) errors.push(`${pw}.seconds must be its length`); if (p.text !== undefined && typeof p.text !== "string") errors.push(`${pw}.text must be the words it reads`); if (p.line !== undefined && typeof p.line !== "string") errors.push(`${pw}.line must be the screen line it was made from (its words)`); + if (p.speaker !== undefined && typeof p.speaker !== "string") errors.push(`${pw}.speaker must be the screen line's speaker it was made for`); if (p.speed !== undefined && !numIn(p.speed, POST_NARRATION_LIMITS.speed)) errors.push(`${pw}.speed must be ${POST_NARRATION_LIMITS.speed.join("–")} (the speed it was synthesized at)`); if (p.tempo !== undefined && !numIn(p.tempo, POST_NARRATION_LIMITS.tempo)) errors.push(`${pw}.tempo must be ${POST_NARRATION_LIMITS.tempo.join("–")} (its reading speed in the take)`); if (p.role !== undefined && !(typeof p.role === "string" && /^(post|quoted|parent:\d|media:\d|linked:\d|screen:[a-z0-9][a-z0-9-]{0,23}:\d{1,2})$/.test(p.role))) errors.push(`${pw}.role must be post, quoted, parent:<i>, linked:<i>, media:<i> or screen:<id>:<line> (the text it reads)`); diff --git a/umtool/report-to-video/post-screens-review.test.mjs b/umtool/report-to-video/post-screens-review.test.mjs @@ -110,7 +110,7 @@ test("MUST 3 (p7): `Order number: 4419`, `Ref: AB-1234`, `Tracking: 1Z999AA1`, ` test("MUST 4 (p1, p2): cards, spaced SSNs and local numbers, dash/dot separators, fullwidth digits, `is` after the keyword, non-ASCII e-mail -- all masked", () => { const masked = [ - ["card 4111 1111 1111 1111 exp 12/27", "card ████ ████ ████ ████ exp 12/27"], + ["card 4111 1111 1111 1111 exp 12/27", "card ████ ████ ████ ████ exp █████"] /* exp MM/YY masked since review 2 */, ["Order: 1234 5678 9012 3456 7890", "Order: ████ ████ ████ ████ ████"], ["call 555 – 123 – 4567", "call ███ █ ███ █ ████"], ["call 555 · 123 · 4567", "call ███ █ ███ █ ████"], diff --git a/umtool/report-to-video/post-screens-review2.test.mjs b/umtool/report-to-video/post-screens-review2.test.mjs @@ -0,0 +1,155 @@ +// lane/screen-reads REVIEW 2 (12 Nov): the reviewer's probes q1/q2 as tests. Three blockers -- the staleness guard +// judged on the drawn (anonymised) copy; a line take that says a shape or extra words; dash-written SSNs and phone runs +// split by a decimal -- and five should-fixes. The build's ENFORCED lint (build-video.mjs enforcedLint, the seam the +// build and every take's render go through) is where a read of a screen is refused. Temp dirs only. +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 { anonymiseEntry, anonymiseManifest } from "./post-anon.mjs"; +import { projectAnonymousSet } from "./project-characters-file.mjs"; +import { draftScript } from "./post-narration.mjs"; +import { threadReadErrors, validateScreenReads } from "./post-thread.mjs"; +import { REDACT_MARK } from "./post-redact.mjs"; +import { maskShapes, screenLineSaid, screenWarnings } from "./post-screens.mjs"; + +const TMP = await mkdtemp(path.join(tmpdir(), "umtool-screens-review2-")); +after(() => rm(TMP, { recursive: true, force: true })); +const shown = (t) => maskShapes(t).text.replace(new RegExp(REDACT_MARK, "g"), "█"); +const IMG = { src: "a.jpg", kind: "image", width: 10, height: 10 }; +const mk = (lines, read = "all") => ({ type: "post", id: "p-1", post: "x/1", platform: "x", author: "A", handle: "aa", date: "2026-11-02T01:40:36.000Z", text: "Your turn.", url: "https://x.com/aa/status/1", media: [IMG], screens: [{ id: "s1", media: 0, kind: "dm", read, lines }] }); +/** A thread read of every read line, each part storing the line and the speaker it was made from (as the read does). */ +function take(e) { + const sc = e.screens[0]; + const parts = [{ n: 1, para: 0, text: "Your turn.", role: "post", start: 0, seconds: 1 }]; + sc.lines.forEach((l, n) => { + const s = screenLineSaid(sc, n); + if (s) parts.push({ n: parts.length + 1, para: (n + 1) * 100, text: s, line: draftScript(s).script, speaker: l.who ?? "", role: `screen:s1:${n}`, start: 2 + n * 3, seconds: 2 }); + }); + return { ...e, narration: { script: "Your turn.", pick: 0, takes: [{ file: "narration/posts/1/take-1.orpheus-thread.wav", engine: "orpheus", voice: "x", seconds: 20, script: "x", parts }] } }; +} + +// --------------------------------------------------------------------------- +// MUST 1: staleness is judged on the cut AS WRITTEN; the build's enforced lint refuses a stale read, never a fresh one. +// --------------------------------------------------------------------------- + +const CHARS = { format: "umtool-project-characters", version: 1, characters: [{ id: "anon-1", name: "Real Guy", anonymous: true, shown: "Anon 1", handles: ["secretkid"] }] }; +const wholeOf = (e) => ({ schemaVersion: 1, title: "T", slug: "t", provenance: {}, render: { width: 1280, height: 720, fps: 30 }, timeline: [e] }); +async function project(name, whole) { + const dir = path.join(TMP, name); + await mkdir(path.join(dir, "narration/posts/1"), { recursive: true }); + await writeFile(path.join(dir, "narration/characters.json"), JSON.stringify(CHARS)); + 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 enforcedLint(drawn, { manifestDir: dir, whole, only: null, validators: false }, { cut, anonymity }); +}; + +test("MUST 1 (q1): a line mentioning an anonymous handle -- its fresh read is not refused (as drawn or at the build's seam)", async () => { + // As a synthesized read says it (the shown name), so the anonymity lint is quiet too. + const e = take(mk([{ who: "bob", text: "ask @secretkid about it" }])); + e.narration.takes[0].parts[1].text = "ask Anon 1 about it."; + assert.deepEqual(threadReadErrors(e, {}), []); + assert.deepEqual(threadReadErrors(anonymiseEntry(e, new Map([["secretkid", "Anon 1"]])), {}), [], "the drawn copy is self-consistent too"); + const whole = wholeOf(e); + const lint = await seam(await project("q1", whole), whole); + assert.ok(!lint.errors.some((x) => /screen s1|changed since the read/.test(x)), lint.errors.join("\n")); +}); + +test("MUST 1: the build's enforced lint REFUSES a stale screen read -- at the seam and through a take's render manifest", async () => { + const e = take(mk([{ who: "bob", text: "ask @secretkid about it" }, { who: "aa", text: "will do" }])); + e.narration.takes[0].parts[1].text = "ask Anon 1 about it."; + e.screens[0].lines[1].text = "will NOT do"; + const whole = wholeOf(e); + const dir = await project("stale", whole); + const lint = await seam(dir, whole); + assert.ok(lint.errors.some((x) => /line 1 of screen s1 changed since the read/.test(x)), lint.errors.join("\n")); + 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: .*line 1 of screen s1 changed since the read/); + // The fresh one's render stops on its missing files alone, never on its screen. + const fresh = wholeOf(take(mk([{ who: "bob", text: "ask @secretkid about it" }]))); + fresh.timeline[0].narration.takes[0].parts[1].text = "ask Anon 1 about it."; + const d2 = await project("fresh", fresh); + const rm2 = path.join(d2, ".take-t2.render.json"); + await writeFile(rm2, JSON.stringify(fresh)); + await assert.rejects(buildVideo({ manifestPath: rm2, opts: { noNetwork: true, skipFetch: true } }), (err) => /lint:/.test(err.message) && !/screen s1/.test(err.message)); +}); + +test("SHOULD (who): a speaker-only edit under a read is refused -- the old voice under a new name", () => { + const base = take(mk([{ who: "bob", text: "hello there" }, { who: "aa", text: "see you soon" }])); + assert.deepEqual(threadReadErrors(base, {}), []); + const x = structuredClone(base); + x.screens[0].lines[0].who = "SomeoneElse"; + assert.ok(threadReadErrors(x, {}).some((m) => /line 0 of screen s1 changed since the read/.test(m))); + const y = structuredClone(base); + y.screens[0].lines[1].side = "left"; + assert.deepEqual(threadReadErrors(y, {}), [], "a side is not a word"); + // A part that recorded no speaker (a take made before speakers were recorded, or by hand) is judged by its words + // alone: an unchanged line is not refused for it. + const z = structuredClone(base); + for (const pt of z.narration.takes[0].parts) delete pt.speaker; + assert.deepEqual(threadReadErrors(z, {}), []); +}); + +// --------------------------------------------------------------------------- +// MUST 2: what a screen piece SAYS holds no shape -- refused by the build's enforced lint. +// --------------------------------------------------------------------------- + +test("MUST 2: a screen part that says a shape (a recorded line take saying the number) is refused by validateScreenReads", () => { + const e = take(mk([{ who: "bob", text: "please call me at 555 201 4477 tonight after work ok" }])); + assert.deepEqual(validateScreenReads({ timeline: [e] }), []); + e.narration.takes[0].parts[1].text = "please call me at 555 201 4477 tonight after work ok"; + assert.ok(validateScreenReads({ timeline: [e] }).some((x) => /part 2 \(line 0 of screen s1\) says a long number or a phone number/.test(x))); + assert.ok(!validateScreenReads({ timeline: [e] }).some((x) => /555/.test(x)), "never the value"); +}); + +// --------------------------------------------------------------------------- +// MUST 3 + SHOULD keywords: the shapes. +// --------------------------------------------------------------------------- + +test("MUST 3 (q1): dash- and dot-written SSNs, 3-2-4 groups, a phone run around a decimal -- masked; plausible dates kept", () => { + for (const [t, want] of [ + ["my social is 123-45-6789", "my social is ███████████"], + ["call 555-12-3456", "call ███████████"], + ["1234-56-7890", "████████████"], + ["acct 12/34/5678", "acct ██████████"], + ["SSN: 078.05.1120", "SSN: ███████████"], + ["call 555 201-44.77 now", "call ███ █████████ now"], + ]) assert.equal(shown(t), want, t); + for (const t of ["on 11/02/2026 at 10:42", "weighed 312.4 on 2026-11-02", "lost 41.2 lbs, 312.4 to 271.2", "since 02.11.26", "weights 312.4 310.2 308.0 305.5", "paid $104.90 today"]) assert.equal(shown(t), t, t); +}); + +test("SHOULD (keywords): cvv, cvc, security code, exp MM/YY, a date of birth -- masked", () => { + for (const [t, want] of [ + ["exp 12/27 cvv 123", "exp █████ cvv ███"], + ["cvc 4821", "cvc ████"], + ["security code 991", "security code ███"], + ["DOB 1990-04-12", "DOB ██████████"], + ["my birthday is 4/12/1990", "my birthday is █████████"], + ["born 04/12/1990", "born ██████████"], + ]) assert.equal(shown(t), want, t); +}); + +test("SHOULD (split digits): two adjacent lines whose digits together make a shape -- the lint names the lines", () => { + const e = mk([{ who: "a", text: "my card is 4111 1111" }, { who: "a", text: "1111 1111" }, { who: "a", text: "call 555 201" }, { who: "a", text: "4477 thanks" }, { who: "a", text: "ok" }]); + const w = screenWarnings(e, { narrated: false }); + assert.ok(w.some((x) => /lines 0 and 1 of screen s1 together hold/.test(x)), w.join("\n")); + assert.ok(w.some((x) => /lines 2 and 3 of screen s1 together hold/.test(x)), w.join("\n")); + assert.ok(!w.some((x) => /lines 3 and 4/.test(x))); + assert.ok(!w.some((x) => /4111|555/.test(x))); +}); + +test("SHOULD (draw errors up front): an excerpt not in its line as drawn is refused by the build's enforced lint", async () => { + const e = take(mk([{ who: "bob", text: "Preamble. He said it was fine. Private aside." }], [{ line: 0, text: "said it was fine" }])); + const whole = wholeOf(e); + whole.timeline[0].screens[0].read = [{ line: 0, text: "said it was okay" }]; + const lint = await seam(await project("draw", whole), whole); + assert.ok(lint.errors.some((x) => /line 0 of screen s1: its excerpt is not in the line as drawn/.test(x)), lint.errors.join("\n")); +}); diff --git a/umtool/report-to-video/post-screens.mjs b/umtool/report-to-video/post-screens.mjs @@ -95,12 +95,24 @@ const SPOKEN_EMAIL_RE = /[\p{L}\p{N}._-]+ (?:at) [\p{L}\p{N}-]+ (?:dot) (?:com|n const RUN_RE = /[+(]?\p{Nd}(?:[ \t\-‐‑–—·./()]{0,3}\p{Nd})*/gu; /** A decimal (an amount, a weight: "99.95", "312.4") -- never part of a run. */ const DECIMAL_RE = /\p{Nd}+[.,]\p{Nd}{1,2}(?!\p{Nd})/gu; -/** A date: 11/02/2026, 2026-11-02, 02.11.26 -- shown. */ -const DATE_RE = /^\p{Nd}{1,4}[/.\-‐‑–—]\p{Nd}{1,2}[/.\-‐‑–—]\p{Nd}{1,4}$/u; +/** + * A PLAUSIBLE date -- shown: a year of 19xx / 20xx first with a month and a day after it (2026-11-02), or a month and a + * day (either order) then a two-digit or a 19xx / 20xx year (11/02/2026, 02.11.26). A 3-2-4 group (an SSN) is never one. + */ +const DATE_SHAPE = /^(\p{Nd}{1,4})[/.\-‐‑–—](\p{Nd}{1,2})[/.\-‐‑–—](\p{Nd}{1,4})$/u; +const isDate = (v) => { + const m = DATE_SHAPE.exec(str(v).replace(/\p{Nd}/gu, (d) => String(Number.parseInt(d.normalize("NFKC"), 10)))); + if (!m) return false; + const [a, b, c] = [m[1], m[2], m[3]]; + const year4 = (y) => /^(19|20)\d\d$/.test(y); + const md = (x, y) => (Number(x) >= 1 && Number(x) <= 12 && Number(y) >= 1 && Number(y) <= 31) || (Number(y) >= 1 && Number(y) <= 12 && Number(x) >= 1 && Number(x) <= 31); + if (year4(a)) return Number(b) >= 1 && Number(b) <= 12 && Number(c) >= 1 && Number(c) <= 31 && c.length <= 2; + return a.length <= 2 && b.length <= 2 && (c.length === 2 || year4(c)) && md(a, b); +}; /** Case-insensitive by letters (the `i` flag would make the IBAN's \p{Lu} match any letter). */ const ci = (w) => w.replace(/[a-z]/g, (c) => `[${c}${c.toUpperCase()}]`); -const KEYWORDS = "order|confirmation|conf|invoice|tracking|reference|ref|account|acct|card|iban|ssn|social security|code|pin|passcode|routing|member|customer|ticket|receipt|transaction|policy|booking|reservation|serial|id".split("|").map(ci).join("|"); -const GROUP = String.raw`[#]?[\p{L}\p{N}\-]*\p{Nd}[\p{L}\p{N}\-]*`; +const KEYWORDS = "order|confirmation|conf|invoice|tracking|reference|ref|account|acct|card|iban|ssn|social security|security code|code|pin|passcode|routing|member|customer|ticket|receipt|transaction|policy|booking|reservation|serial|cvv|cvc|exp|expiry|expires|dob|date of birth|born|birthday|id".split("|").map(ci).join("|"); +const GROUP = String.raw`[#]?[\p{L}\p{N}\-/.]*\p{Nd}[\p{L}\p{N}\-/.]*`; /** A keyword, "number" / "no." / "#", "is" / ":" / "ending in", then its value: groups with digits (an IBAN's capitals between them). */ const ORDER_RE = new RegExp(String.raw`(?<![\p{L}\p{N}])(?:${KEYWORDS})(?:\s+(?:${["number", "no", "no.", "num", "id", "code"].map(ci).join("|").replace(/\./g, "\\.")}|#))?(?:\s*(?:${["is", "was", "ending in", "ending"].map(ci).join("|")}|=|:|#))*\s*(${GROUP}(?:[ \t](?:${GROUP}|\p{Lu}{1,4}(?=[ \t]${GROUP})))*)`, "gu"); const HASHNUM_RE = /#\s?[\p{L}\p{N}-]*\p{Nd}{4,}[\p{L}\p{N}-]*/gu; @@ -132,12 +144,13 @@ export function shapeSpans(text) { out.push({ start: m.index, end: m.index + v.length, kind: "email" }); } for (const m of t.matchAll(SPOKEN_EMAIL_RE)) out.push({ start: m.index, end: m.index + m[0].length, kind: "email" }); - // Runs, the decimals blanked first (a list of weights is not a phone number). - const blank = t.replace(DECIMAL_RE, (d) => "x".repeat(d.length)); + // Runs, a free-standing decimal blanked first (a list of weights is not a phone number) -- never one that touches a + // run's separator or another digit ("555 201-44.77", "078.05.1120": those are the run). + const blank = t.replace(DECIMAL_RE, (d, at) => (/[\-‐‑–—·./()\p{Nd}]/u.test(t[at - 1] ?? "") || /[\-‐‑–—·./()\p{Nd}]/u.test(t[at + d.length] ?? "") ? d : "x".repeat(d.length))); for (const m of blank.matchAll(RUN_RE)) { const v = m[0].replace(/[ \t\-‐‑–—·./(]+$/, ""); const n = digitsIn(v); - if (n < 7 || DATE_RE.test(v.replace(/^[+(]/, ""))) continue; + if (n < 7 || isDate(v.replace(/^[+(]/, ""))) continue; const local = n <= 8 && /^\p{Nd}{3}[ \t\-‐‑–—·.]{1,3}\p{Nd}{4}$/u.test(v); if (n >= 9 || local) out.push({ start: m.index, end: m.index + v.length, kind: "number" }); } @@ -154,7 +167,7 @@ export function shapeSpans(text) { const lead = tok.match(/^[("'“[]*/)[0].length; const trail = tok.match(/[)"'”\].,;:!?]*$/)[0].length; const core = tok.slice(lead, tok.length - trail); - if (DATE_RE.test(core) || /^\p{Nd}{1,2}:\p{Nd}{2}(?::\p{Nd}{2})?$/u.test(core)) continue; + if (isDate(core) || /^\p{Nd}{1,2}:\p{Nd}{2}(?::\p{Nd}{2})?$/u.test(core)) continue; out.push({ start: m.index + lead, end: m.index + tok.length - trail, kind: "number" }); } out.sort((a, b) => a.start - b.start || b.end - a.end); @@ -696,6 +709,16 @@ export function screenWarnings(entry, { narrated = false, takeRoles = [], attach if (k2.length) out.push(`${w}: screen ${sc.id} line ${n}'s ${what} holds ${kindWords(k2)} -- masked on the card; write it without (umtool posts screen <p> ${id} set ${sc.id} line.${n}.${f}=…)`); } }); + // DIGITS SPLIT ACROSS TWO LINES ("my card is 4111 1111" / "1111 1111"): a shape only the two together make. + for (let n = 0; n + 1 < sc.lines.length; n += 1) { + const a = sc.lines[n]; + const b = sc.lines[n + 1]; + if (!isObj(a) || !isObj(b) || a.redact === true || b.redact === true) continue; + const ta = str(a.text); + const joined = `${ta} ${str(b.text)}`; + const across = shapeSpans(joined).filter((sp) => sp.start < ta.length && sp.end > ta.length + 1); + if (across.length) out.push(`${w}: lines ${n} and ${n + 1} of screen ${sc.id} together hold ${kindWords([...new Set(across.map((x) => x.kind))])} split across them -- each alone is drawn and said; mark them redact (umtool posts screen <p> ${id} set ${sc.id} line.${n}.redact=on line.${n + 1}.redact=on) or join them`); + } const tk = [...new Set(shapeSpans(str(sc.title)).map((x) => x.kind))]; if (tk.length) out.push(`${w}: screen ${sc.id}'s title holds ${kindWords(tk)} -- masked on the card; write it without (umtool posts screen <p> ${id} set ${sc.id} title=…)`); if (sc.kind === "post" && sc.ref) out.push(`${w}: screen ${sc.id} pictures ${sc.ref} -- drawn from its transcription; umtool posts set-item <p> ${id} link.add=… draws the archived post itself`); diff --git a/umtool/report-to-video/post-thread.mjs b/umtool/report-to-video/post-thread.mjs @@ -55,7 +55,7 @@ import { followKnobs } from "./read-follow.mjs"; import { planContext } from "./post-conversation.mjs"; import { branchMapOf, mapKnobs, mapTimes } from "./post-branch-map.mjs"; import { isPictureOnly, pictureBeatSeconds } from "./post-picture.mjs"; -import { isScreenScope, parseScreenRole, readScreens, screenLineProblem, screenLineSaid, screenOrder, screenPieces, screenReadLines, screenRole, screenScope, screenWarnings, screensOf as screensOfEntry, tileOfRole } from "./post-screens.mjs"; +import { isScreenScope, parseScreenRole, readScreens, screenLineProblem, screenLineSaid, screenOrder, screenPieces, screenReadLines, screenRole, screenScope, screenWarnings, screensOf as screensOfEntry, shapeSpans, tileOfRole } from "./post-screens.mjs"; /** What a context tile may be. */ export const THREAD_MODES = Object.freeze(["auto", "full", "excerpt", "context", "carry", "hidden"]); @@ -545,6 +545,54 @@ function layoutMap(entry, tiles, roles, { prevId, group, knobs }) { return branchMapOf(nodes, { prevId, nowId: now, subject: str(entry?.handle), style: knobs.style, group }); } +/** + * ONE SCREEN PART's errors (part k of the picked take, its role a screen line's), pure: the line the screen does not + * read (left out, redacted, `read: "none"`, gone); the line CHANGED since the read (its words or its speaker: + * screenLineChanged -- judged on the entry it is given: the build judges the cut AS WRITTEN, validateScreenReads); and + * what the part SAYS holding a shape (an e-mail, a number: a recording that says what the card masks). `changed`: the + * roles already said changed (one sentence a line). + */ +export function screenPartErrors(entry, k, roles = partRoles(entry), changed = new Set()) { + const r = roles[k]; + const p = r?.role ? parseScreenRole(r.role) : null; + if (!p) return []; + const w = `timeline ${entry?.id ?? "?"}`; + const id = entry?.id ?? "<item>"; + const n = k + 1; + const out = []; + const why = screenLineProblem(entry, r.role); + if (why) out.push(`${w}: its take's part ${n} reads ${why} -- read it (umtool posts screen <p> ${id} set <screen> read=…) or re-make the read without it (umtool posts screen <p> ${id} read)`); + // The words it says are the line's AS IT IS NOW (operator's rule: nothing said the card does not show): a line edited, + // removed or moved since the read leaves the old audio under new lit text -- refused, never played. + else if (!changed.has(r.role) && screenLineChanged(entry, r.role, roles)) { + changed.add(r.role); + out.push(`${w}: its take's part ${n}: line ${p.n} of screen ${p.id} changed since the read (its words or its speaker are not what the take says) -- make the read again (umtool posts screen <p> ${id} read)`); + } + const part = (pickedTake(entry)?.parts ?? [])[k]; + const kinds = [...new Set(shapeSpans(str(part?.text)).map((x) => x.kind))]; + if (kinds.length) out.push(`${w}: its take's part ${n} (line ${p.n} of screen ${p.id}) says ${kinds.map((x) => (x === "email" ? "an e-mail address" : x === "order" ? "an order or reference number" : "a long number or a phone number")).join(" and ")} -- the card masks it, and a read never says it: re-record the line without it, or make the read again (umtool posts screen <p> ${id} read)`); + return out; +} + +/** + * THE SCREENS' READS over a cut, pure (the build's ENFORCED lint, build-video.mjs enforcedLint, gives it the cut AS + * WRITTEN -- never the anonymised copy it draws): every screen part's errors (screenPartErrors) of every narrated post + * item that carries screens. Empty for a cut with none. + */ +export function validateScreenReads(manifest) { + const tl = Array.isArray(manifest?.timeline) ? manifest.timeline : []; + const out = []; + for (const e of tl) { + if (e?.type !== "post" || !Array.isArray(e.screens) || !isNarrated(e)) continue; + const roles = partRoles(e); + const changed = new Set(); + roles.forEach((r, k) => { + if (r?.role && parseScreenRole(r.role)) out.push(...screenPartErrors(e, k, roles, changed)); + }); + } + return out; +} + const sayKeys = (t) => str(t).toLowerCase().split(/\s+/).map((x) => x.replace(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, "")).filter(Boolean); const normText = (t) => str(t).replace(/\s+/g, " ").trim(); @@ -562,6 +610,9 @@ export function screenLineChanged(entry, role, roles = partRoles(entry)) { const parts = Array.isArray(t?.parts) && t.parts.length ? t.parts : scriptParts(str(t?.script).trim() ? t.script : str(entry?.narration?.script)).map((q) => ({ text: q.text })); const mine = roles.map((r, k) => (r?.role === role ? parts[k] : null)).filter(Boolean); if (!mine.length) return false; + // Its speaker (`speaker`, stored beside the line): a line given to someone else is not the line the voice read. + const spk = mine.find((x) => typeof x.speaker === "string"); + if (spk && normText(spk.speaker).toLowerCase() !== normText(sc.lines[p.n]?.who).toLowerCase()) return true; const stored = mine.find((x) => typeof x.line === "string"); if (stored) return normText(stored.line) !== normText(draftScript(said).script); const a = sayKeys(mine.map((x) => str(x.text)).join(" ")); @@ -602,16 +653,7 @@ export function threadReadErrors(entry, render = undefined, { prev = null, scene return; } if (parseScreenRole(r.role)) { - // A SCREEN's line (post-screens.mjs): drawn and lit only when the screen reads it. - const why = screenLineProblem(entry, r.role); - if (why) errors.push(`${w}: its take's part ${n} reads ${why} -- read it (umtool posts screen <p> ${entry?.id ?? "<item>"} set <screen> read=…) or re-make the read without it (umtool posts screen <p> ${entry?.id ?? "<item>"} read)`); - // The words it says are the line's AS IT IS NOW (operator's rule: nothing said the card does not show): a line edited, - // removed or moved since the read leaves the old audio under new lit text -- refused, never played. - else if (!changed.has(r.role) && screenLineChanged(entry, r.role, L.roles)) { - changed.add(r.role); - const p = parseScreenRole(r.role); - errors.push(`${w}: its take's part ${n}: line ${p.n} of screen ${p.id} changed since the read (its words are not what the take says) -- make the read again (umtool posts screen <p> ${entry?.id ?? "<item>"} read)`); - } + errors.push(...screenPartErrors(entry, k, L.roles, changed)); return; } if (r.role.startsWith("media:")) {