// THE READING PIN (lane/line-rerun, S3 of the Orpheus re-tune plan; operator ruling 3, 15 Nov 2026: "every edit is for // READING only -- the original text is always what is shown on screen"). An item whose read says its shown text as // drafted draws BYTE-IDENTICALLY to main (19fb842b5) before a line of S3 was written: its plain card, its followed // card (the blocks the read lights, the paragraphs an excerpt tile hides), its thread tiles' modes and the screens it // draws. A change that moves one of these hashes changes what a card made before S3 draws. // // Recorded on main: PIN_RECORD=1 node --test report-to-video/post-reading-pin.test.mjs import assert from "node:assert/strict"; import { test } from "node:test"; import { createHash } from "node:crypto"; import { draftScript } from "./post-narration.mjs"; import { postItemPlan } from "./post-item.mjs"; import { FIXTURES, PINNED_SHAS, drawn, singleItem, threadItem } from "./post-reading-pin.fixtures.mjs"; test("THE READING PIN: an item whose read says its shown text as drafted draws as it did on main", () => { const got = Object.fromEntries(Object.entries(FIXTURES).map(([k, e]) => [k, drawn(e)])); if (process.env.PIN_RECORD) { console.log(JSON.stringify(got, null, 2)); return; } assert.deepEqual(got, PINNED_SHAS); }); // --------------------------------------------------------------------------- // EDITED FOR READING (lane line-rerun): the read's words edited -- an acronym spelled out, a tag, paragraphs merged, // a sentence left out, words that match nothing on the card -- and a new take of them picked. The card draws exactly // what it drew before the edit: the same hashes as the pin above. // --------------------------------------------------------------------------- const EDITS = { respelled: "The council met on Tuesday about the new bridge, the B R I D G E.\n\nNobody from the ministry came to explain the delay.", merged: "The council met on Tuesday about the new bridge. Nobody from the ministry came to explain the delay.", shortened: "The council met on Tuesday about the new bridge.", unrelated: "Completely different words that the card never shows.\n\nAnd a second paragraph of them.\n\nAnd a third.", }; /** A single item whose script is `script`, saved for reading, and a take of it picked. */ function editedSingle(script) { const e = singleItem(); return { ...e, narration: { ...e.narration, script, forReading: true, pick: 1, takes: [...e.narration.takes, { file: "narration/posts/7003/take-2.orpheus-zac.wav", engine: "orpheus", voice: "zac", seconds: 5.1, script, reading: 1, forReading: true }] } }; } /** A thread item whose post piece reads `script` (its paragraphs its parts), saved for reading, picked. */ function editedThread(script) { const e = threadItem(); const t = e.narration.takes[0]; const own = draftScript(script).script.split("\n\n"); const before = t.parts.filter((p) => p.role !== "post"); const at = t.parts.findIndex((p) => p.role === "post"); let start = t.parts[at].start; const post = own.map((text, i) => { const sec = Math.round((text.split(/\s+/).length / 3) * 100) / 100; const p = { n: 0, para: 200 + i, text, voice: "zac", role: "post", start: Math.round(start * 1000) / 1000, seconds: sec }; start += sec + 0.6; return p; }); const parts = [...before.slice(0, at), ...post, ...before.slice(at)].map((p, i) => ({ ...p, n: i + 1 })); const take = { ...t, file: "narration/posts/7003/take-2.orpheus-thread.wav", parts, script: parts.map((p) => p.text).join("\n\n"), reading: 1, forReading: true }; return { ...e, narration: { ...e.narration, script, forReading: true, pick: 1, takes: [t, take] } }; } for (const [name, script] of Object.entries(EDITS)) { test(`EDITED FOR READING (${name}): a single read's card draws as before the edit`, () => { assert.deepEqual(drawn(editedSingle(script)), PINNED_SHAS.single); }); test(`EDITED FOR READING (${name}): a thread read's card draws as before the edit -- the excerpt tile hides what it hid, the tiles keep their modes`, () => { assert.deepEqual(drawn(editedThread(script)), PINNED_SHAS.thread); }); } test("EDITED BEFORE (a playing take made before the rule: no stamp): the card follows its words, as it always did", () => { const e = editedSingle(EDITS.unrelated); delete e.narration.forReading; delete e.narration.takes[1].forReading; assert.notDeepEqual(drawn(e), PINNED_SHAS.single); }); // --------------------------------------------------------------------------- // WHEN THE TILES ARE DRAWN (review 1, finding 1): a spoken edit never moves when a thread tile shows. The tiles' t0/t1 // of the unedited items, hashed as main (19fb842b5) schedules them -- recorded by running main's report-to-video on // these fixtures -- and every edited variant schedules them the same. // --------------------------------------------------------------------------- const RENDER = { postNarration: { lead: 0.4 } }; const tilesOf = (e) => (postItemPlan(e, RENDER).follow?.thread?.tiles ?? []).map((t) => [t.scope, t.mode, t.t0, t.t1, t.from, t.to]); const sha = (v) => createHash("sha1").update(JSON.stringify(v)).digest("hex"); // Main's: thread [["parent:0","excerpt",4.8,5.5,…],["quoted","full",4.8,5.5,…],["post","full",7.93,8.63,…],["screen:s1","full",15.33,16.03,…]]. const TILE_SHAS_MAIN = { single: "d1021365f7f764ec2d5fb30a8b089d2ba6ddfe54", thread: "ee8b33368446e02103771de890cb8b9f9c060583" }; test("THE TILES' TIMES: the unedited items schedule their tiles as main does", () => { assert.deepEqual(Object.fromEntries(Object.entries(FIXTURES).map(([k, e]) => [k, sha(tilesOf(e))])), TILE_SHAS_MAIN); }); for (const [name, script] of Object.entries(EDITS)) { test(`THE TILES' TIMES (${name}): an edit to his words read moves no tile's time -- the parent, the quoted post, his post, the screen`, () => { assert.equal(sha(tilesOf(editedThread(script))), TILE_SHAS_MAIN.thread, JSON.stringify(tilesOf(editedThread(script)))); }); } // --------------------------------------------------------------------------- // A SINGLE READ IN PARTS, its parts storing no role (Rule B: his post's, part by part; Rule A: the shown paragraphs). // --------------------------------------------------------------------------- /** A single read of `script` in parts (a paragraph each), no roles, stamped for reading, picked. */ function editedSingleParts(script) { const e = singleItem(); let t = 0; const parts = draftScript(script).script.split("\n\n").map((text, i) => { const sec = Math.round((text.split(/\s+/).length / 3) * 100) / 100; const p = { n: i + 1, para: i, text, start: Math.round(t * 1000) / 1000, seconds: sec }; t += sec + 0.5; return p; }); const take = { file: "narration/posts/7003/take-2.orpheus-zac.wav", engine: "orpheus", voice: "zac", seconds: Math.round(t * 100) / 100, script, parts, reading: 1, forReading: true }; return { ...e, narration: { ...e.narration, script, forReading: true, pick: 1, takes: [...e.narration.takes, take] } }; } for (const [name, script] of Object.entries(EDITS)) { test(`A SINGLE READ IN PARTS, NO ROLES (${name}): the card draws as before the edit`, () => { assert.deepEqual(drawn(editedSingleParts(script)), PINNED_SHAS.single); }); }