Archilyzer · Source

archilyzer

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

commit daa62081e9044b283bd1b2e8a626572391638e30
parent 4c5f8ad81146943c325e28bb01a2ee7fe892701e
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 12 Nov 2026 21:55:28 -0500

Merge lane/take-tools: a take's tools mean the take -- take --preview --at/--dur is cut seconds of the take's own cut, with the chrome at its state then, in a file of its own (never over the full preview), one window at a time and its own status; quote-check --take judges the take's clips into the take's file, and the take's render and check --take refuse what either the take's rows or the project's current rows refuse; editing a take with --take is the supported path and no longer prints a deprecation line; the by-date chart gives a stretch width by the weights it holds as well as by its days; umtool lint names a stale ledger file beside the manifest's live ledger

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

Diffstat:
Meditor/CHANGELOG.md | 5+++++
Mumtool/bin/umtool.mjs | 41+++++++++++++++++++++++++++++++++++------
Mumtool/docs/cli.md | 14+++++++-------
Mumtool/docs/knobs.md | 18+++++++++++++++++-
Mumtool/docs/report-video.md | 17+++++++++++++++++
Mumtool/lib/cli/groups.mjs | 21+++++++++++----------
Mumtool/lib/cli/verbs.mjs | 4++--
Mumtool/lib/queue/cli.mjs | 9+++++----
Aumtool/lib/report/ledgerFiles.test.mjs | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/report/lintCli.mjs | 65+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Mumtool/lib/report/postsCli.mjs | 3+--
Mumtool/lib/report/quoteCheck.mjs | 160++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
Aumtool/lib/report/quoteCheckTake.test.mjs | 175+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/report/renderRecord.mjs | 2++
Mumtool/lib/report/takeCli.mjs | 13+++++++++----
Mumtool/lib/report/takeDeprecation.mjs | 13++++++++-----
Mumtool/lib/report/takeEdit.test.mjs | 4++--
Aumtool/lib/report/takeEditFirstClass.test.mjs | 45+++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/report/takeMaker.mjs | 10++++++----
Mumtool/lib/report/takePreview.mjs | 146++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Aumtool/lib/report/takePreviewWindow.test.mjs | 178+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/report/takeRender.mjs | 10++++++----
Mumtool/lib/report/takeScope.test.mjs | 8++++----
Mumtool/lib/report/timelineCli.mjs | 3+--
Mumtool/report-to-video/build-video.mjs | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/modules/trail.mjs | 2+-
Mumtool/report-to-video/trail-plan.mjs | 34++++++++++++++++++++++++++++++----
Mumtool/report-to-video/trail-plan.test.mjs | 24++++++++++++++++++++++++
Mumtool/report-to-video/vertical-deck.test.mjs | 3++-
29 files changed, 1065 insertions(+), 82 deletions(-)

diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -109,6 +109,11 @@ - **The changelog page opens with its Cut and Amend forms, and pages its notes; the latest release can be amended.** `/changelog` rendered the whole of `editor/CHANGELOG.md` (760 KB of markdown, a 2.9 MB response) before the Cut release form at its bottom, so the form took 1 s to appear on an idle machine and 5-10 s on a busy one. The forms now come first (the Cut release button shows in about 0.35 s where it took 1 s) and the notes stream in after them a page at a time (`?page=N`: whole releases up to about 96 KB a page, `[Unreleased]` always on page 1, an index of every release under **All releases**); a link to an older release's anchor (`/changelog#2026-09-26`, or the new per-release `#v0.9.0`) goes to the page that holds it. **Amend the latest release** re-picks its bump (patch, minor or major, counted from the release before it), its date, folds the notes now under `[Unreleased]` into it, or moves it back under `[Unreleased]`; only the newest release, and a version change commits as that version's release (`Release editor 0.12.0`, the amend in the body). The same writer is `pnpm ops amend-release` and `archilyzer release amend`; `/sites` has the form for the export changelog. - **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>`). A schedule older than the take's `take.json` is not trusted (the entries' lengths are used, said as estimates), and an `--at` past the end is refused before anything builds. The file is `takes/<t>/out/<slug>.preview.<at>-<end>.mp4`, `<end>` as rendered (clipped at the cut's end), built in `out/window/`; one window of a take renders at a time, `umtool take status` lists it as `window <at>-<to>`, and the window lays no claim rail. 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` 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 (with `--take`, the take's) as the live one and the file as stale — or as newer than the manifest when it holds row ids the live ledger lacks, which it names — with both row counts and local dates. Only a file that reads as a ledger counts: a list of rows with ids, or `{rows|ledger: […]}`; `ledgerSchema.json`, an empty list and unreadable files are not mentioned. 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. ## [0.12.0] - 2026-10-28 - **An X post's screenshot is of the post, not of a page in the middle of laying itself out.** On 2026-10-27 a forced capture of TheQuartering's post 2114859155022389342 came out shifted about 100 px: its left edge cut off, X's menu laid over its words and the gap beside the column showing; another post once came out as a strip of the post above it. The shot was a full-page capture, which resizes the page for the moment of the capture — in the X session profile the page saw its window go to 1×1 — and X laid itself out again for that size while it was being captured, so the shot was cut from a different layout than the one measured. A post is now shot from the window as it stands: scrolled into it, the window made taller first when the post is taller than it, so nothing is resized under the shot; and the post is measured again after the shot and shot again if it moved. An X Article's shot is taken the same way. Posts taller than the tallest window (16,384 px) are still shot from a full-page capture. Needs a restart of the editor. diff --git a/umtool/bin/umtool.mjs b/umtool/bin/umtool.mjs @@ -13,11 +13,11 @@ // umtool ls [--kind K] [--template T] [--state S] [--open] [--blocking] // [--q TEXT] [--sort name|recent] [--json] // umtool show <project> [--json] -// umtool check [<project> | --all] [--json] exit 1 on anything blocking +// umtool check [<project> | --all] [--take <t>] [--json] exit 1 on anything blocking (--take: the take's quote rows) // umtool links <project> [--json] [--fix] do the clip QRs open on their sites (out/links.json) // umtool cast [ls|add|set|rm|undo|project|audition|use|reread] … the characters' voices across projects (castCli.mjs) // umtool speaker-check <project> [--clip <id> …] [--set 'Name=…'] [--list] which named voice each clip is (speaker-check.json) -// umtool quote-check <project> [--clips a,b] [--status] is each clip's quote in the seconds it plays (quote-check.json) +// umtool quote-check <project> [--take <t>] [--clips a,b] [--status] is each clip's quote in the seconds it plays (quote-check.json; a take's: takes/<t>/) // umtool check-joins <project> --take <id> [--json] [--all] do the post joins of a rendered take carry on, or jump // umtool link-policy <project> [--via <site>] [--direct a,b] [--clear] [--fix] cite via site X; these channels direct // umtool decisions [--json] @@ -416,7 +416,25 @@ async function cmdCheck() { const one = positional[0]; const refs = one ? [await pick(one)] : await projectRefs(); const rows = []; - for (const p of refs) rows.push(...(await decisionsFor(p))); + // --take <t>: the project's rows, its quote check's for the TAKE's clips and the take's verdicts + // (quoteCheck.mjs takeQuoteDecisions: takes/<t>/quote-check.json over the project's). + const take = val("--take"); + if (take !== undefined && !one) die("--take names a take of one project: umtool check <project> --take <t>"); + for (const p of refs) { + const ds = await decisionsFor(p); + if (take === undefined) { + rows.push(...ds); + continue; + } + const { takeQuoteDecisions } = await import("../lib/report/quoteCheck.mjs"); + let own; + try { + own = await takeQuoteDecisions(p, take); + } catch (e) { + die(`--take ${take}: ${e?.message ?? String(e)}`); + } + rows.push(...ds.filter((d) => d.kind !== "clip-quote-moved" && d.kind !== "clip-quote-missing"), ...own); + } const sorted = sortDecisions(rows); const blocking = sorted.filter((d) => d.severity === "blocking"); @@ -1147,15 +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 } = await import("../lib/report/quoteCheck.mjs"); - const doc = 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 { @@ -1171,7 +1200,7 @@ async function cmdWindow() { // same rules, an undo point first -- never into the project's manifest. const take = val("--take"); if (take !== undefined) { - (await import("../lib/report/takeDeprecation.mjs")).warnTakeEdit("window --take", { project: p.id, take }); + // A supported path, said nothing about (12 Nov; takeDeprecation.mjs): the take's patch, never the draft. try { const { updateTakeClip } = await import("../lib/report/takeEdit.mjs"); const res = await updateTakeClip(p.dir, take, clipId, patch); diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -19,7 +19,7 @@ Inbox cannot disagree about what is wrong with one. |---|---| | `ls [--kind --template --state --open --blocking --q --sort --json]` | the index, as text or JSON | | `show <project> [--json]` | one project: summary, the cut, per-clip status, decisions | -| `check [<project>] [--json]` | **exit 1 on anything blocking** — including an `out/`, `clips/` or `share-*/` link whose drive is not there (`storage-unreachable`) | +| `check [<project>] [--take T] [--json]` | **exit 1 on anything blocking** — including an `out/`, `clips/` or `share-*/` link whose drive is not there (`storage-unreachable`). `--take T`: the quote check's rows are the TAKE's — its clips, judged by `takes/T/quote-check.json` over the project's | | `links <project> --embed-ids [--clips a,b] [--dry-run] [--json]` | the **published embed id**: every clip citing a Rumble URL-slug folder the archive does not serve gets `siteVideo` (the folder's `metadata.info.json` id, shareLine.mjs `siteVideoFor`), a citeUrl naming the folder moved with it; no network, one write, one undo point. The Cut tab's Project › Rumble cites ([knobs.md](knobs.md#the-inspector-panels-this-weeks-hand-edits-in-the-ui)) | | `links <project> [--json] [--fix]` | do the clip QRs open on their sites? `corpus.json` → the channel's manifest → `slugToPage` → the shard's record, one request at a time, shards from the cue cache; recorded in `out/links.json`, which `check` reads (`link-dead` blocking, `links-unverified`, `links-unchecked`); `--fix` rewrites a Twitch id the site serves as `v<id>`, and a Rumble folder id (the URL slug) as the embed id the site serves (the clip gets `siteVideo`); **exit 1** when a link is dead ([knobs.md](knobs.md#do-the-qr-links-open)). The same record dates each site's deploy: a cited video newer than it is `site-deploy-behind` ([knobs.md](knobs.md#the-sites-the-links-depend-on)) | | `cast [ls] \| add <id> --name … --voice <engine:voice> [--handles a,b] [--speakers …] [--speed s] [--convert-engine e] [--convert-voice v] [--convert-pitch target\|source\|contour] [--convert-semitones n] [--enhance on\|off] [--trim on\|off] [--trim-pad ms] [--direction "…"] [--narrator] \| set <id> … \| rm <id> \| undo [--json]` | **THE CAST** (`<reports>/.umtool/cast.json`, [knobs.md](knobs.md#the-cast-each-characters-voice-in-every-project-and-the-voices-page)): the characters across projects, one writer, an undo point a write. **A character is a PRESET**, two of them ([knobs.md](knobs.md#a-character-is-a-preset)): `synthetic` -- the STOCK voice it reads in (`--voice`) and its speed (`--speed` 0.5–2; Orpheus has none) -- and `recorded` -- what a recording of them is made into: the stock voice (`--convert-voice`; a file or a recording is refused), the engine, the **pitch** the converted read lands on (`--convert-pitch`: `target` the stock voice's own, `source` the pitch it was read at, `contour` the read's rises and falls at the stock voice's register; `--convert-semitones` -12…12 moves a followed one), whether it is cleaned first (`--enhance`), its edges trimmed to speech (`--trim`, `--trim-pad` the ms kept either side) and a `--direction` (one line for the person reading, never sent to a model). `set` lays the flags given over the presets; `default` for one takes that key off; `--no-convert`, `--no-speed`. A version 1 file (`voice`, `convert` at a character's top) reads as these presets and the first write makes it version 2 (`undo` puts the old file back). A followed pitch on an engine that has none, semitones with nothing followed, a speed or a pad out of range: **exit 1** | @@ -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> [--clips a,b] [--pad S] [--json]` · `quote-check <project> --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 ([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)) | @@ -70,14 +70,14 @@ Inbox cannot disagree about what is wrong with one. | `notes …` | operator notes: list, read, reply, resolve ([notes.md](notes.md)) | | `modules list [--json]` · `modules apply <project> [--config FILE] [--dry-run] [--json]` · `modules apply <project> [--config FILE] --take <id> [--label L] [--at S --dur S \| --full] [--quick] [--force] [--from TAKE] [--keep-frames] [--patch-out FILE]` | the **video modules** (release 39): `list` every module, its kind, slot and where its settings live; `apply` maps the project's `module-config.json` (the modules a video wants, in MODULES-DESIGN's vocabulary) into the manifest's homes (`report-to-video/modules/config-loader.mjs`) — the preset, the deck's subtitle and QR, the counter's series and each clip's marks, the stamps, the rail's markers, the chapters, the pairs, the status ledger, the intro, the finale — and lists every field with no home, by path. Without `--take` the manifest is rewritten through `replaceManifest` (a snapshot first); with `--take` it is that take's patch (`takes/<id>.modules-patch.json`, or `--patch-out`) and the take is made from it as `take` makes one, the manifest untouched. **Exit 1** when the result would not build (the build's sentences) ([knobs.md](knobs.md#look-presets)) | | `preset list [--json]` · `preset show <name> [--json]` · `preset save <name> --from <project> [--description D] [--force]` · `preset apply <name\|none> <project> [--replace] [--json]` | the **look presets** (`umtool/presets/<name>.json`, or `UMTOOL_PRESETS_DIR`; built in: `plain-deck` `huck-deck` `ember-deck` `archive-catalog` `basic`): a render block a manifest stands on (`"preset": "<name>"`), laid under it — preset → manifest → style → take patch. `save` keeps a project's look and leaves its content out; `apply` names the preset on the cut through `updatePreset` (nothing copied in), refused when the cut over it would not build (a basic cut's chrome is not checked); `--replace` also clears the manifest's own value of every key the preset sets, after an undo point (`revisions/…-auto-before-preset-replace`), and prints what went ([knobs.md](knobs.md#look-presets)) | -| `lint <project> [--take <take>] [--variant sourced\|full] [--final] [--json]` | **the manifest lint** (`report-to-video/lint.mjs`, what a build runs before it renders a frame) from umtool: the project's manifest, or with `--take` the take's (its patches applied, written beside the project's manifest for the lint as its render's is, then removed) -- plus the **files its post items name**: a picked read, an attachment or a context post's media not in the project is an ERROR, another kept take a warning. Run it after an import and before queueing the render. `--json`: `{ok, entries, errors, warnings}`. **Exit 0 no error · 1 an error · 2 usage** | +| `lint <project> [--take <take>] [--variant sourced\|full] [--final] [--json]` | **the manifest lint** (`report-to-video/lint.mjs`, what a build runs before it renders a frame) from umtool: the project's manifest, or with `--take` the take's (its patches applied, written beside the project's manifest for the lint as its render's is, then removed) -- plus the **files its post items name**: a picked read, an attachment or a context post's media not in the project is an ERROR, another kept take a warning. A `ledger*.json` beside a manifest that carries its own `ledger` -- one that parses as rows with ids (never `ledgerSchema.json`) -- is a warning naming the live one (the manifest's, or with `--take` the take's: what the build and `umtool ledger` read) and the file as stale, or NEWER only when it holds row ids the live ledger lacks (named), with both counts and local dates; the file is never touched. Run it after an import and before queueing the render. `--json`: `{ok, entries, errors, warnings}`. **Exit 0 no error · 1 an error · 2 usage** | | `take <project> --id <id> --label L [--group G] [--kind similar\|different] [--summary S] [--style NAME] [--patch FILE \| --patch-json JSON \| --set path=value …] [--effect NAME] [--at S --dur S \| --full] [--quick] [--force] [--progress ndjson]` | one **take**: the manifest with a montage style's patch, then an overlay effect's (`--effect`, release 35), then the take's own, rendered into `takes/<id>/` (the Takes page's New take); `--id <id> --rebuild` makes one again from its own `take.json` ([report-video.md](report-video.md#making-takes)) | | `take <project> --id <id> --label L [--patch F \| …] --draft` (`--no-render`) · `take <project> --id <id> [--full \| --at S --dur S]` · `take <project> --id <id> --rebuild [--full \| --at S --dur S]` · `take <project> --id <id> --promote [--anyway] [--json]` | a **draft** take: recorded with nothing rendered, to be walked first; a draft named with no patch flags is rendered from its stored (walked) patch, and `--rebuild` takes a window flag; **make it the cut**: the take's patch applied to the manifest now, one undo point (`revisions/…-auto-before-promote-take`), refused (exit 1) when its timeline would replace a cut that changed since, until `--anyway` ([report-video.md](report-video.md#walking-a-take-drafts-edits-into-the-take-and-making-it-the-cut)) | | `take <project> --id <id> … --uncensored` · build-video `--uncensored` | the **uncensored cut** ([knobs.md](knobs.md#the-slur-filter-slurs-masked-in-what-is-published-off-for-the-uncensored-cut)): the same cut with the post items' slur filter off -- `render.posts.slurs.on: false` in the take's patch (a `--rebuild` keeps it; a censored take is not rebuilt uncensored, **exit 2**: make a take of its own), its label gains "(uncensored)", take.json's `slurs` records `censored` or `uncensored`. The redaction of private words and censored attachments stay on | | `take <project> --id <id> --draft --from <take> [--label L] [--patch F \| --patch-json J \| --set p=v …]` | a **draft made from another take**: that take's style and patch (a `--patch` merged over it), its label "<that label> (from <take>)" unless `--label`, nothing rendered; its timeline is its own from then on, and its render's `--from` (segments reused) is a separate flag of the render ([take-scoped edits](#edit-a-take-not-the-project-items-from-other-projects-and-take-scoped-edits)) | -| `take <project> --id <id> --preview [--from <take>] [--at S --dur S \| --full] [--priority] [--json]` | the take's **preview**: the take as stored (a draft too, from its walked patch) composed exactly as its render is -- the same 1920×1080 layout, segments, chrome frames and sound -- with only its final picture encoded smaller and faster (`render.preview`: 1280×720, x264 veryfast, crf 26) into `takes/<id>/out/<slug>.preview.mp4`; its build, schedule and record (`render.json`, `render.log`) in `takes/<id>/out/preview/`. The full render (`preview.mp4`, `out/<slug>.mp4`, `out/sourced/`, `take.json`, `render.json`) is never touched. Reuses this take's own full render, and `--from`'s full render and preview ([report-video.md](report-video.md#fast-feedback-preview-and-changes-renders), [knobs.md](knobs.md#fast-feedback-a-preview-and-a-reel-of-the-changes)) | +| `take <project> --id <id> --preview [--from <take>] [--at S --dur S \| --full] [--priority] [--json]` | the take's **preview**: the take as stored (a draft too, from its walked patch) composed exactly as its render is -- the same 1920×1080 layout, segments, chrome frames and sound -- with only its final picture encoded smaller and faster (`render.preview`: 1280×720, x264 veryfast, crf 26) into `takes/<id>/out/<slug>.preview.mp4`; its build, schedule and record (`render.json`, `render.log`) in `takes/<id>/out/preview/`. The full render (`preview.mp4`, `out/<slug>.mp4`, `out/sourced/`, `take.json`, `render.json`) is never touched. `--at S --dur S`: cut seconds of the take's own cut (its schedule when newer than its take.json, else its entries' lengths as estimates; an S past the end refused before anything builds), the chrome at its state then and no rail, into its own `takes/<id>/out/<slug>.preview.<S>-<end>.mp4` (`<end>` as rendered, clipped at the cut's end; build and record in `out/window/`, one window at a time; `take status` says `window S-…`), never over the full preview. Reuses this take's own full render, and `--from`'s full render and preview ([report-video.md](report-video.md#fast-feedback-preview-and-changes-renders), [knobs.md](knobs.md#fast-feedback-a-preview-and-a-reel-of-the-changes)) | | `take <project> --id <id> --changes [--from <take>] [--pad 3] [--no-preview] [--priority] [--json]` | the take's **changes reel**: only what changed against `--from` (default: the take's own `from`, or the take a draft was made from) -- each added, re-read, re-picked, re-voiced, trimmed, held, fx'd, … item with a neighbour either side, rendered in one build (`takes/<id>/out/changes/`), cut to the item ± `--pad` s, a label burned in (`21:19 · p-2116831815466193102 · re-voiced`: its time in the FULL cut), joined into `takes/<id>/out/<slug>.changes.mp4`; a removed item shows as the join it leaves. `takes/<id>/changes.json` lists the pieces with their full-cut times and how exact they are (`times.basis`: `measured` -- the base's measured schedule plus the changed items' measured lengths -- or `estimate`). Preview quality unless `--no-preview`. Nothing changed: no reel, and the list says so | -| `take <project> --id <id> --import-item <project>:<item>[,<item>…] [--import-item …] [--after <entry> \| --before <entry>] [--as <id>] [--dry-run] [--json]` | **items of another project into a take** -- deprecated, saying so in one line on stderr: edits land in the draft, so open the take there and use `timeline <p> import-item` (`takeImport.mjs`): each entry CLONED from the source's manifest as it is now (its card, context, knobs, narration with its takes and its pick) into the take's timeline -- one write, an undo point of the take's (`timeline <p> --take <id> undo`); the files it names (narration takes and their `take-<n>.*` sidecars, the parts' cache files, attachments, a context post's media, the picture of each author it draws that the take lacks, added to the take's `postAvatars`) **hard-linked** into this project's dir at the same path, so the render and the lint find them (copied across filesystems; the same file already there is left; ANOTHER file at the path: linked under `imports/<source>/<path>` and the clone names that). The source project and this project's manifest are only read. **Placed** `--after`/`--before` an entry of the take (several items in the order named, one after another), else by the post's date when the take's posts are in date order, else at the end. **Again**: updated in place from the source (moved only with `--after`/`--before`), `unchanged` with no write when nothing differs. `--as`: one item under another id (a second copy). `--dry-run`: the plan and the placement, nothing linked or written. `--json`: `items[] {id, action added\|updated\|unchanged\|moved, at {index, after, before}, narration {takes, pick, file}, files[], avatars[]}`, `revision`. Refused while the take renders. **Exit 0 · 1 refused (no such item, take or entry; a link out of the project) · 2 usage** | +| `take <project> --id <id> --import-item <project>:<item>[,<item>…] [--import-item …] [--after <entry> \| --before <entry>] [--as <id>] [--dry-run] [--json]` | **items of another project into a take** -- into the take's patch, the draft untouched (`timeline <p> import-item` is the draft's twin; `takeImport.mjs`): each entry CLONED from the source's manifest as it is now (its card, context, knobs, narration with its takes and its pick) into the take's timeline -- one write, an undo point of the take's (`timeline <p> --take <id> undo`); the files it names (narration takes and their `take-<n>.*` sidecars, the parts' cache files, attachments, a context post's media, the picture of each author it draws that the take lacks, added to the take's `postAvatars`) **hard-linked** into this project's dir at the same path, so the render and the lint find them (copied across filesystems; the same file already there is left; ANOTHER file at the path: linked under `imports/<source>/<path>` and the clone names that). The source project and this project's manifest are only read. **Placed** `--after`/`--before` an entry of the take (several items in the order named, one after another), else by the post's date when the take's posts are in date order, else at the end. **Again**: updated in place from the source (moved only with `--after`/`--before`), `unchanged` with no write when nothing differs. `--as`: one item under another id (a second copy). `--dry-run`: the plan and the placement, nothing linked or written. `--json`: `items[] {id, action added\|updated\|unchanged\|moved, at {index, after, before}, narration {takes, pick, file}, files[], avatars[]}`, `revision`. Refused while the take renders. **Exit 0 · 1 refused (no such item, take or entry; a link out of the project) · 2 usage** | | `take … --priority` · `takes make … --priority` · `render-mode on [--for 90m] [--note T] [--json \| --print-token]` · `render-mode on [--for 90m] [--note T] [--print-token] -- <cmd …>` · `render-mode off [--force] [--json]` · `render-mode status [--json]` | **render mode**: a render the operator waits for gets the machine. `--priority` turns it on for the take's (or the batch's) lifetime — on at the start, off at the end, on a failure and on a signal; the Takes page's **Give renders the machine** is the same flag. While it is on, every other heavy job (e2e suites, `next build`s, the publish stages, other renders) waits at the heavy slot's door (`queue-lock: held for a render (…) — waiting`), the render runs on the floor 4000 MB and the cap 10240 MB, and the editor's transcription, download and Speakers lanes are held through its ops (`lane`; only the ones not already held, and only those are released at off). `render-mode on` is a window (default 2h) for a chain of renders: every `umtool take` started in it renders in it, another command joins with the `RENDER_PRIORITY_TOKEN` it prints (`--print-token`: the token alone on stdout, the rest on stderr). **`on … -- <cmd …>` is the form for a script**: the command is spawned with the token in its environment, the hold is the command's pid, and it is released when the command exits — done, failed, or umtool signalled (the signal is passed on); umtool exits with the command's code, and inside a manual window the command joins it. A bare `on` in a script leaves the window behind (the chain trap). `off` ends it (a running take's hold only with `--force`, else it ends with the take); `status` says what holds it and releases a stale hold's lanes. A hold whose process is gone or whose window is over is no hold. Needs WORKER_TOKEN and the editor at ARCHILYZER_EDITOR_URL for the lanes; without them it still holds the door. **Exit 1** when it is already on, or a lane could not be released ([report-video.md](report-video.md#render-mode-giving-a-render-the-machine); WORKTREES.md, "Render mode") | | `take status <project> [--id <take>] [--json] [--log] [--tail N]` | a take's **render record** (`takes/<take>/render.json`, written by every render whoever started it — a terminal, the Takes page, the queue): `state` (`running`, `waiting` at the heavy slot, `done`, `failed`, `cancelled`; `queued` or `blocked` while a queue step waits to render it), `stage` and a rough `percent`, the `error` (the first error line, not a bare "exited 1") and the log's last 40 lines (`tail`), on done the `mp4` and its measured `seconds`; `--log` prints the FULL `takes/<take>/render.log`. A "running" whose process is gone reads **failed** ("the render process is gone"); a done whose mp4 is missing or 0 bytes reads **failed**. **Exit 0 done · 3 queued, waiting or running · 1 failed, cancelled, blocked or none.** Without `--id`: every take with a record, the newest's exit ([queue and poll](#queue-and-poll-instead-of-scripting)); and its fast-feedback renders beside it, `preview` and `changes` (each one's state, mp4, seconds, log; a changes reel's piece count, its base and its list), a queued `--preview`/`--changes` step said as such -- never as the take's own render | | `queue add [--after <qid>\|last] [--label T] [--timeout <minutes>] [--json] -- <umtool subcommand argv…>` | a **step** of the durable queue: the argv of a umtool command, one word per argument (no shell), stored under `<reports root>/.umtool-queue/` and run by the **umtool app** (its systemd unit), one step at a time, in order — so it survives the session that queued it, an app restart and a ship. Prints the qid (`q<N>`) alone on stdout. `--after` waits for that step to be **done**; when it fails or is cancelled this one is **blocked** (and so is whatever waits on it). `--timeout`: the step's limit (default 720 minutes). A step does not start while the app's own job runner is busy (a Takes-page job), and a heavy step still takes the machine's heavy slot and render mode by itself | @@ -167,7 +167,7 @@ draft (the project's manifest); *project*: a project's other files, or reads; *c |---|---|---| | `ls [--kind KIND] [--template TEMPLATE] [--state STATE] [--open] [--blocking] [--q Q] [--sort recent\|name]` | every project, as text | form · *corpus* | | `show <project>` | one project: summary, the cut, per-clip status, decisions | form · *project* | -| `check [<project>] [--all-severities]` | what blocks a build (exit 1 on anything blocking) | form · *project* | +| `check [<project>] [--take TAKE] [--all-severities]` | what blocks a build (exit 1 on anything blocking) | form · *project* | | `links <project> [--fix] [--embed-ids] [--clips CLIPS] [--dry-run]` | do the clip QRs open on their sites (out/links.json) | form · *project* | | `provenance <project> ls` | the project's provenance: site origin, channel slug, channel, link policy | form · *project* | | `provenance <project> set [--site-origin SITE-ORIGIN] [--channel-slug CHANNEL-SLUG] [--channel CHANNEL]` | the project's site origin, channel slug and channel name ("" removes one) | form · *draft* | @@ -191,7 +191,7 @@ draft (the project's manifest); *project*: a project's other files, or reads; *c | `cast reread <project> <character> [--dry-run]` | the items that say a character in another voice, read again | form · queued · *project* | | `cast assign <project> [--model] [--dry-run] [--accept ACCEPT] [--accept-all] [--reject REJECT] [--reject-all] [--change CHANGE] [--voice VOICE] [--speed N] [--name NAME] [--direction DIRECTION] [--anonymous] [--shown SHOWN] [--no-anonymous]` | a proposed character for each author with none (by rule; --model on request); accept, change, reject | form · *project* | | `speaker-check <project> [--clip CLIP…] [--list] [--set SET] [--remove REMOVE]` | which named voice each clip is (speaker-check.json) | form · queued · *project* | -| `quote-check <project> [--clips CLIPS] [--pad N] [--status]` | is each clip's quote in the seconds it plays | form · queued · *project* | +| `quote-check <project> [--take TAKE] [--clips CLIPS] [--pad N] [--status]` | is each clip's quote in the seconds it plays | form · queued · *project* | | `check-joins <project> --take TAKE [--all] [--limit N]` | do a rendered take's post joins carry on | form · queued · *project* | | `link-policy <project> [--via VIA] [--direct DIRECT] [--clear] [--fix]` | cite via site X, these channels direct | form · *draft* | | `patch-markers <project> [<file>] [--fix]` | take patches whose deck markers name a clip not in the cut | form · *draft* | diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -127,6 +127,15 @@ until checked again (`prep --status` counts the stale ones). `umtool check` call clip like an incorrect one — unless a person heard it and ruled: `umtool window <p> <clip> --quote-ruled` (`quoteRuled` on the clip; `--no-quote-ruled` clears it). +**A take's clips** are judged with `--take <t>`: the take as it renders (its patch over the draft, its +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 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 since reads `ok`; the check is what catches a span on a step of that map, a map that could not be @@ -717,6 +726,12 @@ expected the cut). A take is a **saved version** — FROZEN: - **Old addresses.** The take walk (`/projects/<p>/takes/<t>/walk`) and a take's bench (`…/takes/<t>/clip/<id>`) are the Open in draft page now — then the draft's bench. The take-scoped CLI (`--in-take`, `umtool timeline <p> --take`, `umtool window --take`, `/api/report/takes/timeline`) stays for agents. +- **Editing a take from a terminal is supported, and leaves the draft alone.** `umtool set|look|window <p> … --take + <t>`, `umtool timeline <p> --take <t> <verb>`, `umtool posts <verb> … --in-take <t>` and `umtool take <p> --id <t> + --import-item …` write `takes/<t>/take.json`'s patch, an undo point first (`umtool timeline <p> --take <t> undo`), + and never the project's manifest. They say nothing on stderr (from 9 to 12 Nov they printed "deprecated — edits + land in the draft now; open the take there first", whose advice — `takes open` — is the one path that writes the + version over the draft). Only the old take walk's route, `/api/report/takes/timeline`, still says it. ## The workspace (one screen per report video) @@ -2040,6 +2055,7 @@ labelled with its time in the full cut). Neither touches the take's full render | | From a terminal | In umtool | Route | |---|---|---|---| | a preview of the whole take | `umtool take <p> --id <t> --preview [--from <t0>]` → `takes/<t>/out/<slug>.preview.mp4` | the take card's **Preview render**; Play's **Fast render** | `POST /api/report/takes/fast {project, take, kind: "preview"}` (a queue step) | +| a preview of a window of the take | `umtool take <p> --id <t> --preview --at S --dur S` → `takes/<t>/out/<slug>.preview.<S>-<end>.mp4` (its own file, `<end>` as rendered: clipped at the cut's end; the full preview untouched; one window at a time, `take status` says `window S-…`). S and dur are **cut seconds of the take's own cut** (its last preview's or render's schedule when newer than its take.json, else its entries' lengths as estimates; an S past the end refused before anything builds); the whole take is built, only the window laid and encoded, its chrome at its state then; no rail | — | — | | a reel of what changed | `umtool take <p> --id <t> --changes [--from <t0>] [--pad 3] [--no-preview]` → `takes/<t>/out/<slug>.changes.mp4`, `takes/<t>/changes.json` | **Render changes** (against the take's own base) | `… kind: "changes"` | | queued, then polled | `umtool queue add -- take <p> --id <t> --preview` · `umtool take status <p> --id <t> [--json]` (`preview`, `changes`) | the state inline, the local path with **Copy**, **Play** of the file | `GET /api/report/takes/fast?project&take` (`&file=preview\|changes`: the mp4) | @@ -2753,7 +2769,7 @@ Under the dial: the measure's `state.lost.total` (the highest real-time loss cla ### Weight trail -At the foot of the instruments' column: every weight the cut shows -- the STATED ones and (`remembered`) the remembered ones, "≈390, as of Feb 2023" -- placed by the date he was that weight (its `asOf`, else its date), a dot appearing at its event's `t`; ONE line runs through every weight shown, stated and remembered alike, joining neighbours by date once both are said -- so it never passes over a point; of several weights for one day the line takes the one said last and the others stay as marks beside it. A remembered weight is a hollow grey ring with a solid border (a qualified one a size smaller), and a stretch of the line with a remembered end is drawn quieter, grey and thinner; between two stated weights it keeps the accent (a qualified stated one is hollow). The axes FIT what has been said so far (trail-plan.mjs): each new weight outside them reflows the chart over 0.4 s -- the years, the bounds, every dot -- so the time axis advances with the story; a stretch with no statement longer than `gap` is a break in the time axis (a small `//` on the axis foot, each side with its own years; a year inside a stretch a short tick there) and the line across it dotted, so a decade of nothing does not take the width from the dense run after it. A red ring on the latest said. The `mark` line (300) dashed across; with `count` and the mark at 300, `UNDER 300 · SAID n×` counts the measure's `totals.under300` rows as the cut reaches each. +At the foot of the instruments' column: every weight the cut shows -- the STATED ones and (`remembered`) the remembered ones, "≈390, as of Feb 2023" -- placed by the date he was that weight (its `asOf`, else its date), a dot appearing at its event's `t`; ONE line runs through every weight shown, stated and remembered alike, joining neighbours by date once both are said -- so it never passes over a point; of several weights for one day the line takes the one said last and the others stay as marks beside it. A remembered weight is a hollow grey ring with a solid border (a qualified one a size smaller), and a stretch of the line with a remembered end is drawn quieter, grey and thinner; between two stated weights it keeps the accent (a qualified stated one is hollow). The axes FIT what has been said so far (trail-plan.mjs): each new weight outside them reflows the chart over 0.4 s -- the years, the bounds, every dot -- so the time axis advances with the story; a stretch with no statement longer than `gap` is a break in the time axis (a small `//` on the axis foot, each side with its own years; a year inside a stretch a short tick there) and the line across it dotted, so a decade of nothing does not take the width from the dense run after it. The width is shared half by days and half by the weights each stretch holds (each day a weight is said for owns an equal slot), so a run of weights a few days apart is spread out rather than piled into a few pixels, and an empty year still reads as longer than a week. A red ring on the latest said. The `mark` line (300) dashed across; with `count` and the mark at 300, `UNDER 300 · SAID n×` counts the measure's `totals.under300` rows as the cut reaches each. | Knob | Range · default | From a terminal | |---|---|---| diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -2387,6 +2387,10 @@ matches main's). ``` takes/<t>/out/<slug>.preview.mp4 the preview +takes/<t>/out/<slug>.preview.<S>-<end>.mp4 + a window's preview (--preview --at S --dur S): cut seconds of the take's + own cut, <end> as rendered (clipped at the cut's end), never written over + the full preview; its build and record in out/window/ (one at a time) takes/<t>/out/preview/ its build's own out/: sourced/schedule.json, segments, chunks …, render.json and render.log (its record; the take's render.json is the full render's) @@ -2397,6 +2401,19 @@ takes/<t>/changes.json the reel's pieces: id, kinds, label, `at`/`e out), `render` (what changed outside the timeline) ``` +**A window's preview** (`--preview --at S --dur S`) is cut seconds S..S+dur of the TAKE's own cut -- timed +by the take's last measured schedule (its preview's or its render's `schedule.json`) when it is newer than +the take's `take.json` (a take edited since may have grown), else by its entries' own lengths, said as +estimates; an S past the end -- measured or estimated, said which -- is refused before anything builds. Not the project draft's seconds: a +take whose patch carries its own timeline does not share the draft's (rev9-a9, 12 Nov: `--at 440 --dur 170` +timed over the draft rendered 92 s of the cut's early clips). The whole take goes to the build with the +window (build-video `--cut-window <at> <dur>`): every segment is built or reused by its key as a full +build's, the deck is rendered over the whole cut's schedule from S, and only the window is laid and +encoded -- so its timeline, counters and trail are at their state at S, not a cut that starts there. The +claim rail is not laid in a window (as `--chrome-preview`). The file is named by the window the build laid +(clipped at the cut's end); one window of a take renders at a time (the second is refused, naming the +first's pid and window), and `umtool take status` reports it as `window S-…` from `out/window/render.json`. + **What it shares, and what it never feeds.** A clip or post segment, a chrome frame and the cut's sound are the same bytes whichever tier they end up in, and are keyed by what makes them, so a preview links this take's own full render's, the `--from` take's full render's and its previews' (`takeFrom.mjs` diff --git a/umtool/lib/cli/groups.mjs b/umtool/lib/cli/groups.mjs @@ -41,11 +41,11 @@ export const GROUPS = [ { cmd: "check", usage: [ - " umtool check [<project>] [--json] exit 1 on anything blocking", + " umtool check [<project>] [--take T] [--json] exit 1 on anything blocking (--take: the take's quote rows)", ], docs: [ - ["`check [<project>] [--json]`", - "**exit 1 on anything blocking** — including an `out/`, `clips/` or `share-*/` link whose drive is not there (`storage-unreachable`)"], + ["`check [<project>] [--take T] [--json]`", + "**exit 1 on anything blocking** — including an `out/`, `clips/` or `share-*/` link whose drive is not there (`storage-unreachable`). `--take T`: the quote check's rows are the TAKE's — its clips, judged by `takes/T/quote-check.json` over the project's"], ], }, { @@ -102,14 +102,15 @@ export const GROUPS = [ { cmd: "quote-check", usage: [ - " umtool quote-check <project> [--clips a,b] [--pad S] [--json] | --status is each clip's quote in the seconds it plays?", + " umtool quote-check <project> [--take T] [--clips a,b] [--pad S] [--json] | --status is each clip's quote in the seconds it plays?", " the cut ±15 s of the source the render would use, transcribed by the editor (words on), the quote", " found in it and in the cues: ok | moved (heard N s away: window --align) | not-found -> quote-check.json;", - " check calls moved and not-found blocking, and a take refuses them unless the clip is --quote-ruled", + " check calls moved and not-found blocking, and a take refuses them unless the clip is --quote-ruled;", + " --take T judges the take's clips into takes/T/quote-check.json (check --take and the take read it)", ], docs: [ - ["`quote-check <project> [--clips a,b] [--pad S] [--json]` · `quote-check <project> --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 ([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))"], ], }, { @@ -569,7 +570,7 @@ export const GROUPS = [ ], docs: [ ["`lint <project> [--take <take>] [--variant sourced\\|full] [--final] [--json]`", - "**the manifest lint** (`report-to-video/lint.mjs`, what a build runs before it renders a frame) from umtool: the project's manifest, or with `--take` the take's (its patches applied, written beside the project's manifest for the lint as its render's is, then removed) -- plus the **files its post items name**: a picked read, an attachment or a context post's media not in the project is an ERROR, another kept take a warning. Run it after an import and before queueing the render. `--json`: `{ok, entries, errors, warnings}`. **Exit 0 no error · 1 an error · 2 usage**"], + "**the manifest lint** (`report-to-video/lint.mjs`, what a build runs before it renders a frame) from umtool: the project's manifest, or with `--take` the take's (its patches applied, written beside the project's manifest for the lint as its render's is, then removed) -- plus the **files its post items name**: a picked read, an attachment or a context post's media not in the project is an ERROR, another kept take a warning. A `ledger*.json` beside a manifest that carries its own `ledger` -- one that parses as rows with ids (never `ledgerSchema.json`) -- is a warning naming the live one (the manifest's, or with `--take` the take's: what the build and `umtool ledger` read) and the file as stale, or NEWER only when it holds row ids the live ledger lacks (named), with both counts and local dates; the file is never touched. Run it after an import and before queueing the render. `--json`: `{ok, entries, errors, warnings}`. **Exit 0 no error · 1 an error · 2 usage**"], ], }, { @@ -590,11 +591,11 @@ export const GROUPS = [ ["`take <project> --id <id> --draft --from <take> [--label L] [--patch F \\| --patch-json J \\| --set p=v …]`", "a **draft made from another take**: that take's style and patch (a `--patch` merged over it), its label \"<that label> (from <take>)\" unless `--label`, nothing rendered; its timeline is its own from then on, and its render's `--from` (segments reused) is a separate flag of the render ([take-scoped edits](#edit-a-take-not-the-project-items-from-other-projects-and-take-scoped-edits))"], ["`take <project> --id <id> --preview [--from <take>] [--at S --dur S \\| --full] [--priority] [--json]`", - "the take's **preview**: the take as stored (a draft too, from its walked patch) composed exactly as its render is -- the same 1920×1080 layout, segments, chrome frames and sound -- with only its final picture encoded smaller and faster (`render.preview`: 1280×720, x264 veryfast, crf 26) into `takes/<id>/out/<slug>.preview.mp4`; its build, schedule and record (`render.json`, `render.log`) in `takes/<id>/out/preview/`. The full render (`preview.mp4`, `out/<slug>.mp4`, `out/sourced/`, `take.json`, `render.json`) is never touched. Reuses this take's own full render, and `--from`'s full render and preview ([report-video.md](report-video.md#fast-feedback-preview-and-changes-renders), [knobs.md](knobs.md#fast-feedback-a-preview-and-a-reel-of-the-changes))"], + "the take's **preview**: the take as stored (a draft too, from its walked patch) composed exactly as its render is -- the same 1920×1080 layout, segments, chrome frames and sound -- with only its final picture encoded smaller and faster (`render.preview`: 1280×720, x264 veryfast, crf 26) into `takes/<id>/out/<slug>.preview.mp4`; its build, schedule and record (`render.json`, `render.log`) in `takes/<id>/out/preview/`. The full render (`preview.mp4`, `out/<slug>.mp4`, `out/sourced/`, `take.json`, `render.json`) is never touched. `--at S --dur S`: cut seconds of the take's own cut (its schedule when newer than its take.json, else its entries' lengths as estimates; an S past the end refused before anything builds), the chrome at its state then and no rail, into its own `takes/<id>/out/<slug>.preview.<S>-<end>.mp4` (`<end>` as rendered, clipped at the cut's end; build and record in `out/window/`, one window at a time; `take status` says `window S-…`), never over the full preview. Reuses this take's own full render, and `--from`'s full render and preview ([report-video.md](report-video.md#fast-feedback-preview-and-changes-renders), [knobs.md](knobs.md#fast-feedback-a-preview-and-a-reel-of-the-changes))"], ["`take <project> --id <id> --changes [--from <take>] [--pad 3] [--no-preview] [--priority] [--json]`", "the take's **changes reel**: only what changed against `--from` (default: the take's own `from`, or the take a draft was made from) -- each added, re-read, re-picked, re-voiced, trimmed, held, fx'd, … item with a neighbour either side, rendered in one build (`takes/<id>/out/changes/`), cut to the item ± `--pad` s, a label burned in (`21:19 · p-2116831815466193102 · re-voiced`: its time in the FULL cut), joined into `takes/<id>/out/<slug>.changes.mp4`; a removed item shows as the join it leaves. `takes/<id>/changes.json` lists the pieces with their full-cut times and how exact they are (`times.basis`: `measured` -- the base's measured schedule plus the changed items' measured lengths -- or `estimate`). Preview quality unless `--no-preview`. Nothing changed: no reel, and the list says so"], ["`take <project> --id <id> --import-item <project>:<item>[,<item>…] [--import-item …] [--after <entry> \\| --before <entry>] [--as <id>] [--dry-run] [--json]`", - "**items of another project into a take** -- deprecated, saying so in one line on stderr: edits land in the draft, so open the take there and use `timeline <p> import-item` (`takeImport.mjs`): each entry CLONED from the source's manifest as it is now (its card, context, knobs, narration with its takes and its pick) into the take's timeline -- one write, an undo point of the take's (`timeline <p> --take <id> undo`); the files it names (narration takes and their `take-<n>.*` sidecars, the parts' cache files, attachments, a context post's media, the picture of each author it draws that the take lacks, added to the take's `postAvatars`) **hard-linked** into this project's dir at the same path, so the render and the lint find them (copied across filesystems; the same file already there is left; ANOTHER file at the path: linked under `imports/<source>/<path>` and the clone names that). The source project and this project's manifest are only read. **Placed** `--after`/`--before` an entry of the take (several items in the order named, one after another), else by the post's date when the take's posts are in date order, else at the end. **Again**: updated in place from the source (moved only with `--after`/`--before`), `unchanged` with no write when nothing differs. `--as`: one item under another id (a second copy). `--dry-run`: the plan and the placement, nothing linked or written. `--json`: `items[] {id, action added\\|updated\\|unchanged\\|moved, at {index, after, before}, narration {takes, pick, file}, files[], avatars[]}`, `revision`. Refused while the take renders. **Exit 0 · 1 refused (no such item, take or entry; a link out of the project) · 2 usage**"], + "**items of another project into a take** -- into the take's patch, the draft untouched (`timeline <p> import-item` is the draft's twin; `takeImport.mjs`): each entry CLONED from the source's manifest as it is now (its card, context, knobs, narration with its takes and its pick) into the take's timeline -- one write, an undo point of the take's (`timeline <p> --take <id> undo`); the files it names (narration takes and their `take-<n>.*` sidecars, the parts' cache files, attachments, a context post's media, the picture of each author it draws that the take lacks, added to the take's `postAvatars`) **hard-linked** into this project's dir at the same path, so the render and the lint find them (copied across filesystems; the same file already there is left; ANOTHER file at the path: linked under `imports/<source>/<path>` and the clone names that). The source project and this project's manifest are only read. **Placed** `--after`/`--before` an entry of the take (several items in the order named, one after another), else by the post's date when the take's posts are in date order, else at the end. **Again**: updated in place from the source (moved only with `--after`/`--before`), `unchanged` with no write when nothing differs. `--as`: one item under another id (a second copy). `--dry-run`: the plan and the placement, nothing linked or written. `--json`: `items[] {id, action added\\|updated\\|unchanged\\|moved, at {index, after, before}, narration {takes, pick, file}, files[], avatars[]}`, `revision`. Refused while the take renders. **Exit 0 · 1 refused (no such item, take or entry; a link out of the project) · 2 usage**"], ["`take … --priority` · `takes make … --priority` · `render-mode on [--for 90m] [--note T] [--json \\| --print-token]` · `render-mode on [--for 90m] [--note T] [--print-token] -- <cmd …>` · `render-mode off [--force] [--json]` · `render-mode status [--json]`", "**render mode**: a render the operator waits for gets the machine. `--priority` turns it on for the take's (or the batch's) lifetime — on at the start, off at the end, on a failure and on a signal; the Takes page's **Give renders the machine** is the same flag. While it is on, every other heavy job (e2e suites, `next build`s, the publish stages, other renders) waits at the heavy slot's door (`queue-lock: held for a render (…) — waiting`), the render runs on the floor 4000 MB and the cap 10240 MB, and the editor's transcription, download and Speakers lanes are held through its ops (`lane`; only the ones not already held, and only those are released at off). `render-mode on` is a window (default 2h) for a chain of renders: every `umtool take` started in it renders in it, another command joins with the `RENDER_PRIORITY_TOKEN` it prints (`--print-token`: the token alone on stdout, the rest on stderr). **`on … -- <cmd …>` is the form for a script**: the command is spawned with the token in its environment, the hold is the command's pid, and it is released when the command exits — done, failed, or umtool signalled (the signal is passed on); umtool exits with the command's code, and inside a manual window the command joins it. A bare `on` in a script leaves the window behind (the chain trap). `off` ends it (a running take's hold only with `--force`, else it ends with the take); `status` says what holds it and releases a stale hold's lanes. A hold whose process is gone or whose window is over is no hold. Needs WORKER_TOKEN and the editor at ARCHILYZER_EDITOR_URL for the lanes; without them it still holds the door. **Exit 1** when it is already on, or a lane could not be released ([report-video.md](report-video.md#render-mode-giving-a-render-the-machine); WORKTREES.md, \"Render mode\")"], ["`take status <project> [--id <take>] [--json] [--log] [--tail N]`", diff --git a/umtool/lib/cli/verbs.mjs b/umtool/lib/cli/verbs.mjs @@ -115,7 +115,7 @@ export const VERBS = Object.freeze([ opt("--q", { help: "words the project's text holds" }), pick("--sort", ["recent", "name"]), ]), form("show", "project", "one project: summary, the cut, per-clip status, decisions", [project()]), - form("check", "project", "what blocks a build (exit 1 on anything blocking)", [project({ required: false, help: "one project; none: every project" }), bool("--all-severities", "the info rows too")]), + form("check", "project", "what blocks a build (exit 1 on anything blocking)", [project({ required: false, help: "one project; none: every project" }), takeOpt({ help: "a take of the project: its clips' quote rows, by its own verdicts" }), bool("--all-severities", "the info rows too")]), form("links", "project", "do the clip QRs open on their sites (out/links.json)", [ project(), bool("--fix", "rewrite the dead links it knows the fix for"), bool("--embed-ids", "no check: every clip citing a Rumble URL-slug folder gets the embed id the archive serves (siteVideo), one write to the draft"), @@ -182,7 +182,7 @@ export const VERBS = Object.freeze([ project(), many("--clip", { repeat: true, help: "clip ids, one per line (none: every clip)" }), bool("--list", "list the named voices"), opt("--set", { help: "Name=<clip>,<channel>/<id>,channel:<slug>" }), opt("--remove", { help: "a voice's name" }), ], { ...Q, confirm: { what: "remove that named voice from speakers.json", when: ["--remove"] }, ...B(["clip"], { "--clip": "{id}" }) }), - form("quote-check", "project", "is each clip's quote in the seconds it plays", [project(), opt("--clips", { help: "a,b (none: every clip)" }), num("--pad"), bool("--status", "the rows as they stand")], { ...Q, ...B(["clip"], { "--clips": "{id}" }) }), + form("quote-check", "project", "is each clip's quote in the seconds it plays", [project(), takeOpt({ help: "a take's clips: its rows in takes/<t>/quote-check.json" }), opt("--clips", { help: "a,b (none: every clip)" }), num("--pad"), bool("--status", "the rows as they stand")], { ...Q, ...B(["clip"], { "--clips": "{id}" }) }), form("check-joins", "project", "do a rendered take's post joins carry on", [project(), takeOpt({ required: true, help: "the rendered take" }), bool("--all", "every post-to-post boundary"), num("--limit")], Q), form("link-policy", "draft", "cite via site X, these channels direct", [ project(), opt("--via", { help: "a site id or its https address" }), opt("--direct", { help: "channel slugs, a,b" }), bool("--clear"), bool("--fix", "rewrite the clips that break it"), diff --git a/umtool/lib/queue/cli.mjs b/umtool/lib/queue/cli.mjs @@ -350,9 +350,9 @@ async function fastStatus(project, id, steps) { const got = await fastRenders(path.join(project.dir, "takes", id), slug); /** @type {Record<string, any>} */ const out = {}; - for (const kind of ["preview", "changes"]) { + for (const kind of ["preview", "window", "changes"]) { const step = steps.filter((s) => s.target.take === id && fastKindOf(s.argv) === kind).at(-1) ?? null; - const rec = got[/** @type {"preview" | "changes"} */ (kind)]; + const rec = got[/** @type {"preview" | "window" | "changes"} */ (kind)]; const live = rec && (rec.state === "running" || rec.state === "waiting"); if (step && !live && (step.state === "queued" || step.state === "blocked" || (step.state === "running" && !(rec?.endedAt === null)))) { out[kind] = { ...(rec ?? {}), state: step.state === "running" ? "running" : step.state, queue: { qid: step.qid, state: step.state, after: step.after, error: step.error } }; @@ -419,11 +419,12 @@ export async function takeStatus(project, { take, json, showLog, tail, reportsRo return code; } const fastLines = (r) => { - for (const kind of ["preview", "changes"]) { + for (const kind of ["preview", "window", "changes"]) { const f = r[kind]; if (!f) continue; const what = f.queue ? `${String(f.state).toUpperCase()} in the queue as ${f.queue.qid}` : String(f.state ?? "?").toUpperCase(); - log(` ${kind}: ${what}${f.mp4 ? ` — ${f.mp4}${f.seconds != null ? ` (${f.seconds} s)` : ""}` : ""}${f.items != null ? `, ${f.items} piece(s) against ${f.from}, list ${f.list}` : ""}${f.error ? ` — ${f.error}` : ""}`); + // A window preview's own record (out/window/), named by the window it was asked for. + log(` ${kind === "window" && f.span ? `window ${f.span}` : kind}: ${what}${f.mp4 ? ` — ${f.mp4}${f.seconds != null ? ` (${f.seconds} s)` : ""}` : ""}${f.items != null ? `, ${f.items} piece(s) against ${f.from}, list ${f.list}` : ""}${f.error ? ` — ${f.error}` : ""}`); } }; for (const r of rows) { diff --git a/umtool/lib/report/ledgerFiles.test.mjs b/umtool/lib/report/ledgerFiles.test.mjs @@ -0,0 +1,69 @@ +// A ledger file beside the manifest (quartering-diet's ledger.draft.json, 30 Aug: 186 rows) is not the ledger the +// build reads -- that is video.manifest.json's `ledger` (564 rows, 12 Nov) -- and nothing said so. `umtool lint` now +// says which is live and that the other is stale, naming the file and the newer date. The file is never touched. +import assert from "node:assert/strict"; +import { mkdir, mkdtemp, readFile, rm, utimes, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import test from "node:test"; +import { ledgerFileWarnings, lintCommand } from "./lintCli.mjs"; + +const row = (id) => ({ id, date: "2026-01-01", scope: "weight", population: "self", value: 300 }); + +async function project() { + const root = await mkdtemp(path.join(tmpdir(), "umtool-ledger-files-")); + const dir = path.join(root, "diet"); + await mkdir(dir, { recursive: true }); + const manifest = { schemaVersion: 1, slug: "diet", title: "T", render: { width: 640, height: 360, fps: 15 }, ledger: [row("d1"), row("d2"), row("d3")], timeline: [{ type: "clip", id: "c1", channel: "ch", video: "v", start: 0, end: 5 }] }; + await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify(manifest)); + await writeFile(path.join(dir, "ledger.draft.json"), JSON.stringify([row("d1")])); + // The draft from 30 Aug, the manifest from 12 Nov. + await utimes(path.join(dir, "ledger.draft.json"), new Date("2026-08-30T13:18:00Z"), new Date("2026-08-30T13:18:00Z")); + await utimes(path.join(dir, "video.manifest.json"), new Date("2026-11-12T16:51:00Z"), new Date("2026-11-12T16:51:00Z")); + return { root, dir, manifest }; +} + +test("a ledger file beside the manifest: lint says the manifest's ledger is live and the file stale, with both dates", async () => { + const p = await project(); + try { + const before = await readFile(path.join(p.dir, "ledger.draft.json"), "utf8"); + const w = await ledgerFileWarnings(p.dir, p.manifest); + assert.equal(w.length, 1); + assert.match(w[0], /ledger\.draft\.json/); + assert.match(w[0], /live ledger is video\.manifest\.json's `ledger` \(3 rows, 2026-11-12\)/); + assert.match(w[0], /ledger\.draft\.json \(1 row, 2026-08-30\) is stale/); + // Through `umtool lint`: a warning, not an error -- the exit is the lint's own. + const out = []; + const code = await lintCommand(["diet"], { reportsRoot: p.root, log: (l) => out.push(l), err: (l) => out.push(l) }); + assert.match(out.join("\n"), /ledger\.draft\.json \(1 row, 2026-08-30\) is stale/); + assert.notEqual(code, 2); + assert.equal(await readFile(path.join(p.dir, "ledger.draft.json"), "utf8"), before, "the operator's file is never touched"); + // Written after the manifest but holding nothing the live ledger lacks: not "NEWER" (review 1, S8). + await utimes(path.join(p.dir, "ledger.draft.json"), new Date("2026-11-13T15:00:00Z"), new Date("2026-11-13T15:00:00Z")); + const later = await ledgerFileWarnings(p.dir, p.manifest); + assert.doesNotMatch(later[0], /NEWER/); + assert.match(later[0], /ledger\.draft\.json \(1 row, 2026-11-13\) is stale/); + // Newer AND rows the manifest lacks: said so, naming them. + await writeFile(path.join(p.dir, "ledger.draft.json"), JSON.stringify([row("d1"), row("d9")])); + const newer = await ledgerFileWarnings(p.dir, p.manifest); + assert.match(newer[0], /ledger\.draft\.json \(2 rows, \d{4}-\d\d-\d\d\) is NEWER than the manifest and holds 1 row the live ledger lacks \(d9\)/); + // Not a ledger: a schema, an empty list, rows without ids, not JSON -- nothing said. + await writeFile(path.join(p.dir, "ledgerSchema.json"), JSON.stringify({ kind: "measure", fields: [] })); + await writeFile(path.join(p.dir, "ledger.empty.json"), "[]"); + await writeFile(path.join(p.dir, "ledger.noids.json"), JSON.stringify([{ date: "2026-01-01" }])); + await writeFile(path.join(p.dir, "ledger.bad.json"), "{not json"); + await writeFile(path.join(p.dir, "ledger.rows.json"), JSON.stringify({ rows: [row("d1")] })); + const names = (await ledgerFileWarnings(p.dir, p.manifest)).map((w) => w.split(" ")[0]); + assert.deepEqual(names, ["ledger.draft.json", "ledger.rows.json"]); + // Under --take the live count is the take's. + const takeW = await ledgerFileWarnings(p.dir, { ...p.manifest, ledger: [row("d1"), row("d2")] }, { take: "t1" }); + assert.match(takeW[0], /the live ledger is take t1's \(video\.manifest\.json's with its patch; 2 rows/); + for (const f of ["ledgerSchema.json", "ledger.empty.json", "ledger.noids.json", "ledger.bad.json", "ledger.rows.json"]) await rm(path.join(p.dir, f)); + // No ledger in the manifest, or no such file: nothing said. + assert.deepEqual(await ledgerFileWarnings(p.dir, { ...p.manifest, ledger: undefined }), []); + await rm(path.join(p.dir, "ledger.draft.json")); + assert.deepEqual(await ledgerFileWarnings(p.dir, p.manifest), []); + } finally { + await rm(p.root, { recursive: true, force: true }); + } +}); diff --git a/umtool/lib/report/lintCli.mjs b/umtool/lib/report/lintCli.mjs @@ -6,7 +6,7 @@ // item (a take's imported items are hard-linked in by `umtool take --import-item`; this says when one is not). // // exit 0 no error (warnings said) · 1 an error · 2 usage -import { rm, stat, writeFile } from "node:fs/promises"; +import { readdir, readFile, rm, stat, writeFile } from "node:fs/promises"; import path from "node:path"; import { REPORTS_ROOT, resolveProject } from "../projects/core.mjs"; @@ -17,6 +17,9 @@ export const LINT_USAGE = [ " picked read, an attachment, a context post's media not in the project is an ERROR; another named file a warning.", " And the cast's guard (umtool cast): a picked read that says a cast character in another voice than now is a", " warning (umtool cast reread); a cast voice the project's voice map overrides on purpose is a note.", + " A ledger*.json beside a manifest that carries its own `ledger` -- one that parses as rows with ids -- is a warning:", + " the manifest's (with --take, the take's) is the live one, what the build and umtool ledger read; the file stale, or", + " NEWER when it holds row ids the live ledger lacks (named); local dates; the file is never touched.", " Exit 0 no error · 1 an error · 2 usage.", ].join("\n"); @@ -24,6 +27,63 @@ const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v); const exists = async (f) => !!(await stat(f).catch(() => null)); /** + * THE LEDGER'S ONE SOURCE OF TRUTH (12 Nov): the build, the instruments and `umtool ledger` read the manifest's + * `ledger`; a ledger file beside it (quartering-diet's ledger.draft.json, 30 Aug, 186 rows against the manifest's + * 564) is read by none of them. One warning per such file, naming which is live, each one's rows and (local) date. + * A file counts only when it parses as a ledger: `ledger*.json`, a list of rows each with an id, or `{rows|ledger: + * [...]}` -- never ledgerSchema.json, an empty list, rows without ids, or what does not parse. "NEWER" only when + * the file is newer AND holds row ids the live ledger lacks (review 1, S8). Only said when the manifest carries a + * ledger. The file is never touched (a project's own script may read it). Under --take, the live count is the take's. + * @param {string} dir the project's dir + * @param {Record<string, any>} manifest the project's, or the take's resolved one (`take`) + * @param {{ take?: string | null }} [o] + * @returns {Promise<string[]>} + */ +export async function ledgerFileWarnings(dir, manifest, { take = null } = {}) { + if (!Array.isArray(manifest?.ledger)) return []; + const names = (await readdir(dir).catch(() => [])).filter((n) => /^ledger.*\.json$/i.test(n) && !/^ledger-?schema\b/i.test(n)).sort(); + if (!names.length) return []; + const pad = (n) => String(n).padStart(2, "0"); + const day = (ms) => { + const d = new Date(ms); + return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`; + }; + const rows = (n) => `${n} row${n === 1 ? "" : "s"}`; + const man = await stat(path.join(dir, "video.manifest.json")).catch(() => null); + const liveIds = new Set(manifest.ledger.map((r) => (isObj(r) ? String(r.id ?? "") : "")).filter(Boolean)); + const when = man ? `, ${day(man.mtimeMs)}` : ""; + const live = take + ? `take ${take}'s (video.manifest.json's with its patch; ${rows(manifest.ledger.length)}${when})` + : `video.manifest.json's \`ledger\` (${rows(manifest.ledger.length)}${when})`; + const out = []; + for (const name of names) { + const st = await stat(path.join(dir, name)).catch(() => null); + // A ledger file, not a dump: past 64 MB it is not read. + if (!st?.isFile() || st.size > 64 * 1024 * 1024) continue; + let doc; + try { + doc = JSON.parse(await readFile(path.join(dir, name), "utf8")); + } catch { + continue; + } + const list = Array.isArray(doc) ? doc : Array.isArray(doc?.ledger) ? doc.ledger : Array.isArray(doc?.rows) ? doc.rows : null; + if (!list?.length || !list.every((r) => isObj(r) && (typeof r.id === "string" || typeof r.id === "number") && String(r.id) !== "")) continue; + const extra = [...new Set(list.map((r) => String(r.id)))].filter((id) => !liveIds.has(id)); + const it = `${name} (${rows(list.length)}, ${day(st.mtimeMs)})`; + const newer = !!man && st.mtimeMs > man.mtimeMs; + const few = extra.slice(0, 5).join(", ") + (extra.length > 5 ? `, +${extra.length - 5} more` : ""); + out.push( + `${name} is not the ledger the build reads: the live ledger is ${live}; ` + + (newer && extra.length + ? `${it} is NEWER than the manifest and holds ${rows(extra.length)} the live ledger lacks (${few}) -- not in the cut (umtool ledger <p> add …)` + : `${it} is stale${extra.length ? ` -- ${rows(extra.length)} of it not in the live ledger (${few})` : ""}${newer ? " (written after the manifest, nothing in it the live ledger lacks)" : " -- the manifest is newer"}`) + + "; the file is left as it is", + ); + } + return out; +} + +/** * The files the post items of `manifest` name that are not in `dir`: `{ errors, warnings }`. * An error: the picked narration take, an attachment (`media[].src`), a context post's or a link's media. * A warning: any other narration take the item keeps. @@ -146,8 +206,9 @@ export async function lintCommand(args, { reportsRoot = REPORTS_ROOT, log = cons const lint = await lintManifestFile(file, { variant, final: flags.has("--final") }); const files = await namedFileProblems(selectVariant(manifest, variant), project.dir); const voices = await castProblems(selectVariant(manifest, variant), project, reportsRoot); + const ledgers = await ledgerFileWarnings(project.dir, manifest, { take }); const errors = [...lint.errors, ...files.errors]; - const warnings = [...lint.warnings, ...files.warnings, ...voices.warnings]; + const warnings = [...lint.warnings, ...files.warnings, ...voices.warnings, ...ledgers]; if (flags.has("--json")) log(JSON.stringify({ ok: errors.length === 0, project: project.id, take, variant, entries: manifest.timeline?.length ?? 0, errors, warnings, notes: voices.notes }, null, 2)); else { for (const line of lintReport({ errors, warnings })) log(line); diff --git a/umtool/lib/report/postsCli.mjs b/umtool/lib/report/postsCli.mjs @@ -793,8 +793,7 @@ async function inTakeCommand({ verb, take, rest }, { root, out, err }) { } if (!words[1]) throw new CliError(`which project? umtool posts ${verb} <project> … --in-take ${take}`); const project = await projectOf(words[1], root); - // Deprecated (L3 S6): it still lands, and says so in one line naming the project as parsed. - err((await import("./takeDeprecation.mjs")).takeEditDeprecation(`posts ${verb} --in-take`, { project: project.id, take })); + // A supported path (12 Nov; takeDeprecation.mjs): the take's patch, never the draft. const { isTakeId, takesDirOf, TAKE_FILE } = await import("./takes.mjs"); if (!isTakeId(take)) throw new CliError(`"${take}" is not a take id (lower-case letters, digits, dashes)`); if (!(await stat(path.join(takesDirOf(project.dir), take, TAKE_FILE)).catch(() => null))) { diff --git a/umtool/lib/report/quoteCheck.mjs b/umtool/lib/report/quoteCheck.mjs @@ -22,6 +22,16 @@ // found or moved unless the clip says `quoteRuled` (`umtool window <p> <clip> // --quote-ruled`: heard and ruled by a person). // +// 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 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"; import os from "node:os"; @@ -31,10 +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) => { + 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. */ @@ -78,6 +94,69 @@ export async function readQuoteCheck(dir) { } } +/** + * 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 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) { const file = path.join(dir, QUOTE_CHECK_FILE); const tmp = tmpPathFor(file); @@ -181,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; @@ -218,6 +299,35 @@ export function alignPatch(entry, row) { return patch; } +/** + * `umtool check <p> --take <t>`'s quote rows: the take's clips (as it renders: its rulings applied) gated by the + * take's verdicts over the project's. The rows `umtool check` makes of the project's quote check, for the take. + * @param {{ id: string, dir: string }} p + * @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 ?? []; + 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}`)}${g.from === "take" ? "" : " (the project's row)"}`, + severity: "blocking", + href: `/projects/${p.id}/takes/${take}`, + fix: + g.status === "moved" + ? `umtool window ${p.id} ${g.id} --take ${take} --align # or --quote-ruled, having heard it` + : `umtool fetch ${p.id} --refetch ${g.id} && umtool quote-check ${p.id} --take ${take} --clips ${g.id} # or --quote-ruled, having heard it`, + })); +} + // --------------------------------------------------------------------------- // The run. // --------------------------------------------------------------------------- @@ -314,8 +424,9 @@ async function unmake(dir, first) { * @param {Awaited<ReturnType<typeof planQuoteCheck>>} plan * @param {{ transcribe?: typeof editorWords, cuesOf?: (slug: string, video: string) => Promise<any[] | null>, log?: (l: string) => void, now?: () => Date }} [opts] */ -export async function runQuoteCheck(dir, manifest, plan, { transcribe = editorWords, cuesOf = null, log = () => {}, now = () => new Date(), workDirs = null, reportsRoot = null } = {}) { - const doc = await readQuoteCheck(dir); +export async function runQuoteCheck(dir, manifest, plan, { transcribe = editorWords, cuesOf = null, log = () => {}, now = () => new Date(), workDirs = null, reportsRoot = null, store = dir } = {}) { + // `store`: where the rows go -- the project's dir, or a take's (takeQuoteCheckDir). + const doc = await readQuoteCheck(store); // Never under out/ (quoteCheckWorkDirs): the first the editor does not refuse as inside the corpus. const works = workDirs ?? (await quoteCheckWorkDirs(dir, { reportsRoot })); let wi = 0; @@ -375,7 +486,7 @@ export async function runQuoteCheck(dir, manifest, plan, { transcribe = editorWo log(rowLine(p.id, results[p.id])); } const merged = { version: 1, checkedAt: now().toISOString(), clips: { ...doc.clips, ...results } }; - const file = await writeQuoteCheck(dir, merged); + const file = await writeQuoteCheck(store, merged); return { file, doc: merged, results, work: works[wi] }; } @@ -384,8 +495,8 @@ export async function runQuoteCheck(dir, manifest, plan, { transcribe = editorWo // --------------------------------------------------------------------------- export const QUOTE_CHECK_USAGE = [ - "usage: umtool quote-check <project> [--clips a,b] [--pad S] [--json] transcribe what each clip plays; find its quote", - " umtool quote-check <project> --status [--json] the rows as they stand (stale ones said)", + "usage: umtool quote-check <project> [--take T] [--clips a,b] [--pad S] [--json] transcribe what each clip plays; find its quote", + " umtool quote-check <project> [--take T] --status [--json] the rows as they stand (stale ones said)", "", `Each clip's cut ±${SEARCH_PAD_S} s (--pad) of the source the render would cut it from is transcribed by the`, "editor (its transcription lane, words on), and the quote is found in those words and in the recording's", @@ -395,6 +506,10 @@ export const QUOTE_CHECK_USAGE = [ "<reports>/.umtool/quote-check/<project>/, then ~/.cache/umtool/quote-check/<project>/.", `Rows go to <project>/${QUOTE_CHECK_FILE}; umtool check reads them, and a take refuses a moved or`, "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", + "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 {} @@ -419,20 +534,38 @@ export async function quoteCheckCommand(args, { reportsRoot = REPORTS_ROOT, log if (!r.project) throw new CliError(`no project matches "${words[0]}"`); const project = r.project; if (!kindMakesTakes(project.kind)) throw new CliError(`${project.id} is a ${project.kind}, not a report video`); - const manifest = await readManifest(project.dir); + const take = flags["--take"]?.at(-1) ?? null; + if (take !== null && !take) throw new CliError("--take names a take of the project"); + let manifest = await readManifest(project.dir); if (!manifest) throw new CliError(`${project.id} has no manifest`); + if (take) { + // The take as it renders: its patch over the draft (resolveTakeManifest), its clip rulings applied. + const [{ resolveTakeManifest }, { applyMontageRulings, readMontageRulings }] = await Promise.all([ + import("./takeManifest.mjs"), + import("umtool-report-to-video/montage-rulings"), + ]); + const r = await resolveTakeManifest(project.dir, take).catch((e) => { + throw new CliError(`--take ${take}: ${e instanceof Error ? e.message : String(e)}`); + }); + manifest = applyMontageRulings(r.manifest, await readMontageRulings(project.dir)).manifest; + } const json = !!flags["--json"]; if (flags["--status"]) { - const doc = 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) }); + 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, 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)"}`); + 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)" : ""}`); return 0; } @@ -442,14 +575,15 @@ export async function quoteCheckCommand(args, { reportsRoot = REPORTS_ROOT, log const channelsDirs = channelsLayersFor(project.dir, manifest, { shadowExists: await hasShadowChannels(project.dir) }); if (!channelsDirs.length) throw new CliError("no channels directory (CHANNELS_DIR) to read the windows from"); const plan = await planQuoteCheck(project.dir, manifest, { channelsDirs, clipIds, pad }); - if (clipIds.length && !plan.length) throw new CliError(`none of ${clipIds.join(", ")} is a clip of ${project.id}`); + if (clipIds.length && !plan.length) throw new CliError(`none of ${clipIds.join(", ")} is a clip of ${take ? `take ${take}` : project.id}`); const { file, results, work } = await runQuoteCheck(project.dir, manifest, plan, { ...(transcribe ? { transcribe } : {}), ...(cuesOf ? { cuesOf } : {}), reportsRoot, log: json ? () => {} : log, + ...(take ? { store: takeQuoteCheckDir(project.dir, take) } : {}), }); - if (json) log(JSON.stringify({ project: project.id, file, work, clips: results }, null, 1)); + if (json) log(JSON.stringify({ project: project.id, ...(take ? { take } : {}), file, work, clips: results }, null, 1)); else { const count = (s) => Object.values(results).filter((x) => x.status === s).length; log(`→ ${file}: ${count("ok")} ok, ${count("moved")} moved, ${count("not-found")} not found, ${count("no-window")} with no window`); diff --git a/umtool/lib/report/quoteCheckTake.test.mjs b/umtool/lib/report/quoteCheckTake.test.mjs @@ -0,0 +1,175 @@ +// `umtool quote-check <p> --take <t>` (12 Nov 2026: the check judged the draft -- 25 blocking there -- and left the +// take unjudged). With --take the take's own clips are judged (its timeline: its patch over the draft), the rows +// go to takes/<t>/quote-check.json, and a take's refusal and `umtool check --take` read the take's rows first. +// The words and cues are the 6 Nov c43 window's (report-to-video/fixtures/rev9-a3-rumble-words.json). +// +// Run with: pnpm test:scripts +import assert from "node:assert/strict"; +import test from "node:test"; +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, quoteGate, readQuoteCheck, readTakeQuoteCheck, takeQuoteCheckDir, takeQuoteDecisions, takeQuoteRefusals } from "./quoteCheck.mjs"; +import { makeTake } from "./takeMaker.mjs"; + +const HERE = path.dirname(fileURLToPath(import.meta.url)); +const FIX = JSON.parse(await readFile(path.join(HERE, "..", "..", "report-to-video", "fixtures", "rev9-a3-rumble-words.json"), "utf8")); +const C43 = FIX.clips.find((c) => c.id === "c43"); + +/** c43 in the draft: re-cut to seconds no window holds (no-window); in the take, where the 6 Nov fetch had it (moved). */ +const DRAFT = { start: 3000, end: 3010 }; +const EARLY = { start: 2119.34, end: 2127.44 }; + +async function project() { + const root = await mkdtemp(path.join(os.tmpdir(), "quote-check-take-")); + const dir = path.join(root, "diet"); + const raw = path.join(dir, "out", "clips-raw"); + await mkdir(raw, { recursive: true }); + const channels = path.join(root, "channels"); + await mkdir(channels, { recursive: true }); + await writeFile(path.join(raw, `${C43.video}_${C43.window[0].toFixed(2)}-${C43.window[1].toFixed(2)}.mp4`), "mp4"); + const c43 = { type: "clip", id: "c43", channel: C43.channel, video: C43.video, quote: C43.quote }; + const manifest = { + slug: "diet", + render: { width: 640, height: 360, fps: 15, transition: 0 }, + provenance: { channelSlug: "the-quartering-rumble", channelsDir: channels, channelsFallback: false }, + timeline: [{ ...c43, ...DRAFT }], + }; + await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify(manifest)); + const takeDir = path.join(dir, "takes", "t1"); + await mkdir(takeDir, { recursive: true }); + await writeFile(path.join(takeDir, "take.json"), JSON.stringify({ id: "t1", group: "takes", order: 0, label: "T1", kind: "different", preview: "preview.mp4", draft: true, window: "full", patch: { timeline: [{ ...c43, ...EARLY }] } })); + return { root, dir, takeDir }; +} + +const fakeTranscribe = async (req) => C43.words.filter((w) => w.start >= req.start - 0.01 && w.end <= req.end + 0.01); +const fakeCues = async () => C43.cues; +const run = async (p, args) => { + const out = []; + const code = await quoteCheckCommand(args, { reportsRoot: p.root, log: (l) => out.push(l), err: (l) => out.push(`ERR ${l}`), transcribe: fakeTranscribe, cuesOf: fakeCues }); + return { code, text: out.join("\n") }; +}; +const exists = (f) => stat(f).then(() => true, () => false); + +test("quote-check --take judges the take's clips into takes/<t>/quote-check.json; the draft's rows are its own", async () => { + const p = await project(); + try { + // The draft: its c43 has no window to judge. + let r = await run(p, ["diet"]); + assert.equal(r.code, 0, r.text); + assert.match(r.text, /0 ok, 0 moved, 0 not found, 1 with no window/); + // The take: its c43 13 s early -- judged on ITS cut, into its own file. + r = await run(p, ["diet", "--take", "t1"]); + assert.equal(r.code, 0, r.text); + assert.match(r.text, /0 ok, 1 moved/); + assert.match(r.text, /takes\/t1\/quote-check\.json/); + const own = JSON.parse(await readFile(path.join(p.takeDir, "quote-check.json"), "utf8")); + assert.equal(own.clips.c43.status, "moved"); + assert.equal(own.clips.c43.cut.from, EARLY.start); + // The draft's file is untouched by the take's run. + const draft = JSON.parse(await readFile(path.join(p.dir, "quote-check.json"), "utf8")); + assert.equal(draft.clips.c43.status, "no-window"); + // --status --take: the take's rows, against the take's clips. + r = await run(p, ["diet", "--take", "t1", "--status"]); + assert.equal(r.code, 0, r.text); + assert.match(r.text, /c43 +moved/); + // A take that is not there is refused. + r = await run(p, ["diet", "--take", "nope"]); + assert.equal(r.code, 2); + assert.match(r.text, /nope/); + } finally { + await rm(p.root, { recursive: true, force: true }); + } +}); + +test("a take's refusal and `check --take` read the take's verdicts, the project's under them", async () => { + const p = await project(); + try { + 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.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"]]); + assert.match(ds[0].fix, /--take t1/); + // The take's render refuses its moved c43 (before: only the draft's rows were read, and they say no-window). + let rendered = false; + const render = async () => { + rendered = true; + throw new Error("no render in this test"); + }; + await assert.rejects(makeTake(p.dir, { id: "t1", label: "T1", window: "full", patch: { timeline: JSON.parse(await readFile(path.join(p.takeDir, "take.json"), "utf8")).patch.timeline } }, { render, force: true }), /c43: its quote is heard/); + 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")).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/renderRecord.mjs b/umtool/lib/report/renderRecord.mjs @@ -258,6 +258,8 @@ export async function openRenderRecord(takeDir, o) { project, take: o.take, label: o.label ?? null, + // A take's window preview (takePreview.mjs): the cut seconds it was asked for. + ...(o.window ? { window: { at: o.window.at, dur: o.window.dur } } : {}), state: "running", pid, pidStart: procStartTime(pid), diff --git a/umtool/lib/report/takeCli.mjs b/umtool/lib/report/takeCli.mjs @@ -48,7 +48,13 @@ export const TAKE_USAGE = [ " umtool take <project> --id <id> --preview [--from TAKE] [--at S --dur S | --full] [--priority] [--json]", " the take as stored (a draft too) at the PREVIEW tier (render.preview: 1280x720, veryfast,", " crf 26; the same layout, segments, chrome and sound): takes/<id>/out/<slug>.preview.mp4,", - " its build and record in out/preview/; the take's full render untouched", + " its build and record in out/preview/; the take's full render untouched. --at S --dur S: CUT", + " SECONDS of the take's own cut (its last preview's or render's schedule when newer than take.json;", + " else its entries' own lengths, said as estimates; an S past the end refused before anything", + " builds): the whole take built (segments reused by key), only S..S+dur laid and encoded, its chrome", + " (timeline, counters) at its state then, no rail, into its OWN file", + " takes/<id>/out/<slug>.preview.<S>-<end>.mp4 (<end> as rendered: clipped at the cut's end; build and", + " record in out/window/, one window at a time; take status says \"window S-…\"); the full preview never touched", " umtool take <project> --id <id> --changes [--from TAKE] [--pad 3] [--no-preview] [--priority] [--json]", " a reel of only what changed against TAKE (default: the take's own from): each changed item", " ± pad s, labelled with its time in the full cut: takes/<id>/out/<slug>.changes.mp4 and", @@ -287,9 +293,8 @@ export async function takeCommand(args, { reportsRoot = REPORTS_ROOT, log = cons if (!id) throw new CliError("--id <id>: the take's directory name (lower-case letters, digits, dashes)"); if (p.has("--promote")) return await promote(project, id, p, log, err); if (p.has("--import-item")) { - // A write into the take's patch (takeDeprecation.mjs): the draft's twin is `timeline <p> import-item`. - const { takeEditDeprecation } = await import("./takeDeprecation.mjs"); - err(takeEditDeprecation("take --import-item", { project: project.id, take: id, instead: `umtool timeline ${project.id} import-item <src>:<item>[,<item>…]` })); + // A write into the take's patch, a supported path (12 Nov; takeDeprecation.mjs); the draft's twin is + // `timeline <p> import-item`. return await importItems(project, id, p, { reportsRoot, log, err }); } if (p.has("--preview") || p.has("--changes")) return await fastRender(project, id, p, out, { args, log, deps, renderMode }); diff --git a/umtool/lib/report/takeDeprecation.mjs b/umtool/lib/report/takeDeprecation.mjs @@ -1,8 +1,11 @@ -// THE TAKE-PATCH EDITS, DEPRECATED (umtool redesign L3, S6). Every edit lands in the working draft now; a saved -// version is frozen and is edited by opening it in the draft (`umtool takes open <p> <v>`). The CLI paths that -// still write a take's patch -- `--in-take`, `timeline --take`, `window --take`, `take --import-item` -- and the route behind the -// old take walk (/api/report/takes/timeline) keep working for now, each saying so in ONE line on stderr, so a -// script that leans on them hears it before they go. +// THE TAKE-PATCH EDITS (umtool redesign L3, S6; 12 Nov 2026). Every edit IN THE APP lands in the working draft; +// a saved version is frozen and is edited in the app by opening it in the draft (`umtool takes open <p> <v>`, +// which writes the version over the draft -- the draft saved first). The CLI's take-patch writes -- `set --take`, +// `look --take`, `window --take`, `timeline <verb> --take`, `posts … --in-take`, `take --import-item` -- are the +// SUPPORTED way to edit a take without touching the draft (knobs.md: "the take-scoped CLI stays for agents"): each +// writes takes/<t>/take.json's patch with an undo point of its own, and says nothing on stderr. They said this +// line from 9 Nov to 12 Nov, and its advice (open the take in the draft) is the one path that writes the draft. +// Only the old take walk's route (/api/report/takes/timeline, the app's) still says it, with its Deprecation header. // // Plain ESM: the CLI and the route both read it. diff --git a/umtool/lib/report/takeEdit.test.mjs b/umtool/lib/report/takeEdit.test.mjs @@ -303,8 +303,8 @@ test("the CLI twins: umtool walk --take, umtool timeline --take, umtool take --p out.length = 0; assert.equal(await timelineCommand(["proj", "--take", "tight", "move", "t03a", "--to", "0"], io), 0, err.join("\n")); assert.match(out.join("\n"), /take tight: moved t03a: 3 -> 0/); - // Deprecated (L3 S6): one line on stderr for a write, and it still works; `ls` (a read) says nothing. - assert.deepEqual(err, ["umtool: timeline move --take is deprecated -- edits land in the draft now; open the take there first (umtool takes open proj tight) and edit without it"]); + // A supported path (12 Nov): a write says nothing on stderr -- no deprecation line pointing at `takes open`. + assert.deepEqual(err, []); err.length = 0; assert.equal(await timelineCommand(["proj", "--take", "tight", "undo"], io), 0, err.join("\n")); // "Add to this take only" (lane/ui-simplify): a clip into the take's timeline, never the project's. diff --git a/umtool/lib/report/takeEditFirstClass.test.mjs b/umtool/lib/report/takeEditFirstClass.test.mjs @@ -0,0 +1,45 @@ +// Editing a take with --take is a supported path (12 Nov 2026): `window --take`, `set --take`, `timeline --take`, +// `posts … --in-take` write the take's patch with an undo point of its own and never the project's manifest (the +// operator's draft). They said "deprecated -- edits land in the draft now; open the take there first (umtool takes +// open …)", and that advice is the one path here that writes over the draft. They now say nothing on stderr. +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import test from "node:test"; +import { fileURLToPath } from "node:url"; +import { draftTake } from "./takeMaker.mjs"; + +const CLI = fileURLToPath(new URL("../../bin/umtool.mjs", import.meta.url)); + +test("window --take and set --take: the take's patch written, the draft byte for byte the same, no deprecation line", async () => { + const root = await mkdtemp(path.join(tmpdir(), "umtool-take-edit-")); + try { + const dir = path.join(root, "proj"); + await mkdir(dir, { recursive: true }); + const manifest = { schemaVersion: 1, slug: "proj", timeline: [{ type: "clip", id: "e1", channel: "ch", video: "v1", start: 10, end: 20 }, { type: "clip", id: "e2", channel: "ch", video: "v2", start: 30, end: 40 }] }; + await writeFile(path.join(dir, "video.manifest.json"), `${JSON.stringify(manifest, null, 2)}\n`); + await draftTake(dir, { id: "t1", label: "T1", patch: { timeline: manifest.timeline } }); + const draftBefore = await readFile(path.join(dir, "video.manifest.json"), "utf8"); + const run = (...args) => spawnSync(process.execPath, [CLI, ...args], { cwd: root, env: { ...process.env, REPORTS_DIR: root }, encoding: "utf8" }); + + let r = run("window", dir, "e1", "--take", "t1", "--start", "11", "--end", "21"); + assert.equal(r.status, 0, r.stderr); + assert.match(r.stdout, /e1 \(take t1\): 10–20 -> 11–21/); + assert.match(r.stdout, /undo point: takes\/t1\//); + assert.doesNotMatch(r.stderr, /deprecated/); + assert.equal(r.stderr.trim(), ""); + + r = run("set", dir, "e2", "audio.gain=3", "--take", "t1"); + assert.equal(r.status, 0, r.stderr); + assert.doesNotMatch(r.stderr, /deprecated/); + + const take = JSON.parse(await readFile(path.join(dir, "takes", "t1", "take.json"), "utf8")); + assert.equal(take.patch.timeline.find((e) => e.id === "e1").start, 11); + assert.equal(take.patch.timeline.find((e) => e.id === "e2").audio?.gain, 3); + assert.equal(await readFile(path.join(dir, "video.manifest.json"), "utf8"), draftBefore, "the operator's draft is never written"); + } finally { + await rm(root, { recursive: true, force: true }); + } +}); diff --git a/umtool/lib/report/takeMaker.mjs b/umtool/lib/report/takeMaker.mjs @@ -447,7 +447,7 @@ export function normalizeWindow(w) { * * @typedef {{ * manifestPath: string, outDir: string, slug: string, full: boolean, xfade: boolean, - * keepFrames?: boolean, estimateMb?: number | null, + * keepFrames?: boolean, estimateMb?: number | null, cutWindow?: { at: number, dur: number } | null, * emit: (ev: Record<string, unknown>) => void, log: (line: string) => void, * signal?: AbortSignal, * }} RenderJob @@ -728,10 +728,12 @@ async function makeTakeLocked(projectDir, rawSpec, opts) { if (wrong.length) throw new Error(`${spec.id}: ${wrong.map(incorrectWhy).join("; ")}`); // 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. + // person ruled it (`quoteRuled`). No check on record refuses nothing. The + // 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, readQuoteCheck } = await import("./quoteCheck.mjs"); - const unheard = quoteGate(renderDoc.timeline, await readQuoteCheck(projectDir)); + 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("; ")} ` + diff --git a/umtool/lib/report/takePreview.mjs b/umtool/lib/report/takePreview.mjs @@ -12,6 +12,16 @@ // The take's full render -- preview.mp4, out/<slug>.mp4, out/sourced/, take.json, render.json -- is // never touched. A draft is previewed from its stored patch, as its render would be. // +// umtool take <p> --id <t> --preview --at S --dur S +// CUT SECONDS [S, S + dur] of the take's own cut (its schedule: the last preview's or render's, else its +// entries' own lengths, said as estimates) -- not the project's draft, whose timeline a take may not +// share (rev9-a9, 12 Nov: `--at 440 --dur 170` timed over the draft rendered 92 s of early clips). The +// whole take is handed to the build with the window (build-video --cut-window): every segment built or +// reused by its key, only the window's seconds laid and encoded, the deck drawn over the whole cut's +// schedule from S -- its timeline, counters and trail at their state then, never reset. Into +// takes/<t>/out/<slug>.preview.<S>-<S+dur>.mp4 the window's own file, never over the full preview's +// takes/<t>/out/window/ its build and record +// // umtool take <p> --id <t> --changes [--from <t0>] [--pad 3] [--no-preview] // a REEL of only what changed against <t0> (default: the take's own `from`): each changed item -- added, // re-read, re-picked, re-voiced, fx, a trim, a hold, a panel, … -- with one neighbour each side @@ -37,7 +47,7 @@ import { mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises"; import path from "node:path"; import { promisify } from "node:util"; import { applyMontageRulings, readMontageRulings } from "umtool-report-to-video/montage-rulings"; -import { composeTake, checkSpec, estimatedSeconds, getPath, linkSharedOut, MANIFEST, mergePatch, QUICK_RENDER, sourcedEntries, windowManifest } from "./takeMaker.mjs"; +import { composeTake, checkSpec, estimatedSeconds, getPath, linkSharedOut, MANIFEST, mergePatch, QUICK_RENDER, sourcedEntries, windowEntries, windowManifest } from "./takeMaker.mjs"; import { takesDirOf, TAKE_FILE } from "./takes.mjs"; import { tmpPathFor } from "yt-dlp-transcript-common/lib/atomicFile.mjs"; @@ -50,6 +60,8 @@ export const PREVIEW_DEFAULTS = Object.freeze({ width: 1280, height: 720, preset /** The build dirs under takes/<t>/out/. */ export const PREVIEW_DIR = "preview"; export const CHANGES_DIR = "changes"; +/** A windowed preview's build dir (`--preview --at S --dur S`). */ +export const WINDOW_DIR = "window"; /** The changes reel's list, beside take.json. */ export const CHANGES_FILE = "changes.json"; /** Seconds of context either side of a changed item in the reel. */ @@ -122,6 +134,39 @@ export function previewPaths(takeDir, slug) { }; } +/** Seconds in a file name: 440, 612.5. Pure. */ +const secondsName = (v) => String(Math.round(Number(v) * 1000) / 1000); + +/** A windowed preview's file, beside the full preview and never over it: <slug>.preview.<at>-<to>.mp4. Pure. */ +export function windowPreviewMp4(takeDir, slug, win) { + return path.join(takeDir, "out", `${slug}.preview.${secondsName(win.at)}-${secondsName(win.at + win.dur)}.mp4`); +} + +/** + * Which entries of the TAKE's own cut a window of cut seconds covers: timed by `schedule` (the take's last + * measured one, when newer than its take.json: takeScheduleOf) when it names every entry, else by the entries' + * own lengths (estimates). A window that starts at or past the end -- measured, or estimated (said so) -- is + * refused before anything is built, naming the unit. Pure. + * + * @param {Array<Record<string, any>>} timeline the take's render timeline (its rulings applied) + * @param {{ at: number, dur: number }} win + * @param {{ segments?: Array<{ id: string, start: number, duration: number }>, estimated?: boolean } | null} schedule + * @returns {{ ids: string[], basis: "schedule" | "estimate", total: number }} + */ +export function previewWindowPlan(timeline, win, schedule) { + const measured = schedule && schedule.estimated !== true ? schedule : null; + const w = windowEntries(timeline, win, measured); + if (!(win.at < w.total)) { + const len = Math.round(w.total * 10) / 10; + throw new Error( + w.basis === "schedule" + ? `--at ${win.at} is past the end of the take's cut (${len} s of cut time, by its schedule): --at and --dur are seconds of the take's cut` + : `--at ${win.at} is past the end of the take's cut by its entries' own lengths (an estimate: ${len} s of cut time; the take has no schedule newer than its take.json): --at and --dur are seconds of the take's cut`, + ); + } + return { ids: w.ids, basis: w.basis, total: w.total }; +} + // --------------------------------------------------------------------------- // What changed: one take's timeline against another's. // --------------------------------------------------------------------------- @@ -500,11 +545,11 @@ async function linkSources(projectDir, id, from, dst, { tierDir }) { * One build of a render manifest into `outDir` (the take's preview or changes dir): through renderTake, * the heavy slot and all, recorded in outDir/render.json and render.log. Resolves to the build's mp4. */ -async function buildInto(projectDir, { id, label, kind, renderDoc, outDir, from, xfade, opts }) { +async function buildInto(projectDir, { id, label, kind, renderDoc, outDir, from, xfade, opts, cutWindow = null }) { const recordMod = await import("./renderRecord.mjs"); await mkdir(outDir, { recursive: true }); const rec = await recordMod - .openRenderRecord(outDir, { take: id, projectDir, project: opts.projectId ?? null, label: `${label} (${kind})`, argv: opts.argv, reportsRoot: null }) + .openRenderRecord(outDir, { take: id, projectDir, project: opts.projectId ?? null, label: `${label} (${kind})`, argv: opts.argv, reportsRoot: null, ...(cutWindow ? { window: cutWindow } : {}) }) .catch(() => null); const log = (line) => { rec?.line(line); @@ -523,7 +568,7 @@ async function buildInto(projectDir, { id, label, kind, renderDoc, outDir, from, await writeFile(renderPath, JSON.stringify(renderDoc, null, 2) + "\n", "utf8"); const render = opts.render ?? (await import("./takeRender.mjs")).renderTake; const t0 = Date.now(); - const { file } = await render({ manifestPath: renderPath, outDir, slug: String(renderDoc.slug ?? ""), full: false, xfade: xfade === true, keepFrames: false, emit, log, ...(opts.signal ? { signal: opts.signal } : {}) }); + const { file } = await render({ manifestPath: renderPath, outDir, slug: String(renderDoc.slug ?? ""), full: false, xfade: xfade === true, keepFrames: false, emit, log, ...(cutWindow ? { cutWindow } : {}), ...(opts.signal ? { signal: opts.signal } : {}) }); const made = await stat(file).catch(() => null); if (!made?.isFile() || made.size === 0) throw new Error(`${id}: the ${kind} render wrote no mp4 (${file})`); return { file, rec, log, renderSeconds: Math.round((Date.now() - t0) / 100) / 10 }; @@ -557,6 +602,8 @@ export async function probeSize(file) { * render?: Function, projectId?: string, argv?: string[], signal?: AbortSignal }} [opts] */ export async function previewTake(projectDir, id, opts = {}) { + // --at/--dur said: seconds of the take's own cut, to the window's own file (windowPreview). + if (opts.window && opts.window !== "full") return windowPreview(projectDir, id, opts.window, opts); const { take, spec } = await storedSpec(projectDir, id); const from = opts.from ?? null; if (from) await checkFrom(projectDir, id, from); @@ -583,6 +630,89 @@ export async function previewTake(projectDir, id, opts = {}) { return { id, mp4: p.previewMp4, seconds, renderSeconds: b.renderSeconds, tier: t }; } +/** + * The take's last measured schedule: its preview's build, else its full render's -- the newer -- and only when it is + * newer than the take's take.json (a take edited since may have grown: review 1, S1); else null (estimates). + */ +async function takeScheduleOf(takeDir) { + const taken = await stat(path.join(takeDir, TAKE_FILE)).catch(() => null); + const got = []; + for (const d of [path.join(takeDir, "out", PREVIEW_DIR, "sourced"), path.join(takeDir, "out", "sourced")]) { + const file = path.join(d, "schedule.json"); + const [doc, st] = await Promise.all([readJson(file), stat(file).catch(() => null)]); + if (doc && st && doc.estimated !== true && Array.isArray(doc.segments)) got.push({ doc, mtime: st.mtimeMs, file }); + } + got.sort((a, b) => b.mtime - a.mtime); + const best = got[0] ?? null; + // Strictly newer: a timestamp tie (coarse fs clocks) is not proof the schedule saw this take.json. + return best && taken && !(best.mtime > taken.mtimeMs) ? null : best; +} + +/** "600-1100": a window's span as a file name and a label say it. Pure. */ +export const windowSpan = (win) => `${secondsName(win.at)}-${secondsName(win.at + win.dur)}`; + +/** + * `umtool take <p> --id <t> --preview --at S --dur S`: cut seconds [S, S + dur] of the take's own cut at the + * preview tier -- the whole take built (segments reused by their keys), only the window laid and encoded, its + * chrome at its state then (build-video --cut-window). To <slug>.preview.<S>-<S+dur>.mp4; the full preview, + * and the take's render, untouched. + * + * @param {string} projectDir + * @param {string} id + * @param {{ at: number, dur: number }} win + * @param {Parameters<typeof previewTake>[2]} [opts] + */ +async function windowPreview(projectDir, id, win, opts = {}) { + const { take, spec } = await storedSpec(projectDir, id); + const from = opts.from ?? null; + if (from) await checkFrom(projectDir, id, from); + const log = opts.log ?? (() => {}); + const c = await composeTake(projectDir, { ...spec, window: "full" }, { log }); + const renderDoc = atPreviewTier(spec.quick ? /** @type {Record<string, any>} */ (mergePatch(c.renderDoc, QUICK_RENDER)) : c.renderDoc); + const takeDir = path.join(takesDirOf(projectDir), id); + const slug = String(c.manifest.slug ?? ""); + const sched = await takeScheduleOf(takeDir); + const plan = previewWindowPlan(renderDoc.timeline, win, sched?.doc ?? null); + const outDir = path.join(takeDir, "out", WINDOW_DIR); + // One window at a time (review 1, S3): its build dir, record and work files are shared. + { + const { readRenderRecord } = await import("./renderRecord.mjs"); + const live = await readRenderRecord(outDir); + if (live && (live.state === "running" || live.state === "waiting")) { + throw new Error(`a window preview of ${id} is running (pid ${live.pid}, window ${live.window ? windowSpan(live.window) : "?"}, since ${live.startedAt}): wait for it to end (umtool take status <p> --id ${id})`); + } + } + const span = `cut seconds ${secondsName(win.at)}–${secondsName(win.at + win.dur)}`; + const t = renderDoc.render.tier; + log( + `${id}: a preview of ${span} of the take's cut — ${plan.ids.length} entr${plan.ids.length === 1 ? "y" : "ies"} (${plan.ids.join(", ")}), ` + + (plan.basis === "schedule" ? `timed by ${path.relative(takeDir, sched?.file ?? "")}` : "timed by their own lengths (estimates: the take has no schedule newer than its take.json)") + + `; ${t.width}x${t.height}, ${t.preset}, crf ${t.crf}; the whole cut's segments built or reused, its chrome at its state then (no rail)` + + `${from ? `; reusing ${from}'s` : ""}${take.draft ? " (a draft: its stored patch)" : ""}`, + ); + // The window the build laid (build-video's done event: clipped at the cut's end), else the plan's end clips it. + let laid = null; + const emit = opts.emit ?? (() => {}); + const watched = { ...opts, emit: (ev) => { + if (ev?.ev === "done" && ev.window && Number.isFinite(Number(ev.window.at)) && Number(ev.window.dur) > 0) laid = { at: Number(ev.window.at), dur: Number(ev.window.dur) }; + emit(ev); + } }; + const b = await buildInto(projectDir, { id, label: `${spec.label} ${span}`, kind: WINDOW_DIR, renderDoc, outDir, from, xfade: takeXfade(c), opts: watched, cutWindow: win }); + const rendered = laid ?? { at: win.at, dur: Math.max(0, Math.min(win.dur, plan.total - win.at)) }; + const mp4 = windowPreviewMp4(takeDir, slug, rendered); + try { + await rename(b.file, mp4); + } catch (e) { + await b.rec?.fail(e); + throw e; + } + const seconds = await probeSeconds(mp4); + const doc = await b.rec?.done({ mp4, seconds }); + if (doc && doc.state !== "done") throw new Error(doc.error ?? `${id}: the window's preview left no mp4`); + b.log(`${id}: preview of ${span} ${path.relative(takeDir, mp4)} — ${seconds ?? "?"} s, rendered in ${b.renderSeconds} s`); + return { id, mp4, seconds, renderSeconds: b.renderSeconds, tier: t, window: win, rendered, covers: plan.ids, basis: plan.basis }; +} + async function checkFrom(projectDir, id, from) { if (from === id) throw new Error(`--from ${from}: that is this take — name another take`); const dir = path.join(takesDirOf(projectDir), from); @@ -788,6 +918,8 @@ export function fastKindOf(argv) { const a = Array.isArray(argv) ? argv : []; if (a[0] !== "take") return null; if (a.includes("--changes")) return "changes"; + // A window of the take (--preview --at/--dur): its own build and record, out/window/ (review 1, S4). + if (a.includes("--preview") && (a.includes("--at") || a.includes("--dur"))) return "window"; if (a.includes("--preview")) return "preview"; return null; } @@ -816,8 +948,14 @@ export async function fastRenders(takeDir, slug) { }; }; const [preview, changes, list] = await Promise.all([one(p.previewOut, p.previewMp4), one(p.changesOut, p.changesMp4), readJson(p.changesFile)]); + // The last window's: its record names its file and its window (`span`, as asked). + const windowOut = path.join(takeDir, "out", WINDOW_DIR); + const wrec = await readRenderRecord(windowOut); + const wmp4 = wrec?.mp4 ? path.resolve(windowOut, wrec.mp4) : null; + const window = wrec ? { ...(await one(windowOut, wmp4 ?? path.join(windowOut, "-"))), span: wrec.window ? windowSpan(wrec.window) : null } : null; return { preview, + window, changes: changes || list ? { ...(changes ?? { state: null, mp4: null }), list: list ? p.changesFile : null, items: Array.isArray(list?.items) ? list.items.length : null, from: list?.from ?? null } : null, }; } diff --git a/umtool/lib/report/takePreviewWindow.test.mjs b/umtool/lib/report/takePreviewWindow.test.mjs @@ -0,0 +1,178 @@ +// `umtool take <p> --id <t> --preview --at S --dur S` (12 Nov 2026, rev9-a9: `--at 440 --dur 170` rendered 92 s of +// the cut's early clips with the chrome reset, over the full preview's file). --at/--dur are seconds of the TAKE's +// own cut: the take's measured schedule says which entries they cover; the whole cut is handed to the render with +// the window (build-video --cut-window), so the deck draws its state at that second; the file is the window's own. +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { mkdtempSync, rmSync } from "node:fs"; +import { mkdir, readFile, utimes, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import { fastKindOf, fastRenders, previewTake, previewWindowPlan, windowPreviewMp4 } from "./takePreview.mjs"; +import { renderArgv } from "./takeRender.mjs"; +import { cutWindowFile, cutWindowFlag, cutWindowSpan } from "umtool-report-to-video/build-video"; + +const clip = (id, len) => ({ type: "clip", id, video: "v", cutStart: 0, cutEnd: len }); + +/** A project whose draft holds a–f (100 s each) and a take whose own cut opens with x (300 s), measured. */ +async function fixture() { + const dir = mkdtempSync(path.join(tmpdir(), "take-window-")); + const base = { slug: "s", title: "T", render: { width: 1920, height: 1080, fps: 30 }, timeline: ["a", "b", "c", "d", "e", "f"].map((id) => clip(id, 100)) }; + await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify(base)); + const takeDir = path.join(dir, "takes", "t1"); + const timeline = [clip("x", 300), ...base.timeline]; + await mkdir(path.join(takeDir, "out", "preview", "sourced"), { recursive: true }); + await writeFile(path.join(takeDir, "take.json"), JSON.stringify({ id: "t1", label: "T1", draft: true, window: "full", patch: { timeline } })); + await writeFile(path.join(takeDir, "out", "s.preview.mp4"), "FULL"); + let t = 0; + const segments = timeline.map((e) => { + const s = { id: e.id, start: t, duration: e.cutEnd }; + t += e.cutEnd; + return s; + }); + await writeFile(path.join(takeDir, "out", "preview", "sourced", "schedule.json"), JSON.stringify({ estimated: false, total: t, segments })); + return { dir, takeDir }; +} + +test("previewWindowPlan: --at/--dur are seconds of the take's own cut, timed by its measured schedule", () => { + const timeline = [clip("x", 300), clip("a", 100), clip("b", 100), clip("c", 100), clip("d", 100)]; + const schedule = { segments: timeline.map((e, i) => ({ id: e.id, start: i === 0 ? 0 : 300 + (i - 1) * 100, duration: e.cutEnd })) }; + const p = previewWindowPlan(timeline, { at: 440, dur: 170 }, schedule); + assert.deepEqual(p.ids, ["b", "c", "d"]); + assert.equal(p.basis, "schedule"); + // Past the take's end: refused, naming the unit and the cut's length. + assert.throws(() => previewWindowPlan(timeline, { at: 900, dur: 10 }, schedule), /--at 900 is past the end of the take's cut \(700 s of cut time/); + // No schedule: the take's own lengths, said to be estimates. + const e = previewWindowPlan(timeline, { at: 0, dur: 10 }, null); + assert.equal(e.basis, "estimate"); + assert.deepEqual(e.ids, ["x"]); +}); + +test("take --preview --at 440 --dur 170: the whole take's cut with the window, to its own file; the full preview untouched", async () => { + const { dir, takeDir } = await fixture(); + try { + /** @type {any[]} */ + const jobs = []; + const lines = []; + const render = async (job) => { + const doc = JSON.parse(await readFile(job.manifestPath, "utf8")); + jobs.push({ ...job, doc }); + const file = cutWindowFile(job.outDir, job.slug, "sourced"); + await mkdir(path.dirname(file), { recursive: true }); + await writeFile(file, "WINDOW"); + return { file }; + }; + const r = await previewTake(dir, "t1", { window: { at: 440, dur: 170 }, render, log: (l) => lines.push(l) }); + assert.equal(jobs.length, 1); + // The window is the render's to lay: every entry of the take's cut is in its manifest (the chrome's state at 440 s). + assert.deepEqual(jobs[0].doc.timeline.map((e) => e.id), ["x", "a", "b", "c", "d", "e", "f"]); + assert.deepEqual(jobs[0].cutWindow, { at: 440, dur: 170 }); + assert.equal(jobs[0].doc.render.tier?.name, "preview"); + // Its own build dir, never the full preview's. + assert.equal(jobs[0].outDir, path.join(takeDir, "out", "window")); + // The entries the take's schedule puts in 440–610: b (400–500), c (500–600), d (600–700). + assert.deepEqual(r.covers, ["b", "c", "d"]); + assert.ok(lines.some((l) => /cut seconds 440–610/.test(l) && /b, c, d/.test(l)), lines.join("\n")); + assert.equal(r.mp4, path.join(takeDir, "out", "s.preview.440-610.mp4")); + assert.equal(r.mp4, windowPreviewMp4(takeDir, "s", { at: 440, dur: 170 })); + assert.equal(await readFile(r.mp4, "utf8"), "WINDOW"); + assert.equal(await readFile(path.join(takeDir, "out", "s.preview.mp4"), "utf8"), "FULL"); + // Past the take's end: refused before anything renders. + await assert.rejects(previewTake(dir, "t1", { window: { at: 2000, dur: 10 }, render }), /--at 2000 is past the end/); + assert.equal(jobs.length, 1); + } finally { + rmSync(dir, { recursive: true, force: true }); + } +}); + +test("--cut-window: build-video's flag, its span against the cut, and the take render's argv", () => { + assert.equal(cutWindowFlag(["m.json"]), null); + assert.deepEqual(cutWindowFlag(["m.json", "--cut-window", "440", "170"]), { at: 440, dur: 170 }); + assert.throws(() => cutWindowFlag(["m.json", "--cut-window", "7:20", "170"]), /seconds of the cut/); + assert.throws(() => cutWindowFlag(["m.json", "--cut-window", "4", "5", "--chrome-only"]), /not with --chrome-only/); + assert.deepEqual(cutWindowSpan({ at: 600, dur: 170 }, 668.3), { at: 600, dur: 668.3 - 600 }); + assert.throws(() => cutWindowSpan({ at: 700, dur: 10 }, 668.3), /past the cut's end \(668\.3 s/); + const argv = renderArgv({ manifestPath: "m.json", outDir: "/o", full: false, xfade: false, queueLock: null, cutWindow: { at: 440, dur: 170 } }); + assert.deepEqual(argv.slice(argv.indexOf("--cut-window"), argv.indexOf("--cut-window") + 3), ["--cut-window", "440", "170"]); + assert.ok(!renderArgv({ manifestPath: "m.json", outDir: "/o", full: false, xfade: false, queueLock: null }).includes("--cut-window")); + assert.equal(cutWindowFile("/o", "s", "sourced"), "/o/sourced/s.window.mp4"); +}); + +// Review round 1 (S1–S6). +test("a schedule older than take.json is not the take's: its entries' lengths, said as estimates -- and an --at past their end refused before anything builds (S1, S2)", async () => { + const { dir, takeDir } = await fixture(); + try { + // The take grew since its last preview: x is 500 s now (the schedule says 300). Its take.json is the newer file. + const tj = JSON.parse(await readFile(path.join(takeDir, "take.json"), "utf8")); + tj.patch.timeline[0] = clip("x", 500); + await writeFile(path.join(takeDir, "take.json"), JSON.stringify(tj)); + const old = new Date(Date.now() - 3600_000); + await utimes(path.join(takeDir, "out", "preview", "sourced", "schedule.json"), old, old); + const jobs = []; + const render = async (job) => { + jobs.push(job); + const file = cutWindowFile(job.outDir, job.slug, "sourced"); + await mkdir(path.dirname(file), { recursive: true }); + await writeFile(file, "W"); + return { file }; + }; + // 650 is inside the take's 1100 s now (by its lengths), past the stale schedule's 900 -- not refused. + const r = await previewTake(dir, "t1", { window: { at: 650, dur: 50 }, render }); + assert.equal(r.basis, "estimate"); + assert.deepEqual(r.covers, ["b"]); + // Past the estimated end: refused, saying it is an estimate and the length, before any render. + await assert.rejects(previewTake(dir, "t1", { window: { at: 5000, dur: 50 }, render }), /--at 5000 is past the end of the take's cut by its entries' own lengths \(an estimate: 1100 s/); + assert.equal(jobs.length, 1); + } finally { + rmSync(dir, { recursive: true, force: true }); + } +}); + +test("the file names the window rendered (clipped at the cut's end); a second window while one runs is refused; take status reads the window's record (S3, S4, S5)", async () => { + const { dir, takeDir } = await fixture(); + try { + // The build reports the window it laid (build-video's done event): 650–700, the cut ends at 700. + const render = async (job) => { + job.emit({ ev: "done", out: "x", failures: [], window: { at: 650, dur: 50 } }); + const file = cutWindowFile(job.outDir, job.slug, "sourced"); + await mkdir(path.dirname(file), { recursive: true }); + await writeFile(file, "W"); + return { file }; + }; + const r = await previewTake(dir, "t1", { window: { at: 650, dur: 100 }, render }); + assert.equal(path.basename(r.mp4), "s.preview.650-700.mp4"); + // With no report from the build, the plan's own end clips it. + const r2 = await previewTake(dir, "t1", { window: { at: 600, dur: 500 }, render: async (job) => { + const file = cutWindowFile(job.outDir, job.slug, "sourced"); + await mkdir(path.dirname(file), { recursive: true }); + await writeFile(file, "W"); + return { file }; + } }); + assert.equal(path.basename(r2.mp4), "s.preview.600-900.mp4"); + // take status: the window's own record, labelled, never the full preview's. + const fast = await fastRenders(takeDir, "s"); + assert.equal(fast.window?.state, "done"); + assert.equal(fast.window?.span, "600-1100"); + assert.equal(path.basename(fast.window?.mp4 ?? ""), "s.preview.600-900.mp4"); + assert.equal(fast.preview?.mp4, path.join(takeDir, "out", "s.preview.mp4")); + assert.equal(fastKindOf(["take", "p", "--id", "t1", "--preview", "--at", "1", "--dur", "2"]), "window"); + assert.equal(fastKindOf(["take", "p", "--id", "t1", "--preview"]), "preview"); + const { takeStatus } = await import("../queue/cli.mjs"); + const said = []; + await takeStatus({ id: "p", dir }, { take: "t1", json: false, showLog: false, tail: null, reportsRoot: dir, env: {}, log: (l) => said.push(l), err: (l) => said.push(l) }); + assert.match(said.join("\n"), /window 600-1100: DONE — .*s\.preview\.600-900\.mp4/); + assert.match(said.join("\n"), /preview: DONE — .*out\/s\.preview\.mp4/); + // A window running now (its record live, this very process): the second is refused, naming it. + const rec = JSON.parse(await readFile(path.join(takeDir, "out", "window", "render.json"), "utf8")); + await writeFile(path.join(takeDir, "out", "window", "render.json"), JSON.stringify({ ...rec, state: "running", pid: process.pid, pidStart: null, endedAt: null })); + await assert.rejects(previewTake(dir, "t1", { window: { at: 10, dur: 5 }, render }), new RegExp(`a window preview of t1 is running \\(pid ${process.pid}, window 600-1100`)); + } finally { + rmSync(dir, { recursive: true, force: true }); + } +}); + +test("--cut-window refuses the runs that are not a build of the cut (S6)", () => { + for (const f of [["--clip-preview", "c1"], ["--fetch-only", "c1"], ["--short", "c1"], ["--join-preview"], ["--thumbnail"], ["--chapters-only"]]) { + assert.throws(() => cutWindowFlag(["m.json", "--cut-window", "1", "2", ...f]), new RegExp(`not with ${f[0]}`), f[0]); + } +}); diff --git a/umtool/lib/report/takeRender.mjs b/umtool/lib/report/takeRender.mjs @@ -30,7 +30,7 @@ import { existsSync } from "node:fs"; import path from "node:path"; import { promisify } from "node:util"; import { readFile } from "node:fs/promises"; -import { DEFAULT_VARIANT, variantPaths, xfadeBatchSize } from "umtool-report-to-video/build-video"; +import { cutWindowFile, DEFAULT_VARIANT, variantPaths, xfadeBatchSize } from "umtool-report-to-video/build-video"; import { manifestEstimateMb, renderEstimateMb } from "umtool-report-to-video/render-estimate"; import { PIPELINE_DIR, UMTOOL_DIR } from "./driver.mjs"; @@ -48,9 +48,10 @@ export function queueLockScript() { /** * The argv of a take's render, pure. * `estimateMb`: what the render declares to the heavy slot (null: nothing). - * @param {{ manifestPath: string, outDir: string, full: boolean, xfade: boolean, keepFrames?: boolean, queueLock?: string | null, estimateMb?: number | null }} job + * `cutWindow`: only those cut seconds laid and encoded, the whole cut's segments built (build-video --cut-window). + * @param {{ manifestPath: string, outDir: string, full: boolean, xfade: boolean, keepFrames?: boolean, queueLock?: string | null, estimateMb?: number | null, cutWindow?: { at: number, dur: number } | null }} job */ -export function renderArgv({ manifestPath, outDir, full, xfade, keepFrames = false, queueLock = queueLockScript(), estimateMb = renderEstimateMb("render") }) { +export function renderArgv({ manifestPath, outDir, full, xfade, keepFrames = false, queueLock = queueLockScript(), estimateMb = renderEstimateMb("render"), cutWindow = null }) { const build = [ process.execPath, path.join(/* turbopackIgnore: true */ PIPELINE_DIR, "build-video.mjs"), @@ -64,6 +65,7 @@ export function renderArgv({ manifestPath, outDir, full, xfade, keepFrames = fal ...(xfade ? [] : ["--no-xfade"]), ...(full ? [] : ["--no-chapters"]), ...(keepFrames ? ["--keep-frames"] : []), + ...(cutWindow ? ["--cut-window", String(cutWindow.at), String(cutWindow.dur)] : []), ]; if (!queueLock) return build; const estimate = Number(estimateMb) > 0 ? ["--estimate", String(Math.round(Number(estimateMb)))] : []; @@ -183,7 +185,7 @@ export async function renderTake(job) { return; } if (code === 0 && !failed.length) { - resolve({ file: variantPaths(job.outDir, job.slug, DEFAULT_VARIANT).final }); + resolve({ file: job.cutWindow ? cutWindowFile(job.outDir, job.slug, DEFAULT_VARIANT) : variantPaths(job.outDir, job.slug, DEFAULT_VARIANT).final }); return; } reject( diff --git a/umtool/lib/report/takeScope.test.mjs b/umtool/lib/report/takeScope.test.mjs @@ -108,8 +108,8 @@ test("--in-take: set-item, narrate --pick, roles --set and fx land in the take's assert.match(r.out, /on take t1 \(its patch; scope-a's manifest untouched\): 1 edit\(s\), undo point takes\/t1\/revisions\/.*-auto-before-post-item\.take\.json -- umtool timeline scope-a --take t1 undo/); assert.equal(await text(a), before, "the project's manifest is never written"); assert.equal((await takeDoc(a, "t1")).patch.timeline.find((e) => e.id === "p-1").hold, 4); - // Deprecated (L3 S6): it still lands, and says so in one line on stderr. - assert.equal(r.err, "umtool: posts set-item --in-take is deprecated -- edits land in the draft now; open the take there first (umtool takes open scope-a t1) and edit without it"); + // A supported path (12 Nov): it lands, and says nothing on stderr. + assert.equal(r.err, ""); // The alias: set-item's --take <t> is --in-take <t>; --json is the command's own object with the take. r = await posts("set-item", "scope-a", "p-1", "thread.group=g1", "--take", "t1", "--json"); assert.equal(r.code, 0, r.err); @@ -235,8 +235,8 @@ test("--import-item: an item of another project cloned into the take with its na assert.deepEqual(doc.items[0].avatars, ["neighbour_one"]); r = await take("imp-dst", "--id", "t1", "--import-item", "imp-src:12", "--before", "p-3"); assert.equal(r.code, 0, r.err); - // A take-patch write, deprecated in one line on stderr that names the draft's verb. - assert.match(r.err, /^umtool: take --import-item is deprecated -- .*umtool takes open imp-dst t1\) and use umtool timeline imp-dst import-item <src>:<item>/m); + // A take-patch write, a supported path (12 Nov): no deprecation line. + assert.doesNotMatch(r.err, /deprecated/); assert.match(r.out, /p-12: added from imp-src:12 at 4, after p-2, before p-3/); const m = (await resolveTakeManifest(dst.dir, "t1")).manifest; assert.deepEqual(m.timeline.map((e) => e.id), ["p-1", "p-11", "p-10", "p-2", "p-12", "p-3"]); diff --git a/umtool/lib/report/timelineCli.mjs b/umtool/lib/report/timelineCli.mjs @@ -570,8 +570,7 @@ export async function timelineCommand(args, { root = REPORTS_ROOT, out = (s) => // A video entry (video-entry.mjs), into the cut or a take's timeline. if (verb === "add-video" || verb === "set-video") return await videoVerb(project, verb, rest, flags, { out, json }); if (flags.has("--take")) { - // `ls` only reads; a write into a take's patch is the deprecated path (L3 S6). - if (verb !== "ls") err((await import("./takeDeprecation.mjs")).takeEditDeprecation(`timeline ${verb} --take`, { project: project.id, take: String(flags.get("--take")) })); + // A write into a take's patch: a supported path (12 Nov; takeDeprecation.mjs) -- never the draft. return await takeTimeline(project, String(flags.get("--take")), verb, rest, flags, { out, json }); } const manifest = await readManifest(project.dir); diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs @@ -122,6 +122,9 @@ // --chrome-preview <at> <dur> Render only that window of the deck and write // out/<variant>/<slug>.preview.mp4 of it, from the cached // concat when there is one, else from the segments it touches +// --cut-window <at> <dur> A full build's segments, then only cut seconds +// [at, at + dur] laid and encoded, the deck at its state then, +// to out/<variant>/<slug>.window.mp4 (umtool take --preview --at) // // Requires: yt-dlp, ffmpeg/ffprobe, ImageMagick with Pango. @@ -7506,6 +7509,24 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly // on their inputs; null without any, which leaves every concat as it was. const joins = await cutJoins({ schedule: deck ? schedule : null, entries, segments, render }); + // `--cut-window <at> <dur>` (umtool take … --preview --at S --dur S): the WHOLE cut's segments, built or + // reused by their keys as above, then only cut seconds [at, at + dur] laid and encoded -- the deck rendered + // over the whole cut's schedule from `at`, so its timeline, counters and trail show their state at that + // second, never a cut that starts there. To out/<variant>/<slug>.window.mp4 (cutWindowFile). + if (opts.cutWindow) { + const { starts, durs, total } = await cutOffsets(segments, D, render.fps, joins); + const end = deck ? schedule.total : total; + const { at, dur } = cutWindowSpan(opts.cutWindow, end); + const plan = deck && !opts.noChrome ? await renderDeck({ manifestPath, render, outDir, variant, schedule, from: at, duration: dur }) : { regions: [] }; + const out = path.join(outDir, `${manifest.slug}.window.mp4`); + EMIT("note", { message: `--cut-window: cut seconds ${at}–${Math.round((at + dur) * 1000) / 1000} of ${Math.round(end * 10) / 10}` }); + await execFileP(FFMPEG, previewFromSegmentsArgs({ segments, durs, starts, D, at, dur, render, chromePlan: plan, outPath: out, joins }), { maxBuffer: 1 << 26 }); + await tierFinalPass(out, render); + // The window laid, clipped at the cut's end: the take names its file by it. + EMIT("done", { out, failures: [], window: { at, dur } }); + return { out, failures: [] }; + } + const railPlan = opts.noRail ? null : await buildRailPlan(manifest, render, entries, segments, D, outDir); // A hard-cut deck build's sound needs only the segments and the joins: it // is begun now, beside the deck's capture, and the chunked encode awaits it. @@ -7722,6 +7743,34 @@ export function chromeFlags(argv) { } /** + * `--cut-window <at> <dur>`, read off argv: seconds of the CUT (its schedule), or null. Pure; throws a + * sentence on a malformed one, or beside a run that does not build the cut. + */ +export function cutWindowFlag(argv) { + const i = argv.indexOf("--cut-window"); + if (i < 0) return null; + const at = Number(argv[i + 1]); + const dur = Number(argv[i + 2]); + if (argv[i + 1] === undefined || argv[i + 2] === undefined || !Number.isFinite(at) || !Number.isFinite(dur) || at < 0 || dur <= 0) { + throw new Error("--cut-window takes <at> <dur> in seconds of the cut (at ≥ 0, dur > 0)"); + } + for (const f of ["--chrome-only", "--chrome-preview", "--rail-only", "--preview", "--only", "--clip-preview", "--fetch-only", "--short", "--join-preview", "--thumbnail", "--chapters-only"]) { + if (argv.includes(f)) throw new Error(`--cut-window builds the cut and lays a window of it: not with ${f}`); + } + return { at, dur }; +} + +/** A cut window against the cut's length: `at` inside the cut, `dur` to its end at most; refused past it. Pure. */ +export function cutWindowSpan(win, total) { + const at = Number(win.at); + if (!(at < total)) throw new Error(`--cut-window: ${at} s is past the cut's end (${Math.round(total * 10) / 10} s of cut time)`); + return { at, dur: Math.min(Number(win.dur), total - at) }; +} + +/** Where `--cut-window` writes its file: out/<variant>/<slug>.window.mp4. Pure. */ +export const cutWindowFile = (outRoot, slug, variant) => path.join(variantPaths(outRoot, slug, variant).dir, `${slug}.window.mp4`); + +/** * Does this run take the machine's heavy slot (heavy-gate.mjs)? Every run that * renders the cut does -- a full build, --chrome-only, --chrome-preview, * --rail-only, a --no-chrome build, one clip's --clip-preview. A fetch, one `--only` segment, the @@ -7809,6 +7858,7 @@ async function main() { " [--progress ndjson] [--continue-on-error] [--no-reuse] [--no-segment-cache]\n" + " [--no-rail] [--rail-only] [--preview <start> <dur>]\n" + " [--chrome-only] [--no-chrome] [--chrome-preview <at> <dur>] [--keep-frames] (render.chrome, the deck)\n" + + " [--cut-window <at> <dur>] (the whole cut's segments, then only those cut seconds laid and encoded)\n" + " [--clip-preview <id>] (one clip's segment with its deck: out/<variant>/clip-preview/<id>.mp4)\n" + " [--lint] [--no-lint] (lint the manifest and stop / build without the lint)\n" + " [--no-rulings] (build as if there were no montage-rulings.json beside the manifest)\n" + @@ -7868,6 +7918,7 @@ async function main() { }; try { Object.assign(opts, chromeFlags(argv)); + opts.cutWindow = cutWindowFlag(argv); } catch (err) { console.error(err.message); process.exit(2); diff --git a/umtool/report-to-video/modules/trail.mjs b/umtool/report-to-video/modules/trail.mjs @@ -37,7 +37,7 @@ export default defineModule({ ], docs: { heading: "Weight trail", - intro: "At the foot of the instruments' column: every weight the cut shows -- the STATED ones and (`remembered`) the remembered ones, \"≈390, as of Feb 2023\" -- placed by the date he was that weight (its `asOf`, else its date), a dot appearing at its event's `t`; ONE line runs through every weight shown, stated and remembered alike, joining neighbours by date once both are said -- so it never passes over a point; of several weights for one day the line takes the one said last and the others stay as marks beside it. A remembered weight is a hollow grey ring with a solid border (a qualified one a size smaller), and a stretch of the line with a remembered end is drawn quieter, grey and thinner; between two stated weights it keeps the accent (a qualified stated one is hollow). The axes FIT what has been said so far (trail-plan.mjs): each new weight outside them reflows the chart over 0.4 s -- the years, the bounds, every dot -- so the time axis advances with the story; a stretch with no statement longer than `gap` is a break in the time axis (a small `//` on the axis foot, each side with its own years; a year inside a stretch a short tick there) and the line across it dotted, so a decade of nothing does not take the width from the dense run after it. A red ring on the latest said. The `mark` line (300) dashed across; with `count` and the mark at 300, `UNDER 300 · SAID n×` counts the measure's `totals.under300` rows as the cut reaches each.", + intro: "At the foot of the instruments' column: every weight the cut shows -- the STATED ones and (`remembered`) the remembered ones, \"≈390, as of Feb 2023\" -- placed by the date he was that weight (its `asOf`, else its date), a dot appearing at its event's `t`; ONE line runs through every weight shown, stated and remembered alike, joining neighbours by date once both are said -- so it never passes over a point; of several weights for one day the line takes the one said last and the others stay as marks beside it. A remembered weight is a hollow grey ring with a solid border (a qualified one a size smaller), and a stretch of the line with a remembered end is drawn quieter, grey and thinner; between two stated weights it keeps the accent (a qualified stated one is hollow). The axes FIT what has been said so far (trail-plan.mjs): each new weight outside them reflows the chart over 0.4 s -- the years, the bounds, every dot -- so the time axis advances with the story; a stretch with no statement longer than `gap` is a break in the time axis (a small `//` on the axis foot, each side with its own years; a year inside a stretch a short tick there) and the line across it dotted, so a decade of nothing does not take the width from the dense run after it. The width is shared half by days and half by the weights each stretch holds (each day a weight is said for owns an equal slot), so a run of weights a few days apart is spread out rather than piled into a few pixels, and an empty year still reads as longer than a week. A red ring on the latest said. The `mark` line (300) dashed across; with `count` and the mark at 300, `UNDER 300 · SAID n×` counts the measure's `totals.under300` rows as the cut reaches each.", rows: [ ["`deck.trail`", "`true` · an object of the knobs below · `false` off · absent: ON when the cut draws a measure (`deck.measure` set), else off", "`umtool look <p> deck.trail=false`"], ["`deck.trail.mark`", "a weight, or `null` · default `300`", "`umtool look <p> deck.trail.mark=300`"], diff --git a/umtool/report-to-video/trail-plan.mjs b/umtool/report-to-video/trail-plan.mjs @@ -28,6 +28,10 @@ // the earlier ones stay as marks beside it, so the line never zigzags up and // down one date. // +// THE WIDTH (12 Nov, rev9-a9 5:30–6:00: nine weights of July–November 2026 piled into the right edge): half of it +// by days, half by the weights each stretch between said days holds (trailLayout, DAY_SHARE), so a dense run is +// spread and an empty year still reads as longer than a week. +// // PURE: the measure slice and a box in, plain data out. import { dayNumber } from "./measure-draw.mjs"; @@ -37,6 +41,8 @@ export const TRAIL_REFLOW = 0.4; /** `gap: "auto"`: a stretch is a break when longer than this many days, or `GAP_MEDIANS` times the median spacing. */ export const GAP_FLOOR_DAYS = 365; export const GAP_MEDIANS = 8; +/** The part of the strip's width shared out by days; the rest goes by the weights each stretch holds (trailLayout). */ +export const DAY_SHARE = 0.5; const r2 = (v) => Math.round(v * 100) / 100; @@ -105,17 +111,37 @@ export function trailLayout(points, box, { thr = Infinity, mark = null } = {}) { c.from = c.first - p; c.to = c.last + p; } + // THE WIDTH BY DAYS AND BY WEIGHTS (12 Nov, rev9-a9: nine weights of July–November 2026 shared 31 px of a 2023–26 + // cluster, under a pixel apart). Each stretch between two neighbouring days a weight is said for (and a cluster's + // padding) gets DAY_SHARE of the width by its days and the rest by the weights it holds -- each said day owning + // an equal slot, half on either side of it -- so a crowded run is spread and an empty year still reads as longer. const widthDays = cl.reduce((s, c) => s + (c.to - c.from), 0) || 1; - const scale = Math.max(0, x1 - x0 - gapPx * Math.max(0, cl.length - 1)) / widthDays; + const avail = Math.max(0, x1 - x0 - gapPx * Math.max(0, cl.length - 1)); + const said = new Set(points.map((p) => p.day)); + const slots = said.size || 1; let at = x0; for (const c of cl) { + const days = [...said].filter((d) => d >= c.first && d <= c.last).sort((a, b) => a - b); + const knots = [c.from, ...days, c.to]; + let x = at; + c.knots = knots.map((d, i) => { + if (i > 0) { + const share = (i > 1 ? 0.5 : 0) + (i < knots.length - 1 ? 0.5 : 0); + x += avail * (DAY_SHARE * (d - knots[i - 1]) / widthDays + (1 - DAY_SHARE) * share / slots); + } + return { d, x }; + }); c.x0 = r2(at); - c.x1 = r2(at + (c.to - c.from) * scale); - at = c.x1 + gapPx; + c.x1 = r2(x); + at = x + gapPx; } const X = (d) => { const c = cl.find((k) => d >= k.from - 1e-9 && d <= k.to + 1e-9) ?? null; - return c ? r2(c.x0 + (d - c.from) * scale) : null; + if (!c) return null; + const i = Math.max(1, c.knots.findIndex((k, j) => j > 0 && d <= k.d + 1e-9)); + const a = c.knots[i - 1]; + const b = c.knots[i] ?? a; + return r2(b.d > a.d ? a.x + ((d - a.d) / (b.d - a.d)) * (b.x - a.x) : a.x); }; const Y = (v) => r2(y1 - ((v - lo) / Math.max(1, hi - lo)) * (y1 - y0)); const gaps = cl.slice(1).map((c, i) => ({ key: `${cl[i].last}_${c.first}`, x: r2((cl[i].x1 + c.x0) / 2) })); diff --git a/umtool/report-to-video/trail-plan.test.mjs b/umtool/report-to-video/trail-plan.test.mjs @@ -185,3 +185,27 @@ test("the line takes one point per day -- the one said last -- and a pair never assert.ok(data.cues.some((c) => c.k === "s1_0" && c.at === 30 && c.to.autoAlpha === 0), "the 390's pair goes when the 400 lands"); assert.match(html, /class="seg" data-k="s4_0"/, "2024 → 2025: stated, the accent"); }); + +test("a crowded run gets room: the width goes by how many weights a stretch holds as well as by its days", () => { + // The rev9-a9 shape (12 Nov, 5:30–6:00 of the cut): 2008, 2013, a 2023–26 run whose last nine weights fall in + // July–November 2026 -- one cluster, so by days alone those nine shared 31 px and stood less than a pixel apart. + const said = [["2008-06-30", "remembered", 368], ["2013-03-09", "stated", 346.7], ["2013-03-21", "stated", 342.9], ["2023-02-24", "remembered", 390], + ["2023-12-31", "remembered", 365.7], ["2024-05-09", "remembered", 335], ["2024-07-01", "remembered", 390], ["2025-02-01", "remembered", 370], + ["2025-04-15", "remembered", 387], ["2025-06-06", "stated", 300], ["2025-08-15", "stated", 351], ["2026-01-09", "stated", 339], ["2026-01-16", "stated", 337], + ["2026-07-19", "remembered", 349], ["2026-07-27", "remembered", 342], ["2026-07-31", "stated", 338], ["2026-08-03", "stated", 335.5], ["2026-08-28", "stated", 320], + ["2026-09-24", "stated", 310.5], ["2026-10-15", "stated", 300], ["2026-10-23", "stated", 291], ["2026-11-07", "stated", 288.5]]; + const pts = trailPoints({ events: said.map(([d, k, v], i) => ev(10 * (i + 1), k, v, d, k === "remembered" ? { asOf: d } : {})) }); + const states = trailStates(pts, BOX, { mark: 300 }); + const last = states.at(-1); + const xs = pts.map((p) => last.pos.get(p.n).x); + // In date order, every weight stands right of the one before, and no two closer than a point's own width. + for (let i = 1; i < xs.length; i += 1) assert.ok(xs[i] - xs[i - 1] >= 8, `${said[i - 1][0]} → ${said[i][0]}: ${(xs[i] - xs[i - 1]).toFixed(2)} px`); + const tail = xs.slice(-9); + assert.ok(tail.at(-1) - tail[0] >= 0.18 * (BOX.x1 - BOX.x0), `the July–November run has room (${(tail.at(-1) - tail[0]).toFixed(1)} px)`); + // Still a time axis: inside the box, the 2023–26 run one cluster, a year's tick between its neighbours' dates. + assert.equal(last.layout.clusters.length, 3); + assert.ok(xs[0] >= BOX.x0 && xs.at(-1) <= BOX.x1); + const y2026 = last.layout.years.find((y) => y.text === "2026"); + assert.ok(y2026 && y2026.x > xs[10] && y2026.x < xs[11], "1 January 2026 between 15 August 2025 and 9 January 2026"); + for (const st of states) for (const c of st.layout.clusters) assert.ok(c.x1 >= c.x0 && c.x0 >= BOX.x0 - 1e-6 && c.x1 <= BOX.x1 + 1e-6, `at ${st.at}`); +}); diff --git a/umtool/report-to-video/vertical-deck.test.mjs b/umtool/report-to-video/vertical-deck.test.mjs @@ -271,7 +271,8 @@ const MAIN = { // Main's was 3512192be69f8b9bc33aec6e7b41a088. Re-pinned on lane/trail-join (12 Nov): one line through every weight // shown by date (the remembered too, quieter), one point per day, the breaks and years at the axis foot -- new by // design; frame-zero's was 39c3694f4e26963277d9b22ebfd0f60b. - trail: "7b108207d91e94b740541aea0f98a98a", + // The trail's page moved on purpose (12 Nov, lane/take-tools: its width by days AND by the weights a stretch holds). + trail: "cb462817cd12d54f5691f1dcf68daeb8", dialFinale: "52866e4d87e15bd55afe8c1a703414a3", geometry: "182959796c281f769766df3d02962904", bare: "7ce1f7a66452adec21575bcdbba900f1",