Archilyzer · Source

archilyzer

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

commit 5cbdfc02028a190ee5c4b11e2f20757fde5983b5
parent 36f8ddd5f4aeeced9b512212d1d15d7110eb8fd4
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 12 Nov 2026 09:01:43 -0500

umtool: on-screen anonymising -- an author who is one of the video's anonymous characters (its item names one, or one holds its handle) is drawn under the shown name on every card the build and Play draw: the item's head and strip, parents, the quoted and linked posts, a repost line, Replying to, a thread read's and a scene's tiles, a side card, the vertical cut and the chapters -- no handle beside it, no badge, a neutral avatar (the shown name's initial on the card's muted colour, never the picture), a mention of the handle in the drawn words made the pseudonym's (one word for one, so word indices hold), a reply's captured thread shot that shows them not drawn; not blurred by the card's privacy rule (redact: true still blurs). post-anon.mjs is one pass over the manifest (build-video after selectVariant, the post-item route after a take resolves); with no anonymous character the manifest is the same object, so a cut renders byte-identically; a characters.json the build cannot read or that is refused stops the build. The "not anonymised yet" wording on the Voices page, CharacterPresets, cast help, cli.md and knobs.md says what is true now. Tests on the generated card markup.

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

Diffstat:
Meditor/CHANGELOG.md | 1+
Mumtool/app/api/report/post-item/route.ts | 17+++++++++++++++--
Mumtool/components/projects/CharacterPresets.tsx | 8++++----
Mumtool/components/projects/VoicesPanel.tsx | 2+-
Mumtool/docs/cli.md | 2+-
Mumtool/docs/knobs.md | 15++++++++++++---
Mumtool/lib/cli/groups.mjs | 2+-
Mumtool/lib/cli/verbs.mjs | 2+-
Mumtool/lib/report/castCli.mjs | 2+-
Mumtool/report-to-video/build-video.mjs | 32+++++++++++++++++++++++++++++++-
Mumtool/report-to-video/cast.mjs | 4++--
Mumtool/report-to-video/package.json | 1+
Aumtool/report-to-video/post-anon.mjs | 156+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/report-to-video/post-anon.test.mjs | 140+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/post-conversation.mjs | 3+++
Mumtool/report-to-video/post-item.mjs | 35++++++++++++++++++++++++-----------
16 files changed, 394 insertions(+), 28 deletions(-)

diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## [Unreleased] +- **umtool: an anonymous character is anonymous on screen too.** An anonymous character of a video ("Anon 1") went by its shown name only on umtool's own pages: the cut's post card still showed the author's name, handle and picture. Now the build and Play draw that author under the shown name wherever a card draws them -- the item's head, the strip, the posts it answers, quotes and links, a repost line, "Replying to", a thread read's and a scene's tiles, a side card, the vertical cut, the chapters -- with no handle, no verified badge and a neutral avatar (the shown name's initial on the card's muted colour). A mention of their handle in the words the card shows becomes `@Anon_1`, and a reply's captured thread shot that shows them is not drawn. A cut with no anonymous character renders exactly as before; a `narration/characters.json` the build cannot read now stops the build rather than show a real name. What a read says is unchanged. - **umtool: the Voices page proposes characters and you accept, change or reject each.** A new "proposed" section: **Propose characters** runs the same rule as `umtool cast assign` (no model is needed or asked), each proposal shows its voice, why it was chosen and the items it would be named on, and **Accept**, **Change** (another stock voice, the name, anonymous) and **Reject** each go through the same writer as the CLI. Accepting never touches a picked read: one in another voice is listed as drift, as before. - **umtool: every post author gets a character by rule, as a proposal you accept.** Giving each author of a video a voice meant one `cast project … keep` or Voices-page click per author. `umtool cast assign <p>` now goes through every post item's author: one the item, this video, its voice map or the cast already answers for is left as it is; one with none gets a PROPOSED character of this video -- an id from the handle, their name and a stock Kokoro voice, the next in one fixed rotation (a male and a female voice in turn) that the project does not use yet. A gender hint comes only from pronouns the profile itself states; today's captures carry none, so the rotation is neutral. Proposals are kept apart in `narration/characters.json` (the same writer and undo) and change nothing until a person acts: `--accept <id>` / `--accept-all` makes the character and names it on that author's items that name none, without touching any take; `--change <id>` sets its voice (a stock one only), speed, name or anonymity; `--reject <id>` drops it. `--dry-run` writes nothing. - **umtool: a Model log shows what the model was asked, what it answered, and what the code did with it.** Until now a prompt was shown nowhere, and a local model's calls were in no ledger. Every model call of a run is now recorded, on every route (a local model, the Claude API, this session), and listed in a **Model log** panel on the run page (`/research/runs/<article>/<n>`), the article's Iterations tab and each media draft. Calls are grouped by phase (terms, reading, meaning check, grouping). A row has the first lines of what was asked, what came back, the seconds, and whether its answer was kept, dropped or rewritten, with the reason and each item's fate. A row opens to the whole prompt and answer (40,000 characters of each are kept). A log holds 20,000 calls or 32 MB; past that the panel says the log is full, and later calls are not recorded. The header counts the calls, the seconds and the models; a filter narrows to kept, dropped or rewritten; the list follows a run while it runs. `umtool model-log <article> <n>` (or `--job <jobId>`) prints the same, with `--phase`, `--outcome`, `--task`, `--run`, `--call <run.call>` for one call's whole text, and `--json`; a control sequence in a recorded text is printed as its escape (`\x1b`), never sent to the terminal. `/settings/generation` shows, per task, the route and the model it will run on, "no API key configured" when there is none, and the model of its last run. diff --git a/umtool/app/api/report/post-item/route.ts b/umtool/app/api/report/post-item/route.ts @@ -22,6 +22,8 @@ import { crossSiteRefusal } from "@/lib/report/sameOrigin.mjs"; import { withTakeScope } from "@/lib/report/takeScope.mjs"; import { isTakeId } from "@/lib/report/takes.mjs"; import { projectRedaction } from "@/lib/report/postRedaction.mjs"; +import { readProjectCharacters } from "@/lib/report/castStore.mjs"; +import { anonymiseManifest } from "umtool-report-to-video/post-anon"; export const dynamic = "force-dynamic"; @@ -60,9 +62,19 @@ const noStore = { "cache-control": "no-store" }; type Entry = Record<string, unknown> & { id: string; type?: string; media?: Array<Record<string, unknown>> }; -async function itemOf(project: { dir: string }, manifest: Record<string, unknown>, id: string, take: string | null) { +/** + * The manifest a card is drawn from, its ANONYMOUS authors under their shown names (post-anon.mjs; the build's own + * pass): this video's characters as the store reads them (a broken file reads as none here -- the build refuses it). + */ +async function anonymised(project: { dir: string }, m: Record<string, unknown>) { + const doc = (await readProjectCharacters(project.dir).catch(() => null))?.doc ?? null; + return anonymiseManifest(m, doc) as 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>; + if (anon) m = await anonymised(project, m); const tl = (Array.isArray(m.timeline) ? m.timeline : []) as Entry[]; const at = tl.findIndex((e) => e?.type === "post" && e.id === id); // `ctx`: the item before it in the cut (post-thread.mjs: a parent that is that item is carried in) and the scene its @@ -151,6 +163,7 @@ export async function GET(request: Request) { } catch (e) { return new Response(e instanceof Error ? e.message : String(e), { status: 400 }); } + m = await anonymised(r.project, m); const tl = (Array.isArray(m.timeline) ? m.timeline : []) as Entry[]; const clip = tl.find((e) => e?.type === "clip" && e.id === sideOf); const post = clip ? (sidePostOf(clip, tl) as Entry | null) : null; @@ -178,7 +191,7 @@ export async function GET(request: Request) { const id = q.get("id") ?? ""; let found; try { - found = await itemOf(r.project, r.manifest as Record<string, unknown>, id, q.get("take") || null); + found = await itemOf(r.project, r.manifest as Record<string, unknown>, id, q.get("take") || null, { anon: true }); } catch (e) { return new Response(e instanceof Error ? e.message : String(e), { status: 400 }); } diff --git a/umtool/components/projects/CharacterPresets.tsx b/umtool/components/projects/CharacterPresets.tsx @@ -14,7 +14,7 @@ import { cn } from "@/lib/utils"; // and semitones, cleaned or not, its edges trimmed or not and the room kept, and a DIRECTION // -- one line for the person reading, never sent to a model) -- the cast's or this video's own // ProjectCharacters THIS VIDEO's OWN characters (narration/characters.json): people who must not enter the pool -// (anonymous ones go by "Anon 1" … here and in recording notes; the cut's card is not anonymised yet), add one, remove one, undo, "Add to the +// (anonymous ones go by "Anon 1" … here, in recording notes and on the cut's cards), add one, remove one, undo, "Add to the // pool"; and the post items that name a character of their own // --------------------------------------------------------------------------- @@ -151,7 +151,7 @@ export function PresetEditor({ <input data-preset-name="" value={f.name} onChange={(e) => set("name", e.target.value)} maxLength={80} className={cn(input, "w-44")} /> </label> {c.anonymous && ( - <label className={lab} title="the name it goes by on this page, in `umtool cast project` and in a recording's note — the cut's on-screen card is not anonymised yet: it still shows the post's author"> + <label className={lab} title="the name it goes by on this page, in `umtool cast project`, in a recording's note and on the cut's cards (no handle, no picture)"> <span className="text-muted">shown as</span> <input data-preset-shown="" value={f.shown} onChange={(e) => set("shown", e.target.value)} maxLength={80} className={cn(input, "w-32")} /> </label> @@ -250,7 +250,7 @@ export function ProjectCharacters({ <section data-project-characters={own.length}> <h2 className="micro mb-1.5"> this video&apos;s own characters · {own.length} - <span className="ml-2 normal-case tracking-normal text-muted">people who stay out of the pool — an anonymous one goes by its shown name here and in recording notes; the cut&apos;s on-screen card is not anonymised yet</span> + <span className="ml-2 normal-case tracking-normal text-muted">people who stay out of the pool — an anonymous one goes by its shown name here, in recording notes and on the cut&apos;s cards</span> </h2> {charactersError && <p className="m-0 mb-1 text-doubt-text" data-project-characters-error="">this video&apos;s characters are not read: {charactersError}</p>} {own.length > 0 && ( @@ -260,7 +260,7 @@ export function ProjectCharacters({ <tr key={c.id} data-project-character={c.id} className={cn(open === c.id && "bg-panel-2")}> <td className={cell}> <span className="font-medium">{c.anonymous ? c.shown : c.name}</span> - {c.anonymous && <span className="ml-1.5 rounded-[3px] border border-seam-2 px-1 text-[10.5px] text-doubt-text" title={`anonymous: “${c.shown}” on this page, in cast project and in recording notes (your own label: ${c.name}) — the cut's on-screen card still shows the post's author`}>anonymous</span>} + {c.anonymous && <span className="ml-1.5 rounded-[3px] border border-seam-2 px-1 text-[10.5px] text-doubt-text" title={`anonymous: “${c.shown}” on this page, in cast project and in recording notes (your own label: ${c.name}) and on the cut's cards (no handle, no picture)`}>anonymous</span>} <span className="ml-1.5 font-mono text-[11px] text-muted">{(c.handles ?? []).map((h) => `@${h}`).join(" ")}</span> </td> <td className={cn(cell, "font-mono")}> diff --git a/umtool/components/projects/VoicesPanel.tsx b/umtool/components/projects/VoicesPanel.tsx @@ -307,7 +307,7 @@ export default function VoicesPanel({ project, posts, initialWho = null }: { pro <span className="ml-1.5 font-mono text-[11px] text-muted">{c.handles.map((h) => `@${h}`).join(" ")}</span> {c.character && c.character.layer !== "project" && <span className="ml-1.5 rounded-[3px] border border-seam-2 px-1 text-[10.5px] text-signal-text" title="in the cast: the same voice in every project">cast</span>} {c.character?.layer === "project" && <span className="ml-1.5 rounded-[3px] border border-seam-2 px-1 text-[10.5px] text-text-2" data-voices-layer="project" title="a character of this video only">this video</span>} - {c.character?.anonymous && <span className="ml-1.5 rounded-[3px] border border-seam-2 px-1 text-[10.5px] text-doubt-text" title={`anonymous: “${c.character.shown}” on this page, in cast project and in recording notes — the cut's on-screen card is not anonymised yet: it still shows the post's author`}>anonymous</span>} + {c.character?.anonymous && <span className="ml-1.5 rounded-[3px] border border-seam-2 px-1 text-[10.5px] text-doubt-text" title={`anonymous: “${c.character.shown}” on this page, in cast project, in recording notes and on the cut's cards (no handle, no picture)`}>anonymous</span>} </td> <td className={cell}> <span className="font-mono text-[12px]" data-voice-now={c.voice.spec}>{pretty(c.voice.spec)}</span> diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -24,7 +24,7 @@ Inbox cannot disagree about what is wrong with one. | `links <project> [--json] [--fix]` | do the clip QRs open on their sites? `corpus.json` → the channel's manifest → `slugToPage` → the shard's record, one request at a time, shards from the cue cache; recorded in `out/links.json`, which `check` reads (`link-dead` blocking, `links-unverified`, `links-unchecked`); `--fix` rewrites a Twitch id the site serves as `v<id>`, and a Rumble folder id (the URL slug) as the embed id the site serves (the clip gets `siteVideo`); **exit 1** when a link is dead ([knobs.md](knobs.md#do-the-qr-links-open)). The same record dates each site's deploy: a cited video newer than it is `site-deploy-behind` ([knobs.md](knobs.md#the-sites-the-links-depend-on)) | | `cast [ls] \| add <id> --name … --voice <engine:voice> [--handles a,b] [--speakers …] [--speed s] [--convert-engine e] [--convert-voice v] [--convert-pitch target\|source\|contour] [--convert-semitones n] [--enhance on\|off] [--trim on\|off] [--trim-pad ms] [--direction "…"] [--narrator] \| set <id> … \| rm <id> \| undo [--json]` | **THE CAST** (`<reports>/.umtool/cast.json`, [knobs.md](knobs.md#the-cast-each-characters-voice-in-every-project-and-the-voices-page)): the characters across projects, one writer, an undo point a write. **A character is a PRESET**, two of them ([knobs.md](knobs.md#a-character-is-a-preset)): `synthetic` -- the STOCK voice it reads in (`--voice`) and its speed (`--speed` 0.5–2; Orpheus has none) -- and `recorded` -- what a recording of them is made into: the stock voice (`--convert-voice`; a file or a recording is refused), the engine, the **pitch** the converted read lands on (`--convert-pitch`: `target` the stock voice's own, `source` the pitch it was read at, `contour` the read's rises and falls at the stock voice's register; `--convert-semitones` -12…12 moves a followed one), whether it is cleaned first (`--enhance`), its edges trimmed to speech (`--trim`, `--trim-pad` the ms kept either side) and a `--direction` (one line for the person reading, never sent to a model). `set` lays the flags given over the presets; `default` for one takes that key off; `--no-convert`, `--no-speed`. A version 1 file (`voice`, `convert` at a character's top) reads as these presets and the first write makes it version 2 (`undo` puts the old file back). A followed pitch on an engine that has none, semitones with nothing followed, a speed or a pad out of range: **exit 1** | | `cast project <project> [--json]` · `cast use <project> <character\|@handle> <voice> [--everywhere]` · `cast reread <project> <character> [--dry-run]` | a project's characters: each one's voice now (and speed) and **where it comes from** -- the chain one read asks, first hit wins: the command's flags, the item's own character (`posts character`), this video's character for the author (then its voice map), the cast's, the narrator's, the default -- what a recording of them is made into, its stale reads; this video's own characters; the items that name their own. `use`: the voice for this project (its own character's when it has one for them, else the voice map) or everywhere, and the re-reads that asks for | -| `cast project <project> add <id> [--name "…"] [--voice <engine:voice>] [--handles a,b] [--anonymous [--shown "…"]] [the preset flags]` · `set <id> … [--no-voice] [--no-anonymous]` · `rm <id>` · `undo` · `pool <id>` · `keep <character\|@handle> [--anonymous]` `[--json]` | **THIS VIDEO's OWN CHARACTERS** (`<project>/narration/characters.json`, [knobs.md](knobs.md#this-videos-own-characters-and-an-items-own)): the cast's shape and the cast's writer (a token, an undo point a write, atomic, a broken file never overwritten), for people who must not enter the pool. `--anonymous`: it goes by a **shown name** (`--shown`; default the next of `Anon 1`, `Anon 2` …) on the Voices page, in `cast project` and in a recording's note, and never enters the pool; **the on-screen card is not anonymised yet** (it still shows the post's author). `--voice` is optional here: a character with none leaves the voice to the layers under it. `narration/voices.json` keeps working under it (a handle in it reads as a character with only a synthetic voice) and is never rewritten by these. `pool <id>` (**Add to the pool**) moves one into the cast -- an anonymous one, or an id the cast has, is refused; `keep` (**Keep in this video only**) copies a cast character here (its presets changed for this video alone), or gives an author with no character one, in the voice they read in now. A refusal: **exit 1**, nothing written | +| `cast project <project> add <id> [--name "…"] [--voice <engine:voice>] [--handles a,b] [--anonymous [--shown "…"]] [the preset flags]` · `set <id> … [--no-voice] [--no-anonymous]` · `rm <id>` · `undo` · `pool <id>` · `keep <character\|@handle> [--anonymous]` `[--json]` | **THIS VIDEO's OWN CHARACTERS** (`<project>/narration/characters.json`, [knobs.md](knobs.md#this-videos-own-characters-and-an-items-own)): the cast's shape and the cast's writer (a token, an undo point a write, atomic, a broken file never overwritten), for people who must not enter the pool. `--anonymous`: it goes by a **shown name** (`--shown`; default the next of `Anon 1`, `Anon 2` …) on the Voices page, in `cast project` and in a recording's note, and never enters the pool; **the cut's cards draw them so too** -- the shown name, no handle or badge, a neutral avatar, a mention of the handle made the pseudonym's ([knobs.md](knobs.md#this-videos-own-characters-and-an-items-own)). `--voice` is optional here: a character with none leaves the voice to the layers under it. `narration/voices.json` keeps working under it (a handle in it reads as a character with only a synthetic voice) and is never rewritten by these. `pool <id>` (**Add to the pool**) moves one into the cast -- an anonymous one, or an id the cast has, is refused; `keep` (**Keep in this video only**) copies a cast character here (its presets changed for this video alone), or gives an author with no character one, in the voice they read in now. A refusal: **exit 1**, nothing written | | `cast assign <project> [--model] [--dry-run] [--json]` · `--accept <id>` · `--accept-all` · `--reject <id>` · `--reject-all` · `--change <id> [--voice <engine:voice>] [--speed s] [--name "…"] [--direction "…"] [--anonymous [--shown "…"] \| --no-anonymous]` | **AUTO-ASSIGNMENT BY RULE** ([knobs.md](knobs.md#proposed-characters-cast-assign)): every post item's author gets a character -- the item's own, this video's, its voice map's or the cast's; an author with none a **PROPOSED** character of this video: an id from the handle, their name, a STOCK Kokoro voice -- the next, in one fixed rotation (a male and a female voice in turn), that this project does not use yet; a gender hint only from the profile's own stated pronouns when the capture carries them. Proposals are kept apart in `<project>/narration/characters.json` (`proposed`; the same writer, an undo point: `cast project <p> undo`) and are **applied to nothing** -- no item, no picked read -- until a person accepts. `--accept <id>` / `--accept-all`: this video's character, named (`narration.character`) on that author's items that name none -- no take made or changed (a picked read in another voice shows as drift); `--change <id>`: its voice (a stock one only), speed, name, direction or anonymity; `--reject <id>` / `--reject-all`: dropped. A proposal whose author has a character now is dropped by the next run. `--dry-run` writes nothing. **`--model`** (on request only): the generation task `cast-assign`, routed by `settings.generation` like the other tasks, is asked per author (display name, bio, post text -- untrusted) for `{character, voice, speed, direction}`; each field is checked (a stock voice, a speed 0.5–2, one plain line, control characters stripped) and laid over the rule's row, which stays when the answer fails. Refused: **exit 1**, nothing written | | `cast audition <character\|@handle> --voices a,b,… [--project <p>] [--text "…" \| --item <id> \| --line <n> \| --stock] [--no-score \| --score-only] [--json] [--progress ndjson]` | **AN AUDITION**: one line read by 2-6 stock voices through the editor's tts op, levelled to -20 LUFS in `<p>/narration/auditions/` (cached), scored for closeness to the character's real voice (`speakers.json`; TitaNet, local) | | `speaker-check <project> [--clip <id> …] [--json] [--progress ndjson]` · `--set 'Name=<clip>,<channel>/<id>,channel:<slug>'` · `--remove <name>` · `--list` | which of the project's **named voices** (`speakers.json`) each clip is: TitaNet-small, local, against each voice's robust centroid → `<project>/speaker-check.json` (merged); the walk's **Speaker:** badge and **Check speaker** ([report-video.md](report-video.md#the-speaker-check-on-the-walk-which-of-several-voices)) | diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -1496,9 +1496,18 @@ synthetic voice), never from a preset. writer in `castStore.mjs` -- `projectCharactersWrite`: a token, an undo point a write in `characters.undo.json`, atomic, a broken file never overwritten) are the cast's shape, for people who must **not enter the pool**: they live in that video only. One may be **`anonymous: true`** with a **`shown`** name -- what the Voices page, `umtool cast -project` and a recording's note call them, never their own name. **The on-screen card is NOT anonymised yet**: a cut -still shows the post's author, so an anonymous character keeps someone out of the pool and off umtool's own surfaces, -not off the video. The default is the next unused of **"Anon 1", "Anon 2" …** (`cast.mjs` +project` and a recording's note call them, never their own name -- and **the cut's on-screen card** too +(`post-anon.mjs`, applied by the build and by Play): wherever a card draws that author -- the item's head, the strip, +a parent, the quoted or a linked post, a repost line, "Replying to", a thread read's tiles, a scene's tiles, a side +card, the vertical cut, the chapters -- it is the shown name with no handle beside it, no verified badge and a neutral +avatar (the shown name's initial on the card's muted colour, never their picture); a mention of their handle in the +words the card draws becomes the shown name's pseudonym (`@Anon_1`, one word for one); a reply's captured thread +shot is not drawn when it shows them. An anonymous author is not blurred by the card's privacy rule (the shown name +says nothing of who they are); `redact: true` still blurs them. Who: the item's own author when its +`narration.character` names an anonymous character, else any author whose handle one holds. A cut with no anonymous +character renders byte-identically to before; a `characters.json` the build cannot read or that is refused stops +the build (read as none, an anonymous character would be drawn under its own name). What the read SAYS is not +changed: that is its take and its script. The default is the next unused of **"Anon 1", "Anon 2" …** (`cast.mjs` `ANON_NAME_PATTERN`, the one place the pattern is written). A preset is optional here: a character with no synthetic voice leaves the voice to the layers under it. It has no narrator (the narrator is the cast's). `narration/voices.json` keeps working under it and is never rewritten by these commands. diff --git a/umtool/lib/cli/groups.mjs b/umtool/lib/cli/groups.mjs @@ -81,7 +81,7 @@ export const GROUPS = [ ["`cast project <project> [--json]` · `cast use <project> <character\\|@handle> <voice> [--everywhere]` · `cast reread <project> <character> [--dry-run]`", "a project's characters: each one's voice now (and speed) and **where it comes from** -- the chain one read asks, first hit wins: the command's flags, the item's own character (`posts character`), this video's character for the author (then its voice map), the cast's, the narrator's, the default -- what a recording of them is made into, its stale reads; this video's own characters; the items that name their own. `use`: the voice for this project (its own character's when it has one for them, else the voice map) or everywhere, and the re-reads that asks for"], ["`cast project <project> add <id> [--name \"…\"] [--voice <engine:voice>] [--handles a,b] [--anonymous [--shown \"…\"]] [the preset flags]` · `set <id> … [--no-voice] [--no-anonymous]` · `rm <id>` · `undo` · `pool <id>` · `keep <character\\|@handle> [--anonymous]` `[--json]`", - "**THIS VIDEO's OWN CHARACTERS** (`<project>/narration/characters.json`, [knobs.md](knobs.md#this-videos-own-characters-and-an-items-own)): the cast's shape and the cast's writer (a token, an undo point a write, atomic, a broken file never overwritten), for people who must not enter the pool. `--anonymous`: it goes by a **shown name** (`--shown`; default the next of `Anon 1`, `Anon 2` …) on the Voices page, in `cast project` and in a recording's note, and never enters the pool; **the on-screen card is not anonymised yet** (it still shows the post's author). `--voice` is optional here: a character with none leaves the voice to the layers under it. `narration/voices.json` keeps working under it (a handle in it reads as a character with only a synthetic voice) and is never rewritten by these. `pool <id>` (**Add to the pool**) moves one into the cast -- an anonymous one, or an id the cast has, is refused; `keep` (**Keep in this video only**) copies a cast character here (its presets changed for this video alone), or gives an author with no character one, in the voice they read in now. A refusal: **exit 1**, nothing written"], + "**THIS VIDEO's OWN CHARACTERS** (`<project>/narration/characters.json`, [knobs.md](knobs.md#this-videos-own-characters-and-an-items-own)): the cast's shape and the cast's writer (a token, an undo point a write, atomic, a broken file never overwritten), for people who must not enter the pool. `--anonymous`: it goes by a **shown name** (`--shown`; default the next of `Anon 1`, `Anon 2` …) on the Voices page, in `cast project` and in a recording's note, and never enters the pool; **the cut's cards draw them so too** -- the shown name, no handle or badge, a neutral avatar, a mention of the handle made the pseudonym's ([knobs.md](knobs.md#this-videos-own-characters-and-an-items-own)). `--voice` is optional here: a character with none leaves the voice to the layers under it. `narration/voices.json` keeps working under it (a handle in it reads as a character with only a synthetic voice) and is never rewritten by these. `pool <id>` (**Add to the pool**) moves one into the cast -- an anonymous one, or an id the cast has, is refused; `keep` (**Keep in this video only**) copies a cast character here (its presets changed for this video alone), or gives an author with no character one, in the voice they read in now. A refusal: **exit 1**, nothing written"], ["`cast assign <project> [--model] [--dry-run] [--json]` · `--accept <id>` · `--accept-all` · `--reject <id>` · `--reject-all` · `--change <id> [--voice <engine:voice>] [--speed s] [--name \"…\"] [--direction \"…\"] [--anonymous [--shown \"…\"] \\| --no-anonymous]`", "**AUTO-ASSIGNMENT BY RULE** ([knobs.md](knobs.md#proposed-characters-cast-assign)): every post item's author gets a character -- the item's own, this video's, its voice map's or the cast's; an author with none a **PROPOSED** character of this video: an id from the handle, their name, a STOCK Kokoro voice -- the next, in one fixed rotation (a male and a female voice in turn), that this project does not use yet; a gender hint only from the profile's own stated pronouns when the capture carries them. Proposals are kept apart in `<project>/narration/characters.json` (`proposed`; the same writer, an undo point: `cast project <p> undo`) and are **applied to nothing** -- no item, no picked read -- until a person accepts. `--accept <id>` / `--accept-all`: this video's character, named (`narration.character`) on that author's items that name none -- no take made or changed (a picked read in another voice shows as drift); `--change <id>`: its voice (a stock one only), speed, name, direction or anonymity; `--reject <id>` / `--reject-all`: dropped. A proposal whose author has a character now is dropped by the next run. `--dry-run` writes nothing. **`--model`** (on request only): the generation task `cast-assign`, routed by `settings.generation` like the other tasks, is asked per author (display name, bio, post text -- untrusted) for `{character, voice, speed, direction}`; each field is checked (a stock voice, a speed 0.5–2, one plain line, control characters stripped) and laid over the rule's row, which stays when the answer fails. Refused: **exit 1**, nothing written"], ["`cast audition <character\\|@handle> --voices a,b,… [--project <p>] [--text \"…\" \\| --item <id> \\| --line <n> \\| --stock] [--no-score \\| --score-only] [--json] [--progress ndjson]`", diff --git a/umtool/lib/cli/verbs.mjs b/umtool/lib/cli/verbs.mjs @@ -150,7 +150,7 @@ export const VERBS = Object.freeze([ // This video's OWN characters (<project>/narration/characters.json; castStore.mjs: one writer, an undo point a write). form("cast project add", "project", "a character of this video only (anonymous: shown under Anon 1 …)", [ project(), arg("id"), opt("--name", { help: "required unless --anonymous" }), opt("--voice", { help: "engine:voice (none: the layers under it)" }), opt("--handles", { help: "a,b" }), - bool("--anonymous", "goes by a shown name on umtool's pages; never enters the pool (the cut's card is not anonymised yet)"), opt("--shown", { help: "the shown name (default: the next Anon n)" }), ...presetArgs(), opt("--note"), + bool("--anonymous", "goes by a shown name on umtool's pages and on the cut's cards (no handle, no picture); never enters the pool"), opt("--shown", { help: "the shown name (default: the next Anon n)" }), ...presetArgs(), opt("--note"), ], { shape: "cast project <project> add <id>" }), form("cast project set", "project", "change a character of this video's", [ project(), arg("id"), opt("--name"), opt("--voice", { help: "engine:voice" }), opt("--handles"), opt("--shown"), ...presetArgs(), opt("--note"), opt("--add-handle"), opt("--remove-handle"), diff --git a/umtool/lib/report/castCli.mjs b/umtool/lib/report/castCli.mjs @@ -77,7 +77,7 @@ export const CAST_USAGE = [ " project <p> add|set|rm|undo: THIS VIDEO's OWN characters (<p>/narration/characters.json, one writer, an undo", " point per write) -- the same shape, for people who must not enter the pool. --anonymous: it goes by a SHOWN NAME", ` (--shown; default the next of "${ANON_NAME_PATTERN.replace("{n}", "1")}", "${ANON_NAME_PATTERN.replace("{n}", "2")}" …) on the Voices page, in cast project and in a recording's note, and never`, - " enters the pool. The cut's ON-SCREEN CARD IS NOT ANONYMISED YET: it still shows the post's author. --voice is optional", + " enters the pool -- and THE CUT's CARDS draw them so too: the shown name, no handle, a neutral avatar. --voice is optional", " here: a character with none leaves the voice to the layers under it. pool <id>: it moves into the cast (an", " anonymous one is refused). keep <character|@handle>: a cast character copied here (its presets changed for this", " video only), or an author with no character given one here, in the voice they read in now.", diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs @@ -252,6 +252,8 @@ function postJoinFrom(timeline, id, render, groups, depth = 0) { import { readPostRedaction } from "./post-redact-files.mjs"; import { dropMarks, redactEntry } from "./post-redact.mjs"; import { avatarUrls } from "./post-avatars.mjs"; +import { anonymiseManifest } from "./post-anon.mjs"; +import { PROJECT_CHARACTERS_FILE, validateProjectCharacters } from "./cast.mjs"; import { applyPostCombo } from "./post-combo-render.mjs"; import { projectCombos } from "./post-combo-prints.mjs"; import { mediaSceneById, sceneEntry } from "./post-media-scene.mjs"; @@ -6588,6 +6590,31 @@ export async function prepareLocalMedia(timeline, manifestDir, render = {}) { if (errors.length) throw new Error(`manifest: ${errors.join("; ")}`); } +/** + * The project's own characters (cast.mjs PROJECT_CHARACTERS_FILE) beside a manifest, for the anonymising pass: null + * with none. A file that does not parse or is refused STOPS the build -- read as none, an anonymous character would + * be drawn under the name it must not show. + */ +export async function readProjectCharactersFor(manifestDir) { + const file = path.join(manifestDir, ...PROJECT_CHARACTERS_FILE.split("/")); + let text; + try { + text = await readFile(file, "utf8"); + } catch (e) { + if (e?.code === "ENOENT") return null; + throw new Error(`${PROJECT_CHARACTERS_FILE} cannot be read (${e?.message ?? e}): an anonymous character could be drawn under its own name -- fix it first`); + } + let doc; + try { + doc = JSON.parse(text); + } catch (e) { + throw new Error(`${PROJECT_CHARACTERS_FILE} is not JSON (${e instanceof Error ? e.message : e}): an anonymous character could be drawn under its own name -- fix it first (umtool cast project <p> undo)`); + } + const errors = validateProjectCharacters(doc, PROJECT_CHARACTERS_FILE); + if (errors.length) throw new Error(`${PROJECT_CHARACTERS_FILE} is refused (${errors.join("; ")}): an anonymous character could be drawn under its own name -- fix it first (umtool cast project <p> undo)`); + return doc; +} + export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly } = {}) { const variant = opts.variant ?? "sourced"; // A vertical short (`--short <id>`, release 36 lane C) is that one clip, @@ -6609,7 +6636,10 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly const ruled = opts.noRulings ? { manifest: whole, left: [], matched: [], renumbered: false } : applyMontageRulings(whole, await readMontageRulings(manifestDir), { keep: only ? [only] : [] }); - const manifest = selectVariant(ruled.manifest, variant); + // ON-SCREEN ANONYMISING (post-anon.mjs): an author who is one of this video's anonymous characters is drawn under + // the shown name on every card below -- the cut, the vertical cut, a side card, the chapters. No anonymous + // character: the manifest as it was. + const manifest = anonymiseManifest(selectVariant(ruled.manifest, variant), await readProjectCharactersFor(manifestDir)); // THE BASIC OUTPUT MODE (render.mode, basic.mjs): the footage alone. Every // render of the cut gets it -- a take, `umtool build`, this CLI -- because the // mode is read here, off the manifest every layer resolved into. The runs diff --git a/umtool/report-to-video/cast.mjs b/umtool/report-to-video/cast.mjs @@ -34,7 +34,7 @@ // PROJECT_CHARACTERS_FORMAT; the same store) are the same shape, with no // narrator and with `anonymous: true` + `shown` ("Anon 1") for a person who // must not enter the pool: they live in that video only. (The shown name is -// what umtool's own surfaces call them; the cut's card is not anonymised yet.) +// what umtool's own surfaces call them, and what the cut's cards draw them as: post-anon.mjs.) // // A project's `narration/voices.json` (post-say.mjs) stays the project's // OVERRIDE LAYER (a handle in it reads as a project character with only a @@ -374,7 +374,7 @@ export function projectCharactersOf(doc) { /** * The name a character goes by where umtool names it (the Voices page, `umtool cast project`, a recording's note): an - * anonymous one's `shown` name, never its own. The cut's on-screen card does NOT ask this yet: it shows the post's author. + * anonymous one's `shown` name, never its own -- the cut's on-screen card too (post-anon.mjs). */ export const shownNameOf = (c) => (c?.anonymous === true ? str(c.shown).trim() || ANON_NAME_PATTERN.replace("{n}", "1") : str(c?.name)); diff --git a/umtool/report-to-video/package.json b/umtool/report-to-video/package.json @@ -88,6 +88,7 @@ "./post-say": "./post-say.mjs", "./cast": "./cast.mjs", "./cast-assign": "./cast-assign.mjs", + "./post-anon": "./post-anon.mjs", "./post-redact-files": "./post-redact-files.mjs", "./post-slurs": "./post-slurs.mjs", "./post-thread": "./post-thread.mjs", diff --git a/umtool/report-to-video/post-anon.mjs b/umtool/report-to-video/post-anon.mjs @@ -0,0 +1,156 @@ +// ON-SCREEN ANONYMISING (characters C3; knobs.md, "This video's own characters, and an item's own"): an author who is +// one of the project's ANONYMOUS characters (`<project>/narration/characters.json`, `anonymous: true` + `shown`) is +// drawn under the shown name wherever a post card draws an author -- the item's own head, the strip, the posts it +// answers, quotes and links, a repost line, "Replying to", a thread read's tiles, a scene's tiles, a side card, the +// vertical cut -- with the handle replaced by a pseudonym made from the shown name (no "@handle" beside the name), +// its verified badge dropped and its avatar a neutral one (the shown name's initial on the card's muted colour, +// post-item.mjs avatarHtml): never their picture. A reply whose author, or whose parent, is anonymous loses its +// captured thread shot (a picture of the real names) -- the card's own "Replying to" line stands in. +// +// Who is anonymous: the item's OWN author when its `narration.character` names an anonymous character of this video, +// else any author whose handle an anonymous character of this video holds. The cast never holds anonymous ones. +// +// The pass is made ONCE on the manifest a build (build-video.mjs) or a preview (the app's post-item route) reads, +// after a take's manifest is resolved, so every surface below it draws the same thing. With no anonymous character +// the manifest is returned AS IT IS (the same object): a cut with none renders byte-identically. +// +// A MENTION of an anonymous author's handle in the words the card draws ("@realhandle said …": the post's own, its +// parents', the quoted post's, the linked posts') becomes the pseudonym's ("@Anon_1") -- one word for one, so every +// word index (a word zoom's, the read-follow's) is the same. An anonymous author is not blurred by the card's +// privacy rule (post-item.mjs authorRedaction: the shown name says nothing of who they are); `redact: true` still is. +// What it does not touch: a take, its script, or anything the read SAYS -- only what the card draws. +// +// PURE and dependency-free (beyond cast.mjs / post-say.mjs). +import { projectCharactersOf, shownNameOf } from "./cast.mjs"; +import { handleKey } from "./post-say.mjs"; + +const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v); +const str = (v) => (typeof v === "string" ? v : ""); + +/** The handle an anonymous author is drawn under: the shown name as a handle ("Anon 1" -> "Anon_1"). */ +export const pseudonymOf = (shown) => str(shown).replace(/[^A-Za-z0-9_]+/g, "_").replace(/^_+|_+$/g, "").slice(0, 64) || "anon"; + +/** + * A project's anonymous characters as the pass reads them: `{ byHandle: Map<handle, shown>, byId: Map<id, shown> }` + * (characters.json's document; null or none: both empty). + */ +export function anonymousOf(doc) { + const byHandle = new Map(); + const byId = new Map(); + for (const c of projectCharactersOf(doc)) { + if (c.anonymous !== true) continue; + const shown = shownNameOf(c); + byId.set(c.id, shown); + for (const h of c.handles ?? []) if (!byHandle.has(h)) byHandle.set(h, shown); + } + return { byHandle, byId }; +} + +/** An author object (`{ author, handle, badge? … }`) drawn as `shown`: the shown name, the pseudonym, no badge, marked `anonymous`. */ +function asAnon(who, shown) { + const { badge: _b, ...rest } = who; + return { ...rest, author: shown, handle: pseudonymOf(shown), anonymous: true }; +} + +const escRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + +/** `text` with every @mention of an anonymous handle made its pseudonym's (one word for one); the same string when none is. */ +export function anonymiseMentions(text, byHandle) { + if (typeof text !== "string" || !text.includes("@") || !byHandle?.size) return text; + let out = text; + for (const [h, shown] of byHandle) out = out.replace(new RegExp(`@${escRe(h)}(?![A-Za-z0-9_])`, "gi"), `@${pseudonymOf(shown)}`); + return out; +} + +/** A post or a ref with the mentions in its words made pseudonyms (its `text`, its `paraphrase`); the object itself when none changed. */ +function withMentions(o, byHandle) { + if (!isObj(o)) return o; + let out = o; + for (const k of ["text", "paraphrase"]) { + const v = anonymiseMentions(o[k], byHandle); + if (v !== o[k]) out = { ...(out === o ? o : out), [k]: v }; + } + return out; +} + +/** + * ONE POST ITEM with its anonymous authors drawn under their shown names (pure; see the head). Returns the entry + * itself when nothing in it is anonymous. + * + * @param {Record<string, any>} e + * @param {{ byHandle: Map<string, string>, byId: Map<string, string> }} anon + */ +export function anonymiseEntry(e, anon) { + if (e?.type !== "post" || (!anon?.byHandle?.size && !anon?.byId?.size)) return e; + const of = (h) => anon.byHandle.get(handleKey(h)) ?? null; + const ownId = str(e.narration?.character).trim().toLowerCase(); + const own = ownId ? anon.byId.get(ownId) ?? null : null; + // An item that names a character of its own is that character; one that names none, its handle's. + const ownShown = ownId ? own : of(e.handle); + let out = null; + const edit = () => (out ??= { ...e }); + if (ownShown) { + const o = edit(); + o.author = ownShown; + o.handle = pseudonymOf(ownShown); + o.anonymous = true; + delete o.badge; + } + const refs = (list) => { + if (!Array.isArray(list)) return list; + let changed = false; + const next = list.map((p) => { + const s = isObj(p) ? of(p.handle) : null; + if (!s) return p; + changed = true; + return asAnon(p, s); + }); + return changed ? next : list; + }; + const parents = refs(e.parents); + if (parents !== e.parents) edit().parents = parents; + const links = refs(e.links); + if (links !== e.links) edit().links = links; + if (isObj(e.quoted) && of(e.quoted.handle)) edit().quoted = asAnon(e.quoted, of(e.quoted.handle)); + if (isObj(e.repostedBy) && of(e.repostedBy.handle)) edit().repostedBy = asAnon(e.repostedBy, of(e.repostedBy.handle)); + const replyShown = str(e.replyingTo) ? of(e.replyingTo) : null; + if (replyShown) edit().replyingTo = pseudonymOf(replyShown); + // The subjects name handles: an anonymous one is its pseudonym there too (the card's subject accent still finds it). + if (Array.isArray(e.subjects) && e.subjects.some((h) => of(h) || (ownShown && handleKey(h) === handleKey(e.handle)))) { + edit().subjects = e.subjects.map((h) => (ownShown && handleKey(h) === handleKey(e.handle) ? pseudonymOf(ownShown) : of(h) ? pseudonymOf(of(h)) : h)); + } + // The mentions in the words the card draws. + const own2 = withMentions(out ?? e, anon.byHandle); + if (own2 !== (out ?? e)) out = own2; + for (const k of ["parents", "links"]) { + const list = (out ?? e)[k]; + if (!Array.isArray(list)) continue; + const next = list.map((p) => withMentions(p, anon.byHandle)); + if (next.some((p, i) => p !== list[i])) edit()[k] = next; + } + if (isObj((out ?? e).quoted)) { + const q = withMentions((out ?? e).quoted, anon.byHandle); + if (q !== (out ?? e).quoted) edit().quoted = q; + } + // A captured thread shot is a picture of the real names: not drawn for an anonymous reply or one to an anonymous author. + if (typeof e.parentShot === "string" && (ownShown || replyShown || (Array.isArray(parents) && parents.some((p) => p?.anonymous === true)))) delete edit().parentShot; + return out ?? e; +} + +/** + * A MANIFEST with every post item's anonymous authors drawn under their shown names (anonymiseEntry), or the same + * object when the project has no anonymous character or no item has one. `doc`: characters.json's document. + */ +export function anonymiseManifest(manifest, doc) { + const anon = anonymousOf(doc); + if (!anon.byHandle.size && !anon.byId.size) return manifest; + const tl = Array.isArray(manifest?.timeline) ? manifest.timeline : null; + if (!tl) return manifest; + let changed = false; + const timeline = tl.map((e) => { + const n = anonymiseEntry(e, anon); + if (n !== e) changed = true; + return n; + }); + return changed ? { ...manifest, timeline } : manifest; +} diff --git a/umtool/report-to-video/post-anon.test.mjs b/umtool/report-to-video/post-anon.test.mjs @@ -0,0 +1,140 @@ +// On-screen anonymising (post-anon.mjs; post-item.mjs avatarHtml/nameHtml; build-video.mjs readProjectCharactersFor): +// an anonymous character of this video is drawn under its shown name on the card -- its head, the strip, a parent, the +// quoted post, "Replying to", a thread read's tiles, a scene's tile -- with no handle, no badge and a neutral avatar; +// a card with none is byte-identical to before. +// +// Run: node --test umtool/report-to-video/post-anon.test.mjs +import assert from "node:assert/strict"; +import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import { after, test } from "node:test"; +import { anonymiseEntry, anonymiseManifest, anonymousOf, pseudonymOf } from "./post-anon.mjs"; +import { postCardHtml, sceneTileHtml } from "./post-item.mjs"; +import { sceneRefOf } from "./post-conversation.mjs"; +import { readProjectCharactersFor } from "./build-video.mjs"; + +const TMP = await mkdtemp(path.join(tmpdir(), "umtool-post-anon-")); +after(() => rm(TMP, { recursive: true, force: true })); + +const doc = { + format: "umtool-project-characters", version: 1, + characters: [ + { id: "anon-1", name: "Jane Real", anonymous: true, shown: "Anon 1", handles: ["janereal"] }, + { id: "anon-2", name: "Reply Guy", anonymous: true, shown: "A reply", handles: [] }, + { id: "host", name: "Host", handles: ["host"], synthetic: { voice: "kokoro:am_adam" } }, + ], +}; +const card = (e, o = {}) => postCardHtml(e, { width: 1280, height: 720, avatars: { janereal: "assets/jane.jpg", host: "assets/host.jpg", other: "assets/other.jpg" }, ...o }); +const base = (o = {}) => ({ type: "post", id: "p1", post: "chan/1", platform: "x", author: "Jane Real", handle: "janereal", badge: "blue", date: "2026-10-30T10:00:00.000Z", text: "my words here", ...o }); +const leaks = (html) => ["Jane Real", "janereal", "assets/jane.jpg", "Reply Guy"].filter((s) => html.includes(s)); + +test("the pass: the shown name, a pseudonym for the handle, no badge; nothing anonymous -- the same object", () => { + assert.equal(pseudonymOf("Anon 1"), "Anon_1"); + assert.equal(pseudonymOf(" !! "), "anon"); + const anon = anonymousOf(doc); + assert.deepEqual([...anon.byHandle], [["janereal", "Anon 1"]]); + assert.deepEqual([...anon.byId], [["anon-1", "Anon 1"], ["anon-2", "A reply"]]); + const e = anonymiseEntry(base(), anon); + assert.deepEqual([e.author, e.handle, e.anonymous, e.badge], ["Anon 1", "Anon_1", true, undefined]); + const host = base({ author: "Host", handle: "host" }); + assert.equal(anonymiseEntry(host, anon), host, "not anonymous: the entry itself"); + const m = { render: {}, timeline: [host, { type: "clip", id: "c1" }] }; + assert.equal(anonymiseManifest(m, doc), m, "no anonymous author in it: the manifest itself"); + assert.equal(anonymiseManifest(m, null), m); + const m2 = { render: {}, timeline: [host, base({ id: "p2" })] }; + const out = anonymiseManifest(m2, doc); + assert.notEqual(out, m2); + assert.equal(out.timeline[0], host, "the others untouched"); + assert.equal(m2.timeline[1].author, "Jane Real", "a copy: the manifest read is not changed"); + // An item that names an anonymous character of its own is that character, whatever its handle. + const named = anonymiseEntry(base({ author: "Host", handle: "host", narration: { character: "anon-2" } }), anon); + assert.deepEqual([named.author, named.handle], ["A reply", "A_reply"]); + // An item that names a NON-anonymous character is not anonymised by its handle either. + assert.equal(anonymiseEntry(base({ narration: { character: "host" } }), anon).author, "Jane Real"); +}); + +test("the card: the shown name alone, a neutral avatar (never the picture), the rule only on a page that draws one", () => { + const anon = anonymousOf(doc); + const html = card(anonymiseEntry(base(), anon)); + assert.deepEqual(leaks(html), []); + assert.match(html, /data-post-anon=""><span class="name">Anon 1<\/span><\/span>/); + assert.ok(!/class="handle"/.test(html), "no @handle beside the name"); + assert.match(html, /class="avatar anon" data-post-avatar="anon"[^>]*>A<\/div>/, "the shown name's initial"); + assert.match(html, /\.avatar\.anon \{ background: #a2957f !important;/, "the card's muted colour"); + // Not anonymous: no rule, the picture -- and the same bytes as an entry that never went through the pass. + const host = base({ author: "Host", handle: "host" }); + const plain = card(host); + assert.ok(!plain.includes(".avatar.anon")); + assert.match(plain, /data-post-avatar="image"/); + assert.equal(card(anonymiseEntry(host, anon)), plain, "byte-identical"); + // Redacted wins: the bars, as before. + const red = card(anonymiseEntry(base({ subjects: ["host"], redact: true }), anon)); + assert.match(red, /data-post-avatar="redacted"/); +}); + +test("context: a parent, the quoted post, a repost, Replying to; a captured thread shot of an anonymous reply is not drawn", () => { + const anon = anonymousOf(doc); + const reply = base({ + author: "Host", handle: "host", + parents: [{ id: "9", handle: "JaneReal", author: "Jane Real", badge: "gold", date: "2026-10-30T09:00:00.000Z", text: "the question" }], + quoted: { id: "8", handle: "janereal", author: "Jane Real", text: "quoted words" }, + }); + const e = anonymiseEntry(reply, anon); + assert.equal(e.author, "Host"); + assert.deepEqual([e.parents[0].author, e.parents[0].handle, e.parents[0].badge, e.parents[0].anonymous], ["Anon 1", "Anon_1", undefined, true]); + assert.equal(e.quoted.author, "Anon 1"); + const html = card(e); + assert.deepEqual(leaks(html), []); + assert.equal((html.match(/data-post-avatar="anon"/g) ?? []).length, 2, "the parent's and the quoted post's"); + assert.match(html, /data-post-avatar="image"/, "his own picture stays"); + const r2 = anonymiseEntry(base({ author: "Host", handle: "host", replyingTo: "janereal", parentShot: "posts-media/x/1/shot-thread.png", repostedBy: { handle: "janereal", author: "Jane Real" } }), anon); + assert.equal(r2.parentShot, undefined, "the shot shows the real names"); + assert.equal(r2.replyingTo, "Anon_1"); + const h2 = card(r2, { parentShotUrl: null }); + assert.deepEqual(leaks(h2), []); + assert.match(h2, /Replying to <span class="mention">@Anon_1<\/span>/); + assert.match(h2, /Anon 1 reposted/); + // A mention of the real handle in the words: the pseudonym, one word for one; forced redaction still blurs. + const m = anonymiseEntry(base({ author: "Host", handle: "host", text: "thanks @JaneReal, and @janereals is someone else", parents: [{ id: "9", handle: "x1", author: "X", text: "cc @janereal" }] }), anon); + assert.equal(m.text, "thanks @Anon_1, and @janereals is someone else"); + assert.equal(m.parents[0].text, "cc @Anon_1"); + assert.equal(m.text.split(/\s+/).length, "thanks @JaneReal, and @janereals is someone else".split(/\s+/).length); + assert.match(card(anonymiseEntry(reply, anon)), /Anon 1/); + const forced = card(anonymiseEntry({ ...reply, redact: true }, anon)); + assert.ok(!forced.includes('data-post-avatar="anon"'), "redact: true blurs them all"); + assert.deepEqual(leaks(forced), []); + // His own reply anonymous: his thread shot goes too. + assert.equal(anonymiseEntry(base({ parentShot: "posts-media/x/1/shot-thread.png" }), anon).parentShot, undefined); + assert.equal(anonymiseEntry(base({ author: "Host", handle: "host", parentShot: "s.png" }), anon).parentShot, "s.png"); +}); + +test("a thread read's tiles and a scene's tile draw the shown name too", () => { + const anon = anonymousOf(doc); + const e = anonymiseEntry(base({ author: "Host", handle: "host", parents: [{ id: "9", handle: "janereal", author: "Jane Real", date: "2026-10-30T09:00:00.000Z", text: "the question asked" }] }), anon); + const html = card(e, { follow: true, thread: { tiles: [{ scope: "parent:0", mode: "full" }, { scope: "post", mode: "full" }] } }); + assert.match(html, /data-post-thread=/, "the threaded card"); + assert.deepEqual(leaks(html), []); + assert.match(html, /data-thread-tile="parent:0"[^]*data-post-avatar="anon"/); + // A scene (post-conversation.mjs): the ref of an anonymous item stays anonymous on the next item's card. + const own = anonymiseEntry(base(), anon); + const ref = sceneRefOf(own, "post"); + assert.equal(ref.anonymous, true); + assert.equal(sceneRefOf(base({ author: "Host", handle: "host" }), "post").anonymous, undefined, "not anonymous: the ref as before"); + assert.equal(sceneRefOf(e, "parent:0").anonymous, true); + const tile = sceneTileHtml({ scope: "scene:p1", mode: "scene", entry: own }, { k: 1, pal: { accent: "#c8752a", muted: "#a2957f" }, size: () => 30, avatars: { janereal: "assets/jane.jpg" } }); + assert.deepEqual(leaks(tile), []); + assert.match(tile, /data-post-avatar="anon"/); +}); + +test("the build reads this video's characters beside the manifest: none is none; a broken or refused file stops it", async () => { + const dir = path.join(TMP, "p"); + await mkdir(path.join(dir, "narration"), { recursive: true }); + assert.equal(await readProjectCharactersFor(dir), null); + await writeFile(path.join(dir, "narration", "characters.json"), JSON.stringify(doc)); + assert.deepEqual(await readProjectCharactersFor(dir), doc); + await writeFile(path.join(dir, "narration", "characters.json"), "{ not json"); + await assert.rejects(readProjectCharactersFor(dir), /not JSON.*drawn under its own name/); + await writeFile(path.join(dir, "narration", "characters.json"), JSON.stringify({ ...doc, characters: [{ id: "BAD", name: "x" }] })); + await assert.rejects(readProjectCharactersFor(dir), /is refused/); +}); diff --git a/umtool/report-to-video/post-conversation.mjs b/umtool/report-to-video/post-conversation.mjs @@ -229,6 +229,8 @@ export function sceneRefOf(e, scope) { id: shownIdOf(e), author: str(e?.author) || undefined, handle: str(e?.handle) || undefined, + // An anonymous author (post-anon.mjs) stays one in another item's scene. + ...(e?.anonymous === true ? { anonymous: true } : {}), date: str(e?.date) || undefined, text: cardText(e), redact: authors.find((a) => a.where === "author")?.redact === true, @@ -245,6 +247,7 @@ export function sceneRefOf(e, scope) { id: str(p.id), author: str(p.author) || undefined, handle: str(p.handle) || undefined, + ...(p.anonymous === true ? { anonymous: true } : {}), date: str(p.date) || undefined, ...(p.badge ? { badge: p.badge } : {}), text: contextText(p), diff --git a/umtool/report-to-video/post-item.mjs b/umtool/report-to-video/post-item.mjs @@ -545,11 +545,14 @@ export function mediaTimeAt(step, s) { * * and `redact: true` blurs even those. An author the archive does not name * is blurred. The words of the post stay: what was said is the evidence; - * who a private person is, is not. + * who a private person is, is not. An ANONYMOUS author (post-anon.mjs: drawn + * under a shown name, "Anon 1", with no handle or picture of theirs) is not + * blurred by this rule -- the shown name says nothing of who they are; + * `redact: true` still blurs them. * - * @param {{ handle?: string|null, badge?: string|null }} who + * @param {{ handle?: string|null, badge?: string|null, anonymous?: boolean }} who * @param {{ subjects?: string[], redact?: boolean }} [o] - * @returns {{ redact: boolean, reason: "off"|"forced"|"subject"|"verified"|"blue-check"|"private"|"unknown" }} + * @returns {{ redact: boolean, reason: "off"|"forced"|"subject"|"anonymous"|"verified"|"blue-check"|"private"|"unknown" }} */ export function authorRedaction(who, { subjects = [], redact = undefined } = {}) { const same = (a, b) => !!a && !!b && String(a).replace(/^@/, "").toLowerCase() === String(b).replace(/^@/, "").toLowerCase(); @@ -557,6 +560,7 @@ export function authorRedaction(who, { subjects = [], redact = undefined } = {}) if (redact === false) return { redact: false, reason: "off" }; if (handle && subjects.some((s) => same(s, handle))) return { redact: redact === true, reason: redact === true ? "forced" : "subject" }; if (redact === true) return { redact: true, reason: "forced" }; + if (who?.anonymous === true) return { redact: false, reason: "anonymous" }; if (!handle) return { redact: true, reason: "unknown" }; if (who?.badge === "gold" || who?.badge === "grey") return { redact: false, reason: "verified" }; if (who?.badge === "blue") return { redact: true, reason: "blue-check" }; @@ -582,7 +586,7 @@ export function cardAuthors(entry) { const o = { subjects, redact: typeof entry?.redact === "boolean" ? entry.redact : undefined }; const out = []; // The post's own author, when the item names its subjects and it is not one (a repost of somebody else's post). - if (Array.isArray(entry?.subjects)) out.push({ where: "author", handle: str(entry.handle) || null, ...authorRedaction({ handle: entry.handle, badge: entry.badge }, o) }); + if (Array.isArray(entry?.subjects)) out.push({ where: "author", handle: str(entry.handle) || null, ...authorRedaction({ handle: entry.handle, badge: entry.badge, ...(entry.anonymous === true ? { anonymous: true } : {}) }, o) }); parentsOf(entry).forEach((p, i) => out.push({ where: `parents[${i}]`, handle: str(p.handle) || null, ...authorRedaction(p, o) })); if (isObj(entry?.quoted)) out.push({ where: "quoted", handle: str(entry.quoted.handle) || null, ...authorRedaction(entry.quoted, o) }); linksOf(entry).forEach((p, i) => out.push({ where: `links[${i}]`, handle: str(p.handle) || null, ...authorRedaction(p, o) })); @@ -1126,20 +1130,26 @@ export function avatarUrlOf(avatars, handle) { /** * An author's round avatar: their picture when one is known (`img`), else the * initial on a colour of their handle. A REDACTED author never shows a - * picture -- a blurred stand-in, whatever is known. + * picture -- a blurred stand-in, whatever is known. An ANONYMOUS one + * (post-anon.mjs: one of the project's anonymous characters) never shows + * theirs either: the shown name's initial on the card's muted colour + * (`.avatar.anon`, the page's rule). */ export function avatarHtml(who, { redact, size, accent, img = null }) { const name = str(who?.author) || str(who?.handle) || "?"; const initial = esc((name.replace(/^@/, "")[0] ?? "?").toUpperCase()); + const anon = !redact && who?.anonymous === true; const bg = accent ?? `hsl(${hueOf(who?.handle)}, 38%, 42%)`; - const pic = !redact && typeof img === "string" && img; + const pic = !redact && !anon && typeof img === "string" && img; const inner = redact ? "" : pic ? `<img src="${esc(img)}" alt="" style="width:100%;height:100%;border-radius:50%;object-fit:cover;display:block">` : initial; - return `<div class="avatar${redact ? " redact" : ""}" data-post-avatar="${redact ? "redacted" : pic ? "image" : "initial"}" style="width:${size}px;height:${size}px;font-size:${Math.round(size * 0.46)}px;background:${bg}">${inner}</div>`; + return `<div class="avatar${redact ? " redact" : anon ? " anon" : ""}" data-post-avatar="${redact ? "redacted" : anon ? "anon" : pic ? "image" : "initial"}" style="width:${size}px;height:${size}px;font-size:${Math.round(size * 0.46)}px;background:${bg}">${inner}</div>`; } export function nameHtml(who, { redact, cls = "" }) { if (redact) return `<span class="who ${cls}"><span class="name redact">xxxxxxxxxxxx</span> <span class="handle redact">@xxxxxxxx</span></span>`; const h = str(who?.handle).replace(/^@/, ""); + // An anonymous author (post-anon.mjs) is the shown name alone: no handle beside it. + if (who?.anonymous === true) return `<span class="who ${cls}" data-post-anon=""><span class="name">${esc(str(who?.author) || h)}</span></span>`; return `<span class="who ${cls}"><span class="name">${esc(str(who?.author) || h)}</span>${h ? ` <span class="handle">@${esc(h)}</span>` : ""}</span>`; } @@ -1257,7 +1267,7 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p }; const menSize = Math.round(22 * k); 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 }; + const own = { author: entry.author, handle: entry.handle, ...(entry.anonymous === true ? { anonymous: true } : {}) }; const ownRed = red("author"); const strip = phase === "media" && L.mode === "stack"; const e = entry.engagement ?? {}; @@ -1338,7 +1348,7 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p const sz = fin(join?.size) ? join.size : sizeFor(contextText(p) || " ", innerW, innerH - 170 * k); // A PICTURE-ONLY post carried in keeps its picture, drawn as the item before drew it (post-picture.mjs). const pictured = scenePictureOf(p, scope); - const own2 = { author: p.author, handle: p.handle }; + const own2 = { author: p.author, handle: p.handle, ...(p.anonymous === true ? { anonymous: true } : {}) }; const headP = `<div class="head"${r ? ' data-redacted=""' : ""}>${avatarHtml(own2, { redact: r, size: Math.round(64 * k), accent: r ? undefined : pal.accent, img: r ? null : pic(p) })}<div class="hwho">${nameHtml(own2, { redact: r, cls: "big" })}<div class="date">${esc(cardDate(p.date))}</div></div><div class="mark">${esc(PLATFORM_NAME[entry.platform] ?? "")}</div></div>`; tileHtml.push(`<div class="tslot" data-thread-slot="${esc(scope)}"${slotAttr}><div class="tile tpost tcarry${join?.plain ? " tplain" : ""}" data-thread-tile="${esc(scope)}" data-thread-mode="${mode}" ${attr} data-join-anchor="">${relationHtml(t0(scope))}${!join?.plain && fin(join?.headSize) ? headP.replace('<div class="head"', `<div class="head" style="font-size:${join.headSize}px"`) : headP}<div class="twords${pictured ? " pmen" : ""}" style="font-size:${pictured ? menSize : sz}px">${wordsHtml(contextText(p), r && p.handle ? [...blurred, p.handle] : blurred)}</div>${pictured ? picIn(scope, pictured, innerW, Math.round(innerH * 0.62)) : ""}</div></div>`); }; @@ -1415,6 +1425,8 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p // part reads (links are never read: post-narration.mjs dropUrls). const tc = threaded ? threadCard(L.card) : null; const body = strip ? `${stripHtml}${slot}` : `${tc ? tc.html : card(L.card)}${slot}`; + // An anonymous author's neutral avatar (avatarHtml): its rule only on a page that draws one -- every other page as it was. + const anyAnon = body.includes('data-post-avatar="anon"'); const minSize = tc ? size : follow ? longRead ?? followMin : Math.round(POST_TEXT_SIZES[POST_TEXT_SIZES.length - 1] * k); // A status link is marked (`data-link`, post-link-visit.mjs) only when it names a post the card draws -- a link to // anything else draws as it always did. @@ -1464,7 +1476,8 @@ b, .name, .mark { font-family: 'PostSansBold', sans-serif; font-weight: 400; } .counts { display: flex; gap: ${Math.round(24 * k)}px; color: ${pal.muted}; font-size: ${Math.round(21 * k)}px; border-top: 1px solid ${line}; padding-top: ${Math.round(14 * k)}px; flex: none; } .counts b { color: ${pal.fg}; } .redact { filter: blur(${Math.round(9 * k)}px); color: ${pal.muted}; } -.avatar.redact { background: ${rgbaOf(pal.muted, 0.6)} !important; } +.avatar.redact { background: ${rgbaOf(pal.muted, 0.6)} !important; }${anyAnon ? ` +.avatar.anon { background: ${pal.muted} !important; color: ${pal.bg}; }` : ""} .slot { background: ${rgbaOf("#000000", 0.32)}; border-radius: ${Math.round(14 * k)}px; }${anyPic ? ` .tpic { position: relative; overflow: hidden; flex: none; border: 1px solid; border-radius: ${Math.round(14 * k)}px; background: ${rgbaOf("#000000", 0.35)}; margin-top: ${Math.round(10 * k)}px; } .picmore { position: absolute; right: ${Math.round(10 * k)}px; bottom: ${Math.round(10 * k)}px; padding: ${Math.round(2 * k)}px ${Math.round(10 * k)}px; border-radius: ${Math.round(8 * k)}px; background: ${rgbaOf("#000000", 0.6)}; color: #fff; font-size: ${Math.round(20 * k)}px; } @@ -1574,7 +1587,7 @@ export function sceneTileHtml(t, { k, pal, size, redaction = null, avatars = {} const blurred = authors.filter((a) => a.redact && a.handle).map((a) => a.handle); const red = (where) => authors.find((a) => a.where === where)?.redact ?? false; const ownRed = red("author"); - const own = { author: e.author, handle: e.handle }; + const own = { author: e.author, handle: e.handle, ...(e.anonymous === true ? { anonymous: true } : {}) }; const words = cardText(e); const n = e.engagement ?? {}; const counts = [["replies", n.replies], ["reposts", n.reposts], ["likes", n.likes], ["quotes", n.quotes]]