Archilyzer · Source

archilyzer

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

commit 65c85efb257f50329eba35e97425019893e07086
parent c7c8d06e33617e50173e0138722b8cc65fd95755
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 12 Nov 2026 21:37:18 -0500

umtool take --preview --at/--dur, review 1: a stale schedule is not trusted, an --at past the end refused before building, one window at a time, its own status, the file named by what rendered (S1-S7)

S1: takeScheduleOf trusts the take's preview/render schedule.json only when it is strictly newer than
its take.json (a take edited since may have grown; a timestamp tie is not proof); else the entries'
own lengths, said as estimates (review probe 2: --at 650 on a take grown to 800 s was refused by a
600 s schedule; now it covers b, basis estimate).
S2: previewWindowPlan refuses an --at past the end on estimates too, saying it is an estimate and the
length, before anything builds (probe 3b: --at 5000 now refused, not built).
S3: a second window preview of a take while the first's record (out/window/render.json) is live is
refused, naming its pid, window and start (the record now carries `window`).
S4: fastKindOf says "window" for --preview with --at/--dur; fastRenders reads out/window/render.json
(state, its file, `span`), and take status prints "window <at>-<to>" beside the full preview's line.
S5: the file is named by the window the build laid: build-video's --cut-window done event carries
{at, dur} (clipped at the cut's end); without it, the plan's end clips the name.
S6: --cut-window refuses --clip-preview, --fetch-only, --short, --join-preview, --thumbnail,
--chapters-only.
S7: the help, cli.md (groups.mjs), knobs.md and report-video.md say the window lays no rail.
build-video.mjs: two lines inside this lane's own --cut-window code, nothing moved.
Tests: takePreviewWindow.test.mjs (S1-S6, take status through lib/queue/cli.mjs).

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

Diffstat:
Meditor/CHANGELOG.md | 2+-
Mumtool/docs/cli.md | 2+-
Mumtool/docs/knobs.md | 2+-
Mumtool/docs/report-video.md | 15++++++++++-----
Mumtool/lib/cli/groups.mjs | 2+-
Mumtool/lib/queue/cli.mjs | 9+++++----
Mumtool/lib/report/renderRecord.mjs | 2++
Mumtool/lib/report/takeCli.mjs | 11++++++-----
Mumtool/lib/report/takePreview.mjs | 65++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
Mumtool/lib/report/takePreviewWindow.test.mjs | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Mumtool/report-to-video/build-video.mjs | 5+++--
11 files changed, 163 insertions(+), 35 deletions(-)

diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -109,7 +109,7 @@ - **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>`). The file is `takes/<t>/out/<slug>.preview.<at>-<to>.mp4`, built in `out/window/`; the full preview is never touched. `--preview` without `--at`, and a take's own window, render as before. +- **umtool: 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. diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -75,7 +75,7 @@ Inbox cannot disagree about what is wrong with one. | `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. `--at S --dur S`: cut seconds of the take's own cut (its schedule), the chrome at its state then, into its own `takes/<id>/out/<slug>.preview.<S>-<S+dur>.mp4` (build in `out/window/`), 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> --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** -- 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") | diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -2055,7 +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>-<S+dur>.mp4` (its own file; the full preview untouched). S and dur are **cut seconds of the take's own cut** (its last preview's or render's schedule, else its entries' lengths as estimates; past its end refused); the whole take is built, only the window laid and encoded, its chrome at its state then | — | — | +| 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) | diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -2387,9 +2387,10 @@ matches main's). ``` takes/<t>/out/<slug>.preview.mp4 the preview -takes/<t>/out/<slug>.preview.<S>-<S+dur>.mp4 +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, never written over the full preview; its build in out/window/ + 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) @@ -2401,13 +2402,17 @@ takes/<t>/changes.json the reel's pieces: id, kinds, label, `at`/`e ``` **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`), else by its entries' -own lengths, said as estimates; an S past a measured end is refused. Not the project draft's seconds: a +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. +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 diff --git a/umtool/lib/cli/groups.mjs b/umtool/lib/cli/groups.mjs @@ -591,7 +591,7 @@ 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. `--at S --dur S`: cut seconds of the take's own cut (its schedule), the chrome at its state then, into its own `takes/<id>/out/<slug>.preview.<S>-<S+dur>.mp4` (build in `out/window/`), 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))"], + "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]`", 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/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 @@ -49,11 +49,12 @@ export const TAKE_USAGE = [ " 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. --at S --dur S: CUT", - " SECONDS of the take's own cut (its last preview's or render's schedule; else its entries' own", - " lengths, said as estimates; past its end refused): the whole take built (segments reused by key),", - " only S..S+dur laid and encoded, its chrome (timeline, counters) at its state then, into its OWN", - " file takes/<id>/out/<slug>.preview.<S>-<S+dur>.mp4 (build and record in out/window/); the full", - " preview never touched", + " 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", diff --git a/umtool/lib/report/takePreview.mjs b/umtool/lib/report/takePreview.mjs @@ -144,8 +144,9 @@ export function windowPreviewMp4(takeDir, slug, win) { /** * Which entries of the TAKE's own cut a window of cut seconds covers: timed by `schedule` (the take's last - * measured one) when it names every entry, else by the entries' own lengths (estimates). A window that starts - * at or past the end of a measured cut is refused, naming the unit. Pure. + * 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 @@ -155,8 +156,13 @@ export function windowPreviewMp4(takeDir, slug, win) { export function previewWindowPlan(timeline, win, schedule) { const measured = schedule && schedule.estimated !== true ? schedule : null; const w = windowEntries(timeline, win, measured); - if (w.basis === "schedule" && !(win.at < w.total)) { - throw new Error(`--at ${win.at} is past the end of the take's cut (${Math.round(w.total * 10) / 10} s of cut time, by its schedule): --at and --dur are seconds of the take's cut`); + 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 }; } @@ -543,7 +549,7 @@ async function buildInto(projectDir, { id, label, kind, renderDoc, outDir, from, 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); @@ -624,8 +630,12 @@ 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 that names its entries. */ +/** + * 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"); @@ -633,9 +643,14 @@ async function takeScheduleOf(takeDir) { 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); - return got[0] ?? null; + 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 @@ -658,17 +673,33 @@ async function windowPreview(projectDir, id, win, opts = {}) { const slug = String(c.manifest.slug ?? ""); const sched = await takeScheduleOf(takeDir); const plan = previewWindowPlan(renderDoc.timeline, win, sched?.doc ?? null); - const mp4 = windowPreviewMp4(takeDir, slug, win); + 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 measured schedule yet)") + - `; ${t.width}x${t.height}, ${t.preset}, crf ${t.crf}; the whole cut's segments built or reused, its chrome at its state then; to ${path.relative(takeDir, mp4)}` + + (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)" : ""}`, ); - const outDir = path.join(takeDir, "out", WINDOW_DIR); - const b = await buildInto(projectDir, { id, label: `${spec.label} ${span}`, kind: WINDOW_DIR, renderDoc, outDir, from, xfade: takeXfade(c), opts, cutWindow: win }); + // 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) { @@ -679,7 +710,7 @@ async function windowPreview(projectDir, id, win, opts = {}) { 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, covers: plan.ids, basis: plan.basis }; + return { id, mp4, seconds, renderSeconds: b.renderSeconds, tier: t, window: win, rendered, covers: plan.ids, basis: plan.basis }; } async function checkFrom(projectDir, id, from) { @@ -887,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; } @@ -915,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 @@ -5,10 +5,10 @@ import { test } from "node:test"; import assert from "node:assert/strict"; import { mkdtempSync, rmSync } from "node:fs"; -import { mkdir, readFile, writeFile } from "node:fs/promises"; +import { mkdir, readFile, utimes, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import path from "node:path"; -import { previewTake, previewWindowPlan, windowPreviewMp4 } from "./takePreview.mjs"; +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"; @@ -97,3 +97,82 @@ test("--cut-window: build-video's flag, its span against the cut, and the take r 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/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs @@ -7522,7 +7522,8 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly 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); - EMIT("done", { out, failures: [] }); + // 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: [] }; } @@ -7753,7 +7754,7 @@ export function cutWindowFlag(argv) { 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"]) { + 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 };