Archilyzer · Source

archilyzer

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

commit c9d21bc8f480f2fd77ab49241204dc01d699472a
parent f77bb2c3262437e29535ae80db551e89033ad1fc
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 12 Nov 2026 21:59:27 -0500

umtool analysis item, review round 1: audio passes the build's validators, typed numbers said, bounds in words, audio only from kept words, the page measured

- M1: clip-audio.mjs leaves an analysis item's `audio` to analysis-plan.mjs (the build's validator block and the
  lint refused it); a test runs the first use's shape WITH audio through buildVideo's own block and the lint.
- M2: every word field has its dates taken out and any digit left warned, naming the field; a field naming a row
  may say that row's own figure; a status row must be his; the dashed line is `mark: {row}` (a bare number refused).
- M3: a bounded pace row in words, unsigned: "MORE THAN 10.5 lb lost" / "AT MOST 8.5 lb lost" (and "gained"),
  "—" for opposite bounds, "about −9 lb" for an approximate end; the same words in --dry-run and the lint.
- M4: the audio must lie inside the clip's cut and outside its gaps, at most 30 s; a start before its file refused.
- M5: the lint refuses words and rows past the frame's room; the build measures the page in the browser
  (`?measure`) and refuses a box out of the frame, an overlap or a clipped row; the QR laid with clear room.
- S1 a typed date with two points names them; S2 a span's baseless deltas named with the rows to give; S3 the
  audio read from the clip's own window (analysisAudioSource); S4 the clip's own level and gain; S5 --vertical
  refuses it early; S6 `umtool ledger rm` counts its rows; S7 refusals exit 1; S8 docs: the band's dates are typed.

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

Diffstat:
Meditor/CHANGELOG.md | 2+-
Mumtool/docs/cli.md | 2+-
Mumtool/docs/knobs.md | 2+-
Mumtool/docs/report-video.md | 72++++++++++++++++++++++++++++++++++++++++++++++++++----------------------
Mumtool/e2e/fixtures/make-fixture.mjs | 2+-
Mumtool/e2e/play-teaser.spec.ts | 5+++--
Mumtool/lib/cli/groups.mjs | 2+-
Mumtool/lib/report/analysisCli.test.mjs | 14++++++++++++--
Mumtool/lib/report/ledgerRows.mjs | 3+++
Mumtool/lib/report/timelineCli.mjs | 11++++-------
Mumtool/report-to-video/analysis-build.test.mjs | 71++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mumtool/report-to-video/analysis-plan.mjs | 303++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------
Mumtool/report-to-video/analysis-plan.test.mjs | 170+++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------
Mumtool/report-to-video/build-video.mjs | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
Mumtool/report-to-video/chrome-analysis.mjs | 85+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
Mumtool/report-to-video/chrome-analysis.test.mjs | 20++++++++++++++++----
Mumtool/report-to-video/clip-audio.mjs | 5+++--
Mumtool/report-to-video/modules/analysis.mjs | 2+-
18 files changed, 651 insertions(+), 198 deletions(-)

diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog ## [Unreleased] -- **umtool: a report video can end on an analysis item, built from the ledger.** A new timeline entry, `{type: "analysis"}`, draws a full-frame ending on the deck's fonts and colours. It has a chart of a named run of his weights with a shaded band and marks, a pace table, status rows and one reading line. The line draws in and the rows land; there is no slam, hit or camera move. Every figure comes from a ledger row. A loss ("down 31.5") is placed against the run's start, the same weight a loss goal's base uses. A pace row's pounds and days are computed, never typed. A bound ("under 300") is drawn as a hollow point, and a pace row ending on one says "over" or "under" in the right direction. With `audio`, a clip's sound plays under the item and its citation and QR code are shown, but not its picture. Without audio the item is silent for at most 8 seconds. `umtool lint` names the row behind every refusal. `umtool timeline <p> [--take <t>] add-analysis | set-analysis` writes one into the draft or a take, with an undo point, and `--dry-run` prints every figure with its row. Play the cut draws the item as the build does, but silently. A cut without an analysis item builds exactly as before. +- **umtool: a report video can end on an analysis item, built from the ledger.** A new timeline entry, `{type: "analysis"}`, draws a full-frame ending on the deck's fonts and colours. It has a chart of a named run of his weights with a shaded band and marks, a pace table, status rows and one reading line. The line draws in and the rows land; there is no slam, hit or camera move. Every figure comes from a ledger row. A loss ("down 31.5") is placed against the run's start, the same weight a loss goal's base uses. A pace row's pounds and days are computed, never typed. A bound ("under 300") is drawn as a hollow point, and a pace row ending on one says it in words that stay true, "MORE THAN 10.5 lb lost" or "AT MOST 8.5 lb lost". A number typed into the words is a lint warning. The page is measured before it is encoded, and an item that overflows the frame is refused. With `audio`, a clip's sound plays under the item and its citation and QR code are shown, but not its picture. Without audio the item is silent for at most 8 seconds. `umtool lint` names the row behind every refusal. `umtool timeline <p> [--take <t>] add-analysis | set-analysis` writes one into the draft or a take, with an undo point, and `--dry-run` prints every figure with its row. Play the cut draws the item as the build does, but silently. A cut without an analysis item builds exactly as before. - **umtool: a build and a take refuse a picked read that says an anonymous author's handle or name.** `umtool lint` reported it, but the lint a build enforces (and so every take's render) did not, so a recorded "@realguy is lying" rendered with the card anonymised and the audio saying the handle. The enforced lint now carries the same error in the same words; `--no-lint` is still the only override, and a video with no anonymous character lints exactly as before. Also: a video with anonymous characters whose `video.manifest.json` is missing or unreadable is refused rather than read with an empty set; a read collapses a status link to an anonymous author's post; a `--post-take` part takes its words from what the source take said; and the words sent to a model lose an anonymous author's display name, bare handle, `/i/web/status/` links and percent-encoded handles too. - **umtool: anonymity covers the whole project, every link, the podcast and the previews; old reads keep their speed.** Re-checking the anonymous characters found several gaps. An item that named one in another variant, or one dropped by a ruling, `--only`, a window or a take, left the author in clear. The deck's corner QR on an anonymous author's post item still led to the real post. Links were rewritten with the status id kept. The podcast's show notes and the chrome preview, still and onscreen routes had no pass at all. Now: - The set is built from the whole project manifest (and a take's), and the build, the chrome composer, the podcast, Play, Present and the previews all take it from one function. diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -117,7 +117,7 @@ Inbox cannot disagree about what is wrong with one. | `timeline <project> sections [--json]` · `section-move <id>… --to-section N [--start]` · `section-add --after <id> [--label L] [--color C]` · `section-boundary <marker> --after <id>` · `section-remove <marker>` · `section-set <marker> [--label L] [--color C]` · `split <id> <second>` · `flash-forward <id> <from>-<to> (--after <id\|-> \| --to-section N [--start]) [--move] [--quote Q] [--id ID]` | **sections as sections** (the deck's markers; the Cut tab's section bars and row menus): clips moved to a section with every marker following, a section opened, a boundary moved, relabelled, removed — no section emptied, no boundary crossed (**exit 1**) — and every take patch in step synced; **split** (each half's quote from the words, the second half's cite and QR at its second, a marker after the clip following its second half); **flash-forward** a tight copy of a span elsewhere with the clip's attribution and locks, as `repeatOf` the clip (`--move`: out of the clip) ([knobs.md](knobs.md#sections-split-and-flash-forward-editing-the-cut)) | | `timeline <project> threads [--json]` · `timeline <project> threads --write [--conversation <id>]` | **the cut's conversations** ([report-video.md](report-video.md#thread-reads), `post-conversation.mjs`): each tree of two post items or more — its root, its items' places, whether they play as one run (one scene) or are split by other entries, a reply placed before the post it answers, an item re-reading a post its run already read (with `posts set-item <p> <item> thread.parent.<i>=context`). `--write` gathers each (or the one holding `<id>`: its root, a post, an item, a `thread.group` name) at its first item's place in TREE order (a manual thread: in DATE order) — a post after what it answers, sibling branches by date, each depth first — in ONE write (one undo point); never across a section boundary (gathered within each section, and said) | | `timeline <project> [--take <t>] add-video <src> [--from S] [--to S] [--fit contain\|cover] [--bass dB] [--gain dB] [--enter cut\|<out>,<in>] [--hold S] [--title T] [--id ID] [--after <id>\|-] [--dry-run] [--json]` · `timeline <project> [--take <t>] set-video <id> <key>=<value>…` | **a video entry** ([report-video.md](report-video.md#a-video-entry)): a file of the project (`src`, relative; probed, its `fileSeconds` written) played FULL FRAME with its own sound, nothing drawn over it, at the end unless `--after` (`-`: the start), into the cut or the take's timeline only (`--take`, an undo point of the take's); `set-video` sets `from= to= fit= audio.bass= audio.gain= enter=cut\|<out>,<in> enter.out= enter.in= holdLast= deck=hidden\|shown title= note= src=` (`key=` clears). `--dry-run`: the entry and its place, nothing written. `--json`: `{ok, op, take?, inserted\|updated {id, at, entry}, revision?}`. **Exit 0 · 1 refused (no such file, take or entry; the build would not take it) · 2 usage** | -| `timeline <project> [--take <t>] add-analysis <json\|@file> [--id ID] [--after <id>\|-] [--dry-run] [--json]` · `timeline <project> [--take <t>] set-analysis <id> <json\|@file> [--dry-run] [--json]` | **an analysis item** ([report-video.md](report-video.md#the-analysis-item)): an ending drawn from the LEDGER, full frame -- a chart of a named run of his weights (`series`: `{rows}` or `{from, to}`; a delta against the run's start), a `band`, `marks`, a `pace` table (pounds and days computed; a row ending on a bound says over/under), `status`, ONE `reading`, a `footnote`; `audio: {clip, start, end}` plays that clip's sound under it (its citation and QR drawn, its picture not), else silent for `seconds` (7, at most 8). Into the cut or the take's timeline only (`--take`, an undo point of the take's), at the end unless `--after` (`-`: the start); refused for a row the ledger lacks and everything the lint refuses (**exit 1**). `set-analysis` replaces the keys given (`null` removes one). `--dry-run`: every figure with its row, nothing written. `--json`: `{ok, op, take?, inserted\|updated, warnings, figures, revision?}` | +| `timeline <project> [--take <t>] add-analysis <json\|@file> [--id ID] [--after <id>\|-] [--dry-run] [--json]` · `timeline <project> [--take <t>] set-analysis <id> <json\|@file> [--dry-run] [--json]` | **an analysis item** ([report-video.md](report-video.md#the-analysis-item)): an ending drawn from the LEDGER, full frame -- a chart of a named run of his weights (`series`: `{rows}` or `{from, to}`; a delta against the run's start), a `band`, `marks`, a `pace` table (pounds and days computed; a row ending on a bound says it in words: "MORE THAN 10.5 lb lost", "AT MOST 8.5 lb lost"), `status`, ONE `reading`, a `footnote`; `audio: {clip, start, end}` plays that clip's sound under it (its citation and QR drawn, its picture not), else silent for `seconds` (7, at most 8). Into the cut or the take's timeline only (`--take`, an undo point of the take's), at the end unless `--after` (`-`: the start); refused for a row the ledger lacks and everything the lint refuses (**exit 1**). `set-analysis` replaces the keys given (`null` removes one). `--dry-run`: every figure with its row, nothing written. `--json`: `{ok, op, take?, inserted\|updated, warnings, figures, revision?}` | | `timeline <project> insert (--after <id\|-> \| --to-section N \| --group G) post:<channel>/<postId> [--id ID]` | **one post item** among the cut's entries, made as `posts reel` makes one | | `timeline <project> insert (--after <id\|-> \| --to-section N \| --group G) post-json:<json>\|post-json:@<file> [--id ID]` | **a post item made by hand** — a post no archive holds (one kept only as a picture): `{post: "<channel>/<postId>", author, handle, date, text, media: ["posts-media/…"], parents?, quoted?, subjects?, redact?}`, its media measured, its id `p-<postId>` unless `--id`; refused in the build's words (**exit 1**). Its avatar: `posts avatar <project> <handle> <file>` | | `scenes <project> <clip> [--black-min 0.05] [--threshold 8] [--pix-th 0.10] [--pad 30 \| --from S --to S] [--json]` | the picture's **scene cuts** (ffmpeg `scdet`, score ≥ threshold) and **black spans** (`blackdetect`) in the clip's fetched window, in SOURCE seconds — for `blur.from`/`blur.to` and trims ([knobs.md](knobs.md#a-clips-picture-blurred)). The window is the one the build would cut from (the project's `out/clips-raw`, the editor's `channels/<slug>/data/<id>/clips/`, a saved source); the extent ± `--pad` inside it is scanned. Nothing is fetched: **exit 1** with no window on disk (`fetch` first) | diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -2519,7 +2519,7 @@ The current section's name on one quiet line centred under the rail (`render.chr ### Analysis item -A timeline entry `{ type: "analysis", … }` (analysis-plan.mjs; [report-video.md](report-video.md#the-analysis-item)): a full-frame ending drawn from the LEDGER -- a chart of a named run of his weights (`series`: rows, or a span; a delta resolved against the run's start), a shaded `band`, `marks`, a `pace` table whose pounds and days are computed, `status` rows and ONE `reading` -- the line drawing in, the rows landing; with `audio` a clip's sound under it (its citation and QR on the page, its picture not), else silent for `seconds` (7, at most 8). Every figure traces to a ledger row; a bound ("< 300") is drawn hollow and a pace row ending on one says over/under. +A timeline entry `{ type: "analysis", … }` (analysis-plan.mjs; [report-video.md](report-video.md#the-analysis-item)): a full-frame ending drawn from the LEDGER -- a chart of a named run of his weights (`series`: rows, or a span; a delta resolved against the run's start), a shaded `band`, `marks`, a `pace` table whose pounds and days are computed, `status` rows and ONE `reading` -- the line drawing in, the rows landing; with `audio` a clip's sound under it (its citation and QR on the page, its picture not), else silent for `seconds` (7, at most 8). Every figure traces to a ledger row (the dashed line too: `mark: {row}`); a bound ("< 300") is drawn hollow and a pace row ending on one says it in words ("MORE THAN 10.5 lb lost", "AT MOST 8.5 lb lost"); a number typed into the words is a lint warning. | Knob | Range · default | From a terminal | |---|---|---| diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -463,13 +463,13 @@ umtool timeline <p> --take mid-22 set-video video audio.bass=10 enter=0.8,0.4 "kicker": "THE KETO RUN · EVERY WEIGHT HE STATED", "title": "What his own numbers say", "series": { "rows": ["w91", "w87", "w93", "w104", "w115", "w118", "w122", "w137"] }, // or { "from": "<date|row>", "to": "<date|row>" } - "band": { "from": "2026-10-23", "to": "2026-11-03", "label": "WORLD SERIES" }, // dates or row ids, inside the series + "band": { "from": "2026-10-23", "to": "2026-11-03", "label": "WORLD SERIES" }, // an event's dates, TYPED; inside the series "marks": [{ "row": "w118", "label": "offers the scale video", "quote": "…" }], // a point of the series "pace": [{ "from": "2026-09-24", "to": "2026-10-15" }, { "from": "w122", "to": "w137", "note": "…" }], "status": [{ "label": "SCALE VIDEO", "value": "NOT POSTED", "note": "offered 23 Oct", "color": "red", "row": "p01" }], "reading": "By his own numbers the loss is steady — and it stalled …", // ONE line, required "footnote": "All figures are his own statements; no weigh-in has been shown.", - "mark": 300, // the dashed line across + "mark": { "row": "w115" }, // the dashed line at that row's value "audio": { "clip": "c46", "start": 4112.6, "end": 4127.1 }, // optional: that clip's sound under it "seconds": 7 } // without audio; at most 8 ``` @@ -484,33 +484,61 @@ it), the pace rows land one by one, then the status, then the reading. No slam, variant reads its whole measure record). A series row is a weight of HIS on the value track -- `current`, `past` (at its `asOf`) or `delta`, which is resolved against **the run's start** exactly as a loss goal's base is (measure-slice.mjs `runStartAt`: a remembered weight within `bandGapDays` before the -run's first loss claim) and names that row. Of two weights for one day the line takes the one said last. -A pace row's ends are dates (the series point that day) or row ids; its **pounds and days are computed**, -never typed. A mark draws its row's figure and day, then your words. A status row's figure names its row -(`row`). A row the ledger lacks, another speaker's row, a non-weight row, a band outside the series or a -pace end with no point refuses the item; a number typed into a label or note is a warning. +run's first loss claim) and names that row; a `{from, to}` span that takes a delta with no such start is +refused, naming the rows to give as `rows` instead. Of two weights for one day the line takes the one said +last. A pace row's ends are row ids, or dates with exactly ONE series point on them (two on one day: name +one by id); its **pounds and days are computed**, never typed. A mark draws its row's figure and day, then +your words. The dashed line (`mark`) is a row's: `{ "row": "w115" }` draws it at that row's value, labelled +with the number ("300" for w115's "< 300"); a bare number is refused. A status row may name its row (`row`, +HIS -- another speaker's is refused). A row the ledger lacks, another speaker's row, a non-weight row, a band +outside the series or a pace end with no point refuses the item. **The band's dates are typed** -- an event's +dates (the World Series), not ledger rows. + +**Numbers typed into words are said.** In the title, the kicker, the reading, the footnote, the band's +label, a mark's label, a pace row's note and a status row's label, value and note, every date ("23 Oct", +"Oct 23, 2026", "Oct 2026", "2026-10-23") is taken out and then ANY digit left is a lint warning naming the +field -- "In 2026 he lost 75 lb" warns for "2026" and "75" (a year counts as a date only beside a month). +A field that names a row (a mark, a status row with `row`) may say that row's own figure ("under 300" on +w115), and a date there that is not the row's is said too. **A bound is never an exact figure.** A row with a qualifier (`<`, `>`; "under 300") is drawn as a hollow -point, and the line's stretches to and from it are dotted. A pace row ending on a bound is a bound, in the -right direction on each side: ending on `< 300` the change is LESS than computed -- the loss is **over** -the figure ("OVER −10.5 lb") -- and starting on it, **under** ("UNDER −8.5 lb"); its sub-line says which -end ("to < 300"). Both ends bounding opposite ways draw no figure. `--dry-run` and the lint name the row. - -**Its sound.** With `audio`, the named clip's sound over `[start, end]` (source seconds inside that clip's -window) plays under the item: read from the clip's own fetched source as its segment reads it (the raw -cache, on its clock, its `audio.offset` applied), levelled to `render.loudness` as a clip is, faded in and -out over 0.3 s. Its picture is not shown; its citation ("HEARD: channel · title · date · clock") and its -QR are, at the foot. The item lasts exactly the span. The lint warns when the cut also plays that span -(the words heard twice). Without audio the item is **silent for `seconds`** (default 7, at most 8: no dead -air); a short one's motion is scaled to leave a 1.5 s hold. Works with no model anywhere. +point, and the line's stretches to and from it are dotted. A pace row ending on a bound says so in WORDS, +unsigned, in the direction that stays true whatever the real change was: ending on `< 300` it is **"MORE +THAN 10.5 lb lost"**, starting on it **"AT MOST 8.5 lb lost"** (for a gain, "MORE THAN / AT MOST n lb +gained"); its sub-line says which end ("to < 300"). Opposite bounds at both ends draw "—"; an approximate end +(`≈`) draws "about −9 lb"; every exact row keeps its sign ("−0.7 lb"). `--dry-run` and the lint say the same +words and name the bounded row ("w110 310.5 → w115 < 300"). + +**Its sound.** With `audio`, the named clip's sound over `[start, end]` plays under the item. The span must +lie inside what the cut KEEPS of that clip -- within its `cutStart`–`cutEnd` (its `start`–`end` without a +cut) and in none of its `gaps` -- and be at most 30 s; anything else is refused. It is read from the window +the clip's own segment is cut from (the build's `analysisAudioSource`: a window on disk first, the piece that +holds the span for a clip fetched in pieces), so a full build fetches nothing the clip does not and +`--chrome-only` reads only what is on disk; a span that would start before that file does is refused. It +plays at the clip's own level (its cut record's loudness gain under `render.loudness`, then its own +`audio.gain`), faded in and out over 0.3 s. Its picture is not shown; its citation ("HEARD: channel · title · +date · clock") and its QR are, at the foot. The item lasts exactly the span. The lint warns when the cut +also plays that span (the words heard twice). Without audio the item is **silent for `seconds`** (default 7, +at most 8: no dead air); a short one's motion is scaled to leave a 1.5 s hold. Works with no model anywhere. + +**What fits.** The side panel holds **5 rows** (pace and status together; pace at most 5, status at most 2); +the reading **two lines** -- about 185 characters, 160 beside the QR; the title 44, the kicker 64, the band's +label 28, a mark's line 46, a pace note 24, a status label 20, value 12, note 36, the footnote 120. The lint +refuses past those (an estimate on the deck's condensed faces); the build then MEASURES the page at its last +frame in the browser (`?measure`) and refuses any box that leaves the frame, a table row wider than the panel +or whose words and figure overlap, the table running into the reading, the QR or the citation over the +table, the reading or the footnote, and a mark over the table. The normal case -- four pace rows, one status +row, a two-line reading, the QR -- has clear room. **Its segment** is composed and rendered once (`chrome/analysis-<id>/`, cached by its page key, as a teaser's is) and encoded with its sound; `segments/<id>.analysis.json` keys the frames, the sound (the source file, its offset, its gain) and the encode, so an unchanged item is not encoded again, and `--chrome-only` rebuilds it from the cache. The deck is away over it (full frame). No vertical form: a -9:16 cut refuses it. A cut without an analysis item builds byte for byte as before. **Play the cut** draws -its page as the build does (composed for preview by `POST /api/report/chrome/teasers`, as a teaser's), -seeked on the cut clock -- silent: the sound under it is the render's. +9:16 cut, or `--vertical` on a landscape one, refuses it before anything is spent. `umtool ledger rm` refuses +a row an analysis item draws, naming the item. A cut without an analysis item builds byte for byte as +before. **Play the cut** draws its page as the build does (composed for preview by `POST +/api/report/chrome/teasers`, as a teaser's), seeked on the cut clock -- silent: the sound under it is the +render's. ```sh umtool timeline <p> --take rev9-a10 add-analysis @first-use.json --after c99 --dry-run # every figure with its row diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs @@ -2124,7 +2124,7 @@ pa.timeline = pa.timeline.map((e) => (e.id === "k01" ? { type: "analysis", id: "a01", seconds: 6, title: "What his own numbers say", kicker: "THE RUN", series: { rows: ["w2", "w3", "w4", "w5", "w6"] }, pace: [{ from: "w4", to: "w5" }, { from: "w5", to: "w6" }], - reading: "The loss is steady.", mark: 300, + reading: "The loss is steady.", mark: { row: "w5" }, } : e)); writeFileSync(paFile, JSON.stringify(pa, null, 2) + "\n"); diff --git a/umtool/e2e/play-teaser.spec.ts b/umtool/e2e/play-teaser.spec.ts @@ -83,8 +83,9 @@ test("an analysis item plays as the build draws it: its page full frame, its pac await expect(item).toHaveAttribute("data-play-teaser-ready", "1", { timeout: 30_000 }); await expect(page.locator("[data-play-placeholder]")).toHaveCount(0); await expect(f.locator(".ttl")).toHaveText("What his own numbers say"); - await expect(f.locator('[data-k="r0"] .v')).toHaveText("over−10.5 lb"); - await expect(f.locator('[data-k="r1"] .v')).toHaveText("under−8.5 lb"); + // A bound in words, unsigned: ending on w5's "< 300" more than 10.5 lb lost, starting on it at most 8.5 lb lost. + await expect(f.locator('[data-k="r0"] .v')).toHaveText("MORE THAN10.5 lblost"); + await expect(f.locator('[data-k="r1"] .v')).toHaveText("AT MOST8.5 lblost"); await expect(f.locator('[data-k="r0"] .ls')).toHaveText("21 days · to < 300"); // Landed by now (the rows land after the line): seeked, not a still of its first frame. await expect.poll(() => f.locator('[data-k="rd"]').evaluate((el) => Number(getComputedStyle(el).opacity)), { timeout: 10_000 }).toBeGreaterThan(0.9); diff --git a/umtool/lib/cli/groups.mjs b/umtool/lib/cli/groups.mjs @@ -964,7 +964,7 @@ export const GROUPS = [ ["`timeline <project> [--take <t>] add-video <src> [--from S] [--to S] [--fit contain\\|cover] [--bass dB] [--gain dB] [--enter cut\\|<out>,<in>] [--hold S] [--title T] [--id ID] [--after <id>\\|-] [--dry-run] [--json]` · `timeline <project> [--take <t>] set-video <id> <key>=<value>…`", "**a video entry** ([report-video.md](report-video.md#a-video-entry)): a file of the project (`src`, relative; probed, its `fileSeconds` written) played FULL FRAME with its own sound, nothing drawn over it, at the end unless `--after` (`-`: the start), into the cut or the take's timeline only (`--take`, an undo point of the take's); `set-video` sets `from= to= fit= audio.bass= audio.gain= enter=cut\\|<out>,<in> enter.out= enter.in= holdLast= deck=hidden\\|shown title= note= src=` (`key=` clears). `--dry-run`: the entry and its place, nothing written. `--json`: `{ok, op, take?, inserted\\|updated {id, at, entry}, revision?}`. **Exit 0 · 1 refused (no such file, take or entry; the build would not take it) · 2 usage**"], ["`timeline <project> [--take <t>] add-analysis <json\\|@file> [--id ID] [--after <id>\\|-] [--dry-run] [--json]` · `timeline <project> [--take <t>] set-analysis <id> <json\\|@file> [--dry-run] [--json]`", - "**an analysis item** ([report-video.md](report-video.md#the-analysis-item)): an ending drawn from the LEDGER, full frame -- a chart of a named run of his weights (`series`: `{rows}` or `{from, to}`; a delta against the run's start), a `band`, `marks`, a `pace` table (pounds and days computed; a row ending on a bound says over/under), `status`, ONE `reading`, a `footnote`; `audio: {clip, start, end}` plays that clip's sound under it (its citation and QR drawn, its picture not), else silent for `seconds` (7, at most 8). Into the cut or the take's timeline only (`--take`, an undo point of the take's), at the end unless `--after` (`-`: the start); refused for a row the ledger lacks and everything the lint refuses (**exit 1**). `set-analysis` replaces the keys given (`null` removes one). `--dry-run`: every figure with its row, nothing written. `--json`: `{ok, op, take?, inserted\\|updated, warnings, figures, revision?}`"], + "**an analysis item** ([report-video.md](report-video.md#the-analysis-item)): an ending drawn from the LEDGER, full frame -- a chart of a named run of his weights (`series`: `{rows}` or `{from, to}`; a delta against the run's start), a `band`, `marks`, a `pace` table (pounds and days computed; a row ending on a bound says it in words: \"MORE THAN 10.5 lb lost\", \"AT MOST 8.5 lb lost\"), `status`, ONE `reading`, a `footnote`; `audio: {clip, start, end}` plays that clip's sound under it (its citation and QR drawn, its picture not), else silent for `seconds` (7, at most 8). Into the cut or the take's timeline only (`--take`, an undo point of the take's), at the end unless `--after` (`-`: the start); refused for a row the ledger lacks and everything the lint refuses (**exit 1**). `set-analysis` replaces the keys given (`null` removes one). `--dry-run`: every figure with its row, nothing written. `--json`: `{ok, op, take?, inserted\\|updated, warnings, figures, revision?}`"], ["`timeline <project> insert (--after <id\\|-> \\| --to-section N \\| --group G) post:<channel>/<postId> [--id ID]`", "**one post item** among the cut's entries, made as `posts reel` makes one"], ["`timeline <project> insert (--after <id\\|-> \\| --to-section N \\| --group G) post-json:<json>\\|post-json:@<file> [--id ID]`", diff --git a/umtool/lib/report/analysisCli.test.mjs b/umtool/lib/report/analysisCli.test.mjs @@ -12,6 +12,7 @@ import test from "node:test"; import { draftTake } from "./takeMaker.mjs"; import { resolveTakeManifest } from "./takeManifest.mjs"; import { timelineCommand } from "./timelineCli.mjs"; +import { ledgerCommand } from "./ledgerCli.mjs"; const W = (id, population, date, value, extra = {}) => ({ id, scope: "weight", population, date, value, ...extra }); const MANIFEST = { @@ -65,8 +66,8 @@ test("add-analysis --dry-run prints every figure with its row and writes nothing const text = p.out.join("\n"); assert.match(text, /would add analysis analysis at 1 \(after c01\) in proj:/); assert.match(text, /point w104: 317\.5 on 2026-09-04 \(-31\.5 from w91 349\)/); - assert.match(text, /pace\[0\] 24 Sep → 15 Oct: over −10\.5 lb \(w110 310\.5 → w115 300\), 21 days -- a bound: w115/); - assert.match(text, /pace\[1\] 15 → 23 Oct: under −8\.5 lb/); + assert.match(text, /pace\[0\] 24 Sep → 15 Oct: MORE THAN 10\.5 lb lost \(w110 310\.5 → w115 < 300\), 21 days -- a bound: w115/); + assert.match(text, /pace\[1\] 15 → 23 Oct: AT MOST 8\.5 lb lost/); assert.match(text, /warning: .*pace\[0\] ends on a bound/); assert.equal(await readFile(path.join(p.dir, "video.manifest.json"), "utf8"), before); } finally { @@ -95,6 +96,15 @@ test("add-analysis and set-analysis on the draft: written, an undo point each, r assert.equal("kicker" in m.timeline[2], false); assert.ok((await readdir(path.join(p.dir, "revisions"))).some((f) => /auto-before-analysis/.test(f))); + // Refusals are exit 1 (cli.md): an id already in the cut, a patch that changes the id. + assert.equal(await p.run("proj", "add-analysis", p.file, "--id", "end"), 1); + assert.match(p.err.join("\n"), /end is already in proj/); + assert.equal(await p.run("proj", "set-analysis", "end", JSON.stringify({ id: "zz" })), 1); + assert.match(p.err.join("\n"), /does not change its id/); + // A ledger row the item draws cannot be removed from under it (umtool ledger rm). + const lines = []; + assert.equal(await ledgerCommand(["proj", "rm", "w115"], { root: path.dirname(p.dir), out: (s) => lines.push(s), err: (s) => lines.push(s) }), 1); + assert.match(lines.join("\n"), /w115 is still named: analysis item end draws it/); p.err.length = 0; assert.equal(await p.run("proj", "set-analysis", "end", JSON.stringify({ series: { rows: ["w91", "w999"] } })), 1); assert.match(p.err.join("\n"), /series row w999 is not in the ledger/); diff --git a/umtool/lib/report/ledgerRows.mjs b/umtool/lib/report/ledgerRows.mjs @@ -20,6 +20,7 @@ import { 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"; +import { analysisRowRefs } from "umtool-report-to-video/analysis-plan"; const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v); const DATE_RE = /^\d{4}(?:-\d{2}(?:-\d{2})?)?$/; @@ -191,6 +192,8 @@ export function ledgerRowOf(manifest, base, patch, { unset = [] } = {}) { export function ledgerRowReferences(manifest, id) { const out = []; for (const e of manifest.timeline ?? []) if (typeof e?.claim === "string" && e.claim.trim() === id) out.push(`timeline entry ${e.id} pins it (claim)`); + // An analysis item draws the rows it names (analysis-plan.mjs): its series, marks, pace ends, status rows, its line. + for (const e of manifest.timeline ?? []) if (e?.type === "analysis" && analysisRowRefs(e).includes(id)) out.push(`analysis item ${e.id} draws it (series, a mark, a pace end, a status row or its line)`); const refs = isMeasureLedger(manifest) ? measureSchema(manifest.ledgerSchema).fields.filter((f) => f.kind === "rowRef").map((f) => f.key) : []; for (const r of manifest.ledger ?? []) { if (!isObj(r) || r.id === id) continue; diff --git a/umtool/lib/report/timelineCli.mjs b/umtool/lib/report/timelineCli.mjs @@ -1141,11 +1141,11 @@ async function analysisVerb(project, verb, rest, flags, { out, json }) { if (verb === "add-analysis") { const raw = await jsonArg(rest[0], "add-analysis"); if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw new CliError("add-analysis takes the item as a JSON object (or @file)"); - if (raw.type !== undefined && raw.type !== "analysis") throw new CliError(`add-analysis adds an analysis item, not a ${raw.type}`); + if (raw.type !== undefined && raw.type !== "analysis") throw new Error(`add-analysis adds an analysis item, not a ${raw.type}`); const { type: _t, id: rawId, ...keys } = raw; void _t; const id = flags.has("--id") ? String(flags.get("--id")) : typeof rawId === "string" && rawId ? rawId : "analysis"; - if (timeline.some((e) => e?.id === id)) throw new CliError(`${id} is already in ${where} (--id another, or set-analysis ${id})`); + if (timeline.some((e) => e?.id === id)) throw new Error(`${id} is already in ${where} (--id another, or set-analysis ${id})`); entry = { type: "analysis", id, ...keys }; const afterArg = flags.has("--after") ? String(flags.get("--after")) : null; after = afterArg === null ? (timeline.length ? timeline[timeline.length - 1].id : null) : afterArg === "-" || afterArg === "" ? null : afterArg; @@ -1159,11 +1159,8 @@ async function analysisVerb(project, verb, rest, flags, { out, json }) { at = timeline.findIndex((e) => e?.id === id); if (at < 0) throw new Error(`no entry ${id} in ${where}`); if (timeline[at].type !== "analysis") throw new Error(`${id} is a ${timeline[at].type ?? "non-analysis"} entry, not an analysis item`); - try { - entry = A.applyAnalysisPatch(timeline[at], patch); - } catch (e) { - throw new CliError(e instanceof Error ? e.message : String(e)); - } + // A patch that changes its id or type is refused (exit 1), as the build refuses what it breaks. + entry = A.applyAnalysisPatch(timeline[at], patch); judged = judge(entry, timeline.map((e, k) => (k === at ? entry : e))); if (!dry) { const r = take diff --git a/umtool/report-to-video/analysis-build.test.mjs b/umtool/report-to-video/analysis-build.test.mjs @@ -2,6 +2,10 @@ // length in the schedule, the deck away over it, its chapter -- and its errors among the build's validators. import { test } from "node:test"; import assert from "node:assert/strict"; +import { existsSync } from "node:fs"; +import { mkdtemp, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import path from "node:path"; import { analysisAudioGraph, analysisEncodeArgs, chapterTitle, teaserAudioGraph } from "./build-video.mjs"; import { estimatedDuration, estimateSchedule, hidesDeck, resolveDeck } from "./deck.mjs"; @@ -65,5 +69,70 @@ test("the build's validators and the lint: its errors, its warnings, its code me const { warnings } = lintManifest(heard, { whole: heard, exists: () => true }); assert.ok(warnings.some((w) => /its words are heard twice/.test(w)), warnings.join("\n")); const q = qrsOf(heard).find((x) => x.id === "an"); - assert.ok(q && /example\.pages\.dev/.test(q.url) && q.px === 225, JSON.stringify(q)); + assert.ok(q && /example\.pages\.dev/.test(q.url) && q.px === 210, JSON.stringify(q)); +}); + +test("the build measures the page: what fits passes, a reading or a table past its room is named", { skip: !existsSync(process.env.CHROME ?? "/usr/bin/chromium") && "no chromium" }, async () => { + const { measureAnalysisPage } = await import("./build-video.mjs"); + const { analysisHtml } = await import("./chrome-analysis.mjs"); + const m = manifest({ audio: { clip: "c1", start: 12, end: 26.5 }, pace: [{ from: "w1", to: "w2" }], status: [{ label: "SCALE VIDEO", value: "NOT POSTED", color: "red" }] }); + const e = m.timeline[1]; + const ctx = { ledger: m.ledger, schema: m.ledgerSchema, timeline: m.timeline, render: m.render }; + const dir = await mkdtemp(path.join(tmpdir(), "analysis-measure-")); + try { + const page = (html) => writeFile(path.join(dir, "index.html"), html); + const html = analysisHtml(e, ctx, { cite: "HEARD: chan · a stream · 1:08:32", qrSrc: "qr.png" }); + await page(html); + assert.deepEqual(await measureAnalysisPage(dir, m.render), []); + // A reading past its room (the plan refuses it first; the page is the build's last word). + await page(html.replace("It went down.", "word ".repeat(120))); + const long = await measureAnalysisPage(dir, m.render); + assert.ok(long.some((x) => /the reading leaves the frame|the QR overlaps the reading/.test(x)), long.join("\n")); + // A table past the panel's room runs under the code. + const row = '<div class="row"><div class="l"><div class="lt">1 → 2 OCT</div><div class="ls">1 days</div></div><div class="v">−1 lb</div></div>'; + await page(html.replace('<div class="side">', `<div class="side">${row.repeat(8)}`)); + const tall = await measureAnalysisPage(dir, m.render); + assert.ok(tall.some((x) => /the QR overlaps table row \d|the table runs into/.test(x)), tall.join("\n")); + } finally { + await rm(dir, { recursive: true, force: true }); + } +}); + +test("the first use's shape WITH audio passes the build's own validator block (buildVideo) and the lint", async () => { + const { buildVideo } = await import("./build-video.mjs"); + const W = (id, population, date, value, extra = {}) => ({ id, scope: "weight", population, date, value, ...extra }); + const schema = { kind: "measure", unit: "lb", bandGapDays: 60, tracks: [{ key: "weight", role: "value", label: "Weight" }], + fields: [{ key: "qualifier", label: "Bound", kind: "enum", options: [">", "<", "≈"], render: "cell" }] }; + const m = { + schemaVersion: 1, slug: "fu", title: "First use", provenance: { siteOrigin: "https://example.pages.dev", channelSlug: "chan" }, + render: { width: 1920, height: 1080, fps: 30 }, ledgerSchema: schema, + ledger: [W("w83", "delta", "2026-07-23", -5), W("w91", "past", "2026-08-03", 349, { asOf: "2026-07-19" }), W("w104", "delta", "2026-09-04", -31.5), W("w110", "current", "2026-09-24", 310.5), W("w113", "delta", "2026-10-06", -47), + W("w115", "current", "2026-10-15", 300, { qualifier: "<" }), W("w118", "current", "2026-10-26", 291.5, { asOf: "2026-10-23" }), + W("w122", "delta", "2026-11-03", -58.2), W("w137", "current", "2026-11-07", 288.5), { id: "p01", scope: "weight", population: "promise", date: "2026-10-23" }], + timeline: [ + { type: "teaser", id: "t1", lines: ["One"] }, + { type: "clip", id: "c46", video: "v1", start: 4111.4, end: 4158.8, cutStart: 4112.6, cutEnd: 4158.5, gaps: [{ from: 4127.15, to: 4132.45 }] }, + { type: "analysis", id: "analysis", kicker: "THE KETO RUN · EVERY WEIGHT HE STATED", title: "What his own numbers say", + series: { rows: ["w91", "w110", "w115", "w118", "w122", "w137"] }, band: { from: "2026-10-23", to: "2026-11-03", label: "WORLD SERIES" }, + marks: [{ row: "w91", label: "he starts" }, { row: "w115", label: "" }, { row: "w118", label: "offers the scale video" }], + pace: [{ from: "2026-09-24", to: "2026-10-15" }, { from: "2026-10-15", to: "2026-10-23" }, { from: "2026-10-23", to: "2026-11-03", note: "the World Series" }, { from: "2026-11-03", to: "2026-11-07" }], + status: [{ label: "SCALE VIDEO", value: "NOT POSTED", note: "offered 23 Oct", color: "red", row: "p01" }], + reading: "By his own numbers the loss is steady — and it stalled for two weeks around the World Series, exactly when the scale video was promised.", + footnote: "All figures are his own statements; no weigh-in has been shown.", mark: { row: "w115" }, + audio: { clip: "c46", start: 4112.6, end: 4127.1 } }, + ], + }; + assert.deepEqual(validatorErrors(m), []); + assert.deepEqual(lintManifest(m, { whole: m, exists: () => true }).errors, []); + const dir = await mkdtemp(path.join(tmpdir(), "analysis-first-use-")); + try { + const manifestPath = path.join(dir, "video.manifest.json"); + await writeFile(manifestPath, JSON.stringify(m)); + // A fetch of the teaser is a no-op AFTER the build's validators: the block that refused `audio` on a non-clip. + assert.deepEqual(await buildVideo({ manifestPath, opts: { noNetwork: true, skipFetch: true }, fetchOnly: "t1" }), { out: null, failures: [] }); + // A vertical build refuses it before anything is spent. + await assert.rejects(buildVideo({ manifestPath, opts: { noNetwork: true, skipFetch: true, vertical: true }, fetchOnly: "t1" }), /vertical: analysis is an analysis item, which has no vertical form/); + } finally { + await rm(dir, { recursive: true, force: true }); + } }); diff --git a/umtool/report-to-video/analysis-plan.mjs b/umtool/report-to-video/analysis-plan.mjs @@ -6,25 +6,26 @@ // { "type": "analysis", "id": "an1", "title": "What his own numbers say", // "kicker": "THE KETO RUN · EVERY WEIGHT HE STATED", // "series": { "rows": ["w91", "w87", …] } // or { "from": "<date|row>", "to": "<date|row>" } -// "band": { "from": "2026-10-23", "to": "2026-11-03", "label": "WORLD SERIES" }, +// "band": { "from": "2026-10-23", "to": "2026-11-03", "label": "WORLD SERIES" }, // an event's dates, typed // "marks": [{ "row": "w118", "label": "offers the scale video", "quote": "…" }], // "pace": [{ "from": "2026-09-24", "to": "2026-10-15", "note": "…" }], // "status": [{ "label": "SCALE VIDEO", "value": "NOT POSTED", "note": "offered 23 Oct", "color": "red", "row": "p01" }], -// "reading": "…", "footnote": "…", "mark": 300, +// "reading": "…", "footnote": "…", "mark": { "row": "w115" }, // "audio": { "clip": "c46", "start": 4112.6, "end": 4127.1 }, // optional // "seconds": 7 } // without audio; at most 8 // // DATA, NOT DRAWING. Every figure on screen is computed here from a ledger // row and carries that row's id: a point's weight (a `delta` resolved against // the run's start, measure-slice.mjs runStartAt -- the base a loss goal reads), -// a mark's figure and date, a pace row's pounds and days. Nothing typed is a -// number the item draws (a label or note with a digit is a lint warning; a -// status figure names its row). A row the ledger lacks refuses the item. +// a mark's figure and date, a pace row's pounds and days, the dashed line's +// value. A number TYPED into the words (a title, a label, a note, the reading) +// is a lint warning naming the field -- dates aside ("23 Oct", "Oct 2026") -- +// unless the field names a row and the number is that row's. // // A BOUND IS NEVER AN EXACT FIGURE. A point whose row is a bound ("< 300") is -// drawn hollow (as the trail draws a qualified weight) with its glyph; a pace -// row that ends on one is a bound too, in the right direction on each side: -// ending on "< 300" the loss is OVER the figure, starting on it UNDER it. +// drawn hollow (as the trail draws a qualified weight); a pace row that ends on +// one says it in words, unsigned and in the right direction: ending on +// "< 300" it is "MORE THAN 10.5 lb lost", starting on it "AT MOST 8.5 lb lost". // // PURE: the entry, the ledger, the schema and the timeline in, plain data out. import { dateKey } from "./ledger-shared.mjs"; @@ -35,11 +36,21 @@ import { playEdges } from "./mute.mjs"; import { gapsOf } from "./gaps.mjs"; import { trailLayout, trailLine } from "./trail-plan.mjs"; -/** The silent item's length: its default and its ceiling (no dead air), and the floor any item has. */ -export const ANALYSIS_SECONDS = Object.freeze({ silent: 7, silentMax: 8, min: 4 }); +/** The item's length: the silent default and ceiling (no dead air), the floor any item has, the longest audio. */ +export const ANALYSIS_SECONDS = Object.freeze({ silent: 7, silentMax: 8, min: 4, audioMax: 30 }); -/** How many rows each table holds on the frame. */ -export const ANALYSIS_LIMITS = Object.freeze({ pace: 5, status: 2, marks: 6, rows: 120 }); +/** How many rows each table holds on the frame (`rows`: pace and status together, the side panel's room). */ +export const ANALYSIS_LIMITS = Object.freeze({ pace: 5, status: 2, rows: 5, marks: 6, series: 120 }); + +/** + * What each word field holds, in characters -- the lint's estimate of the frame (the deck's condensed faces at + * 1280x720 units); the build measures the page itself and refuses what leaves the frame or overlaps (chrome-analysis.mjs). + * `reading` with the audio's QR beside it is `readingQr`. + */ +export const ANALYSIS_TEXT = Object.freeze({ + title: 44, kicker: 64, bandLabel: 28, mark: 46, quote: 100, paceNote: 24, statusLabel: 20, statusValue: 12, statusNote: 36, + reading: 185, readingQr: 160, footnote: 120, +}); /** The palette roles a status figure may be drawn in (or a #hex). */ export const ANALYSIS_COLORS = Object.freeze(["accent", "amber", "red", "fg", "muted"]); @@ -52,7 +63,6 @@ export const ANALYSIS_KEYS = Object.freeze([ const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v); const isIso = (v) => typeof v === "string" && /^\d{4}-\d{2}-\d{2}$/.test(v); -const hasDigit = (s) => /\d/.test(String(s ?? "")); const r2 = (v) => Math.round(v * 100) / 100; const MON = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; @@ -70,6 +80,110 @@ export function spanWords(a, b) { return ma === mb ? `${na} → ${nb} ${mb}` : `${da} → ${db}`; } +// --------------------------------------------------------------------------- +// Numbers typed into words. +// --------------------------------------------------------------------------- + +const MONTH = "(jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)[a-z]*\\.?"; +const YEAR = "((?:19|20)\\d{2})"; +/** The date tokens a text may carry, strictest first: ISO, day month [year], month day [year], month year. */ +const DATE_TOKENS = [ + { re: /\b(\d{4})-(\d{2})-(\d{2})\b/gi, of: (m) => ({ y: Number(m[1]), mon: Number(m[2]) - 1, d: Number(m[3]) }) }, + { re: new RegExp(`\\b(\\d{1,2})(?:st|nd|rd|th)?\\s+${MONTH}(?:,?\\s+${YEAR})?\\b`, "gi"), of: (m) => ({ d: Number(m[1]), mon: monthIndex(m[2]), y: m[3] ? Number(m[3]) : null }) }, + { re: new RegExp(`\\b${MONTH}\\s+(\\d{1,2})(?:st|nd|rd|th)?(?:,?\\s+${YEAR})?\\b`, "gi"), of: (m) => ({ d: Number(m[2]), mon: monthIndex(m[1]), y: m[3] ? Number(m[3]) : null }) }, + { re: new RegExp(`\\b${MONTH}\\s+${YEAR}\\b`, "gi"), of: (m) => ({ d: null, mon: monthIndex(m[1]), y: Number(m[2]) }) }, +]; +function monthIndex(word) { + return MON.findIndex((m) => String(word).toLowerCase().startsWith(m.toLowerCase())); +} + +/** + * A text's typed numbers: its date tokens (each `{ text, d, mon, y }`) taken out, then every number left + * (`numbers`, as written). A year counts as part of a date only beside a month; a bare "2026" is a number. + */ +export function typedNumbers(text) { + let rest = String(text ?? ""); + const dates = []; + for (const { re, of } of DATE_TOKENS) { + rest = rest.replace(re, (...m) => { + dates.push({ text: m[0], ...of(m) }); + return " "; + }); + } + return { dates, numbers: rest.match(/\d+(?:[.,]\d+)?/g) ?? [] }; +} + +/** Does a date token name this day (an ISO date)? A token without a year matches any year. */ +function dateIs(tok, iso) { + const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso ?? "")); + if (!m) return false; + return (tok.d === null || tok.d === Number(m[3])) && tok.mon === Number(m[2]) - 1 && (tok.y === null || tok.y === Number(m[1])); +} + +/** + * The warnings a typed field earns: a number left once its dates are taken out -- unless `row` backs it and the + * number is that row's figure (`figures`, the row's value and any value it is drawn as); with a row, a date that is + * not the row's (its date or its asOf) is said too. + */ +function numberWarnings(where, text, { row = null, figures = [] } = {}) { + if (typeof text !== "string" || !text) return []; + const { dates, numbers } = typedNumbers(text); + const out = []; + const okFigure = (n) => figures.some((f) => Number.isFinite(f) && Math.abs(Math.abs(f) - Math.abs(Number(n.replace(",", ".")))) < 0.051); + const stray = row ? numbers.filter((n) => !okFigure(n)) : numbers; + if (stray.length) { + out.push(`${where} "${text}" has ${stray.map((n) => `"${n}"`).join(", ")} typed -- ${row ? `not ${row.id}'s figure; ` : ""}the item's figures are drawn from ledger rows${row ? "" : " (name the row, or take it out)"}`); + } + if (row) { + const wrong = dates.filter((d) => !dateIs(d, row.date) && !dateIs(d, row.asOf)); + if (wrong.length) out.push(`${where} "${text}" says ${wrong.map((d) => `"${d.text}"`).join(", ")} -- not ${row.id}'s date (${dayMonth(row.date)}${row.asOf ? `, as of ${dayMonth(row.asOf)}` : ""})`); + } + return out; +} + +// --------------------------------------------------------------------------- +// Bounds. +// --------------------------------------------------------------------------- + +/** + * The bound a pace row's figure is, from its two ends' qualifiers: the true change against the computed one. Ending + * on "< v" (the weight was under v) the change is LESS than computed (more lost); starting on it, MORE (less lost); + * ">" the other way. Both ends bounding opposite ways: no bound can be said ("unknown"). Null: exact. + * + * @returns {null | "lt" | "gt" | "unknown"} + */ +export function paceBound(qa, qb) { + const dirs = []; + if (qa === "<") dirs.push("gt"); + if (qa === ">") dirs.push("lt"); + if (qb === "<") dirs.push("lt"); + if (qb === ">") dirs.push("gt"); + if (!dirs.length) return null; + return dirs.every((d) => d === dirs[0]) ? dirs[0] : "unknown"; +} + +/** + * A pace row's figure in words: `{ lead, figure, tail, text }`. Exact: the signed change ("−0.7 lb"). A bound, + * unsigned and in words that stay true whatever the real change was -- the change LESS than computed is "MORE THAN + * 10.5 lb lost" (or "AT MOST n lb gained"), MORE than computed "AT MOST 8.5 lb lost" (or "MORE THAN n lb gained"); + * opposite bounds "—". An "about" end ("≈"): "about −9 lb". + */ +export function paceWords(lb, bound, approx = false) { + const n = `${fmtWeight(Math.abs(lb))} lb`; + let w; + if (bound === "unknown") w = { lead: null, figure: "—", tail: null }; + else if (bound === "lt") w = lb < 0 ? { lead: "MORE THAN", figure: n, tail: "lost" } : { lead: "AT MOST", figure: n, tail: "gained" }; + else if (bound === "gt") w = lb <= 0 ? { lead: "AT MOST", figure: n, tail: "lost" } : { lead: "MORE THAN", figure: n, tail: "gained" }; + else if (approx) w = { lead: "about", figure: `${fmtSigned(lb)} lb`, tail: null }; + else w = { lead: null, figure: `${fmtSigned(lb)} lb`, tail: null }; + return { ...w, text: [w.lead, w.figure, w.tail].filter(Boolean).join(" ") }; +} + +/** A point as the dry-run and the lint name it: "w115 < 300", "w101 ≈324", "w110 310.5". */ +const endWords = (p) => `${p.row} ${p.qualifier === "<" || p.qualifier === ">" ? `${p.qualifier} ` : p.qualifier ?? ""}${fmtWeight(p.value)}`; + +// --------------------------------------------------------------------------- + /** The item's length: the audio's span, else `seconds` (default ANALYSIS_SECONDS.silent). */ export function analysisSeconds(entry) { const a = entry?.audio; @@ -99,6 +213,23 @@ export function analysisWarnings(manifest, { only = null } = {}) { } /** + * The ledger rows an analysis entry names (series rows, marks, pace ends given as ids, status rows, the dashed + * line's row) -- what `umtool ledger rm` counts as a reference. + */ +export function analysisRowRefs(entry) { + const out = new Set(); + const add = (v) => { if (typeof v === "string" && v && !isIso(v)) out.add(v); }; + if (Array.isArray(entry?.series?.rows)) entry.series.rows.forEach(add); + add(entry?.series?.from); + add(entry?.series?.to); + for (const m of Array.isArray(entry?.marks) ? entry.marks : []) add(m?.row); + for (const p of Array.isArray(entry?.pace) ? entry.pace : []) { add(p?.from); add(p?.to); } + for (const s of Array.isArray(entry?.status) ? entry.status : []) add(s?.row); + add(entry?.mark?.row); + return [...out]; +} + +/** * An analysis entry with `patch` laid over it, key by key: a key given replaces the entry's, `null` removes it, a key * not given is kept. Its `type` and `id` are not a patch's to change. Throws a sentence for a patch that is not an object. */ @@ -114,34 +245,6 @@ export function applyAnalysisPatch(entry, patch) { } /** - * The bound a pace row's figure is, from its two ends' qualifiers: the true change against the computed one. Ending - * on "< v" (the weight was under v) the change is LESS than computed (more lost); starting on it, MORE (less lost); - * ">" the other way. Both ends bounding opposite ways: no bound can be said ("unknown"). Null: exact. - * - * @returns {null | "lt" | "gt" | "unknown"} - */ -export function paceBound(qa, qb) { - const dirs = []; - if (qa === "<") dirs.push("gt"); - if (qa === ">") dirs.push("lt"); - if (qb === "<") dirs.push("lt"); - if (qb === ">") dirs.push("gt"); - if (!dirs.length) return null; - return dirs.every((d) => d === dirs[0]) ? dirs[0] : "unknown"; -} - -/** - * A pace row's bound as words before its figure, by size: "over" when the change is bigger than the figure says - * (a loss of more than 10.5), "under" when smaller (a loss of less than 8.5, or a gain). Null: exact. - */ -export function boundWord(lb, bound) { - if (!bound) return null; - if (bound === "unknown") return "unknown"; - const bigger = lb < 0 ? bound === "lt" : bound === "gt"; - return bigger ? "over" : "under"; -} - -/** * Every reason the item cannot be drawn (`errors`) and what is said about it (`warnings`), each naming the entry and * the row. `ctx`: `{ ledger, schema, timeline, render }` -- the WHOLE ledger (analysisLedger), the ledger's schema, * the cut's timeline. @@ -153,15 +256,15 @@ export function analysisProblems(entry, ctx) { /** * The plan: the points (each `{ n, row, value, day, date, said, kind, qualifier, bound, base? }`), the line through * them (trailLine: one point a day, the one said last, in date order), the axes laid in `box` (trailLayout, one - * cluster: `lo`/`hi`, `X`/`Y`, `grid`, `months`), the band, the marks, the pace rows, the status rows, the words, - * the audio and the seconds. Throws the errors (analysisProblems) when there are any. + * cluster: `lo`/`hi`, `X`/`Y`, `grid`, `months`, the dashed line's `mark`), the band, the marks, the pace rows, the + * status rows, the words, the audio and the seconds. Throws the errors (analysisProblems) when there are any. */ export function analysisPlan(entry, ctx, box = { x0: 70, x1: 800, y0: 150, y1: 560 }) { const r = resolve(entry, ctx); if (r.problems.errors.length) throw new Error(r.problems.errors.join("; ")); const { points } = r; const line = trailLine(points); - const mark = Number.isFinite(Number(entry.mark)) && entry.mark !== null && entry.mark !== "" ? Number(entry.mark) : null; + const mark = r.mark ? r.mark.value : null; const L = trailLayout(points, box, { thr: Infinity, mark }); const pos = new Map(points.map((p) => [p.n, { x: L.X(p.day), y: L.Y(p.value) }])); const step = L.hi - L.lo > 60 ? 20 : 10; @@ -186,7 +289,8 @@ export function analysisPlan(entry, ctx, box = { x0: 70, x1: 800, y0: 150, y1: 5 kicker: String(entry.kicker ?? "").trim(), reading: String(entry.reading ?? "").trim(), footnote: String(entry.footnote ?? "").trim(), - points, line: line.map((p) => p.n), pos, layout: { lo: L.lo, hi: L.hi, X: L.X, Y: L.Y, grid, months, mark, markY: mark !== null ? L.Y(mark) : null }, + points, line: line.map((p) => p.n), pos, + layout: { lo: L.lo, hi: L.hi, X: L.X, Y: L.Y, grid, months, mark, markRow: r.mark?.row ?? null, markLabel: r.mark?.label ?? null, markY: mark !== null ? L.Y(mark) : null }, band, marks, pace: r.pace, status: r.status, audio: r.audio, seconds: analysisSeconds(entry), first: points.length ? line[0] : null, last: points.length ? line[line.length - 1] : null, }; @@ -198,9 +302,10 @@ export function analysisFigures(plan) { for (const p of plan.points) { out.push(`point ${p.row}: ${p.qualifier ?? ""}${fmtWeight(p.value)} on ${p.date}${p.base ? ` (${p.raw} from ${p.base.row} ${fmtWeight(p.base.value)})` : ""}${p.bound ? " -- a bound, drawn hollow" : ""}`); } - if (plan.band) out.push(`band ${plan.band.from} → ${plan.band.to} "${plan.band.label}"`); + if (plan.layout.mark !== null) out.push(`line ${plan.layout.markLabel} (${plan.layout.markRow}), dashed`); + if (plan.band) out.push(`band ${plan.band.from} → ${plan.band.to} "${plan.band.label}" (typed dates)`); plan.pace.forEach((x, i) => out.push( - `pace[${i}] ${x.span}: ${x.word ? `${x.word} ` : ""}${x.text} (${x.from.row} ${fmtWeight(x.from.value)} → ${x.to.row} ${fmtWeight(x.to.value)}), ${x.days} days${x.boundRows.length ? ` -- a bound: ${x.boundRows.join(", ")}` : ""}`, + `pace[${i}] ${x.span}: ${x.text} (${endWords(x.from)} → ${endWords(x.to)}), ${x.days} days${x.boundRows.length ? ` -- a bound: ${x.boundRows.join(", ")}` : ""}`, )); plan.marks.forEach((k, i) => out.push(`marks[${i}] ${k.row}: ${k.text}`)); plan.status.forEach((s, i) => out.push(`status[${i}] ${s.label}: ${s.value}${s.note ? ` · ${s.note}` : ""}${s.row ? ` (${s.row})` : ""}`)); @@ -216,7 +321,7 @@ function resolve(entry, { ledger = [], schema = null, timeline = [], render = {} const warnings = []; const id = entry?.id ?? "?"; const at = `timeline ${id} (analysis)`; - const out = { problems: { errors, warnings }, points: [], band: null, marks: [], pace: [], status: [], audio: null }; + const out = { problems: { errors, warnings }, points: [], band: null, marks: [], pace: [], status: [], audio: null, mark: null }; if (!isObj(entry)) { errors.push(`${at}: not an object`); return out; } for (const k of Object.keys(entry)) if (!ANALYSIS_KEYS.includes(k)) errors.push(`${at}: unknown key "${k}"`); if (!String(entry.title ?? "").trim()) errors.push(`${at}: title is empty`); @@ -224,6 +329,10 @@ function resolve(entry, { ledger = [], schema = null, timeline = [], render = {} if (render && (Number(render.height) > Number(render.width) || render.format === "vertical")) { errors.push(`${at}: an analysis item has no vertical form -- a 9:16 cut cannot carry it`); } + const fits = (where, text, max) => { + const s = String(text ?? "").trim(); + if (s.length > max) errors.push(`${at}: ${where} is ${s.length} characters -- at most ${max} fit the frame (the lint's estimate; the build measures the page)`); + }; const s = measureSchema(schema ?? {}); const valueTrack = s.tracks.find((t) => t.role === "value")?.key ?? null; @@ -235,9 +344,10 @@ function resolve(entry, { ledger = [], schema = null, timeline = [], render = {} const series = entry.series; const weightRow = (r) => r.scope === valueTrack && ["current", "past", "delta"].includes(r.population); let picked = []; + let spanMode = false; if (isObj(series) && Array.isArray(series.rows)) { if (!series.rows.length) errors.push(`${at}: series.rows is empty`); - if (series.rows.length > ANALYSIS_LIMITS.rows) errors.push(`${at}: series.rows has ${series.rows.length} rows (at most ${ANALYSIS_LIMITS.rows})`); + if (series.rows.length > ANALYSIS_LIMITS.series) errors.push(`${at}: series.rows has ${series.rows.length} rows (at most ${ANALYSIS_LIMITS.series})`); const seen = new Set(); for (const rid of series.rows) { const r = byId.get(String(rid)); @@ -250,6 +360,7 @@ function resolve(entry, { ledger = [], schema = null, timeline = [], render = {} picked.push(r); } } else if (isObj(series) && (series.from !== undefined || series.to !== undefined)) { + spanMode = true; const a = endDay(series.from, byId), b = endDay(series.to, byId); if (!a.ok) errors.push(`${at}: series.from ${a.why}`); if (!b.ok) errors.push(`${at}: series.to ${b.why}`); @@ -262,6 +373,7 @@ function resolve(entry, { ledger = [], schema = null, timeline = [], render = {} } else errors.push(`${at}: series is { rows: [ids] } or { from, to }`); const points = []; + const baseless = []; for (const r of picked) { const raw = Number(r.value); if (r.value === null || r.value === "" || !Number.isFinite(raw)) { errors.push(`${at}: series row ${r.id} has no number`); continue; } @@ -273,7 +385,11 @@ function resolve(entry, { ledger = [], schema = null, timeline = [], render = {} let base = null; if (r.population === "delta") { base = runStartOf(rows, schema, r.date); - if (!base) { errors.push(`${at}: series row ${r.id} is a delta (${raw}) with no run start in the record to resolve it against`); continue; } + if (!base) { + if (spanMode) baseless.push(r); + else errors.push(`${at}: series row ${r.id} is a delta (${raw}) with no run start in the record to resolve it against`); + continue; + } value = r2(base.value + raw); } points.push({ @@ -282,25 +398,46 @@ function resolve(entry, { ledger = [], schema = null, timeline = [], render = {} qualifier: q, bound: q === "<" || q === ">", ...(base ? { base: { row: base.row, value: base.value } } : {}), }); } + if (baseless.length) { + const ok = picked.filter((r) => !baseless.includes(r)).map((r) => r.id); + errors.push(`${at}: series {from, to} takes ${baseless.map((r) => `${r.id} (${r.value})`).join(", ")} -- deltas with no run start in the record to resolve them against; name the rows instead: "series": { "rows": [${ok.map((x) => `"${x}"`).join(", ")}] }`); + } // `t` is the order he SAID them (date, then the ledger's order): of two weights for one day the line takes the later. points.sort((p, q) => dateKey(p.said).localeCompare(dateKey(q.said)) || order.get(p.row) - order.get(q.row)); points.forEach((p, i) => { p.t = i; p.n = i; }); out.points = points; const firstDay = points.length ? Math.min(...points.map((p) => p.day)) : NaN; const lastDay = points.length ? Math.max(...points.map((p) => p.day)) : NaN; + // A pace end: a row id, or a date with exactly one point of the series on it. const pointOf = (v) => { if (typeof v !== "string" || !v.trim()) return { ok: false, why: "is missing" }; if (isIso(v)) { const on = points.filter((p) => p.day === dayNumber(v)); if (!on.length) return { ok: false, why: `${v}: no point of the series on that day` }; - return { ok: true, p: on.reduce((a, b) => (b.t > a.t ? b : a)) }; + if (on.length > 1) return { ok: false, why: `${v}: ${on.map((p) => p.row).join(", ")} are all on that day -- name one by id` }; + return { ok: true, p: on[0] }; } const p = points.find((x) => x.row === v); if (p) return { ok: true, p }; return { ok: false, why: byId.has(v) ? `${v} is not a point of the series` : `${v} is not in the ledger` }; }; - // ---- the band ------------------------------------------------------------ + // ---- the dashed line: a row's value -------------------------------------- + if (entry.mark !== undefined && entry.mark !== null) { + const m = entry.mark; + if (!isObj(m) || typeof m.row !== "string") errors.push(`${at}: mark is { "row": "<id>" } -- the dashed line at that row's value (a bare number is not backed by a row)`); + else { + const r = byId.get(m.row); + const v = Number(r?.value); + if (!r) errors.push(`${at}: mark.row ${m.row} is not in the ledger`); + else if (speakerOf(r) !== null) errors.push(`${at}: mark.row ${m.row} is ${speakerOf(r)}'s, not his`); + else if (r.scope !== valueTrack || r.population === "delta" || r.value === null || r.value === "" || !Number.isFinite(v)) { + errors.push(`${at}: mark.row ${m.row} has no weight to draw a line at (${r.scope}/${r.population})`); + } else out.mark = { row: r.id, value: v, label: fmtWeight(v) }; + } + } + + // ---- the band: an event's dates, typed ------------------------------------- if (entry.band !== undefined && entry.band !== null) { const b = entry.band; if (!isObj(b)) errors.push(`${at}: band is { from, to, label }`); @@ -314,7 +451,8 @@ function resolve(entry, { ledger = [], schema = null, timeline = [], render = {} errors.push(`${at}: band ${a.date} → ${z.date} is outside the series (${isoOf(firstDay)} → ${isoOf(lastDay)})`); } else out.band = { from: a.date, to: z.date, fromDay: a.day, toDay: z.day, label: String(b.label ?? "").trim() }; } - if (hasDigit(b.label) && !/\b(19|20)\d\d\b/.test(String(b.label))) warnings.push(`${at}: band.label "${b.label}" has a number -- the item draws figures from rows`); + warnings.push(...numberWarnings(`${at}: band.label`, b.label)); + fits("band.label", b.label, ANALYSIS_TEXT.bandLabel); } } @@ -328,12 +466,16 @@ function resolve(entry, { ledger = [], schema = null, timeline = [], render = {} const f = pointOf(String(m.row ?? "")); if (!f.ok) { errors.push(`${at}: marks[${i}].row ${f.why}`); return; } const label = String(m.label ?? "").trim(); - if (hasDigit(label)) warnings.push(`${at}: marks[${i}].label "${label}" has a number -- the mark's figure and date are drawn from ${f.p.row}`); + const row = byId.get(f.p.row); + warnings.push(...numberWarnings(`${at}: marks[${i}].label`, label, { row, figures: [f.p.value, f.p.raw] })); const quote = typeof m.quote === "string" ? m.quote.trim() : ""; - const rowQuote = String(byId.get(f.p.row)?.quote ?? ""); + const rowQuote = String(row?.quote ?? ""); if (quote && rowQuote && !quoteIn(quote, rowQuote)) warnings.push(`${at}: marks[${i}].quote is not in ${f.p.row}'s quote -- say whose words they are`); + fits(`marks[${i}].quote`, quote, ANALYSIS_TEXT.quote); const fig = `${f.p.qualifier === "<" || f.p.qualifier === ">" || f.p.qualifier === "≈" ? `${f.p.qualifier} ` : ""}${fmtWeight(f.p.value)}`; - out.marks.push({ i, row: f.p.row, n: f.p.n, label, quote, text: `${fig} · ${dayMonth(f.p.date)}${label ? ` · ${label}` : ""}` }); + const text = `${fig} · ${dayMonth(f.p.date)}${label ? ` · ${label}` : ""}`; + fits(`marks[${i}] ("${text}")`, text, ANALYSIS_TEXT.mark); + out.marks.push({ i, row: f.p.row, n: f.p.n, label, quote, text }); }); } @@ -352,13 +494,16 @@ function resolve(entry, { ledger = [], schema = null, timeline = [], render = {} if (days <= 0) { errors.push(`${at}: pace[${i}] ends (${b.p.date}) on or before it starts (${a.p.date})`); return; } const lb = r2(b.p.value - a.p.value); const bound = paceBound(a.p.bound ? a.p.qualifier : null, b.p.bound ? b.p.qualifier : null); + const approx = a.p.qualifier === "≈" || b.p.qualifier === "≈"; + const words = paceWords(lb, bound, approx); const boundRows = [a.p, b.p].filter((p) => p.bound).map((p) => p.row); const note = String(x.note ?? "").trim(); - if (hasDigit(note)) warnings.push(`${at}: pace[${i}].note "${note}" has a number -- the row's pounds and days are computed`); - if (bound) warnings.push(`${at}: pace[${i}] ends on a bound (${boundRows.map((r) => `${r} ${points.find((p) => p.row === r).qualifier} ${fmtWeight(points.find((p) => p.row === r).value)}`).join(", ")}) -- drawn as ${bound === "unknown" ? "no figure (its bounds go both ways)" : `${boundWord(lb, bound)} ${fmtSigned(lb)} lb`}`); + warnings.push(...numberWarnings(`${at}: pace[${i}].note`, note)); + fits(`pace[${i}].note`, note, ANALYSIS_TEXT.paceNote); + if (bound) warnings.push(`${at}: pace[${i}] ends on a bound (${[a.p, b.p].filter((p) => p.bound).map(endWords).join(", ")}) -- drawn as ${words.text}`); out.pace.push({ i, span: spanWords(a.p.date, b.p.date), from: pick(a.p), to: pick(b.p), lb, days, note, - bound, boundRows, word: boundWord(lb, bound), text: bound === "unknown" ? "—" : `${fmtSigned(lb)} lb`, + bound, boundRows, approx, lead: words.lead, figure: words.figure, tail: words.tail, text: words.text, }); }); } @@ -372,20 +517,30 @@ function resolve(entry, { ledger = [], schema = null, timeline = [], render = {} if (!isObj(x)) { errors.push(`${at}: status[${i}] is { label, value, note, color, row? }`); return; } const color = x.color === undefined || x.color === null || x.color === "" ? "fg" : String(x.color); if (!ANALYSIS_COLORS.includes(color) && !/^#[0-9a-fA-F]{6}$/.test(color)) errors.push(`${at}: status[${i}].color "${color}" is ${ANALYSIS_COLORS.join(", ")} or a #rrggbb`); - const row = x.row === undefined || x.row === null || x.row === "" ? null : String(x.row); - if (row && !byId.has(row)) errors.push(`${at}: status[${i}].row ${row} is not in the ledger`); + const rid = x.row === undefined || x.row === null || x.row === "" ? null : String(x.row); + const row = rid ? byId.get(rid) ?? null : null; + if (rid && !row) errors.push(`${at}: status[${i}].row ${rid} is not in the ledger`); + else if (row && speakerOf(row) !== null) errors.push(`${at}: status[${i}].row ${rid} is ${speakerOf(row)}'s, not his -- a status names his own row`); if (!String(x.label ?? "").trim() || !String(x.value ?? "").trim()) errors.push(`${at}: status[${i}] needs a label and a value`); - if (!row && (hasDigit(x.value) || hasDigit(x.note))) warnings.push(`${at}: status[${i}] has a number and no row -- name the row it comes from (row)`); - if (row && hasDigit(x.note) && byId.get(row)?.date && !String(x.note).includes(dayMonth(byId.get(row).date))) { - warnings.push(`${at}: status[${i}].note "${x.note}" does not say ${row}'s date (${dayMonth(byId.get(row).date)})`); - } - out.status.push({ i, label: String(x.label ?? "").trim(), value: String(x.value ?? "").trim(), note: String(x.note ?? "").trim(), color, row }); + const figures = row ? [Number(row.value)] : []; + for (const k of ["label", "value", "note"]) warnings.push(...numberWarnings(`${at}: status[${i}].${k}`, String(x[k] ?? "").trim(), { row: row && speakerOf(row) === null ? row : null, figures })); + fits(`status[${i}].label`, x.label, ANALYSIS_TEXT.statusLabel); + fits(`status[${i}].value`, x.value, ANALYSIS_TEXT.statusValue); + fits(`status[${i}].note`, x.note, ANALYSIS_TEXT.statusNote); + out.status.push({ i, label: String(x.label ?? "").trim(), value: String(x.value ?? "").trim(), note: String(x.note ?? "").trim(), color, row: rid }); }); } + const tableRows = (Array.isArray(pace) ? pace.length : 0) + (Array.isArray(status) ? status.length : 0); + if (tableRows > ANALYSIS_LIMITS.rows) errors.push(`${at}: ${tableRows} pace and status rows -- the side panel holds ${ANALYSIS_LIMITS.rows}`); + + // ---- the words ----------------------------------------------------------- + for (const k of ["title", "kicker", "reading", "footnote"]) warnings.push(...numberWarnings(`${at}: ${k}`, typeof entry[k] === "string" ? entry[k].trim() : "")); + fits("title", entry.title, ANALYSIS_TEXT.title); + fits("kicker", entry.kicker, ANALYSIS_TEXT.kicker); + fits("footnote", entry.footnote, ANALYSIS_TEXT.footnote); + fits(`reading (two lines${entry.audio ? ", beside the QR" : ""})`, entry.reading, entry.audio ? ANALYSIS_TEXT.readingQr : ANALYSIS_TEXT.reading); - // ---- the words and the length ------------------------------------------- - if (hasDigit(entry.reading) && !/\b(19|20)\d\d\b/.test(String(entry.reading))) warnings.push(`${at}: reading has a number -- the item's figures are the chart's and the table's`); - if (entry.mark !== undefined && entry.mark !== null && !Number.isFinite(Number(entry.mark))) errors.push(`${at}: mark is a number (the line across, e.g. 300)`); + // ---- the sound and the length -------------------------------------------- const a = entry.audio; if (a !== undefined && a !== null) { if (!isObj(a)) errors.push(`${at}: audio is { clip, start, end }`); @@ -396,8 +551,14 @@ function resolve(entry, { ledger = [], schema = null, timeline = [], render = {} else if (clip.type !== "clip") errors.push(`${at}: audio.clip ${a.clip} is a ${clip.type} entry, not a clip`); if (!Number.isFinite(st) || !Number.isFinite(en) || en <= st) errors.push(`${at}: audio.start and audio.end are source seconds, end after start`); else if (clip?.type === "clip") { - if (st < Number(clip.start) - 1e-6 || en > Number(clip.end) + 1e-6) { - errors.push(`${at}: audio ${st}–${en} is outside ${clip.id}'s window ${clip.start}–${clip.end}`); + const cut = Number.isFinite(clip.cutStart) && Number.isFinite(clip.cutEnd); + const lo = cut ? Number(clip.cutStart) : Number(clip.start), hi = cut ? Number(clip.cutEnd) : Number(clip.end); + const gaps = gapsOf(clip).filter((g) => g.from < en && g.to > st); + if (en - st > ANALYSIS_SECONDS.audioMax + 1e-6) errors.push(`${at}: audio is ${r2(en - st)} s -- at most ${ANALYSIS_SECONDS.audioMax}`); + if (st < lo - 1e-6 || en > hi + 1e-6) { + errors.push(`${at}: audio ${st}–${en} is outside ${clip.id}'s ${cut ? "cut" : "window"} ${lo}–${hi} -- it plays only words the cut keeps`); + } else if (gaps.length) { + errors.push(`${at}: audio ${st}–${en} runs into ${clip.id}'s gap${gaps.length > 1 ? "s" : ""} ${gaps.map((g) => `${g.from}–${g.to}`).join(", ")} -- seconds the cut takes out`); } else { out.audio = { clip: clip.id, start: st, end: en, video: clip.video ?? null }; const heard = playedSpans(clip, render).filter((g) => g.from < en && g.to > st); diff --git a/umtool/report-to-video/analysis-plan.test.mjs b/umtool/report-to-video/analysis-plan.test.mjs @@ -1,11 +1,13 @@ // The analysis item's plan (analysis-plan.mjs): every figure from a ledger row, deltas against the run's start, bounds -// never exact (in the right direction on both sides of a pace row), and the refusals the lint names. +// never exact (in words, in the right direction on both sides of a pace row), typed numbers said, and the refusals +// the lint names. import { test } from "node:test"; import assert from "node:assert/strict"; import { - analysisFigures, analysisPlan, analysisProblems, analysisSeconds, boundWord, dayMonth, paceBound, spanWords, + analysisFigures, analysisPlan, analysisProblems, analysisRowRefs, analysisSeconds, dayMonth, paceBound, paceWords, spanWords, typedNumbers, } from "./analysis-plan.mjs"; +import { validateClipAudioEntries } from "./clip-audio.mjs"; // The first use's shape (quartering-diet, 12 Nov): ids, dates and values only -- no quotes. const SCHEMA = { @@ -29,6 +31,7 @@ const LEDGER = [ W("w137", "current", "2026-11-07", 288.5), W("x1", "current", "2026-10-01", 250, { speaker: "madamsavvy" }), { id: "p01", scope: "promise", population: "promise", date: "2026-10-23" }, + { id: "s01", scope: "promise", population: "promise_claim", date: "2026-10-23", speaker: "madamsavvy" }, ]; const TIMELINE = [ { type: "clip", id: "c46", video: "v1", start: 4111.4, end: 4158.8, cutStart: 4112.6, cutEnd: 4158.5, gaps: [{ from: 4127.15, to: 4132.45 }] }, @@ -42,7 +45,7 @@ const ITEM = { marks: [{ row: "w118", label: "offers the scale video" }, { row: "w115", label: "" }], pace: [{ from: "2026-09-24", to: "2026-10-15" }, { from: "2026-10-15", to: "2026-10-23" }, { from: "2026-10-23", to: "2026-11-03", note: "the World Series" }, { from: "w122", to: "w137" }], status: [{ label: "SCALE VIDEO", value: "NOT POSTED", note: "offered 23 Oct", color: "red", row: "p01" }], - reading: "By his own numbers the loss is steady.", footnote: "All figures are his own statements.", mark: 300, + reading: "By his own numbers the loss is steady.", footnote: "All figures are his own statements.", mark: { row: "w115" }, }; const errorsOf = (e, ctx = CTX) => analysisProblems(e, ctx).errors; const warningsOf = (e, ctx = CTX) => analysisProblems(e, ctx).warnings; @@ -56,15 +59,16 @@ test("every point is its row's weight at its plot date; a delta is the run's sta assert.equal(by.w104.value, 317.5); assert.deepEqual(by.w104.base, { row: "w91", value: 349 }); assert.equal(by.w122.value, 290.8); - assert.deepEqual(by.w122.base, { row: "w91", value: 349 }); assert.equal(by.w115.bound, true); - assert.equal(by.w115.qualifier, "<"); - // The line runs in date order: w91 (19 Jul) first. assert.equal(plan.points[plan.line[0]].row, "w91"); assert.equal(plan.points[plan.line.at(-1)].row, "w137"); + // The dashed line is a row's: w115's value, labelled with it. + assert.equal(plan.layout.mark, 300); + assert.equal(plan.layout.markLabel, "300"); + assert.equal(plan.layout.markRow, "w115"); }); -test("pace rows: pounds and days computed, never typed; a date names the point that day", () => { +test("pace rows: pounds and days computed, never typed; a date names the one point that day", () => { const { pace } = analysisPlan(ITEM, CTX); assert.deepEqual(pace.map((x) => [x.from.row, x.to.row, x.lb, x.days]), [ ["w110", "w115", -10.5, 21], ["w115", "w118", -8.5, 8], ["w118", "w122", -0.7, 11], ["w122", "w137", -2.3, 4], @@ -75,80 +79,124 @@ test("pace rows: pounds and days computed, never typed; a date names the point t assert.equal(pace[2].bound, null); }); -test("a bound end is a bound in the right direction: ending on < 300 the loss is OVER, starting on it UNDER", () => { +test("a bound end is said in words, unsigned, the right way: ending on < 300 MORE THAN n lost, starting on it AT MOST n lost", () => { const { pace } = analysisPlan(ITEM, CTX); - assert.equal(pace[0].bound, "lt"); - assert.equal(pace[0].word, "over"); + assert.equal(pace[0].text, "MORE THAN 10.5 lb lost"); assert.deepEqual(pace[0].boundRows, ["w115"]); - assert.equal(pace[1].bound, "gt"); - assert.equal(pace[1].word, "under"); - // And the other glyph: ending on "> v" the change is more than computed (less lost); starting on it, more lost. - assert.equal(paceBound(null, ">"), "gt"); + assert.equal(pace[1].text, "AT MOST 8.5 lb lost"); + // Every case: the computed change and the direction the truth lies in. + assert.equal(paceWords(-10.5, "lt").text, "MORE THAN 10.5 lb lost"); + assert.equal(paceWords(-8.5, "gt").text, "AT MOST 8.5 lb lost"); + assert.equal(paceWords(4, "gt").text, "MORE THAN 4 lb gained"); + assert.equal(paceWords(4, "lt").text, "AT MOST 4 lb gained"); + assert.equal(paceWords(-3, "unknown").text, "—"); + assert.equal(paceWords(-9, null, true).text, "about −9 lb"); + assert.equal(paceWords(-0.7, null).text, "−0.7 lb"); + // The ends' glyphs to a direction: "<" at the end, ">" at the start -> less than computed; opposite bounds -> none. + assert.equal(paceBound(null, "<"), "lt"); assert.equal(paceBound(">", null), "lt"); - assert.equal(boundWord(-10, paceBound(null, ">")), "under"); - assert.equal(boundWord(-10, paceBound(">", null)), "over"); - // Both ends agreeing: the same bound; bounding opposite ways (both "<", both ">"): no figure can be said. + assert.equal(paceBound("<", null), "gt"); + assert.equal(paceBound(null, ">"), "gt"); assert.equal(paceBound("<", ">"), "gt"); assert.equal(paceBound(">", "<"), "lt"); assert.equal(paceBound("<", "<"), "unknown"); assert.equal(paceBound(">", ">"), "unknown"); - assert.equal(paceBound("<", null), "gt"); - // A gain ending on "< v": the true change is smaller -- "under" a gain is the bigger figure's words reversed. - assert.equal(boundWord(4, "lt"), "under"); - assert.equal(boundWord(4, "gt"), "over"); const w = warningsOf(ITEM); - assert.ok(w.some((x) => /pace\[0\] ends on a bound \(w115 < 300\) -- drawn as over −10\.5 lb/.test(x)), w.join("\n")); - assert.ok(w.some((x) => /pace\[1\] ends on a bound \(w115 < 300\) -- drawn as under −8\.5 lb/.test(x)), w.join("\n")); + assert.ok(w.some((x) => /pace\[0\] ends on a bound \(w115 < 300\) -- drawn as MORE THAN 10\.5 lb lost/.test(x)), w.join("\n")); + assert.ok(w.some((x) => /pace\[1\] ends on a bound \(w115 < 300\) -- drawn as AT MOST 8\.5 lb lost/.test(x)), w.join("\n")); + assert.ok(!w.some((x) => /\bover\b|\bunder\b/i.test(x)), w.join("\n")); +}); + +test("an approximate end: 'about'", () => { + const ledger = [...LEDGER, W("ap", "current", "2026-10-01", 301.5, { qualifier: "≈" })]; + const e = { ...ITEM, series: { rows: ["w110", "ap"] }, pace: [{ from: "w110", to: "ap" }], marks: [], band: null, mark: null }; + const plan = analysisPlan(e, { ...CTX, ledger }); + assert.equal(plan.pace[0].text, "about −9 lb"); + assert.ok(analysisFigures(plan).some((l) => l === "pace[0] 24 Sep → 1 Oct: about −9 lb (w110 310.5 → ap ≈301.5), 7 days"), analysisFigures(plan).join("\n")); }); -test("--dry-run's figures name every row", () => { +test("--dry-run's figures name every row, a bound with its glyph", () => { const lines = analysisFigures(analysisPlan(ITEM, CTX)); assert.ok(lines.includes("point w104: 317.5 on 2026-09-04 (-31.5 from w91 349)"), lines.join("\n")); assert.ok(lines.includes("point w115: <300 on 2026-10-15 -- a bound, drawn hollow")); - assert.ok(lines.some((l) => l.startsWith("pace[0] 24 Sep → 15 Oct: over −10.5 lb (w110 310.5 → w115 300), 21 days -- a bound: w115"))); + assert.ok(lines.includes("pace[0] 24 Sep → 15 Oct: MORE THAN 10.5 lb lost (w110 310.5 → w115 < 300), 21 days -- a bound: w115"), lines.join("\n")); + assert.ok(lines.includes("pace[1] 15 → 23 Oct: AT MOST 8.5 lb lost (w115 < 300 → w118 291.5), 8 days -- a bound: w115")); + assert.ok(lines.includes("line 300 (w115), dashed")); assert.ok(lines.includes("marks[0] w118: 291.5 · 23 Oct · offers the scale video")); assert.ok(lines.includes("marks[1] w115: < 300 · 15 Oct")); assert.ok(lines.includes("silent, 7 s")); }); -test("series as a span: his own weights between two dates (another speaker's never)", () => { - const plan = analysisPlan({ ...ITEM, series: { from: "2026-09-01", to: "w137" }, pace: [], marks: [], band: null }, CTX); - assert.deepEqual(plan.points.map((p) => p.row).sort(), ["w104", "w110", "w115", "w117", "w118", "w122", "w137"].sort()); - // Two weights for 23 Oct (w117 said that day, w118 said on the 26th of the 23rd): the line takes the one said last. - const onDay = plan.line.map((n) => plan.points[n]).filter((p) => p.date === "2026-10-23"); - assert.deepEqual(onDay.map((p) => p.row), ["w118"]); +test("typed numbers: dates taken out, every other digit said, naming the field; a row backs only its own figure", () => { + assert.deepEqual(typedNumbers("offered 23 Oct, Oct 2026 and 2026-10-23").numbers, []); + assert.deepEqual(typedNumbers("In 2026 he lost 75 lb").numbers, ["2026", "75"]); + assert.deepEqual(typedNumbers("Oct 2026 · 75 LB").numbers, ["75"]); + assert.deepEqual(typedNumbers("on Oct 23, 2026 he said 61").numbers, ["61"]); + const w = warningsOf({ + ...ITEM, title: "He lost 61 lb", kicker: "61 LB DOWN", footnote: "Down 61 lb since July", reading: "In 2026 he lost 75 lb.", + band: { ...ITEM.band, label: "2026 · 75 LB" }, marks: [{ row: "w115", label: "under 300" }, { row: "w118", label: "291.5 on the scale" }, { row: "w137", label: "lost 70" }], + pace: [{ from: "w110", to: "w137", note: "3 weeks" }], + status: [{ label: "S", value: "5 days", note: "x" }, { label: "P", value: "SAID", note: "offered 24 Oct", row: "p01" }], + }); + const has = (re) => assert.ok(w.some((x) => re.test(x)), `${re}\n${w.join("\n")}`); + has(/title "He lost 61 lb" has "61" typed/); + has(/kicker "61 LB DOWN" has "61" typed/); + has(/footnote "Down 61 lb since July" has "61" typed/); + has(/reading "In 2026 he lost 75 lb\." has "2026", "75" typed/); + has(/band\.label "2026 · 75 LB" has "2026", "75" typed/); + has(/marks\[2\]\.label "lost 70" has "70" typed -- not w137's figure/); + has(/pace\[0\]\.note "3 weeks" has "3" typed/); + has(/status\[0\]\.value "5 days" has "5" typed/); + has(/status\[1\]\.note "offered 24 Oct" says "24 Oct" -- not p01's date \(23 Oct\)/); + // A mark's label that says its own row's figure is backed: "under 300" is w115's, "291.5" w118's. + assert.ok(!w.some((x) => /marks\[0\]|marks\[1\]/.test(x)), w.join("\n")); + // The first use's words: nothing. + assert.ok(!warningsOf(ITEM).some((x) => /typed|says/.test(x)), warningsOf(ITEM).join("\n")); }); test("refusals, each naming the row", () => { - assert.ok(errorsOf({ ...ITEM, series: { rows: ["w91", "w999"] } }).some((e) => /series row w999 is not in the ledger/.test(e))); - assert.ok(errorsOf({ ...ITEM, series: { rows: ["w91", "p01"] } }).some((e) => /series row p01 is not a weight/.test(e))); - assert.ok(errorsOf({ ...ITEM, series: { rows: ["w91", "x1"] } }).some((e) => /series row x1 is madamsavvy's/.test(e))); - assert.ok(errorsOf({ ...ITEM, band: { from: "2026-07-01", to: "2026-08-01", label: "" } }).some((e) => /band 2026-07-01 → 2026-08-01 is outside the series \(2026-07-19 → 2026-11-07\)/.test(e))); - assert.ok(errorsOf({ ...ITEM, pace: [{ from: "2026-09-24" }] }).some((e) => /pace\[0\]\.to is missing/.test(e))); - assert.ok(errorsOf({ ...ITEM, pace: [{ from: "2026-09-25", to: "w137" }] }).some((e) => /pace\[0\]\.from 2026-09-25: no point of the series on that day/.test(e))); - assert.ok(errorsOf({ ...ITEM, pace: [{ from: "w137", to: "w110" }] }).some((e) => /pace\[0\] ends \(2026-09-24\) on or before it starts/.test(e))); - assert.ok(errorsOf({ ...ITEM, marks: [{ row: "w117" }] }).some((e) => /marks\[0\]\.row w117 is not a point of the series/.test(e))); - assert.ok(errorsOf({ ...ITEM, reading: " " }).some((e) => /reading is empty/.test(e))); - assert.ok(errorsOf({ ...ITEM, status: [{ label: "X", value: "Y", row: "zz" }] }).some((e) => /status\[0\]\.row zz is not in the ledger/.test(e))); - assert.ok(errorsOf({ ...ITEM, status: [{ label: "X", value: "Y", color: "pink" }] }).some((e) => /status\[0\]\.color "pink"/.test(e))); - assert.ok(errorsOf({ ...ITEM, bogus: 1 }).some((e) => /unknown key "bogus"/.test(e))); + const has = (e, re, ctx) => assert.ok(errorsOf(e, ctx).some((x) => re.test(x)), `${re}\n${errorsOf(e, ctx).join("\n")}`); + has({ ...ITEM, series: { rows: ["w91", "w999"] } }, /series row w999 is not in the ledger/); + has({ ...ITEM, series: { rows: ["w91", "p01"] } }, /series row p01 is not a weight/); + has({ ...ITEM, series: { rows: ["w91", "x1"] } }, /series row x1 is madamsavvy's/); + has({ ...ITEM, band: { from: "2026-07-01", to: "2026-08-01", label: "" } }, /band 2026-07-01 → 2026-08-01 is outside the series \(2026-07-19 → 2026-11-07\)/); + has({ ...ITEM, pace: [{ from: "2026-09-24" }] }, /pace\[0\]\.to is missing/); + has({ ...ITEM, pace: [{ from: "2026-09-25", to: "w137" }] }, /pace\[0\]\.from 2026-09-25: no point of the series on that day/); + has({ ...ITEM, pace: [{ from: "w137", to: "w110" }] }, /pace\[0\] ends \(2026-09-24\) on or before it starts/); + has({ ...ITEM, marks: [{ row: "w117" }] }, /marks\[0\]\.row w117 is not a point of the series/); + has({ ...ITEM, reading: " " }, /reading is empty/); + has({ ...ITEM, status: [{ label: "X", value: "Y", row: "zz" }] }, /status\[0\]\.row zz is not in the ledger/); + has({ ...ITEM, status: [{ label: "X", value: "Y", row: "s01" }] }, /status\[0\]\.row s01 is madamsavvy's, not his/); + has({ ...ITEM, status: [{ label: "X", value: "Y", color: "pink" }] }, /status\[0\]\.color "pink"/); + has({ ...ITEM, bogus: 1 }, /unknown key "bogus"/); + has({ ...ITEM, mark: 300 }, /mark is \{ "row": "<id>" \} -- the dashed line at that row's value \(a bare number is not backed by a row\)/); + has({ ...ITEM, mark: { row: "p01" } }, /mark\.row p01 has no weight to draw a line at/); + has({ ...ITEM, mark: { row: "x1" } }, /mark\.row x1 is madamsavvy's/); + // Two points for one typed day: name one by id. + has({ ...ITEM, series: { rows: [...ITEM.series.rows, "w117"] } }, /pace\[1\]\.to 2026-10-23: w117, w118 are all on that day -- name one by id/); // A delta with no run start in the record to resolve it against. const lone = { ...CTX, ledger: [W("d1", "delta", "2020-01-05", -3), W("s1", "current", "2020-01-01", 200)] }; - assert.ok(errorsOf({ ...ITEM, series: { rows: ["s1", "d1"] }, band: null, pace: [], marks: [], status: [] }, lone).some((e) => /series row d1 is a delta \(-3\) with no run start/.test(e))); + const bare = { ...ITEM, band: null, pace: [], marks: [], status: [], mark: null }; + has({ ...bare, series: { rows: ["s1", "d1"] } }, /series row d1 is a delta \(-3\) with no run start/, lone); + // ... in a span: one sentence naming them all and the rows to name instead. + has({ ...bare, series: { from: "2020-01-01", to: "2020-01-31" } }, /series \{from, to\} takes d1 \(-3\) -- deltas with no run start .*"series": \{ "rows": \["s1"\] \}/, lone); assert.throws(() => analysisPlan({ ...ITEM, series: { rows: ["w999"] } }, CTX), /w999 is not in the ledger/); }); -test("audio: the clip must be a clip of the cut, its span inside its window; a span the cut plays is said", () => { - assert.ok(errorsOf({ ...ITEM, audio: { clip: "c99", start: 1, end: 9 } }).some((e) => /audio\.clip c99 is not an entry of the cut/.test(e))); - assert.ok(errorsOf({ ...ITEM, audio: { clip: "k1", start: 1, end: 9 } }).some((e) => /audio\.clip k1 is a card entry, not a clip/.test(e))); - assert.ok(errorsOf({ ...ITEM, audio: { clip: "c46", start: 4100, end: 4120 } }).some((e) => /audio 4100–4120 is outside c46's window 4111\.4–4158\.8/.test(e))); +test("audio: a clip of the cut, inside what its cut keeps -- never a gap, never past its cut, at most 30 s", () => { + const has = (e, re) => assert.ok(errorsOf(e).some((x) => re.test(x)), `${re}\n${errorsOf(e).join("\n")}`); + has({ ...ITEM, audio: { clip: "c99", start: 1, end: 9 } }, /audio\.clip c99 is not an entry of the cut/); + has({ ...ITEM, audio: { clip: "k1", start: 1, end: 9 } }, /audio\.clip k1 is a card entry, not a clip/); + has({ ...ITEM, audio: { clip: "c46", start: 4111.4, end: 4116 } }, /audio 4111\.4–4116 is outside c46's cut 4112\.6–4158\.5 -- it plays only words the cut keeps/); + has({ ...ITEM, audio: { clip: "c46", start: 4120, end: 4130 } }, /audio 4120–4130 runs into c46's gap 4127\.15–4132\.45/); + has({ ...ITEM, audio: { clip: "c46", start: 4127.2, end: 4132.4 } }, /runs into c46's gap/); + has({ ...ITEM, audio: { clip: "c46", start: 4113, end: 4158 } }, /audio is 45 s -- at most 30/); const ok = { ...ITEM, audio: { clip: "c46", start: 4112.6, end: 4127.1 } }; assert.deepEqual(errorsOf(ok), []); assert.equal(analysisSeconds(ok), 14.5); assert.ok(warningsOf(ok).some((w) => /the audio's span plays in the cut too \(c46 plays 4112\.6–4127\.1\)/.test(w))); - // Inside a gap of the clip: not heard twice. - const inGap = { ...ITEM, audio: { clip: "c46", start: 4127.5, end: 4132 } }; - assert.ok(!warningsOf(inGap).some((w) => /heard twice/.test(w))); + // The build's own clip-audio check leaves an analysis item's `audio` to this one. + assert.deepEqual(validateClipAudioEntries({ timeline: [...TIMELINE, ok] }), []); }); test("length: silent 7 s by default, at most 8 without audio; no vertical form", () => { @@ -160,15 +208,16 @@ test("length: silent 7 s by default, at most 8 without audio; no vertical form", assert.ok(errorsOf(ITEM, { ...CTX, render: { width: 1920, height: 1080, format: "vertical" } }).some((e) => /no vertical form/.test(e))); }); -test("numbers typed into words are said: a mark label, a pace note, a status without its row", () => { - const w = warningsOf({ - ...ITEM, marks: [{ row: "w115", label: "under 300" }], pace: [{ from: "w110", to: "w137", note: "3 weeks" }], - status: [{ label: "S", value: "5 days", note: "x" }], - }); - assert.ok(w.some((x) => /marks\[0\]\.label "under 300" has a number -- the mark's figure and date are drawn from w115/.test(x))); - assert.ok(w.some((x) => /pace\[0\]\.note "3 weeks" has a number/.test(x))); - assert.ok(w.some((x) => /status\[0\] has a number and no row/.test(x))); - assert.ok(!warningsOf(ITEM).some((x) => /status/.test(x))); +test("the frame's room: words past their length and rows past the panel are refused", () => { + const has = (e, re) => assert.ok(errorsOf(e).some((x) => re.test(x)), `${re}\n${errorsOf(e).join("\n")}`); + has({ ...ITEM, title: "W".repeat(80) }, /title is 80 characters -- at most 44 fit the frame/); + has({ ...ITEM, reading: "word ".repeat(60) }, /reading \(two lines\) is 299 characters -- at most 185/); + has({ ...ITEM, reading: "word ".repeat(34), audio: { clip: "c46", start: 4112.6, end: 4127.1 } }, /reading \(two lines, beside the QR\) is 169 characters -- at most 160/); + has({ ...ITEM, status: [...ITEM.status, { label: "WEIGH-IN", value: "NONE", color: "amber" }] }, /6 pace and status rows -- the side panel holds 5/); +}); + +test("the rows an item names, for `umtool ledger rm`", () => { + assert.deepEqual(analysisRowRefs(ITEM).sort(), ["p01", "w104", "w110", "w115", "w118", "w122", "w137", "w87", "w91", "w93"].sort()); }); test("words: a day and a span", () => { @@ -182,6 +231,5 @@ test("axes: one cluster fitted to the points (trailLayout), a tick per month, th assert.equal(plan.layout.lo, 280); assert.equal(plan.layout.hi, 360); assert.deepEqual(plan.layout.months.map((m) => m.text), ["JUL", "AUG", "SEP", "OCT", "NOV"]); - assert.equal(plan.layout.mark, 300); assert.ok(plan.band.x1 > plan.band.x0); }); diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs @@ -2998,12 +2998,15 @@ export async function buildTeaserSegment(entry, { manifestPath, render, outDir, // An `analysis` entry (analysis-plan.mjs) is a full-frame page drawn from the // ledger (chrome-analysis.mjs), composed and rendered once (cached by its page // key, as a teaser is) and encoded here with its sound: with `audio`, the -// named clip's sound over [start, end] -- read from that clip's own source as -// its segment reads it (fetchClipAligned: the raw cache, on its clock, its -// sync offset applied), levelled to the cut's loudness target as a clip is, -// faded in and out -- its picture never shown; without, digital silence. Its -// record (`<id>.analysis.json`) keys the frames, the sound and the encode, so -// an unchanged item is not encoded again. +// named clip's sound over [start, end] -- read from the window the clip's own +// segment is cut from (analysisAudioSource: on disk first, the piece holding +// the span for a clip fetched in pieces; its sync offset applied), at the +// level the clip plays at (its cut record's loudness gain, its own `audio.gain`), +// faded in and out -- its picture never shown; without, digital silence. The +// page is MEASURED first (chrome-analysis.mjs `?measure`: a box out of the +// frame, an overlap) and refused for it. Its record (`<id>.analysis.json`) +// keys the frames, the sound and the encode, so an unchanged item is not +// encoded again. /** The analysis sound's fades at its edges, in seconds. */ export const ANALYSIS_AUDIO_FADE = 0.3; @@ -3013,12 +3016,12 @@ export const ANALYSIS_AUDIO_FADE = 0.3; * clock, its level gain (`gain`, dB, or null), faded in and out and padded to `seconds`; null `audio`: the teaser's * silence (teaserAudioGraph with no hits). */ -export function analysisAudioGraph({ seconds, render, audio = null, gain = null, fade = ANALYSIS_AUDIO_FADE }) { +export function analysisAudioGraph({ seconds, render, audio = null, gain = null, clipGain = null, fade = ANALYSIS_AUDIO_FADE }) { if (!audio) return teaserAudioGraph([], { seconds, render }); const layout = render.audioChannels === 1 ? "mono" : "stereo"; const f = Math.min(fade, seconds / 4); return `[1:a]${[ - AUDIO_ON_CLOCK, gain != null ? levelFilters(gain) : "", + AUDIO_ON_CLOCK, gain != null ? levelFilters(gain) : "", ...clipAudioFilters(clipGain ? { gain: clipGain } : null, seconds), `afade=t=in:d=${f}`, `afade=t=out:st=${Number((seconds - f).toFixed(3))}:d=${f}`, `apad=whole_dur=${seconds}`, `aformat=sample_rates=${render.audioRate}:channel_layouts=${layout}`, ].filter(Boolean).join(",")}[ta]`; @@ -3033,6 +3036,37 @@ export function analysisEncodeArgs({ framesDir, seconds, render, audio, sound = } /** + * The window an analysis item's sound is read from: the audio clip's source as its own segment has it -- a window on + * disk holding its extent first (onDiskClipSource), else, for a clip fetched in pieces (fetchSpans), the piece that + * holds [start, end] (the span lies in one: it may not cross a gap), else the clip's fetch -- so a full build fetches + * nothing the clip's segment does not, and --chrome-only (skipFetch) reads only what is on disk. + */ +export async function analysisAudioSource(clip, audio, meta, render, local, opts = {}) { + const disk = await onDiskClipSource(clip, meta, render, local, opts); + if (disk) return alignedClipSource(disk); + const spans = hasLocalMedia(clip) ? [] : fetchSpans(clip, render, opts); + if (spans.length > 1) { + const span = spans.find((x) => Number(audio.start) >= x.from - 1e-6 && Number(audio.end) <= x.to + 1e-6); + if (!span) throw new Error(`${clip.id}: no piece of its window holds ${audio.start}–${audio.end}`); + return fetchClipAligned(clip, meta, render, local, { ...opts, span }); + } + return fetchClipAligned(clip, meta, render, local, opts); +} + +/** The analysis page measured (chrome-analysis.mjs `?measure`): its sentences, empty when it fits. */ +export async function measureAnalysisPage(projDir, render) { + const { rendererEnv } = await import("./compose-chrome.mjs"); + const { measuredProblems } = await import("./chrome-analysis.mjs"); + const { stdout } = await execFileP(process.env.CHROME ?? "/usr/bin/chromium", [ + "--headless", "--disable-gpu", "--no-sandbox", "--hide-scrollbars", `--window-size=${render.width},${render.height}`, + "--virtual-time-budget=8000", "--dump-dom", `file://${path.join(projDir, "index.html")}?measure=1`, + ], { maxBuffer: 1 << 26, env: rendererEnv() }); + const problems = measuredProblems(stdout); + if (problems === null) throw new Error(`the analysis page in ${projDir} did not measure itself (its fonts or script did not load)`); + return problems; +} + +/** * Compose and render the analysis item (cached by compose-chrome's key), then encode its segment with its sound * unless the one on disk was made from the same frames, sound and encode. `clipSource` gets the audio clip's source * (`{ path, fetchStart }`), `meta` its record's metadata (the citation line); both null without audio. @@ -3049,9 +3083,12 @@ export async function buildAnalysisSegment(entry, { manifestPath, manifest, rend phase: r.cached ? "cached" : "render", region: "analysis", segment: entry.id, frames: r.frameCount, key: r.key, dir: r.frames, seconds: Number(((Date.now() - t0) / 1000).toFixed(1)), }); + const misfit = await measureAnalysisPage(r.projDir, render); + if (misfit.length) throw new Error(`${entry.id}: the analysis page does not fit the frame -- ${misfit.join("; ")}`); const seconds = analysisSeconds(entry); let sound = null; let gain = null; + let clipGain = null; let soundKey = null; if (entry.audio) { const clip = (manifest.timeline ?? []).find((e) => e?.id === entry.audio.clip && e.type === "clip"); @@ -3060,13 +3097,23 @@ export async function buildAnalysisSegment(entry, { manifestPath, manifest, rend // The clip's sync offset (clip-audio.mjs): its sound read from that much earlier or later, as its segment reads it. const off = (clipAudioOf(clip)?.offset ?? 0) / 1000; const from = Number(entry.audio.start) - src.fetchStart - off; - sound = { path: src.path, from, seconds }; - if (loudnessTargetOf(render) != null) gain = (await montageLevel(src.path, Math.max(0, from), from + seconds, { target: loudnessTargetOf(render) })).gain; + if (from < -0.01) throw new Error(`${entry.id}: its audio starts ${(-from).toFixed(2)}s before ${path.basename(src.path)} begins -- fetch ${clip.id}'s window again (umtool fetch --refetch ${clip.id}) or start it later`); + sound = { path: src.path, from: Math.max(0, from), seconds }; + // The level the clip plays at in its own place: its cut record's loudness gain (measured over its cut), else + // that measured now over its play window; then its own `audio.gain`. + if (loudnessTargetOf(render) != null) { + const rec = await readCutRecord(path.join(outDir, "segments", `${clip.id}.mp4`)).catch(() => null); + if (Number.isFinite(rec?.loudness?.gain)) gain = rec.loudness.gain; + else { + const { from: pf, to: pt } = playWindow(clip, render); + gain = (await montageLevel(src.path, Math.max(0, pf - src.fetchStart - off), pt - src.fetchStart - off, { target: loudnessTargetOf(render) })).gain; + } + } + clipGain = clipAudioOf(clip)?.gain ?? null; const st = await stat(src.path); - soundKey = { file: path.basename(src.path), size: st.size, from: Number(from.toFixed(3)), gain }; - if (from < 0) EMIT("note", { id: entry.id, message: `${entry.id}: its audio starts ${(-from).toFixed(2)}s before ${path.basename(src.path)} — silence there` }); + soundKey = { file: path.basename(src.path), size: st.size, from: Number(sound.from.toFixed(3)), gain, clipGain }; } - const audio = analysisAudioGraph({ seconds, render, audio: sound ? entry.audio : null, gain }); + const audio = analysisAudioGraph({ seconds, render, audio: sound ? entry.audio : null, gain, clipGain }); const key = createHash("sha256") .update(JSON.stringify({ v: 1, frames: r.key, audio, sound: soundKey, encode: encodeArgs(render) })) .digest("hex"); @@ -6768,6 +6815,9 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly manifest.render = verticalRender(asked); // The brand intro is a landscape page: a short opens on its first moment. manifest.timeline = (manifest.timeline ?? []).filter((e) => !isIntro(e)); + // An analysis item is a landscape page with no vertical form (analysis-plan.mjs): refused before anything is spent. + const landscape = manifest.timeline.filter((e) => e?.type === "analysis").map((e) => e.id); + if (landscape.length) throw new Error(`vertical: ${landscape.join(", ")} ${landscape.length > 1 ? "are analysis items" : "is an analysis item"}, which has no vertical form -- take it out of the vertical cut`); } // A join preview (release 38, join-preview.mjs): the first few joins of // the cut, each clip shortened to a few seconds at the join, in the cut's look. @@ -7192,7 +7242,7 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly const meta = clip ? await clipMeta(clip, provenance) : null; return buildAnalysisSegment(entry, { manifestPath, manifest, render, outDir, variant, meta, - clipSource: clip ? (c) => fetchClipAligned(c, meta, render, dirs.local, o) : null, + clipSource: clip ? (c) => analysisAudioSource(c, entry.audio, meta, render, dirs.local, o) : null, }); } if (entry.type !== "teaser" && entry.type !== "clip" && entry.type !== "post") { diff --git a/umtool/report-to-video/chrome-analysis.mjs b/umtool/report-to-video/chrome-analysis.mjs @@ -24,7 +24,7 @@ export const ANALYSIS_MOTION = Object.freeze({ }); /** The frame, in the 1280x720 units the page is laid out in (scaled to the render). */ -export const ANALYSIS_BOX = Object.freeze({ x0: 70, x1: 800, y0: 150, y1: 560, panel: 850, panelR: 1230, qr: 150 }); +export const ANALYSIS_BOX = Object.freeze({ x0: 70, x1: 800, y0: 150, y1: 560, panel: 850, panelR: 1230, qr: 140 }); /** When each thing lands, in the item's own seconds: `{ title, axes, band, points: Map(n -> t), marks, rows: [t], reading, foot, end }`. */ export function analysisTimes(plan) { @@ -83,7 +83,7 @@ export function analysisHtml(entry, ctx, opts = {}) { for (const g of lay.grid) axes.push(`<div class="grid" style="top:${g.y}px"></div><div class="gv" style="top:${g.y}px">${g.v}</div>`); axes.push(`<div class="base" style="top:${px(B.y1)}px"></div>`); for (const m of lay.months) axes.push(`<div class="mt" style="left:${m.x}px; top:${px(B.y1)}px"></div><div class="mn" style="left:${m.x}px; top:${r4(px(B.y1) + px(10))}px">${m.text}</div>`); - if (lay.mark !== null) axes.push(`<div class="markl" style="top:${lay.markY}px"></div><div class="gv mk" style="top:${lay.markY}px">${lay.mark}</div>`); + if (lay.mark !== null) axes.push(`<div class="markl" style="top:${lay.markY}px"></div><div class="gv mk" style="top:${lay.markY}px">${esc(lay.markLabel)}</div>`); parts.push(`<div class="axes" data-k="axes">${axes.join("")}</div>`); hidden("axes"); show("axes", T.axes, 0.5); @@ -136,7 +136,7 @@ export function analysisHtml(entry, ctx, opts = {}) { plan.pace.forEach((x) => { const sub = [`${x.days} days`, x.note, x.bound ? boundNote(x) : ""].filter(Boolean).join(" · "); rows.push(`<div class="row"><div class="l"><div class="lt">${esc(x.span.toUpperCase())}</div><div class="ls">${esc(sub)}</div></div>` + - `<div class="v${x.bound ? " b" : ""}">${x.word && x.word !== "unknown" ? `<span class="bw">${x.word}</span>` : ""}${esc(x.text)}</div></div>`); + `<div class="v${x.bound ? " b" : ""}">${paceFigure(x)}</div></div>`); }); plan.status.forEach((x) => { rows.push(`<div class="row"><div class="l"><div class="lt">${esc(x.label)}</div>${x.note ? `<div class="ls">${esc(x.note)}</div>` : ""}</div>` + @@ -197,8 +197,9 @@ export function analysisHtml(entry, ctx, opts = {}) { .row .v { font-family: ${fontStack(fonts, "display")}; font-size: ${px(30)}px; color: ${C.fg}; white-space: nowrap; text-align: right; } .row .v.b { color: ${mix(C.bg, C.fg, 0.82)}; } .row .v.st { font-size: ${px(28)}px; } - .row .bw { font-family: ${fontStack(fonts, "condensed")}; font-size: ${px(16)}px; letter-spacing: 0.06em; color: ${C.muted}; - text-transform: uppercase; margin-right: ${px(8)}px; vertical-align: ${px(4)}px; } + .row .bw { font-family: ${fontStack(fonts, "condensed")}; font-size: ${px(15)}px; letter-spacing: 0.08em; color: ${C.muted}; } + .row .bw.ab { margin-right: ${px(8)}px; vertical-align: ${px(4)}px; } + .row .bt { font-family: ${fontStack(fonts, "condensed")}; font-size: ${px(17)}px; color: ${C.muted}; margin-left: ${px(4)}px; } .foot { position: absolute; left: ${px(B.x0)}px; right: ${px(1280 - B.panelR)}px; top: ${px(604)}px; } .foot.narrow { right: ${px(1280 - B.panelR + B.qr + 24)}px; } .rd { font-family: ${fontStack(fonts, "regular")}; font-size: ${px(24)}px; line-height: 1.3; color: ${C.fg}; } @@ -209,7 +210,7 @@ export function analysisHtml(entry, ctx, opts = {}) { id: "analysis", W, H, fps, fonts, gsap: opts.gsap, data: { total: plan.seconds, window: null, init, cues }, css, - body: `<div class="bg"></div>${parts.join("")}`, + body: `<div class="bg"></div>${parts.join("")}${measureScript(W, H)}`, }); } @@ -219,6 +220,78 @@ const dm = (iso) => { return m ? `${Number(m[3])} ${MON[Number(m[2]) - 1]}`.toUpperCase() : ""; }; +/** + * A pace row's figure: exact, the signed change; "about" before an approximate one; a bound in words, unsigned -- + * "MORE THAN" / "AT MOST" over the figure, "lost" / "gained" after it (analysis-plan.mjs paceWords). + */ +function paceFigure(x) { + if (x.lead === "about") return `<span class="bw ab">about</span>${esc(x.figure)}`; + if (x.lead) return `<div class="bw">${esc(x.lead)}</div><div>${esc(x.figure)}<span class="bt">${esc(x.tail)}</span></div>`; + return esc(x.figure); +} + +/** + * THE PAGE MEASURED (the build's check, `?measure`): at the item's last frame, every text box and the code + * against the frame and each other -- a box leaving the frame, a row's words and figure overlapping or the row + * wider than the panel, the table running into the reading, the QR or the citation over the table, the reading or + * the footnote, a mark over the table -- written as `data-measure` (a JSON list of sentences) on the root. + */ +function measureScript(W, H) { + return `<script data-measure=""> + (function () { + if (new URLSearchParams(location.search).get("measure") === null) return; + addEventListener("load", function () { + (document.fonts ? document.fonts.ready : Promise.resolve()).then(function () { + var tl = window.__timelines && window.__timelines["analysis"]; + if (tl) tl.seek(tl.duration(), false); + var W = ${W}, H = ${H}, P = []; + var R = function (el) { return el.getBoundingClientRect(); }; + var hit = function (a, b) { return a.width > 0 && b.width > 0 && a.left < b.right - 0.5 && b.left < a.right - 0.5 && a.top < b.bottom - 0.5 && b.top < a.bottom - 0.5; }; + var named = []; + var add = function (sel, name) { document.querySelectorAll(sel).forEach(function (el, i) { named.push({ el: el, name: name.replace("#", String(i)) }); }); }; + add(".kick", "the kicker"); add(".ttl", "the title"); add(".bandl", "the band's label"); add(".mk1", "marks[#]"); + add(".side .row", "table row #"); add(".rd", "the reading"); add(".fn", "the footnote"); add(".ci", "the citation"); add(".qr", "the QR"); + named.forEach(function (x) { + var r = R(x.el); + if (r.width > 0 && (r.left < -0.5 || r.top < -0.5 || r.right > W + 0.5 || r.bottom > H + 0.5)) P.push(x.name + " leaves the frame"); + }); + document.querySelectorAll(".side .row").forEach(function (row, i) { + if (row.scrollWidth > row.clientWidth + 1) P.push("table row " + i + " is wider than the panel (clipped)"); + var l = row.querySelector(".l"), v = row.querySelector(".v"); + if (l && v && R(l).right > R(v).left + 0.5) P.push("table row " + i + ": its words and its figure overlap"); + }); + var rows = Array.prototype.slice.call(document.querySelectorAll(".side .row")); + var foot = ["rd", "fn", "ci"].map(function (k) { return document.querySelector("." + k); }).filter(Boolean); + var last = rows[rows.length - 1]; + foot.forEach(function (f) { if (last && R(last).bottom > R(f).top + 0.5 && hit(R(document.querySelector(".side")), R(f))) P.push("the table runs into " + (f.className === "rd" ? "the reading" : f.className === "fn" ? "the footnote" : "the citation")); }); + var qr = document.querySelector(".qr"), ci = document.querySelector(".ci"); + [qr, ci].filter(Boolean).forEach(function (q) { + var qn = q === qr ? "the QR" : "the citation"; + rows.forEach(function (row, i) { if (hit(R(q), R(row))) P.push(qn + " overlaps table row " + i); }); + foot.forEach(function (f) { if (f !== q && hit(R(q), R(f))) P.push(qn + " overlaps " + (f.className === "rd" ? "the reading" : f.className === "fn" ? "the footnote" : "the citation")); }); + }); + var side = document.querySelector(".side"); + document.querySelectorAll(".mk1").forEach(function (m, i) { if (side && hit(R(m), R(side))) P.push("marks[" + i + "] runs into the table"); }); + document.documentElement.setAttribute("data-measure", JSON.stringify(P)); + }); + }); + })(); +</script>`; +} + +/** The measure's sentences from a page's dumped DOM (`data-measure`), or null when the page did not measure. */ +export function measuredProblems(dom) { + const m = /<html[^>]*\sdata-measure="([^"]*)"/.exec(String(dom ?? "")); + if (!m) return null; + const json = m[1].replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&"); + try { + const v = JSON.parse(json); + return Array.isArray(v) ? v.map(String) : null; + } catch { + return null; + } +} + /** The words under a bounded pace row: which end is a bound, as he said it ("to < 300"). */ function boundNote(x) { const end = (e) => `${e.qualifier} ${fmtWeight(e.value)}`; diff --git a/umtool/report-to-video/chrome-analysis.test.mjs b/umtool/report-to-video/chrome-analysis.test.mjs @@ -32,16 +32,19 @@ const ITEM = { marks: [{ row: "w118", label: "offers the scale video" }], pace: [{ from: "w110", to: "w115" }, { from: "w115", to: "w118" }], status: [{ label: "SCALE VIDEO", value: "NOT POSTED", note: "offered 23 Oct", color: "red" }], - reading: "The loss is steady.", footnote: "His own statements.", mark: 300, + reading: "The loss is steady.", footnote: "His own statements.", mark: { row: "w115" }, }; const dataOf = (html) => JSON.parse(/<script id="analysis-data" type="application\/json">(.*?)<\/script>/s.exec(html)[1]); -test("the page draws the plan's figures, a bound hollow and its pace rows over/under", () => { +test("the page draws the plan's figures, a bound hollow and its pace rows in words", () => { const html = analysisHtml(ITEM, CTX); assert.match(html, /data-duration="7"/); assert.match(html, /What his own numbers say/); - assert.match(html, /<span class="bw">over<\/span>−10\.5 lb/); - assert.match(html, /<span class="bw">under<\/span>−8\.5 lb/); + assert.match(html, /<div class="bw">MORE THAN<\/div><div>10\.5 lb<span class="bt">lost<\/span><\/div>/); + assert.match(html, /<div class="bw">AT MOST<\/div><div>8\.5 lb<span class="bt">lost<\/span><\/div>/); + assert.doesNotMatch(html, /−10\.5|−8\.5/); + // The dashed line at w115's value, labelled with it. + assert.match(html, /<div class="gv mk" style="top:[\d.]+px">300<\/div>/); assert.match(html, /21 days · to &lt; 300/); assert.match(html, /8 days · from &lt; 300/); assert.match(html, /291\.5 · 23 Oct · offers the scale video/); @@ -98,3 +101,12 @@ test("with audio: the citation line and the code", () => { test("deterministic", () => { assert.equal(analysisHtml(ITEM, CTX), analysisHtml(ITEM, CTX)); }); + +test("the page measures itself under ?measure (the build's check), and the dump is read back", async () => { + const { measuredProblems } = await import("./chrome-analysis.mjs"); + const html = analysisHtml(ITEM, CTX); + assert.match(html, /<script data-measure="">/); + assert.equal(measuredProblems("<html lang=\"en\" data-measure=\"[&quot;the reading leaves the frame&quot;]\"><body></body></html>")[0], "the reading leaves the frame"); + assert.deepEqual(measuredProblems('<html data-fit="1" data-measure="[]">'), []); + assert.equal(measuredProblems("<html><body></body></html>"), null); +}); diff --git a/umtool/report-to-video/clip-audio.mjs b/umtool/report-to-video/clip-audio.mjs @@ -63,8 +63,9 @@ export function validateClipAudio(audio, where = "audio") { export function validateClipAudioEntries(manifest) { const errors = []; (manifest?.timeline ?? []).forEach((e, i) => { - // A video entry's `audio` (bass, gain) is its own: video-entry.mjs validates it. - if (e?.audio === undefined || e?.type === "video") return; + // A video entry's `audio` (bass, gain) is its own: video-entry.mjs validates it. So is an analysis item's + // (`{clip, start, end}`: the clip whose sound plays under it -- analysis-plan.mjs validates it). + if (e?.audio === undefined || e?.type === "video" || e?.type === "analysis") return; const where = `timeline[${i}] (${e.id ?? "?"}).audio`; if (e.type && e.type !== "clip") { errors.push(`${where}: only a clip's sound has these settings`); return; } errors.push(...validateClipAudio(e.audio, where)); diff --git a/umtool/report-to-video/modules/analysis.mjs b/umtool/report-to-video/modules/analysis.mjs @@ -40,7 +40,7 @@ export default defineModule({ validate: (_value, { manifest }) => validateAnalysisEntries(manifest), docs: { heading: "Analysis item", - intro: "A timeline entry `{ type: \"analysis\", … }` (analysis-plan.mjs; [report-video.md](report-video.md#the-analysis-item)): a full-frame ending drawn from the LEDGER -- a chart of a named run of his weights (`series`: rows, or a span; a delta resolved against the run's start), a shaded `band`, `marks`, a `pace` table whose pounds and days are computed, `status` rows and ONE `reading` -- the line drawing in, the rows landing; with `audio` a clip's sound under it (its citation and QR on the page, its picture not), else silent for `seconds` (7, at most 8). Every figure traces to a ledger row; a bound (\"< 300\") is drawn hollow and a pace row ending on one says over/under.", + intro: "A timeline entry `{ type: \"analysis\", … }` (analysis-plan.mjs; [report-video.md](report-video.md#the-analysis-item)): a full-frame ending drawn from the LEDGER -- a chart of a named run of his weights (`series`: rows, or a span; a delta resolved against the run's start), a shaded `band`, `marks`, a `pace` table whose pounds and days are computed, `status` rows and ONE `reading` -- the line drawing in, the rows landing; with `audio` a clip's sound under it (its citation and QR on the page, its picture not), else silent for `seconds` (7, at most 8). Every figure traces to a ledger row (the dashed line too: `mark: {row}`); a bound (\"< 300\") is drawn hollow and a pace row ending on one says it in words (\"MORE THAN 10.5 lb lost\", \"AT MOST 8.5 lb lost\"); a number typed into the words is a lint warning.", rows: [ ["an `analysis` entry", "`title`, `kicker`, `series`, `band`, `marks`, `pace`, `status`, `reading`, `footnote`, `mark`, `audio?`, `seconds?`", "`umtool timeline <p> [--take <t>] add-analysis @<file>` · `set-analysis <id> @<file>` (or the JSON itself)"], ],