commit 080d8ffd1321dacbc07b29038cf98a551fd182f3
parent 4a7b44bd6f7cd779d14e91a451456340b4fa9a92
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 17 Nov 2026 12:04:02 -0500
test: the pin for a character with no tuning, taken on main (208a2c4c9)
A single post take, a thread read and its screen lines: the request bodies,
the take records and the parts keys hashed on main's code before the wiring.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
1 file changed, 102 insertions(+), 0 deletions(-)
diff --git a/umtool/lib/report/characterTuningWiring.test.mjs b/umtool/lib/report/characterTuningWiring.test.mjs
@@ -0,0 +1,102 @@
+// A CHARACTER's TUNING REACHES ITS READS (lane character-tuning, the wiring after S3): a single post's take
+// (makeTake), a thread read and a screen line (postThreadRead.mjs threadTake) are asked with the character's Orpheus
+// tuning when their line asks none of its own, and record `tuningAsked: "preset"`; a line's own tuning beats it
+// (`true`). THE PIN: a character WITHOUT a tuning asks, keys and records exactly as main did (5958688a0) -- the
+// hashes below were taken from main's code before a line of this wiring was written. No editor (a stub tts);
+// temp dirs; invented people.
+import assert from "node:assert/strict";
+import { createHash } from "node:crypto";
+import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import { after, test } from "node:test";
+import { encodeWav16 } from "yt-dlp-transcript-common/lib/montage/voiceMatch.mjs";
+import { VOICE_B, syntheticVoice, withSilence } from "yt-dlp-transcript-common/testing/audio/syntheticVoice.mjs";
+import { castPresetMap } from "umtool-report-to-video/cast";
+import { makeTake } from "./postNarrationCli.mjs";
+import { threadTake } from "./postThreadRead.mjs";
+
+const ROOT = await mkdtemp(path.join(tmpdir(), "umtool-tuning-wiring-"));
+after(() => rm(ROOT, { recursive: true, force: true }));
+delete process.env.UMTOOL_CAST_FILE;
+const LIVELY = { temperature: 0.75, top_p: 0.92, repeat_penalty: 1.25 };
+const wavOf = async (file, seconds = 0.6) => {
+ await mkdir(path.dirname(file), { recursive: true });
+ await writeFile(file, encodeWav16(withSilence(syntheticVoice({ ...VOICE_B, seconds }), { before: 0.1, after: 0.1 })));
+};
+const stubAsk = (asked) => async (body) => {
+ asked.push(body);
+ await wavOf(body.out);
+ return {
+ jobId: `job-${asked.length}`,
+ result: { wav: body.out, engine: body.engine, voice: body.voice, ...(body.engine === "orpheus" ? { tuning: { temperature: 0.55, top_p: 0.85, top_k: 50, min_p: 0, repeat_penalty: 1.2, takes: 3, ...(body.tuning ?? {}) }, reading: body.reading ?? 0 } : {}) },
+ };
+};
+const NO_RED = { terms: [], markup: {}, slurs: null };
+const IMG = { src: "posts-media/ferry-x/7/7_1.png", kind: "image", width: 900, height: 1400 };
+const ITEM = {
+ type: "post", id: "p-7", post: "ferry-x/7", platform: "x", author: "Ferry Teller", handle: "invented_ferry", date: "2026-10-02T10:00:00.000Z",
+ text: "Here is what they sent.", media: [IMG], narration: { script: "Here is what they sent." },
+ screens: [{ id: "s1", media: 0, kind: "dm", read: "all", lines: [{ who: "invented_river", text: "Are the tolls going up?" }, { who: "invented_ferry", text: "Not this year." }] }],
+};
+/** The cast: the item's author (orpheus:tara) and the screen's other speaker (orpheus:leo), each with `tuning` when given. */
+const castDoc = (ferry = null, river = null) => ({
+ format: "umtool-cast", version: 2, characters: [
+ { id: "ferry", name: "Ferry Teller", handles: ["invented_ferry"], synthetic: { voice: "orpheus:tara", ...(ferry ? { tuning: ferry } : {}) } },
+ { id: "river", name: "River Talk", handles: ["invented_river"], synthetic: { voice: "orpheus:leo", ...(river ? { tuning: river } : {}) } },
+ ],
+});
+
+async function project(name, cast) {
+ const root = path.join(ROOT, name);
+ const dir = path.join(root, "p");
+ await mkdir(path.join(dir, "narration"), { recursive: true });
+ await mkdir(path.join(root, ".umtool"), { recursive: true });
+ await writeFile(path.join(root, ".umtool", "cast.json"), JSON.stringify(cast, null, 1));
+ await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify({
+ schemaVersion: 1, slug: name, title: name, provenance: { channelsDir: "../channels", channelSlug: "chan" },
+ render: { width: 1920, height: 1080, fps: 30, postNarration: { engine: "orpheus", voice: "zac" } }, timeline: [ITEM],
+ }, null, 2));
+ return { id: name, dir };
+}
+const read = async (p) => JSON.parse(await readFile(path.join(p.dir, "video.manifest.json"), "utf8"));
+const sha = (v) => createHash("sha1").update(JSON.stringify(v)).digest("hex");
+/** A take as the pin compares it: everything but its time and job. */
+const stable = (t) => {
+ const { at: _a, jobId: _j, ...rest } = t;
+ return { ...rest, ...(Array.isArray(rest.parts) ? { parts: rest.parts.map(({ at: _pa, jobId: _pj, ...p }) => p) } : {}) };
+};
+const bodies = (asked, dir) => asked.map((b) => ({ ...b, out: path.relative(dir, b.out) }));
+const layersOf = (cast) => ({ map: {}, cast: castPresetMap(cast), item: null, names: {} });
+
+/** A single post's take of p-7, and its thread read with the screen (two of its pieces another character's). */
+async function readsOf(name, cast, { tuning = null, tuned = {} } = {}) {
+ const p = await project(name, cast);
+ const asked = [];
+ const one = await makeTake(p, (await read(p)).timeline[0], { ask: stubAsk(asked), redaction: NO_RED, ...(tuning ? { tuning } : {}) });
+ const single = asked.splice(0);
+ const thread = await threadTake(p, (await read(p)).timeline[0], { red: NO_RED, ask: stubAsk(asked), lanes: null, ...layersOf(cast), tuned });
+ return { p, single, take: one.take, threadAsks: asked, thread };
+}
+
+// Taken on main's code (5958688a0, merged as 8824428b1) before the wiring: a character with NO tuning.
+const MAIN = {
+ single: "9f675482a1264083457304cfdb409dcdc35774db",
+ take: "923bcf133ac164c200e898c18656c2dda2ae2075",
+ threadAsks: "126f1f4da6c72d2605b0ea15cf6399938608cd83",
+ threadTake: "6b3b40cf343afd894f348c40a672b3d67d190938",
+ keys: "FAKE-TEST-VALUE",
+};
+
+test("THE PIN: a character with no tuning -- the post's take, the thread read and its screen lines ask, key and record as main did", async () => {
+ const r = await readsOf("pin", castDoc());
+ const got = {
+ single: sha(bodies(r.single, r.p.dir)),
+ take: sha(stable(r.take)),
+ threadAsks: sha(bodies(r.threadAsks, r.p.dir)),
+ threadTake: sha(stable(r.thread.take)),
+ keys: sha(r.thread.parts.map((x) => x.key)),
+ };
+ if (process.env.PIN_PRINT) console.log(JSON.stringify(got, null, 2));
+ assert.deepEqual(got, MAIN);
+});