Archilyzer · Source

archilyzer

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

commit 0d8e361bba78ff085da0ec72f459217c1418cd78
parent 872d70d3bc6ddce86b4cefc40fd4856bbd992716
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 13 Oct 2026 23:25:36 -0400

threads: Use this on an alternative sets the clips' threads with the list (r28 M9, lane E's question 2)

A threads draft's alternative now keeps {list, clips} (clip id → thread
id); the task applies the list alone. writeDraftedField takes the clips:
each clip's thread set, removed from a clip in none, a clip the cut lacks
refused, and the entries checked as the build checks them
(validateThreadEntries). An alternative without clips writes the list as
before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mcommon/lib/report/draft/tasks/panelTasks.test.ts | 28++++++++++++++++++++++++++++
Mcommon/lib/report/draft/tasks/threads.ts | 8++++++--
Mumtool/lib/report/drafted-writer.test.mjs | 22++++++++++++++++++++++
Mumtool/lib/report/manifest.mjs | 33++++++++++++++++++++++++++++++---
4 files changed, 86 insertions(+), 5 deletions(-)

diff --git a/common/lib/report/draft/tasks/panelTasks.test.ts b/common/lib/report/draft/tasks/panelTasks.test.ts @@ -338,6 +338,34 @@ test("threads: refused with operator's flips; forced over drafted flips replaces assert.ok(p.lines.some((l) => /the drafted flips were removed/.test(l))); }); +test("threads: a draft kept as an alternative carries the clips' assignments with the list (release 28 M9)", async () => { + const p = await project(await kit("manifests/full.video.manifest.json")); + const before = await p.manifestNow(); + const answer = { + threads: [{ id: "shop", label: "The bakery" }, { id: "prize", label: "The contest" }], + clips: [ + { clip: "c01", thread: "shop" }, + { clip: "c02", thread: "shop" }, + { clip: "c03", thread: "shop" }, + { clip: "c04", thread: "prize" }, + { clip: "c05", thread: "prize" }, + { clip: "c06", thread: "prize" }, + { clip: "c07", thread: "shop" }, + ], + }; + ol.push(jsonReply(answer), jsonReply(answer)); + const out = await threads(p.input({ force: true }), p.deps); + assert.equal(out.status, "done", `${out.summary}\n${p.lines.join("\n")}`); + const now = await p.manifestNow(); + assert.deepEqual(now.render.chrome.threads, before.render.chrome.threads, "the operator's threads stand"); + const alt = (await p.draftNow("threads")).alternatives; + assert.equal(alt.length, 1); + assert.equal(alt[0]!.reason, "operator"); + const v = alt[0]!.value as { list: { id: string }[]; clips: Record<string, string> }; + assert.deepEqual(v.list.map((t) => t.id), ["shop", "prize"]); + assert.deepEqual(v.clips, { c01: "shop", c02: "shop", c03: "shop", c04: "prize", c05: "prize", c06: "prize", c07: "shop" }); +}); + test("youtube: the better of two attempts, the summary's failing sentence removed; the operator's field kept and the draft an alternative", async () => { const p = await project(await kit("manifests/basic.video.manifest.json")); const title = "What the baker of Synth Kitchen says about the bakery"; diff --git a/common/lib/report/draft/tasks/threads.ts b/common/lib/report/draft/tasks/threads.ts @@ -249,12 +249,16 @@ export const THREADS_SPEC: MediaTaskSpec<ThreadsUnit, ThreadsValue, ThreadsInput } return best; }, + // The field is `{list}`; what an alternative keeps also carries `clips`, the + // clip → thread assignments, so umtool's "Use this" sets each clip's thread + // with the list (release 28 M9). `apply` writes the list alone. toField(value, u) { u.chosen = planThreads(value, u, u.manifest); - return { list: u.chosen.list }; + return { list: u.chosen.list, clips: u.chosen.clips }; }, apply(manifest, u, value, provenance, force, ctx) { - const res = applyDraft(manifest, { field: "render.chrome.threads", value, provenance, force }); + const { list } = value as { list: unknown }; + const res = applyDraft(manifest, { field: "render.chrome.threads", value: { list }, provenance, force }); if (!res.applied) return res; setClipThreads(manifest, u.chosen?.clips ?? {}); const m = manifest as VideoManifest & { render?: { chrome?: Record<string, unknown> } }; diff --git a/umtool/lib/report/drafted-writer.test.mjs b/umtool/lib/report/drafted-writer.test.mjs @@ -103,3 +103,25 @@ test("writeDraftedField: Use this writes an alternative as the operator's, check await assert.rejects(writeDraftedField(p.dir, { field: "publish.youtube", value: { title: 3 } }), StructureRefused); assert.equal(await readFile(path.join(p.dir, MANIFEST_NAME), "utf8"), before); }); + +test("writeDraftedField: a threads alternative's clips set each clip's thread with the list (release 28 M9)", async (t) => { + const p = await project(t); + const clipIds = (await p.read()).timeline.filter((e) => e.type === "clip").map((e) => e.id); + const [first, ...others] = clipIds; + const clips = Object.fromEntries([[first, "solo"], ...others.map((id) => [id, "rest"])]); + const list = [{ id: "solo", label: "One clip" }, { id: "rest", label: "The others" }]; + await writeDraftedField(p.dir, { field: "render.chrome.threads", value: { list, clips } }); + const m = await p.read(); + assert.deepEqual(m.render.chrome.threads, { list }, "the field is the list alone"); + assert.equal(m.timeline.find((e) => e.id === first).thread, "solo"); + assert.ok(others.every((id) => m.timeline.find((e) => e.id === id).thread === "rest")); + assert.ok(!marks(m).includes("*:render.chrome.threads"), "taken, it is the operator's"); + // A clip the cut lacks, or a thread left with no clip, is refused; the file stays. + const before = await readFile(path.join(p.dir, MANIFEST_NAME), "utf8"); + await assert.rejects(writeDraftedField(p.dir, { field: "render.chrome.threads", value: { list, clips: { nope: "solo" } } }), /clips this cut does not have: nope/); + await assert.rejects( + writeDraftedField(p.dir, { field: "render.chrome.threads", value: { list, clips: Object.fromEntries(clipIds.map((id) => [id, "rest"])) } }), + /thread solo has no clip/, + ); + assert.equal(await readFile(path.join(p.dir, MANIFEST_NAME), "utf8"), before); +}); diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs @@ -31,6 +31,7 @@ import { } from "umtool-report-to-video/ledger-totals"; import { isCalendarDate } from "umtool-report-to-video/attribution"; import { normalizeOnscreen, validateChrome, validatePosts, validateTeaser, validateTeasers } from "umtool-report-to-video/deck"; +import { validateThreadEntries } from "yt-dlp-transcript-common/lib/report/panels.mjs"; import { applySectionEnter } from "./sections.mjs"; import { normalizeClaim, validateClaims } from "umtool-report-to-video/factcheck"; import { validateNarration } from "umtool-report-to-video/narration"; @@ -1109,8 +1110,12 @@ export async function updateNarration(dir, id, text, { token = null, at = null } * lines a teaser's lines (validateTeaser) * narration a card's narration object (validateNarration) * render.chrome.flips the deck's flips (validateChrome) - * render.chrome.threads the deck's thread list (validateChrome; each - * clip's `thread` key is the build's to check) + * render.chrome.threads the deck's thread list (validateChrome); a value + * that carries `clips` ({clip id: thread id}, what a + * threads draft keeps, release 28 M9) sets each + * clip's `thread` too — removed from a clip in none + * — and the entries are checked as the build checks + * them (validateThreadEntries) * publish.youtube `{ title, description }` (validatePublish) * * The cut's order ("timeline") is not taken this way: an order replaces every @@ -1155,12 +1160,34 @@ export async function writeDraftedField(dir, { entry = null, field, value }, { t throw new Error("flips and threads are drawn by the on-screen deck, and this manifest has none — turn the deck on first"); } const key = field === "render.chrome.flips" ? "flips" : "threads"; - const chrome = { ...render.chrome, [key]: copy() }; + const v = copy(); + // A threads draft's assignments ride beside its list; the field is the list. + let clips = null; + if (key === "threads" && v && typeof v === "object" && !Array.isArray(v) && "clips" in v) { + clips = v.clips; + delete v.clips; + if (!clips || typeof clips !== "object" || Array.isArray(clips) || Object.values(clips).some((t) => typeof t !== "string" || !t)) { + throw new StructureRefused(["the threads' clips must map a clip id to a thread id"]); + } + const known = new Set((m.timeline ?? []).filter((e) => e?.type === "clip").map((e) => e.id)); + const strays = Object.keys(clips).filter((id) => !known.has(id)); + if (strays.length) throw new StructureRefused([`the threads name clips this cut does not have: ${strays.join(", ")}`]); + } + const chrome = { ...render.chrome, [key]: v }; const { chrome: _old, ...rest } = render; const already = new Set(validateChrome(render.chrome, rest)); const errors = validateChrome(chrome, rest).filter((e) => !already.has(e)); if (errors.length) throw new StructureRefused(errors); m.render = { ...render, chrome }; + if (clips) { + for (const e of m.timeline ?? []) { + if (e?.type !== "clip") continue; + if (clips[e.id]) e.thread = clips[e.id]; + else delete e.thread; + } + const entryErrors = validateThreadEntries(m); + if (entryErrors.length) throw new StructureRefused(entryErrors); + } return { entry: null, field, value: chrome[key] }; }); }