Archilyzer · Source

archilyzer

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

commit 7d99aa4f3ff34772512f0222bf79fffc17d76154
parent d6b3f0b2116be9c5d8dd732a946200eabc6d4355
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 17 Nov 2026 15:25:32 -0500

a plain press passes back only what the LINE owned: a re-read comes back fresh (reads-find ruling 2)

The bench's untouched Read again sent the last read's recorded takes as the line's own, so a read
stale only because its character's takes changed came back with the old takes and stayed stale
after its pick. The orchestrator's ruling (17 Nov 2026) supersedes S3's "the recorded takes are
passed back" for values the line does not own:

- a take records `tuningOwn`, the line's own values exactly as asked (none owned: no key), from
  `posts narrate --take` and the bench's take op alike;
- tuneAsk.mjs lineOwnOf / pieceOwnOf say what a read's line owned: `tuningOwn`, else (an older take)
  every recorded value when it asked true, else none -- the known limit: an old take that owned
  only its takes re-reads with the character's or the settings' takes;
- the Tune's takes start from the line's own, else the character's, else empty (the setting), and a
  press sends takes only when the line owns them or they are typed; plainPressAskOf is that ask, the
  one the re-read queue uses;
- the bench's take list says a take's line-owned values beside what it was made with.

tuneAsk.test.mjs: the assertions that pinned the old pass-back now state the new rule. New:
plainPressFresh.test.mjs (character takes change -> stale -> plain press -> picked -> fresh; a
line-owned takes survives; the old-take fallback). The S2 no-tuning pin and S3's reading pin are
green unchanged.

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

Diffstat:
Mumtool/app/api/report/post-narration/route.ts | 6++++--
Mumtool/components/projects/NarrationReview.tsx | 1+
Mumtool/components/projects/PostNarrationPanel.tsx | 3+++
Mumtool/components/projects/PostThreadPanel.tsx | 3++-
Mumtool/components/projects/ScreenLineVoice.tsx | 6++++--
Mumtool/components/projects/read/ReadAgain.tsx | 19+++++++++++++------
Mumtool/e2e/character-tuning.spec.ts | 3++-
Aumtool/lib/report/plainPressFresh.test.mjs | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/report/postNarrationCli.mjs | 2++
Mumtool/lib/report/tuneAsk.mjs | 68+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
Mumtool/lib/report/tuneAsk.test.mjs | 57+++++++++++++++++++++++++++++++++++++++++++++------------
Mumtool/report-to-video/post-narration.mjs | 6+++++-
12 files changed, 236 insertions(+), 32 deletions(-)

