Archilyzer · Source

archilyzer

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

commit c3185e27f673018bb03a48d8765fb2de56abc3e9
parent 7db0c1e9c26eb7e48ac77e58d5661040b5a8053d
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri, 13 Nov 2026 03:21:05 -0500

umtool screens, re-check: the public payload is built from what the card draws; one verdict, one accessor

M. Present's public screens are built FROM THE CARD's OWN DRAWING (present.mjs publicScreens):
only the screens the card draws (post-thread.mjs drawnScreens, which threadLayout now uses too),
each as its rows (post-screens.mjs screenRows: a read line's read run alone, masked, "…" where it is
cut; a line not read absent -- a {gap} row where the card draws "⋯" -- or dim when the card draws
it dim; a redacted line never), its header and badge (screenHeader), each speaker as the card
names it (post-item.mjs screenSpeakerShown, which the card now calls). No `lines`, no `read`.
b. The card page judges the read on the item AS WRITTEN (before its anonymity pass) and applies
the verdict to the item it draws (post-thread.mjs playableAsWritten).
e. One accessor for an item's playable read, post-thread.mjs playableTake: Present, the player
and postItemAssets read their take through it; a source test lists the player/preview/payload
files and refuses a direct picked-take read in them (the card route's word-timing writes allowed).

Tests made failing first (lib/report/postScreensReview3.test.mjs): the whole public payload walked
for planted markers (an excerpt's remainder, a line not read, a screen not read, a redacted line,
masked numbers, a title's and a time's shape, an anonymous handle and name), the operator payload
as written; playableAsWritten; the accessor source test. The pins hold; d1 identical to main.

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

Diffstat:
Mumtool/app/api/report/post-item/route.ts | 9++++++---
Mumtool/components/projects/review/PostItemPlayer.tsx | 10+++++-----
Mumtool/docs/report-video.md | 13+++++++++----
Mumtool/lib/report/postScreensReview3.test.mjs | 131++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------
Mumtool/lib/report/present.mjs | 84+++++++++++++++++++++++++++++++++++++------------------------------------------
Mumtool/report-to-video/post-item.mjs | 23+++++++++++++++--------
Mumtool/report-to-video/post-thread.mjs | 40+++++++++++++++++++++++++++++++++-------
7 files changed, 220 insertions(+), 90 deletions(-)

diff --git a/umtool/app/api/report/post-item/route.ts b/umtool/app/api/report/post-item/route.ts @@ -7,7 +7,7 @@ import { jobState, startJob } from "@/lib/research/case-editor"; import { withEditNotes } from "@/lib/report/guard"; import { StaleToken, StructureRefused, manifestToken, updatePostFx, updatePostItem, updatePostNarration } from "@/lib/report/manifest.mjs"; import { isNarrated, pickedTake } from "umtool-report-to-video/post-narration"; -import { playableEntry } from "umtool-report-to-video/post-thread"; +import { playableAsWritten } from "umtool-report-to-video/post-thread"; import { scriptWordTimes } from "umtool-report-to-video/word-zoom"; import { followKnobs } from "umtool-report-to-video/read-follow"; import { threadLayout } from "umtool-report-to-video/post-thread"; @@ -84,6 +84,8 @@ async function anonymised(project: { dir: string }, m: Record<string, unknown>, async function itemOf(project: { dir: string }, manifest: Record<string, unknown>, id: string, take: string | null, { anon = false }: { anon?: boolean } = {}) { let m = manifest; if (take) m = (await resolveTakeManifest(project.dir, take, { base: manifest })).manifest as Record<string, unknown>; + // The item AS WRITTEN (before the anonymity pass): what the build's enforced lint judges its read on. + const written = ((Array.isArray(m.timeline) ? m.timeline : []) as Entry[]).find((e) => e?.type === "post" && e.id === id) ?? null; if (anon) m = await anonymised(project, m, manifest); const tl = (Array.isArray(m.timeline) ? m.timeline : []) as Entry[]; const at = tl.findIndex((e) => e?.type === "post" && e.id === id); @@ -92,7 +94,7 @@ async function itemOf(project: { dir: string }, manifest: Record<string, unknown const ctx = planContext(tl, at, (m.render ?? {}) as Record<string, unknown>) as { prev: Record<string, unknown> | null; scene: Record<string, unknown> | null; join: { seconds: number } | null }; // THE JOIN (post-join.mjs): the item before's own context, so its post's size is known (the carried post drawn alike). const prevCtx = at > 0 && ctx.join ? (planContext(tl, at - 1, (m.render ?? {}) as Record<string, unknown>) as Record<string, unknown>) : null; - return { item: at >= 0 ? tl[at] : null, prev: ctx.prev, ctx, prevCtx, manifest: m }; + return { item: at >= 0 ? tl[at] : null, written, prev: ctx.prev, ctx, prevCtx, manifest: m }; } /** How the item before draws its post (post-item.mjs joinCarryOf), as the build draws the carried post alike. */ @@ -275,7 +277,8 @@ export async function GET(request: Request) { const h = Math.round(Number(q.get("h")) || 0); if (!(w >= 160 && w <= 3840 && h >= 90 && h <= 2160)) return new Response("w and h are the footage box, in px", { status: 400 }); // NEVER A READ THE BUILD REFUSES (post-thread.mjs playableEntry): a read older than its screen draws as no read at all. - found.item = playableEntry(found.item) as Entry; + // Judged on the item AS WRITTEN, applied to the one drawn (post-thread.mjs playableAsWritten): the build's verdict. + found.item = playableAsWritten(found.written ?? found.item, found.item) as Entry; const base = `/api/report/post-item?project=${encodeURIComponent(r.project.id)}`; const parentShot = typeof found.item.parentShot === "string" ? `${base}&file=${encodeURIComponent(found.item.parentShot)}` : null; // The authors' pictures (post-avatars.mjs), served as the project's files. diff --git a/umtool/components/projects/review/PostItemPlayer.tsx b/umtool/components/projects/review/PostItemPlayer.tsx @@ -5,8 +5,8 @@ import { POST_ENTER_FADE, POST_PUSH, mediaTimeAt, postLayout, stepAt, stepBoxes import { applyJoinState, endMediaOf, joinClockOf, joinEase, joinFrameAt } from "umtool-report-to-video/post-join"; import { applyVisitState } from "umtool-report-to-video/post-link-visit"; import { applyMapState, mapHtml, mapPlace, mapSize } from "umtool-report-to-video/post-branch-map"; -import { dryGainAt, mixPhaseAt, pickedTake, wetGainAt } from "umtool-report-to-video/post-narration"; -import { READ_REFUSED_REASON, itemReadRefusals } from "umtool-report-to-video/post-thread"; +import { dryGainAt, mixPhaseAt, wetGainAt } from "umtool-report-to-video/post-narration"; +import { READ_REFUSED_REASON, itemReadRefusals, playableTake } from "umtool-report-to-video/post-thread"; import { applyFollowState, followPath, followStateAt, measureFollow } from "umtool-report-to-video/read-follow"; import { scrollAt, showOpacityAt } from "umtool-report-to-video/post-thread"; import { blurCqw, blurOf, labelBoxOf, pixelGrid } from "umtool-report-to-video/post-censor"; @@ -221,7 +221,7 @@ export function postItemAssets({ project, take = null, entry, plan, box, publish if (postLayout(entry, box).mode === "stack") docs.push(page(entry.id, "media")); if (joinFrom && (plan.follow?.join?.seconds ?? 0) > 0) docs.push(page(joinFrom.entry.id, "read")); const files: string[] = []; - const voice = plan.narration ? (pickedTake(entry) as { file?: string } | null) : null; + const voice = plan.narration ? (playableTake(entry) as { file?: string } | null) : null; if (voice?.file) files.push(takeFileUrl(project, voice.file)); for (const st of plan.steps) { for (const m of st.items) { @@ -639,7 +639,7 @@ export default function PostItemPlayer({ }, [entry]); // Narrated (post-narration.mjs): the picked take on the item's clock, from `at`. const mix = readRefused ? null : plan.narration ?? null; - const voiceTake = useMemo(() => (mix ? pickedTake(entry) : null), [mix, entry]); + const voiceTake = useMemo(() => (mix ? playableTake(entry) : null), [mix, entry]); const voice = useRef<HTMLAudioElement | null>(null); const local = mix ? s - mix.at : -1; const speaking = !!mix && local >= 0 && local < mix.seconds; @@ -679,7 +679,7 @@ export default function PostItemPlayer({ const [ahead] = useState(() => { const here = (u: string) => postPreload.urlOf(u) !== u; if (postPreload.docOf(pageUrl("read")) === null) return false; - const take = plan.narration ? (pickedTake(entry) as { file?: string } | null) : null; + const take = plan.narration ? (playableTake(entry) as { file?: string } | null) : null; if (take?.file && !here(takeFileUrl(project, take.file))) return false; return (plan.steps[0]?.items ?? []).every((m) => here(postFileUrl(project, String(m.src)))); }); diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -1633,14 +1633,19 @@ scratch dir of its own, mkdtemp), followed on the page; a job's result never rep item as written: `itemReadRefusals`). The writer lets a screen change under its read -- a line's words or speaker edited, a line removed, redacted or no longer read -- and the build refuses the old read; so do Play, Present (the public payload too), the card page and the post bench's player: the item plays SILENT, as an item not narrated, no take -of it in the payload, saying why ("the read is older than its screen … make the read again"). **No part of a read may +of it in the payload, saying why ("the read is older than its screen … make the read again"). One verdict everywhere: +the item AS WRITTEN is judged (the card page too, before its anonymity pass: `playableAsWritten`), and every player, +preview and payload reads an item's take through one accessor, `playableTake` (a source test lists the files and +refuses a direct picked-take read in them). **No part of a read may say what the item's screens hide** (`readSaysHiddenErrors`, in the enforced lint): his words, a context post, a screen line or a take with no parts that says a number (four digits or more, however joined) or an e-mail one of the item's screens masks, or three or more words of a line marked `redact`, refuses the read -- naming the part and the line, never the value. (The project's own redaction terms are a read's to leave out -- spokenRead -- and an anonymous handle the -anonymity lint's.) Present's PUBLIC payload carries the screens as the card draws them -- every shape masked in words, -speakers, times and titles (an excerpt masked in place), a redacted line wordless, a speaker the card blurs nameless -- -never a raw line. +anonymity lint's.) Present's PUBLIC payload carries the screens AS THE CARD DRAWS THEM, built from the card's own drawing +(`publicScreens`: post-thread.mjs `drawnScreens`, post-screens.mjs `screenRows` and `screenHeader`, post-item.mjs +`screenSpeakerShown`) -- only the screens the card draws, each as its rows: a read line's read run alone, masked, "…" +where it is cut; a line not read absent (a `{ gap }` row where the card draws "⋯"), or dim when the card draws it dim; +a redacted line never; a speaker the card blurs nameless; no `lines`, no `read` -- never a raw line. **Byte-identical without.** An item with no `screens` draws, plans and keys exactly as before (`post-screens-pin.test.mjs`); a segment with screens carries `screens: POST_SCREEN_DRAW_V` in its key. An item with diff --git a/umtool/lib/report/postScreensReview3.test.mjs b/umtool/lib/report/postScreensReview3.test.mjs @@ -95,26 +95,14 @@ test("M1 Play and Present: a refused read is in no view and no payload -- operat assert.equal(pay.slides.find((x) => x.kind === "post").narration.file, THREAD); }); -test("i: the public payload's screens are what the card draws -- shapes masked in words, speaker, time and title; a redacted line wordless; a blurred speaker nameless; an excerpt masked in place", async () => { - const sc = { id: "s1", media: 0, kind: "dm", title: "Mail to savvy@gmail.com", read: [{ line: 0 }, { line: 1, text: "call 555 201 4477 tonight" }, { line: 3 }], lines: [ - { who: "Stranger", text: "my email is jane.doe@example.com", time: "555-201-4477" }, - { who: "MadamSavvy", text: "please call 555 201 4477 tonight after work" }, - { who: "Stranger", text: "Order number 4419283", redact: true }, - { who: "Other", text: "fine" }, - ] }; - const e = { ...ITEM, narration: undefined, screens: [sc] }; - const p = await project("i-pub", e); +test("i: an item whose read draws no screen carries no screen in the public payload (the card draws none)", async () => { + const sc = { id: "s1", media: 0, kind: "dm", title: "Mail to savvy@gmail.com", read: "all", lines: [{ who: "Stranger", text: "my email is jane.doe@example.com", time: "555-201-4477" }] }; + const p = await project("i-pub", { ...ITEM, narration: undefined, screens: [sc] }); const pay = await presentPayload(p, { canUncensor: false }); - const shown = pay.slides.find((x) => x.kind === "post").post.screens[0]; - const raw = JSON.stringify(shown); - for (const v of ["jane.doe", "example.com", "555", "4477", "savvy@gmail", "4419283", "Stranger", "Other"]) assert.ok(!raw.includes(v), `${v} not in the public data`); - assert.deepEqual(shown.lines[2], { text: "", redact: true }); - assert.equal(shown.lines[1].who, "MadamSavvy", "her own line: her name (a subject)"); - assert.notEqual(shown.lines[0].who, shown.lines[3].who, "two blurred speakers still told apart"); - assert.ok(shown.lines[1].text.includes(shown.read[1].text), "the excerpt is masked in place: still a run of its line"); - // The operator's payload keeps the lines as written (the operator's own screen). + assert.deepEqual(pay.slides.find((x) => x.kind === "post").post.screens, []); + assert.ok(!/jane\.doe|savvy@gmail|4477/.test(JSON.stringify(pay))); const op = await presentPayload(p, { canUncensor: true }); - assert.ok(JSON.stringify(op.slides.find((x) => x.kind === "post").post.screens).includes("jane.doe@example.com")); + assert.ok(JSON.stringify(op.slides.find((x) => x.kind === "post").post.screens).includes("jane.doe@example.com"), "the operator's own screen, as written"); }); test("M2 the enforced lint: no part of an item's read says a number or an e-mail its screens mask, nor a redacted line's words -- whoever's part it is", () => { @@ -267,3 +255,110 @@ test("j: an unheard line take is said to be one -- the record's note, the lint p assert.ok(lineTakeWarnings(chose("take-2.recorded-operator")).some((x) => /line take 2 of screen s1 line 2 was not heard -- nothing verified what the recording says/.test(x))); assert.ok(!lineTakeWarnings(chose("take-3.recorded-operator")).some((x) => /was not heard/.test(x))); }); + +// --------------------------------------------------------------------------- +// RE-CHECK: the public payload is built from what the card draws (M); one verdict on the item as written (b); one +// accessor for an item's playable read (e). +// --------------------------------------------------------------------------- +import { publicScreens } from "./present.mjs"; +import { playableAsWritten, playableTake } from "umtool-report-to-video/post-thread"; +import { postCardHtml, postItemPlan } from "umtool-report-to-video/post-item"; + +/** Every string anywhere in a value (keys too), any depth. */ +const strings = (v, out = []) => { + if (typeof v === "string") out.push(v); + else if (Array.isArray(v)) v.forEach((x) => strings(x, out)); + else if (v && typeof v === "object") for (const [k, x] of Object.entries(v)) strings(x, out.concat(k)); + return out; +}; +const MARKED = { + type: "post", id: "p-2117", post: "savvy-x/2117", platform: "x", author: "Savvy", handle: "MadamSavvy", date: "2026-11-02T01:40:36.000Z", text: "Hey, you told me.", subjects: ["MadamSavvy"], media: [IMG], + screens: [ + { id: "s1", media: 0, kind: "dm", title: "Mail to TITLEMARK@example.com", read: [{ line: 0, text: "keep this part" }, { line: 1 }, { line: 4 }], lines: [ + { who: "MadamSavvy", text: "keep this part CUTREMAINDER words", time: "call 555 201 4477" }, + { who: "TheQuartering", text: "ring 555 777 8888 now", time: "11:32 AM" }, + { who: "TheQuartering", text: "OMITTEDLINE never chosen" }, + { who: "TheQuartering", text: "REDACTEDWORDS alpha beta gamma", redact: true }, + { who: "secretkid", text: "ask @secretkid about it" }, + ] }, + { id: "s2", media: 0, kind: "text", read: "all", lines: [{ text: "UNREADSCREEN its words" }] }, + ], +}; +const narratedMarked = () => { + const e = structuredClone(MARKED); + const parts = [{ n: 1, para: 0, text: "Hey, you told me.", voice: "tara", role: "post", start: 0, seconds: 1 }]; + let t = 1.5; + for (const n of [0, 1, 4]) { + const said = screenLineSaid(e.screens[0], n); + parts.push({ n: parts.length + 1, para: 100 * (n + 1), text: said, voice: "leo", role: `screen:s1:${n}`, start: t, seconds: 1, line: draftScript(said).script, speaker: e.screens[0].lines[n].who }); + t += 1.5; + } + return { ...e, narration: { script: "Hey, you told me.", pick: 0, takes: [{ file: THREAD, engine: "orpheus", voice: "tara+leo", seconds: t, script: "x", parts, read: { kind: "thread", parents: "0" } }] } }; +}; + +test("M (re-check): the WHOLE public payload holds nothing the card does not draw -- an excerpt's remainder, a line not read, a screen not read, a redacted line, a masked number, a title's or a time's shape, an anonymous handle; the operator payload as before", async () => { + const p = await project("m-public", narratedMarked()); + await writeFile(path.join(p.dir, "narration", "characters.json"), JSON.stringify({ format: "umtool-project-characters", version: 1, characters: [{ id: "kid", name: "Secret Kid", handles: ["secretkid"], anonymous: true }] })); + const pub = await presentPayload(p, { canUncensor: false }); + assert.ok(!pub.error, String(pub.error)); + const all = strings(pub).join("\n"); + for (const marker of ["CUTREMAINDER", "OMITTEDLINE", "UNREADSCREEN", "REDACTEDWORDS", "alpha beta", "555 201 4477", "4477", "555 777 8888", "8888", "TITLEMARK", "secretkid", "Secret Kid"]) { + assert.ok(!all.toLowerCase().includes(marker.toLowerCase()), `${marker} is nowhere in the public payload`); + } + // What the card draws IS there: the excerpt's run cut "…", a "⋯" row for the lines left out, the read lines masked. + const sc = pub.slides.find((x) => x.kind === "post").post.screens; + assert.deepEqual(sc.map((x) => x.id), ["s1"], "only the screens the card draws"); + const rows = sc[0].rows; + assert.equal(rows[0].text, "keep this part…"); + assert.ok(rows.some((r) => r.gap), "the lines left out are a gap row, not their words"); + assert.ok(rows.some((r) => /^ring\b/.test(r.text) && !/\d/.test(r.text)), "a read line, its number masked"); + assert.equal("lines" in sc[0], false, "no lines to draw from but the rows drawn"); + // The card itself draws none of the markers either (the payload and the card agree). + const e = narratedMarked(); + const plan = postItemPlan(e, {}); + const html = postCardHtml(e, { width: 1600, height: 900, follow: true, thread: plan.follow?.thread ?? null }); + for (const marker of ["CUTREMAINDER", "OMITTEDLINE", "UNREADSCREEN", "REDACTEDWORDS"]) assert.ok(!html.includes(marker), `${marker} not on the card`); + // The operator's payload: the screens as written, unchanged. + const op = await presentPayload(p, { canUncensor: true }); + const opScreens = op.slides.find((x) => x.kind === "post").post.screens; + assert.deepEqual(opScreens.map((x) => x.lines.map((l) => l.text)), MARKED.screens.map((x) => x.lines.map((l) => l.text.replace("@secretkid", "@Anon_1"))), "every line as written (the anonymity pass as before)"); + assert.deepEqual(opScreens.map((x) => x.read), MARKED.screens.map((x) => x.read)); + // A read refused: no screen drawn, none in the public data. + assert.deepEqual(publicScreens(MARKED, { roles: [] }), []); +}); + +test("b (re-check): the card page's verdict is the item AS WRITTEN's, applied to the item as drawn (playableAsWritten)", async () => { + const stale = edited(EDITS["words of line 1 edited"]); + // The drawn copy may differ (the anonymity pass, the censor): the verdict is the written one's either way. + const drawnLooksFine = { ...stale, screens: ITEM.screens }; + const out = playableAsWritten(stale, drawnLooksFine); + assert.equal(out.narration, undefined); + assert.ok(out.readRefused); + const fine = playableAsWritten(ITEM, { ...ITEM, screens: stale.screens }); + assert.equal(fine.narration.takes[0].file, THREAD, "written fine: the drawn copy plays"); + // The route calls it with the item as written. + const src = await readFile(new URL("../../app/api/report/post-item/route.ts", import.meta.url), "utf8"); + assert.match(src, /playableAsWritten\(found\.written \?\? found\.item, found\.item\)/); + assert.match(src, /const written = .*before the anonymity pass|The item AS WRITTEN \(before the anonymity pass\)/); +}); + +test("e (re-check): every player, preview and payload reads an item's take through playableTake -- no direct picked-take read outside the allow-list", async () => { + assert.equal(playableTake(edited(EDITS["line 1 redacted"])), null); + assert.equal(playableTake(ITEM).file, THREAD); + assert.equal(playableTake({ ...ITEM, readRefused: { reason: "x" } }), null); + const root = new URL("../../", import.meta.url); + // The files that play, preview or ship an item's read. + const files = ["lib/report/present.mjs", "lib/report/playView.mjs", "lib/report/postBenchData.ts", "components/projects/review/PostItemPlayer.tsx", "components/projects/present/PresentView.tsx", "app/api/report/post-item/route.ts"]; + for (const dir of ["components/projects/review/playEngine"]) for (const f of await readdir(new URL(dir, root))) if (/\.(ts|tsx|mjs)$/.test(f) && !/\.test\./.test(f)) files.push(`${dir}/${f}`); + // Allowed: the card route's word-timing ops, which time the take on record (a write), never play it. + const ALLOW = [/const take = pickedTake\(found\.item\) as .*script\?: string; parts\?: unknown\[\]/, /const take = found\.item \? \(pickedTake\(found\.item\) as .*\{ file: string \}\) \| null\) : null;/]; + const bad = []; + for (const f of files) { + const lines = (await readFile(new URL(f, root), "utf8")).split("\n"); + lines.forEach((l, i) => { + if (/^\s*(\/\/|\*)/.test(l)) return; + if ((/\bpickedTake\(/.test(l) || /\bnarration\??\.takes\b/.test(l)) && !ALLOW.some((re) => re.test(l))) bad.push(`${f}:${i + 1}: ${l.trim().slice(0, 120)}`); + }); + } + assert.deepEqual(bad, [], "read an item's take through playableTake (post-thread.mjs)"); +}); diff --git a/umtool/lib/report/present.mjs b/umtool/lib/report/present.mjs @@ -25,13 +25,14 @@ // `canUncensor: false` (a public export, step 4) carries the CENSORED posts only -- every redacted span already // marked, every masked slur masked, every blurred author's name and handle gone from the data -- and no reveal // data at all. A public page can add censoring, never remove it. -import { cardAuthors, cardText, excerptRanges, excerptSpansOf, postDay, subjectsOf } from "umtool-report-to-video/post-item"; -import { excerptRun, maskShapes, maskedField, screenWho } from "umtool-report-to-video/post-screens"; +import { cardAuthors, cardText, excerptRanges, excerptSpansOf, postDay, screenSpeakerShown } from "umtool-report-to-video/post-item"; +import { maskedField, screenHeader, screenIsExcerpt, screenRows, screenSide } from "umtool-report-to-video/post-screens"; +import { drawnScreens, partRoles, playableTake } from "umtool-report-to-video/post-thread"; +import { followKnobs } from "umtool-report-to-video/read-follow"; import { REDACT_MARK, redactEntry, redactionOn } from "umtool-report-to-video/post-redact"; import { maskFor, slurMatches, slursOn } from "umtool-report-to-video/post-slurs"; import { blurOf, censorEntry } from "umtool-report-to-video/post-censor"; import { clockZoneOf } from "umtool-report-to-video/post-clock"; -import { pickedTake } from "umtool-report-to-video/post-narration"; import { estimateSchedule } from "umtool-report-to-video/deck"; import { gapsOf, keptSpans } from "umtool-report-to-video/gaps"; import { clipBlurOf } from "umtool-report-to-video/clip-blur"; @@ -189,7 +190,7 @@ export function censorData(entry, red) { * @param {Record<string, any>} entry * @param {import("umtool-report-to-video/post-redact").Redaction | null} red */ -export function publicPostEntry(entry, red) { +export function publicPostEntry(entry, red, render = undefined) { const out = /** @type {Record<string, any>} */ (structuredClone(redactEntry(entry, red))); // A blurred author keeps a handle that names nobody: the card's rule still blurs it, and a mention of it in any // words is drawn blurred too (wordsHtml) -- the real handle is nowhere in the data. @@ -227,62 +228,55 @@ export function publicPostEntry(entry, red) { if (typeof out.replyingTo === "string" && blurred.has(out.replyingTo.replace(/^@/, "").toLowerCase())) out.replyingTo = NOBODY; if (Array.isArray(out.subjects)) out.subjects = out.subjects.filter((h) => !blurred.has(String(h).replace(/^@/, "").toLowerCase())); } - const take = pickedTake(entry); + // Its read as a preview may play it (post-thread.mjs playableTake: none when the build refuses it). + const take = playableTake(entry); if (isObj(out.narration)) out.narration = take ? { takes: [{ file: take.file, seconds: take.seconds, ...(fin(take.rate) ? { rate: take.rate } : {}) }], pick: 0 } : { off: true }; delete out.notes; - // ITS SCREENS AS THE CARD DRAWS THEM (review round 1, i): never a raw line in the data. - if (Array.isArray(out.screens)) out.screens = publicScreens(out, { authorHidden: cardAuthors(entry).some((a) => a.where === "author" && a.redact) }); + // ITS SCREENS AS THE CARD DRAWS THEM (re-check M): built from the card's drawing, never a raw line in the data. + if (Array.isArray(out.screens)) { + out.screens = publicScreens(out, { authorHidden: cardAuthors(entry).some((a) => a.where === "author" && a.redact), roles: take ? partRoles(entry) : [], follow: followKnobs(entry, render ?? {}).on }); + } // A read not played: why, without the build's words (they name commands, not what was said). if (isObj(out.readRefused)) out.readRefused = { reason: String(out.readRefused.reason ?? "") }; return out; } /** - * A post's SCREENS AS ITS CARD DRAWS THEM, for a payload that cannot uncensor (post-screens.mjs, post-item.mjs - * postCardHtml's screenShown): each line's words, its time and the screen's title with their shapes MASKED (the - * redaction's marks, the same length: an excerpt is masked in place, so it is still a run of its line); a line marked - * redact carries no words, no speaker, no time; a speaker the card blurs carries no name (`xxxxxxxx`, one a speaker so - * the card still tells them apart) -- her own lines under the author's rule, an anonymous one (the pass's) as shown. + * A post's SCREENS AS ITS CARD DRAWS THEM, for a payload that cannot uncensor (review round 1, i; re-check M) -- built + * FROM THE CARD's OWN DRAWING, never a second pass over the lines: only the screens the card draws (post-thread.mjs + * drawnScreens: the ones its read reads, with read-follow on), each as its rows (post-screens.mjs screenRows: a read + * line's read run alone, masked, "…" where it is cut; a line not read absent -- a `{ gap }` row where the card draws + * "⋯" -- or dim when the card draws it dim; a redacted line never), its header and badge (screenHeader), each row's + * speaker as the card names it (post-item.mjs screenSpeakerShown; a blurred one `xxxxxxxx`, one a speaker) and its + * time masked. `{ id, kind, media, at?, header, badge, excerpt, rows }` -- no `lines`, no `read`: nothing to draw from + * but what was drawn. * - * @param {Record<string, any>} entry the post item (its redaction marked, its anonymous authors under their names) - * @param {{ authorHidden?: boolean }} [o] + * @param {Record<string, any>} entry the post item as the card draws it (its redaction marked, its anonymous authors + * under their names) + * @param {{ authorHidden?: boolean, roles?: Array<{ role: string | null }>, follow?: boolean }} [o] `roles`: its + * picked take's (partRoles); `follow`: read-follow on (off: the card is not threaded, no screen is drawn) */ -export function publicScreens(entry, { authorHidden = false } = {}) { - const subjects = new Set(subjectsOf(entry).map((h) => String(h).replace(/^@/, "").toLowerCase())); +export function publicScreens(entry, { authorHidden = false, roles = [], follow = true } = {}) { + if (!follow) return []; const hidden = new Map(); - const shown = (l) => { - const sw = screenWho(l?.who, entry); - if (sw.self) return !authorHidden; - if (l?.anonymous === true) return true; - if (entry.redact === true) return false; - if (entry.redact === false) return true; - return !!sw.handle && subjects.has(String(sw.handle).toLowerCase()); - }; const nobody = (who) => { const k = String(who).trim().toLowerCase(); if (!hidden.has(k)) hidden.set(k, hidden.size ? `${NOBODY}${hidden.size + 1}` : NOBODY); return hidden.get(k); }; - return entry.screens.map((sc) => { - if (!isObj(sc) || !Array.isArray(sc.lines)) return sc; - const lines = sc.lines.map((l) => { - if (!isObj(l)) return l; - if (l.redact === true) return { text: "", redact: true }; - const out = { ...l, text: maskShapes(str(l.text)).text }; - if (typeof l.who === "string" && l.who.trim()) out.who = shown(l) ? maskedField(l.who) : nobody(l.who); - if (typeof l.time === "string") out.time = maskedField(l.time); - return out; + return drawnScreens(entry, roles).map((sc) => { + const head = screenHeader(entry, sc, { authorHidden }); + const rows = screenRows(sc).map((r) => { + if (r.gap) return { gap: r.lines }; + const l = sc.lines[r.n] ?? {}; + const who = str(l.who).trim(); + return { + n: r.n, text: `${r.cutBefore ? "…" : ""}${r.text}${r.cutAfter ? "…" : ""}`, read: r.read, side: screenSide(l, entry), + ...(who ? { who: screenSpeakerShown(entry, l, { authorHidden }) ? maskedField(who) : nobody(who) } : {}), + ...(str(l.time).trim() ? { time: maskedField(l.time.trim()) } : {}), + }; }); - const read = Array.isArray(sc.read) - ? sc.read.map((x) => { - if (!isObj(x) || typeof x.text !== "string" || !isObj(sc.lines[x.line])) return x; - const raw = str(sc.lines[x.line].text); - const run = excerptRun(raw, x.text); - // An excerpt not in its line is never drawn whole: left out (the card leaves the line out too). - return run ? { ...x, text: maskShapes(raw).text.slice(run.start, run.end) } : null; - }).filter(Boolean) - : sc.read; - return { ...sc, lines, read, ...(typeof sc.title === "string" ? { title: maskedField(sc.title) } : {}) }; + return { id: sc.id, kind: sc.kind, media: sc.media, ...(Array.isArray(sc.at) ? { at: sc.at } : {}), header: head.text, badge: head.badge, excerpt: screenIsExcerpt(sc), rows }; }); } @@ -397,10 +391,10 @@ export function presentFrom({ view, manifest, red, canUncensor = true }) { if (e.type === "post" && e.post && e.postPlan) { const post = /** @type {Record<string, any>} */ (e.post); const day = dayIn(post.date, zone); - const take = pickedTake(post); + const take = playableTake(post); const spans = excerptSpansOf(post); const excerpt = spans ? excerptRanges(cardText(post), spans) : null; - const shown = canUncensor ? post : publicPostEntry(post, red); + const shown = canUncensor ? post : publicPostEntry(post, red, manifest.render); slides.push({ id: unique(postSlideId(e)), kind: "post", diff --git a/umtool/report-to-video/post-item.mjs b/umtool/report-to-video/post-item.mjs @@ -1235,6 +1235,20 @@ export function pictureHtml(scope, media, { width, maxH, k, mediaUrl = null, pos } /** + * WHETHER A SCREEN LINE's SPEAKER IS NAMED on the card, pure (postCardHtml's screens, and the public payload's: one rule): + * the post's author under the card's rule for her (`authorHidden`: cardAuthors' "author" redact); an anonymous one (the + * pass flagged it) under the shown name; anyone else under the privacy rule -- a subject, or the item's redact: false. + */ +export function screenSpeakerShown(entry, l, { authorHidden = false } = {}) { + const s = screenWho(l?.who, entry); + if (s.self) return !authorHidden; + if (l?.anonymous === true) return true; + if (entry?.redact === true) return false; + if (entry?.redact === false) return true; + return !!s.handle && subjectsOf(entry).some((h) => String(h).replace(/^@/, "").toLowerCase() === String(s.handle).toLowerCase()); +} + +/** * The card's HTML: one page `width` × `height` (the box the item fills), the * card drawn in the deck's palette and faces, the attachments' slot left as a * well for the media to be laid into (the build overlays the files; Play the @@ -1316,14 +1330,7 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p const menSize = Math.round(22 * k); // A SCREEN's speaker (post-screens.mjs): the post's author under the card's rule for her; an anonymous one (the pass // flagged it) under the shown name; anyone else under the privacy rule -- a subject, or the item's redact: false. - const screenShown = (l) => { - const s = screenWho(l?.who, entry); - if (s.self) return !red("author"); - if (l?.anonymous === true) return true; - if (entry.redact === true) return false; - if (entry.redact === false) return true; - return !!s.handle && subjectsOf(entry).some((h) => String(h).replace(/^@/, "").toLowerCase() === String(s.handle).toLowerCase()); - }; + const screenShown = (l) => screenSpeakerShown(entry, l, { authorHidden: red("author") }); const ownPicMax = Math.max(Math.round(140 * k), L.card.height - 2 * L.pad - Math.round(250 * k) - Math.min(2, parentsOf(entry).length) * Math.round(130 * k) - (isObj(entry.quoted) ? Math.round(170 * k) : 0)); const own = { author: entry.author, handle: entry.handle, ...(entry.anonymous === true ? { anonymous: true } : {}) }; const ownRed = red("author"); diff --git a/umtool/report-to-video/post-thread.mjs b/umtool/report-to-video/post-thread.mjs @@ -289,6 +289,15 @@ const postIdOf = (e) => String(e?.post ?? "").split("/")[1] ?? ""; export const shownIdOf = (e) => str(e?.originalId) || postIdOf(e); /** + * THE SCREENS A THREADED CARD DRAWS, pure: each screen whose lines the screen reads and the picked take reads a line of, + * in the screens' order (threadLayout's tiles; the public payload's screens: one rule). `roles`: partRoles' (none: not + * narrated -- no screen is drawn). + */ +export function drawnScreens(entry, roles = isNarrated(entry) ? partRoles(entry) : []) { + return readScreens(entry).filter((sc) => roles.some((r) => r?.role && parseScreenRole(r.role)?.id === sc.id)); +} + +/** * THE THREAD LAYOUT, pure: `{ on, tiles: [{ scope, mode, read }], roles, * quotedAt }` -- the tiles top to bottom (the parents oldest first, a quoted * post read first, "post", a quoted post inside it), each with its resolved @@ -356,10 +365,7 @@ export function threadLayout(entry, render = undefined, { prev = null, scene = n // reads them -- a quote read before the post it answers sits above it -- one not read where it stood before the next. orderByRead(tiles, roles); // ITS SCREENS (post-screens.mjs): each screen the take reads a line of, a tile after his post's, in the screens' order. - for (const sc of readScreens(entry)) { - if (!roles.some((r) => r?.role && parseScreenRole(r.role)?.id === sc.id)) continue; - tiles.push({ scope: screenScope(sc.id), mode: "full", read: true, screen: true }); - } + for (const sc of drawnScreens(entry, roles)) tiles.push({ scope: screenScope(sc.id), mode: "full", read: true, screen: true }); const quotedAtOut = tiles.some((t) => t.above) ? "above" : "inside"; // THE SCENE (post-conversation.mjs): what the run had on screen, in the tree's order with this item's own tiles. const scened = withRelations(entry, isNarrated(entry) ? sceneTiles(entry, tiles, scene, k) : tiles, { group: !!scene?.group || !!groupOf(entry) }); @@ -661,15 +667,35 @@ export function readSaysHiddenErrors(e) { export const READ_REFUSED_REASON = "the read is older than its screen, or says what the screen hides -- it is not played: make the read again (umtool posts screen <p> <item> read)"; /** + * AN ITEM's PLAYABLE READ, pure: the picked take a preview may play -- none when the item says its read is refused + * (`readRefused`, playableEntry's) or the build would refuse it (itemReadRefusals). EVERY player, preview and payload + * reads the take through this (the source test pins it: lib/report/postScreensReview3.test.mjs, e). + */ +export function playableTake(e) { + if (!e || e.readRefused) return null; + if (itemReadRefusals(e).length) return null; + return pickedTake(e); +} + +/** * THE ITEM AS A PREVIEW MAY PLAY IT, pure (review round 1, M1): the item itself when the build would play its read; * else the item WITHOUT its read -- no narration, no take, no part in it (it plays silent, as an item not narrated) -- * with `readRefused: { reason, errors }` saying why. Judged on the item as written (itemReadRefusals); every player and * payload goes through it: playView (Play, Present -- the public payload too), the card page, the post bench's player. */ export function playableEntry(e) { - const errors = itemReadRefusals(e); - if (!errors.length) return e; - const { narration: _n, ...rest } = e; + return playableAsWritten(e, e); +} + +/** + * THE VERDICT ON THE ITEM AS WRITTEN, APPLIED TO THE ITEM AS DRAWN, pure (re-check b: one verdict everywhere): `drawn` + * (the anonymised, censored copy a page draws) as it may play -- itself, or without its read (`readRefused`) when + * `written` (the same item before those passes: what the build's enforced lint judges) has a read the build refuses. + */ +export function playableAsWritten(written, drawn) { + const errors = itemReadRefusals(written); + if (!errors.length) return drawn; + const { narration: _n, ...rest } = drawn; return { ...rest, readRefused: { reason: READ_REFUSED_REASON, errors } }; }