Archilyzer · Source

archilyzer

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

commit c7c8d06e33617e50173e0138722b8cc65fd95755
parent d8cd92aaf5f94585ccdb06064980ea0819f3e94f
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 12 Nov 2026 21:34:31 -0500

umtool quote-check --take, review 1: a take only ever adds a refusal -- a stale take row no longer hides the project's current one (M1, S9, S10)

M1: readTakeQuoteCheck merged {...project.clips, ...own.clips}, so a take row that was STALE for the
take's clip (judged at another cut) shadowed the project's current `moved` row and quoteGate skipped
it: a take main refuses rendered, and check --take showed nothing (review probes probe-quote.mjs,
probe-quote-inherit.mjs: main ['c1 moved'], lane []).
Now readTakeQuoteCheck returns the two files ({own, project}); takeQuoteGate refuses what the take's
current rows refuse AND what the project's current rows refuse (union; a current take `ok` never
removes a project refusal of the same cut); takeQuoteRefusals reads the files and the draft's
timeline and is what makeTake's gate and check --take (takeQuoteDecisions) call. takeQuoteRows picks
the row that speaks for a clip (own if current, else the project's) for --status and window --align.
quoteGate refuses a take's two-file shape outright instead of answering [].
S9: takeQuoteCheckDir / readTakeQuoteCheck / takeQuoteDecisions check isTakeId before any read.
S10: the project's row counts for a take's clip only when the draft's entry of that id has the same
video and channel (a row records neither). rowIsCurrent and the path without --take are unchanged:
quote-check without --take prints and writes byte-identical output on main and the lane (probe on the
quoteCheck.test fixture).
Tests: quoteCheckTake.test.mjs, both probe cases, a current take ok beside a current project moved,
another video/channel under the same id, the id check.

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

Diffstat:
Meditor/CHANGELOG.md | 2+-
Mumtool/bin/umtool.mjs | 16+++++++++++++---
Mumtool/docs/cli.md | 2+-
Mumtool/docs/knobs.md | 6++++--
Mumtool/lib/cli/groups.mjs | 2+-
Mumtool/lib/report/quoteCheck.mjs | 97++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
Mumtool/lib/report/quoteCheckTake.test.mjs | 69++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Mumtool/lib/report/takeMaker.mjs | 7++++---
8 files changed, 172 insertions(+), 29 deletions(-)

diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -110,7 +110,7 @@ - **Bad clip windows of one video can be evicted, and nothing else.** `evict-clips` only evicted by age, a channel at most, so the four windows cut from a corrupt saved video could not be removed without emptying the channel's cache. `pnpm ops evict-clips --json '{"slug": "<slug>", "id": "<video>"}'` now evicts every cached window of that one video; `"windows": ["<from>-<to>", …]` (the cache's own names) narrows it to those, and `"covering": [{"from": s, "to": s}, …]` to every window that overlaps a span, a wider window holding it included. A set-aside `.desynced` window of a targeted span goes with it, `"dryRun": true` only lists, and `"olderThanDays"` is optional here (still required for the by-age form). A video that does not exist is said in the run's summary, as is a named window that is not cached; an unknown shape is refused by name. umtool asks for it: `umtool fetch <project> --refetch <clipId>[,<clipId>…]` evicts the windows overlapping those clips' fetch spans, waits for that, then fetches as usual (`--refetch-video <slug>/<id>` for every window the project asks of a video; `--dry-run` evicts nothing), and records what went in `fetch-runs.json`. Needs a restart of the editor. - **A saved alternate can be dropped once it has been checked.** A download over a copy already in the saved-video store keeps both and flags the other copy (`source-media.alt-<h>p-<stamp>.<ext>`, listed by `pnpm ops get saved-alternates`), but nothing could remove one alternate after the check: the only deleter took the whole video. `pnpm ops drop-saved-alternate --json '{"slug": "<slug>", "id": "<video>", "file": "<alternate>"}'` now deletes that one copy from the store and its entry from `saved-video.json`, leaving the rest of the pointer as it was (`alternates` goes when it empties); `"dryRun": true` says what it would free and changes nothing. The active copy, a name the pointer does not list and any path are refused, and so is a store being moved; an alternate already gone from disk is cleaned from the pointer. The video page's Source video card now lists a saved video's alternates, each with **Drop this alternate** (and a confirm). No undo. Needs a restart of the editor. - **umtool: a take's windowed preview shows the seconds you asked for, with its chrome, in its own file.** `umtool take <p> --id <t> --preview --at 440 --dur 170` timed the window over the project's draft rather than the take, so on a take with its own timeline it rendered a different stretch (92 s of early clips), its timeline and counters started from zero, and it was written over the take's full preview. `--at`/`--dur` with `--preview` are now seconds of the take's own cut, timed by its last preview's or render's schedule (or, with neither, its entries' own lengths, said as estimates); an `--at` past the end is refused. The whole take is built, reusing its segments, and only the window is laid and encoded, with the deck at its state at that second (build-video's new `--cut-window <at> <dur>`). The file is `takes/<t>/out/<slug>.preview.<at>-<to>.mp4`, built in `out/window/`; the full preview is never touched. `--preview` without `--at`, and a take's own window, render as before. -- **umtool: the quote check can judge a take.** `umtool quote-check` only judged the project's draft, so a take with clips of its own was never checked (on 12 Nov, 25 rows blocked the draft and the take went unjudged), and a take's render was gated by the draft's rows alone. `umtool quote-check <p> --take <t>` now judges the take's clips as it renders them and keeps the rows in `takes/<t>/quote-check.json`; the project's `quote-check.json` is not touched. A take's render, the new `umtool check <p> --take <t>` and `umtool window <p> <clip> --take <t> --align` read the take's rows first; a clip the take has not been checked for keeps the project's row, as before. `--status --take <t>` lists the take's rows and says which came from the project. +- **umtool: the quote check can judge a take.** `umtool quote-check` only judged the project's draft, so a take with clips of its own was never checked (on 12 Nov, 25 rows blocked the draft and the take went unjudged), and a take's render was gated by the draft's rows alone. `umtool quote-check <p> --take <t>` now judges the take's clips as it renders them and keeps the rows in `takes/<t>/quote-check.json`; the project's `quote-check.json` is not touched. A take's render, the new `umtool check <p> --take <t>` and `umtool window <p> <clip> --take <t> --align` refuse what the take's own current rows refuse and what the project's current rows refuse for the same clip and cut, so checking a take can only add refusals, never remove one the project's rows make. `--status --take <t>` lists the take's rows and says which came from the project. - **umtool: editing a take from a terminal no longer says it is deprecated.** `umtool window … --take`, `timeline <p> --take <t> <verb>`, `posts <verb> … --in-take` and `take --id <t> --import-item` printed "deprecated — edits land in the draft now; open the take there first (umtool takes open …)" on stderr. They are the supported way to edit a take without touching the draft (as `set --take` and `look --take` already were): they write only the take's patch, with an undo point. The advice was the problem, since `takes open` writes the take over the draft. The line is gone; what the commands do, their stdout and `--json` are unchanged. The old take walk's route (`/api/report/takes/timeline`) still says it. - **umtool: the by-date weight chart no longer piles a recent run of weights into its right edge.** The chart's width was shared by days alone, so on rev9-a9 the nine weights said for July–November 2026 shared 31 px of a 2023–26 stretch, under a pixel apart. Now half the width goes by days and half by how many weights each stretch holds: the same run spreads over about 100 px, no two weights closer than 11 px, and a long empty stretch still reads as longer. Breaks, years, the line and the reflow are unchanged. - **umtool: `umtool lint` says which ledger is live.** A `ledger*.json` beside a video's manifest (quartering-diet's `ledger.draft.json`: 186 rows from 30 Aug) looked like the ledger, but the build, the instruments and `umtool ledger` read only the manifest's own `ledger` (564 rows). `umtool lint` now warns once per such file, naming the manifest's ledger as the live one and the file as stale — or as newer than the manifest, with rows that are not in the cut — with both row counts and dates. The file is never changed or moved (a project's own script may still read it); it is only said when the manifest carries a ledger. diff --git a/umtool/bin/umtool.mjs b/umtool/bin/umtool.mjs @@ -1165,16 +1165,26 @@ async function cmdWindow() { // manifest (or the take's) holds it now. if (has("--align")) { if (patch.cutStart !== undefined || patch.cutEnd !== undefined) die("--align sets the cut; give it or --cut-start/--cut-end, not both"); - const { alignPatch, readQuoteCheck, readTakeQuoteCheck } = await import("../lib/report/quoteCheck.mjs"); - // A take's clip: the take's verdicts (quote-check --take) over the project's. - const doc = val("--take") !== undefined ? await readTakeQuoteCheck(p.dir, val("--take")) : await readQuoteCheck(p.dir); + const { alignPatch, readQuoteCheck, readTakeQuoteCheck, takeQuoteRows } = await import("../lib/report/quoteCheck.mjs"); + let doc; let entry = null; if (val("--take") !== undefined) { const { resolveTakeManifest } = await import("../lib/report/takeManifest.mjs"); entry = ((await resolveTakeManifest(p.dir, val("--take"))).manifest.timeline ?? []).find((e) => e.id === clipId) ?? null; + // A take's clip: the row that speaks for it -- its own when current, else the project's for the same clip. + const { readManifest } = await import("../lib/projects/report.mjs"); + let docs; + try { + docs = await readTakeQuoteCheck(p.dir, val("--take")); + } catch (e) { + die(e?.message ?? String(e)); + } + const got = entry ? takeQuoteRows([entry], docs, (await readManifest(p.dir))?.timeline ?? []).get(clipId) : null; + doc = { clips: { [clipId]: got?.row ?? docs.own.clips[clipId] ?? null } }; } else { const { readManifest } = await import("../lib/projects/report.mjs"); entry = ((await readManifest(p.dir))?.timeline ?? []).find((e) => e.id === clipId) ?? null; + doc = await readQuoteCheck(p.dir); } if (!entry) die(`no clip ${clipId}`); try { diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -28,7 +28,7 @@ Inbox cannot disagree about what is wrong with one. | `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 -- the row is then a person's, never re-sent to a model or overwritten; `--reject <id>` / `--reject-all`: dropped. An author an anonymous character covers is never proposed for and never sent to a model. 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)) | -| `quote-check <project> [--take T] [--clips a,b] [--pad S] [--json]` · `quote-check <project> [--take T] --status` | **is each clip's quote in the seconds it plays?** The cut ±15 s of the source the render would cut it from, transcribed by the editor (`pnpm ops transcribe`, words on — its transcription lane), the quote found in those words and in the cues: `ok`, `moved` (heard more than 0.5 s from where the cues have it), `not-found`; rows in `quote-check.json`, stale when the cut or the quote changes; the editor's work files go to `<project>/.quote-check/`, never under `out/` (a link onto a media drive the editor will not write in); `check` blocks on `moved`/`not-found` (`clip-quote-moved`, `clip-quote-missing`), a take refuses them, `prep --status` counts them; `--take T` judges the take's own clips into `takes/T/quote-check.json`, which the take's render, `check --take T` and `window --take T --align` read over the project's rows ([knobs.md](knobs.md#the-quote-check-is-the-quote-where-the-clip-plays)) | +| `quote-check <project> [--take T] [--clips a,b] [--pad S] [--json]` · `quote-check <project> [--take T] --status` | **is each clip's quote in the seconds it plays?** The cut ±15 s of the source the render would cut it from, transcribed by the editor (`pnpm ops transcribe`, words on — its transcription lane), the quote found in those words and in the cues: `ok`, `moved` (heard more than 0.5 s from where the cues have it), `not-found`; rows in `quote-check.json`, stale when the cut or the quote changes; the editor's work files go to `<project>/.quote-check/`, never under `out/` (a link onto a media drive the editor will not write in); `check` blocks on `moved`/`not-found` (`clip-quote-moved`, `clip-quote-missing`), a take refuses them, `prep --status` counts them; `--take T` judges the take's own clips into `takes/T/quote-check.json`, which the take's render, `check --take T` and `window --take T --align` read with the project's rows (either current row refuses: `--take` only ever adds a refusal) ([knobs.md](knobs.md#the-quote-check-is-the-quote-where-the-clip-plays)) | | `check-joins <project> --take <id> [--json] [--all] [--limit <n>]` | do a rendered take's **post joins carry on**: every boundary of its master where the next post item draws a post the one before showed, its planned join, the SSIM across it and the largest frame-to-frame step (read-only, ffmpeg) -- worst first ([report-video.md](report-video.md#thread-scenes-whole-threads-the-join-manual-threads-wide-attachments-context-media-link-visits-the-branch-map)) | | `link-policy <project> [--via <site id \| https://…>] [--direct <slug,…>] [--clear] [--fix] [--json]` | the project's **link policy** (`provenance.linkPolicy`): cite via site X, these channels direct. With no flag, prints it and every clip whose QR breaks it; `--fix` rewrites each one that has a fix through the window writer; new clips are written by it. **Exit 1** when a clip still breaks it ([knobs.md](knobs.md#the-link-policy)) | | `patch-markers <project> [<file>.patch.json] [--fix] [--json]` | take patches whose deck markers name a clip not in the cut (a take made with one is refused); `--fix` gives each the `after` of the cut's marker of the same label; **exit 1** when one is left ([knobs.md](knobs.md#take-patches-follow-a-removal)) | diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -131,8 +131,10 @@ clip like an incorrect one — unless a person heard it and ruled: `umtool windo clip rulings applied), the rows in `takes/<t>/quote-check.json`, never the project's file (`umtool quote-check <p> --take <t> [--clips a,b]`, `--status --take <t>`). The take's render, `umtool check <p> --take <t>` (its quote rows replace the project's) and `umtool window <p> <clip> ---take <t> --align` read the take's rows over the project's: a clip the take never judged keeps the -project's row, which counts only while the take's cut and quote are the same. +--take <t> --align` read the take's rows AND the project's: a take refuses what either current row +refuses, so `--take` only ever adds a refusal to what the project's rows refuse for the same cut, never takes +one away. A row counts only while it is current for the take's clip (its cut and quote); the project's, only +for the same clip too (the draft's entry of that id has the take's video and channel). The recording's own clock is the editor's (AGENTS.md, "Two FILES of one recording disagree too"): a Rumble window is cut from the saved whole recording through `data/<id>/clock.json`, so a clip fetched diff --git a/umtool/lib/cli/groups.mjs b/umtool/lib/cli/groups.mjs @@ -110,7 +110,7 @@ export const GROUPS = [ ], docs: [ ["`quote-check <project> [--take T] [--clips a,b] [--pad S] [--json]` · `quote-check <project> [--take T] --status`", - "**is each clip's quote in the seconds it plays?** The cut ±15 s of the source the render would cut it from, transcribed by the editor (`pnpm ops transcribe`, words on — its transcription lane), the quote found in those words and in the cues: `ok`, `moved` (heard more than 0.5 s from where the cues have it), `not-found`; rows in `quote-check.json`, stale when the cut or the quote changes; the editor's work files go to `<project>/.quote-check/`, never under `out/` (a link onto a media drive the editor will not write in); `check` blocks on `moved`/`not-found` (`clip-quote-moved`, `clip-quote-missing`), a take refuses them, `prep --status` counts them; `--take T` judges the take's own clips into `takes/T/quote-check.json`, which the take's render, `check --take T` and `window --take T --align` read over the project's rows ([knobs.md](knobs.md#the-quote-check-is-the-quote-where-the-clip-plays))"], + "**is each clip's quote in the seconds it plays?** The cut ±15 s of the source the render would cut it from, transcribed by the editor (`pnpm ops transcribe`, words on — its transcription lane), the quote found in those words and in the cues: `ok`, `moved` (heard more than 0.5 s from where the cues have it), `not-found`; rows in `quote-check.json`, stale when the cut or the quote changes; the editor's work files go to `<project>/.quote-check/`, never under `out/` (a link onto a media drive the editor will not write in); `check` blocks on `moved`/`not-found` (`clip-quote-moved`, `clip-quote-missing`), a take refuses them, `prep --status` counts them; `--take T` judges the take's own clips into `takes/T/quote-check.json`, which the take's render, `check --take T` and `window --take T --align` read with the project's rows (either current row refuses: `--take` only ever adds a refusal) ([knobs.md](knobs.md#the-quote-check-is-the-quote-where-the-clip-plays))"], ], }, { diff --git a/umtool/lib/report/quoteCheck.mjs b/umtool/lib/report/quoteCheck.mjs @@ -25,9 +25,12 @@ // A TAKE'S OWN VERDICTS (`--take <t>`): the take's clips -- its patch over the // draft, as it renders -- judged into takes/<t>/quote-check.json. A take's // refusal, `umtool check <p> --take <t>` and `window --take --align` read the -// take's rows over the project's (readTakeQuoteCheck): a clip the take never -// judged keeps the project's row, which says something only while its cut and -// quote are the take's too (rowIsCurrent). +// take's rows AND the project's (takeQuoteGate): a take may only ever ADD a +// refusal to what the project's rows refuse for the same cut, never take one +// away (review, 12 Nov: a stale take row once hid a current project `moved`). +// Each row counts only while it is current for the take's clip (rowIsCurrent); +// the project's, only for the same clip too -- its video and channel the +// draft's entry of that id (a row does not record them). // // Plain ESM: the CLI runs under bare node; the app reads the file. import { mkdir, readFile, realpath, rename, rmdir, writeFile } from "node:fs/promises"; @@ -38,12 +41,16 @@ import { cueWords, findQuote, ON_TIME_S, quoteOffset } from "umtool-report-to-vi import { resolveLocalSource } from "umtool-report-to-video/sources"; import { REPORTS_ROOT, resolveProject } from "../projects/core.mjs"; import { kindMakesTakes } from "../projects/kinds.mjs"; +import { isTakeId } from "./takes.mjs"; import { channelsLayersFor, hasShadowChannels, readManifest } from "../projects/report.mjs"; import { tmpPathFor } from "yt-dlp-transcript-common/lib/atomicFile.mjs"; export const QUOTE_CHECK_FILE = "quote-check.json"; /** Where a take's own rows live: beside its take.json. */ -export const takeQuoteCheckDir = (projectDir, take) => path.join(projectDir, "takes", take); +export const takeQuoteCheckDir = (projectDir, take) => { + if (!isTakeId(take)) throw new Error(`"${take}" is not a take id (lower-case letters, digits, dashes)`); + return path.join(projectDir, "takes", take); +}; /** Seconds either side of the cut that are transcribed: the 6 Nov offsets reached 13.6 s. */ export const SEARCH_PAD_S = 15; /** Cues read either side of the searched span, to find the quote in. */ @@ -88,14 +95,66 @@ export async function readQuoteCheck(dir) { } /** - * The rows a take is judged by: its own (takes/<t>/quote-check.json) over the project's, by clip id. `own` and - * `project` say which file each came from. + * The two files a take is judged by: its own rows (takes/<t>/quote-check.json) and the project's. The take id is + * checked before anything is read. * @param {string} projectDir * @param {string} take + * @returns {Promise<{ own: { clips: Record<string, any> }, project: { clips: Record<string, any> } }>} */ export async function readTakeQuoteCheck(projectDir, take) { - const [project, own] = await Promise.all([readQuoteCheck(projectDir), readQuoteCheck(takeQuoteCheckDir(projectDir, take))]); - return { version: 1, clips: { ...project.clips, ...own.clips }, own: new Set(Object.keys(own.clips)) }; + const dir = takeQuoteCheckDir(projectDir, take); + const [project, own] = await Promise.all([readQuoteCheck(projectDir), readQuoteCheck(dir)]); + return { own, project }; +} + +/** The draft's entry of that id is the same clip as the take's: the same video and channel (a row records neither). */ +const sameClip = (draftEntry, e) => !draftEntry || (String(draftEntry.video ?? "") === String(e.video ?? "") && String(draftEntry.channel ?? "") === String(e.channel ?? "")); + +/** + * Per clip of the take, the row that speaks for it: its own when current for the take's entry, else the project's + * when current and about the same clip (sameClip), else null. `from` says whose. For --status and --align. + * @param {Record<string, any>[]} timeline the take's + * @param {Awaited<ReturnType<typeof readTakeQuoteCheck>>} docs + * @param {Record<string, any>[]} draftTimeline the project's manifest's + * @returns {Map<string, { row: Record<string, any>, from: "take" | "project" }>} + */ +export function takeQuoteRows(timeline, docs, draftTimeline = []) { + const draft = new Map((draftTimeline ?? []).filter((e) => e?.id).map((e) => [e.id, e])); + const out = new Map(); + for (const e of timeline ?? []) { + if (e?.type !== "clip") continue; + const own = docs.own?.clips?.[e.id]; + const proj = docs.project?.clips?.[e.id]; + if (rowIsCurrent(own, e)) out.set(e.id, { row: own, from: "take" }); + else if (rowIsCurrent(proj, e) && sameClip(draft.get(e.id), e)) out.set(e.id, { row: proj, from: "project" }); + } + return out; +} + +/** + * What a take's render refuses: the clips its own current rows refuse AND those the project's current rows refuse + * (same clip, same cut) -- never fewer than the project's rows refuse for the same cut. `from` on each. + * @param {Record<string, any>[]} timeline the take's + * @param {Awaited<ReturnType<typeof readTakeQuoteCheck>>} docs + * @param {Record<string, any>[]} draftTimeline + */ +export function takeQuoteGate(timeline, docs, draftTimeline = []) { + const draft = new Map((draftTimeline ?? []).filter((e) => e?.id).map((e) => [e.id, e])); + const own = quoteGate(timeline, docs.own ?? { clips: {} }).map((g) => ({ ...g, from: "take" })); + const mine = new Set(own.map((g) => g.id)); + const proj = quoteGate( + (timeline ?? []).filter((e) => sameClip(draft.get(e?.id), e)), + docs.project ?? { clips: {} }, + ).filter((g) => !mine.has(g.id)).map((g) => ({ ...g, from: "project" })); + const order = new Map((timeline ?? []).map((e, i) => [e?.id, i])); + return [...own, ...proj].sort((a, b) => (order.get(a.id) ?? 0) - (order.get(b.id) ?? 0)); +} + +/** takeQuoteGate over the files on disk: the take's rows, the project's, and the draft's timeline. */ +export async function takeQuoteRefusals(projectDir, take, timeline) { + const docs = await readTakeQuoteCheck(projectDir, take); + const draft = await readFile(path.join(projectDir, "video.manifest.json"), "utf8").then((t) => JSON.parse(t)?.timeline ?? [], () => []); + return takeQuoteGate(timeline, docs, draft); } async function writeQuoteCheck(dir, doc) { @@ -201,6 +260,8 @@ export function rowLine(id, row) { * @returns {{ id: string, status: string, why: string }[]} */ export function quoteGate(timeline, doc) { + // A take's two files (readTakeQuoteCheck) are not one doc: their gate is takeQuoteGate, never an empty [] here. + if (doc && !doc.clips && (doc.own || doc.project)) throw new Error("quoteGate takes one quote-check doc; a take's rows go through takeQuoteGate"); const out = []; for (const e of timeline ?? []) { if (e?.type !== "clip" || e.quoteRuled) continue; @@ -245,19 +306,19 @@ export function alignPatch(entry, row) { * @param {string} take */ export async function takeQuoteDecisions(p, take) { + if (!isTakeId(take)) throw new Error(`"${take}" is not a take id (lower-case letters, digits, dashes)`); const [{ resolveTakeManifest }, { applyMontageRulings, readMontageRulings }] = await Promise.all([ import("./takeManifest.mjs"), import("umtool-report-to-video/montage-rulings"), ]); const { manifest } = await resolveTakeManifest(p.dir, take); const timeline = applyMontageRulings(manifest, await readMontageRulings(p.dir)).manifest.timeline ?? []; - const doc = await readTakeQuoteCheck(p.dir, take); - return quoteGate(timeline, doc).map((g) => ({ + return (await takeQuoteRefusals(p.dir, take, timeline)).map((g) => ({ kind: g.status === "moved" ? "clip-quote-moved" : "clip-quote-missing", project: p.id, take, target: g.id, - why: `take ${take}: ${g.why.replace("<p>", `${p.id} --take ${take}`)}${doc.own.has(g.id) ? "" : " (the project's row: the take has not been checked)"}`, + why: `take ${take}: ${g.why.replace("<p>", `${p.id} --take ${take}`)}${g.from === "take" ? "" : " (the project's row)"}`, severity: "blocking", href: `/projects/${p.id}/takes/${take}`, fix: @@ -447,7 +508,8 @@ export const QUOTE_CHECK_USAGE = [ "missing quote unless the clip is ruled (umtool window <p> <clip> --quote-ruled).", "--take T judges the TAKE's clips (its patch over the draft, as it renders) into takes/T/quote-check.json; the", "take's render, `umtool check <p> --take T` and `umtool window <p> <clip> --take T --align` read the take's rows", - "over the project's (a clip the take never judged keeps the project's row while its cut and quote are the same).", + "and the project's: a take refuses what either current row refuses (the project's only for the same clip: video,", + "channel), so --take only ever adds a refusal, never takes one away.", ].join("\n"); class CliError extends Error {} @@ -490,12 +552,17 @@ export async function quoteCheckCommand(args, { reportsRoot = REPORTS_ROOT, log const json = !!flags["--json"]; if (flags["--status"]) { - const doc = take ? await readTakeQuoteCheck(project.dir, take) : await readQuoteCheck(project.dir); + const doc = take ? null : await readQuoteCheck(project.dir); + // A take's: the row that speaks for each clip (takeQuoteRows), else its own stale one. + const docs = take ? await readTakeQuoteCheck(project.dir, take) : null; + const picked = docs ? takeQuoteRows(manifest.timeline, docs, (await readManifest(project.dir))?.timeline ?? []) : null; + const own = docs?.own ?? null; const rows = []; for (const e of manifest.timeline ?? []) { if (e?.type !== "clip") continue; - const row = doc.clips[e.id]; - rows.push({ id: e.id, ...(row ?? { status: "unchecked" }), current: rowIsCurrent(row, e), ...(take && row ? { from: /** @type {any} */ (doc).own.has(e.id) ? "take" : "project" } : {}) }); + const got = picked?.get(e.id) ?? null; + const row = take ? got?.row ?? own?.clips[e.id] : doc?.clips[e.id]; + rows.push({ id: e.id, ...(row ?? { status: "unchecked" }), current: rowIsCurrent(row, e), ...(take && row ? { from: got?.from ?? "take" } : {}) }); } if (json) log(JSON.stringify({ project: project.id, ...(take ? { take } : {}), clips: rows }, null, 1)); else for (const row of rows) log(`${rowLine(row.id, row)}${row.current || row.status === "unchecked" ? "" : " (stale: the cut or the quote changed)"}${row.from === "project" ? " (the project's row)" : ""}`); diff --git a/umtool/lib/report/quoteCheckTake.test.mjs b/umtool/lib/report/quoteCheckTake.test.mjs @@ -10,7 +10,7 @@ import { mkdir, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises" import os from "node:os"; import path from "node:path"; import { fileURLToPath } from "node:url"; -import { quoteCheckCommand, readTakeQuoteCheck, takeQuoteDecisions } from "./quoteCheck.mjs"; +import { quoteCheckCommand, quoteGate, readQuoteCheck, readTakeQuoteCheck, takeQuoteCheckDir, takeQuoteDecisions, takeQuoteRefusals } from "./quoteCheck.mjs"; import { makeTake } from "./takeMaker.mjs"; const HERE = path.dirname(fileURLToPath(import.meta.url)); @@ -89,7 +89,7 @@ test("a take's refusal and `check --take` read the take's verdicts, the project' assert.equal((await run(p, ["diet"])).code, 0); assert.equal((await run(p, ["diet", "--take", "t1"])).code, 0); const doc = await readTakeQuoteCheck(p.dir, "t1"); - assert.equal(doc.clips.c43.status, "moved"); + assert.equal(doc.own.clips.c43.status, "moved"); // check --take: the take's c43 blocks, naming the take. const ds = await takeQuoteDecisions({ id: "diet", dir: p.dir }, "t1"); assert.deepEqual(ds.map((d) => [d.kind, d.target, d.severity]), [["clip-quote-moved", "c43", "blocking"]]); @@ -104,9 +104,72 @@ test("a take's refusal and `check --take` read the take's verdicts, the project' assert.equal(rendered, false); // No take file: the project's rows still gate it (nothing loosened). await rm(path.join(p.takeDir, "quote-check.json")); - assert.equal((await readTakeQuoteCheck(p.dir, "t1")).clips.c43.status, "no-window"); + assert.equal((await readTakeQuoteCheck(p.dir, "t1")).project.clips.c43.status, "no-window"); assert.equal(await exists(path.join(p.dir, "quote-check.json")), true); } finally { await rm(p.root, { recursive: true, force: true }); } }); + +// Review round 1 (M1): `--take` may only ever ADD refusals to what the project's rows refuse for the same cut. +const writeRows = (dir, rows) => writeFile(path.join(dir, "quote-check.json"), JSON.stringify({ version: 1, clips: rows })); +async function bare(timelineDraft, takePatch) { + const root = await mkdtemp(path.join(os.tmpdir(), "quote-gate-take-")); + const dir = path.join(root, "p"); + await mkdir(path.join(dir, "takes", "t1"), { recursive: true }); + await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify({ slug: "p", render: { width: 640, height: 360, fps: 15 }, timeline: timelineDraft })); + await writeFile(path.join(dir, "takes", "t1", "take.json"), JSON.stringify({ id: "t1", group: "takes", order: 0, label: "T1", kind: "different", preview: "preview.mp4", draft: true, window: "full", patch: takePatch })); + return { root, dir }; +} + +test("a stale take row never hides the project's current refusal (the take re-set to the draft's cut)", async () => { + const c1 = { type: "clip", id: "c1", channel: "ch", video: "v", quote: "q", cutStart: 10, cutEnd: 20, start: 10, end: 20 }; + const p = await bare([c1], { render: { crf: 20 } }); + try { + await writeRows(p.dir, { c1: { status: "moved", offset: 3.1, cut: { from: 10, to: 20 }, quote: "q" } }); + // judged when the take had c1 at 12-22 (ok); the take is back at 10-20 + await writeRows(takeQuoteCheckDir(p.dir, "t1"), { c1: { status: "ok", offset: 0, cut: { from: 12, to: 22 }, quote: "q" } }); + const main = quoteGate([c1], await readQuoteCheck(p.dir)).map((g) => `${g.id} ${g.status}`); + assert.deepEqual(main, ["c1 moved"]); + assert.deepEqual((await takeQuoteRefusals(p.dir, "t1", [c1])).map((g) => `${g.id} ${g.status}`), main); + } finally { + await rm(p.root, { recursive: true, force: true }); + } +}); + +test("a take that inherits the draft's re-cut: its own row from before is stale, the project's current moved row refuses (makeTake's gate and check --take)", async () => { + const c1 = { type: "clip", id: "c1", channel: "ch", video: "v", quote: "q", start: 30, end: 40 }; + const p = await bare([c1], { render: { crf: 20 } }); + try { + await writeRows(takeQuoteCheckDir(p.dir, "t1"), { c1: { status: "ok", offset: 0, cut: { from: 10, to: 20 }, quote: "q" } }); + await writeRows(p.dir, { c1: { status: "moved", offset: 13.1, cut: { from: 30, to: 40 }, quote: "q" } }); + assert.deepEqual((await takeQuoteRefusals(p.dir, "t1", [c1])).map((g) => `${g.id} ${g.status}`), ["c1 moved"]); + assert.deepEqual((await takeQuoteDecisions({ id: "p", dir: p.dir }, "t1")).map((d) => `${d.kind} ${d.target}`), ["clip-quote-moved c1"]); + // A current take row that says ok does not take away the project's current refusal of the same cut either. + await writeRows(takeQuoteCheckDir(p.dir, "t1"), { c1: { status: "ok", offset: 0, cut: { from: 30, to: 40 }, quote: "q" } }); + assert.deepEqual((await takeQuoteRefusals(p.dir, "t1", [c1])).map((g) => `${g.id} ${g.status}`), ["c1 moved"]); + } finally { + await rm(p.root, { recursive: true, force: true }); + } +}); + +test("the project's row speaks for a take's clip only when it is the same clip: another video or channel under the same id is not judged by it (S10)", async () => { + const draft = { type: "clip", id: "c1", channel: "ch", video: "v", quote: "q", start: 30, end: 40 }; + const other = { ...draft, video: "w" }; + const p = await bare([draft], { timeline: [other] }); + try { + await writeRows(p.dir, { c1: { status: "moved", offset: 13.1, cut: { from: 30, to: 40 }, quote: "q" } }); + assert.deepEqual(await takeQuoteRefusals(p.dir, "t1", [other]), []); + assert.deepEqual(await takeQuoteRefusals(p.dir, "t1", [{ ...draft, channel: "elsewhere" }]), []); + // The same clip: refused as main refuses it. + assert.deepEqual((await takeQuoteRefusals(p.dir, "t1", [draft])).map((g) => g.id), ["c1"]); + } finally { + await rm(p.root, { recursive: true, force: true }); + } +}); + +test("a take id is checked before anything is read (S9)", async () => { + await assert.rejects(readTakeQuoteCheck("/nowhere", "../../.."), /not a take id/); + assert.throws(() => takeQuoteCheckDir("/nowhere", "../x"), /not a take id/); + await assert.rejects(takeQuoteDecisions({ id: "p", dir: "/nowhere" }, "../x"), /not a take id/); +}); diff --git a/umtool/lib/report/takeMaker.mjs b/umtool/lib/report/takeMaker.mjs @@ -729,10 +729,11 @@ async function makeTakeLocked(projectDir, rawSpec, opts) { // A clip whose quote the quote check did not hear where it plays (lane // one-clock, lib/report/quoteCheck.mjs): refused the same way, unless a // person ruled it (`quoteRuled`). No check on record refuses nothing. The - // take's own rows (`quote-check --take`) over the project's. + // take's own current rows (`quote-check --take`) AND the project's: never + // fewer refusals than the project's rows make for the same cut. { - const { quoteGate, readTakeQuoteCheck } = await import("./quoteCheck.mjs"); - const unheard = quoteGate(renderDoc.timeline, await readTakeQuoteCheck(projectDir, spec.id)); + const { takeQuoteRefusals } = await import("./quoteCheck.mjs"); + const unheard = await takeQuoteRefusals(projectDir, spec.id, renderDoc.timeline); if (unheard.length) { throw new Error( `${spec.id}: ${unheard.map((u) => u.why.replace("<p>", path.basename(projectDir))).join("; ")} ` +