diff --git a/umtool/app/api/report/post-narration/route.ts b/umtool/app/api/report/post-narration/route.ts @@ -262,12 +262,14 @@ export async function GET(request: Request) { const { slurs, lexicon } = spoken; // What the POST asked (its speed and where it came from), kept beside the file until the take is made. const askFile = `${abs}.ask.json`; - const ask = (await readFile(askFile, "utf8").then(JSON.parse, () => null)) as { speed?: number; speedAsked?: true | "item" | "preset"; keepPick?: boolean; tuningAsked?: true | "preset" } | null; + const ask = (await readFile(askFile, "utf8").then(JSON.parse, () => null)) as { speed?: number; speedAsked?: true | "item" | "preset"; keepPick?: boolean; tuningAsked?: true | "preset"; tuningOwn?: Record<string, number> } | null; await rm(askFile, { force: true }); const take = { ...(typeof ask?.speed === "number" ? { speed: ask.speed } : {}), ...(ask?.speedAsked !== undefined ? { speedAsked: ask.speedAsked } : {}), // Where its tuning came from (lane character-tuning): its line's own, or its character's. ...(ask?.tuningAsked === true || ask?.tuningAsked === "preset" ? { tuningAsked: ask.tuningAsked } : {}), + // The line's own values as asked (lane reads-find): what a plain press passes back. + ...(ask?.tuningOwn && typeof ask.tuningOwn === "object" && Object.keys(ask.tuningOwn).length ? { tuningOwn: ask.tuningOwn } : {}), // What it said, when an anonymous handle made that differ from the script (post-anon.mjs; the lint reads it). ...(spoken.anonymised ? { said: spoken.text } : {}), ...(slurs ? { slurs } : {}), @@ -456,7 +458,7 @@ async function postHere(request: Request) { const tuning = ta.tuning; const tuningAsked = ta.asked; askFile = `${out}.ask.json`; - if (speed || keepPick || tuningAsked) await writeFile(`${out}.ask.json`, JSON.stringify({ ...(speed ? { speed, speedAsked: body.speed !== undefined && body.speed !== null ? true : (e.narration as { speed?: number } | undefined)?.speed != null ? "item" : "preset" } : {}), ...(keepPick ? { keepPick: true } : {}), ...(tuningAsked ? { tuningAsked } : {}) })); + if (speed || keepPick || tuningAsked || ta.own) await writeFile(`${out}.ask.json`, JSON.stringify({ ...(speed ? { speed, speedAsked: body.speed !== undefined && body.speed !== null ? true : (e.narration as { speed?: number } | undefined)?.speed != null ? "item" : "preset" } : {}), ...(keepPick ? { keepPick: true } : {}), ...(tuningAsked ? { tuningAsked } : {}), ...(ta.own ? { tuningOwn: ta.own } : {}) })); const jobId = await startJob("/api/ops/tts", { text: spoken, engine, voice, out, ...(speed ? { speed } : {}), ...(tuning ? { tuning } : {}), ...(reading !== null ? { reading } : {}) }); // The marker names its job, its file and what the take keeps (its words, its note): a bench that lost the job // finds it again here and lands its take (GET ?pending). diff --git a/umtool/components/projects/NarrationReview.tsx b/umtool/components/projects/NarrationReview.tsx @@ -456,6 +456,7 @@ function NarrationCard({ onReadAgain={(t) => void readAgain(t, null)} onReadEdited={(t) => void readAgain(t, text)} madeWith={r.madeWith ?? r.tuning ?? null} + lineOwn={r.tuning ?? null} autoplay={auto} onAutoplay={setAuto} /> diff --git a/umtool/components/projects/PostNarrationPanel.tsx b/umtool/components/projects/PostNarrationPanel.tsx @@ -17,6 +17,7 @@ import type { PostPlan } from "./review/PostItemPlayer"; import { wordZoomTimes, zoomSpan } from "umtool-report-to-video/word-zoom"; import PostAttachmentLane from "./PostAttachmentLane"; import ReadAgain, { madeWithText, playNow, useAutoPlay, type KeepForCharacter, type Tuning } from "./read/ReadAgain"; +import { lineOwnOf } from "@/lib/report/tuneAsk.mjs"; import { useKeepForCharacter } from "./read/keepForCharacter"; import { LEGACY_EDIT_TEXT, legacyReadOf } from "umtool-report-to-video/post-item"; @@ -712,6 +713,7 @@ export default function PostNarrationPanel({ </span> <span className="tabular-nums">{Number(t.seconds).toFixed(1)} s</span> {madeWithText(t) && <span className="font-mono text-text-2" data-post-take-made={i + 1}>{madeWithText(t)}</span>} + {(t as { tuningOwn?: Tuning }).tuningOwn && <span className="font-mono text-text-2" data-post-take-own={i + 1}>line&apos;s own: {Object.entries((t as { tuningOwn?: Tuning }).tuningOwn ?? {}).map(([k, v]) => `${k.replace("_", " ")} ${v}`).join(", ")}</span>} {landed === t.file && <span className="micro text-[var(--color-sel)]" data-post-take-new={i + 1}>new</span>} {/* eslint-disable-next-line jsx-a11y/media-has-caption */} <audio src={fileUrl(project, t.file)} controls preload="none" className="h-7" data-post-take-audio={i + 1} /> @@ -821,6 +823,7 @@ export default function PostNarrationPanel({ onReadAgain={(t) => void press(() => readAgain(n.script ?? "", t))} onReadEdited={(t) => void press(() => readEdited(t))} madeWith={madeWith} + lineOwn={lineOwnOf(madeTake as Parameters<typeof lineOwnOf>[0]) as Tuning | null} baseline={readsAs.baseline} madeOwn={readsAs.madeOwn} refreshBaseline={readsAs.refresh} diff --git a/umtool/components/projects/PostThreadPanel.tsx b/umtool/components/projects/PostThreadPanel.tsx @@ -3,7 +3,7 @@ import { useEffect, useMemo, useRef, useState } from "react"; import ReadAgain, { playNow, useAutoPlay, type Tuning } from "./read/ReadAgain"; import { useKeepForCharacter } from "./read/keepForCharacter"; -import { threadTuneMadeOf } from "@/lib/report/tuneAsk.mjs"; +import { pieceOwnOf, threadTuneMadeOf } from "@/lib/report/tuneAsk.mjs"; import { THREAD_DEFAULTS, THREAD_LIMITS, THREAD_MODES, partRoles, readPieces, threadKnobs, threadLayout, threadReadErrors } from "umtool-report-to-video/post-thread"; import { followKnobs } from "umtool-report-to-video/read-follow"; import { pickedTake } from "umtool-report-to-video/post-narration"; @@ -176,6 +176,7 @@ export default function PostThreadPanel({ waiting={again?.state === "running" ? again.waiting ?? null : null} onReadAgain={(t) => void readThreadAgain(t)} madeWith={postPart?.tuning ?? null} + lineOwn={pieceOwnOf(playing, "post") as Tuning | null} baseline={readsAs.baseline} madeOwn={readsAs.madeOwn} refreshBaseline={readsAs.refresh} diff --git a/umtool/components/projects/ScreenLineVoice.tsx b/umtool/components/projects/ScreenLineVoice.tsx @@ -4,6 +4,7 @@ import { useCallback, useEffect, useRef, useState } from "react"; import { useMic, ls } from "./useMic"; import ReadAgain, { playNow, useAutoPlay, type Tuning } from "./read/ReadAgain"; import { useKeepForCharacter } from "./read/keepForCharacter"; +import { pieceOwnOf } from "@/lib/report/tuneAsk.mjs"; // --------------------------------------------------------------------------- // A SCREEN LINE IN THE OPERATOR's VOICE, on the post bench's screens section (lib/report/screenLineRecord.mjs; the @@ -185,7 +186,7 @@ export type ScreenVoice = ReturnType<typeof useScreenVoice>; export type LineTakeOption = { id: string; label: string; current: boolean }; /** One synthesized reading of a line: the take it is in (index), its part's file, words, reading and tuning. */ -export type LineReading = { take: number; picked: boolean; file: string | null; text: string; reading: number; tuning: Tuning | null; tuningAsked?: true | "preset" }; +export type LineReading = { take: number; picked: boolean; file: string | null; text: string; reading: number; tuning: Tuning | null; tuningAsked?: true | "preset"; own?: Tuning | null }; /** The readings of a line (`role`) in an item's takes: each take whose parts read it, synthesized. */ export function lineReadings(entry: Record<string, unknown>, role: string): LineReading[] { @@ -194,7 +195,7 @@ export function lineReadings(entry: Record<string, unknown>, role: string): Line return (n.takes ?? []).flatMap((t, i) => { const p = (t.parts ?? []).find((x) => x.role === role && !(x as { take?: string }).take); const asked = (p as { tuningAsked?: unknown } | undefined)?.tuningAsked; - return p ? [{ take: i, picked: i === pick, file: p.file ?? null, text: String(p.text ?? ""), reading: Number.isInteger(p.reading) ? (p.reading as number) : 0, tuning: p.tuning ?? null, ...(asked === true || asked === "preset" ? { tuningAsked: asked } : {}) }] : []; + return p ? [{ take: i, picked: i === pick, file: p.file ?? null, text: String(p.text ?? ""), reading: Number.isInteger(p.reading) ? (p.reading as number) : 0, tuning: p.tuning ?? null, ...(asked === true || asked === "preset" ? { tuningAsked: asked } : {}), own: pieceOwnOf(t, role) as Tuning | null }] : []; }); } @@ -249,6 +250,7 @@ export function ScreenLineVoice({ role, n, voice, dirty, options, chosen, onChoo onReadAgain={(t) => void voice.readLine(role, t)} onReadEdited={(t) => void voice.readLine(role, t)} madeWith={playedLine?.tuning ?? null} + lineOwn={playedLine?.own ?? null} baseline={readsAs.baseline} madeOwn={readsAs.madeOwn} refreshBaseline={readsAs.refresh} diff --git a/umtool/components/projects/read/ReadAgain.tsx b/umtool/components/projects/read/ReadAgain.tsx @@ -34,7 +34,7 @@ export type KeepForCharacter = (tuning: Tuning) => Promise<string | null>; * from the character's (all of it when the last read was the line's own); nothing changed on a character's line sends * none of the sampler, so the character's is asked as it is then. */ -export type TuneBaseline = { character: { name: string; tuning: Tuning | null } | null; madeOwn: boolean }; +export type TuneBaseline = { character: { name: string; tuning: Tuning | null } | null; madeOwn: boolean; ownTakes?: number | null }; /** Was a read the line's own? (lib/report/tuneAsk.mjs: the one rule.) */ export const madeOwnOf = (tuning: Tuning | null | undefined, tuningAsked: unknown): boolean => tuneMadeOwnOf(tuning, tuningAsked); const NAMED: Record<string, string> = { steady: "Steady", default: "Default", lively: "Lively", custom: "custom" }; @@ -94,7 +94,7 @@ export function madeWithText(t: { reading?: number | null; tuning?: Tuning | nul } export default function ReadAgain({ - what = "", busy = false, waiting = null, canReadAgain = true, edited = false, onReadAgain, onReadEdited, madeWith = null, baseline = undefined, madeOwn = false, refreshBaseline, baselineError = null, onRetryBaseline, character = null, keepForCharacter, error = null, note = null, autoplay, onAutoplay, + what = "", busy = false, waiting = null, canReadAgain = true, edited = false, onReadAgain, onReadEdited, madeWith = null, lineOwn = null, baseline = undefined, madeOwn = false, refreshBaseline, baselineError = null, onRetryBaseline, character = null, keepForCharacter, error = null, note = null, autoplay, onAutoplay, }: { /** What is read, in the controls' names: "" (the post), "line 2", "the thread", "the card". */ what?: string; @@ -117,6 +117,11 @@ export default function ReadAgain({ baseline?: TuneBaseline | null; /** Its last read was the line's own (known before the baseline is: an untouched press while it is read). */ madeOwn?: boolean; + /** + * The values its last read's LINE owned (lib/report/tuneAsk.mjs lineOwnOf: the take's `tuningOwn`, else an older + * take's every value when it asked true) -- a plain press passes back only these; the rest is resolved now. + */ + lineOwn?: Tuning | null; /** The baseline as it is NOW: a press asking a sampler value of its own checks it first (review 3 #1). */ refreshBaseline?: () => Promise<TuneBaseline | null>; /** Why the baseline could not be read, and a retry: said in place. */ @@ -133,12 +138,14 @@ export default function ReadAgain({ onAutoplay: (on: boolean) => void; }) { // The numbers a plain press would read with now: the line's own last numbers, else its character's, else the - // defaults; the takes the last read's (lib/report/tuneAsk.mjs). + // defaults; the takes the line owned, else the character's, else the settings' (lib/report/tuneAsk.mjs). // "Use <character>'s" (review 3 #3): the line back to its character -- the baseline as if its last read were the // character's, until a new read lands. const [fromCharacter, setFromCharacter] = useState(false); - const eff: TuneBaseline | null | undefined = baseline && fromCharacter ? (characterTuneOf(madeWith, baseline).baseline as TuneBaseline) : baseline; - const start = (): Record<string, string> => tuneStartOf({ madeWith, baseline: eff }) as Record<string, string>; + // The takes the line owns ride on the baseline (a press sends them back; a takes it did not own is resolved now). + const own = fromCharacter ? null : lineOwn; + const eff: TuneBaseline | null | undefined = baseline && fromCharacter ? (characterTuneOf(madeWith, baseline).baseline as TuneBaseline) : baseline ? { ...baseline, ownTakes: typeof own?.takes === "number" ? own.takes : null } : baseline; + const start = (): Record<string, string> => tuneStartOf({ madeWith, baseline: eff, own }) as Record<string, string>; const [draft, setDraft] = useState<Record<string, string>>(start); const [kept, setKept] = useState<string | null>(null); const [keeping, setKeeping] = useState(false); @@ -155,7 +162,7 @@ export default function ReadAgain({ setDraft(start()); setTakesTyped(false); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [JSON.stringify(madeWith), JSON.stringify(eff)]); + }, [JSON.stringify(madeWith), JSON.stringify(eff), JSON.stringify(own)]); const edit = (next: Record<string, string>) => { setDraft(next); setDirty(true); diff --git a/umtool/e2e/character-tuning.spec.ts b/umtool/e2e/character-tuning.spec.ts @@ -248,7 +248,8 @@ test("the post bench: Read again asks the character's Lively (\"preset\"); the T await panel.locator('[aria-label="Read again"]').click(); await expect(panel.locator("[data-post-take]")).toHaveCount(2, { timeout: 30_000 }); expect(benchAsks().length).toBe(asked0 + 1); - // (The Read again carries the takes its last read was made with -- S3's rule -- and the character's sampler under it.) + // (The Read again carries the character's sampler, and only the takes the LINE owned -- none here: they are the + // character's or the editor's setting, resolved now, never copied from the last read; lane reads-find.) expect(benchAsks().at(-1)!.tuning).toMatchObject({ temperature: 0.75, top_p: 0.92, repeat_penalty: 1.25 }); expect(takesOf("p-1")[1]).toMatchObject({ tuningAsked: "preset", tuning: { temperature: 0.75, top_p: 0.92, repeat_penalty: 1.25 } }); diff --git a/umtool/lib/report/plainPressFresh.test.mjs b/umtool/lib/report/plainPressFresh.test.mjs @@ -0,0 +1,94 @@ +// A RE-READ COMES BACK FRESH (lane reads-find, the orchestrator's ruling 2): a plain press passes back only the values +// the LINE owned (`tuningOwn`); the character's and the settings' -- takes included -- are resolved now. The character's +// takes change -> its read is stale -> a plain press re-reads it -> picked -> fresh. A line that owned its takes keeps +// them. No editor (a stub tts); temp dirs; invented people. +import assert from "node:assert/strict"; +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 { tuningStale } from "umtool-report-to-video/cast"; +import { makeTake } from "./postNarrationCli.mjs"; +import { resolverFor } from "./castProject.mjs"; +import { manifestToken, updatePostNarration } from "./manifest.mjs"; +import { lineOwnOf, madeOwnOf, plainPressAskOf } from "./tuneAsk.mjs"; + +const ROOT = await mkdtemp(path.join(tmpdir(), "umtool-plain-press-")); +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 NO_RED = { terms: [], markup: {}, slurs: null }; +const wavOf = async (file) => { + await mkdir(path.dirname(file), { recursive: true }); + await writeFile(file, encodeWav16(withSilence(syntheticVoice({ ...VOICE_B, seconds: 0.6 }), { before: 0.1, after: 0.1 }))); +}; +/** The editor's answer: what was asked over the defaults, the setting's 3 takes when none was asked. */ +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, 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 castDoc = (tuning) => ({ format: "umtool-cast", version: 2, characters: [{ id: "ferry", name: "Ferry Teller", handles: ["invented_ferry"], synthetic: { voice: "orpheus:tara", tuning } }] }); +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.", narration: { script: "Here is what they sent." } }; + +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, render: { width: 1920, height: 1080, fps: 30, postNarration: { engine: "orpheus", voice: "zac" } }, timeline: [ITEM] }, null, 2)); + return { id: name, dir, root }; +} +const read = async (p) => JSON.parse(await readFile(path.join(p.dir, "video.manifest.json"), "utf8")); +const setCast = (p, cast) => writeFile(path.join(p.root, ".umtool", "cast.json"), JSON.stringify(cast, null, 1)); +/** The bench's untouched Read again, as its ask is built (ReadAgain: the Tune's start, the line's own values). */ +const plainPress = (take, characterTuning) => plainPressAskOf({ madeWith: take.tuning ?? null, baseline: { character: { name: "Ferry Teller", tuning: characterTuning }, madeOwn: madeOwnOf(take.tuning, take.tuningAsked) }, own: lineOwnOf(take) }); +const pick = async (p, n) => updatePostNarration(p.dir, "p-7", { pick: n }, { token: await manifestToken(p.dir) }); + +test("the character's takes change: its read is stale; a plain press re-reads it with the takes resolved now; picked, it is fresh", async () => { + const p = await project("takes-change", castDoc(LIVELY)); + const asked = []; + const first = (await makeTake(p, (await read(p)).timeline[0], { ask: stubAsk(asked), redaction: NO_RED })).take; + assert.equal(first.tuningAsked, "preset"); + assert.equal(first.tuning.takes, 3, "made with the editor's setting"); + assert.equal("tuningOwn" in first, false, "the line owned nothing"); + // The character names 4 takes now: stale. + const now = { ...LIVELY, takes: 4 }; + await setCast(p, castDoc(now)); + assert.deepEqual(tuningStale(await read(p), resolverFor({ cast: castDoc(now) }), { settingTakes: 3 }).map((r) => r.id), ["p-7"]); + // A plain press asks nothing of its own: the character's 4 takes are resolved now, not the last read's 3. + const ask = plainPress(first, now); + assert.equal(ask, null); + const again = (await makeTake(p, (await read(p)).timeline[0], { ask: stubAsk(asked), redaction: NO_RED, tuning: ask, keepPick: true })).take; + assert.deepEqual(asked.at(-1).tuning, now); + assert.equal(again.tuning.takes, 4); + // Not picked yet: still stale (what plays is the old read). Picked: fresh. + assert.equal(tuningStale(await read(p), resolverFor({ cast: castDoc(now) }), { settingTakes: 3 }).length, 1); + await pick(p, 1); + assert.deepEqual(tuningStale(await read(p), resolverFor({ cast: castDoc(now) }), { settingTakes: 3 }), []); +}); + +test("a line that owned its takes keeps them through a plain press (tuningOwn), the sampler still the character's", async () => { + const p = await project("takes-own", castDoc(LIVELY)); + const asked = []; + const own = (await makeTake(p, (await read(p)).timeline[0], { ask: stubAsk(asked), redaction: NO_RED, tuning: { takes: 5 } })).take; + assert.deepEqual(own.tuningOwn, { takes: 5 }); + assert.equal(own.tuningAsked, "preset"); + const now = { ...LIVELY, takes: 4 }; + await setCast(p, castDoc(now)); + const ask = plainPress(own, now); + assert.deepEqual(ask, { takes: 5 }); + const again = (await makeTake(p, (await read(p)).timeline[0], { ask: stubAsk(asked), redaction: NO_RED, tuning: ask, keepPick: true })).take; + assert.equal(again.tuning.takes, 5); + assert.deepEqual(again.tuningOwn, { takes: 5 }); + assert.equal(again.tuning.temperature, 0.75, "the character's sampler"); +}); + +test("an older take (no tuningOwn) asked true owns every recorded value; one recorded \"preset\" owns none (the known limit)", () => { + const made = { temperature: 0.9, top_p: 0.85, top_k: 50, min_p: 0, repeat_penalty: 1.2, takes: 5 }; + assert.deepEqual(plainPress({ tuning: made, tuningAsked: true }, LIVELY), { temperature: 0.9, top_p: 0.85, top_k: 50, min_p: 0, repeat_penalty: 1.2, takes: 5 }); + assert.equal(plainPress({ tuning: { ...LIVELY, top_k: 50, min_p: 0, takes: 5 }, tuningAsked: "preset" }, LIVELY), null); +}); diff --git a/umtool/lib/report/postNarrationCli.mjs b/umtool/lib/report/postNarrationCli.mjs @@ -464,6 +464,8 @@ export async function makeTake(project, e, { script = null, note = null, engine ...tunedOfResult(result), // Where that tuning came from: its line's own (true) or its character's ("preset": stale when that changes). ...(tuningAsked ? { tuningAsked } : {}), + // The line's own values as asked (lane reads-find): what a plain press passes back; none owned, no key. + ...(ta.own ? { tuningOwn: ta.own } : {}), // What its audio does with the slurs the script holds (post-slurs.mjs), and its words when timed for a beep. ...(slurs ? { slurs } : {}), ...(timed ? { words: timed } : {}), // The pronunciation entries it said (post-say.mjs; `umtool posts say <p> stale` reads them). diff --git a/umtool/lib/report/tuneAsk.mjs b/umtool/lib/report/tuneAsk.mjs @@ -8,7 +8,9 @@ // a PRESS with no character, S3's rule (what differs from the defaults); with one, what differs from the // character's tuning (all of the sampler when the last read was the line's own) -- nothing changed on // a character's line asks none of the sampler, so the character's is asked as it is then; the takes -// when given (S3: a recorded takes is passed back) +// only when the LINE owns them (lane reads-find, the orchestrator's ruling, 17 Nov 2026: superseding S3's +// "a recorded takes is passed back") -- the last read's own takes, or a takes typed -- else they are +// resolved now (the character's, else the editor's setting), never copied from the last read // a KEEP the sampler as it stands (top k, min p only when not their defaults) and the takes only when typed // // Plain ESM, pure. @@ -25,6 +27,36 @@ export function madeOwnOf(tuning, tuningAsked) { return TUNE_SAMPLER.some((k) => typeof tuning?.[k] === "number" && tuning[k] !== DEFAULTS[k]); } +/** + * THE VALUES A READ's LINE OWNED (lane reads-find): its `tuningOwn` (the line's own values as asked, recorded on every + * take made since) when it has one; an OLDER take records no ownership field by field, so it reads as owning every + * recorded value when `tuningAsked` is true, and none otherwise -- a known limit: an old take that owned only its takes + * (recorded "preset") re-reads with the character's or the settings' takes. Null: the line owns none. + * @param {{ tuning?: Record<string, number> | null, tuningAsked?: unknown, tuningOwn?: Record<string, number> | null }} [made] + */ +export function lineOwnOf(made) { + const own = made?.tuningOwn; + if (own && typeof own === "object" && !Array.isArray(own)) return Object.keys(own).length ? { ...own } : null; + if (made?.tuningAsked === true && made?.tuning && typeof made.tuning === "object") return Object.keys(made.tuning).length ? { ...made.tuning } : null; + return null; +} + +/** + * The values one PIECE of a thread read owned (`role`): its `read.tuned[role]` (the read's own values for that piece, + * postThreadRead.mjs readRecordOf) when the read records the piece there, else lineOwnOf of its part. Null: none. + * @param {any} take + * @param {string} role + */ +export function pieceOwnOf(take, role) { + const t = take?.read?.tuned; + if (t && typeof t === "object" && t[role] && typeof t[role] === "object") { + const own = t[role].tuning; + return own && typeof own === "object" && Object.keys(own).length ? { ...own } : null; + } + const part = (Array.isArray(take?.parts) ? take.parts : []).find((p) => p?.role === role && typeof p?.take !== "string") ?? null; + return lineOwnOf(part); +} + /** S3's ask (ReadAgain.tsx tuningAsked): the sampler values off the defaults, and the takes whenever given. */ export function defaultsAskOf(draft) { const out = {}; @@ -37,18 +69,37 @@ export function defaultsAskOf(draft) { /** * The Tune's starting numbers, as its fields hold them (strings): the baseline's sampler (`baseline` null: S3's -- the - * last read's), and the last read's takes. - * @param {{ madeWith?: Record<string, number> | null, baseline?: { character: { tuning: Record<string, number> | null } | null, madeOwn: boolean } | null }} o + * last read's); the takes the LINE owns (`own`: lineOwnOf's, null none -- or the baseline's `ownTakes`), else the + * character's, else empty (the editor's setting): a takes the line does not own is resolved now, never the last read's. + * @param {{ madeWith?: Record<string, number> | null, baseline?: { character: { tuning: Record<string, number> | null } | null, madeOwn: boolean, ownTakes?: number | null } | null, own?: Record<string, number> | null }} o */ -export function tuneStartOf({ madeWith = null, baseline = null } = {}) { +export function tuneStartOf({ madeWith = null, baseline = null, own = null } = {}) { // No character (none now, or one since removed): S3's rule -- the last read's numbers (review 3 #4). const b = !baseline || baseline.madeOwn || !baseline.character ? madeWith : baseline.character.tuning ?? null; + const takes = ownTakesOf(own, baseline) ?? baseline?.character?.tuning?.takes ?? null; return Object.fromEntries(TTS_TUNING_FIELDS.map((k) => { - const v = k === "takes" ? madeWith?.takes : b?.[k]; + const v = k === "takes" ? takes : b?.[k]; return [k, v !== undefined && v !== null ? String(v) : k in DEFAULTS ? String(DEFAULTS[k]) : ""]; })); } +/** The takes the line owns: `own`'s, else the baseline's `ownTakes`; null when it owns none. */ +const ownTakesOf = (own, baseline) => { + const t = own?.takes ?? baseline?.ownTakes; + return typeof t === "number" && Number.isFinite(t) ? t : null; +}; + +/** + * WHAT A PLAIN PRESS ASKS (lane reads-find: the bench's untouched Read again, and the re-read queue's -- one rule): + * the Tune's start, asked as an untouched press asks it. `own` the values the line owned (lineOwnOf). + * @param {{ madeWith?: Record<string, number> | null, baseline?: { character: { tuning: Record<string, number> | null } | null, madeOwn: boolean, ownTakes?: number | null } | null, own?: Record<string, number> | null }} o + */ +export function plainPressAskOf({ madeWith = null, baseline = null, own = null } = {}) { + const b = baseline ? { ...baseline, ownTakes: ownTakesOf(own, baseline) } : baseline; + const draft = tuneStartOf({ madeWith, baseline: b, own }); + return b?.character ? tuneAskOf(draft, b) : defaultsAskOf(draft); +} + /** * What a press asks as the line's own (null: nothing of its own -- the character's, or the defaults, as they are now). * @param {Record<string, string>} draft @@ -62,8 +113,11 @@ export function tuneAskOf(draft, baseline = null) { const was = baseline.character.tuning?.[k] ?? DEFAULTS[k]; if (v !== null && (baseline.madeOwn || v !== was)) out[k] = v; } + // The takes: the line's own (its last read's, `ownTakes`; or typed other than the character's) -- never the + // character's own takes sent back as the line's (they are resolved now; lane reads-find). const takes = num(draft?.takes); - if (takes !== null) out.takes = takes; + const charTakes = baseline.character.tuning?.takes; + if (takes !== null && (takes !== charTakes || takes === baseline.ownTakes)) out.takes = takes; return Object.keys(out).length ? out : null; } @@ -121,6 +175,6 @@ export function unknownBaselineAskOf(draft, { madeOwn = false, dirty = false } = * @param {{ character: { tuning: Record<string, number> | null } | null, madeOwn: boolean }} baseline */ export function characterTuneOf(madeWith, baseline) { - const b = { ...baseline, madeOwn: false }; + const b = { ...baseline, madeOwn: false, ownTakes: null }; return { baseline: b, draft: tuneStartOf({ madeWith, baseline: b }) }; } diff --git a/umtool/lib/report/tuneAsk.test.mjs b/umtool/lib/report/tuneAsk.test.mjs @@ -4,7 +4,7 @@ // line's own). import assert from "node:assert/strict"; import { test } from "node:test"; -import { asksSampler, characterTuneOf, defaultsAskOf, keepAskOf, madeOwnOf, sameBaseline, threadTuneMadeOf, tuneAskOf, tuneStartOf, unknownBaselineAskOf } from "./tuneAsk.mjs"; +import { asksSampler, characterTuneOf, defaultsAskOf, keepAskOf, lineOwnOf, madeOwnOf, plainPressAskOf, sameBaseline, threadTuneMadeOf, tuneAskOf, tuneStartOf, unknownBaselineAskOf } from "./tuneAsk.mjs"; const LIVELY = { temperature: 0.75, top_p: 0.92, repeat_penalty: 1.25 }; const STEADY = { temperature: 0.4, top_p: 0.8 }; @@ -16,17 +16,19 @@ test("review 2 #1: a plain press after a read under the character's Lively asks const made = { tuning: MADE_LIVELY, tuningAsked: "preset" }; const b = asCharacter(LIVELY, madeOwnOf(made.tuning, made.tuningAsked)); const draft = tuneStartOf({ madeWith: made.tuning, baseline: b }); - assert.deepEqual(tuneAskOf(draft, b), { takes: 3 }, "only the recorded takes (S3's rule): the sampler is the character's"); + assert.equal(tuneAskOf(draft, b), null, "nothing of its own (lane reads-find): the sampler is the character's, and the takes the line did not own are resolved now, never the last read's"); // The rule before the fix: the last read's numbers, as the line's own. - assert.deepEqual(defaultsAskOf(tuneStartOf({ madeWith: made.tuning })), { temperature: 0.75, top_p: 0.92, repeat_penalty: 1.25, takes: 3 }); + // (Its takes not owned by the line: not in the start since lane reads-find.) + assert.deepEqual(defaultsAskOf(tuneStartOf({ madeWith: made.tuning })), { temperature: 0.75, top_p: 0.92, repeat_penalty: 1.25 }); // The character is Steady now: the Tune starts there, and a plain press still asks none of the sampler. const now = asCharacter(STEADY, false); const d2 = tuneStartOf({ madeWith: made.tuning, baseline: now }); assert.deepEqual([d2.temperature, d2.top_p, d2.repeat_penalty], ["0.4", "0.8", "1.2"]); - assert.deepEqual(tuneAskOf(d2, now), { takes: 3 }); - // The line's own last read stays its own: its numbers are the baseline, all of the sampler asked. + assert.equal(tuneAskOf(d2, now), null, "still nothing of its own: the takes are the character's or the settings', resolved now"); + // The line's own last read stays its own: its numbers are the baseline, all of the sampler asked -- and its takes, + // which it owned (an older take asked true owns every recorded value: lineOwnOf). const own = asCharacter(STEADY, madeOwnOf({ ...MADE_LIVELY, temperature: 0.9 }, true)); - const d3 = tuneStartOf({ madeWith: { ...MADE_LIVELY, temperature: 0.9 }, baseline: own }); + const d3 = tuneStartOf({ madeWith: { ...MADE_LIVELY, temperature: 0.9 }, baseline: own, own: lineOwnOf({ tuning: { ...MADE_LIVELY, temperature: 0.9 }, tuningAsked: true }) }); assert.deepEqual(tuneAskOf(d3, own), { temperature: 0.9, top_p: 0.92, top_k: 50, min_p: 0, repeat_penalty: 1.25, takes: 3 }); // Made before `tuningAsked` was recorded: a sampler value off the defaults was the line's own; the defaults were not. assert.equal(madeOwnOf({ temperature: 0.7 }, undefined), true); @@ -74,7 +76,7 @@ test("review 3 #1: a draft edited against Lively while the character became Stea const was = asCharacter(LIVELY, false); const draft = { ...tuneStartOf({ madeWith: MADE_LIVELY, baseline: was }), top_p: "0.9" }; const a = tuneAskOf(draft, was); - assert.deepEqual(a, { top_p: 0.9, takes: 3 }); + assert.deepEqual(a, { top_p: 0.9 }, "the changed value only: the takes the line did not own are not sent"); assert.equal(asksSampler(a), true, "it names a sampler value of its own: the baseline is read again before it is sent"); // Read again: Steady now. It changed under the draft -- nothing is sent (the press is refused, the new baseline said). const now = asCharacter(STEADY, false); @@ -82,17 +84,18 @@ test("review 3 #1: a draft edited against Lively while the character became Stea assert.equal(sameBaseline(asCharacter({ ...LIVELY }, false), was), true); // Sent as it was, it would have read {temperature 0.4 (Steady's), top_p 0.9} while the Tune showed 0.75. // Pressed again against Steady, the draft as shown is the line's own: every number that differs from Steady's. - assert.deepEqual(tuneAskOf(draft, now), { temperature: 0.75, top_p: 0.9, repeat_penalty: 1.25, takes: 3 }); + assert.deepEqual(tuneAskOf(draft, now), { temperature: 0.75, top_p: 0.9, repeat_penalty: 1.25 }); // An untouched press names no sampler value: sent at once (the character's is asked as it is then). assert.equal(asksSampler({ takes: 3 }), false); }); test("review 3 #2: the baseline unknown -- an untouched press asks nothing of its own, an edited one waits", () => { const draft = tuneStartOf({ madeWith: MADE_LIVELY, baseline: null }); - assert.deepEqual(unknownBaselineAskOf(draft, { madeOwn: false }), { waits: false, ask: { takes: 3 } }); + assert.deepEqual(unknownBaselineAskOf(draft, { madeOwn: false }), { waits: false, ask: null }, "an untouched press asks nothing of its own: the takes it did not own are resolved now (lane reads-find)"); assert.deepEqual(unknownBaselineAskOf(draft, { madeOwn: false, dirty: true }), { waits: true, ask: null }); // A line whose last read was its own: its numbers again (S3's rule), still its own. - assert.deepEqual(unknownBaselineAskOf(tuneStartOf({ madeWith: { ...MADE_LIVELY, temperature: 0.9 }, baseline: null }), { madeOwn: true }).ask, { temperature: 0.9, top_p: 0.92, repeat_penalty: 1.25, takes: 3 }); + const ownMade = { ...MADE_LIVELY, temperature: 0.9 }; + assert.deepEqual(unknownBaselineAskOf(tuneStartOf({ madeWith: ownMade, baseline: null, own: lineOwnOf({ tuning: ownMade, tuningAsked: true }) }), { madeOwn: true }).ask, { temperature: 0.9, top_p: 0.92, repeat_penalty: 1.25, takes: 3 }); }); test("review 3 #3: Use <character>'s -- a line whose last read was its own goes back to its character: nothing of its own asked", () => { @@ -101,12 +104,42 @@ test("review 3 #3: Use <character>'s -- a line whose last read was its own goes assert.ok(asksSampler(tuneAskOf(tuneStartOf({ madeWith: own, baseline: b }), b)), "before: its own numbers, asked as its own"); const back = characterTuneOf(own, b); assert.deepEqual([back.draft.temperature, back.draft.top_p, back.draft.repeat_penalty], ["0.4", "0.8", "1.2"], "the draft at the character's"); - assert.deepEqual(tuneAskOf(back.draft, back.baseline), { takes: 3 }, "the next press asks only the takes: recorded \"preset\""); + assert.equal(tuneAskOf(back.draft, back.baseline), null, "the next press asks nothing of its own -- the takes too are the character's or the settings' now -- and records \"preset\""); }); test("review 3 #4: no character now, the last read the character's since removed -- the Tune starts from the last read's numbers (S3)", () => { const none = { character: null, madeOwn: false }; const d = tuneStartOf({ madeWith: MADE_LIVELY, baseline: none }); - assert.deepEqual([d.temperature, d.top_p, d.repeat_penalty, d.takes], ["0.75", "0.92", "1.25", "3"]); + assert.deepEqual([d.temperature, d.top_p, d.repeat_penalty, d.takes], ["0.75", "0.92", "1.25", ""], "the sampler the last read's (S3); the takes it did not own empty: the editor's setting"); assert.deepEqual(tuneStartOf({ madeWith: MADE_LIVELY, baseline: none }), tuneStartOf({ madeWith: MADE_LIVELY }), "S3's start, exactly"); }); + +// --------------------------------------------------------------------------- +// LINE-OWNED VALUES ONLY (lane reads-find, the orchestrator's ruling 2): a plain press passes back only what the line +// owned (`tuningOwn`, else an older take's every recorded value when it asked true); the character's or the settings' +// -- takes included -- are resolved now. +// --------------------------------------------------------------------------- + +test("lineOwnOf: tuningOwn when recorded; an older take asked true owns every recorded value; else none", () => { + assert.deepEqual(lineOwnOf({ tuning: MADE_LIVELY, tuningAsked: "preset", tuningOwn: { takes: 5 } }), { takes: 5 }); + assert.deepEqual(lineOwnOf({ tuning: MADE_LIVELY, tuningAsked: true }), MADE_LIVELY); + assert.equal(lineOwnOf({ tuning: MADE_LIVELY, tuningAsked: "preset" }), null, "an old take that owned only its takes reads as owning none (the known limit)"); + assert.equal(lineOwnOf({ tuning: MADE_LIVELY }), null); + assert.equal(lineOwnOf(null), null); +}); + +test("a plain press: the character's takes changed -- the old recorded takes are not sent; a line-owned takes survives", () => { + // Made under the character's tuning with the editor's 3 takes; the character names 4 takes now. + const now = { character: { name: "The Teller", tuning: { ...LIVELY, takes: 4 } }, madeOwn: false }; + assert.equal(plainPressAskOf({ madeWith: MADE_LIVELY, baseline: now, own: lineOwnOf({ tuning: MADE_LIVELY, tuningAsked: "preset" }) }), null, "the character's 4 is asked as it is now"); + // The line asked its own 5 takes (tuningOwn): they survive, the sampler is still the character's. + assert.deepEqual(plainPressAskOf({ madeWith: { ...MADE_LIVELY, takes: 5 }, baseline: now, own: { takes: 5 } }), { takes: 5 }); + // Its own takes equal to the character's now are still its own. + assert.deepEqual(plainPressAskOf({ madeWith: { ...MADE_LIVELY, takes: 4 }, baseline: now, own: { takes: 4 } }), { takes: 4 }); + // No character: S3's rule for the sampler; the takes only when owned. + assert.equal(plainPressAskOf({ madeWith: { temperature: 0.55, takes: 3 }, baseline: { character: null, madeOwn: false } }), null); + assert.deepEqual(plainPressAskOf({ madeWith: { temperature: 0.7, takes: 3 }, baseline: null, own: { temperature: 0.7, takes: 3 } }), { temperature: 0.7, takes: 3 }); + // The untouched bench press is this same ask (ReadAgain: tuneAskOf of the start, the baseline with ownTakes). + const b = { ...now, ownTakes: 5 }; + assert.deepEqual(tuneAskOf(tuneStartOf({ madeWith: { ...MADE_LIVELY, takes: 5 }, baseline: b, own: { takes: 5 } }), b), plainPressAskOf({ madeWith: { ...MADE_LIVELY, takes: 5 }, baseline: now, own: { takes: 5 } })); +}); diff --git a/umtool/report-to-video/post-narration.mjs b/umtool/report-to-video/post-narration.mjs @@ -205,7 +205,9 @@ const ITEM_KEYS = new Set([...MIX_KEYS, "script", "excerpt", "engine", "voice", // `tuningAsked` (lane character-tuning): where an Orpheus take's tuning came from -- true (its line's own: the // command's flags, the bench's Tune), "preset" (its character's: stale when that changes, cast.mjs tuningStale). // Absent: none was asked (the defaults), or unknown (made before it was recorded). -const TAKE_KEYS = new Set(["file", "engine", "voice", "seconds", "script", "at", "note", "speed", "lufs", "jobId", "parts", "label", "source", "steps", "words", "slurs", "lexicon", "read", "said", "speedAsked", "screenLine", "tuning", "reading", "forReading", "tuningAsked"]); +// `tuningOwn` (lane reads-find): the LINE's own values exactly as asked (the flags, the bench's Tune; absent: it owned +// none) -- what a plain press passes back; every other value is the character's or the settings', resolved anew. +const TAKE_KEYS = new Set(["file", "engine", "voice", "seconds", "script", "at", "note", "speed", "lufs", "jobId", "parts", "label", "source", "steps", "words", "slurs", "lexicon", "read", "said", "speedAsked", "screenLine", "tuning", "reading", "forReading", "tuningAsked", "tuningOwn"]); const STEP_KEYS = new Set(["op", "engine", "voice", "pitch", "semitones", "params", "ranAt", "job", "drop", "tempo", "spans", "pauses", "revoice"]); // `role` (post-thread.mjs): the text a part reads -- "post", "quoted", "parent:<i>", "media:<i>"; `voice`, `piece`: the batch's; // `engine`: the part's own when it is not the take's (a cast voice that names its engine: postThreadRead.mjs). @@ -691,6 +693,8 @@ export function validatePostNarration(e) { if (t.speedAsked !== undefined && t.speedAsked !== true && t.speedAsked !== "item" && t.speedAsked !== "preset") errors.push(`${tw}.speedAsked must be true, "item" or "preset"`); if (t.tuningAsked !== undefined && t.tuningAsked !== true && t.tuningAsked !== "preset") errors.push(`${tw}.tuningAsked must be true (its line's own tuning) or "preset" (its character's)`); errors.push(...tuningProblems(t.tuning, t.reading, tw)); + if (t.tuningOwn !== undefined && (!isObj(t.tuningOwn) || !Object.keys(t.tuningOwn).length)) errors.push(`${tw}.tuningOwn must be the line's own tuning values (or absent: it owned none)`); + else if (t.tuningOwn !== undefined) errors.push(...tuningProblems(t.tuningOwn, undefined, `${tw}.tuningOwn`).map((x) => x.replace(`${tw}.tuningOwn.tuning`, `${tw}.tuningOwn`))); if (t.forReading !== undefined && t.forReading !== true) errors.push(`${tw}.forReading must be true (or absent)`); if (t.read !== undefined && !(isObj(t.read) && t.read.kind === "thread" && JSON.stringify(t.read).length <= 4000)) errors.push(`${tw}.read must be {kind: "thread", …} (how the thread read was asked for)`); // A RECORDING OF ONE SCREEN LINE (postScreensCli.mjs `posts screen … record`, post-screens.mjs): the line it was