commit 8d503bf3364718580a89fbac0a6f10e886adc85c parent c454f74e95c7068dcdd9985929300f6c5929d925 Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st> Date: Thu, 12 Nov 2026 03:06:34 -0500 Merge lane/a9-fixes: the finale hides the remembered-weight callout, a goal's base can go stale (deck.goals.baseMaxDays, look --take), the REFUNDED stamp takes its second line from the ledger (stampNote), quote-check works when out/ is a link onto the media drive, a preview window keeps only the effects whose clips it holds, an entry's chapter is a knob, posts attach reads the archive's captures too and refuses a capture name that is not a plain file name, the trail skips an event with no number Co-Authored-By: Claude <noreply@anthropic.com> Diffstat:
34 files changed, 1030 insertions(+), 80 deletions(-)
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -4,6 +4,15 @@ - **A published archive is a source: connect it once, sweep it, and fetch its cited clips with no local corpus.** A fresh clone pointed at jeralyzer.pages.dev could search it through the MCP and do nothing else: Create had no corpus to offer, and every clip of a channel the editor did not archive was a 404 `Channel "<slug>" not found`. An archive is now connected by its origin — `/sites` → **Connected archives**, or `pnpm ops archives --json '{"connect":"https://jeralyzer.pages.dev"}'` (`"dryRun": true` reads it and writes nothing; `pnpm ops get archives` lists them) — and kept in `settings.remoteArchives`. `TRANSCRIPT_SITE_URL`'s archive is offered without being connected, so a clone set up as AGENTS.md says starts with one. Create offers each connected archive as a sweep's source, preselected when this machine has no corpus of its own, the MCP's `list_sources` lists them and `generate` passes the choice. A sweep over an archive cites that archive's origin, whatever `generation.citationOrigin` says, and its revisions, drafts and refreshes inherit it. A clip window cited from one registers its channel **remote-only** on first need (`fetch-windows` and `fetch-window` take `"archive"`, and the MCP's `fetch_clip` names it): a `config.json` and nothing else, shown as "remote only" in the channel list, skipped by every sync, lane, scan and site build, and left out of the site form's channel picker. On a whole-recording platform (Rumble) a window means downloading the whole recording, which nobody planned for a channel that is not archived here: it is refused with the recording's length and estimated size until the ask carries `"allowWholeRecording": true`. The archive's documents are cached on disk by its build (512 MB by default), read one at a time and paced. `corpus.json` is spec 6 (the export's changelog): each channel names its platform and its page there; an older archive's platform is read from a record's `webpageUrl`. - **A connected archive is untrusted input.** umtool can connect one and is open on the LAN, and everything an archive serves is someone else's JSON. An archive on this machine or its network — loopback, private, link-local and CGNAT addresses in any spelling (decimal, hex, IPv4 carried inside IPv6), a `.local`/`.internal`/`.lan` name, or a name that resolves to one — is refused at connect, before anything is asked of it, unless the editor runs with `ARCHILYZER_ALLOW_PRIVATE_ARCHIVES=1` or the origin is `TRANSCRIPT_SITE_URL`'s or already in `settings.json`; the check is made once, at connect. Its documents are read on its own origin only: a redirect elsewhere is refused unfollowed, a manifest its `corpus.json` names on another origin is not followed, and no document past 32 MB is read or kept. A record's page URL is fetched only when its host is its channel's video platform's own domain or a subdomain (`evilyoutube.com` and `youtube.com.evil.example` are not YouTube); a URL carrying a backslash, whitespace or a control character is refused unparsed, because Node and yt-dlp's Python read its host differently; and what reaches yt-dlp is the URL the check parsed, never the archive's own string. A remote-only channel whose archive was removed from settings is refused before its record is read. - **umtool: the Source chip connects an archive, and an article swept over one is cut from it.** The Source chip takes an archive's address, reads it and connects it through the editor; a connected archive is offered as the source of **Article from a question** and of a new article, first when this machine has no corpus. The chain of an article swept over an archive asks the editor for its windows with the archive named and each record's page URL, so the cited channels are registered remote-only and fetched; a manifest with no sweep naming an origin takes the archive as its QR origin. A Rumble window fails the step with every recording's size, nothing fetched, until **Fetch the whole recordings** (`umtool chain <article> <n> --allow-whole-recording`). `--stop-before-render` ends Draft everything before the voices, and its new `cut-windows` step fetches the drafted cut's windows, asking the editor only for those not on disk. The cue walk, the link check and a source's build identity read an archive under the same rules as the editor (its own origin, 32 MB), and a chain whose archive is no longer connected stops and says to connect it again. +- **umtool e2e: the Inbox spec waits for the list after a Park, Mute or Undo.** Three runs failed where the list had not changed 5 seconds after Reactivate, Unmute or Undo. In each the write had been saved and the page's refresh had been asked for; the server was slow for those seconds (a neighbouring suite was building) and the check gave up first. The first look at the list after such a write now waits up to 20 seconds. Nothing in the app changed: the lifecycle and the mutes are read from disk on every render, and the rail's count is memoised for 10 seconds by design and cleared by those writes. +- **umtool: the trail no longer draws a 0 lb point for a row with no number.** A measure event whose value was empty was read as 0 and plotted at the foot of the trail. Such a row is now left off; a real 0 is still drawn. +- **umtool: `posts attach` finds captures in the archive too.** On a project with its own channels tree (a `.shadow-channels`), `umtool posts attach` and `posts repeats` looked for a post's capture only there, so media captured into the real archive's `channels/<slug>/posts-media/<id>/` was not seen. They now look in the project's tree first and then the archive's, as the other readers do. The archive is only read: the files are copied into the project as before. `--dry-run` prints which tree each file would come from. A capture whose file name is not a plain name (`../../x`, `a/b`, `..`) is refused before any file is read or any folder made. +- **umtool: an entry's chapter name is set from a terminal.** An entry's `chapter` names it in the chapter list (the YouTube text, `umtool export --format chapters`) in place of its on-screen title, and it could only be written by editing the manifest by hand. `umtool set <p> <entry> chapter='The weigh-in'` writes it for any entry (a clip, a post item, a still), `chapter=` clears it, and `--take <t>` writes it on that take alone. One line, at most 100 characters. +- **umtool: a windowed take preview no longer fails on an effect that names a clip outside the window.** `umtool take <p> --id <t> --preview --at S --dur S` on a cut with `render.chrome.fx.glitch.clips` or `fx.thenNow.pairs` was refused with "names k06, which is not a clip of the cut". The window's manifest now keeps only the named clips inside it (a glitch's only when a clip stands right before it in the window, a then/now pair only with both ends), as it already did for markers and claim checks; an effect left naming no clip is off in that window. A glitch in another mode (`on: "year"`) does not read its list and is left as it is. The same for `fx.kineticQuote.clips` and `fx.redact.clips`. +- **umtool: `quote-check` works on a project whose `out/` is on the media drive.** The check asked the editor to write its word files under `<project>/out/quote-check/`; when `out/` is a link onto a media drive, that is inside the corpus and the editor refuses to write there, so every clip failed. The work files now go to `<project>/.quote-check/`, and if the editor refuses that too (the project itself is inside the corpus) to `<reports>/.umtool/quote-check/<project>/`, then `~/.cache/umtool/quote-check/<project>/`. The rows are still the project's `quote-check.json`; the editor's refusal is unchanged. A directory the editor refuses is removed again if the check made it, so no empty `.quote-check/` is left on the media drive. +- **umtool: the words under the promise clock's REFUNDED stamp can be the record's own.** The stamp always read "by <date> · no video" under REFUNDED or WITHDRAWN, whatever the outcome row said. A `promise_outcome` row may now carry `stampNote` (`umtool ledger <p> set <row> --stampNote "by her account · no receipt"`, `--stampNote null` to take it off): it is the stamp's second line, and the one-line strip over a post's card shows its first clause. Without one the words are as before. `umtool lint` warns when a note is longer than the stamp's line holds (26 characters). +- **umtool: a loss goal no longer takes its base from a weight said years before.** A goal such as "lose 100" is shown against the latest weight he had given by then, however old: on the weight video that put "(FROM 368)" on a goal set eight years after he said 368. `deck.goals.baseMaxDays` (unset: as before) keeps a base only when its weight was said at most that many days before the goal; an older one is no base, so the note carries no "(FROM …)" and the dial draws no goal weight or tick from it. `umtool look <p> deck.goals.baseMaxDays=365`, and `umtool look` now takes `--take <t>` for the deck's keys, which sets them on that take alone. +- **umtool: the dial's finale no longer shows the callout's labels over its hub.** With `deck.dial.rememberedAs: "callout"` the finale's dial drew every remembered weight's label box and the ghost needle and never hid them, so the boxes sat on the hub for the whole finale (take rev9-a9). They are hidden there now; the rim's marker and flag for the last remembered weight stay. - **umtool: record, filter and listen before anything is kept.** On the record page a recording became a take the moment its last part was in, and hearing it in the character's voice meant importing it on the Voices page and waiting for three takes (operator, 11 Nov: "run the filter and preview it seamlessly in the record UI"). With **Filter before keeping** (on by itself for a post whose character has a stock voice to convert to) the post now waits. **Filter** (`f`) runs the character's recorded preset as one job: clean, cut, convert. Its result is a preview in `narration/.record-preview/<postId>.<label>/`, not a take. The page shows the three stages and the time it has run, and a wait at the editor's queue or the machine's heavy slot reads "waiting for memory … the gate working, not an error". **▶ Raw** and **▶ Filtered** play at one loudness. **Keep** (`Enter`) makes the recorded, cleaned and converted takes from the preview's files, converts nothing again, picks the last and opens the next post not recorded; **Again** (`Backspace` or `r`) drops the preview and records the part again. Each part's waveform carries two **cut marks** at the auto trim's answer; drag one, or press the arrow keys on it, to cut a keyboard click off the start or the end. **Pitch** and **semitones** (a Seed-VC convert) default to the preset's and re-run the convert alone; **Save to character** writes them back, and a post read as the narrator or as nobody offers **Keep in this video only**. Above the record button: the character, its direction line and **▶ <voice> reads it** (its synthetic preset's voice), which plays the read kept from before when there is one and asks the editor only when pressed. Cancel stops the editor's job too. Opened over http from the LAN the page says the microphone is off (a browser opens it only on localhost or https); **Use a sound file…** takes a recording made elsewhere, and Filter, the preview and Keep work there. From a terminal: `umtool posts narrate <p> <item> --recording <file> --preview [--out <file>] [--trim-span 0.4-3.1]` prints the paths and makes no take, `--keep-preview` keeps it, `--discard-preview` drops it. A "start on speech" trigger was not built: it would lose the start of the first word, and the auto trim already cuts the silence before it. ([knobs.md](../umtool/docs/knobs.md#record-filter-preview-on-the-record-page)) - **umtool: a convert made from a take uses its character's voice, not the editor's default.** On 11 Nov `umtool posts narrate <p> <item> --derive <n> --op convert` with no flags made a take in the wrong voice: it asked the editor with nothing, and the editor used its own default target. A convert now takes its engine, stock voice, pitch and semitones from the recorded preset of the character the read is made as (`--as`, else the item's own, this video's for the author, the cast's, the narrator); a flag overrides its own key. With no character and no `--voice` it is refused in one sentence. The post bench's **run AI on take** does the same on the server. - **Lookouts: a saved set of channels and days, and a dry run that lists what it would read.** A lookout (lane/lookout) will read its channels' recent transcripts and answer with video ideas; this first part has no model. `settings.lookouts` holds the lookouts (off and empty by default; nothing in code names a channel), and `pnpm ops lookout-run --json '{"id":"…","dryRun":true}'` lists the week it would read: every video by its AIR date in the lookout's time zone (a stream that starts at 8:20 pm in New York is 3 Nov, not the 4 Nov of its UTC upload date), a recording uploaded twice read once with the other upload named beside it, a stream's cut-downs credited to the stream, the longest 40 read and every one left out listed with why. Over the pilot's week, read-only, it found all 6 of the pilot's duplicate uploads and all 18 of its stream cut-downs. `pnpm ops get lookouts` is the readout. Runs and verdicts will live in `transcripts/.lookouts/`, never published. diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -27,7 +27,7 @@ Inbox cannot disagree about what is wrong with one. | `cast project <project> add <id> [--name "…"] [--voice <engine:voice>] [--handles a,b] [--anonymous [--shown "…"]] [the preset flags]` · `set <id> … [--no-voice] [--no-anonymous]` · `rm <id>` · `undo` · `pool <id>` · `keep <character\|@handle> [--anonymous]` `[--json]` | **THIS VIDEO's OWN CHARACTERS** (`<project>/narration/characters.json`, [knobs.md](knobs.md#this-videos-own-characters-and-an-items-own)): the cast's shape and the cast's writer (a token, an undo point a write, atomic, a broken file never overwritten), for people who must not enter the pool. `--anonymous`: it goes by a **shown name** (`--shown`; default the next of `Anon 1`, `Anon 2` …) on the Voices page, in `cast project` and in a recording's note, and never enters the pool; **the on-screen card is not anonymised yet** (it still shows the post's author). `--voice` is optional here: a character with none leaves the voice to the layers under it. `narration/voices.json` keeps working under it (a handle in it reads as a character with only a synthetic voice) and is never rewritten by these. `pool <id>` (**Add to the pool**) moves one into the cast -- an anonymous one, or an id the cast has, is refused; `keep` (**Keep in this video only**) copies a cast character here (its presets changed for this video alone), or gives an author with no character one, in the voice they read in now. A refusal: **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; `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> [--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)) | | `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)) | @@ -46,9 +46,9 @@ Inbox cannot disagree about what is wrong with one. | `review-pass <project> [ls] [--json]` · `review-pass <project> mark <block> keep\|fix\|clear [--note T]` | the workspace's **review pass** (`?mode=review`): every block but the intro and a clip rejected for a cut reason, its answer and the block the pass resumes on; a Fix ("needs work", saying what) is a mark in `<project>/review-pass.json` on any block, a clip too — never a clip's verdict (`incorrect` is the bench's fact-error ruling, never written or overwritten here); a clip's Keep is its walk verdict (`window --verdict confirmed`), a post's or a card's a mark — `mark` writes one (a Fix needs `--note`; a clip takes `fix` and `clear`) ([knobs.md](knobs.md#the-review-pass)) | | `review-pass <project> verdict like\|maybe\|no\|clear [--note T] [--json]` | the pass's **verdict on the draft**, one locked call: a draft that differs from its parent version only by what the walk and the review pass write (verdict, correction, reason, reject note, walk note, ★) judges the PARENT and saves nothing; otherwise the draft is saved as the next version and that is judged (`takes/verdicts.json`) | | `present <project> [--take <take> \| --cut] [--json] [--public] [--open] [--url <origin>]` | **present mode**: the cut as slides, navigated like a deck (`/projects/<p>/present`) — prints the address and every slide (its kind, id — a post's `<channel>/<id>`, a clip's id, `section-<n>`, `day-<YYYY-MM-DD>` — date, words and censor counts); `--json` the payload (each post's card as Play draws it and its censor data by kind, each clip's spans, the dividers); `--public` the payload a public page would carry (censored, no reveal data); `--open` opens it; `<address>#<slide id>` opens a slide ([knobs.md](knobs.md#present-mode-the-cut-as-slides-navigated-like-a-deck)) | -| `set <project> <clip> key=value …` | a clip's **knobs**: `claim.at` `claim.hold` `claim.stamp` `claim.count` `claim.label` (the first mark's, or `--mark <id>`'s), its **marks** `mark.add=<verdict>[@<sec>]` `mark.remove=<id>` `mark.verdict=<verdict>` `marks=<json>`, `audio.offset` `audio.gain` `audio.fadeIn` `audio.fadeOut`, its picture's **blur** `blur.on=true` `blur.caption=…` `blur.strength` `blur.from` `blur.to` (`blur.on=` clears it; [knobs.md](knobs.md#a-clips-picture-blurred)), its **effects** `fx.zoom=<json>` `fx.receipts=<json>` `fx.punch=…` `fx.quote` `fx.punchIn=<json>` `fx.speakers=<json>` (`fx=<json>` all of them, `fx=` clears them; a shot is a file in the project; [knobs.md](knobs.md#effects)); `key=` clears one ([knobs.md](knobs.md#marks)) | +| `set <project> <clip> key=value …` | a clip's **knobs**: `claim.at` `claim.hold` `claim.stamp` `claim.count` `claim.label` (the first mark's, or `--mark <id>`'s), its **marks** `mark.add=<verdict>[@<sec>]` `mark.remove=<id>` `mark.verdict=<verdict>` `marks=<json>`, `audio.offset` `audio.gain` `audio.fadeIn` `audio.fadeOut`, its picture's **blur** `blur.on=true` `blur.caption=…` `blur.strength` `blur.from` `blur.to` (`blur.on=` clears it; [knobs.md](knobs.md#a-clips-picture-blurred)), its **effects** `fx.zoom=<json>` `fx.receipts=<json>` `fx.punch=…` `fx.quote` `fx.punchIn=<json>` `fx.speakers=<json>` (`fx=<json>` all of them, `fx=` clears them; a shot is a file in the project; [knobs.md](knobs.md#effects)); on ANY entry (a post item, a still, a clip) `hideModules=diet,streak`, `shelfNote='…'` and `chapter='…'` (its name in the chapter list, one line of at most 100 characters; `chapter=` none); `--take <t>` writes the entry knobs into that take's patch; `key=` clears one ([knobs.md](knobs.md#marks)) | | `intro <project> [key=value …] [--off] [--json]` · `intro <project> --take <take> --off\|--on` | **the intro** the cut opens on (`render.intro`): with no key, prints it as written, what the cut opens with (a `title-card`'s words resolved) and each version's on/off; `key=value` writes it through the look writer (`style` `seconds` 3.5–8 `mark` `ground` `sound` (`false` silent) `site` `title` `lines` (`a\|b`, ≤ 3) and the brand's keys; `key=` clears one; a new intro starts as `boot-dark`); `--off` takes it off the cut; `--take <t> --off` that version opens on no intro (its patch's `render.intro: null`), `--on` on the cut's again. **Exit 1** on a value the build refuses ([knobs.md](knobs.md#the-intro-played-and-edited)) | -| `look <project> key=value … [--unset render.<key>]…` | the cut's **knobs**: `factcheck.stamp.*`, `factcheck.verdicts.<V>.stampLabel\|label\|color`, `deck.markers=<json>`, `deck.markerLayout`, `variants=<json>`, and the look's keys — `mode=basic\|deck` (the footage alone, [knobs.md](knobs.md#basic-output-the-footage-alone)) and `basic=<json>` (its fades) among them ([knobs.md](knobs.md)) **The deck on, legacy keys off** (`updateRenderKeys`, one write, an undo point `revisions/…auto-render-keys…` first): `chrome.layout=deck` turns the deck on (render.chrome created when the cut has none: engine hyperframes, an empty deck), `--unset render.<key>` (repeatable) drops a legacy render key -- only `rail` `chromeEngine` `railEngine` `chromeRegions` `claimSchedule` `wordmark` `title` `finale` `cut`; the deck beside the old rail is refused in the build's words unless the same command drops it; deck.* keys in the same command land after the chrome exists. Another key named: **exit 2** | +| `look <project> key=value … [--unset render.<key>]… [--take <t>]` | the cut's **knobs** (`--take <t>`: the `deck.*` keys given are set on that take -- its patch, an undo point of its own, the project's manifest untouched; the other knobs are the project's): `factcheck.stamp.*`, `factcheck.verdicts.<V>.stampLabel\|label\|color`, `deck.markers=<json>`, `deck.markerLayout`, `variants=<json>`, and the look's keys — `mode=basic\|deck` (the footage alone, [knobs.md](knobs.md#basic-output-the-footage-alone)) and `basic=<json>` (its fades) among them ([knobs.md](knobs.md)) **The deck on, legacy keys off** (`updateRenderKeys`, one write, an undo point `revisions/…auto-render-keys…` first): `chrome.layout=deck` turns the deck on (render.chrome created when the cut has none: engine hyperframes, an empty deck), `--unset render.<key>` (repeatable) drops a legacy render key -- only `rail` `chromeEngine` `railEngine` `chromeRegions` `claimSchedule` `wordmark` `title` `finale` `cut`; the deck beside the old rail is refused in the build's words unless the same command drops it; deck.* keys in the same command land after the chrome exists. Another key named: **exit 2** | | `variants <project> [--take <t>] [--list] [--json]` | **Make variants**: the encode ladder of the build (or of a take's); `--list` what was made and the build's sync report, each clip's lag (past a frame flagged) ([knobs.md](knobs.md)) | | `corrections <project>` | what the report got wrong (the clip bench's sixth field) and the walk's coverage, as markdown for the next pass | | `build <project> [--preset preview\|fast\|final] [--only ID]` | **prints** the chain | @@ -91,7 +91,7 @@ Inbox cannot disagree about what is wrong with one. | `trailer <project> --take <t> (--beats FILE \| --beats-json JSON) [--intro] [--finale S] [--xfade 0.3] [--no-snap] [--out NAME] [--dry-run] [--json]` | a **trailer cut from the take's finished master**: spans of the master's own frames (the deck shows the whole timeline), clip beats in source seconds mapped by the take's build records, each clip beat's end moved forward into the next pause (through its sentence when one ends within 1 s) and its start back into the one before, so the crossfade lands in quiet, each move said (`--no-snap`: the edges as written), crossfaded, the take's encode, in the heavy slot; writes `takes/<t>/out/<slug>.trailer.mp4` and `.trailer.json`; **exit 1** on a refusal ([report-video.md](report-video.md#trailer-from-the-master)) · `--reel <name> [--take <t>]`: a **beat reel** -- its own beats file (`promo/<name>-beats.json`), crossfade, intro (one rendered for the reel when the master has none, or the reel's own) and outro card (the title, the call to action, an image, the site's name; faded in from the last beat, held to the end), written to `<slug>.<name>.mp4`; no `--take`: its pinned take, else the one it was last cut from, else the latest finished master ([report-video.md](report-video.md#beat-reels)) | | `trailer-beats <project> [ls] [--json]` · `add <clip> [<from>-<to>] [--at N] [--label L]` · `add-raw <at> <dur>` · `set <n> <from>-<to>` · `remove <n>` · `move <n> --to <m>` · `order` · `limit <s\|m:ss\|x\|instagram\|shorts\|tiktok>` · `xfade <s>` · `intro on\|off\|'<render.intro JSON>'` · `outro on\|off\|none\|'{title,text,image,seconds}'` · `candidates [--add]` · `verdict <n> confirmed\|note\|clear` · `title <text>\|none` · `take <t>\|none` · `undo` · `reels [--json]` · `new-reel <name> [--from <reel>] [--title T]` · `gap <n> add <from>-<to>\|remove <s>\|clear` · `status [--take <t>] [--json]` · `anchor [<n>…] --take <t>` · `clamp <n>` · `repoint <n> <clip>` · `history [--json]` · `--take <t>` on an edit · `--reel <name>` on any | **the trailer's beats** (`promo/trailer-beats.json`, the Trailer page's file, what `trailer --beats` reads) or another **beat reel's** (`--reel`: `promo/<name>-beats.json`): each beat's length, the running length against the platform limit (X 2:20 by default), beats outside their clip's window, the cut's order, the walk's ★ clips; the reel's own intro and its outro card (`ls`: `· outro 3.5 s`, counted in the length); every write an undo point and a history entry; a beat's gaps (two moments of one clip as one beat of jump cuts); each beat read against the take now -- what it was cut against, what changed (`status`), and the fixes ([knobs.md](knobs.md#the-trailers-beats), [reels track their source](knobs.md#reels-track-their-source)) | | `tighten <project> [--json] [--all] [--no-measure]` · `tighten <project> --apply <clip>[,<clip>…]` | the Cut tab's **Propose tight windows**: each clip to its sentence (the sentences its cut touches, else the whole ones inside its window) and each edge into its pause (the build's measured silences and the gaps between the recording's timed words, ≤ 1 s, inside the cached window) — before → after with the seconds, the clips that would change (`--all`: every clip); prints only. `--apply` writes the named rows through the window writer (the token, the cite that follows the edge); a lock is kept (it is against `resolve-windows`, not a person) ([knobs.md](knobs.md#tighten-to-the-sentence-snap-to-a-pause)) | -| `ledger <project> [ls] [--scope S] [--population P] [--json]` · `ledger <project> add <id> --date D --scope S --population P [--value V] --scopeBasis "…" [--<key> V …] [--row '{…}']` · `ledger <project> set <id> --<key> V … [--unset k,k]` · `ledger <project> rm <id>` | a **measure ledger's rows** (`ledgerSchema.kind "measure"`), the only writer of them: each row is checked against the schema -- a track, a form (and the promise forms `promise` / `promise_check`), a number in its unit or a declared regime with an event, the six adjudication fields (a new row defaults `scopeConfidence` read, `valueKind` uttered, `flags` []; `--scopeBasis` is never defaulted), the declared fields, and the instruments' own keys: `run` (a loss claim's run), `retro` (a loss told in the past with no `asOf`: off the odometer), `promise`, `kept`, `due`, `speaker` (another party's key: her rows move none of his numbers), `paidOn`, `outcome` (a `promise_outcome`'s: kept, refunded, withdrawn); the promise forms are `promise`, `promise_check`, `promise_claim`, `promise_outcome`. `rm` refuses a row an entry pins or another row names ([knobs.md](knobs.md#the-measure-slice-the-weight-instruments)) | +| `ledger <project> [ls] [--scope S] [--population P] [--json]` · `ledger <project> add <id> --date D --scope S --population P [--value V] --scopeBasis "…" [--<key> V …] [--row '{…}']` · `ledger <project> set <id> --<key> V … [--unset k,k]` · `ledger <project> rm <id>` | a **measure ledger's rows** (`ledgerSchema.kind "measure"`), the only writer of them: each row is checked against the schema -- a track, a form (and the promise forms `promise` / `promise_check`), a number in its unit or a declared regime with an event, the six adjudication fields (a new row defaults `scopeConfidence` read, `valueKind` uttered, `flags` []; `--scopeBasis` is never defaulted), the declared fields, and the instruments' own keys: `run` (a loss claim's run), `retro` (a loss told in the past with no `asOf`: off the odometer), `promise`, `kept`, `due`, `speaker` (another party's key: her rows move none of his numbers), `paidOn`, `outcome` (a `promise_outcome`'s: kept, refunded, withdrawn), `stampNote` (a `promise_outcome`'s: the words under its stamp on the promise clock in place of "by <date> · no video" -- `ledger <p> set <row> --stampNote "…"`, `--stampNote null` for the clock's own words again; one line, the strip over a post's card shows its first clause, and `umtool lint` warns past 26 characters); the promise forms are `promise`, `promise_check`, `promise_claim`, `promise_outcome`. `rm` refuses a row an entry pins or another row names ([knobs.md](knobs.md#the-measure-slice-the-weight-instruments)) | | `measure <project> [--take <t>] [--scopes a,b] [--scale MIN-MAX] [--as-of YYYY-MM-DD] [--json]` | the **measure slice** the instruments draw from (`render.chrome.deck.measure`; the flags override it): each row in scope the cut shows at the cut second its figure is said, the hidden rows, and the totals -- the odometer's runs, NET, the goals, the diets, the promises. The take's built `schedule.json` with `--take`, else an estimate; `--json` prints the slice. Reads only ([knobs.md](knobs.md#the-measure-slice-the-weight-instruments)) | | `rulings <project> [--json]` · `rulings <project> import [--dry-run] [--json]` · `rulings <project> set <clip\|key> keep\|cut\|not-him\|read-aloud [--reason R] [--match M]` · `rulings <project> clear <clip\|key>` | a montage's **clip rulings** (`montage-rulings.json`, the clip deck's): each clip and its ruling and the next render's kept clips; the earlier rulings in the seed's `edits.json`, once; one ruling set or cleared. A render leaves out every clip ruled cut, not-him or read-aloud ([report-video.md](report-video.md#ruling-the-clips)) | | `fetch <project> --body` · `fetch <project> --dry-run [--json]` · `fetch <project> [--wait] [--json]` · `fetch <project> --status [--json]` · `… [--reason R]` · `… --refetch <clipId>[,…]` · `… --refetch-video <slug>/<id>` · `… --take <take>` | **Fetch windows** (the Cut tab's and the clip deck's button): every clip's window asked of the editor as ONE fetch-windows batch — `--body` prints the body and asks nobody; `--dry-run` the editor's plan (groups per platform, cached, in flight, unresolved); no flag starts it (one paced job per platform queue), `--wait` follows the jobs to their end and names each window a job failed; `--status` follows the last run's jobs once. Clips the montage rulings leave out are not asked for. `--refetch <clipId>[,<clipId>…]` evicts the cached windows that OVERLAP those clips' fetch spans first (the editor's `evict-clips` `{slug, id, covering}`, one job per video, waited for), then fetches as usual — for windows known bad (cut from a corrupt saved video); `--refetch-video <slug>/<id>` does it for every window the project asks of that video; with `--dry-run` the eviction is a dry run too and names what it would remove. `--take <take>` asks for a TAKE's clips instead — its manifest as its walk reads it (the project's now with the take's patches; a draft's too, nothing rendered), so a clip only the take has is fetched; the run is recorded with `take`, and `--status --take` follows the take's last run (the cut's never reads a take's). Every run is recorded in `<project>/fetch-runs.json` (a refetch's evictions under `refetch`). Needs WORKER_TOKEN (else the editor's env files) and the editor at ARCHILYZER_EDITOR_URL. **Exit 1** when a job failed or the editor refused ([report-video.md](report-video.md#fetching-the-windows-and-stand-ins)) | @@ -147,7 +147,7 @@ Inbox cannot disagree about what is wrong with one. | `posts context <project> [--dry-run] [--json]` | every **post item's context from its capture** (`postContext.mjs`): the post it quotes and the post it answers, as its page showed them (`capture.json`'s `context`, read by the editor's `capture-posts` -- `"contextOnly": true` reads it alone), filled where the archive row lacks them -- `quoted` where the entry has none (or a named one with no words, the same post), `parents` where it has none (a thread shot stays on the entry; the card draws the parents). An x.com/twitter.com **status link** in its words (or its row's links) is a quote: the post it names, from any channel's archive, fills `quoted` (`via: "link"`) when it has none; the row's `threadId` is snapshotted as the item's `conversation` (the thread walk reads it). What the archive gave is never replaced. ONE write for every entry (`setPostItemsContext`: one undo point, refused whole in the build's words); a re-run with nothing new writes nothing. A post whose capture read no context is listed with the call that reads it (`pnpm ops capture-posts --json '{"slug":…,"ids":[…],"contextOnly":true}' --wait`). The card's blur of other authors is unchanged ([report-video.md](report-video.md#post-items-a-post-as-an-entry-of-the-cut)) | | `posts picture-reply <project> [on=on\|off] [image=<s>] [min=<s>] [max=<s>] [maxSound=<s>] [--in-take <take>] [--json]` | the cut's **PICTURE-ONLY RULE** ([knobs.md](knobs.md#picture-only-posts-a-reply-that-is-its-picture)): `render.posts.pictureReply` (`updatePostPictureReplyRender`, one undo point) -- `on` the rule at all; a beat's length: an image `image` s (2), a GIF's or a silent video's own length clamped to `min`–`max` (1.5–4 s), a video with its sound its whole length up to `maxSound` (8 s). `k=` the default again; none: the rule as it stands. `--in-take` writes it into a take's patch. Refused in the build's words (**exit 1**) | | `posts repeats <project> [--match id\|file\|audio] [--json]` | the **combo counter**'s repeats ([report-video.md](report-video.md#the-combo-counter)): every attachment the cut's post items play more than once -- the same X media id (the capture's url), else the same file (the capture's sha256 when its bytes agree, else hashed; cached by path, size and mtime), else (`--match audio`) the same sound (fpcalc, else a coarse ffmpeg hash) -- its posts in the cut's ORDER with their dates, the tier that matched and the badge each draws (`×2` from the second use, `(×n)` counted but not drawn); a post whose CAPTURE holds the same file but whose entry carries no attachment is listed too, `NOT ATTACHED`, with the `posts attach` that brings it in. Reads only | -| `posts attach <project> [<item> … \| --all] [--dry-run] [--json]` | a post item with **no attachment whose capture holds one** (captured after it went in -- `posts repeats` marks them `NOT ATTACHED`): the capture's media (its own channel's `posts-media/<postId>/`, else any channel the cut's posts come from) copied into the project's `posts-media/<slug>/<postId>/` and measured, set as the entry's `media` as `posts reel` would have made it -- nothing else of the entry changes (its paraphrases, narration, knobs kept); an item that has an attachment is never touched. ONE write (one undo point: `timeline <p> undo`), refused whole in the build's words | +| `posts attach <project> [<item> … \| --all] [--dry-run] [--json]` | a post item with **no attachment whose capture holds one** (captured after it went in -- `posts repeats` marks them `NOT ATTACHED`): the capture's media (its own channel's `posts-media/<postId>/`, else any channel the cut's posts come from -- looked for in the project's channels tree first, a `.shadow-channels` or `provenance.channelsDir`, then the archive's `CHANNELS_DIR` behind it, read only; `--dry-run` says which tree each file comes from) copied into the project's `posts-media/<slug>/<postId>/` and measured, set as the entry's `media` as `posts reel` would have made it -- nothing else of the entry changes (its paraphrases, narration, knobs kept); an item that has an attachment is never touched. ONE write (one undo point: `timeline <p> undo`), refused whole in the build's words | | `posts combo <project> [on=on\|off] [label=L] [position=top-right\|top-left\|bottom-right\|bottom-left\|center] [color=#rrggbb] [scale=0.4-2.5] [sfx=off\|hit\|coin] [minCount=2-20] [match=id\|file\|audio] [--json]` · `posts combo <project> <item> off\|on\|auto\|label=…\|position=…\|color=…\|scale=…\|sfx=… [--json]` | the **combo badge's knobs** ([knobs.md](knobs.md#the-combo-counter)): the cut's (`render.posts.combo`, `updatePostComboRender`; no knobs prints them; `k=` the default again) or one post item's (`combo`, `updatePostCombo`): `off` draws no badge on it -- it still counts -- `on`/`auto` the cut's again. Refused in the build's words (**exit 1**) | | `candidates <project> [ls] [--all] [--json]` · `candidates <project> import <sweep.md> [--dry-run] [--json]` · `candidates <project> add <json\|@file> [--json]` | the **candidates inbox** (`<project>/candidates.json`): proposals only — `import` reads a sweep's bullets (`- [verdict] [title @ time](link) (date) "quote" — why`, under their headings; a Top N section marks what it restates; a bullet with no verdict or link is skipped and said), `add` an agent's (`{channel?, video, t, quote?, why?, verdict?, score?, section?}` or `{link, …}`); the same moment again changes nothing it holds. Insert and Not this are the Cut tab's Candidates panel's ([knobs.md](knobs.md#the-candidates-inbox-proposed-clips-picked-by-a-press)) | | `ingredient <channel>/<video> [--window <from>-<to>] [--used-in] [--json]` | **one recording's life cycle**, the twin of `/ingredients/<channel>/<video>` ([knobs.md](knobs.md#an-ingredients-life-cycle-the-rail)): nine stages — found, downloaded, transcribed, clock, windows, used in, checked, rendered, published — each **✓**, a count, **!** or **—**, and its line, then every project clip that cuts from it (the draft and each saved version, from the usage index `<REPORTS_ROOT>/.umtool/usage-index.json`). A Rumble recording answers to its folder slug or its embed id; both are printed. `--window`: one clip window, the stages after it narrowed to the clips it plays. `--used-in`: the clips alone. `--json`: the page's object. Read-only over the corpus. **Exit 0 · 1 failed · 2 usage** | diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -37,6 +37,7 @@ that generates it ([notes.md](notes.md)). | `chat` — `on`: the clip's live chat (its video's `live_chat.cues.json`, for the clip's source span, timed through its gaps) in a column beside the footage; `off` or `chat=` (the default): none. A video with no chat draws nothing and the build log says so ([Live chat](#live-chat)) | — | `umtool set <p> <clip> chat=on` (`chat=` clears it) | — | | `hideModules` — `["diet","streak",…]`: the measure extras (`goals` `peak` `promise` `diet` `streak`) hidden over THIS entry's span, each with its own fade, whatever it would otherwise do there -- for text in the footage no dodge can know of (a DM screenshot's refund email under the diet badge). Any entry, a post item too; an id no entry can hide is refused | — | `umtool set <p> <entry> hideModules=diet,streak` (`hideModules=` clears it; `--take <t>` writes the take's patch, the project's manifest untouched) | — | | `shelfNote` — one line of at most 80 characters on the shelf (`render.chrome.deck.shelf`, its `note` slot) over THIS entry's span, coming and going with it -- a short fact beside the footage for any video, with or without a measure slice ([Shelf](#shelf)). Any entry, a post item too | — | `umtool set <p> <entry> shelfNote='Weighed in on camera'` (`shelfNote=` clears it; `--take <t>` writes the take's patch) | — | +| `chapter` — the entry's name in the chapter list (`out/…chapters`, `youtube.txt`, `umtool export --format chapters`): one line of at most 100 characters. An authored `chapter` wins over the entry's on-screen title (under the deck) and the line derived from its record; without one the list is as before. Any entry, a post item too | — | `umtool set <p> <entry> chapter='The weigh-in'` (`chapter=` clears it; `--take <t>` writes the take's patch, the project's manifest untouched) | — | | `fx.zoom` — `{shot, focus, at?, hold?}`: a screenshot (a file in the project; a bare name under its `shots/` is written as `shots/<name>`) that comes up over the footage and pushes in on `focus` (`[left, top, right, bottom]`, fractions of the shot) — drawn once `render.chrome.fx.zoom` is on ([Effects](#effects)). **How long it stays**: up 0.2 s into the clip's clean span (rising in over 0.38 s), its focus box drawn 0.55 s later, the push at `at` (seconds into the clip; default as soon as the box has drawn) over 1 s, then a slow drift on the detail; it leaves with a 0.3 s fade 0.3 s before the clip's clean span ends — or, with `hold` (0.5–10 s), that long after the push lands (never past the clip's own leave) | — | `umtool set <p> <clip> fx.zoom='{"shot":"shots/x.png","focus":[0.1,0.2,0.9,0.4],"at":5.9,"hold":4}'` (`fx.zoom=` clears it) | `PUT /api/report/window {project, clip, "fx.zoom": {…} \| null}` | | `fx.receipts`, `fx.punch`, `fx.quote`, `fx.punchIn`, `fx.speakers` — the clip's other effect fields (`[{shot, mark?, at?, hold?, label?}]` 1–4, `at` the source second a receipt flies in at (default: as the clip comes up), `hold` 0.5–10 s it stays once landed (on every one: they leave then, not with the clip), `label` a line of at most 80 characters in a band under the screenshot (when it was taken, what it is); the words to punch; `false`: no line; 1–8 source seconds inside the clip; `[{at, who: 0\|1}]`), each inert until its effect is on; `fx` is all of them at once. Checked by the build's own `validateFxEntries` | — | `fx.punch="the words"` `fx.punchIn='[231.4]'` · `fx='{…}'` sets them all, `fx=` clears every one | `PUT /api/report/window {project, clip, fx}` (or one `"fx.<field>"`) | | `gaps` — `[{from, to}]`, SOURCE seconds cut out of the clip's middle: it renders as ONE segment of jump cuts (one pip, one card), not two clips with a crossfade ([below](#gaps-inside-a-clip)) | clip bench (Edit this clip), the waveform: **Select a gap** (`g`) or Alt + drag a span, **Cut gap** (`g`), **Hear it**; a click on a gap's band puts it back (`G`: the one at the playhead); **Undo** | `umtool window <p> <clip> --gap 12.3-15.1` (repeatable) · `--gap-remove 12.3` · `--gaps '12.3-15.1,20-20.6'` (`--gaps ''` clears) · `umtool set <p> <clip> gap.add=12.3-15.1 gap.remove=12.3 gaps=` | `PUT /api/report/window {project, clip, token, gapAdd \| gapRemove \| gaps}` | @@ -107,7 +108,10 @@ misclip), and only listening caught it. `umtool quote-check <p> [--clips a,b]` l clip's cut ±15 s (`--pad`) of the source the render would use is transcribed by the editor (its transcription lane, words on), and the quote is found in those words — numbers one token however they are written, a word one letter off still a match, an ellipsis splitting it into fragments found in -order — and in the recording's cues. The rows (`quote-check.json`, one per clip, with the cut, the +order — and in the recording's cues. The editor's work files (`<clip>.words.json`) go to +`<project>/.quote-check/` — never under `out/`, which may be a link onto a media drive, where the editor +refuses to write (inside the corpus); refused there too, `<reports>/.umtool/quote-check/<project>/`, then +`~/.cache/umtool/quote-check/<project>/`. The rows (`quote-check.json`, one per clip, with the cut, the quote and the source judged): | row | means | what settles it | @@ -1747,7 +1751,7 @@ in the build's words (`validatePostCombos`). `k=` (empty) takes the default (the | | In umtool | From a terminal | Route | |---|---|---|---| | the repeats: each attachment played more than once, its posts in the cut's order with their dates, the tier that matched (`X media id`, `same file`, `same sound`) and the badge each draws; a post whose capture holds the same file but whose entry carries none, marked | the post bench's **combo** block (this item's group) | `umtool posts repeats <p> [--match id\|file\|audio] [--json]` | `GET /api/report/post-combo?project` | -| attach what a capture holds to a post item that carries none (captured after it went in): its media copied in and set, nothing else of the entry changed; then it plays and counts | — | `umtool posts attach <p> <item>… \| --all [--dry-run]` | — | +| attach what a capture holds to a post item that carries none (captured after it went in): its media copied in and set, nothing else of the entry changed; then it plays and counts. The capture is looked for in the project's channels tree (a `.shadow-channels`, `provenance.channelsDir`), then the archive's behind it -- read only, the files are copied into the project; `--dry-run` says which tree each file comes from | — | `umtool posts attach <p> <item>… \| --all [--dry-run]` | — | | the badge on the item's clock | Play the cut, the post bench (the player) | the build: `segments/<id>.mp4` (the plain one `<id>.plain.mp4`, the record `<id>.combo.json`) | — | ## Media scenes (one attachment, several messages) @@ -2569,11 +2573,12 @@ A sticky note per goal on a pile in a corner of the footage box, read off the sc | Knob | Range · default | From a terminal | |---|---|---| -| `deck.goals` | `true` · `false` · `{show, position, x, y, scale, hold, finale, max, color, countdown, base}` · default on with a measure slice | `umtool look <p> deck.goals=false` | +| `deck.goals` | `true` · `false` · `{show, position, x, y, scale, hold, finale, max, color, countdown, base, baseMaxDays}` · default on with a measure slice | `umtool look <p> deck.goals=false` | | `deck.goals.position`, `.x`/`.y`, `.scale` | `top-left` `top-right` `bottom-left` `bottom-right` `top-center` `bottom-center` · design px · 0.5–2 · default `bottom-right`, unset, 1 | `umtool look <p> deck.goals.position=bottom-left` | | `deck.goals.position=shelf` | its shelf form (`deck.shelf`): the count of goals set in a column, then the notes fanned sideways like the diet's tags -- ordered by the dial's goal board (measure-goals.mjs `goalsAt(goalBoard(schedule.measure), t)`, so the shelf and the dial always agree): its headline -- the closest goal in force -- in front with "+N more" for the others in force, the rest by recency; a goal the board misses struck in red, MISSED on it, for the dial's 6 s; with no goal in force, the newest in front; a new goal landing from above as on the pile; each older one showing its goal's words in the strip beside it (all of each when there is room); a repeat comes to the front with its ×n. The fan takes the shelf's spare width (shelfLayout), up to its notes side by side. On the shelf it stays up from the first goal (`hold` unset). What the dial draws of the goal stays on the dial | `umtool look <p> deck.shelf.items='["diet","goals"]' deck.goals.position=shelf` | | `deck.goals.max`, `.color`, `.countdown` | 1–8 notes · #hex paper · bool · default 4, the palette's amber, `true` | `umtool look <p> deck.goals.max=6` | | `deck.goals.base` | bool · default `false`: each note also says the weight he had stated when he set the goal -- "LOSE 100 (FROM 346.7)", its qualifier kept ("(FROM ≈390)") -- the slice's own base for that goal, the one the gauge reckons its target from (measure-slice.mjs `goalBase`: the start of the run open when he set it, else the latest weight he gave by the goal's date, stated or remembered). A goal with no base (no weight by then, a target goal such as "250 LB", a base the scale's foot refuses) shows none -- never one made up. On a back card it is a line of its own, right-aligned like the label | `umtool look <p> deck.goals.base=true` | +| `deck.goals.baseMaxDays` | whole days 0–36500 · unset (default): every base counts. A loss goal's base is a weight he gave by the goal's date, however long before; with this set, a base counts only when its weight was SAID (its row's date, never a remembered weight's as-of) at most that many days before the goal's date. A staler one is no base: the note carries no "(FROM …)", and the slice resolves no target from it -- the dial draws no goal weight and no tick for that goal, his words ("LOSE 100") stay. It is the slice's rule (measure-slice.mjs `goalBaseMaxDays`), so the notes, the shelf and the dial agree; it needs `deck.goals` as settings (`deck.goals.base=true deck.goals.baseMaxDays=365`), and `baseMaxDays=null` takes it off | `umtool look <p> deck.goals.baseMaxDays=365` (`--take <t>` for a take) | | `deck.goals.hold`, `.finale` | 0 (up from the first goal on) or 2–600 s after each · `hide` `show` · default 20, `hide` | `umtool look <p> deck.goals.hold=0` | | `deck.goals.flash` | bool · unset (default): follows `deck.measure.flash` -- THE UPDATE FLASH (update-flash.mjs): the note that lands lights as a goal is set -- not the first note (the stack coming up), not the board's own changes; a thin outline in its own colour, up over 0.15 s and gone over 0.7 s, no size change, never on frame 0 or while the deck is away | `umtool look <p> deck.goals.flash=false` | | `deck.goals.onPosts`, `.onChapters` | `dodge` `hide` `show` · default `dodge`: while a post item's card (its card, slot and strip as postLayout lays them: the schedule's `covers`) or a chapter band is up where it stands, it moves to a free anchor of the footage box -- a size down to half if it must, never onto another measure extra that is up -- and hides when none fits; `hide` hides, `show` stays over it | `umtool look <p> deck.goals.onPosts=hide` | @@ -2694,6 +2699,7 @@ A days-since counter for a promise (`render.chrome.deck.promise`, measure-extras | `deck.promise.position`, `.x`/`.y`, `.scale` | an anchor in the footage box · design px · 0.5–2 · default `top-center`, unset, 1 | `umtool look <p> deck.promise.position=bottom-center` | | `deck.promise.hold`, `.finale` | 0 (stays up) or 2–600 s · `hide` `show` · default 0, `show` | `umtool look <p> deck.promise.finale=hide` | | `deck.promise.label`, `.verb`, `.kept`, `.broken`, `.checks` | ≤40 each · `label` `quote` · default the row's display, "offered", "Posted", "None posted", `label` | `umtool look <p> deck.promise.label='scale video'` | +| a `promise_outcome` row's `stampNote` | one line, 1–80 characters · unset (default): the clock's own words under the stamp, "by <date> · no video". The row's note is that second line instead (REFUNDED / "by her account · no receipt"); the strip over a post's card, which has one line for everything, shows its first clause (to its first `·`, `;`, `—`, `, ` or ` -- `: "refunded · by her account"). It is the ledger row's, so every take of the project reads it. `umtool lint` warns past 26 characters (the stamp's line is never wrapped: a longer one runs past its border) | `umtool ledger <p> set <row> --stampNote "by her account · no receipt"` · off again: `--stampNote null` | | `deck.promise.speakers`, `.claimVerb`, `.claimColor` | `{<speaker>: {handle, color}}` · ≤40 · #hex · default `{}` (the postAvatars handle), "paid", #E37AB8 | `umtool look <p> deck.promise.speakers='{"madamsavvy":{"handle":"MadamSavvy"}}'` | | `deck.promise.onPosts`, `.onChapters` | `dodge` `hide` `show` · default `dodge`: while a post item's card (its card, slot and strip as postLayout lays them: the schedule's `covers`) or a chapter band is up where it stands, it moves to a free anchor of the footage box -- a size down to half if it must, never onto another measure extra that is up -- and hides when none fits; `hide` hides, `show` stays over it | `umtool look <p> deck.promise.onPosts=hide` | | a timeline entry's `hideModules` | `["promise", …]` on an entry hides it over that entry's span, with its own fade, whatever it would otherwise do there (text in the footage no dodge can know of) · any entry, a post item too | `umtool set <p> <entry> hideModules=promise` (`--take <t>` for a take) | diff --git a/umtool/e2e/inbox.spec.ts b/umtool/e2e/inbox.spec.ts @@ -32,6 +32,15 @@ const setLife = (request: APIRequestContext, piece: string, state: string) => request.post("/api/pieces/lifecycle", { data: { piece, state } }); const card = (page: Page, piece: string, kind: string) => page.locator(`[data-lit-line][data-piece='${piece}'][data-card='${kind}']`); +// A WRITE, THEN THE LIST AGAIN. Park, Mark done, Reactivate, Mute, Unmute and Undo POST, then router.refresh(): the +// list changes when the refreshed page has been rendered and streamed whole. Three failures of this spec (11 Nov: +// :122 Reactivate, :178 Unmute, and Undo after Mark done) were all that step late, not wrong: the POST had answered +// 200 and the refresh's request had gone out and been answered, the lifecycle and the mutes are read from disk on +// every render (never memoised), and in the one trace that shows it a HEAD of the same page, sent in the same +// second, took 5.8 s to answer -- the server was that slow for those seconds (another suite's build beside it) and +// the default 5 s expect gave up first. So the FIRST look at the list after such a write waits this long. +const SETTLES = { timeout: 20_000 }; + test.beforeAll(async ({ playwright }) => { test.setTimeout(WARM_TIMEOUT); await warm(playwright, ["/", "/?hidden=1", "/api/browse/decisions", "/api/rail", "/settings/system", "/projects"]); @@ -95,6 +104,7 @@ test("j lights the next card, and only the lit card's action wears Signal", asyn }); test("Park hides a piece's calls, Undo brings them back; Show hidden lists them with Reactivate", async ({ page, request }) => { + test.slow(); // room for SETTLES on a loaded machine try { await page.goto(urls.homeHref()); const ready = card(page, ZETA, "iteration-ready"); @@ -104,12 +114,12 @@ test("Park hides a piece's calls, Undo brings them back; Show hidden lists them await ready.click(); await ready.locator("[data-lifecycle-to=parked]").click(); await expect(page.locator(`[data-undo='${ZETA}']`)).toContainText("Parked"); - await expect(page.locator(`[data-lit-line][data-piece='${ZETA}']`)).toHaveCount(0); + await expect(page.locator(`[data-lit-line][data-piece='${ZETA}']`)).toHaveCount(0, SETTLES); await expect(page.locator("[data-inbox-count]")).not.toHaveAttribute("data-inbox-count", String(before)); await expect(page.locator("[data-show-hidden]")).toContainText(/^Show hidden \d+$/); await page.locator(`[data-undo='${ZETA}']`).getByRole("button", { name: "Undo" }).click(); - await expect(ready).toBeVisible(); + await expect(ready).toBeVisible(SETTLES); await expect(page.locator("[data-inbox-count]")).toHaveAttribute("data-inbox-count", String(before)); // Parked again, it is listed under Hidden, and Reactivate is its action. @@ -119,7 +129,7 @@ test("Park hides a piece's calls, Undo brings them back; Show hidden lists them await expect(hidden).toBeVisible(); await hidden.click(); await hidden.locator("[data-lifecycle-to=active]").click(); - await expect(page.locator(`[data-group=hidden] [data-lit-line][data-piece='${ZETA}']`)).toHaveCount(0); + await expect(page.locator(`[data-group=hidden] [data-lit-line][data-piece='${ZETA}']`)).toHaveCount(0, SETTLES); await expect(card(page, ZETA, "iteration-ready")).toBeVisible(); } finally { await setLife(request, ZETA, "active"); @@ -127,6 +137,7 @@ test("Park hides a piece's calls, Undo brings them back; Show hidden lists them }); test("Mark done on a piece that looks done takes it off the Inbox; Undo puts it back", async ({ page, request }) => { + test.slow(); // room for SETTLES on a loaded machine try { await page.goto(urls.homeHref()); const done = page.locator(`[data-group=ready-to-finish] [data-piece='${ALPHA}'][data-card='looks-done']`); @@ -134,15 +145,16 @@ test("Mark done on a piece that looks done takes it off the Inbox; Undo puts it await done.click(); await done.locator("[data-lifecycle-to=done]").click(); await expect(page.locator(`[data-undo='${ALPHA}']`)).toContainText("Marked done"); - await expect(done).toHaveCount(0); + await expect(done).toHaveCount(0, SETTLES); await page.locator(`[data-undo='${ALPHA}']`).getByRole("button", { name: "Undo" }).click(); - await expect(done).toBeVisible(); + await expect(done).toBeVisible(SETTLES); } finally { await setLife(request, ALPHA, "active"); } }); test("Mute is the server's: the card leaves, its rows stay hidden-by-muted, Muted N lists it with Unmute", async ({ page, request }) => { + test.slow(); // room for SETTLES on a loaded machine const rows = async () => ((await (await request.get("/api/browse/decisions")).json()) as { items: { piece?: string; kind: string; hidden: boolean; hiddenBy?: string }[]; muted: number }) try { @@ -153,7 +165,7 @@ test("Mute is the server's: the card leaves, its rows stay hidden-by-muted, Mute await ready.click(); await ready.locator("[data-mute=mute]").click(); await expect(page.locator(`[data-undo='${ZETA}']`)).toContainText("Muted"); - await expect(ready).toHaveCount(0); + await expect(ready).toHaveCount(0, SETTLES); // Never dropped: every row is still in the API, hidden, and says why. const after = await rows(); @@ -175,7 +187,7 @@ test("Mute is the server's: the card leaves, its rows stay hidden-by-muted, Mute await expect(muted).toHaveAttribute("data-muted", ""); await muted.click(); await muted.locator("[data-mute=unmute]").click(); - await expect(muted).toHaveCount(0); + await expect(muted).toHaveCount(0, SETTLES); await expect(page.locator(`[data-group=review] [data-lit-line][data-piece='${ZETA}'][data-card='iteration-ready']`)).toBeVisible(); expect((await rows()).items.filter((d) => d.piece === ZETA && d.kind === "iteration-ready").every((d) => !d.hidden)).toBe(true); } finally { diff --git a/umtool/lib/cli/groups.mjs b/umtool/lib/cli/groups.mjs @@ -105,7 +105,7 @@ export const GROUPS = [ ], 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; `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))"], + "**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))"], ], }, { @@ -301,7 +301,7 @@ export const GROUPS = [ ], docs: [ ["`set <project> <clip> key=value …`", - "a clip's **knobs**: `claim.at` `claim.hold` `claim.stamp` `claim.count` `claim.label` (the first mark's, or `--mark <id>`'s), its **marks** `mark.add=<verdict>[@<sec>]` `mark.remove=<id>` `mark.verdict=<verdict>` `marks=<json>`, `audio.offset` `audio.gain` `audio.fadeIn` `audio.fadeOut`, its picture's **blur** `blur.on=true` `blur.caption=…` `blur.strength` `blur.from` `blur.to` (`blur.on=` clears it; [knobs.md](knobs.md#a-clips-picture-blurred)), its **effects** `fx.zoom=<json>` `fx.receipts=<json>` `fx.punch=…` `fx.quote` `fx.punchIn=<json>` `fx.speakers=<json>` (`fx=<json>` all of them, `fx=` clears them; a shot is a file in the project; [knobs.md](knobs.md#effects)); `key=` clears one ([knobs.md](knobs.md#marks))"], + "a clip's **knobs**: `claim.at` `claim.hold` `claim.stamp` `claim.count` `claim.label` (the first mark's, or `--mark <id>`'s), its **marks** `mark.add=<verdict>[@<sec>]` `mark.remove=<id>` `mark.verdict=<verdict>` `marks=<json>`, `audio.offset` `audio.gain` `audio.fadeIn` `audio.fadeOut`, its picture's **blur** `blur.on=true` `blur.caption=…` `blur.strength` `blur.from` `blur.to` (`blur.on=` clears it; [knobs.md](knobs.md#a-clips-picture-blurred)), its **effects** `fx.zoom=<json>` `fx.receipts=<json>` `fx.punch=…` `fx.quote` `fx.punchIn=<json>` `fx.speakers=<json>` (`fx=<json>` all of them, `fx=` clears them; a shot is a file in the project; [knobs.md](knobs.md#effects)); on ANY entry (a post item, a still, a clip) `hideModules=diet,streak`, `shelfNote='…'` and `chapter='…'` (its name in the chapter list, one line of at most 100 characters; `chapter=` none); `--take <t>` writes the entry knobs into that take's patch; `key=` clears one ([knobs.md](knobs.md#marks))"], ], }, { @@ -325,8 +325,8 @@ export const GROUPS = [ " variants=<json>, and the look's keys (transition=0.3, …)", ], docs: [ - ["`look <project> key=value … [--unset render.<key>]…`", - "the cut's **knobs**: `factcheck.stamp.*`, `factcheck.verdicts.<V>.stampLabel\\|label\\|color`, `deck.markers=<json>`, `deck.markerLayout`, `variants=<json>`, and the look's keys — `mode=basic\\|deck` (the footage alone, [knobs.md](knobs.md#basic-output-the-footage-alone)) and `basic=<json>` (its fades) among them ([knobs.md](knobs.md)) **The deck on, legacy keys off** (`updateRenderKeys`, one write, an undo point `revisions/…auto-render-keys…` first): `chrome.layout=deck` turns the deck on (render.chrome created when the cut has none: engine hyperframes, an empty deck), `--unset render.<key>` (repeatable) drops a legacy render key -- only `rail` `chromeEngine` `railEngine` `chromeRegions` `claimSchedule` `wordmark` `title` `finale` `cut`; the deck beside the old rail is refused in the build's words unless the same command drops it; deck.* keys in the same command land after the chrome exists. Another key named: **exit 2**"], + ["`look <project> key=value … [--unset render.<key>]… [--take <t>]`", + "the cut's **knobs** (`--take <t>`: the `deck.*` keys given are set on that take -- its patch, an undo point of its own, the project's manifest untouched; the other knobs are the project's): `factcheck.stamp.*`, `factcheck.verdicts.<V>.stampLabel\\|label\\|color`, `deck.markers=<json>`, `deck.markerLayout`, `variants=<json>`, and the look's keys — `mode=basic\\|deck` (the footage alone, [knobs.md](knobs.md#basic-output-the-footage-alone)) and `basic=<json>` (its fades) among them ([knobs.md](knobs.md)) **The deck on, legacy keys off** (`updateRenderKeys`, one write, an undo point `revisions/…auto-render-keys…` first): `chrome.layout=deck` turns the deck on (render.chrome created when the cut has none: engine hyperframes, an empty deck), `--unset render.<key>` (repeatable) drops a legacy render key -- only `rail` `chromeEngine` `railEngine` `chromeRegions` `claimSchedule` `wordmark` `title` `finale` `cut`; the deck beside the old rail is refused in the build's words unless the same command drops it; deck.* keys in the same command land after the chrome exists. Another key named: **exit 2**"], ], }, { @@ -729,7 +729,7 @@ export const GROUPS = [ ], docs: [ ["`ledger <project> [ls] [--scope S] [--population P] [--json]` · `ledger <project> add <id> --date D --scope S --population P [--value V] --scopeBasis \"…\" [--<key> V …] [--row '{…}']` · `ledger <project> set <id> --<key> V … [--unset k,k]` · `ledger <project> rm <id>`", - "a **measure ledger's rows** (`ledgerSchema.kind \"measure\"`), the only writer of them: each row is checked against the schema -- a track, a form (and the promise forms `promise` / `promise_check`), a number in its unit or a declared regime with an event, the six adjudication fields (a new row defaults `scopeConfidence` read, `valueKind` uttered, `flags` []; `--scopeBasis` is never defaulted), the declared fields, and the instruments' own keys: `run` (a loss claim's run), `retro` (a loss told in the past with no `asOf`: off the odometer), `promise`, `kept`, `due`, `speaker` (another party's key: her rows move none of his numbers), `paidOn`, `outcome` (a `promise_outcome`'s: kept, refunded, withdrawn); the promise forms are `promise`, `promise_check`, `promise_claim`, `promise_outcome`. `rm` refuses a row an entry pins or another row names ([knobs.md](knobs.md#the-measure-slice-the-weight-instruments))"], + "a **measure ledger's rows** (`ledgerSchema.kind \"measure\"`), the only writer of them: each row is checked against the schema -- a track, a form (and the promise forms `promise` / `promise_check`), a number in its unit or a declared regime with an event, the six adjudication fields (a new row defaults `scopeConfidence` read, `valueKind` uttered, `flags` []; `--scopeBasis` is never defaulted), the declared fields, and the instruments' own keys: `run` (a loss claim's run), `retro` (a loss told in the past with no `asOf`: off the odometer), `promise`, `kept`, `due`, `speaker` (another party's key: her rows move none of his numbers), `paidOn`, `outcome` (a `promise_outcome`'s: kept, refunded, withdrawn), `stampNote` (a `promise_outcome`'s: the words under its stamp on the promise clock in place of \"by <date> · no video\" -- `ledger <p> set <row> --stampNote \"…\"`, `--stampNote null` for the clock's own words again; one line, the strip over a post's card shows its first clause, and `umtool lint` warns past 26 characters); the promise forms are `promise`, `promise_check`, `promise_claim`, `promise_outcome`. `rm` refuses a row an entry pins or another row names ([knobs.md](knobs.md#the-measure-slice-the-weight-instruments))"], ], }, { @@ -1060,7 +1060,7 @@ export const GROUPS = [ ["`posts repeats <project> [--match id\\|file\\|audio] [--json]`", "the **combo counter**'s repeats ([report-video.md](report-video.md#the-combo-counter)): every attachment the cut's post items play more than once -- the same X media id (the capture's url), else the same file (the capture's sha256 when its bytes agree, else hashed; cached by path, size and mtime), else (`--match audio`) the same sound (fpcalc, else a coarse ffmpeg hash) -- its posts in the cut's ORDER with their dates, the tier that matched and the badge each draws (`×2` from the second use, `(×n)` counted but not drawn); a post whose CAPTURE holds the same file but whose entry carries no attachment is listed too, `NOT ATTACHED`, with the `posts attach` that brings it in. Reads only"], ["`posts attach <project> [<item> … \\| --all] [--dry-run] [--json]`", - "a post item with **no attachment whose capture holds one** (captured after it went in -- `posts repeats` marks them `NOT ATTACHED`): the capture's media (its own channel's `posts-media/<postId>/`, else any channel the cut's posts come from) copied into the project's `posts-media/<slug>/<postId>/` and measured, set as the entry's `media` as `posts reel` would have made it -- nothing else of the entry changes (its paraphrases, narration, knobs kept); an item that has an attachment is never touched. ONE write (one undo point: `timeline <p> undo`), refused whole in the build's words"], + "a post item with **no attachment whose capture holds one** (captured after it went in -- `posts repeats` marks them `NOT ATTACHED`): the capture's media (its own channel's `posts-media/<postId>/`, else any channel the cut's posts come from -- looked for in the project's channels tree first, a `.shadow-channels` or `provenance.channelsDir`, then the archive's `CHANNELS_DIR` behind it, read only; `--dry-run` says which tree each file comes from) copied into the project's `posts-media/<slug>/<postId>/` and measured, set as the entry's `media` as `posts reel` would have made it -- nothing else of the entry changes (its paraphrases, narration, knobs kept); an item that has an attachment is never touched. ONE write (one undo point: `timeline <p> undo`), refused whole in the build's words"], ["`posts combo <project> [on=on\\|off] [label=L] [position=top-right\\|top-left\\|bottom-right\\|bottom-left\\|center] [color=#rrggbb] [scale=0.4-2.5] [sfx=off\\|hit\\|coin] [minCount=2-20] [match=id\\|file\\|audio] [--json]` · `posts combo <project> <item> off\\|on\\|auto\\|label=…\\|position=…\\|color=…\\|scale=…\\|sfx=… [--json]`", "the **combo badge's knobs** ([knobs.md](knobs.md#the-combo-counter)): the cut's (`render.posts.combo`, `updatePostComboRender`; no knobs prints them; `k=` the default again) or one post item's (`combo`, `updatePostCombo`): `off` draws no badge on it -- it still counts -- `on`/`auto` the cut's again. Refused in the build's words (**exit 1**)"], ], diff --git a/umtool/lib/report/knobsCli.mjs b/umtool/lib/report/knobsCli.mjs @@ -59,7 +59,7 @@ export const VERTICAL_SET_KEYS = Object.freeze(["vertical", "vertical.crop", "ve export const SIDE_SET_KEYS = Object.freeze(["side", "side.item", "side.post", "side.from", "side.to", "side.place"]); const SET_KEYS = [ "claim", ...CLAIM_KNOBS.map((k) => `claim.${k}`), ...MARK_KEYS, ...AUDIO_KNOBS.map((k) => `audio.${k}`), ...BLUR_KNOBS.map((k) => `blur.${k}`), "layout", ...REVIEW_KEYS, - ...FX_KEYS, ...GAP_KEYS, "chat", "hideModules", "shelfNote", + ...FX_KEYS, ...GAP_KEYS, "chat", "hideModules", "shelfNote", "chapter", // The vertical format (lane vertical): the clip's 9:16 crop and layout, and its side post. ...VERTICAL_SET_KEYS, ...SIDE_SET_KEYS, ]; @@ -105,6 +105,8 @@ export const SET_USAGE = [ " footage no dodge can know of; any entry, a post item too): goals peak promise diet streak; `hideModules=` none.", " shelfNote='Weighed in on camera' puts one line (≤ 80 characters) on the shelf (render.chrome.deck.shelf, its", " `note` slot) over this entry's span, coming and going with it; any entry; `shelfNote=` none.", + " chapter='The weigh-in' names this entry in the chapter list (out/chapters, youtube.txt) in place of its on-screen", + " title or the line derived from its record: one line, ≤ 100 characters; any entry; `chapter=` none.", " --take <t>: the entry knobs (not claim.* or marks) land in takes/<t>/take.json's patch, an undo point first", " (`umtool timeline <p> --take <t> undo`); the project's manifest is untouched.", " vertical.crop='[x,y,w,h]' (fractions of the source: the 9:16 box a vertical render cuts; vertical.aspect the", @@ -119,7 +121,9 @@ export const SET_USAGE = [ ].join("\n"); export const LOOK_USAGE = [ - "usage: umtool look <project> key=value … [--unset render.<key>]… [--json]", + "usage: umtool look <project> key=value … [--unset render.<key>]… [--take <t>] [--json]", + " --take <t>: the deck.* keys given are set on THAT TAKE (its patch, an undo point of its own:", + " umtool timeline <p> --take <t> undo); the project's manifest is untouched. deck.* keys only", " chrome.layout=deck: the deck on (render.chrome created when the cut has none: engine hyperframes, an empty deck)", " --unset render.<key>: drop a legacy render key (rail chromeEngine railEngine chromeRegions claimSchedule wordmark", " title finale cut) -- with chrome.layout=deck in ONE write (the deck refuses the old rail beside it), an undo point first", @@ -245,6 +249,11 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso entryPatch.shelfNote = value === null || value === undefined ? null : String(value); continue; } + if (key === "chapter") { + // The entry's name in the chapter list (manifest.mjs parseEntryChapter checks it); words whatever they parse as. + entryPatch.chapter = value === null || value === undefined ? null : String(value); + continue; + } if (key === "hideModules") { // The modules hidden over this entry's span (deck.mjs parseHideModules checks the ids); `hideModules=` none. entryPatch.hideModules = value === null || value === undefined ? null : value; @@ -334,6 +343,7 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso if (take) results.take = { id: take, undo: result.revision?.rel ? `takes/${take}/${result.revision.rel}` : null }; if ("hideModules" in entryPatch) results.hideModules = result.entry.hideModules ?? null; if ("shelfNote" in entryPatch) results.shelfNote = result.entry.shelfNote ?? null; + if ("chapter" in entryPatch) results.chapter = result.entry.chapter ?? null; if ("audio" in entryPatch) results.audio = result.entry.audio ?? null; if ("blur" in entryPatch) results.blur = result.entry.blur ?? null; if ("layout" in entryPatch) results.layout = result.entry.layout ?? "clip"; @@ -371,6 +381,7 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso if ("layout" in results) out(`${clipId}: layout ${results.layout}`); if ("hideModules" in results) out(`${clipId}${results.take ? ` (take ${results.take.id})` : ""}: hideModules ${results.hideModules ? `${results.hideModules.join(", ")} (hidden over its span)` : "none"}`); if ("shelfNote" in results) out(`${clipId}${results.take ? ` (take ${results.take.id})` : ""}: shelfNote ${results.shelfNote ? JSON.stringify(results.shelfNote) + " (on the shelf over its span)" : "none"}`); + if ("chapter" in results) out(`${clipId}${results.take ? ` (take ${results.take.id})` : ""}: chapter ${results.chapter ? JSON.stringify(results.chapter) + " (its name in the chapter list)" : "none (named by its on-screen title, else its record)"}`); if (results.take?.undo) out(` undo point: ${results.take.undo} (umtool timeline ${project.id} --take ${results.take.id} undo)`); if ("chat" in results) out(`${clipId}: chat ${results.chat === true ? "on (its video's live_chat.cues.json beside the footage; the build says if there is none)" : results.chat === false ? "off" : "default (off)"}`); if ("fx" in results) out(`${clipId}: fx ${results.fx ? JSON.stringify(results.fx) : "none"}`); @@ -480,6 +491,45 @@ export async function lookCommand(args, { root = REPORTS_ROOT, out = (s) => cons } const project = await projectOf(projectArg, root); const pairs = parseAssignments(rest); + // A TAKE'S DECK KEYS (`--take <t>`, 12 Nov: `deck.goals.baseMaxDays` for one take): the same write over the take's + // manifest, landing in its patch with an undo point of the take's own (takeScope.mjs) -- the project's manifest + // untouched. The deck's keys only: the other knobs here are the project's. + if (flags.has("--take")) { + const take = typeof flags.get("--take") === "string" && flags.get("--take") ? String(flags.get("--take")) : null; + if (!take) throw new CliError("--take needs a take id"); + const other = pairs.filter(([k]) => !k.startsWith("deck.")); + if (other.length || flags.has("--unset")) { + throw new CliError(`--take sets a take's deck keys (deck.<key>=…); ${other.length ? other.map(([k]) => k).join(", ") : "--unset"} is the project's (set it without --take)`); + } + 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)`); + const { stat } = await import("node:fs/promises"); + const { default: nodePath } = await import("node:path"); + if (!(await stat(nodePath.join(takesDirOf(project.dir), take, TAKE_FILE)).catch(() => null))) { + err(`${project.id} has no take ${take} (no takes/${take}/${TAKE_FILE})`); + return 1; + } + const busy = await (await import("./takeImport.mjs")).takeRenderingNow(project.dir, take); + if (busy) { + err(`not edited: ${busy}`); + return 1; + } + const { withTakeScope } = await import("./takeScope.mjs"); + const lines = []; + const code = await withTakeScope(project.dir, take, () => + lookCommand([projectArg, ...rest, ...(json ? ["--json"] : [])], { root, out: (l) => lines.push(l), err })); + if (json && code === 0) { + for (const l of lines) { + let doc = null; + try { doc = JSON.parse(l); } catch { /* a line of prose */ } + out(doc && typeof doc === "object" ? JSON.stringify({ ...doc, take: { id: take, undo: `umtool timeline ${project.id} --take ${take} undo` } }, null, 2) : l); + } + } else { + for (const l of lines) out(l); + if (code === 0) out(`take ${take}: written to its patch (undo: umtool timeline ${project.id} --take ${take} undo)`); + } + return code; + } // THE DECK ON, LEGACY KEYS OFF (updateRenderKeys): `chrome.layout=deck` (render.chrome created when the cut has // none) and `--unset render.<key>`, in one write with an undo point -- before any deck.* key, which needs the chrome. const chromeOn = pairs.filter(([k]) => k === "chrome.layout" || k === "chrome.engine"); diff --git a/umtool/lib/report/knobsCli.test.mjs b/umtool/lib/report/knobsCli.test.mjs @@ -342,3 +342,60 @@ test("umtool look chrome.layout=deck --unset render.<key>: the deck turned on an assert.equal(await run("fresh", "chrome.layout=deck", "deck.sectionTitle=true"), 0, lines.join("\n")); assert.deepEqual((await read(fresh)).render.chrome.deck, { sectionTitle: true }); }); + +test("umtool look deck.<key>=… --take <t>: the take's patch, an undo point of the take's, the project's manifest untouched; deck keys only", async () => { + const dir = await project("looktake"); + const { lines, run } = runner(lookCommand); + const { draftTake } = await import("./takeMaker.mjs"); + const { resolveTakeManifest } = await import("./takeManifest.mjs"); + await draftTake(dir, { id: "a9", label: "A9", patch: {} }); + const before = await readFile(path.join(dir, "video.manifest.json"), "utf8"); + assert.equal(await run("looktake", "deck.goals.base=true", "deck.goals.baseMaxDays=365", "--take", "a9"), 0, lines.join("\n")); + assert.match(lines.join("\n"), /deck\.goals: \{"base":true,"baseMaxDays":365\}/); + assert.match(lines.at(-1), /take a9: written to its patch \(undo: umtool timeline looktake --take a9 undo\)/); + assert.equal(await readFile(path.join(dir, "video.manifest.json"), "utf8"), before); + assert.deepEqual((await resolveTakeManifest(dir, "a9")).manifest.render.chrome.deck.goals, { base: true, baseMaxDays: 365 }); + // One field off again keeps the rest. + assert.equal(await run("looktake", "deck.goals.baseMaxDays=", "--take", "a9"), 0, lines.join("\n")); + assert.deepEqual((await resolveTakeManifest(dir, "a9")).manifest.render.chrome.deck.goals, { base: true }); + // The build's rules still refuse; other knobs and a take that is not there are refused. + assert.equal(await run("looktake", "deck.goals.baseMaxDays=-3", "--take", "a9"), 1); + assert.match(lines.at(-1), /baseMaxDays must be null \(every base counts\) or whole days/); + assert.equal(await run("looktake", "transition=0.3", "--take", "a9"), 2); + assert.match(lines.at(-1), /--take sets a take's deck keys/); + assert.equal(await run("looktake", "deck.goals.baseMaxDays=365", "--take", "nope"), 1); + assert.match(lines.at(-1), /has no take nope/); + assert.equal(await readFile(path.join(dir, "video.manifest.json"), "utf8"), before); +}); + +test("umtool set chapter='…': an entry's name in the chapter list, any entry; chapter= clears; --take writes the take's patch", async () => { + const dir = await project("chapter"); + const m = await read(dir); + m.timeline.push({ type: "post", id: "x01", item: "123" }); + await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify(m, null, 2) + "\n"); + const { lines, run } = runner(setCommand); + assert.equal(await run("chapter", "c02", "chapter= The weigh-in "), 0, lines.join("\n")); + assert.equal((await read(dir)).timeline[1].chapter, "The weigh-in", "trimmed"); + assert.match(lines.at(-1), /c02: chapter "The weigh-in" \(its name in the chapter list\)/); + assert.equal(await run("chapter", "x01", "chapter=2026"), 0, lines.join("\n")); + assert.equal((await read(dir)).timeline[2].chapter, "2026", "a post item too; words whatever they parse as"); + // Beside a clip's other knobs in one command. + assert.equal(await run("chapter", "c01", "chapter=Arrival", "audio.gain=2"), 0, lines.join("\n")); + assert.deepEqual([(await read(dir)).timeline[0].chapter, (await read(dir)).timeline[0].audio], ["Arrival", { gain: 2 }]); + assert.equal(await run("chapter", "c02", `chapter=${"x".repeat(101)}`), 1); + assert.match(lines.at(-1), /chapter is 101 characters \(at most 100\)/); + assert.equal((await read(dir)).timeline[1].chapter, "The weigh-in", "a refused write changes nothing"); + assert.equal(await run("chapter", "c02", "chapter="), 0); + assert.equal("chapter" in (await read(dir)).timeline[1], false); + assert.match(lines.at(-1), /c02: chapter none/); + const { draftTake } = await import("./takeMaker.mjs"); + const { resolveTakeManifest } = await import("./takeManifest.mjs"); + await draftTake(dir, { id: "a9", label: "A9", patch: {} }); + const before = await readFile(path.join(dir, "video.manifest.json"), "utf8"); + assert.equal(await run("chapter", "c02", "chapter=Day 41", "--take", "a9"), 0, lines.join("\n")); + assert.match(lines.join("\n"), /c02 \(take a9\): chapter "Day 41"/); + assert.equal(await readFile(path.join(dir, "video.manifest.json"), "utf8"), before); + assert.equal((await resolveTakeManifest(dir, "a9")).manifest.timeline[1].chapter, "Day 41"); + assert.equal(await run("chapter", "x01", "chapter=", "--take", "a9"), 0, lines.join("\n")); + assert.equal("chapter" in (await resolveTakeManifest(dir, "a9")).manifest.timeline[2], false); +}); diff --git a/umtool/lib/report/ledgerCli.mjs b/umtool/lib/report/ledgerCli.mjs @@ -28,7 +28,9 @@ export const LEDGER_USAGE = [ "instruments' own: run (a loss claim's run, his words placing it), retro (a loss told in the past with no asOf:", "off the odometer), promise (a promise_check's or promise_claim's promise), kept, due (YYYY-MM-DD), speaker (another", "party's key: a promise_claim's -- her rows move none of his numbers), paidOn (YYYY-MM-DD), outcome (a", - "promise_outcome's: kept, refunded, withdrawn)) or a declared field; `null`", + "promise_outcome's: kept, refunded, withdrawn), stampNote (a promise_outcome's: the words under its stamp on the", + "promise clock in place of \"by <date> · no video\" -- one line; the strip shows its first clause; `umtool lint` warns", + "past 26 characters)) or a declared field; `null`", "clears a value. rm refuses a row a timeline entry pins or another row names.", ].join("\n"); diff --git a/umtool/lib/report/ledgerCli.test.mjs b/umtool/lib/report/ledgerCli.test.mjs @@ -118,6 +118,15 @@ test("umtool ledger: add, set, unset, rm -- through the writers, on the file", a assert.equal(await run(ledgerCommand, "weigh", "add", "o02", "--date", "2026-10-31", "--scope", "weight", "--population", "promise_outcome", "--promise", "p01", "--outcome", "forgotten", "--scopeBasis", "x"), 1); assert.match(lines.at(-1), /outcome kept, refunded, withdrawn/); + // The words under its stamp (`stampNote`): a promise_outcome's, one line; null takes them off again. + assert.equal(await run(ledgerCommand, "weigh", "set", "o01", "--stampNote", "by her account · no receipt"), 0, lines.join("\n")); + assert.equal((await manifestOf(dir)).ledger.find((r) => r.id === "o01").stampNote, "by her account · no receipt"); + assert.equal(await run(ledgerCommand, "weigh", "set", "o01", "--stampNote", "x".repeat(81)), 1); + assert.match(lines.at(-1), /stampNote is one line of 1–80 characters/); + assert.equal(await run(ledgerCommand, "weigh", "set", "p01", "--stampNote", "nope"), 1); + assert.match(lines.at(-1), /stampNote is a promise_outcome's/); + assert.equal(await run(ledgerCommand, "weigh", "set", "o01", "--stampNote", "null"), 0, lines.join("\n")); + assert.equal((await manifestOf(dir)).ledger.find((r) => r.id === "o01").stampNote ?? null, null); assert.equal(await run(ledgerCommand, "weigh", "rm", "o01"), 0); assert.equal(await run(ledgerCommand, "weigh", "rm", "s01"), 0); // A loss told in the past: off the odometer; then put back on it. diff --git a/umtool/lib/report/ledgerRows.mjs b/umtool/lib/report/ledgerRows.mjs @@ -18,7 +18,7 @@ // subject) is a lower-case key; another speaker's row moves none of his // numbers (measure-slice.mjs). import { - EVENTS, LEDGER_BUILTIN_KEYS, PROMISE_FORMS, PROMISE_OUTCOMES, SCOPE_CONFIDENCE, VALUE_KINDS, measureDisplay, measureGaps, measureSchema, validateFields, + EVENTS, LEDGER_BUILTIN_KEYS, PROMISE_FORMS, PROMISE_OUTCOMES, SCOPE_CONFIDENCE, STAMP_NOTE, VALUE_KINDS, measureDisplay, measureGaps, measureSchema, validateFields, } from "umtool-report-to-video/ledger-totals"; const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v); @@ -35,7 +35,7 @@ export const LEDGER_KEY_TYPES = Object.freeze({ display: "text?", label: "text?", quote: "text?", deadline: "text?", src: "text?", channel: "text?", video: "text?", cite: "seconds?", citeFrom: "text?", scopeBasis: "text", scopeConfidence: "text", valueKind: "text", flags: "list", hedged: "bool?", unsourced: "bool?", plotted: "bool?", hidden: "bool?", entryId: "text?", authorNote: "text?", - run: "run?", retro: "bool?", promise: "text?", kept: "bool?", due: "day?", speaker: "speaker?", paidOn: "day?", outcome: "text?", + run: "run?", retro: "bool?", promise: "text?", kept: "bool?", due: "day?", speaker: "speaker?", paidOn: "day?", outcome: "text?", stampNote: "text?", }); /** Is this manifest's ledger a measure ledger (the one these writers write)? */ @@ -143,6 +143,13 @@ export function ledgerRowOf(manifest, base, patch, { unset = [] } = {}) { if (row.population === "promise_outcome") { if (!PROMISE_OUTCOMES.includes(row.outcome)) errors.push(`a promise_outcome says how it ended: outcome ${PROMISE_OUTCOMES.join(", ")}`); } else if (row.outcome !== undefined && row.outcome !== null) errors.push("outcome is a promise_outcome's"); + // The words under the outcome's stamp on the promise clock (measure-extras.mjs STAMP_NOTE): one line of text. + if (row.stampNote !== undefined && row.stampNote !== null) { + if (row.population !== "promise_outcome") errors.push("stampNote is a promise_outcome's (the words under its stamp)"); + else if (typeof row.stampNote !== "string" || !row.stampNote.trim() || /[\n\r]/.test(row.stampNote) || row.stampNote.trim().length > STAMP_NOTE.max) { + errors.push(`stampNote is one line of 1–${STAMP_NOTE.max} characters (the stamp's second line; past ${STAMP_NOTE.fit} the lint warns it may not fit)`); + } + } if (["promise_check", "promise_claim", "promise_outcome"].includes(row.population)) { const p = ledger.find((r) => r?.id === row.promise); if (!row.promise) errors.push(`a ${row.population} names its promise (--promise <row id>)`); diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs @@ -328,8 +328,41 @@ function applyShelfNote(entry, value) { else delete entry.shelfNote; } +/** The most characters an entry's `chapter` may have: one line of a chapter list (a YouTube title's own limit). */ +export const ENTRY_CHAPTER_MAX = 100; + +/** + * An entry's `chapter` as written: its name in the chapter list (build-video.mjs chapterTitle: an authored `chapter` + * wins over the on-screen title and the line derived from the record). One line, at most ENTRY_CHAPTER_MAX + * characters, trimmed; null, "" or blank is none. + * @param {unknown} v + * @returns {{ value: string | null, error: string | null }} + */ +export function parseEntryChapter(v) { + if (v === null || v === undefined || v === "" || v === false) return { value: null, error: null }; + if (typeof v !== "string") return { value: null, error: `chapter is words, not ${JSON.stringify(v)}` }; + const s = v.trim(); + if (!s) return { value: null, error: null }; + if (/[\r\n]/.test(s)) return { value: null, error: "chapter must be one line" }; + if ([...s].length > ENTRY_CHAPTER_MAX) return { value: null, error: `chapter is ${[...s].length} characters (at most ${ENTRY_CHAPTER_MAX})` }; + return { value: s, error: null }; +} + +/** + * Set an entry's `chapter` (parseEntryChapter); null or "" removes it -- the chapter list names the entry by its + * on-screen title or its record again. + * @param {Record<string, unknown>} entry + * @param {unknown} value + */ +function applyChapter(entry, value) { + const { value: text, error } = parseEntryChapter(value); + if (error) throw new Error(error); + if (text) entry.chapter = text; + else delete entry.chapter; +} + /** The patch keys any timeline entry may carry (a post item, a still, a clip): applied before the clip-only rules. */ -const ANY_ENTRY_KEYS = Object.freeze(["hideModules", "shelfNote"]); +const ANY_ENTRY_KEYS = Object.freeze(["hideModules", "shelfNote", "chapter"]); /** * updateClip's rules over a manifest held in memory: the ONE place a clip @@ -358,8 +391,9 @@ export function patchClipEntry(manifest, clipId, patch, { edit = "trim", now = n // So may its note on the shelf (`shelfNote`, deck.mjs entryShelfNotes). if (patch !== RESTORE_PATCH && Object.keys(patch).length && Object.keys(patch).every((k) => ANY_ENTRY_KEYS.includes(k))) { if (patch.hideModules !== undefined) applyHideModules(entry, patch.hideModules); - if (patch.shelfNote !== undefined) applyShelfNote(entry, patch.shelfNote); if (patch.shelfNote !== undefined) applyShelfNote(entry, patch.shelfNote); + // Its name in the chapter list (`chapter`, build-video.mjs chapterTitle). + if (patch.chapter !== undefined) applyChapter(entry, patch.chapter); return { entry, before: { start: entry.start, end: entry.end } }; } // `!== "clip"`, not `=== "card"`. The timeline's vocabulary is open -- one @@ -781,6 +815,8 @@ export function patchClipEntry(manifest, clipId, patch, { edit = "trim", now = n } if (patch.hideModules !== undefined) applyHideModules(entry, patch.hideModules); + // A clip's chapter name beside its other knobs in one patch. + if (patch.chapter !== undefined) applyChapter(entry, patch.chapter); // The live-chat column beside this clip (chat.mjs): true shows it, false is // the explicit no, null/"" removes the key (the default: off). diff --git a/umtool/lib/report/postComboCli.mjs b/umtool/lib/report/postComboCli.mjs @@ -16,7 +16,7 @@ // Plain ESM: the CLI runs it under bare node. import { COMBO_DEFAULTS, COMBO_ITEM_KEYS, comboKnobs, repeatGroups } from "umtool-report-to-video/post-combo"; import { captureOnlyMedia, projectCombos } from "umtool-report-to-video/post-combo-prints"; -import { channelsDirFor, readManifest } from "../projects/report.mjs"; +import { channelsDirFor, channelsLayersFor, hasShadowChannels, readManifest } from "../projects/report.mjs"; import { withEditNotes } from "./edit-guard.mjs"; import { copyFile, mkdir, realpath, stat } from "node:fs/promises"; import path from "node:path"; @@ -45,6 +45,8 @@ export const REPEATS_USAGE = [ " umtool posts attach <project> [<item> … | --all] [--dry-run] [--json]", " a post item with no attachment whose capture holds one (captured after it went in): its media copied in and", " set, as posts reel would have made it -- nothing else of the entry changes. One write (one undo point).", + " The capture is looked for in the project's channels tree, then the archive's (read only: the files are", + " copied into the project); --dry-run prints the tree each file would come from.", ].join("\n"); const OFF = new Set(["off", "no", "false", "0"]); @@ -95,7 +97,7 @@ export async function repeatsView(project, { match = null, cacheDir = undefined, const opts = { channelsDir: corpus, ...(match ? { match } : {}), ...(cacheDir !== undefined ? { cacheDir } : {}) }; const cut = await projectCombos(project.dir, manifest, opts); // The posts whose capture has a file their entry does not carry: in the cut's order, as if they played it. - const captured = await captureOnlyMedia(manifest, { channelsDir: corpus }); + const captured = await captureOnlyMedia(manifest, { channelsDirs: await captureTrees(project, manifest, channelsDir) }); const tl = (manifest.timeline ?? []).map((e) => (captured[e?.id] ? { ...e, media: captured[e.id].map((m) => ({ src: `@capture/${m.slug}/${m.name}`, kind: "capture" })) } : e)); const prints = (id, i) => (captured[id] ? { mediaId: captured[id][i]?.mediaId ?? null, sha256: captured[id][i]?.sha256 ?? null } : cut.prints[`${id}:${i}`]); const all = repeatGroups(tl, prints, { match: cut.match }); @@ -148,8 +150,17 @@ export async function scenesView(project, { channelsDir = null } = {}) { const TIER_WORDS = { "media-id": "X media id", sha256: "same file", audio: "same sound" }; const MATCH_WORDS = { id: "the X media id", file: "the X media id, then the file's bytes", audio: "the X media id, the bytes, then the sound" }; +/** + * Is this ONE path segment -- a capture's file name, a post id, a channel slug as a capture or a manifest gives them? + * Not empty, not `.` or `..`, no separator (either slash) and no NUL: a name is joined into a path in a channels tree + * and in the project, and `../../x` would read, and write, outside both. + */ +export const isPathSegment = (v) => typeof v === "string" && v !== "" && v !== "." && v !== ".." && !/[/\\\0]/.test(v); + /** Copy a capture's file into the project (never through a link out of it); the same size already there is left. */ async function copyIn(projectDir, from, rel) { + // Before anything is made: every segment a plain name (attachFromCaptures checks them too -- this is the writer's own). + if (!rel.split("/").every(isPathSegment)) throw new ComboError(`${JSON.stringify(rel)} is not a path inside the project — not copying`); const to = path.join(projectDir, ...rel.split("/")); const [a, b] = await Promise.all([stat(from).catch(() => null), stat(to).catch(() => null)]); if (a && b && a.size === b.size) return; @@ -160,20 +171,40 @@ async function copyIn(projectDir, from, rel) { } /** + * THE CHANNELS TREES A CAPTURE IS LOOKED FOR IN (12 Nov: a project with a `.shadow-channels` tree saw only that, and + * the captures in the real archive's `channels/<slug>/posts-media/<id>/` were invisible): the project's own tree + * first, then the archive behind it -- as the other readers resolve them (projects/report.mjs channelsLayersFor; + * `provenance.channelsFallback: false` or CHANNELS_FALLBACK=0 keeps it to the project's). READ ONLY toward both: + * attach copies into the project. + * @returns {Promise<string[]>} + */ +async function captureTrees(project, manifest, channelsDir = null, channelsDirs = null) { + if (Array.isArray(channelsDirs) && channelsDirs.length) return channelsDirs; + if (channelsDir) return [channelsDir]; + return channelsLayersFor(project.dir, manifest, { shadowExists: await hasShadowChannels(project.dir) }); +} + +/** A tree in words: the first is the project's own, any after it the archive's. */ +const treeKindOf = (trees, tree) => (trees.indexOf(tree) <= 0 ? "project" : "archive"); + +/** * ATTACH WHAT THE CAPTURES HOLD (`umtool posts attach`): each post item with no * attachment whose capture has one (captured after it went in) gets its media * as `posts reel` would have made it -- the files copied into the project's * posts-media/, measured -- and nothing else of the entry changes (its * paraphrases, narration, knobs kept). One write. `ids` narrows it. + * A capture is looked for in the project's channels tree, then the archive's (captureTrees); each planned item + * says which it came from (`tree`, `treeKind`: project | archive), and `--dry-run` prints it per file. * * @param {{ id: string, dir: string }} project - * @param {{ ids?: string[] | null, dryRun?: boolean, channelsDir?: string | null }} [o] + * @param {{ ids?: string[] | null, dryRun?: boolean, channelsDir?: string | null, channelsDirs?: string[] | null }} [o] + * `channelsDirs`: the trees to look in, in order (default: the project's, then the archive's) */ -export async function attachFromCaptures(project, { ids = null, dryRun = false, channelsDir = null } = {}) { +export async function attachFromCaptures(project, { ids = null, dryRun = false, channelsDir = null, channelsDirs = null } = {}) { const manifest = await readManifest(project.dir); if (!manifest) throw new ComboError(`${project.id} has no manifest`); - const corpus = channelsDir ?? channelsDirFor(project.dir, manifest); - const captured = await captureOnlyMedia(manifest, { channelsDir: corpus }); + const trees = await captureTrees(project, manifest, channelsDir, channelsDirs); + const captured = await captureOnlyMedia(manifest, { channelsDirs: trees }); const tl = Array.isArray(manifest.timeline) ? manifest.timeline : []; const want = ids ? ids.map((r) => tl.find((e) => e?.type === "post" && (e.id === r || String(e.post ?? "").split("/")[1] === r))?.id ?? r) : null; if (want) for (const id of want) if (!tl.some((e) => e?.id === id && e.type === "post")) throw new ComboError(`no post item ${id} in ${project.id}`); @@ -184,7 +215,11 @@ export async function attachFromCaptures(project, { ids = null, dryRun = false, const postId = String(tl.find((e) => e?.id === id)?.post ?? "").split("/")[1]; const media = []; for (const m of list) { - const from = path.join(corpus, m.slug, "posts-media", postId, m.name); + // A capture's names are data: refused before any file is looked at, in whichever tree it was found. + for (const [what, v] of [["file name", m.name], ["post id", postId], ["channel", m.slug]]) { + if (!isPathSegment(v)) throw new ComboError(`${id}: its capture's ${what} ${JSON.stringify(v ?? null)} is not a plain name (a path separator, "." or "..", or empty) — nothing attached`); + } + const from = path.join(m.tree, m.slug, "posts-media", postId, m.name); if (!(await stat(from).catch(() => null))) continue; const rel = `posts-media/${m.slug}/${postId}/${m.name}`; const probe = await probeMediaFile(from); @@ -202,7 +237,7 @@ export async function attachFromCaptures(project, { ids = null, dryRun = false, } if (!media.length) continue; patches[id] = media.map((x) => x.item); - plan.push({ id, media: media.map((x) => ({ src: x.item.src, kind: x.item.kind, from: x.from })) }); + plan.push({ id, tree: list[0].tree, treeKind: treeKindOf(trees, list[0].tree), media: media.map((x) => ({ src: x.item.src, kind: x.item.kind, from: x.from })) }); } if (dryRun || !plan.length) return { dryRun, attached: plan, result: null, editNotes: null }; for (const p of plan) for (const m of p.media) await copyIn(project.dir, m.from, m.src); @@ -210,6 +245,19 @@ export async function attachFromCaptures(project, { ids = null, dryRun = false, return { dryRun, attached: plan.filter((p) => result.ids.includes(p.id)), result, editNotes }; } +/** What `posts attach` prints: each item's media, and the channels tree each file is read from (a dry run: per file). */ +export function attachLines(r, projectId) { + const out = [`${r.dryRun ? "would attach" : "attached"} the capture's media to ${r.attached.length} post item(s) in ${projectId}`]; + for (const a of r.attached) { + const whose = a.treeKind === "archive" ? "the archive's" : "the project's"; + out.push(` ${a.id} ${a.media.map((m) => `${m.kind} ${m.src}`).join(", ")}`); + if (r.dryRun) for (const m of a.media) out.push(` from ${whose} channels tree: ${m.from}`); + else out.push(` from ${whose} channels tree (${a.tree})`); + } + if (r.result?.snapshot?.rel && !r.result.snapshot.skipped) out.push(` undo point: ${r.result.snapshot.rel} (umtool timeline ${projectId} undo)`); + return out; +} + /** The repeats view as lines. */ export function repeatsLines(v) { const out = []; @@ -262,9 +310,7 @@ async function comboRun(verb, words, flags, { root, json, out, err }) { const r = await attachFromCaptures(project, { ids: items.length ? items : null, dryRun: flags.has("--dry-run") }); if (json) out(JSON.stringify({ ok: true, ...r, result: r.result ? { ids: r.result.ids, snapshot: r.result.snapshot, token: r.result.token } : null }, null, 2)); else { - out(`${r.dryRun ? "would attach" : "attached"} the capture's media to ${r.attached.length} post item(s) in ${project.id}`); - for (const a of r.attached) out(` ${a.id} ${a.media.map((m) => `${m.kind} ${m.src}`).join(", ")}`); - if (r.result?.snapshot?.rel && !r.result.snapshot.skipped) out(` undo point: ${r.result.snapshot.rel} (umtool timeline ${project.id} undo)`); + for (const l of attachLines(r, project.id)) out(l); } return 0; } diff --git a/umtool/lib/report/postComboCli.test.mjs b/umtool/lib/report/postComboCli.test.mjs @@ -8,7 +8,7 @@ import { tmpdir } from "node:os"; import path from "node:path"; import { after, test } from "node:test"; import { postsCommand } from "./postsCli.mjs"; -import { repeatsView } from "./postComboCli.mjs"; +import { attachFromCaptures, attachLines, isPathSegment, repeatsView } from "./postComboCli.mjs"; const ROOT = await mkdtemp(path.join(tmpdir(), "umtool-post-combo-")); after(() => rm(ROOT, { recursive: true, force: true })); @@ -125,3 +125,96 @@ test("posts attach: the capture's media onto the item that carries none, nothing assert.deepEqual(v.groups[0].members.map((m) => `${m.id}:${m.attached ? m.badge : "-"}`), ["p-1:1", "p-2:2", "p-3:3", "p-5:4"]); assert.equal((await run(["attach", "att"])).code, 2, "names the items, or --all"); }); + +test("posts attach reads every channels tree: the project's first, then the archive's -- read only; a dry run says which tree each file came from", async () => { + const { execFileSync } = await import("node:child_process"); + const { readdir, stat } = await import("node:fs/promises"); + const p = await project("trees"); + // The project's own tree (a .shadow-channels) holds no capture of post 3; the ARCHIVE's does. + const shadow = path.join(p.dir, ".shadow-channels"); + await mkdir(path.join(shadow, "obv-x"), { recursive: true }); + const archive = path.join(ROOT, "archive-channels"); + const capDir = path.join(archive, "obv-x", "posts-media", "3"); + await mkdir(capDir, { recursive: true }); + const gif = path.join(capDir, "3_1.mp4"); + execFileSync("ffmpeg", ["-v", "error", "-y", "-f", "lavfi", "-i", "testsrc=size=160x90:rate=10:duration=1", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-an", gif]); + await writeFile(path.join(capDir, "capture.json"), JSON.stringify({ media: [{ name: "3_1.mp4", url: "https://video.twimg.com/tweet_video/C.mp4" }] })); + const listing = async () => (await readdir(archive, { recursive: true })).sort().join("\n"); + const archiveBefore = await listing(); + const mtimeBefore = (await stat(gif)).mtimeMs; + + // Only the project's tree, as before: nothing to attach. + assert.deepEqual((await attachFromCaptures(p, { channelsDirs: [shadow], dryRun: true })).attached, []); + // Both: found in the archive, and said so. + const dry = await attachFromCaptures(p, { channelsDirs: [shadow, archive], dryRun: true }); + assert.deepEqual(dry.attached.map((a) => [a.id, a.treeKind, a.tree]), [["p-3", "archive", archive]]); + assert.equal(dry.attached[0].media[0].from, gif); + const lines = attachLines(dry, "trees"); + assert.match(lines[0], /would attach the capture's media to 1 post item\(s\) in trees/); + assert.ok(lines.includes(` from the archive's channels tree: ${gif}`), lines.join("\n")); + assert.equal((await manifest(p)).timeline.find((e) => e.id === "p-3").media, undefined, "a dry run writes nothing"); + + // The project's own capture wins when both hold one. + const own = path.join(shadow, "obv-x", "posts-media", "3"); + await mkdir(own, { recursive: true }); + execFileSync("ffmpeg", ["-v", "error", "-y", "-f", "lavfi", "-i", "testsrc=size=160x90:rate=10:duration=1", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-an", path.join(own, "3_9.mp4")]); + await writeFile(path.join(own, "capture.json"), JSON.stringify({ media: [{ name: "3_9.mp4", url: "https://video.twimg.com/tweet_video/D.mp4" }] })); + const both = await attachFromCaptures(p, { channelsDirs: [shadow, archive], dryRun: true }); + assert.deepEqual(both.attached.map((a) => [a.treeKind, a.media[0].src]), [["project", "posts-media/obv-x/3/3_9.mp4"]]); + assert.ok(attachLines(both, "trees").some((l) => l.startsWith(" from the project's channels tree: "))); + await rm(own, { recursive: true, force: true }); + + // The write: copied INTO the project; the archive is exactly as it was. + const done = await attachFromCaptures(p, { channelsDirs: [shadow, archive] }); + assert.deepEqual(done.attached.map((a) => a.id), ["p-3"]); + assert.ok(attachLines(done, "trees").includes(` from the archive's channels tree (${archive})`)); + const e = (await manifest(p)).timeline.find((x) => x.id === "p-3"); + assert.equal(e.media[0].src, "posts-media/obv-x/3/3_1.mp4"); + const copied = await stat(path.join(p.dir, "posts-media", "obv-x", "3", "3_1.mp4")); + assert.ok(copied.isFile() && !copied.isSymbolicLink()); + assert.equal(await listing(), archiveBefore, "nothing added to the archive"); + assert.equal((await stat(gif)).mtimeMs, mtimeBefore, "its file untouched"); +}); + +test("posts attach refuses a capture whose file name is not a plain name, before any file is touched -- in either tree", async () => { + const { readdir } = await import("node:fs/promises"); + for (const bad of ["../../x", "a/b", "..", ".", "a\\b"]) assert.equal(isPathSegment(bad), false, bad); + assert.equal(isPathSegment(""), false); + assert.equal(isPathSegment("3_1.mp4"), true); + let n = 0; + for (const bad of ["../../x", "a/b", ".."]) { + for (const where of ["project", "archive"]) { + n += 1; + const p = await project(`bad${n}`); + const shadow = path.join(p.dir, ".shadow-channels"); + const archive = path.join(ROOT, `bad-archive-${n}`); + const tree = where === "project" ? shadow : archive; + const capDir = path.join(tree, "obv-x", "posts-media", "3"); + await mkdir(capDir, { recursive: true }); + await mkdir(shadow, { recursive: true }); + await mkdir(archive, { recursive: true }); + // A file where the name points, so only the check stands between it and a read. + await writeFile(path.join(tree, "x"), "OUTSIDE"); + await writeFile(path.join(capDir, "capture.json"), JSON.stringify({ media: [{ name: bad, url: "https://video.twimg.com/tweet_video/C.mp4" }] })); + const before = (await readdir(p.dir, { recursive: true })).sort().join("\n"); + const manifestBefore = await readFile(path.join(p.dir, "video.manifest.json"), "utf8"); + for (const dryRun of [true, false]) { + await assert.rejects(attachFromCaptures(p, { channelsDirs: [shadow, archive], dryRun }), (e) => { + assert.match(e.message, /p-3: its capture's file name .* is not a plain name/, `${bad} in the ${where}'s tree`); + return true; + }); + } + assert.equal((await readdir(p.dir, { recursive: true })).sort().join("\n"), before, "no directory made in the project"); + assert.equal(await readFile(path.join(p.dir, "video.manifest.json"), "utf8"), manifestBefore); + // The CLI says it and exits 2. + if (where === "project") { + const m = JSON.parse(manifestBefore); + m.provenance.channelsDir = shadow; + await writeFile(path.join(p.dir, "video.manifest.json"), JSON.stringify(m, null, 2)); + const r = await run(["attach", `bad${n}`, "--all", "--dry-run"]); + assert.equal(r.code, 2, r.out + r.err); + assert.match(r.err, /is not a plain name/); + } + } + } +}); diff --git a/umtool/lib/report/quoteCheck.mjs b/umtool/lib/report/quoteCheck.mjs @@ -23,7 +23,8 @@ // --quote-ruled`: heard and ruled by a person). // // Plain ESM: the CLI runs under bare node; the app reads the file. -import { mkdir, readFile, rename, writeFile } from "node:fs/promises"; +import { mkdir, readFile, realpath, rename, rmdir, writeFile } from "node:fs/promises"; +import os from "node:os"; import path from "node:path"; import { createCueSource, siteOriginFromManifest } from "umtool-report-to-video/cues"; import { cueWords, findQuote, ON_TIME_S, quoteOffset } from "umtool-report-to-video/quote-in-audio"; @@ -234,16 +235,90 @@ async function editorWords(req, { emit }) { } /** + * WHERE THE EDITOR WRITES THE WORDS (12 Nov): the work files were `<project>/out/quote-check/<clip>.words.json`, and + * a project's `out/` may be a symlink onto the media drive -- inside a corpus location, where the editor rightly + * refuses to write (transcribeFile.ts: `"out" … is inside the corpus`). So the work dir is never under `out/`: + * these, in order, each by its REAL path (a link in the way is followed here, not found out by the editor), the + * next one taken when the editor refuses the one before as inside the corpus -- + * + * <project>/.quote-check/ beside the manifest + * <reports>/.umtool/quote-check/<project>/ umtool's own state, when the project dir itself is in a location + * $XDG_CACHE_HOME|~/.cache/umtool/quote-check/<project>/ + * + * The rows are the project's whichever it is: quote-check.json, beside the manifest. + * @param {string} dir the project's dir + * @param {{ reportsRoot?: string | null, env?: Record<string, string | undefined>, home?: string }} [opts] + * @returns {Promise<string[]>} + */ +export async function quoteCheckWorkDirs(dir, { reportsRoot = null, env = process.env, home = os.homedir() } = {}) { + const real = async (p) => { + // The deepest ancestor that exists, resolved; the rest as named (the dir may not be made yet). + const rest = []; + let cur = path.resolve(p); + for (;;) { + const r = await realpath(cur).catch(() => null); + if (r) return path.join(r, ...rest); + const up = path.dirname(cur); + if (up === cur) return path.resolve(p); + rest.unshift(path.basename(cur)); + cur = up; + } + }; + const name = path.basename(path.resolve(dir)); + const cache = env.XDG_CACHE_HOME && path.isAbsolute(env.XDG_CACHE_HOME) ? env.XDG_CACHE_HOME : path.join(home, ".cache"); + const all = [ + path.join(dir, ".quote-check"), + path.join(reportsRoot ?? path.dirname(path.resolve(dir)), ".umtool", "quote-check", name), + path.join(cache, "umtool", "quote-check", name), + ]; + const out = []; + for (const p of all) { + const r = await real(p); + if (!out.includes(r)) out.push(r); + } + return out; +} + +/** + * Is this the editor's refusal of an `out` inside the corpus? The controller's sentence is + * `"out" <path> is inside the corpus (<root>) — this command never writes there; pick a path outside it` + * (common/controller/transcribeFile.ts checkTranscribeFileRequest), answered at once as HTTP 400 `{ error }` by + * POST /api/ops/transcribe (the route's jobResponse), which askEditorOp throws as `the editor refused it (<route>, + * HTTP 400): <error>`. Matched on the part that says what it is -- `"out" … is inside the corpus` -- not on the path, + * the root or the advice after the dash (quoteCheck.test.mjs holds the controller's source to these words). + */ +export const OUT_INSIDE_CORPUS = /"out" .* is inside the corpus\b/; +const insideCorpus = (e) => OUT_INSIDE_CORPUS.test(e instanceof Error ? e.message : String(e)); + +/** + * Take back the directories a refused work dir cost: `dir` and every parent made for it, up to `first` (what + * mkdir's `recursive` says it made first) -- each only when empty (rmdir), so nothing that was there is touched + * and no empty `.quote-check/` is left inside a corpus location. + */ +async function unmake(dir, first) { + if (!first) return; + const stop = path.resolve(first); + let cur = path.resolve(dir); + for (;;) { + if (cur !== stop && !cur.startsWith(stop + path.sep)) return; + if (!(await rmdir(cur).then(() => true, () => false))) return; + if (cur === stop) return; + cur = path.dirname(cur); + } +} + +/** * Check the planned clips; merge the rows into quote-check.json. * @param {string} dir * @param {Record<string, any>} manifest * @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() } = {}) { +export async function runQuoteCheck(dir, manifest, plan, { transcribe = editorWords, cuesOf = null, log = () => {}, now = () => new Date(), workDirs = null, reportsRoot = null } = {}) { const doc = await readQuoteCheck(dir); - const work = path.join(dir, "out", "quote-check"); - await mkdir(work, { recursive: true }); + // 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; const cueSource = cuesOf ? null : createCueSource({ channelsDirs: channelsLayersFor(dir, manifest, { shadowExists: await hasShadowChannels(dir) }), siteOrigin: siteOriginFromManifest(manifest) }); @@ -271,10 +346,24 @@ export async function runQuoteCheck(dir, manifest, plan, { transcribe = editorWo log(rowLine(p.id, results[p.id])); continue; } - const out = path.join(work, `${p.id}.words.json`); let words; try { - words = await transcribe({ path: p.source.path, start: p.file.start, end: p.file.end, out }, { emit: () => {} }); + for (;;) { + // The editor needs the directory to be there (it refuses an `out` whose directory is not), so it is made + // -- and taken back, with any parent made for it, the moment the editor says it is inside the corpus. + const made = await mkdir(works[wi], { recursive: true }); + const out = path.join(works[wi], `${p.id}.words.json`); + try { + words = await transcribe({ path: p.source.path, start: p.file.start, end: p.file.end, out }, { emit: () => {} }); + break; + } catch (e) { + if (!insideCorpus(e)) throw e; + await unmake(works[wi], made); + if (wi + 1 >= works.length) throw e; + log(`quote-check: the editor will not write in ${works[wi]} (inside the corpus) -- its work files go to ${works[wi + 1]}`); + wi += 1; + } + } } catch (e) { log(`${p.id}: the transcription failed: ${e instanceof Error ? e.message : String(e)}`); continue; @@ -287,7 +376,7 @@ export async function runQuoteCheck(dir, manifest, plan, { transcribe = editorWo } const merged = { version: 1, checkedAt: now().toISOString(), clips: { ...doc.clips, ...results } }; const file = await writeQuoteCheck(dir, merged); - return { file, doc: merged, results }; + return { file, doc: merged, results, work: works[wi] }; } // --------------------------------------------------------------------------- @@ -301,6 +390,9 @@ export const QUOTE_CHECK_USAGE = [ `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", `cues: ok (within ${ON_TIME_S} s), moved (heard elsewhere: umtool window <p> <clip> --align), not-found.`, + "The editor's work files (<clip>.words.json) go to <project>/.quote-check/ -- never under out/, which may be a link", + "onto a media drive the editor will not write in; were the project itself inside the corpus, to umtool's own", + "<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).", ].join("\n"); @@ -351,12 +443,13 @@ export async function quoteCheckCommand(args, { reportsRoot = REPORTS_ROOT, log 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}`); - const { file, results } = await runQuoteCheck(project.dir, manifest, plan, { + const { file, results, work } = await runQuoteCheck(project.dir, manifest, plan, { ...(transcribe ? { transcribe } : {}), ...(cuesOf ? { cuesOf } : {}), + reportsRoot, log: json ? () => {} : log, }); - if (json) log(JSON.stringify({ project: project.id, file, clips: results }, null, 1)); + if (json) log(JSON.stringify({ project: project.id, 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/quoteCheck.test.mjs b/umtool/lib/report/quoteCheck.test.mjs @@ -185,3 +185,135 @@ test("prep --status says the quote check's verdicts on the clips as they are now await rm(p.root, { recursive: true, force: true }); } }); + +test("the editor's work files are never under out/: <project>/.quote-check by its real path, and the next dir when the editor refuses one as inside the corpus", async () => { + const { quoteCheckWorkDirs } = await import("./quoteCheck.mjs"); + const { realpath, symlink, stat } = await import("node:fs/promises"); + const p = await project(); + try { + const root = await realpath(p.root); + // out/ linked onto "the media drive" (rev9-a9's project): nothing of the check is written through it. + const drive = path.join(root, "drive", "diet-out"); + await mkdir(path.dirname(drive), { recursive: true }); + const { rename } = await import("node:fs/promises"); + await rename(path.join(p.dir, "out"), drive); + await symlink(drive, path.join(p.dir, "out")); + const dirs = await quoteCheckWorkDirs(p.dir, { reportsRoot: p.root, env: { XDG_CACHE_HOME: path.join(root, "cache") } }); + assert.deepEqual(dirs, [ + path.join(root, "diet", ".quote-check"), + path.join(root, ".umtool", "quote-check", "diet"), + path.join(root, "cache", "umtool", "quote-check", "diet"), + ]); + const plan = await planQuoteCheck(p.dir, p.manifest, { channelsDirs: [p.channels] }); + const outs = []; + const seen = async (req) => { outs.push(req.out); return fakeTranscribe(req); }; + const first = await runQuoteCheck(p.dir, p.manifest, plan, { transcribe: seen, cuesOf: fakeCues, workDirs: dirs }); + assert.equal(first.work, dirs[0]); + assert.ok(outs.length >= 2 && outs.every((o) => path.dirname(o) === dirs[0]), outs.join("\n")); + assert.equal(await stat(path.join(drive, "quote-check")).catch(() => null), null, "nothing under out/"); + assert.equal(first.doc.clips.c44.status, "ok"); + + // The project dir itself inside a location: the editor refuses the first dir, the check moves on and still lands its rows. + const lines = []; + const refused = []; + const picky = async (req) => { + if (path.dirname(req.out) === dirs[0]) { + refused.push(req.out); + throw new Error(`the editor refused it (/api/ops/transcribe, HTTP 400): "out" ${req.out} is inside the corpus (/mnt/media) — this command never writes there; pick a path outside it`); + } + outs.push(req.out); + return fakeTranscribe(req); + }; + outs.length = 0; + const second = await runQuoteCheck(p.dir, p.manifest, plan, { transcribe: picky, cuesOf: fakeCues, workDirs: dirs, log: (l) => lines.push(l) }); + assert.equal(refused.length, 1, "asked once, not once per clip"); + assert.equal(second.work, dirs[1]); + assert.ok(outs.length >= 2 && outs.every((o) => path.dirname(o) === dirs[1])); + assert.match(lines.join("\n"), /the editor will not write in .*\.quote-check \(inside the corpus\) -- its work files go to .*\.umtool\/quote-check\/diet/); + assert.equal(second.doc.clips.c43.status, "moved"); + assert.deepEqual(await readQuoteCheck(p.dir), second.doc); + // Any other failure is that clip's, as before -- no hopping dirs. + const broken = await runQuoteCheck(p.dir, p.manifest, plan, { transcribe: async () => { throw new Error("no engine"); }, cuesOf: fakeCues, workDirs: dirs, log: (l) => lines.push(l) }); + assert.equal(broken.work, dirs[0]); + assert.match(lines.join("\n"), /c43: the transcription failed: no engine/); + } finally { + await rm(p.root, { recursive: true, force: true }); + } +}); + +test("through the real editor client: the editor's own refusal reaches the fall-through, and the refused work dir is taken back -- no empty .quote-check left in the corpus", async () => { + const http = await import("node:http"); + const { stat, readdir } = await import("node:fs/promises"); + const { OUT_INSIDE_CORPUS, quoteCheckWorkDirs } = await import("./quoteCheck.mjs"); + // The controller's sentence, as the editor's source has it: the words the fall-through matches are there. + const controller = await readFile(path.join(HERE, "..", "..", "..", "common", "controller", "transcribeFile.ts"), "utf8"); + const sentence = /error: `("out" \$\{req\.out\} is inside the corpus \(\$\{root\}\)[^`]*)`/.exec(controller); + assert.ok(sentence, "transcribeFile.ts still refuses an out inside the corpus in these words"); + const refusalFor = (out, root) => sentence[1].replace("${req.out}", out).replace("${root}", root); + assert.match(refusalFor("/mnt/media/x/.quote-check/c43.words.json", "/mnt/media"), OUT_INSIDE_CORPUS); + assert.doesNotMatch('"out": the directory /x does not exist', OUT_INSIDE_CORPUS); + assert.doesNotMatch("editor job abc failed — out of memory inside the corpus reader", OUT_INSIDE_CORPUS); + + const p = await project(); + const corpus = p.dir; // the project itself sits in a "location": its .quote-check is refused + const asked = []; + // The editor, stood in for over HTTP: /api/ops/transcribe answers as ops' jobResponse does (400 { ok: false, error } + // for a refusal, { ok: true, jobId } and the words written to `out` otherwise), /api/ops/job/<id> a finished job. + const server = http.createServer((req, res) => { + let text = ""; + req.on("data", (d) => (text += d)); + req.on("end", async () => { + const send = (status, body) => { res.writeHead(status, { "content-type": "application/json" }); res.end(JSON.stringify(body)); }; + if (req.method === "POST" && req.url === "/api/ops/transcribe") { + const body = JSON.parse(text); + asked.push(body.out); + if (body.out.startsWith(corpus + path.sep)) return send(400, { ok: false, error: refusalFor(body.out, corpus) }); + if (!(await stat(path.dirname(body.out)).catch(() => null))) return send(400, { ok: false, error: `"out": the directory ${path.dirname(body.out)} does not exist` }); + const words = await fakeTranscribe(body); + await writeFile(body.out, JSON.stringify({ words })); + return send(200, { ok: true, jobId: `j${asked.length}` }); + } + if (req.method === "GET" && req.url.startsWith("/api/ops/job/")) return send(200, { ok: true, job: { status: "done" }, tail: [] }); + return send(404, { ok: false, error: "no such route" }); + }); + }); + await new Promise((r) => server.listen(0, "127.0.0.1", r)); + const env = { url: process.env.ARCHILYZER_EDITOR_URL, token: process.env.WORKER_TOKEN }; + process.env.ARCHILYZER_EDITOR_URL = `http://127.0.0.1:${server.address().port}`; + process.env.WORKER_TOKEN = "test-token"; + try { + const dirs = await quoteCheckWorkDirs(p.dir, { reportsRoot: p.root, env: { XDG_CACHE_HOME: path.join(p.root, "cache") } }); + const plan = (await planQuoteCheck(p.dir, p.manifest, { channelsDirs: [p.channels] })).filter((r) => r.id !== "c43"); + const lines = []; + // No `transcribe` given: runQuoteCheck's own editorWords, askEditorOp and all. + const r = await runQuoteCheck(p.dir, p.manifest, plan, { cuesOf: fakeCues, workDirs: dirs, log: (l) => lines.push(l) }); + assert.equal(asked[0], path.join(dirs[0], "c44.words.json"), "the project's .quote-check is asked first"); + assert.equal(asked[1], path.join(dirs[1], "c44.words.json")); + assert.equal(r.work, dirs[1]); + assert.equal(r.doc.clips.c44.status, "ok", lines.join("\n")); + assert.match(lines.join("\n"), /the editor will not write in .* \(inside the corpus\)/); + assert.equal(await stat(dirs[0]).catch(() => null), null, "the refused .quote-check is not left behind"); + assert.ok((await readdir(dirs[1])).includes("c44.words.json")); + + // Every dir refused: each one made is taken back, with the parents made for it; the clip's failure says why. + await rm(dirs[1], { recursive: true, force: true }); + await rm(path.join(p.root, ".umtool"), { recursive: true, force: true }); + const inCorpus = [dirs[0], path.join(p.dir, "deep", "er", "work")]; + lines.length = 0; + const none = await runQuoteCheck(p.dir, p.manifest, plan, { cuesOf: fakeCues, workDirs: inCorpus, log: (l) => lines.push(l) }); + assert.match(lines.join("\n"), /c44: the transcription failed: the editor refused it \(\/api\/ops\/transcribe, HTTP 400\): "out" .* is inside the corpus/); + assert.equal(await stat(dirs[0]).catch(() => null), null); + assert.equal(await stat(path.join(p.dir, "deep")).catch(() => null), null, "the parents made for it too"); + assert.equal(none.results.c44, undefined); + // A work dir that was already there, with a file in it, is never removed. + await mkdir(dirs[0], { recursive: true }); + await writeFile(path.join(dirs[0], "kept.txt"), "x"); + await runQuoteCheck(p.dir, p.manifest, plan, { cuesOf: fakeCues, workDirs: [dirs[0]], log: () => {} }); + assert.ok((await readdir(dirs[0])).includes("kept.txt")); + } finally { + if (env.url === undefined) delete process.env.ARCHILYZER_EDITOR_URL; else process.env.ARCHILYZER_EDITOR_URL = env.url; + if (env.token === undefined) delete process.env.WORKER_TOKEN; else process.env.WORKER_TOKEN = env.token; + await new Promise((r) => server.close(r)); + await rm(p.root, { recursive: true, force: true }); + } +}); diff --git a/umtool/lib/report/takeMaker.mjs b/umtool/lib/report/takeMaker.mjs @@ -366,6 +366,9 @@ export function withPatchEntries(takeTimeline, baseTimeline, ids) { * CLIPPED to the steps inside it -- the window keeps a straddling clip * (windowEntries), so it keeps the part of the claim that clip carries; * a goalpost with no step inside is dropped. + * - an effect's clip list (`render.chrome.fx`): `kineticQuote.clips`, `redact.clips` and `glitch.clips` keep the + * clips inside (a glitch's only with a clip right before it: it tears at that cut), `thenNow.pairs` the pairs + * with both ends inside; an effect left with none is off in the window. * * The kept ones need no re-timing: each names a clip by id, and its `t` is a * source second of that clip, which the window renders whole. @@ -391,6 +394,35 @@ export function windowManifest(manifest, ids) { }); } } + // The effects that name clips (fx.mjs validateFxEntries refuses a name the cut does not hold -- rev9-a9, 12 Nov: + // `take --preview --at … --dur …` was refused with "render.chrome.fx.glitch.clips names k06, which is not a clip + // of the cut"). A list keeps the clips inside; an effect left naming none is off in the window (an empty list is + // not one fx.mjs takes). The glitch tears at the cut INTO a clip, so a named clip stays only with a clip right + // before it in the window; a then/now pair needs both its ends. + const fx = m.render?.chrome?.fx; + if (isObj(fx)) { + const at = new Map(m.timeline.map((e, i) => [e?.id, i])); + const isClip = (id) => typeof id === "string" && m.timeline[at.get(id)]?.type === "clip"; + for (const k of ["kineticQuote", "redact"]) { + if (!isObj(fx[k]) || !Array.isArray(fx[k].clips)) continue; + const clips = fx[k].clips.filter(isClip); + if (clips.length) fx[k].clips = clips; + else delete fx[k]; + } + // Only a glitch on "clips" reads its list (fx.mjs); in another mode the list is not looked at, so it is left + // alone -- and the glitch with it. + if (isObj(fx.glitch) && fx.glitch.on === "clips" && Array.isArray(fx.glitch.clips)) { + const clips = fx.glitch.clips.filter((id) => isClip(id) && m.timeline[at.get(id) - 1]?.type === "clip"); + if (clips.length) fx.glitch.clips = clips; + else delete fx.glitch; + } + if (isObj(fx.thenNow) && Array.isArray(fx.thenNow.pairs)) { + const pairs = fx.thenNow.pairs.filter((p) => !isObj(p) || (isClip(p.then) && isClip(p.now))); + if (pairs.length) fx.thenNow.pairs = pairs; + else delete fx.thenNow; + } + if (!Object.keys(fx).length) delete m.render.chrome.fx; + } return m; } diff --git a/umtool/lib/report/takeMaker.test.mjs b/umtool/lib/report/takeMaker.test.mjs @@ -32,6 +32,7 @@ import { } from "./takeMaker.mjs"; import { listTakes, readVerdicts, setTakeVerdict } from "./takes.mjs"; import { validateDeckClaims, validateDeckMarkers } from "umtool-report-to-video/deck"; +import { validateFxEntries } from "umtool-report-to-video/fx"; import { PROJECT_KINDS } from "../projects/kinds.mjs"; // The kind takes are made of, from the registry (never its id spelled here). @@ -562,6 +563,54 @@ test("windowManifest: markers and claim checks outside the window are dropped; a assert.equal(all.render.chrome.deck.claims[2].steps.length, 2); }); +test("windowManifest: an effect's clip list keeps the window's clips -- a glitch's with a clip before it, a then/now pair with both ends -- and an effect left with none is off", () => { + const clipIds = ["k01", "k02", "k03", "k04", "k05", "k06"]; + const manifest = { + ...MANIFEST, + timeline: clipIds.map((id, i) => clip(id, 10 * i, 10 * i + 5)), + render: { + ...MANIFEST.render, + chrome: { + engine: "hyperframes", layout: "deck", deck: {}, + fx: { + glitch: { on: "clips", clips: ["k02", "k03", "k06"] }, + thenNow: { pairs: [{ then: "k02", now: "k03" }, { then: "k05", now: "k06" }] }, + kineticQuote: { clips: ["k01", "k03"] }, + redact: { clips: ["k06"] }, + wipe: {}, + }, + }, + }, + }; + const before = JSON.stringify(manifest); + // The whole manifest windowed as-was is what the build refused (rev9-a9: "names k06, which is not a clip of the cut"). + const naive = { ...manifest, timeline: manifest.timeline.filter((e) => ["k02", "k03", "k04"].includes(e.id)) }; + assert.match(validateFxEntries(naive, { schedule: null }).join("\n"), /render\.chrome\.fx\.glitch\.clips names k06, which is not a clip of the cut/); + const m = windowManifest(manifest, ["k02", "k03", "k04"]); + const fx = m.render.chrome.fx; + // k02 opens the window: no clip before it, no cut to tear at. + assert.deepEqual(fx.glitch, { on: "clips", clips: ["k03"] }); + assert.deepEqual(fx.thenNow.pairs, [{ then: "k02", now: "k03" }]); + assert.deepEqual(fx.kineticQuote.clips, ["k03"]); + assert.equal("redact" in fx, false, "it named only a clip outside: off in the window"); + assert.deepEqual(fx.wipe, {}, "an effect that names no clip is as it was"); + assert.deepEqual(validateFxEntries(m, { schedule: null }), []); + assert.equal(JSON.stringify(manifest), before, "the project's manifest is not touched"); + // A window with none of them: the effects are off, the rest of the chrome as it was. + const none = windowManifest(manifest, ["k04"]); + assert.deepEqual(none.render.chrome.fx, { wipe: {} }); + assert.deepEqual(validateFxEntries(none, { schedule: null }), []); + // The full window keeps every one. + assert.deepEqual(windowManifest(manifest, clipIds).render.chrome.fx, manifest.render.chrome.fx); + // A glitch in another mode never reads its list (fx.mjs): the window leaves it, and the glitch, as they were. + const byYear = { ...manifest, render: { ...manifest.render, chrome: { ...manifest.render.chrome, fx: { glitch: { on: "year", clips: ["k06"] } } } } }; + assert.deepEqual(windowManifest(byYear, ["k02", "k03", "k04"]).render.chrome.fx, { glitch: { on: "year", clips: ["k06"] } }); + const noMode = { ...manifest, render: { ...manifest.render, chrome: { ...manifest.render.chrome, fx: { glitch: { clips: ["k06"] } } } } }; + assert.deepEqual(windowManifest(noMode, ["k02", "k03", "k04"]).render.chrome.fx, { glitch: { clips: ["k06"] } }); + // A pair cut by the window's edge is dropped, the other kept. + assert.deepEqual(windowManifest(manifest, ["k03", "k04", "k05", "k06"]).render.chrome.fx.thenNow.pairs, [{ then: "k05", now: "k06" }]); +}); + test("withPatchEntries: a clip only the take's patch adds stays in the window beside the covered clip before it", () => { const base = [{ id: "a" }, { id: "b" }, { id: "c" }, { id: "d" }]; // The patch adds x after b (covered), y after x, z after d (not covered). diff --git a/umtool/report-to-video/chrome-instruments.mjs b/umtool/report-to-video/chrome-instruments.mjs @@ -581,7 +581,8 @@ export const CALLOUT_HOLD = 2.2; * The remembered weight's cues in the looks other than the long needle (dialParts, `deck.dial.rememberedAs`): its * rim marker and its flag (or its readout line) up while it is the latest remembered; with "callout", first the * ghost needle sweeping from where the needle stands to the value and the label held CALLOUT_HOLD s. In the finale, - * the last one's, all at once. + * the last one's, all at once. The finale never plays the callout: its labels and its ghost needle are hidden there, the + * rim's marker and flag stay. */ function rememberedCues(L, { track, scale, cfg, k, finale }) { const M = INSTRUMENT_MOTION; @@ -594,7 +595,9 @@ function rememberedCues(L, { track, scale, cfg, k, finale }) { R.forEach((g, j) => { L.set(k(`gk${j}`), { rotation: dialAngle(g.value, scale), autoAlpha: 0 }); L.set(k(`${label}${j}`), { autoAlpha: 0 }); - if (call) L.set(k(`gc${j}`), { autoAlpha: 0 }); + // The callout's label is drawn whenever the look is "callout" (dialParts), so it is hidden whenever it is drawn: + // in the finale too, where nothing calls it up (rev9-a9: every box sat at its CSS default over the hub). + if (mode === "callout") L.set(k(`gc${j}`), { autoAlpha: 0 }); if (finale && j !== R.length - 1) return; const next = finale ? null : R[j + 1]; for (const key of [`gk${j}`, `${label}${j}`]) { @@ -602,9 +605,10 @@ function rememberedCues(L, { track, scale, cfg, k, finale }) { if (next) L.add(k(key), startOf(next), M.fade * 0.6, { autoAlpha: 0 }, "power1.in"); } }); + // The ghost needle likewise: drawn with the look, hidden with it -- the finale never sweeps it. + if (mode === "callout") L.set(k("gn"), { rotation: dialAngle(R[0].value, scale), autoAlpha: 0 }); if (!call) return; const a0 = dialAngle(scale.min, scale); - L.set(k("gn"), { rotation: dialAngle(R[0].value, scale), autoAlpha: 0 }); R.forEach((g, j) => { // From where the needle stands as he says it (his stated weight in force then; the scale's foot before one). const cur = [...track.current].filter((c) => c.t <= g.t + 1e-9 && Number.isFinite(c.value)).pop(); diff --git a/umtool/report-to-video/chrome-measure-extras.mjs b/umtool/report-to-video/chrome-measure-extras.mjs @@ -17,7 +17,7 @@ import { rgba } from "./chrome-deck.mjs"; import { compileCues, cuePageHtml, esc, INSTANT, joinSpans, r4, spanEvents } from "./chrome-cues.mjs"; import { daysBetween, daysLeftText, daysText, DIET_TAG, dietDays, dietStates, dietTagStep, goalStates, goalText, GOALS_SHELF, jitter, measureBox, measureExtraGeometry, measureOf, MEASURE_BOXES, promiseStripRect, promiseStripType, - MEASURE_DODGE_MOVE, measurePlacements, monthYear, peakStates, promiseStates, shortDate, streakStates, upSpans, weightText, + MEASURE_DODGE_MOVE, measurePlacements, monthYear, peakStates, promiseStates, shortDate, stampNoteClause, stampNoteLine, streakStates, upSpans, weightText, } from "./measure-extras.mjs"; import { dietTagWidth, MEASURE_RED, resolveMeasureExtra, SHELF_POSITION } from "./modules/measure-extras-settings.mjs"; import { dialFinaleGeometry, dialFinaleHandoff } from "./chrome-instruments.mjs"; @@ -643,7 +643,7 @@ function promiseStrip(states, place, cfg, render, opts, items) { const claim = r.claim ? `<span class="sp">·</span><span>${esc(cfg.claimVerb)} ${esc(shortDate(r.claim.paidOn ?? r.claim.date))} by @${esc(handleOf(r.claim.speaker, cfg, opts))}</span>` : ""; const o = r.outcome; const status = o && o.kind !== "kept" - ? `<span class="no">${o.kind === "refunded" ? "refunded" : "withdrawn"} · no video</span>` + ? `<span class="no">${o.kind === "refunded" ? "refunded" : "withdrawn"} · ${esc(stampNoteClause(o))}</span>` : r.kept ? `<span class="ok">${esc(cfg.kept)}</span>` : `<span class="no">${esc(cfg.broken)}</span>`; const html = `<div class="sl" data-k="${k}"><span>${esc(r.what)} ${esc(cfg.verb)} ${esc(shortDate(r.said))}</span>${claim}<span class="sp">·</span><b>${esc(days)}</b><span class="sp">·</span>${status}</div>`; items.push({ key: k, gate: [k, "autoAlpha"], html }); @@ -725,7 +725,7 @@ export function promiseHtml(schedule, render, opts = {}) { const o = r.outcome; if (o && o.kind !== "kept") { const word = o.kind === "refunded" ? "Refunded" : "Withdrawn"; - status = `<div class="stamp ${esc(o.kind)}" data-k="${k}o"><div class="sw">${word}</div><div class="ss">${o.date ? `by ${esc(shortDate(o.date))} · ` : ""}no video</div></div>`; + status = `<div class="stamp ${esc(o.kind)}" data-k="${k}o"><div class="sw">${word}</div><div class="ss">${esc(stampNoteLine(o))}</div></div>`; } else status = `<div class="pill">${esc(r.kept ? cfg.kept : cfg.broken)}</div>`; let q; if (r.word) { diff --git a/umtool/report-to-video/goal-base-max-days.test.mjs b/umtool/report-to-video/goal-base-max-days.test.mjs @@ -0,0 +1,89 @@ +// `deck.goals.baseMaxDays` (rev9-a9, 12 Nov): a loss goal's base is the latest weight he gave by the goal's date -- +// however long before. On the real record that put "(FROM 368)" on a goal set eight years after he said 368. With +// the knob a base counts only when its weight was SAID at most that many days before the goal; a staler one is no +// base -- no "(FROM …)" on the note, no target and no tick on the dial. Unset, every base counts, as before. +import assert from "node:assert/strict"; +import test from "node:test"; + +import { goalMarks, goalWords } from "./chrome-instruments.mjs"; +import { estimateSchedule, validateChrome } from "./deck.mjs"; +import { goalStates } from "./measure-extras.mjs"; +import { goalBoard } from "./measure-goals.mjs"; +import { goalBaseMaxDays, measureSlice } from "./measure-slice.mjs"; + +const PAL = { bg: "#0F1312", fg: "#EDF0EC", muted: "#98A29B", accent: "#22AB83", amber: "#E8A33F" }; +const render = (goals) => ({ width: 1920, height: 1080, fps: 30, transition: 0.4, palette: PAL, + chrome: { engine: "hyperframes", layout: "deck", deck: { measure: { scopes: ["weight"], scale: { min: 100, max: 400 }, asOf: "2026-11-12" }, ...(goals === undefined ? {} : { goals }) } } }); +const schema = { kind: "measure", unit: "lb", yMin: 100, yMax: 400, bandGapDays: 60, tracks: [{ key: "weight", role: "value", label: "Weight" }], forms: ["current", "past", "delta", "goal", "goal_loss"] }; +const row = (o) => ({ scope: "weight", scopeBasis: "his words", scopeConfidence: "read", valueKind: "uttered", flags: [], asOf: null, ...o }); +// The gaps the real record has: 8 years, 0 days, 279 days, 434 days. +const LEDGER = [ + row({ id: "a1", date: "2015-01-10", population: "current", value: 368, display: "368 lb", entryId: "c1" }), + row({ id: "g8y", date: "2023-01-08", population: "goal_loss", value: -100, display: "lose 100", entryId: "c2" }), + row({ id: "b1", date: "2023-03-01", population: "current", value: 350, display: "350 lb", entryId: "c3" }), + row({ id: "g0", date: "2023-03-01", population: "goal_loss", value: -50, display: "lose 50", entryId: "c4" }), + row({ id: "g279", date: "2023-12-05", population: "goal_loss", value: -60, display: "lose 60", entryId: "c5" }), + row({ id: "g434", date: "2024-05-08", population: "goal_loss", value: -70, display: "lose 70", entryId: "c6" }), +]; + +function sliced(r, ledger = LEDGER) { + const timeline = Array.from({ length: 7 }, (_, i) => ({ type: "clip", id: `c${i + 1}`, video: "v", start: 10 * i, end: 10 * i + 8, cite: 1, section: 0, quote: "q", onscreen: { title: `Clip ${i + 1}` } })); + const manifest = { slug: "m", title: "M", provenance: {}, render: r, timeline, ledgerSchema: schema, ledger }; + const doc = estimateSchedule(manifest); + const m = measureSlice(manifest, doc, {}); + const goalAfter = (id) => m.state[m.events.findIndex((e) => e.row === id) + 1].goal; + return { m, schedule: { ...doc, measure: m }, goalAfter }; +} + +test("unset: every base counts, however old -- and each carries the date its weight was said", () => { + assert.equal(goalBaseMaxDays({ render: render(undefined) }), null); + assert.equal(goalBaseMaxDays({ render: render(true) }), null); + const { goalAfter } = sliced(render({ base: true })); + assert.deepEqual(goalAfter("g8y").base, { value: 368, row: "a1", from: "stated", date: "2015-01-10" }); + assert.equal(goalAfter("g8y").value, 268); + assert.deepEqual(["g0", "g279", "g434"].map((id) => [goalAfter(id).base.row, goalAfter(id).base.date, goalAfter(id).value]), + [["b1", "2023-03-01", 300], ["b1", "2023-03-01", 290], ["b1", "2023-03-01", 280]]); +}); + +test("365: a base said 0 or 279 days before the goal stays; 434 days and eight years are no base -- no target, his words", () => { + const r = render({ base: true, baseMaxDays: 365 }); + assert.deepEqual(validateChrome(r.chrome, r), []); + const { m, schedule, goalAfter } = sliced(r); + assert.deepEqual(["g8y", "g0", "g279", "g434"].map((id) => goalAfter(id).base?.row ?? null), [null, "b1", "b1", null]); + assert.deepEqual(["g8y", "g0", "g279", "g434"].map((id) => goalAfter(id).value), [null, 300, 290, null]); + assert.equal(goalWords(goalAfter("g8y")), "LOSE 100"); + assert.equal(goalWords(goalAfter("g434")), "LOSE 70"); + assert.match(goalWords(goalAfter("g279")), /^GOAL 290 · LOSE 60/); + // The notes: "(FROM …)" only where the base stands. + const states = goalStates(schedule, r); + const baseOf = (text) => states[states.length - 1].notes.find((n) => n.text === text)?.base ?? null; + assert.deepEqual([baseOf("LOSE 100"), baseOf("LOSE 50"), baseOf("LOSE 60"), baseOf("LOSE 70")], [null, "(FROM 350)", "(FROM 350)", null]); + // The dial: a goal with no base has no weight to mark -- no tick from a base it does not have. + const marks = goalMarks(goalBoard(m), m.scale); + const tick = (id) => marks.find((x) => x.goal.row === id).angle !== null; + assert.deepEqual(["g8y", "g0", "g279", "g434"].map(tick), [false, true, true, false]); + // Unset, all four are marked. + const before = sliced(render({ base: true })).m; + assert.deepEqual(goalMarks(goalBoard(before), before.scale).map((x) => x.angle !== null), [true, true, true, true]); +}); + +test("the day counts from when the weight was SAID, never a remembered weight's as-of; the edge day is inside", () => { + const ledger = [ + row({ id: "p1", date: "2024-06-01", asOf: "2016-01-01", population: "past", value: 390, display: "≈390 lb", entryId: "c1" }), + row({ id: "g", date: "2024-06-10", population: "goal_loss", value: -100, display: "lose 100", entryId: "c2" }), + ]; + const kept = sliced(render({ baseMaxDays: 30 }), ledger).goalAfter("g"); + assert.deepEqual([kept.base.row, kept.base.from, kept.base.date, kept.value], ["p1", "remembered", "2024-06-01", 290]); + assert.equal(sliced(render({ baseMaxDays: 9 }), ledger).goalAfter("g").base.row, "p1", "9 days before, 9 allowed"); + assert.equal(sliced(render({ baseMaxDays: 8 }), ledger).goalAfter("g").base, null); + // 0: only a weight said on the goal's own day. + assert.equal(sliced(render({ baseMaxDays: 0 })).goalAfter("g0").base.row, "b1"); + assert.equal(sliced(render({ baseMaxDays: 0 })).goalAfter("g279").base, null); +}); + +test("the setting is checked: whole days from 0, or null", () => { + const problems = (v) => validateChrome(render({ baseMaxDays: v }).chrome, render({ baseMaxDays: v })).join("\n"); + assert.equal(problems(null), ""); + assert.equal(problems(0), ""); + for (const bad of [-1, 1.5, "365", 40000]) assert.match(problems(bad), /deck\.goals\.baseMaxDays must be null \(every base counts\) or whole days from 0 to 36500/, String(bad)); +}); diff --git a/umtool/report-to-video/ledger-shared.mjs b/umtool/report-to-video/ledger-shared.mjs @@ -102,6 +102,16 @@ export const LEDGER_BUILTIN_KEYS = new Set([ // who said it, when it is not the subject (a promise_claim's counterparty; // such a row never moves the subject's numbers), and the day she says she paid "speaker", "paidOn", - // how a promise ended (a promise_outcome's: kept, refunded, withdrawn) - "outcome", + // how a promise ended (a promise_outcome's: kept, refunded, withdrawn), and the words under its stamp + // (`stampNote`: the promise clock's second line in place of "by <date> · no video") + "outcome", "stampNote", ]); + +/** + * THE WORDS UNDER AN OUTCOME'S STAMP (a promise_outcome row's `stampNote`, 12 Nov): the promise clock wrote + * "by <date> · no video" under REFUNDED whatever the record said. A row's own note is that line instead; the strip + * (one line over a post's card) has room for its first clause only. `fit`: the characters the stamp's line holds + * beside the count and the as-of at the card's design width -- the longest the clock's own words come to ("by 26 Oct + * 2025 · no video" is 25) -- past it the lint warns; `max`: what a row may carry at all. + */ +export const STAMP_NOTE = Object.freeze({ fit: 26, max: 80 }); diff --git a/umtool/report-to-video/ledger-totals.mjs b/umtool/report-to-video/ledger-totals.mjs @@ -46,7 +46,7 @@ import { // Re-exported rather than redefined: every consumer already imports these from // here, and two files owning one vocabulary is the divergence this module was // written to stop. -export { LEDGER_BUILTIN_KEYS, SCOPE_CONFIDENCE, VALUE_KINDS, addDays, chronological, dateKey, dayOf, daysBetween } from "./ledger-shared.mjs"; +export { LEDGER_BUILTIN_KEYS, SCOPE_CONFIDENCE, STAMP_NOTE, VALUE_KINDS, addDays, chronological, dateKey, dayOf, daysBetween } from "./ledger-shared.mjs"; export { EVENTS, MEASURE_PREDICATES, diff --git a/umtool/report-to-video/lint.mjs b/umtool/report-to-video/lint.mjs @@ -53,6 +53,8 @@ // and validateTeasers refuses it.) // - a QR under WARN_QR_PX_PER_MODULE_720P pixels per module at 720p: it // scans on a good screen with a steady hand, not reliably. +// - a promise outcome's `stampNote` (a ledger row's words under its stamp on the promise clock) longer than +// the stamp's one line holds (measure-extras.mjs STAMP_NOTE.fit); // - a tally label wider than its cell: drawn smaller, down to // TALLY_LABEL_FLOOR, then cut with an ellipsis (factcheck.mjs // fitTallyLabel) -- the chrome is never refused for it. @@ -85,6 +87,7 @@ import { validateChrome, validateCutEdits, validateDeckMarkers, validatePosts, validateTeasers, deckClaimNotes, validateDeckClaims, } from "./deck.mjs"; import { tallyLabelNotes, validateClaims } from "./factcheck.mjs"; +import { stampNoteWarnings } from "./measure-extras.mjs"; import { validateClipAudioEntries } from "./clip-audio.mjs"; import { validateClipBlurEntries } from "./clip-blur.mjs"; import { validateGapEntries } from "./gaps.mjs"; @@ -457,6 +460,8 @@ export function lintManifest(manifest, { // A tally label wider than its cell, drawn smaller or cut (factcheck.mjs fitTallyLabel): said, never refused. if (!only) warnings.push(...tallyLabelNotes(render)); warnings.push(...stackedLintWarnings(manifest, { only })); + // A promise outcome's own stamp words (a ledger row's `stampNote`) longer than the stamp's line holds. + if (!only) warnings.push(...stampNoteWarnings(whole)); for (const { where, src } of imageSrcsOf(manifest, { only })) { if (path.isAbsolute(src) || src.startsWith("~")) { diff --git a/umtool/report-to-video/measure-extras.mjs b/umtool/report-to-video/measure-extras.mjs @@ -28,6 +28,7 @@ import { deckGeometry, feedGeometry, instrumentsGeometry, overlayBox, pictureK } from "./deck.mjs"; import { chapterCover, chapterWindows } from "./chrome-story.mjs"; import { dietTagWidth, MEASURE_EXTRAS, MEASURE_POSITIONS, resolveMeasureExtra, SHELF_POSITION } from "./modules/measure-extras-settings.mjs"; +import { STAMP_NOTE } from "./ledger-shared.mjs"; import { resolveShelf } from "./modules/shelf-settings.mjs"; import { stackedOn, stackedStandDowns } from "./vertical-deck.mjs"; @@ -353,6 +354,38 @@ export const PROMISE_SETTLE = 4; /** The count-up to the render date: a day a step, over at most this long. */ export const PROMISE_COUNT_UP = 1.2; +export { STAMP_NOTE }; + +/** The stamp's second line: the outcome's own note, else the clock's words ("by 26 Oct · no video"). */ +export function stampNoteLine(outcome) { + if (typeof outcome?.note === "string" && outcome.note.trim()) return outcome.note.trim(); + return `${outcome?.date ? `by ${shortDate(outcome.date)} · ` : ""}no video`; +} + +/** The strip's words after the outcome's: a note's first clause (to its first · , ; — or " -- "), else "no video". */ +export function stampNoteClause(outcome) { + const note = typeof outcome?.note === "string" ? outcome.note.trim() : ""; + if (!note) return "no video"; + return note.split(/\s+--\s+|\s*[·;—]\s*|,\s+/)[0].trim() || note; +} + +/** + * The lint's warnings for the stamp notes (lint.mjs): a `stampNote` longer than the stamp's line holds -- it is one + * line, never wrapped, so it runs past the stamp's border and into the as-of beside it. + * @returns {string[]} + */ +export function stampNoteWarnings(manifest) { + const out = []; + for (const row of Array.isArray(manifest?.ledger) ? manifest.ledger : []) { + if (row?.population !== "promise_outcome" || typeof row.stampNote !== "string") continue; + const note = row.stampNote.trim(); + if (note.length > STAMP_NOTE.fit) { + out.push(`ledger ${row.id}.stampNote "${note}" is ${note.length} characters: the promise clock's stamp holds about ${STAMP_NOTE.fit} on its second line (it is one line, never wrapped) -- it will run past the stamp; shorten it (umtool ledger <p> set ${row.id} --stampNote "…")`); + } + } + return out; +} + /** The promise outcomes the clock draws (CONTRACT addendum 2): kept stops the count; refunded and withdrawn do not. */ export const PROMISE_OUTCOMES = Object.freeze(["kept", "refunded", "withdrawn"]); @@ -387,7 +420,8 @@ export function promiseStates(schedule, render) { const lastWord = new Map(); const outcomeOf = (p) => { const o = isObj(p.outcome) && PROMISE_OUTCOMES.includes(p.outcome.kind) ? p.outcome : null; - return o ? { kind: o.kind, date: o.date ?? null } : p.kept === true ? { kind: "kept", date: null } : null; + const note = typeof o?.note === "string" && o.note.trim() ? o.note.trim() : null; + return o ? { kind: o.kind, date: o.date ?? null, ...(note ? { note } : {}) } : p.kept === true ? { kind: "kept", date: null } : null; }; const rowsAt = (s, freshRow) => (Array.isArray(s?.promises) ? s.promises : []) .filter((p) => p && p.said) diff --git a/umtool/report-to-video/measure-slice.mjs b/umtool/report-to-video/measure-slice.mjs @@ -115,6 +115,19 @@ export function resolveMeasure(manifest, { asOf = null } = {}) { }; } +/** + * `render.chrome.deck.goals.baseMaxDays` as the slice reads it: whole days (0 = the goal's own day), or null when + * unset (or the goal stack is a bare true/false): how long before a loss goal a weight may have been said and still + * be the goal's base (measureSlice `goalBase`). The goal stack's settings check its shape (measure-extras-settings.mjs). + */ +export function goalBaseMaxDays(manifest) { + const v = manifest?.render?.chrome?.deck?.goals?.baseMaxDays; + return Number.isInteger(v) && v >= 0 ? v : null; +} + +/** A promise_outcome row's `stampNote` -- the words under its stamp on the promise clock -- trimmed, or null. */ +export const stampNoteOf = (row) => (typeof row?.stampNote === "string" && row.stampNote.trim() ? row.stampNote.trim() : null); + // --------------------------------------------------------------------------- // The odometer // --------------------------------------------------------------------------- @@ -493,17 +506,24 @@ export function measureSlice(manifest, schedule, opts = {}) { const starts = readings.filter((r) => r.population === "past" && r.asOf && dateKey(r.date) <= dateKey(d) && dateKey(r.asOf) <= dateKey(run.start) && Math.round(daysBetween(r.asOf, run.start)) <= s.bandGapDays); const last = starts[starts.length - 1]; - if (last) return { value: Number(last.value), row: last.id, from: "runStart" }; + if (last) return { value: Number(last.value), row: last.id, from: "runStart", date: last.date ?? null }; } const known = readings .filter((r) => dateKey(r.date) <= dateKey(d)) .sort((a, b) => dateKey(plotDate(a)).localeCompare(dateKey(plotDate(b))) || dateKey(a.date).localeCompare(dateKey(b.date))); const last = known[known.length - 1]; - return last ? { value: Number(last.value), row: last.id, from: last.population === "past" ? "remembered" : "stated" } : null; + return last ? { value: Number(last.value), row: last.id, from: last.population === "past" ? "remembered" : "stated", date: last.date ?? null } : null; }; + // `deck.goals.baseMaxDays` (rev9-a9, 12 Nov: "LOSE 100 (FROM 368)" off a weight he gave eight years before): a + // base counts only when its weight was SAID -- its row's date, never a remembered one's asOf -- at most that many + // days before the goal's date. A staler one is no base: his words stay the goal, no weight, no tick, no "(FROM …)". + // Unset: every base counts, as before. + const baseMaxDays = goalBaseMaxDays(manifest); + const fresh = (base, row) => baseMaxDays === null || !base || (base.date && Math.round(daysBetween(base.date, row.date)) <= baseMaxDays); const scaleMin = Number.isFinite(settings.scale?.min) ? settings.scale.min : -Infinity; const goalOf = (row) => { let base = row.population === "goal_loss" ? goalBase(row) : null; + if (!fresh(base, row)) base = null; let cell = goalCell(row, base, s); if (base && Number.isFinite(cell.value) && cell.value < scaleMin) { base = null; @@ -515,7 +535,7 @@ export function measureSlice(manifest, schedule, opts = {}) { /** A promise_claim as a promise carries it: who, when said, the day she says she paid, his-or-her words. */ /** A promise_outcome as a promise carries it. */ - const outcomeOf = (row) => ({ kind: row.outcome, date: row.date ?? null, row: row.id }); + const outcomeOf = (row) => ({ kind: row.outcome, date: row.date ?? null, row: row.id, ...(stampNoteOf(row) ? { note: stampNoteOf(row) } : {}) }); const claimOf = (row) => ({ row: row.id, speaker: speakerOf(row), date: row.date ?? null, paidOn: isIso(row.paidOn) ? row.paidOn : null, label: row.label ?? row.display ?? null }); // ---- the state after each event ------------------------------------------- diff --git a/umtool/report-to-video/measure-slice.test.mjs b/umtool/report-to-video/measure-slice.test.mjs @@ -175,7 +175,7 @@ test("state: after each event, from the shown rows only", () => { assert.deepEqual(last.lost, { total: 49, runs: [{ run: 0, start: "2024-01-05", peak: 9, row: "w02" }, { run: 1, start: "2025-04-01", peak: 40, row: "w09" }] }); for (let i = 1; i < sl.state.length; i += 1) assert.ok(sl.state[i].lost.total >= sl.state[i - 1].lost.total, "the odometer only goes up"); // "Lose 65" against the start of its run: the 349 he remembers (asOf 20 March, 12 days before). - assert.deepEqual(last.goal, { value: 284, loss: 65, deadline: "by Christmas", due: "2025-12-25", row: "w11", display: "284 lb", base: { value: 349, row: "w07", from: "runStart" } }); + assert.deepEqual(last.goal, { value: 284, loss: 65, deadline: "by Christmas", due: "2025-12-25", row: "w11", display: "284 lb", base: { value: 349, row: "w07", from: "runStart", date: "2025-05-01" } }); assert.deepEqual(last.goals, ["w11"]); assert.deepEqual(last.remembered.map((r) => r.row), ["w01", "w07"]); assert.deepEqual(last.promises, [{ row: "p01", said: "2025-06-05", what: "post a video of the scale", due: null, kept: false, checks: [], claims: [], outcome: null }]); diff --git a/umtool/report-to-video/modules/goals.mjs b/umtool/report-to-video/modules/goals.mjs @@ -23,16 +23,18 @@ export default measureExtraModule({ { key: "color", type: "color", label: "Paper (default the palette's amber)" }, { key: "countdown", type: "boolean", label: "Count a deadline down to the render date", default: true }, { key: "base", type: "boolean", label: "Say the weight he had stated when he set it", default: false }, + { key: "baseMaxDays", type: "number", min: MEASURE_LIMITS.baseMaxDays[0], max: MEASURE_LIMITS.baseMaxDays[1], label: "A base weight said at most this many days before the goal (unset: any age)" }, { key: "flash", type: "boolean", label: "Flash its outline when its value changes (unset: deck.measure.flash)" }, ], docs: { intro: "A sticky note per goal on a pile in a corner of the footage box, read off the schedule's `measure` slice (`render.chrome.deck.goals`, measure-extras.mjs): each goal or goalLoss event drops one, turned a little, onto the pile; the same goal in the same words (\"lose 100\") merges into its note with a count (\"×8\") and comes to the front; `max` notes show, the newest in front, with the goals set so far under them. A goal with a `deadline` counts down to `measure.asOfRender` (\"by Christmas · 50 days left · needs 226.5\"): Christmas is the next 25 Dec from the day he said it, \"next year\" a year on, a named year that year; words that name no date (\"by my birthday\") keep their label and no countdown. On whenever the cut has a measure slice with a goal on camera; `false` turns it off. Up for `hold` seconds after each goal (default 20), the pile as it stands each time. The four measure extras sit at anchors of the footage box by default, clear of the instrument panel's right column and of the top-left, where the streams' face cam most often is (the diet badge bottom-left, the goal stack bottom-right, the moving start top-right, the promise clock top-centre); `position` or `x`/`y` move one.", rows: [ - ["`deck.goals`", "`true` · `false` · `{show, position, x, y, scale, hold, finale, max, color, countdown, base}` · default on with a measure slice", "`umtool look <p> deck.goals=false`"], + ["`deck.goals`", "`true` · `false` · `{show, position, x, y, scale, hold, finale, max, color, countdown, base, baseMaxDays}` · default on with a measure slice", "`umtool look <p> deck.goals=false`"], ["`deck.goals.position`, `.x`/`.y`, `.scale`", "`top-left` `top-right` `bottom-left` `bottom-right` `top-center` `bottom-center` · design px · 0.5–2 · default `bottom-right`, unset, 1", "`umtool look <p> deck.goals.position=bottom-left`"], ["`deck.goals.position=shelf`", "its shelf form (`deck.shelf`): the count of goals set in a column, then the notes fanned sideways like the diet's tags -- ordered by the dial's goal board (measure-goals.mjs \`goalsAt(goalBoard(schedule.measure), t)\`, so the shelf and the dial always agree): its headline -- the closest goal in force -- in front with \"+N more\" for the others in force, the rest by recency; a goal the board misses struck in red, MISSED on it, for the dial's 6 s; with no goal in force, the newest in front; a new goal landing from above as on the pile; each older one showing its goal's words in the strip beside it (all of each when there is room); a repeat comes to the front with its ×n. The fan takes the shelf's spare width (shelfLayout), up to its notes side by side. On the shelf it stays up from the first goal (`hold` unset). What the dial draws of the goal stays on the dial", "`umtool look <p> deck.shelf.items='[\"diet\",\"goals\"]' deck.goals.position=shelf`"], ["`deck.goals.max`, `.color`, `.countdown`", "1–8 notes · #hex paper · bool · default 4, the palette's amber, `true`", "`umtool look <p> deck.goals.max=6`"], ["`deck.goals.base`", "bool · default `false`: each note also says the weight he had stated when he set the goal -- \"LOSE 100 (FROM 346.7)\", its qualifier kept (\"(FROM ≈390)\") -- the slice's own base for that goal, the one the gauge reckons its target from (measure-slice.mjs `goalBase`: the start of the run open when he set it, else the latest weight he gave by the goal's date, stated or remembered). A goal with no base (no weight by then, a target goal such as \"250 LB\", a base the scale's foot refuses) shows none -- never one made up. On a back card it is a line of its own, right-aligned like the label", "`umtool look <p> deck.goals.base=true`"], + ["`deck.goals.baseMaxDays`", "whole days 0–36500 · unset (default): every base counts. A loss goal's base is a weight he gave by the goal's date, however long before; with this set, a base counts only when its weight was SAID (its row's date, never a remembered weight's as-of) at most that many days before the goal's date. A staler one is no base: the note carries no \"(FROM …)\", and the slice resolves no target from it -- the dial draws no goal weight and no tick for that goal, his words (\"LOSE 100\") stay. It is the slice's rule (measure-slice.mjs `goalBaseMaxDays`), so the notes, the shelf and the dial agree; it needs `deck.goals` as settings (`deck.goals.base=true deck.goals.baseMaxDays=365`), and `baseMaxDays=null` takes it off", "`umtool look <p> deck.goals.baseMaxDays=365` (`--take <t>` for a take)"], ["`deck.goals.hold`, `.finale`", "0 (up from the first goal on) or 2–600 s after each · `hide` `show` · default 20, `hide`", "`umtool look <p> deck.goals.hold=0`"], ["`deck.goals.flash`", "bool · unset (default): follows `deck.measure.flash` -- THE UPDATE FLASH (update-flash.mjs): the note that lands lights as a goal is set -- not the first note (the stack coming up), not the board's own changes; a thin outline in its own colour, up over 0.15 s and gone over 0.7 s, no size change, never on frame 0 or while the deck is away", "`umtool look <p> deck.goals.flash=false`"], ], diff --git a/umtool/report-to-video/modules/measure-extras-settings.mjs b/umtool/report-to-video/modules/measure-extras-settings.mjs @@ -6,7 +6,7 @@ // SETTINGS), so it imports only instruments.mjs (a leaf too: whether the // instruments' column is on decides two defaults here). // -// render.chrome.deck.goals { show, position, x, y, scale, hold, finale, max, color, countdown, base, flash } +// render.chrome.deck.goals { show, position, x, y, scale, hold, finale, max, color, countdown, base, baseMaxDays, flash } // render.chrome.deck.peak { show, position, x, y, scale, hold, finale, title, color, values } // render.chrome.deck.promise { show, position, x, y, scale, hold, finale, label, verb, kept, broken, checks, speakers, claimVerb, claimColor } // render.chrome.deck.diet { show, position, x, y, scale, hold, finale, colors, labels, form, tags, overlap, days, flash } @@ -110,6 +110,7 @@ export const MEASURE_LIMITS = Object.freeze({ x: Object.freeze([0, 1920]), y: Object.freeze([0, 1080]), max: Object.freeze([1, 8]), + baseMaxDays: Object.freeze([0, 36500]), text: 40, quote: 160, }); @@ -123,8 +124,10 @@ export const MEASURE_DEFAULTS = Object.freeze({ // after each goal; `max` notes show, the newest in front; `color` is the // paper (default the palette's amber). // `base`: each note also says the weight he had stated when he set it, "(FROM 346.7)" (the slice's goal base). + // `baseMaxDays`: a weight said more than this many days before a loss goal is not its base (measure-slice.mjs + // goalBase reads it): no "(FROM …)", no target, no tick from it. null: every base counts. // `flash`: the update flash (update-flash.mjs) -- null follows deck.measure.flash, true/false for this module. - goals: Object.freeze({ ...COMMON, position: "bottom-right", hold: 20, max: 4, color: null, countdown: true, base: false, flash: null }), + goals: Object.freeze({ ...COMMON, position: "bottom-right", hold: 20, max: 4, color: null, countdown: true, base: false, baseMaxDays: null, flash: null }), // The moving start: up for `hold` seconds after each retelling. peak: Object.freeze({ ...COMMON, position: "top-right", hold: 12, title: "The start keeps moving", color: null, values: "drift" }), // The promise clock: up from the promise on, through the finale. @@ -265,6 +268,9 @@ export function validateMeasureExtra(id, v, where = `render.chrome.deck.${id}`, color(v.color, `${where}.color`, errors); if (v.countdown !== undefined && typeof v.countdown !== "boolean") errors.push(`${where}.countdown must be true or false`); if (v.base !== undefined && typeof v.base !== "boolean") errors.push(`${where}.base must be true or false`); + if (v.baseMaxDays !== undefined && v.baseMaxDays !== null && !(Number.isInteger(v.baseMaxDays) && numIn(v.baseMaxDays, L.baseMaxDays[0], L.baseMaxDays[1]))) { + errors.push(`${where}.baseMaxDays must be null (every base counts) or whole days from ${L.baseMaxDays[0]} to ${L.baseMaxDays[1]}`); + } } if (id === "goals" || id === "diet") { if (v.flash !== undefined && v.flash !== null && typeof v.flash !== "boolean") errors.push(`${where}.flash must be true, false or null (deck.measure.flash)`); diff --git a/umtool/report-to-video/modules/promise.mjs b/umtool/report-to-video/modules/promise.mjs @@ -69,6 +69,7 @@ export default measureExtraModule({ ["`deck.promise.position`, `.x`/`.y`, `.scale`", "an anchor in the footage box · design px · 0.5–2 · default `top-center`, unset, 1", "`umtool look <p> deck.promise.position=bottom-center`"], ["`deck.promise.hold`, `.finale`", "0 (stays up) or 2–600 s · `hide` `show` · default 0, `show`", "`umtool look <p> deck.promise.finale=hide`"], ["`deck.promise.label`, `.verb`, `.kept`, `.broken`, `.checks`", "≤40 each · `label` `quote` · default the row's display, \"offered\", \"Posted\", \"None posted\", `label`", "`umtool look <p> deck.promise.label='scale video'`"], + ["a `promise_outcome` row's `stampNote`", "one line, 1–80 characters · unset (default): the clock's own words under the stamp, \"by <date> · no video\". The row's note is that second line instead (REFUNDED / \"by her account · no receipt\"); the strip over a post's card, which has one line for everything, shows its first clause (to its first `·`, `;`, `—`, `, ` or ` -- `: \"refunded · by her account\"). It is the ledger row's, so every take of the project reads it. `umtool lint` warns past 26 characters (the stamp's line is never wrapped: a longer one runs past its border)", "`umtool ledger <p> set <row> --stampNote \"by her account · no receipt\"` · off again: `--stampNote null`"], ["`deck.promise.speakers`, `.claimVerb`, `.claimColor`", "`{<speaker>: {handle, color}}` · ≤40 · #hex · default `{}` (the postAvatars handle), \"paid\", #E37AB8", "`umtool look <p> deck.promise.speakers='{\"madamsavvy\":{\"handle\":\"MadamSavvy\"}}'`"], ], }, diff --git a/umtool/report-to-video/post-combo-prints.mjs b/umtool/report-to-video/post-combo-prints.mjs @@ -198,27 +198,36 @@ export async function projectCombos(dir, manifest, o = {}) { * the cut whose capture holds one (captured after the item went in -- its * media was never copied). Its capture is looked for under its own channel, * then every channel the cut's posts come from (a reply captured under the - * replies channel). `{ <itemId>: [{ name, slug, mediaId, sha256, url }] }`. + * replies channel). `{ <itemId>: [{ name, slug, tree, mediaId, sha256, url }] }`. + * + * `channelsDirs`: the channels trees to look in, in order (the project's own first, then the archive behind it: + * sources.mjs channelsLayersFor) -- the first tree that holds the post's capture wins, and each file says which + * (`tree`). Read only: nothing is written into any of them. * * @param {Record<string, any>} manifest - * @param {{ channelsDir?: string|null }} [o] + * @param {{ channelsDir?: string|null, channelsDirs?: string[]|null }} [o] */ -export async function captureOnlyMedia(manifest, { channelsDir = null } = {}) { - if (!channelsDir) return {}; +export async function captureOnlyMedia(manifest, { channelsDir = null, channelsDirs = null } = {}) { + const trees = (Array.isArray(channelsDirs) && channelsDirs.length ? channelsDirs : [channelsDir]).filter((d) => typeof d === "string" && d); + if (!trees.length) return {}; const tl = Array.isArray(manifest?.timeline) ? manifest.timeline : []; - const channels = [...new Set(tl.filter((e) => e?.type === "post" && typeof e.post === "string").map((e) => e.post.split("/")[0]).filter(Boolean))]; + const channels = [...new Set(tl.filter((e) => e?.type === "post" && typeof e.post === "string").map((e) => e.post.split("/")[0]).filter((c) => c && c !== "." && c !== ".." && !/[\\\0]/.test(c)))]; const out = {}; for (const e of tl) { if (e?.type !== "post" || typeof e.post !== "string" || (Array.isArray(e.media) && e.media.length)) continue; const [own, postId] = e.post.split("/"); if (!own || !postId) continue; - for (const slug of [own, ...channels.filter((c) => c !== own)]) { - const dirOf = path.join(channelsDir, slug, "posts-media", postId); - const cap = await readFile(path.join(dirOf, "capture.json"), "utf8").then((t) => JSON.parse(t), () => null); - const media = Array.isArray(cap?.media) ? cap.media.filter((m) => typeof m?.name === "string") : []; - if (!media.length) continue; - out[e.id] = media.map((m) => ({ name: m.name, slug, mediaId: xMediaIdOf(m.url), sha256: typeof m.sha256 === "string" ? m.sha256 : null, url: typeof m.url === "string" ? m.url : null })); - break; + // A post id of dots is no folder of a capture: never joined into a tree's path. + if ([own, postId].some((v) => v === "." || v === ".." || /[\\\0]/.test(v))) continue; + found: for (const tree of trees) { + for (const slug of [own, ...channels.filter((c) => c !== own)]) { + const dirOf = path.join(tree, slug, "posts-media", postId); + const cap = await readFile(path.join(dirOf, "capture.json"), "utf8").then((t) => JSON.parse(t), () => null); + const media = Array.isArray(cap?.media) ? cap.media.filter((m) => typeof m?.name === "string") : []; + if (!media.length) continue; + out[e.id] = media.map((m) => ({ name: m.name, slug, tree, mediaId: xMediaIdOf(m.url), sha256: typeof m.sha256 === "string" ? m.sha256 : null, url: typeof m.url === "string" ? m.url : null })); + break found; + } } } return out; diff --git a/umtool/report-to-video/remembered-looks.test.mjs b/umtool/report-to-video/remembered-looks.test.mjs @@ -7,9 +7,10 @@ import path from "node:path"; import test from "node:test"; import { fileURLToPath } from "node:url"; -import { CALLOUT_HOLD, dialHtml, heaviestOf, rememberedMode, rememberedWords } from "./chrome-instruments.mjs"; +import { CALLOUT_HOLD, dialFinaleHtml, dialHtml, heaviestOf, rememberedMode, rememberedWords } from "./chrome-instruments.mjs"; import { estimateSchedule } from "./deck.mjs"; import { validateDial } from "./instruments.mjs"; +import { moduleById } from "./modules/index.mjs"; const HERE = path.dirname(fileURLToPath(import.meta.url)); const MEASURE = JSON.parse(readFileSync(path.join(HERE, "fixtures", "measure-remembered", "measure.json"), "utf8")); @@ -80,3 +81,29 @@ test("one at a time, the latest remembered; the callout sweeps a ghost needle an assert.ok(gn.some((c) => c.at === 3 && c.to.autoAlpha === 0.9), "the ghost needle comes up where the needle stands"); assert.ok(gn.some((c) => Math.abs(c.at - (3 + CALLOUT_HOLD)) < 1e-6 && c.to.autoAlpha === 0), "and goes after the hold"); }); + +// rev9-a9 (12 Nov): in the finale the callout's label boxes and its ghost needle are drawn (dialParts draws them +// whenever the look is "callout") but nothing hid them -- every box sat at its CSS default over the dial's hub. +test("the finale never shows the callout: every label box and the ghost needle hidden from the first frame, the last one's rim flag up", () => { + const r = renderAs("callout"); + r.chrome.deck = { ...r.chrome.deck, qr: { show: false }, finale: { video: "side", totals: false } }; + const timeline = Array.from({ length: 4 }, (_, i) => ({ type: "clip", id: `c${i + 1}`, video: "v", start: 10 * i, end: 10 * i + (i === 3 ? 14 : 8), cite: 1, section: 0, + quote: "q", onscreen: { title: `Clip ${i + 1}` }, ...(i === 3 ? { layout: "finale" } : {}) })); + const schedule = { ...estimateSchedule({ slug: "m", title: "M", provenance: {}, render: r, timeline }), measure: MEASURE }; + const win = moduleById("dial-finale").window(schedule, { fps: 30, total: schedule.total }); + const html = dialFinaleHtml(schedule, r, win, { fonts: {} }); + const data = JSON.parse(/<script id="dial-finale-data" type="application\/json">(.*?)<\/script>/s.exec(html)[1]); + const drawn = [...html.matchAll(/class="rcall" data-k="(fgc\d+)"/g)].map((m) => m[1]); + assert.ok(drawn.length >= 2, "the fixture's remembered weights each draw a callout box"); + for (const k of drawn) { + assert.equal(data.init[k]?.autoAlpha, 0, `${k} is hidden at load`); + assert.ok(!data.cues.some((c) => c.k === k && c.to.autoAlpha > 0), `${k} is never called up`); + } + assert.match(html, /data-k="fgn"/); + assert.equal(data.init.fgn?.autoAlpha, 0, "the ghost needle is hidden at load"); + assert.ok(!data.cues.some((c) => c.k === "fgn" && c.to.autoAlpha > 0), "and never sweeps"); + // The rim's marker and flag stay: the last remembered one's, all at once. + const last = drawn.length - 1; + assert.ok(data.cues.some((c) => c.k === `fgl${last}` && c.to.autoAlpha === 1)); + assert.ok(data.cues.some((c) => c.k === `fgk${last}` && c.to.autoAlpha === 1)); +}); diff --git a/umtool/report-to-video/stamp-note.test.mjs b/umtool/report-to-video/stamp-note.test.mjs @@ -0,0 +1,91 @@ +// THE WORDS UNDER AN OUTCOME'S STAMP (a promise_outcome row's `stampNote`, 12 Nov): the promise clock wrote +// "by <date> · no video" under REFUNDED whatever the record said. A row's own note is that line; the strip over a +// post's card shows its first clause; with none, the clock's words as they were. +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import path from "node:path"; +import test from "node:test"; +import { fileURLToPath } from "node:url"; + +import { promiseHtml } from "./chrome-measure-extras.mjs"; +import { estimateSchedule } from "./deck.mjs"; +import { lintManifest } from "./lint.mjs"; +import { promiseStates, STAMP_NOTE, stampNoteClause, stampNoteLine, stampNoteWarnings } from "./measure-extras.mjs"; +import { measureSlice } from "./measure-slice.mjs"; + +const HERE = path.dirname(fileURLToPath(import.meta.url)); +const MEASURE = JSON.parse(readFileSync(path.join(HERE, "fixtures/measure-extras/measure.json"), "utf8")); +const PAL = { bg: "#0F1312", fg: "#EDF0EC", muted: "#98A29B", accent: "#22AB83", amber: "#E8A33F" }; +const render = (deck = {}) => ({ width: 1920, height: 1080, fps: 30, transition: 0.4, palette: PAL, chrome: { engine: "hyperframes", layout: "deck", deck } }); +const schedule = (measure, extra = {}) => ({ kind: "deck", fps: 30, total: 740, transition: 0.4, segments: [{ id: "a", start: 0, duration: 740, end: 740 }], measure, ...extra }); +const clone = (v) => JSON.parse(JSON.stringify(v)); +const noted = (note) => { + const m = clone(MEASURE); + for (const s of m.state) for (const p of s.promises ?? []) if (p.outcome) p.outcome.note = note; + return m; +}; + +test("the words: the note when the row has one, the clock's own otherwise; the strip takes the first clause", () => { + assert.equal(stampNoteLine({ kind: "refunded", date: "2026-10-31" }), "by 31 Oct · no video"); + assert.equal(stampNoteLine({ kind: "refunded", date: null }), "no video"); + assert.equal(stampNoteLine({ kind: "refunded", date: "2026-10-31", note: " her word · no receipt " }), "her word · no receipt"); + assert.equal(stampNoteClause({ kind: "refunded" }), "no video"); + assert.equal(stampNoteClause({ note: "her word · no receipt" }), "her word"); + assert.equal(stampNoteClause({ note: "by her account, 31 Oct" }), "by her account"); + assert.equal(stampNoteClause({ note: "she says -- nothing shown" }), "she says"); + assert.equal(stampNoteClause({ note: "partly; the rest owed" }), "partly"); + assert.equal(stampNoteClause({ note: "one clause only" }), "one clause only"); +}); + +test("the slice carries a promise_outcome row's stampNote on the promise's outcome; a row without one is as before", () => { + const schema = { kind: "measure", unit: "lb", yMin: 100, yMax: 400, bandGapDays: 60, tracks: [{ key: "weight", role: "value", label: "Weight" }], forms: ["current"] }; + const row = (o) => ({ scope: "weight", scopeBasis: "x", scopeConfidence: "read", valueKind: "uttered", flags: [], asOf: null, ...o }); + const ledger = (note) => [ + row({ id: "p01", date: "2026-10-23", population: "promise", display: "scale video", entryId: "c1" }), + row({ id: "o01", date: "2026-10-31", population: "promise_outcome", promise: "p01", outcome: "refunded", speaker: "madamsavvy", entryId: "c2", ...(note === undefined ? {} : { stampNote: note }) }), + ]; + const r = render({ measure: { scopes: ["weight"], asOf: "2026-11-12" } }); + const timeline = Array.from({ length: 3 }, (_, i) => ({ type: "clip", id: `c${i + 1}`, video: "v", start: 10 * i, end: 10 * i + 8, cite: 1, section: 0, quote: "q", onscreen: { title: `Clip ${i + 1}` } })); + const slice = (note) => { + const manifest = { slug: "m", title: "M", provenance: {}, render: r, timeline, ledgerSchema: schema, ledger: ledger(note) }; + return measureSlice(manifest, estimateSchedule(manifest), {}); + }; + assert.deepEqual(slice(" by her account ").state.at(-1).promises[0].outcome, { kind: "refunded", date: "2026-10-31", row: "o01", note: "by her account" }); + assert.deepEqual(slice(undefined).state.at(-1).promises[0].outcome, { kind: "refunded", date: "2026-10-31", row: "o01" }); + assert.deepEqual(slice(" ").state.at(-1).promises[0].outcome, { kind: "refunded", date: "2026-10-31", row: "o01" }); + // ... and the clock's states keep it. + assert.equal(promiseStates(schedule(slice("by her account")), r).find((s) => s.rows[0].outcome)?.rows[0].outcome.note, "by her account"); +}); + +test("the page: the stamp's second line is the note (escaped); the column's compact stamp too; the strip its first clause", () => { + const r = render({ promise: { speakers: { madamsavvy: { handle: "MadamSavvy" } } } }); + assert.match(promiseHtml(schedule(MEASURE), r, { fonts: {} }).html, /<div class="sw">Refunded<\/div><div class="ss">by 31 Oct · no video<\/div>/); + const html = promiseHtml(schedule(noted("her word · <no> receipt")), r, { fonts: {} }).html; + assert.match(html, /<div class="sw">Refunded<\/div><div class="ss">her word · <no> receipt<\/div>/); + assert.doesNotMatch(html, /no video/); + // The column's compact form (beside the instruments) draws the same stamp. + const col = render({ dial: true, promise: { label: "scale video" } }); + assert.match(promiseHtml(schedule(noted("her word · no receipt")), col, { fonts: {} }).html, /<div class="ss">her word · no receipt<\/div>/); + // The strip (the footage slot, a post's card over the clock): "refunded · <first clause>". + const f = render({ promise: { label: "scale video" } }); + const covered = (m) => schedule(m, { covers: [{ segment: "p", from: 715, to: 739, rects: [{ x: 300, y: 100, width: 700, height: 600 }] }] }); + assert.match(promiseHtml(covered(MEASURE), f, { fonts: {} }).html, /<span class="no">refunded · no video<\/span>/); + const strip = promiseHtml(covered(noted("her word · no receipt")), f, { fonts: {} }).html; + assert.match(strip, /<span class="no">refunded · her word<\/span>/); + assert.doesNotMatch(strip, /<span class="no">refunded · no video<\/span>/); +}); + +test("the lint warns when a note is longer than the stamp's line holds -- never refuses", () => { + const manifest = (note) => ({ slug: "m", title: "M", provenance: {}, render: render({}), timeline: [{ type: "clip", id: "c1", video: "v", start: 0, end: 8 }], + ledger: [{ id: "o01", population: "promise_outcome", outcome: "refunded", stampNote: note }, { id: "w1", population: "current", stampNote: "x".repeat(60) }] }); + assert.deepEqual(stampNoteWarnings(manifest("by her account")), []); + assert.deepEqual(stampNoteWarnings(manifest("x".repeat(STAMP_NOTE.fit))), []); + const long = "refunded in full by her account on 31 Oct"; + const w = stampNoteWarnings(manifest(long)); + assert.equal(w.length, 1); + assert.match(w[0], new RegExp(`ledger o01\\.stampNote "${long}" is ${long.length} characters: the promise clock's stamp holds about ${STAMP_NOTE.fit}`)); + const lint = lintManifest(manifest(long), { validators: false }); + assert.ok(lint.warnings.some((x) => x.startsWith("ledger o01.stampNote")), lint.warnings.join("\n")); + assert.ok(!lint.errors.some((x) => /stampNote/.test(x))); + assert.ok(!lintManifest(manifest("short"), { validators: false }).warnings.some((x) => /stampNote/.test(x))); +}); diff --git a/umtool/report-to-video/trail-plan.mjs b/umtool/report-to-video/trail-plan.mjs @@ -37,7 +37,8 @@ const r2 = (v) => Math.round(v * 100) / 100; export function trailPoints(measure, { remembered = true } = {}) { const out = []; for (const e of measure?.events ?? []) { - if (!Number.isFinite(e.t) || !Number.isFinite(Number(e.value))) continue; + // A row with no number is no point: `Number(null)` and `Number("")` are 0, which drew a 0 lb point (12 Nov). + if (!Number.isFinite(e.t) || e.value === null || e.value === undefined || e.value === "" || typeof e.value === "boolean" || !Number.isFinite(Number(e.value))) continue; if (e.kind !== "stated" && !(remembered && e.kind === "remembered")) continue; const day = dayNumber(e.asOf ?? e.date); if (!Number.isFinite(day)) continue; diff --git a/umtool/report-to-video/trail-plan.test.mjs b/umtool/report-to-video/trail-plan.test.mjs @@ -116,3 +116,21 @@ test("the page: points pop in where their moment puts them and move with every r assert.match(validateTrail({ gap: 10 }).join(), /gap must be "auto", 0 \(no breaks\) or 30 to 3650 days/); assert.match(validateTrail({ bounds: "loose" }).join(), /bounds must be "fit" or "fixed"/); }); + +test("a row with no number is no point: a null, missing, empty or non-numeric value never becomes a 0 lb point", () => { + const ev = (o) => ({ t: 10, kind: "stated", date: "2026-01-01", row: "w", ...o }); + const pts = trailPoints({ events: [ + ev({ t: 1, row: "a", value: 300 }), + ev({ t: 2, row: "null", value: null }), + ev({ t: 3, row: "missing" }), + ev({ t: 4, row: "empty", value: "" }), + ev({ t: 5, row: "words", value: "about three hundred" }), + ev({ t: 6, row: "bool", value: false }), + ev({ t: 7, row: "zero", value: 0 }), + ev({ t: 8, row: "text", value: "291.5" }), + ev({ t: 9, row: "nan", value: NaN }), + ] }); + // A real 0 and a number written as text are still points. + assert.deepEqual(pts.map((p) => [p.row, p.value]), [["a", 300], ["zero", 0], ["text", 291.5]]); + assert.deepEqual(pts.map((p) => p.n), [0, 1, 2]); +});