// A SCREEN LINE's "SAID AS" (lane line-rerun; operator ruling 3, 15 Nov 2026: every edit is for READING only): what the // voice says for a read line (`screens[j].saidAs`), never what the card draws, never the line's identity. import assert from "node:assert/strict"; import { test } from "node:test"; import { saidAsOf, screenLineSaid, screenLineSpoken, screenReadLines, screenRows, validateScreens, withoutLines } from "umtool-report-to-video/post-screens"; import { screenLineChanged } from "umtool-report-to-video/post-thread"; import { validatePostItem } from "umtool-report-to-video/post-item"; import { draftScript } from "umtool-report-to-video/post-narration"; import { applyPairs } from "./postScreensCli.mjs"; import { threadReadPlan } from "./postThreadRead.mjs"; import { lineToRecord } from "./screenLineRecord.mjs"; import { FIXTURES, PINNED_SHAS, drawn } from "../../report-to-video/post-reading-pin.fixtures.mjs"; const NO_RED = { terms: [], markup: {}, slurs: null }; const DM = { id: "s1", media: 0, kind: "dm", read: "all", lines: [ { who: "rivertalk", text: "Did the BRT plan pass?" }, { who: "bridgefan", text: "Ask the clerk, rm 4." }, { who: "rivertalk", text: "Thanks." }, ], }; const IMG = { src: "posts-media/bridge-x/7003/7003_1.png", kind: "image", width: 900, height: 1400 }; const item = (sc) => ({ type: "post", id: "p-1", post: "bridge-x/1", platform: "x", handle: "bridgefan", author: "Bridge Fan", date: "2026-10-02T10:00:00.000Z", text: "Here it is.", media: [IMG], screens: [sc] }); test("saidAs: what the voice says, never what is shown -- shown, screenLineSaid, the drawn rows and the read runs identical with and without it", () => { const as = { ...DM, saidAs: { 0: "Did the B R T plan pass?", 1: "Ask the clerk, room four." } }; assert.equal(saidAsOf(as, 0), "Did the B R T plan pass?"); assert.equal(saidAsOf(as, 2), null); for (const n of [0, 1, 2]) assert.equal(screenLineSaid(as, n), screenLineSaid(DM, n)); assert.equal(screenLineSpoken(as, 0), "Did the B R T plan pass?"); assert.equal(screenLineSpoken(as, 2), screenLineSaid(DM, 2)); assert.deepEqual(screenRows(as), screenRows(DM)); assert.deepEqual(screenReadLines(as), screenReadLines(DM)); }); test("saidAs: a take of the line as shown is still the line's when only its said-as changes (screenLineChanged reads the shown words)", () => { const parts = [0, 1, 2].map((n) => ({ n: n + 1, para: (n + 1) * 100, text: screenLineSaid(DM, n), role: `screen:s1:${n}`, line: draftScript(screenLineSaid(DM, n)).script, speaker: DM.lines[n].who, start: n * 2, seconds: 1.5 })); const narrated = (sc) => ({ ...item(sc), narration: { script: "Here it is.", pick: 0, takes: [{ file: "narration/posts/1/take-1.orpheus-thread.wav", seconds: 6, script: "x", parts, read: { kind: "thread" } }] } }); const before = narrated(DM); const after = narrated({ ...DM, saidAs: { 0: "Did the B R T plan pass?" } }); for (const n of [0, 1, 2]) assert.equal(screenLineChanged(after, `screen:s1:${n}`), screenLineChanged(before, `screen:s1:${n}`)); assert.equal(screenLineChanged(after, "screen:s1:0"), false); }); test("saidAs: refused for a line it does not have, a redacted line, no words, or a shape the card would mask; a line removed takes its said-as with it", () => { const bad = (saidAs) => validateScreens(item({ ...DM, saidAs })); assert.deepEqual(bad({ 0: "Did the B R T plan pass?" }), []); assert.ok(bad({ 7: "x" }).some((m) => /has no line 7/.test(m))); assert.ok(validateScreens(item({ ...DM, lines: [...DM.lines.slice(0, 2), { text: "secret", redact: true }], saidAs: { 2: "secret" } })).some((m) => /redacted/.test(m))); assert.ok(bad({ 0: " " }).some((m) => /must be words/.test(m))); assert.ok(bad({ 1: "write to clerk@example.org" }).some((m) => /an e-mail address the card would mask/.test(m))); assert.ok(bad({ 1: "call 5551234567" }).some((m) => /a number the card would mask/.test(m))); assert.deepEqual(withoutLines({ ...DM, saidAs: { 0: "a", 2: "c" } }, [1]).saidAs, { 0: "a", 1: "c" }); assert.equal("saidAs" in withoutLines({ ...DM, saidAs: { 1: "b" } }, [1]), false); }); test("saidAs: a said-as that says what another line masks is refused by the item's validator", () => { const sc = { ...DM, lines: [...DM.lines, { who: "rivertalk", text: "my number is 555 123 4567" }] }; const hit = validatePostItem({ ...item(sc), screens: [{ ...sc, saidAs: { 0: "it is 5551234567 then" } }] }); assert.ok(hit.some((m) => /a number/.test(m)), hit.join("\n")); }); test("said.= (posts screen set): sets and clears a line's said-as", () => { const sc = applyPairs(DM, ['said.0="Did the B R T plan pass?"']); assert.deepEqual(sc.saidAs, { 0: "Did the B R T plan pass?" }); assert.equal("saidAs" in applyPairs(sc, ["said.0=off"]), false); assert.throws(() => applyPairs(DM, ["said.9=x"]), /line 9/); }); test("saidAs: the thread read SAYS it (a part's text) and keeps the line as shown (`line`, the identity); the record prompt says it too", () => { const e = { ...item({ ...DM, saidAs: { 0: "Did the B R T plan pass?" } }), narration: { script: "Here it is." } }; const plan = threadReadPlan({ timeline: [e], render: {} }, e, { red: NO_RED, map: {}, cast: {}, item: null, names: {} }); const p0 = plan.pieces.find((p) => p.role === "screen:s1:0"); assert.match(p0.text, /B R T/); assert.doesNotMatch(p0.line, /B R T/); const r = lineToRecord(e, "screen:s1:0", { red: NO_RED, names: {} }); assert.match(r.prompt, /B R T/); assert.doesNotMatch(r.written, /B R T/); }); test("THE READING PIN with a said-as: a thread item's card draws as before", () => { const e = structuredClone(FIXTURES.thread); e.screens[0].saidAs = { 0: "Are the tolls going up again, yes or no?" }; assert.deepEqual(drawn(e), PINNED_SHAS.thread); }); test("A LINE REDACTED drops its said-as (review 1, finding 7): line..redact=on is never refused for a said-as it had", () => { const sc = applyPairs({ ...DM, saidAs: { 0: "Did the B R T plan pass?", 1: "Ask the clerk, room four." } }, ["line.1.redact=on"]); assert.equal(sc.lines[1].redact, true); assert.deepEqual(sc.saidAs, { 0: "Did the B R T plan pass?" }); assert.deepEqual(validateScreens(item(sc)), []); assert.equal("saidAs" in applyPairs({ ...DM, saidAs: { 1: "x" } }, ["line.1.redact=on"]), false); });