commit 17cfdb48f17c1e465883c88c60ff5d24b97cf869
parent 1a113d9c3d75c929900ff9d241f6e6326953f650
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Fri, 6 Nov 2026 21:14:02 -0500
Merge lane/dial-ghosts: the dial keeps a faint tick for every weight he claims, warmer for repeats; the goal board -- every goal in force on the dial, the CLOSEST headlined, a missed deadline struck -- read by the shelf too; an agreeing bound (">300" over 342) holds the weight; jokes and other speakers count in no tally (operator, 6 Nov: "a subtle line left over on the dial for every claim … changing color for repeats", "show each goal on the dial, and prioritize the closest one", "If a range is provided … don't change the current weight")
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
17 files changed, 1118 insertions(+), 125 deletions(-)
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -471,6 +471,7 @@ the one it always was.
| `scopes` | the ledger's tracks the instruments see (`["weight","regime"]`); a row of any other track is ignored entirely. Default: every track |
| `scale` | `{min, max}` in the ledger's unit: the dial's face. Default: the schema's `yMin`..`yMax` |
| `asOf` | the day the live countdowns and the promise clock count to (YYYY-MM-DD). Default: the day it is built |
+| `ghosts` | the dial's CLAIM GHOSTS: `true`, `{opacity, tolerance, ramp, pulse}`, or `false`/absent (off). A faint tick on the rim for every weight he has claimed, coloured and thickened by how often (Modules, [Scale dial](#scale-dial)) |
**The odometer** (ruled 5 Nov 2026, "go by his words"): only real-time loss claims count -- a `delta` below zero with
no `asOf` and not `retro`; a run's figure is its HIGHEST claim (his figure, over any app's he cites); a row's `run`
@@ -482,7 +483,12 @@ do, `due` when he gave a day) is checked by his later `promise_check` rows namin
another party's `promise_claim` rows (`speaker`, e.g. `madamsavvy`; `paidOn`; a `citeUrl`), and ended by a
`promise_outcome` (`outcome`: `kept` · `refunded` · `withdrawn`); `kept: true` on the promise or a check, or an
outcome `kept`, keeps it. A row with a `speaker` is someone else's: it moves none of his numbers (current, lost, net,
-goals, diet, the totals) and only feeds the promises (`state.promises[].claims`, `.outcome`).
+goals, diet, the totals) and only feeds the promises (`state.promises[].claims`, `.outcome`). A row whose
+`scopeConfidence` is `unresolved` (not a usable claim: a joke, a line that is not his) counts in NO tally -- goals set,
+the goal and the goal board, diets, pledges, promises, the odometer, "under 300" -- pinned or not (pinned, it is
+still on screen, and a reading still reads); the scoreboard's tallies skip another speaker's rows the same way. A
+qualified reading (`>300`, `<300`, `≈390`, a range) that agrees with the specific weight in force does not replace
+it -- not on the dial, not in the panel's WEIGHT cell (`boundAgrees`); one that contradicts it does.
Rows are written through `umtool ledger` only; `umtool measure` prints the slice:
@@ -1524,7 +1530,7 @@ filter. A knob absent is its default, and a module whose knobs are all absent dr
| [Moving start](#moving-start) `peak` | The starting weight as he retells it: a tick per telling on a small scale, a count per repeat, the drift bracketed. (a page over the whole cut) | `render.chrome.deck.peak` |
| [Goal stack](#goal-stack) `goals` | Each goal he names as a sticky note on a pile -- a repeat merged with its count, a deadline counted down to the render date. (a page over the whole cut) | `render.chrome.deck.goals` |
| [Thread rail](#thread-rail) `threads` | A card per thread beside the footage, lit as its clips play. (a page over the whole cut) | `render.chrome.threads` |
-| [Scale dial](#scale-dial) `dial` | A bathroom-scale face: the needle swings to each weight he states, his remembered weights as ghosts, his goal on the bezel. (a page over the whole cut) | `render.chrome.deck.dial` |
+| [Scale dial](#scale-dial) `dial` | A bathroom-scale face: the needle swings to each weight he states, his remembered weights as ghosts, every goal in force on the bezel (the closest headlined), and -- with deck.measure.ghosts -- a faint tick for every weight he has claimed. (a page over the whole cut) | `render.chrome.deck.dial` |
| [Lost odometer](#lost-odometer) `odometer` | Rolling digits of the pounds he says he has lost (only ever up), NET beside them. (a page over the whole cut) | `render.chrome.deck.odometer` |
| [Weight trail](#weight-trail) `trail` | His stated weights by date, drawn up to the playhead, the 300 lb line and the times he says he is under it. (a page over the whole cut) | `render.chrome.deck.trail` |
| [Flips](#flips) `flips` | Pairs of what was said then and now, in the side panel. (a page over the whole cut) | `render.chrome.flips` |
@@ -1815,7 +1821,7 @@ A sticky note per goal on a pile in a corner of the footage box, read off the sc
|---|---|---|
| `deck.goals` | `true` · `false` · `{show, position, x, y, scale, hold, finale, max, color, countdown}` · default on with a measure slice | `umtool look <p> deck.goals=false` |
| `deck.goals.position`, `.x`/`.y`, `.scale` | `top-left` `top-right` `bottom-left` `bottom-right` `top-center` `bottom-center` · design px · 0.5–2 · default `bottom-right`, unset, 1 | `umtool look <p> deck.goals.position=bottom-left` |
-| `deck.goals.position=shelf` | its shelf form (`deck.shelf`): the count of goals set in a column, then the notes fanned sideways like the diet's tags -- the headline goal in front when the measure state names one (`goals.headline`: the closest goal in force) with "+N more" for the others in force, else the newest; a new goal landing from above as on the pile; each older one showing its goal's words in the strip beside it (all of each when there is room); a repeat comes to the front with its ×n. The fan takes the shelf's spare width (shelfLayout), up to its notes side by side. On the shelf it stays up from the first goal (`hold` unset). What the dial draws of the goal stays on the dial | `umtool look <p> deck.shelf.items='["diet","goals"]' deck.goals.position=shelf` |
+| `deck.goals.position=shelf` | its shelf form (`deck.shelf`): the count of goals set in a column, then the notes fanned sideways like the diet's tags -- ordered by the dial's goal board (measure-goals.mjs `goalsAt(goalBoard(schedule.measure), t)`, so the shelf and the dial always agree): its headline -- the closest goal in force -- in front with "+N more" for the others in force, the rest by recency; a goal the board misses struck in red, MISSED on it, for the dial's 6 s; with no goal in force, the newest in front; a new goal landing from above as on the pile; each older one showing its goal's words in the strip beside it (all of each when there is room); a repeat comes to the front with its ×n. The fan takes the shelf's spare width (shelfLayout), up to its notes side by side. On the shelf it stays up from the first goal (`hold` unset). What the dial draws of the goal stays on the dial | `umtool look <p> deck.shelf.items='["diet","goals"]' deck.goals.position=shelf` |
| `deck.goals.max`, `.color`, `.countdown` | 1–8 notes · #hex paper · bool · default 4, the palette's amber, `true` | `umtool look <p> deck.goals.max=6` |
| `deck.goals.hold`, `.finale` | 0 (up from the first goal on) or 2–600 s after each · `hide` `show` · default 20, `hide` | `umtool look <p> deck.goals.hold=0` |
| `deck.goals.onPosts`, `.onChapters` | `dodge` `hide` `show` · default `dodge`: while a post item's card (its card, slot and strip as postLayout lays them: the schedule's `covers`) or a chapter band is up where it stands, it moves to a free anchor of the footage box -- a size down to half if it must, never onto another measure extra that is up -- and hides when none fits; `hide` hides, `show` stays over it | `umtool look <p> deck.goals.onPosts=hide` |
@@ -1832,13 +1838,16 @@ A card per thread in the side panel beside the footage, lit as its clips play; a
### Scale dial
-A bathroom-scale face at the top of the instruments' column (the right of the frame; the clip moves to the left -- `instrumentsGeometry`, 1248×702 footage beside a 600 px column at 1920×1080). It reads the schedule's `measure` (the measure ledger's slice): the red needle swings to each STATED weight at its event's `t` (the spoken word) with a spring (`back.out`, 0.9 s) and rests there -- a frame at rest is reused, not captured again; a qualifier draws a wedge in pounds (≈ 3 under to 1 over, `>` 10 up, `<` 10 down); every REMEMBERED weight is a grey tick, the latest a long ghost needle with its as-of date; the latest goal is an amber tick on the bezel and its words under the digits. It comes and goes with the deck (a card, the finale). With any instrument on, the posts stay in the footage box (`posts.shift` does not apply), and the side panel (`threads`, `flips`) and the posts feed are refused.
+A bathroom-scale face at the top of the instruments' column (the right of the frame; the clip moves to the left -- `instrumentsGeometry`, 1248×702 footage beside a 600 px column at 1920×1080). It reads the schedule's `measure` (the measure ledger's slice): the red needle swings to each STATED weight at its event's `t` (the spoken word) with a spring (`back.out`, 0.9 s) and rests there -- a frame at rest is reused, not captured again; a BOUND that agrees with the specific weight in force (">300" while he is at 342, "≈390" at 388, "330-340" at 337) is no new figure and moves neither the needle nor the number (measure-totals.mjs `boundAgrees`; it still leaves its claim ghost), while one that contradicts it (">300" at 291) moves them as any reading does; a qualifier draws a wedge in pounds (≈ 3 under to 1 over, `>` 10 up, `<` 10 down); every REMEMBERED weight is a grey tick, the latest a long ghost needle with its as-of date. GOALS (measure-goals.mjs `goalBoard`): every goal in force at the playhead is a mark on the bezel at its weight -- in force from the moment the cut shows it until he meets it in time, a newer goal of the same HORIZON replaces it (the same deadline day, the same deadline words, or both undated), or the record's date passes its day. The HEADLINE is the CLOSEST of them -- the least still to lose from his latest stated weight (a range to its top), ties to the soonest deadline -- the full amber tick, its words under the digits (`GOAL 320 · BY APR 2026`); the others a thin amber tick, no words; a range an amber band too. A goal whose day passes with his latest weight over it is MISSED: struck in the needle's red with a red flash, the line under the digits `MISSED 320 · BY APR 2026` for 6 s (`MISS_HOLD`), then gone; a day passing with his weight under it (a reading after the day) leaves quietly. A goal's day: the ledger's `due`, else his `deadline` words read ("by Christmas", "by the end of 2026"), else the row's `asOf`. Any page that shows a goal reads the same board: `goalBoard(schedule.measure)` -> `[{ t, active, headline, missed, cur }]`, `goalsAt(board, t)`. It comes and goes with the deck (a card, the finale). With any instrument on, the posts stay in the footage box (`posts.shift` does not apply), and the side panel (`threads`, `flips`) and the posts feed are refused.
| Knob | Range · default | From a terminal |
|---|---|---|
| `deck.dial` | `true` · an object of the knobs below · `false` off · absent: ON when the cut draws a measure (`deck.measure` set), else off | `umtool look <p> deck.dial=false` |
| `deck.dial.mark` | a weight, or `null` · default `300` (its tick and label in the accent) | `umtool look <p> deck.dial.mark=300` |
-| `deck.dial.ghosts`, `.goal` | bool · default `true` each | `umtool look <p> deck.dial.ghosts=false` |
+| `deck.dial.ghosts`, `.goal` | bool · default `true` each (`.goal`: every goal in force, the closest headlined) | `umtool look <p> deck.dial.ghosts=false` |
+| `deck.measure.ghosts` | `true` · `{opacity, tolerance, ramp, pulse}` · `false` / absent: off (the default). CLAIM GHOSTS (measure-ghosts.mjs), not `deck.dial.ghosts`: every weight he has claimed so far -- each stated weight the needle goes to and each remembered one, his own, in cut order -- leaves a thin faint tick across the dial's rim at its value, under everything else on the face; a value claimed again (within `tolerance` lb of the tick's first value; an `≈` value as its rounded number; `>300` and `<300` at 300) steps that tick along the `ramp` -- 1× faint, 2× warm, 3× and up hot, a little thicker each step -- and it pulses once as the repeat lands (`pulse`). In the finale every tick stays at its count at the cut's end. Seek-safe: a frame at t draws the claims before t | `umtool look <p> deck.measure.ghosts=true` |
+| `deck.measure.ghosts.opacity`, `.tolerance` | 0.15–0.9 (the 1× tick's; +0.2 a step, at most 0.95) · 0–5 lb · default `0.5`, `0.5` | `umtool look <p> deck.measure.ghosts='{"tolerance":1}'` |
+| `deck.measure.ghosts.ramp`, `.pulse` | 2–4 #hex, 1× first (the last for every count from there up), or `null`: the palette's muted, amber, and amber half way to the needle's red · bool · default `null`, `true` | `umtool look <p> deck.measure.ghosts='{"ramp":["#98a29b","#e8a33f","#f37e47"],"pulse":false}'` |
| `deck.dial.needle` | a #hex · default `#ff5a4e` | `umtool look <p> deck.dial.needle='"#ff5a4e"'` |
| `deck.dial.label` | words over the digits, ≤ 40 · default `HE SAYS HE WEIGHS` | `umtool look <p> deck.dial.label='"…"'` |
| `deck.dial.finale` | bool · default `true`: the dial and the odometer large in the finale (module `dial-finale`) | `umtool look <p> deck.dial.finale=false` |
diff --git a/umtool/report-to-video/chrome-instruments.mjs b/umtool/report-to-video/chrome-instruments.mjs
@@ -19,6 +19,8 @@ import { finaleLayout } from "./chrome-finale.mjs";
import { FINALE_MOTION } from "./finale.mjs";
import { resolveDial, resolveOdometer, resolveTrail } from "./instruments.mjs";
import { promiseStates, upSpans } from "./measure-extras.mjs";
+import { ghostOpacity, ghostRamp, ghostTicks, resolveGhosts } from "./measure-ghosts.mjs";
+import { goalBoard, goalsAt } from "./measure-goals.mjs";
import { resolveMeasureExtra } from "./modules/measure-extras-settings.mjs";
import {
cueList, dayNumber, dialAngle, dialFaceSvg, dialFigures, DIAL_SWEEP, esc, fmtDate, fmtSigned, fmtWeight, INSTANT, measureTrack,
@@ -119,6 +121,64 @@ export const goalWords = (g) => {
return when ? `${what} · ${String(when).toUpperCase()}` : what;
};
+/** A goal's day as the dial says it: his words ("BY CHRISTMAS 2026", the year added when they name none), else "BY APR 2026". */
+export function goalWhen(g) {
+ const year = /^(\d{4})-/.exec(String(g?.deadlineDate ?? ""))?.[1] ?? null;
+ if (g?.deadline) return `${String(g.deadline).toUpperCase()}${year && !/\d{4}/.test(g.deadline) ? ` ${year}` : ""}`;
+ return g?.deadlineDate ? `BY ${fmtDate(g.deadlineDate, { day: false })}` : "";
+}
+
+/**
+ * A goal board's goal (measure-goals.mjs) in words: "GOAL 320 · BY APR 2026", "GOAL 230–240",
+ * "GOAL 250 · LOSE 50" (a loss resolved, no day), "LOSE 75" (unresolved); `missed`: "MISSED 320 · BY APR 2026".
+ */
+export function boardGoalWords(g, { missed = false } = {}) {
+ if (!g) return "";
+ const when = goalWhen(g);
+ const num = Array.isArray(g.range) && g.range.length === 2 ? `${fmtWeight(g.range[0])}–${fmtWeight(g.range[1])}`
+ : Number.isFinite(g.target) ? fmtWeight(g.target) : null;
+ if (missed) return [`MISSED ${num ?? (Number.isFinite(g.loss) ? `LOSE ${fmtWeight(g.loss)}` : "GOAL")}`, when].filter(Boolean).join(" · ");
+ const what = num !== null
+ ? `GOAL ${num}${g.kind === "goalLoss" && Number.isFinite(g.loss) && !when ? ` · LOSE ${fmtWeight(g.loss)}` : ""}`
+ : Number.isFinite(g.loss) ? `LOSE ${fmtWeight(g.loss)}` : "GOAL";
+ return [what, when].filter(Boolean).join(" · ");
+}
+
+/**
+ * The goal board's goals as the dial marks them: each goal the board ever holds (in the order it first does), its
+ * angle (null when it has no weight on the face), and its status in each board state -- "head", "other", "missed"
+ * (with `wasHeadline`) or "off".
+ */
+export function goalMarks(board, scale) {
+ const goals = [];
+ const index = new Map();
+ for (const b of board) {
+ for (const g of [...b.active, ...b.missed]) {
+ if (index.has(g.row)) continue;
+ index.set(g.row, goals.length);
+ const onFace = Number.isFinite(g.target) && g.target >= scale.min && g.target <= scale.max;
+ const r = g.range;
+ const band = Array.isArray(r) && dialAngle(r[1], scale) > dialAngle(r[0], scale);
+ goals.push({ goal: g, angle: onFace ? dialAngle(g.target, scale) : null, band });
+ }
+ }
+ const statusIn = (b, row) => {
+ const m = b.missed.find((x) => x.row === row);
+ if (m) return { status: "missed", wasHeadline: !!m.wasHeadline };
+ if (b.headline?.row === row) return { status: "head" };
+ return b.active.some((x) => x.row === row) ? { status: "other" } : { status: "off" };
+ };
+ return goals.map((x) => ({ ...x, states: board.map((b) => ({ t: b.t, ...statusIn(b, x.goal.row) })) }));
+}
+
+/** What the goal line under the digits says in each board state: the latest miss while it is held, else the headline. */
+export function goalLines(board) {
+ return board.map((b) => {
+ const miss = [...b.missed].sort((x, y) => x.at - y.at).pop();
+ return { t: b.t, words: miss ? boardGoalWords(miss, { missed: true }) : boardGoalWords(b.headline), missed: !!miss };
+ });
+}
+
// ---------------------------------------------------------------------------
// The dial.
// ---------------------------------------------------------------------------
@@ -179,7 +239,7 @@ function asofSpots({ C, Rf, u, a, head, forms, px, fpx }) {
* the hub and the readout blocks. Shared by the column's dial and the
* finale's. Returns its markup and css; its cues are the caller's.
*/
-function dialParts({ size, ox, oy, scale, cfg, colors, fonts, track, prefix = "", preState = true }) {
+function dialParts({ size, ox, oy, scale, cfg, colors, fonts, track, marks = [], lines = [], ghosts = null, prefix = "", preState = true }) {
const face = dialFaceSvg({ size, scale, mark: cfg.mark, colors: { ...colors, mark: colors.accent }, labelFont: fontStack(fonts, "condensed") });
const { C, R, Rf, u } = face;
const px = (v) => Math.round(v * u * 100) / 100;
@@ -188,6 +248,20 @@ function dialParts({ size, ox, oy, scale, cfg, colors, fonts, track, prefix = ""
const layer = (k, inner, cls = "ly") => `<div class="${cls}" data-k="${prefix}${k}"><svg width="${size}" height="${size}" viewBox="0 0 ${size} ${size}">${inner}</svg></div>`;
const parts = [];
parts.push(`<div class="ly face">${face.svg}</div>`);
+ // The claim ghosts (deck.measure.ghosts, measure-ghosts.mjs): under everything on the face, a thin tick across the
+ // rim at each value he has claimed -- one line per step of the ramp (its colour, a little thicker each step), the
+ // step its count is on shown, and a pulse line that flashes as a repeat lands.
+ if (ghosts) {
+ // From just in from the bezel's outer edge to just short of the scale's ticks (they start 6 px in).
+ const r0 = C - R + 2 * u, r1 = C - Rf + 8 * u;
+ ghosts.ticks.forEach((x, i) => {
+ const lines = ghosts.ramp.map((c, k) =>
+ `<div class="ly" data-k="${prefix}gt${i}s${k}"><svg width="${size}" height="${size}" viewBox="0 0 ${size} ${size}"><line x1="${C}" y1="${r0}" x2="${C}" y2="${r1}" stroke="${c}" stroke-width="${px(ghostWidth(k, ghosts.ramp.length))}" stroke-linecap="round"/></svg></div>`).join("");
+ const pulses = ghosts.cfg.pulse ? ghosts.ramp.map((c, k) => (k === 0 ? "" :
+ `<div class="ly" data-k="${prefix}gt${i}p${k}"><svg width="${size}" height="${size}" viewBox="0 0 ${size} ${size}"><line x1="${C}" y1="${C - R - 1 * u}" x2="${C}" y2="${C - Rf + 14 * u}" stroke="${c}" stroke-width="${px(ghostWidth(k, ghosts.ramp.length) + 2)}" stroke-linecap="round"/></svg></div>`)).join("") : "";
+ parts.push(`<div class="ly" data-k="${prefix}gt${i}">${lines}${pulses}</div>`);
+ });
+ }
// Where words laid on the face must not go: its scale figures, and the hub.
const faceFigures = dialFigures({ size, scale, mark: cfg.mark });
const hub = { x0: C - 18 * u, x1: C + 18 * u, y0: C - 18 * u, y1: C + 18 * u };
@@ -223,13 +297,20 @@ function dialParts({ size, ox, oy, scale, cfg, colors, fonts, track, prefix = ""
parts.push(`<div class="qlab" data-k="${prefix}ql${j}" style="left:${spot.x}px; top:${spot.y}px">${esc(words)}</div>`);
});
if (cfg.goal) {
- parts.push(layer("gl", `<polygon points="${C - 11 * u},${C - R - 2 * u} ${C + 11 * u},${C - R - 2 * u} ${C},${C - Rf + 16 * u}" fill="${colors.amber}" stroke="${colors.bg}" stroke-width="${px(2)}"/>`));
- // A goal he gave as a range: the tick spans it, an amber band on the bezel.
- track.goals.forEach((g, j) => {
- const r = g.goal?.range;
- if (!Array.isArray(r)) return;
- const b0 = dialAngle(r[0], scale), b1 = dialAngle(r[1], scale);
- if (b1 > b0) parts.push(`<div class="ly" data-k="${prefix}gr${j}"><svg width="${size}" height="${size}" viewBox="0 0 ${size} ${size}"><path d="${sectorPath(C, C, Rf + 2 * u, R + 4 * u, b0, b1)}" fill="${colors.amber}" fill-opacity="0.9"/></svg></div>`);
+ // EVERY goal in force (measure-goals.mjs goalBoard), each a mark on the bezel at its weight: the headline -- the
+ // closest -- the full amber triangle; the others a thin amber tick; a missed one struck through in the needle's
+ // red, a red flash as it is missed. A range is an amber band on the bezel besides (its headline's brighter).
+ const svg = (k, inner) => `<div class="ly" data-k="${prefix}${k}"><svg width="${size}" height="${size}" viewBox="0 0 ${size} ${size}">${inner}</svg></div>`;
+ marks.forEach((m, i) => {
+ const r = m.goal.range;
+ if (m.band) parts.push(svg(`gb${i}`, `<path d="${sectorPath(C, C, Rf + 2 * u, R + 4 * u, dialAngle(r[0], scale), dialAngle(r[1], scale))}" fill="${colors.amber}"/>`));
+ if (m.angle === null) return;
+ const head = `<polygon points="${C - 11 * u},${C - R - 2 * u} ${C + 11 * u},${C - R - 2 * u} ${C},${C - Rf + 16 * u}" fill="${colors.amber}" stroke="${colors.bg}" stroke-width="${px(2)}"/>`;
+ const other = `<polygon points="${C - 7 * u},${C - R - 1 * u} ${C + 7 * u},${C - R - 1 * u} ${C},${C - Rf + 11 * u}" fill="${colors.amber}" stroke="${colors.bg}" stroke-width="${px(1.5)}"/>`;
+ const strike = `<line x1="${C - 13 * u}" y1="${C - R + 1 * u}" x2="${C + 13 * u}" y2="${C - Rf + 12 * u}" stroke="${colors.needle}" stroke-width="${px(4)}" stroke-linecap="round"/>` +
+ `<line x1="${C + 13 * u}" y1="${C - R + 1 * u}" x2="${C - 13 * u}" y2="${C - Rf + 12 * u}" stroke="${colors.needle}" stroke-width="${px(4)}" stroke-linecap="round"/>`;
+ const flash = `<polygon points="${C - 17 * u},${C - R - 5 * u} ${C + 17 * u},${C - R - 5 * u} ${C},${C - Rf + 26 * u}" fill="none" stroke="${colors.needle}" stroke-width="${px(3)}" stroke-linejoin="round"/>`;
+ parts.push(`<div class="ly" data-k="${prefix}gm${i}">${svg(`gm${i}h`, head)}${svg(`gm${i}o`, other)}${svg(`gm${i}x`, strike)}${svg(`gm${i}p`, flash)}</div>`);
});
}
if (cfg.ghosts && track.remembered.length) {
@@ -265,8 +346,8 @@ function dialParts({ size, ox, oy, scale, cfg, colors, fonts, track, prefix = ""
parts.push(`<div class="read${pre ? " pre" : ""}" data-k="${prefix}cv${j}" style="top:${C + 86 * u}px"><div class="big">${has ? `${esc(weightWords(c))}<i>LB</i>` : pre ? "NO WEIGHT<br>STATED YET" : "—"}</div>${has && c.date ? `<div class="when" style="top:${78 * u}px">${esc(fmtDate(c.date))}</div>` : ""}</div>`);
});
if (cfg.goal) {
- track.goals.forEach((g, j) => {
- parts.push(`<div class="goalw" data-k="${prefix}gw${j}" style="top:${C + 188 * u}px">${esc(goalWords(g.goal))}</div>`);
+ lines.forEach((g, j) => {
+ parts.push(`<div class="goalw${g.missed ? " miss" : ""}" data-k="${prefix}gw${j}" style="top:${C + 188 * u}px">${esc(g.words)}</div>`);
});
}
const css = `
@@ -291,15 +372,25 @@ function dialParts({ size, ox, oy, scale, cfg, colors, fonts, track, prefix = ""
.dial .qlab { position: absolute; transform: translate(-50%, -50%); font-family: ${fontStack(fonts, "display")}; font-size: ${px(26)}px;
color: ${colors.accent}; white-space: nowrap; padding: ${px(1)}px ${px(6)}px; border-radius: ${px(5)}px; background: ${rgba(colors.face, 0.9)}; }
.dial .goalw { position: absolute; left: 0; width: ${size}px; text-align: center; font-family: ${fontStack(fonts, "bold")};
- font-size: ${fpx(17)}px; line-height: ${Math.max(15, px(20))}px; letter-spacing: 0.05em; color: ${colors.amber}; white-space: nowrap; }`;
+ font-size: ${fpx(17)}px; line-height: ${Math.max(15, px(20))}px; letter-spacing: 0.05em; color: ${colors.amber}; white-space: nowrap; }
+ .dial .goalw.miss { color: ${colors.needle}; }`;
return { html: `<div class="dial">${parts.join("\n ")}</div>`, css, face };
}
+/** A claim ghost's width (face px at 524) on step `k` of a ramp of `n`: 1.8 at 1x to 3.4 at the last. */
+export const ghostWidth = (k, n) => Math.round((1.8 + (n > 1 ? (k / (n - 1)) * 1.6 : 0)) * 100) / 100;
+
+/** The claim ghosts' seconds: a step's fade, a pulse's flash and its decay. */
+export const GHOST_MOTION = Object.freeze({ fade: 0.35, flash: 0.12, decay: 0.9 });
+
+/** A miss's flash: in, held, out (s). */
+export const MISS_MOTION = Object.freeze({ in: 0.15, hold: 0.5, out: 0.8 });
+
/** The needle's ease (`deck.dial.motion`): the spring's overshoot and settle, or a plain ease. */
const needleEase = (cfg, spring = INSTRUMENT_MOTION.needleEase) => (cfg.motion === "ease" ? INSTRUMENT_MOTION.needlePlain : spring);
/** The dial's cues over the cut: the needle on each stated weight, the ghosts, the wedges, the goal, the readout. */
-function dialCues(L, { track, scale, cfg, prefix = "", finale = false }) {
+function dialCues(L, { track, scale, cfg, marks = [], lines = [], ghosts = null, prefix = "", finale = false, at = 0 }) {
const M = INSTRUMENT_MOTION;
const a0 = DIAL_SWEEP.a0;
const k = (s) => `${prefix}${s}`;
@@ -352,37 +443,85 @@ function dialCues(L, { track, scale, cfg, prefix = "", finale = false }) {
blocks(L, track.remembered, k("ga"), { fade: M.fade });
}
}
- if (cfg.goal) {
- // A goal off the face (a loss resolved below the scale's foot: "lose 100" from 240) has no tick --
- // pinned at the foot it would say a weight he never named. Its words stay under the digits.
- const onFace = (v) => Number.isFinite(v) && v >= scale.min && v <= scale.max;
- const first = track.goals.find((g) => onFace(g.goal?.value));
- L.set(k("gl"), { rotation: first ? dialAngle(first.goal.value, scale) : a0, autoAlpha: 0 });
- let up = false;
- for (const g of track.goals) {
- const v = g.goal?.value;
- if (onFace(v)) {
- if (!up) {
- L.add(k("gl"), g.t, INSTANT, { rotation: dialAngle(v, scale) });
- L.add(k("gl"), g.t, M.fade, { autoAlpha: 1 }, "power1.out");
- } else L.add(k("gl"), g.t, M.goal, { rotation: dialAngle(v, scale) }, "power2.inOut");
- up = true;
- } else if (up) {
- L.add(k("gl"), g.t, M.fade, { autoAlpha: 0 }, "power1.in");
- up = false;
+ if (cfg.goal) goalCues(L, { marks, lines, k });
+ if (ghosts) ghostCues(L, { ghosts, scale, k, finale, at });
+}
+
+/**
+ * The goal board's cues (goalMarks, goalLines): each mark's status from each board state -- the headline's triangle,
+ * an other's tick, a miss struck in red with a flash -- and the goal line's words.
+ */
+function goalCues(L, { marks, lines, k }) {
+ const M = INSTRUMENT_MOTION;
+ const view = { head: { h: 1, o: 0, x: 0, b: 0.9 }, other: { h: 0, o: 0.85, x: 0, b: 0.4 }, off: { h: 0, o: 0, x: 0, b: 0 } };
+ const look = (st) => (st.status === "missed" ? { h: st.wasHeadline ? 0.45 : 0, o: st.wasHeadline ? 0 : 0.45, x: 1, b: 0.3 } : view[st.status]);
+ marks.forEach((m, i) => {
+ const hasBand = m.band;
+ if (m.angle !== null) {
+ L.set(k(`gm${i}`), { rotation: m.angle, autoAlpha: 1 });
+ for (const c of ["h", "o", "x", "p"]) L.set(k(`gm${i}${c}`), { autoAlpha: 0 });
+ }
+ if (hasBand) L.set(k(`gb${i}`), { autoAlpha: 0 });
+ let was = view.off;
+ let wasMissed = false;
+ for (const st of m.states) {
+ const v = look(st);
+ if (m.angle !== null) {
+ for (const c of ["h", "o", "x"]) if (v[c] !== was[c]) L.add(k(`gm${i}${c}`), st.t, c === "x" ? MISS_MOTION.in : M.fade, { autoAlpha: v[c] }, "power1.out");
+ // The miss is the beat: a red flash round the mark as it lands.
+ if (st.status === "missed" && !wasMissed) {
+ L.add(k(`gm${i}p`), st.t, MISS_MOTION.in, { autoAlpha: 1 }, "power1.out");
+ L.add(k(`gm${i}p`), st.t + MISS_MOTION.in + MISS_MOTION.hold, MISS_MOTION.out, { autoAlpha: 0 }, "power2.in");
+ }
}
+ if (hasBand && v.b !== was.b) L.add(k(`gb${i}`), st.t, M.fade, { autoAlpha: v.b }, "power1.out");
+ was = v;
+ wasMissed = st.status === "missed";
}
- blocks(L, track.goals, k("gw"), { shown: (g) => !!g.goal });
- // A range goal's band, up while it is the latest goal.
- track.goals.forEach((g, j) => {
- const r = g.goal?.range;
- if (!Array.isArray(r) || !(dialAngle(r[1], scale) > dialAngle(r[0], scale))) return;
- L.set(k(`gr${j}`), { autoAlpha: 0 });
- L.add(k(`gr${j}`), g.t, M.fade, { autoAlpha: 1 }, "power1.out");
- const next = track.goals[j + 1];
- if (next) L.add(k(`gr${j}`), next.t, M.fade, { autoAlpha: 0 }, "power1.in");
- });
- }
+ });
+ blocks(L, lines, k("gw"), { shown: (g) => !!g.words });
+}
+
+/**
+ * The claim ghosts' cues (measure-ghosts.mjs ghostTicks): each tick at its angle, from each claim the step its count
+ * is on faded in and the one before out, and a repeat's pulse. The finale (`finale`) shows every tick at its count
+ * at the end of the cut from `at`, no pulses.
+ */
+function ghostCues(L, { ghosts, scale, k, finale, at }) {
+ const G = GHOST_MOTION;
+ const n = ghosts.ramp.length;
+ ghosts.ticks.forEach((x, i) => {
+ L.set(k(`gt${i}`), { rotation: dialAngle(x.value, scale) });
+ for (let s = 0; s < n; s += 1) {
+ L.set(k(`gt${i}s${s}`), { autoAlpha: 0 });
+ if (ghosts.cfg.pulse && s > 0) L.set(k(`gt${i}p${s}`), { autoAlpha: 0 });
+ }
+ if (finale) {
+ const s = Math.min(n - 1, x.claims.length - 1);
+ L.add(k(`gt${i}s${s}`), at, G.fade, { autoAlpha: ghostOpacity(ghosts.cfg.opacity, s) }, "power1.out");
+ return;
+ }
+ let prev = -1;
+ for (const c of x.claims) {
+ const s = Math.min(n - 1, c.n - 1);
+ if (s !== prev) {
+ L.add(k(`gt${i}s${s}`), c.t, G.fade, { autoAlpha: ghostOpacity(ghosts.cfg.opacity, s) }, "power1.out");
+ if (prev >= 0) L.add(k(`gt${i}s${prev}`), c.t, G.fade, { autoAlpha: 0 }, "power1.in");
+ }
+ if (ghosts.cfg.pulse && c.n > 1) {
+ L.add(k(`gt${i}p${s}`), c.t, G.flash, { autoAlpha: 0.9 }, "power1.out");
+ L.add(k(`gt${i}p${s}`), c.t + G.flash, G.decay, { autoAlpha: 0 }, "power2.in");
+ }
+ prev = s;
+ }
+ });
+}
+
+/** The claim ghosts a page draws (deck.measure.ghosts), or null when off. */
+function ghostsOf(measure, render, colors) {
+ const cfg = resolveGhosts(render);
+ if (!cfg) return null;
+ return { cfg, ticks: ghostTicks(measure, cfg), ramp: ghostRamp(cfg, colors, mix) };
}
/**
@@ -400,10 +539,14 @@ export function dialHtml(schedule, render, opts = {}) {
const colors = colorsOf(render, cfg);
const track = measureTrack(M);
const size = even(Math.min(W, H));
- const parts = dialParts({ size, ox: Math.floor((W - size) / 2), oy: Math.floor((H - size) / 2), scale: M.scale, cfg, colors, fonts, track });
+ const board = goalBoard(M);
+ const marks = goalMarks(board, M.scale);
+ const lines = goalLines(board);
+ const ghosts = ghostsOf(M, render, colors);
+ const parts = dialParts({ size, ox: Math.floor((W - size) / 2), oy: Math.floor((H - size) / 2), scale: M.scale, cfg, colors, fonts, track, marks, lines, ghosts });
const L = cueList(fps);
withDeck(L, schedule, render, "rt");
- dialCues(L, { track, scale: M.scale, cfg });
+ dialCues(L, { track, scale: M.scale, cfg, marks, lines, ghosts });
const { init, cues } = L.build();
return pageHtml({
id: "dial", W, H, fps, fonts, gsap: opts.gsap,
@@ -669,7 +812,8 @@ export function finaleNumbers(measure) {
range: lastCur && lastCur.value === to && Array.isArray(lastCur.range) ? lastCur.range : null,
lost, runs, from: Number.isFinite(from) ? from : null,
peak: peaks.length ? Math.max(...peaks) : null,
- goal: [...track.goals].reverse().find((g) => g.goal)?.goal ?? null,
+ // The goal the finale ends on: the board's headline at the cut's end -- the CLOSEST goal in force (measure-goals.mjs).
+ goal: goalsAt(goalBoard(measure), Infinity).headline ?? null,
};
}
@@ -730,11 +874,18 @@ export function dialFinaleHtml(schedule, render, window, opts = {}) {
...full,
current: [{ t: from, value: null }, { t: A + 0.4, value: nums.weight, qualifier: nums.qualifier, date: null, ...(nums.range ? { range: nums.range } : {}) }],
remembered: rem,
- goals: nums.goal ? [{ t: from, goal: null }, { t: A + 0.4, goal: nums.goal }] : [{ t: from, goal: null }],
};
+ // The goals in force at the cut's end, all at once as the needle drops (the miss beats were the cut's).
+ const end = goalsAt(goalBoard(M), Infinity);
+ const board = [{ t: from, active: [], headline: null, missed: [] }, { t: A + 0.4, active: end.active, headline: end.headline, missed: [] }];
+ const marks = goalMarks(board, M.scale);
+ const lines = goalLines(board);
+ // The claim ghosts STAY: the finale is the summary, and the residue of every number he gave is the point of it --
+ // each tick at its count at the cut's end, in with the finale's grow under the needle's drop, no pulses.
+ const ghosts = ghostsOf(M, render, colors);
const size = even(Math.min(H, Math.round(W * 0.56)));
const k = size / 524;
- const dial = dialParts({ size, ox: 0, oy: Math.floor((H - size) / 2), scale: M.scale, cfg, colors, fonts, track, prefix: "f", preState: false });
+ const dial = dialParts({ size, ox: 0, oy: Math.floor((H - size) / 2), scale: M.scale, cfg, colors, fonts, track, marks, lines, ghosts, prefix: "f", preState: false });
const rw = W - size - Math.round(40 * k);
const top = Math.max(Number(M.totals?.lost) || 0, nums.lost);
const wheels = wheelCount(top);
@@ -758,7 +909,7 @@ export function dialFinaleHtml(schedule, render, window, opts = {}) {
else if (D > 0 && from + dur - D > A + 0.4) L.add("rt", from + dur - D, D, { autoAlpha: 0 }, "power1.in");
// The needle starts at his highest remembered weight (the scale's top without one) and drops.
const start = Number.isFinite(nums.peak) ? nums.peak : M.scale.max;
- dialCues(L, { track, scale: M.scale, cfg, prefix: "f", finale: true });
+ dialCues(L, { track, scale: M.scale, cfg, marks, lines, ghosts, prefix: "f", finale: true, at: A });
L.set("fnd", { rotation: dialAngle(start, M.scale) });
if (Number.isFinite(nums.weight)) L.add("fnd", A + 0.4, 1.8, { rotation: dialAngle(nums.weight, M.scale) }, needleEase(cfg, "back.out(1.4)"));
for (let i = 0; i <= wheels; i += 1) L.set(`ow${i}`, { y: 0 });
diff --git a/umtool/report-to-video/chrome-measure-extras.mjs b/umtool/report-to-video/chrome-measure-extras.mjs
@@ -16,11 +16,12 @@ import { formatDeckDate } from "./attribution.mjs";
import { rgba } from "./chrome-deck.mjs";
import { compileCues, cuePageHtml, esc, INSTANT, joinSpans, r4, spanEvents } from "./chrome-cues.mjs";
import {
- daysBetween, daysLeftText, daysText, DIET_TAG, dietDays, dietStates, dietTagStep, goalStates, GOALS_SHELF, jitter, measureBox, measureExtraGeometry, measureOf, MEASURE_BOXES, promiseStripRect, promiseStripType,
+ daysBetween, daysLeftText, daysText, DIET_TAG, dietDays, dietStates, dietTagStep, goalStates, goalText, GOALS_SHELF, jitter, measureBox, measureExtraGeometry, measureOf, MEASURE_BOXES, promiseStripRect, promiseStripType,
MEASURE_DODGE_MOVE, measurePlacements, monthYear, peakStates, promiseStates, shortDate, streakStates, upSpans, weightText,
} from "./measure-extras.mjs";
import { dietTagWidth, MEASURE_RED, resolveMeasureExtra, SHELF_POSITION } from "./modules/measure-extras-settings.mjs";
import { dialFinaleGeometry, dialFinaleHandoff } from "./chrome-instruments.mjs";
+import { goalBoard, goalsAt } from "./measure-goals.mjs";
/** How each module's panel comes in and goes out, s. */
export const MEASURE_FADE = Object.freeze({ in: 0.35, out: 0.4 });
@@ -300,17 +301,9 @@ function goalsShelfHtml(schedule, render, opts, cfg, states) {
});
const spans = upSpans(states.map((s) => s.at), cfg, schedule);
const items = [];
- // THE ORDER ON THE SHELF: the headline goal in front when the state names one (the closest goal in force,
- // goalStates' `headline`), the rest by how recently he set them; else the newest in front, as the pile.
- let before = new Map();
- const shelfStates = states.map((st) => {
- const recent = [...st.notes].sort((a, b) => a.depth - b.depth);
- const lead = st.headline ? recent.find((n) => n.key === st.headline) : null;
- const list = lead ? [lead, ...recent.filter((n) => n !== lead)] : recent;
- const notes = list.map((n, i) => ({ ...n, depth: i, prev: before.has(n.key) ? before.get(n.key) : null }));
- before = new Map(notes.map((n) => [n.key, n.depth]));
- return { ...st, notes };
- });
+ // THE ORDER ON THE SHELF is the dial's (shelfGoalStates): the goal board's headline -- the closest goal in force --
+ // in front with "+N more" for the others in force, the rest by how recently he set them, a missed goal struck.
+ const shelfStates = shelfGoalStates(schedule, states);
const { init, cues } = stateCues(shelfStates, spans, {
own: (st, j, init) => {
const ev = [];
@@ -336,8 +329,11 @@ function goalsShelfHtml(schedule, render, opts, cfg, states) {
init[k] = { x: to.x, y: to.y, rotation: to.rotation };
}
}
- init[`s${j}.c`] = { scale: 1.6, opacity: 0 };
- ev.push({ k: `s${j}.c`, at: st.at + 0.25, dur: 0.3, to: { scale: 1, opacity: 1 }, ease: "back.out(2.2)" });
+ // The count pops as a goal lands; a state the board alone changed (a goal met, missed, or lapsed) keeps it still.
+ if (st.top) {
+ init[`s${j}.c`] = { scale: 1.6, opacity: 0 };
+ ev.push({ k: `s${j}.c`, at: st.at + 0.25, dur: 0.3, to: { scale: 1, opacity: 1 }, ease: "back.out(2.2)" });
+ }
return ev;
},
});
@@ -356,7 +352,9 @@ function goalsShelfHtml(schedule, render, opts, cfg, states) {
const back = backs && n.depth > 0
? `<div class="nb"${crossing ? ` data-k="${k}b"` : ""} style="opacity:${crossing ? 0 : 1}"><div class="bt">${esc(n.text)}</div>${n.date ? `<div class="bh">${esc(monthYear(n.date))}</div>` : ""}</div>`
: "";
- return `<div class="note" data-k="${k}" style="z-index:${20 - n.depth}"><div class="tape"></div>${face}${back}${count}${more}</div>`;
+ // Missed (the board's, held as the dial holds it): struck in red, MISSED on it.
+ const miss = st.missed?.includes(n.key) ? `<div class="mx"></div><div class="ms">Missed</div>` : "";
+ return `<div class="note${miss ? " missed" : ""}" data-k="${k}" style="z-index:${20 - n.depth}"><div class="tape"></div>${face}${back}${count}${more}${miss}</div>`;
}).join("");
const html = `<div class="st" data-k="s${j}"><div class="gc"><div class="gn" data-k="s${j}.c">${st.goalsSet}</div><div class="gl">goal${st.goalsSet === 1 ? "" : "s"} set</div></div>${notes}</div>`;
items.push({ key: `s${j}`, gate: [`s${j}`, "autoAlpha"], html });
@@ -388,13 +386,51 @@ function goalsShelfHtml(schedule, render, opts, cfg, states) {
color: rgba(42, 28, 6, 0.62); white-space: nowrap; }
.mo { position: absolute; right: ${px(8)}px; bottom: ${px(6)}px; padding: 0 ${px(7)}px; height: ${px(20)}px; border-radius: ${px(10)}px;
background: rgba(42, 28, 6, 0.85); color: ${paper}; font-family: 'DeckSansBold', sans-serif; font-size: ${px(12)}px; line-height: ${px(20)}px; }
+ .mx { position: absolute; left: ${px(6)}px; right: ${px(6)}px; top: 50%; height: ${px(4)}px; margin-top: ${px(-2)}px; background: ${MEASURE_RED};
+ transform: rotate(-8deg); border-radius: ${px(2)}px; }
+ .ms { position: absolute; left: ${px(10)}px; bottom: ${px(6)}px; padding: 0 ${px(7)}px; height: ${px(20)}px; border-radius: ${px(10)}px;
+ background: ${MEASURE_RED}; color: #fff; font-family: 'DeckSansBold', sans-serif; font-size: ${px(12)}px; line-height: ${px(20)}px;
+ letter-spacing: 0.1em; text-transform: uppercase; }
.ct { position: absolute; right: ${px(8)}px; top: ${px(5)}px; min-width: ${px(40)}px; height: ${px(24)}px; padding: 0 ${px(7)}px;
border-radius: ${px(12)}px; background: #2a1c06; color: ${paper}; text-align: center;
font-family: ${DISPLAY}; font-size: ${px(19)}px; line-height: ${px(24)}px; }`;
const body = `<div id="pn" data-k="pn">
${blocks.join("\n ")}
</div>`;
- return { html: page("goals", schedule, opts, F, css, body, init, cues, states.map((_, j) => `s${j}`), render), items };
+ return { html: page("goals", schedule, opts, F, css, body, init, cues, shelfStates.map((_, j) => `s${j}`), render), items };
+}
+
+/**
+ * The shelf's goal states, ordered by the dial's goal board (measure-goals.mjs goalBoard / goalsAt), so the two
+ * always agree: each of goalStates' states (one per goal he sets) and a state wherever the board alone changes
+ * after the first (a goal met, missed or past its day; a missed one's hold ending) -- the same notes, `top` null.
+ * Each carries `headline` (the board headline's note key, or null: the newest leads), `active` (the goals in force)
+ * and `missed` (the note keys struck now); its notes in front-to-back order: the headline, then by recency.
+ */
+export function shelfGoalStates(schedule, states) {
+ if (!states.length) return [];
+ const m = schedule.measure;
+ const board = goalBoard(m);
+ const unit = m?.unit ?? "lb";
+ const keyOf = new Map((m?.events ?? []).filter((e) => e.kind === "goal" || e.kind === "goalLoss").map((e) => [e.row, goalText(e, unit).toLowerCase()]));
+ const times = [...new Set([...states.map((st) => st.at), ...board.map((b) => r4(b.t)).filter((t) => t > states[0].at)])].sort((a, b) => a - b);
+ let before = new Map();
+ return times.map((t) => {
+ const own = states.find((st) => Math.abs(st.at - t) < 1e-6);
+ const base = own ?? [...states].reverse().find((st) => st.at <= t);
+ const b = goalsAt(board, t);
+ const headline = b.headline ? keyOf.get(b.headline.row) ?? null : null;
+ const recent = [...base.notes].sort((x, y) => x.depth - y.depth);
+ const lead = headline ? recent.find((n) => n.key === headline) : null;
+ const list = lead ? [lead, ...recent.filter((n) => n !== lead)] : recent;
+ const notes = list.map((n, i) => ({ ...n, depth: i, prev: before.has(n.key) ? before.get(n.key) : null }));
+ before = new Map(notes.map((n) => [n.key, n.depth]));
+ return {
+ ...base, at: t, top: own ? own.top : null, ...(own ? {} : { repeat: false }),
+ headline: lead ? headline : null, active: b.active.length,
+ missed: b.missed.map((g) => keyOf.get(g.row)).filter(Boolean), notes,
+ };
+ });
}
// ---------------------------------------------------------------------------
diff --git a/umtool/report-to-video/instruments.mjs b/umtool/report-to-video/instruments.mjs
@@ -6,7 +6,8 @@
// render.chrome.deck.dial an analog bathroom-scale face: a red needle to
// every weight he states, on the word, with a
// spring; his remembered weights as grey ghosts;
-// his latest goal as an amber tick on the bezel
+// every goal in force on the bezel, the closest
+// headlined (measure-goals.mjs)
// render.chrome.deck.odometer rolling digits of the pounds he says he has
// lost (only ever up), NET beside them
// render.chrome.deck.trail his stated weights by DATE, a thin line drawn
@@ -37,7 +38,8 @@ export const DIAL_DEFAULTS = Object.freeze({
mark: 300,
// The remembered weights as ghost ticks, the latest a long ghost needle with its as-of date.
ghosts: true,
- // The latest goal as an amber tick on the bezel, and its words under the digits.
+ // Every goal in force as a mark on the bezel, the CLOSEST (measure-goals.mjs) the full amber tick
+ // and its words under the digits, a missed one struck in red.
goal: true,
// The needle's colour: a #hex.
needle: NEEDLE_RED,
diff --git a/umtool/report-to-video/instruments.test.mjs b/umtool/report-to-video/instruments.test.mjs
@@ -244,7 +244,10 @@ test("the dial's finale: the record's numbers, a window page the frame keys mode
const html = dialFinaleHtml(schedule, RENDER, win, { fonts });
assert.match(html, /data-composition-id="dial-finale"/);
assert.match(html, />291\.5<i>LB<\/i>/);
- assert.match(html, /GOAL 235</);
+ // The goal it ends on is the CLOSEST in force at the cut's end (measure-goals.mjs), not simply the latest row of the
+ // record: w85, "lose 50" from 300 -> 250 (w90's 235 is the fixture's state, not a goal the cut shows).
+ assert.equal(n.goal.row, "w85");
+ assert.match(html, /GOAL 250 · LOSE 50</);
const keys = frameKeys({ html, region: "dial-finale", fps: FPS, frames: win.frames, version: "t" });
assert.ok(keys);
// Held once the needle, the wheels and NET are in (by 4 s into the window): one key.
diff --git a/umtool/report-to-video/measure-extras.mjs b/umtool/report-to-video/measure-extras.mjs
@@ -229,9 +229,11 @@ export function goalStates(schedule, render) {
const states = [];
let prevDepth = new Map();
let n = 0;
- const rowKey = new Map();
for (const { e, s } of stepsOf(m)) {
if (e.kind !== "goal" && e.kind !== "goalLoss") continue;
+ // A goal of his that counts: not another speaker's, not an `unresolved` row (a joke) -- as the slice's tallies
+ // and the dial's goal board (measure-slice.mjs isUsable, measure-goals.mjs).
+ if (e.unresolved === true || (typeof e.speaker === "string" && e.speaker.trim())) continue;
n += 1;
const text = goalText(e, m.unit ?? "lb");
const key = text.toLowerCase();
@@ -252,22 +254,14 @@ export function goalStates(schedule, render) {
const target = s?.goal && s.goal.row === e.row && Number.isFinite(s.goal.value) ? s.goal.value
: e.kind === "goal" && Number.isFinite(e.value) ? e.value : null;
note.target = target;
- rowKey.set(e.row, key);
order = [...order.filter((k) => k !== key), key];
const shown = order.slice(-cfg.max);
const depth = new Map(shown.map((k, i) => [k, shown.length - 1 - i]));
- // The headline goal, when the state names one (the closest goal in force -- the measure state's
- // `goals.headline`, a row or a goal carrying its row): its note's key, else null (the newest leads).
- const hl = s?.goals && !Array.isArray(s.goals) ? s.goals.headline : s?.goalHeadline;
- const hlRow = typeof hl === "string" ? hl : hl?.row ?? null;
- const active = s?.goals && !Array.isArray(s.goals) && Array.isArray(s.goals.active) ? s.goals.active.length : null;
states.push({
at: r4(e.t),
top: key,
repeat: note.count > 1,
- ...(hlRow && rowKey.has(hlRow) ? { headline: rowKey.get(hlRow) } : {}),
- ...(active !== null ? { active } : {}),
- goalsSet: Array.isArray(s?.goals) ? s.goals.length : Array.isArray(s?.goals?.set) ? s.goals.set.length : n,
+ goalsSet: Array.isArray(s?.goals) ? s.goals.length : n,
notes: shown.map((k) => {
const x = notes.get(k);
return {
diff --git a/umtool/report-to-video/measure-ghosts.mjs b/umtool/report-to-video/measure-ghosts.mjs
@@ -0,0 +1,133 @@
+// THE DIAL'S CLAIM GHOSTS (`render.chrome.deck.measure.ghosts`, 6 Nov 2026):
+// every weight the cut has shown him claim leaves a faint residual tick on the
+// dial's rim at its value, so after a few minutes the face carries the history
+// of everything he has said; a value claimed again changes that tick's colour
+// along a short ramp (1x faint neutral, 2x warm, 3x+ hot) and thickens it, and
+// the tick pulses once as the repeat lands.
+//
+// Not the dial's own `deck.dial.ghosts` (his REMEMBERED weights as long grey
+// ticks with their as-of words, the latest a long ghost needle): those stay as
+// they are, drawn over these.
+//
+// A claim is a measure event the cut shows (`measure.events`, t finite) of his
+// own (no `speaker`) that puts a number on his weight: a STATED weight (each
+// one the needle goes to) or a REMEMBERED one. Two claims are the same tick
+// when their values are within `tolerance` lb of the tick's first value; an
+// "≈" value counts as its rounded number; a ">300" or "<300" is a claim at
+// 300 (its bound is where it stands on the face).
+//
+// PURE and SEEK-SAFE: ghostTicks is a function of the schedule's measure alone,
+// in cut order -- no state from playback -- so Play, the live preview and the
+// render draw the same tick at the same second from either side of it.
+//
+// A LEAF: measure-slice.mjs (the setting's validator) and chrome-instruments.mjs
+// (the dial's page) import it; it imports nothing.
+
+/** The setting's knobs and their defaults (`ghosts: true`). */
+export const GHOST_DEFAULTS = Object.freeze({
+ // The 1x tick's opacity; each step of the ramp adds GHOST_OPACITY_STEP, to at most 0.95.
+ opacity: 0.5,
+ // Pounds: a claim within this of a tick's value is a repeat of it.
+ tolerance: 0.5,
+ // The ramp's colours, 1x first, the last for every count from there up (2 to 4 #hex), or
+ // null: the palette's -- its muted, its amber, and amber half way to the needle's red.
+ ramp: null,
+ // The tick pulses once as a repeat lands.
+ pulse: true,
+});
+
+export const GHOST_OPACITY = Object.freeze([0.15, 0.9]);
+export const GHOST_OPACITY_STEP = 0.2;
+export const GHOST_TOLERANCE = Object.freeze([0, 5]);
+export const GHOST_RAMP = Object.freeze([2, 4]);
+
+const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
+const HEX_RE = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
+const inRange = (v, [lo, hi]) => typeof v === "number" && Number.isFinite(v) && v >= lo && v <= hi;
+
+/** `render.chrome.deck.measure.ghosts`, as sentences. */
+export function validateGhosts(v, where = "render.chrome.deck.measure.ghosts") {
+ if (v === undefined || typeof v === "boolean") return [];
+ if (!isObj(v)) return [`${where} must be true, false or { ${Object.keys(GHOST_DEFAULTS).join(", ")} }`];
+ const errors = [];
+ for (const k of Object.keys(v)) {
+ if (!Object.hasOwn(GHOST_DEFAULTS, k)) errors.push(`${where}.${k} is not a setting of it (${Object.keys(GHOST_DEFAULTS).join(", ")})`);
+ }
+ if (v.opacity !== undefined && !inRange(v.opacity, GHOST_OPACITY)) errors.push(`${where}.opacity must be a number from ${GHOST_OPACITY[0]} to ${GHOST_OPACITY[1]}`);
+ if (v.tolerance !== undefined && !inRange(v.tolerance, GHOST_TOLERANCE)) errors.push(`${where}.tolerance must be pounds from ${GHOST_TOLERANCE[0]} to ${GHOST_TOLERANCE[1]}`);
+ if (v.ramp !== undefined && v.ramp !== null) {
+ if (!Array.isArray(v.ramp) || v.ramp.length < GHOST_RAMP[0] || v.ramp.length > GHOST_RAMP[1] || v.ramp.some((c) => typeof c !== "string" || !HEX_RE.test(c))) {
+ errors.push(`${where}.ramp must be ${GHOST_RAMP[0]} to ${GHOST_RAMP[1]} #hex colours (1x first), or null for the palette's`);
+ }
+ }
+ if (v.pulse !== undefined && typeof v.pulse !== "boolean") errors.push(`${where}.pulse must be true or false`);
+ return errors;
+}
+
+/** The ghosts' settings, defaults filled, or null when off (absent, `false`). */
+export function resolveGhosts(render) {
+ const v = render?.chrome?.deck?.measure?.ghosts;
+ if (v === true) return { ...GHOST_DEFAULTS };
+ if (!isObj(v)) return null;
+ return { ...GHOST_DEFAULTS, ...v };
+}
+
+/** The ramp's colours: the setting's, else from the palette roles (`muted`, `amber`, `needle`, and a `mix`). */
+export function ghostRamp(cfg, { muted, amber, needle }, mix) {
+ if (Array.isArray(cfg?.ramp) && cfg.ramp.length >= GHOST_RAMP[0]) return [...cfg.ramp];
+ return [muted, amber, mix(amber, needle, 0.5)];
+}
+
+/** Step `k` (0 = 1x) of a ramp of `n`: its opacity from the 1x opacity. */
+export const ghostOpacity = (base, k) => Math.min(0.95, Math.round((base + k * GHOST_OPACITY_STEP) * 100) / 100);
+
+/** The claim's value as its tick counts it: an "≈" value is its rounded number. */
+export const claimValue = (e) => (e?.qualifier === "≈" ? Math.round(Number(e.value)) : Number(e.value));
+
+/** Is this event a weight claim of his the cut shows: stated or remembered, a number, a time, no other speaker. */
+export const isClaim = (e) =>
+ !!e && (e.kind === "stated" || e.kind === "remembered") && Number.isFinite(Number(e.value)) && e.value !== null &&
+ Number.isFinite(e.t) && !(typeof e.speaker === "string" && e.speaker.trim());
+
+/**
+ * The ghost ticks of a measure: one per value claimed, in the order first
+ * claimed -- `{ value, claims: [{ t, row, kind, n }] }`, `value` the first
+ * claim's (as its tick counts it), each claim with its count `n` (1 the
+ * first). In cut order: a claim joins the first tick whose value is within
+ * `tolerance` of it, else starts a tick.
+ *
+ * @param {{ events?: object[] }} measure the schedule's measure slice
+ * @param {{ tolerance?: number }} [cfg]
+ */
+export function ghostTicks(measure, cfg = {}) {
+ const tol = Number.isFinite(cfg.tolerance) ? cfg.tolerance : GHOST_DEFAULTS.tolerance;
+ const claims = (Array.isArray(measure?.events) ? measure.events : [])
+ .map((e, i) => ({ e, i }))
+ .filter(({ e }) => isClaim(e))
+ .sort((a, b) => a.e.t - b.e.t || a.i - b.i);
+ const ticks = [];
+ for (const { e } of claims) {
+ const v = claimValue(e);
+ let tick = ticks.find((x) => Math.abs(x.value - v) <= tol + 1e-9);
+ if (!tick) ticks.push((tick = { value: v, claims: [] }));
+ tick.claims.push({ t: e.t, row: e.row ?? null, kind: e.kind, n: tick.claims.length + 1 });
+ }
+ return ticks;
+}
+
+/**
+ * The ticks as they stand at cut second `t`: each tick claimed by then with
+ * its count so far (`count`), the ramp step it is on (`step`, 0 = 1x, held at
+ * the ramp's last), and whether a repeat landed within `pulse` s before `t`.
+ * A pure function of the ticks and `t` -- what a frame at `t` shows.
+ */
+export function ghostsAt(ticks, t, { steps = 3, pulse = 0 } = {}) {
+ const out = [];
+ for (const x of ticks) {
+ const by = x.claims.filter((c) => c.t <= t + 1e-9);
+ if (!by.length) continue;
+ const last = by[by.length - 1];
+ out.push({ value: x.value, count: by.length, step: Math.min(steps - 1, by.length - 1), pulsing: pulse > 0 && last.n > 1 && t - last.t < pulse });
+ }
+ return out;
+}
diff --git a/umtool/report-to-video/measure-ghosts.test.mjs b/umtool/report-to-video/measure-ghosts.test.mjs
@@ -0,0 +1,158 @@
+// The dial's claim ghosts (measure-ghosts.mjs, chrome-instruments.mjs): the
+// setting, the accumulation in cut order, the repeat ramp and its tolerance,
+// and that what a frame shows at t is a pure function of the schedule.
+import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
+import path from "node:path";
+import test from "node:test";
+import { fileURLToPath } from "node:url";
+
+import { estimateSchedule } from "./deck.mjs";
+import { mix } from "./chrome-deck.mjs";
+import { dialFinaleHtml, dialHtml } from "./chrome-instruments.mjs";
+import { frameKeys } from "./frame-keys.mjs";
+import { GHOST_DEFAULTS, claimValue, ghostOpacity, ghostRamp, ghostTicks, ghostsAt, isClaim, resolveGhosts, validateGhosts } from "./measure-ghosts.mjs";
+import { validateMeasureSettings } from "./measure-slice.mjs";
+import { moduleById } from "./modules/index.mjs";
+
+const HERE = path.dirname(fileURLToPath(import.meta.url));
+const MEASURE = JSON.parse(readFileSync(path.join(HERE, "fixtures", "measure-dial", "measure.json"), "utf8"));
+const FPS = 30;
+const fonts = { DeckSans: "assets/DeckSans.ttf", DeckSansBold: "assets/DeckSansBold.ttf" };
+const PALETTE = { bg: "#0F1312", fg: "#EDF0EC", muted: "#98A29B", accent: "#22AB83", amber: "#E8A33F" };
+const renderWith = (measure) => ({
+ width: 1920, height: 1080, fps: FPS, transition: 0.4, palette: PALETTE,
+ chrome: { engine: "hyperframes", layout: "deck", deck: { dial: true, odometer: true, trail: true, qr: { show: false }, finale: { video: "side", totals: false }, ...(measure ? { measure } : {}) } },
+});
+
+function cut(render) {
+ const timeline = Array.from({ length: 9 }, (_, i) => ({
+ type: "clip", id: `c${i + 1}`, video: "vidx", start: 10 * i, end: 10 * i + (i === 8 ? 14 : 8), cite: 1, section: 0,
+ quote: "q", onscreen: { title: `Clip ${i + 1}` }, ...(i === 8 ? { layout: "finale" } : {}),
+ }));
+ const manifest = { slug: "m", title: "M", provenance: {}, render, timeline };
+ return { ...estimateSchedule(manifest), measure: MEASURE };
+}
+
+const dataOf = (html, id = "dial") => JSON.parse(new RegExp(`<script id="${id}-data" type="application/json">(.*?)</script>`, "s").exec(html)[1]);
+
+/** An element's property at cut second `t` from a page's init and cues, as the interpreter lands on it at rest. */
+function valueAt(data, k, p, t) {
+ let v = data.init[k]?.[p];
+ for (const c of data.cues) if (c.k === k && p in c.to && c.at + c.dur <= t + 1e-9) v = c.to[p];
+ return v;
+}
+
+test("the setting: off unless asked; true, false or its knobs; checked where deck.measure is", () => {
+ assert.equal(resolveGhosts(renderWith({})), null);
+ assert.equal(resolveGhosts(renderWith({ ghosts: false })), null);
+ assert.deepEqual(resolveGhosts(renderWith({ ghosts: true })), { ...GHOST_DEFAULTS });
+ assert.deepEqual(resolveGhosts(renderWith({ ghosts: { tolerance: 1, pulse: false } })), { ...GHOST_DEFAULTS, tolerance: 1, pulse: false });
+ assert.deepEqual(validateGhosts(true), []);
+ assert.deepEqual(validateGhosts({ opacity: 0.3, tolerance: 2, ramp: ["#888888", "#e8a33f", "#ff5a4e"], pulse: true }), []);
+ assert.deepEqual(validateGhosts({ opacity: 2, tolerance: -1, ramp: ["red"], pulse: "yes", glow: 1 }), [
+ "render.chrome.deck.measure.ghosts.glow is not a setting of it (opacity, tolerance, ramp, pulse)",
+ "render.chrome.deck.measure.ghosts.opacity must be a number from 0.15 to 0.9",
+ "render.chrome.deck.measure.ghosts.tolerance must be pounds from 0 to 5",
+ "render.chrome.deck.measure.ghosts.ramp must be 2 to 4 #hex colours (1x first), or null for the palette's",
+ "render.chrome.deck.measure.ghosts.pulse must be true or false",
+ ]);
+ assert.deepEqual(validateGhosts("on"), ["render.chrome.deck.measure.ghosts must be true, false or { opacity, tolerance, ramp, pulse }"]);
+ assert.deepEqual(validateMeasureSettings({ ghosts: { ramp: [] } }), [
+ "render.chrome.deck.measure.ghosts.ramp must be 2 to 4 #hex colours (1x first), or null for the palette's",
+ ]);
+ // The palette's ramp: muted, amber, amber half way to the needle.
+ assert.deepEqual(ghostRamp(GHOST_DEFAULTS, { muted: "#98a29b", amber: "#e8a33f", needle: "#ff5a4e" }, mix), ["#98a29b", "#e8a33f", mix("#e8a33f", "#ff5a4e", 0.5)]);
+ assert.deepEqual([0, 1, 2, 5].map((k) => ghostOpacity(0.5, k)), [0.5, 0.7, 0.9, 0.95]);
+});
+
+test("every claim he makes leaves a tick, in cut order: stated and remembered, his own, a number, on screen", () => {
+ assert.equal(isClaim({ kind: "stated", value: 300, t: 1 }), true);
+ assert.equal(isClaim({ kind: "remembered", value: 390, t: 1 }), true);
+ assert.equal(isClaim({ kind: "goal", value: 250, t: 1 }), false);
+ assert.equal(isClaim({ kind: "stated", value: null, t: 1 }), false);
+ assert.equal(isClaim({ kind: "stated", value: 300, t: null }), false);
+ assert.equal(isClaim({ kind: "stated", value: 300, t: 1, speaker: "madamsavvy" }), false);
+ const ticks = ghostTicks(MEASURE, GHOST_DEFAULTS);
+ // The fixture's 21 claims on 15 values: 390 four times (≈390 thrice and 390 once), 300 four times (>300, 300, >300, <300).
+ assert.equal(ticks.reduce((n, x) => n + x.claims.length, 0), 21);
+ assert.equal(ticks.length, 15);
+ const by = new Map(ticks.map((x) => [x.value, x.claims.map((c) => c.n)]));
+ assert.deepEqual(by.get(390), [1, 2, 3, 4]);
+ assert.deepEqual(by.get(300), [1, 2, 3, 4]);
+ assert.deepEqual(by.get(291.5), [1]);
+ // In the order first claimed.
+ assert.deepEqual(ticks.slice(0, 3).map((x) => x.value), [240, 390, 365.7]);
+});
+
+test("a repeat is a claim within the tolerance of a tick's first value; an ≈ counts as its rounded number", () => {
+ const ev = (t, value, qualifier = null, kind = "stated") => ({ t, kind, value, qualifier, row: `r${t}` });
+ const m = { events: [ev(1, 300), ev(2, 300.4), ev(3, 300.6), ev(4, 389.6, "≈", "remembered"), ev(5, 390), ev(6, 299.5)] };
+ const half = ghostTicks(m, { tolerance: 0.5 });
+ assert.deepEqual(half.map((x) => [x.value, x.claims.length]), [[300, 3], [300.6, 1], [390, 2]]);
+ assert.equal(claimValue({ value: 389.6, qualifier: "≈" }), 390);
+ const none = ghostTicks(m, { tolerance: 0 });
+ assert.deepEqual(none.map((x) => x.value), [300, 300.4, 300.6, 390, 299.5]);
+ const wide = ghostTicks(m, { tolerance: 1 });
+ assert.deepEqual(wide.map((x) => [x.value, x.claims.length]), [[300, 4], [390, 2]]);
+});
+
+test("the ramp: 1x, 2x, 3x and up held on the last; a repeat pulses, a first claim does not", () => {
+ const ticks = ghostTicks(MEASURE, GHOST_DEFAULTS);
+ const t390 = ticks.find((x) => x.value === 390).claims.map((c) => c.t);
+ const at = (t) => ghostsAt(ticks, t, { steps: 3, pulse: 1 }).find((x) => x.value === 390) ?? null;
+ assert.equal(at(t390[0] - 0.01), null);
+ assert.deepEqual(at(t390[0]), { value: 390, count: 1, step: 0, pulsing: false });
+ assert.deepEqual(at(t390[1] + 0.5), { value: 390, count: 2, step: 1, pulsing: true });
+ assert.deepEqual(at(t390[1] + 1.5), { value: 390, count: 2, step: 1, pulsing: false });
+ assert.deepEqual(at(t390[3] + 2), { value: 390, count: 4, step: 2, pulsing: false });
+});
+
+test("the dial draws them only when asked; the page is a cue list the frame keys model, and a frame at t shows the ticks at t", () => {
+ const off = renderWith({});
+ const on = renderWith({ ghosts: true });
+ const plain = dialHtml(cut(off), off, { fonts });
+ assert.doesNotMatch(plain, /data-k="gt0/);
+ const html = dialHtml(cut(on), on, { fonts });
+ assert.match(html, /data-k="gt0"/);
+ // Pure: the same schedule draws the same page.
+ assert.equal(html, dialHtml(cut(on), on, { fonts }));
+ const schedule = cut(on);
+ const frames = Math.round(schedule.total * FPS);
+ const keys = frameKeys({ html, region: "dial", fps: FPS, frames, version: "t" });
+ assert.ok(keys, "the frame keys model the dial's page with its ghosts");
+ assert.ok(new Set(keys).size < frames / 2, "the ghosts at rest are reused frame to frame");
+ const data = dataOf(html);
+ const ticks = ghostTicks(MEASURE, GHOST_DEFAULTS);
+ // SEEK-SAFE: at any second, each tick's visible step is ghostsAt's -- read from init and the cues, never from playback.
+ for (const t of [0, 5, 7.25 + 1, 21.25 + 1, 44 + 1, 58 + 1, 61]) {
+ const want = new Map(ghostsAt(ticks, t, { steps: 3 }).map((x) => [x.value, x.step]));
+ ticks.forEach((x, i) => {
+ const shown = [0, 1, 2].filter((s) => (valueAt(data, `gt${i}s${s}`, "autoAlpha", t) ?? 0) > 0);
+ assert.deepEqual(shown, want.has(x.value) ? [want.get(x.value)] : [], `tick ${x.value} at ${t}s`);
+ });
+ }
+ // The 1x opacity, faint; the third step the strongest; a pulse decays to nothing.
+ const i390 = ticks.findIndex((x) => x.value === 390);
+ assert.equal(valueAt(data, `gt${i390}s2`, "autoAlpha", 61), 0.9);
+ assert.equal(valueAt(data, `gt${i390}p1`, "autoAlpha", 61), 0);
+ assert.ok(data.cues.some((c) => c.k === `gt${i390}p1` && c.to.autoAlpha === 0.9), "the second telling pulses");
+ // pulse: false draws no pulse lines.
+ const quiet = renderWith({ ghosts: { pulse: false } });
+ assert.doesNotMatch(dialHtml(cut(quiet), quiet, { fonts }), /data-k="gt\d+p/);
+});
+
+test("the finale keeps them: every tick at its count at the cut's end, in with the finale, no pulses", () => {
+ const on = renderWith({ ghosts: true });
+ const schedule = cut(on);
+ const win = moduleById("dial-finale").window(schedule, { fps: FPS, total: schedule.total });
+ const html = dialFinaleHtml(schedule, on, win, { fonts });
+ const data = dataOf(html, "dial-finale");
+ const ticks = ghostTicks(MEASURE, GHOST_DEFAULTS);
+ ticks.forEach((x, i) => {
+ const s = Math.min(2, x.claims.length - 1);
+ assert.equal(valueAt(data, `fgt${i}s${s}`, "autoAlpha", win.to), ghostOpacity(GHOST_DEFAULTS.opacity, s));
+ });
+ assert.ok(!data.cues.some((c) => /^fgt\d+p/.test(c.k) && c.to.autoAlpha > 0));
+ assert.ok(frameKeys({ html, region: "dial-finale", fps: FPS, frames: win.frames, version: "t" }));
+});
diff --git a/umtool/report-to-video/measure-goals.mjs b/umtool/report-to-video/measure-goals.mjs
@@ -0,0 +1,173 @@
+// THE GOAL BOARD (6 Nov 2026, the operator: "in a sequence of multiple goals
+// such as at the 7m clip, show each goal on the dial, and prioritize the
+// closest one rather than the most ambitious one since failing the easiest
+// goal would be the most interesting"): every goal in force at the playhead,
+// the CLOSEST of them as the headline, and each one whose deadline passed
+// unmet, held a moment as MISSED.
+//
+// active every goal (`goal`, `goal_loss`) of his the cut has shown (an
+// `unresolved` row -- a joke -- is no goal), not
+// yet met, replaced or past its deadline -- in the order set.
+// A newer goal with the same HORIZON replaces the older one: the
+// same deadline day, else the same deadline words, else both
+// undated ("eventual" goals stay until one replaces them).
+// headline the active goal with the least loss still needed from his
+// latest stated weight (to a range's top); a goal with no weight
+// (an unresolved "lose 75") by its loss; ties to the soonest
+// deadline, then the latest set. Not the most ambitious, not
+// simply the latest.
+// missed the goals whose deadline the record's date (the latest date of
+// the events shown so far) has passed with no stated weight of his
+// at or under it by then, while his latest stated weight is over
+// it -- each `{ ...goal, at, wasHeadline }`, held MISS_HOLD s from
+// `at`, then gone. A goal whose deadline passes with his latest
+// weight under it (a reading after the day: we cannot say) or that
+// a reading meets in time leaves quietly.
+//
+// A goal: `{ row, kind, t, said, target, range, loss, display, deadline,
+// deadlineDate, key }` -- `target` the weight it comes to (a `goal_loss`
+// resolved against its base by the slice: the state's `goal.value`), null
+// when unresolved; `deadlineDate` the ledger's `due`, else the date his
+// deadline words name (measure-extras.mjs deadlineDate), else the row's
+// `asOf` (the day a goal is for: "320 by his birthday", asOf 2026-04-01).
+//
+// PURE and SEEK-SAFE: goalBoard is a function of the schedule's measure alone;
+// goalsAt(board, t) is the board at a cut second. The dial draws it
+// (chrome-instruments.mjs); any page that shows a goal reads the same
+// `headline` from here.
+import { deadlineDate } from "./measure-extras.mjs";
+
+/** How long a missed goal stays on the dial, struck, before it goes (s). */
+export const MISS_HOLD = 6;
+
+const ISO_RE = /^\d{4}-\d{2}-\d{2}$/;
+const isIso = (v) => typeof v === "string" && ISO_RE.test(v);
+const own = (e) => !(typeof e?.speaker === "string" && e.speaker.trim());
+const r4 = (v) => Math.round(v * 10000) / 10000;
+
+/** The weight a goal must be at or under to be met: a range's top, else its target. */
+export const goalEdge = (g) => (Array.isArray(g?.range) && g.range.length === 2 ? Math.max(g.range[0], g.range[1]) : g?.target ?? null);
+
+/** Pounds still to lose from `cur` to goal `g` (its loss when it has no weight), or Infinity when unknown. */
+export function goalNeed(g, cur) {
+ const edge = goalEdge(g);
+ if (Number.isFinite(edge) && Number.isFinite(cur)) return r4(cur - edge);
+ if (Number.isFinite(g?.loss)) return g.loss;
+ return Infinity;
+}
+
+/**
+ * The closest of `goals` from weight `cur`: the least still needed (a goal
+ * already under `cur`'s reach -- need 0 or less -- after every one still
+ * ahead), ties to the soonest deadline (undated last), then the latest set.
+ */
+export function headlineOf(goals, cur) {
+ if (!goals.length) return null;
+ const rank = (g) => {
+ const n = goalNeed(g, cur);
+ return n > 0 ? n : 1e9 - n;
+ };
+ return [...goals].sort((a, b) =>
+ rank(a) - rank(b) ||
+ String(a.deadlineDate ?? "9999").localeCompare(String(b.deadlineDate ?? "9999")) ||
+ b.t - a.t)[0];
+}
+
+/** A goal event as the board carries it, with the state after it (`s`, for a goal_loss's resolution). */
+function goalOf(e, s) {
+ const kind = e.kind;
+ const resolved = s?.goal && s.goal.row === e.row ? s.goal : null;
+ const target = kind === "goal" && Number.isFinite(Number(e.value)) && e.value !== null ? Number(e.value)
+ : Number.isFinite(resolved?.value) ? resolved.value : null;
+ const loss = kind === "goalLoss" && Number.isFinite(Number(e.value)) ? Math.abs(Number(e.value)) : Number.isFinite(resolved?.loss) ? resolved.loss : null;
+ const words = typeof e.deadline === "string" && e.deadline.trim() ? e.deadline.trim() : null;
+ const date = isIso(e.due) ? e.due : (words ? deadlineDate(words, e.date) : null) ?? (isIso(e.asOf) ? e.asOf : null);
+ const range = Array.isArray(e.range) && e.range.length === 2 ? [...e.range] : Array.isArray(resolved?.range) ? [...resolved.range] : null;
+ return {
+ row: e.row ?? null, kind, t: e.t, said: isIso(e.date) ? e.date : null,
+ target, ...(range ? { range } : {}), loss, display: e.display ?? null,
+ deadline: words, deadlineDate: date,
+ key: date ? `d:${date}` : words ? `w:${words.toLowerCase()}` : "eventual",
+ };
+}
+
+const sameBoard = (a, b) => a && b &&
+ a.headline?.row === b.headline?.row &&
+ a.active.map((g) => g.row).join("|") === b.active.map((g) => g.row).join("|") &&
+ a.missed.map((g) => g.row).join("|") === b.missed.map((g) => g.row).join("|");
+
+/**
+ * The goal board over the cut: `[{ t, active, headline, missed, cur }]`, one
+ * per change, the first at t 0 (nothing yet), each the board from its `t` to
+ * the next one's. `cur` is his latest stated weight then (null before one).
+ *
+ * @param {{ events?: object[], state?: object[] }} measure the schedule's measure slice
+ * @param {{ hold?: number }} [opts] how long a missed goal is held (MISS_HOLD)
+ */
+export function goalBoard(measure, { hold = MISS_HOLD } = {}) {
+ const events = Array.isArray(measure?.events) ? measure.events : [];
+ const states = Array.isArray(measure?.state) ? measure.state : [];
+ const steps = events
+ .map((e, i) => ({ e, s: states[i + 1] ?? states[states.length - 1] ?? null, i }))
+ .filter(({ e }) => Number.isFinite(e?.t) && own(e) && e.unresolved !== true)
+ .sort((a, b) => a.e.t - b.e.t || a.i - b.i);
+ let active = [];
+ let cur = null;
+ let recordDate = null;
+ const misses = [];
+ const points = [{ t: 0, active: [], headline: null, cur: null }];
+ for (const { e, s } of steps) {
+ if (isIso(e.date) && (recordDate === null || e.date > recordDate)) recordDate = e.date;
+ const before = headlineOf(active, cur);
+ if (e.kind === "goal" || e.kind === "goalLoss") {
+ const g = goalOf(e, s);
+ active = [...active.filter((x) => x.key !== g.key), g];
+ } else if (e.kind === "stated" && Number.isFinite(Number(e.value)) && e.value !== null) {
+ cur = Number(e.value);
+ // Met: a reading of his at or under it, said once it was set and by its day. A ">300" says nothing under.
+ if (e.qualifier !== ">") {
+ active = active.filter((g) => {
+ const edge = goalEdge(g);
+ const inTime = !g.deadlineDate || !isIso(e.date) || e.date <= g.deadlineDate;
+ const after = !g.said || !isIso(e.date) || e.date >= g.said;
+ return !(Number.isFinite(edge) && cur <= edge + 1e-9 && inTime && after);
+ });
+ }
+ }
+ // Past its day: missed when his latest weight is over it, else gone without a word.
+ if (recordDate) {
+ const kept = [];
+ for (const g of active) {
+ if (g.deadlineDate && recordDate > g.deadlineDate) {
+ const edge = goalEdge(g);
+ if (Number.isFinite(edge) && Number.isFinite(cur) && cur > edge) {
+ misses.push({ ...g, at: e.t, wasHeadline: before?.row === g.row });
+ }
+ } else kept.push(g);
+ }
+ active = kept;
+ }
+ points.push({ t: e.t, active: [...active], headline: headlineOf(active, cur), cur });
+ }
+ // Every second the board changes: each step, and each missed goal's end.
+ const times = [...new Set([...points.map((p) => p.t), ...misses.map((m) => r4(m.at + hold))])].sort((a, b) => a - b);
+ const at = (t) => {
+ let p = points[0];
+ for (const q of points) if (q.t <= t + 1e-9) p = q; else break;
+ return p;
+ };
+ const out = [];
+ for (const t of times) {
+ const p = at(t);
+ const b = { t, active: p.active, headline: p.headline, missed: misses.filter((m) => m.at <= t + 1e-9 && t < m.at + hold - 1e-9), cur: p.cur };
+ if (!out.length || !sameBoard(out[out.length - 1], b)) out.push(b);
+ }
+ return out;
+}
+
+/** The board at cut second `t` (goalBoard's state in force then). */
+export function goalsAt(board, t) {
+ let b = board[0] ?? { t: 0, active: [], headline: null, missed: [], cur: null };
+ for (const x of board) if (x.t <= t + 1e-9) b = x; else break;
+ return b;
+}
diff --git a/umtool/report-to-video/measure-goals.test.mjs b/umtool/report-to-video/measure-goals.test.mjs
@@ -0,0 +1,174 @@
+// The goal board (measure-goals.mjs) and how the dial draws it
+// (chrome-instruments.mjs): every goal in force, the closest as the headline,
+// a newer goal of the same horizon replacing the older, a goal met or past its
+// day leaving -- missed, struck in red a moment, when his weight is over it.
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { boardGoalWords, dialHtml, goalLines, goalMarks } from "./chrome-instruments.mjs";
+import { estimateSchedule } from "./deck.mjs";
+import { frameKeys } from "./frame-keys.mjs";
+import { MISS_HOLD, goalBoard, goalNeed, goalsAt, headlineOf } from "./measure-goals.mjs";
+
+const FPS = 30;
+const SCALE = { min: 220, max: 400 };
+const fonts = { DeckSans: "assets/DeckSans.ttf", DeckSansBold: "assets/DeckSansBold.ttf" };
+
+/** A measure from events: each state after it, its `goal` the resolution of a goalLoss when `resolved` names one. */
+function measureOf(events) {
+ const state = [{ t: 0 }];
+ for (const e of events) state.push({ t: e.t, ...(e.resolved ? { goal: { row: e.row, value: e.resolved, loss: Math.abs(e.value) } } : {}) });
+ return { scale: SCALE, events: events.map(({ resolved, ...e }) => e), state };
+}
+const stated = (t, row, date, value, qualifier = null) => ({ t, row, date, kind: "stated", value, qualifier });
+const goal = (t, row, date, value, extra = {}) => ({ t, row, date, kind: "goal", value, ...extra });
+const loss = (t, row, date, value, resolved, extra = {}) => ({ t, row, date, kind: "goalLoss", value, resolved, ...extra });
+
+const rows = (b) => b.active.map((g) => g.row);
+
+test("a ladder of three: each in force, the CLOSEST the headline -- not the most ambitious, not the latest", () => {
+ const m = measureOf([
+ stated(1, "s1", "2026-01-09", 337),
+ goal(2, "g1", "2026-01-16", 320, { asOf: "2026-04-01" }), // by his birthday: 17 to go
+ loss(3, "g2", "2026-01-16", -75, 262, { deadline: "by the end of 2026" }), // 75 to go
+ goal(4, "g3", "2026-01-16", 240), // eventual: 97 to go
+ ]);
+ const board = goalBoard(m);
+ const end = goalsAt(board, 10);
+ assert.deepEqual(rows(end), ["g1", "g2", "g3"]);
+ assert.equal(end.headline.row, "g1");
+ assert.equal(end.headline.deadlineDate, "2026-04-01", "a goal's asOf is the day it is for");
+ assert.equal(end.active[1].deadlineDate, "2026-12-31", "his deadline words, read");
+ assert.equal(goalNeed(end.active[1], 337), 75);
+ // Each step on its own second.
+ assert.equal(goalsAt(board, 2.5).headline.row, "g1");
+ assert.deepEqual(rows(goalsAt(board, 3.5)), ["g1", "g2"]);
+ // The words: the headline's, with its day.
+ assert.equal(boardGoalWords(end.headline), "GOAL 320 · BY APR 2026");
+ assert.equal(boardGoalWords(end.active[1]), "GOAL 262 · BY THE END OF 2026");
+ assert.equal(boardGoalWords(end.active[2]), "GOAL 240");
+});
+
+test("ties go to the soonest deadline, then the latest set; a goal with no weight ranks by its loss", () => {
+ const a = { row: "a", t: 1, target: 300, deadlineDate: "2026-12-25" };
+ const b = { row: "b", t: 2, target: 300, deadlineDate: "2026-06-01" };
+ const c = { row: "c", t: 3, target: 300, deadlineDate: null };
+ assert.equal(headlineOf([a, b, c], 320).row, "b");
+ assert.equal(headlineOf([a, c], 320).row, "a", "undated last");
+ assert.equal(headlineOf([{ ...c, row: "c1", t: 1 }, { ...c, row: "c2", t: 2 }], 320).row, "c2", "then the latest set");
+ const unresolved = { row: "u", t: 1, target: null, loss: 15, deadlineDate: null };
+ assert.equal(headlineOf([a, unresolved], 320).row, "u", "15 to lose beats 20");
+ // Before any stated weight a goal's own loss is all there is; a weight already under reach ranks after any still ahead.
+ assert.equal(goalNeed({ target: 250, loss: 50 }, null), 50);
+ assert.equal(headlineOf([{ row: "met", t: 1, target: 330 }, { row: "ahead", t: 2, target: 300 }], 320).row, "ahead");
+});
+
+test("a newer goal of the same horizon replaces the older: the same day, the same words, or both undated", () => {
+ const m = measureOf([
+ goal(1, "a", "2025-08-15", 275, { asOf: "2026-04-01" }),
+ goal(2, "b", "2026-01-16", 320, { asOf: "2026-04-01" }),
+ goal(3, "c", "2026-01-16", 240),
+ goal(4, "d", "2026-01-17", 250),
+ loss(5, "e", "2026-01-18", -80, 211, { deadline: "by my birthday" }),
+ loss(6, "f", "2026-01-18", -90, 201, { deadline: "By my birthday" }),
+ ]);
+ assert.deepEqual(rows(goalsAt(goalBoard(m), 10)), ["b", "d", "f"]);
+});
+
+test("a goal met in time leaves quietly; one past its day with his weight over it is MISSED, held, then gone", () => {
+ const m = measureOf([
+ stated(1, "s1", "2026-01-09", 337),
+ goal(2, "g1", "2026-01-16", 320, { asOf: "2026-04-01" }),
+ goal(3, "g2", "2026-01-16", 330, { due: "2026-03-01" }),
+ goal(4, "g3", "2026-01-16", 240),
+ stated(5, "s2", "2026-02-10", 329), // meets g2 (330) by its day
+ stated(10, "s3", "2026-05-02", 326), // past g1's day (Apr 2026), over 320: MISSED
+ stated(30, "s4", "2026-06-01", 238.5, "<"), // meets the eventual 240
+ ]);
+ const board = goalBoard(m);
+ assert.deepEqual(rows(goalsAt(board, 6)), ["g1", "g3"], "g2 met");
+ assert.equal(goalsAt(board, 6).headline.row, "g1");
+ const miss = goalsAt(board, 10);
+ assert.deepEqual(rows(miss), ["g3"]);
+ assert.deepEqual(miss.missed.map((g) => [g.row, g.at, g.wasHeadline]), [["g1", 10, true]]);
+ assert.equal(miss.headline.row, "g3");
+ assert.equal(goalsAt(board, 10 + MISS_HOLD - 0.01).missed.length, 1);
+ assert.equal(goalsAt(board, 10 + MISS_HOLD).missed.length, 0, "held MISS_HOLD s, then gone");
+ assert.deepEqual(rows(goalsAt(board, 31)), [], "met");
+ assert.equal(goalsAt(board, 31).missed.length, 0, "a goal met is no miss");
+ // The line under the digits says the miss while it is held, then the next headline.
+ const lines = goalLines(board);
+ const lineAt = (t) => [...lines].reverse().find((l) => l.t <= t);
+ assert.deepEqual(lineAt(11), { t: 10, words: "MISSED 320 · BY APR 2026", missed: true });
+ assert.equal(lineAt(17).words, "GOAL 240");
+ // A day passed with his latest weight UNDER the goal (a reading after the day): no miss, it leaves quietly.
+ const late = goalBoard(measureOf([stated(1, "s1", "2026-01-09", 337), goal(2, "g1", "2026-01-16", 320, { asOf: "2026-04-01" }), stated(3, "s2", "2026-07-05", 300)]));
+ assert.deepEqual(goalsAt(late, 4), { ...goalsAt(late, 4), active: [], missed: [] });
+});
+
+test("seek-safe: the board at t is a pure function of the measure, and the dial's marks read it from either side", () => {
+ const m = measureOf([
+ stated(1, "s1", "2026-01-09", 337),
+ goal(2, "g1", "2026-01-16", 320, { asOf: "2026-04-01" }),
+ goal(3, "g2", "2026-01-16", 240),
+ goal(4, "g3", "2026-01-16", 225, { range: [220, 230], due: "2027-01-01" }),
+ stated(6, "s2", "2026-05-02", 326),
+ ]);
+ assert.deepEqual(goalBoard(m), goalBoard(structuredClone(m)));
+ const board = goalBoard(m);
+ const marks = goalMarks(board, SCALE);
+ assert.deepEqual(marks.map((x) => x.goal.row), ["g1", "g2", "g3"]);
+ assert.equal(marks[2].band, true);
+ const statusAt = (x, t) => [...x.states].reverse().find((s) => s.t <= t)?.status;
+ assert.deepEqual(marks.map((x) => statusAt(x, 3.5)), ["head", "other", "off"]);
+ assert.deepEqual(marks.map((x) => statusAt(x, 6.5)), ["missed", "head", "other"]);
+ assert.deepEqual(marks.map((x) => statusAt(x, 6 + MISS_HOLD + 1)), ["off", "head", "other"]);
+
+ // On the dial's page: the marks' cues, which the frame keys model.
+ const timeline = Array.from({ length: 2 }, (_, i) => ({ type: "clip", id: `c${i + 1}`, video: "v", start: 10 * i, end: 10 * i + 8, cite: 1, section: 0, quote: "q", onscreen: { title: "T" } }));
+ const render = { width: 1920, height: 1080, fps: FPS, palette: {}, chrome: { engine: "hyperframes", layout: "deck", deck: { dial: true, qr: { show: false } } } };
+ const schedule = { ...estimateSchedule({ slug: "m", title: "M", provenance: {}, render, timeline }), measure: m };
+ const html = dialHtml(schedule, render, { fonts });
+ assert.match(html, /data-k="gm0h"/);
+ assert.match(html, /class="goalw miss" data-k="gw\d+"[^>]*>MISSED 320 · BY APR 2026</);
+ const data = JSON.parse(/<script id="dial-data" type="application\/json">(.*?)<\/script>/s.exec(html)[1]);
+ const at = (k, t) => {
+ let v = data.init[k]?.autoAlpha;
+ for (const c of data.cues) if (c.k === k && "autoAlpha" in c.to && c.at + c.dur <= t + 1e-9) v = c.to.autoAlpha;
+ return v;
+ };
+ assert.deepEqual([at("gm0h", 3.5), at("gm1o", 3.5), at("gm0x", 3.5)], [1, 0.85, 0]);
+ assert.deepEqual([at("gm0x", 7), at("gm1h", 7), at("gm0p", 9)], [1, 1, 0]);
+ assert.ok(data.cues.some((c) => c.k === "gm0p" && c.to.autoAlpha === 1), "the miss flashes");
+ const frames = Math.round(schedule.total * FPS);
+ assert.ok(frameKeys({ html, region: "dial", fps: FPS, frames, version: "t" }));
+});
+
+test("the shelf's goal fan reads the same board: the headline in front, +N more, a missed goal struck; a joke or another's goal is no note", async () => {
+ const { goalStates } = await import("./measure-extras.mjs");
+ const { goalsHtml, shelfGoalStates } = await import("./chrome-measure-extras.mjs");
+ const m = { ...measureOf([
+ stated(1, "s1", "2026-01-09", 337),
+ goal(2, "g1", "2026-01-16", 320, { asOf: "2026-04-01" }),
+ goal(3, "g2", "2026-01-16", 240),
+ goal(4, "j1", "2026-01-16", 150, { unresolved: true }),
+ goal(5, "o1", "2026-01-16", 200, { speaker: "madamsavvy" }),
+ stated(10, "s2", "2026-05-02", 326),
+ ]), unit: "lb" };
+ const render = { width: 1920, height: 1080, fps: FPS, palette: { bg: "#0F1312", fg: "#EDF0EC", muted: "#98A29B", accent: "#22AB83", amber: "#E8A33F" },
+ chrome: { engine: "hyperframes", layout: "deck", deck: { measure: {}, dial: true, shelf: { items: ["goals"] }, goals: { position: "shelf" } } } };
+ const schedule = { kind: "deck", fps: FPS, total: 40, transition: 0, segments: [{ id: "a", start: 0, duration: 40, end: 40 }], measure: m };
+ const states = goalStates(schedule, render);
+ assert.deepEqual(states.map((s) => s.at), [2, 3], "the joke and her goal are no notes");
+ const shelf = shelfGoalStates(schedule, states);
+ // A state per goal set, and one where the board alone changes: g1 missed at 10, its hold's end.
+ assert.deepEqual(shelf.map((s) => s.at), [2, 3, 10, 10 + MISS_HOLD]);
+ const front = (s) => s.notes.find((n) => n.depth === 0).key;
+ // At 3 the newest is 240, but the CLOSEST leads: 320, with one more in force.
+ assert.deepEqual([front(shelf[1]), shelf[1].headline, shelf[1].active], ["320 lb", "320 lb", 2]);
+ assert.deepEqual([shelf[2].top, shelf[2].missed, front(shelf[2])], [null, ["320 lb"], "240 lb"]);
+ assert.deepEqual(shelf[3].missed, []);
+ const { html } = goalsHtml(schedule, render, {});
+ assert.match(html, /\+1 more/);
+ assert.match(html, /class="note missed"/);
+});
diff --git a/umtool/report-to-video/measure-slice.mjs b/umtool/report-to-video/measure-slice.mjs
@@ -21,9 +21,10 @@
//
// The odometer rule (ruled 5 Nov 2026, "go by his words"): see lossRuns.
import { chronological, dateKey, daysBetween } from "./ledger-shared.mjs";
-import { PROMISE_FORMS, measureDisplay, measureQualifier, measureSchema, measureTotals, plotDate } from "./measure-totals.mjs";
+import { PROMISE_FORMS, boundAgrees, displayRange, measureDisplay, measureQualifier, measureSchema, measureTotals, plotDate } from "./measure-totals.mjs";
import { goalCell, nextRegime, offOf } from "./panel-model.mjs";
import { offsetIn } from "./gaps.mjs";
+import { validateGhosts } from "./measure-ghosts.mjs";
import { dietRecord } from "./diet-record.mjs";
import { dietRunsOn } from "./finale.mjs";
@@ -32,7 +33,7 @@ export const MEASURE_SLICE_VERSION = 1;
export { PROMISE_FORMS };
/** `render.chrome.deck.measure`'s keys. */
-export const MEASURE_SETTINGS_KEYS = Object.freeze(["scopes", "scale", "asOf"]);
+export const MEASURE_SETTINGS_KEYS = Object.freeze(["scopes", "scale", "asOf", "ghosts"]);
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) && !Number.isNaN(Date.parse(`${v}T00:00:00Z`));
@@ -40,16 +41,17 @@ const r1 = (v) => Math.round(v * 10) / 10;
const r3 = (v) => Math.round(v * 1000) / 1000;
/**
- * `render.chrome.deck.measure`, checked: `{ scopes?, scale?, asOf? }` --
+ * `render.chrome.deck.measure`, checked: `{ scopes?, scale?, asOf?, ghosts? }` --
* `scopes` a list of track keys (unique, at least one), `scale` `{ min, max }`
- * (numbers, min < max), `asOf` a date (YYYY-MM-DD). Whether the scopes are
+ * (numbers, min < max), `asOf` a date (YYYY-MM-DD), `ghosts` the dial's claim
+ * ghosts (measure-ghosts.mjs: true, false or their knobs). Whether the scopes are
* the ledger's tracks is measureSettingsProblems' (it has the schema).
*
* @returns {string[]}
*/
export function validateMeasureSettings(v, where = "render.chrome.deck.measure") {
if (v === undefined) return [];
- if (!isObj(v)) return [`${where} must be { scopes, scale, asOf }`];
+ if (!isObj(v)) return [`${where} must be { ${MEASURE_SETTINGS_KEYS.join(", ")} }`];
const errors = [];
for (const k of Object.keys(v)) if (!MEASURE_SETTINGS_KEYS.includes(k)) errors.push(`${where}.${k} is not a measure setting (${MEASURE_SETTINGS_KEYS.join(", ")})`);
if (v.scopes !== undefined) {
@@ -64,6 +66,7 @@ export function validateMeasureSettings(v, where = "render.chrome.deck.measure")
else for (const k of Object.keys(s)) if (k !== "min" && k !== "max") errors.push(`${where}.scale.${k} is not a scale setting (min, max)`);
}
if (v.asOf !== undefined && !isIso(v.asOf)) errors.push(`${where}.asOf must be a date (YYYY-MM-DD)`);
+ errors.push(...validateGhosts(v.ghosts, `${where}.ghosts`));
return errors;
}
@@ -210,11 +213,7 @@ const entrySource = (entry) => (entry?.type === "clip" ? "clip" : entry?.type ==
* as a range -- a wedge, "330–340" -- never the middle alone.
*/
export function rangeOf(row) {
- const m = /(\d+(?:\.\d+)?)\s*[-–]\s*(\d+(?:\.\d+)?)/.exec(String(row?.display ?? ""));
- if (!m) return null;
- const lo = Number(m[1]);
- const hi = Number(m[2]);
- return Number.isFinite(lo) && Number.isFinite(hi) && hi > lo ? [lo, hi] : null;
+ return displayRange(row?.display);
}
function eventOf(row, schema, runOf) {
@@ -242,6 +241,8 @@ function eventOf(row, schema, runOf) {
run: kind === "lost" && runOf.has(row.id) ? runOf.get(row.id) : null,
speaker: speakerOf(row),
outcome: row.population === "promise_outcome" && typeof row.outcome === "string" ? row.outcome : null,
+ // Not a usable claim (a joke, a misattributed line): on screen when pinned, in no tally (isUsable).
+ ...(row.scopeConfidence === "unresolved" ? { unresolved: true } : {}),
};
}
@@ -253,6 +254,15 @@ function eventOf(row, schema, runOf) {
*/
export const speakerOf = (row) => (typeof row?.speaker === "string" && row.speaker.trim() ? row.speaker.trim() : null);
+/**
+ * Does the row COUNT -- in a tally (goals set, diets, pledges, the odometer,
+ * "under 300", the goal ladder)? Not when its scope is `unresolved`: the
+ * ledger's word for "not a usable claim" (a joke -- w44, "only way I'm losing
+ * 100 lbs is by amputation" -- or a line that is not his). Such a row is still
+ * a row: pinned, it is on screen, and a reading still reads (operator, 6 Nov).
+ */
+export const isUsable = (row) => row?.scopeConfidence !== "unresolved" && row?.unresolved !== true;
+
// ---------------------------------------------------------------------------
// When a row lands: the spoken number in the clip's words
// ---------------------------------------------------------------------------
@@ -395,7 +405,9 @@ export function measureSlice(manifest, schedule, opts = {}) {
const byId = new Map(rows.map((r) => [r.id, r]));
// HIS rows: every number the instruments draw is the subject's own.
const own = rows.filter((r) => speakerOf(r) === null);
- const { runs, runOf, claims: lossClaims, total } = lossRuns(own, s);
+ // What counts in a tally: his own usable rows.
+ const counted = own.filter(isUsable);
+ const { runs, runOf, claims: lossClaims, total } = lossRuns(counted, s);
const runById = new Map(runs.map((r) => [r.run, r]));
// ---- events: each pinned row at the cut second it lands -------------------
@@ -537,7 +549,12 @@ export function measureSlice(manifest, schedule, opts = {}) {
const row = byId.get(ev.row);
// Another speaker's row feeds the promises and nothing else.
if (ev.speaker !== null && ev.kind !== "promiseClaim" && ev.kind !== "promiseOutcome") { state.push(snapshot(ev.t)); continue; }
- if (ev.kind === "stated" && ev.value !== null) current = { value: ev.value, qualifier: ev.qualifier, row: ev.row, date: ev.date, asOf: ev.asOf, ...(ev.range ? { range: [...ev.range] } : {}) };
+ // An unresolved row is no claim to count: it moves a reading (it is on screen), never a goal, a diet, a promise.
+ if (ev.unresolved && ev.kind !== "stated" && ev.kind !== "remembered") { state.push(snapshot(ev.t)); continue; }
+ // A bound that agrees with the specific weight in force (">300" while he is at 342) is no new figure: the needle
+ // and the number stay (boundAgrees). One that contradicts it (">300" at 291) moves them, as any reading does.
+ if (ev.kind === "stated" && ev.value !== null && boundAgrees(ev, current)) { /* the current weight stands */ }
+ else if (ev.kind === "stated" && ev.value !== null) current = { value: ev.value, qualifier: ev.qualifier, row: ev.row, date: ev.date, asOf: ev.asOf, ...(ev.range ? { range: [...ev.range] } : {}) };
else if (ev.kind === "remembered" && ev.value !== null) remembered.push({ value: ev.value, asOf: ev.asOf, row: ev.row, date: ev.date, ...(ev.qualifier ? { qualifier: ev.qualifier } : {}), ...(ev.range ? { range: [...ev.range] } : {}) });
else if (ev.kind === "goal" || ev.kind === "goalLoss") { goal = goalOf(row); goals.push(ev.row); }
else if (ev.kind === "lost" && ev.run !== null) {
@@ -571,7 +588,8 @@ export function measureSlice(manifest, schedule, opts = {}) {
// ---- totals over the whole record in scope --------------------------------
const all = chronological(own);
const lastStated = [...readings].filter((r) => r.population === "current").pop() ?? null;
- const goalRows = all.filter((r) => r.population === "goal" || r.population === "goal_loss");
+ const tallied = all.filter(isUsable);
+ const goalRows = tallied.filter((r) => r.population === "goal" || r.population === "goal_loss");
const repeats = {};
for (const r of goalRows) { const d = measureDisplay(r, s); repeats[d] = (repeats[d] ?? 0) + 1; }
const goalRepeats = Object.fromEntries(Object.entries(repeats).filter(([, n]) => n > 1).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])));
@@ -585,18 +603,18 @@ export function measureSlice(manifest, schedule, opts = {}) {
const peakDrift = [...new Set(readings.filter((r) => r.population === "past" && r.asOf && firstStated && dateKey(r.asOf) >= firstStated && Number(r.value) > maxStated).map((r) => Number(r.value)))].sort((a, b) => a - b);
// UNDER 300: a weight he stated below it, or "under 300" itself -- never a
// bound the other way ("over 240" is not a weight under 300).
- const under = stated.filter((r) => {
+ const under = stated.filter(isUsable).filter((r) => {
const q = measureQualifier(r, s);
return q !== ">" && (Number(r.value) < 300 || (Number(r.value) === 300 && q === "<"));
});
const dates = all.map((r) => plotDate(r)).filter(Boolean).map(dateKey).sort();
- const promiseRows = all.filter((r) => r.population === "promise");
+ const promiseRows = tallied.filter((r) => r.population === "promise");
const checksOf = (id) => all.filter((r) => r.population === "promise_check" && r.promise === id);
const outcomeRowOf = (id) => chronological(rows).filter((r) => r.population === "promise_outcome" && r.promise === id && typeof r.outcome === "string").pop() ?? null;
const claimsOf = (id) => chronological(rows).filter((r) => r.population === "promise_claim" && r.promise === id).map(claimOf);
let diets = 0;
try {
- diets = measureTotals(own, s, { strict: false }).switches;
+ diets = measureTotals(counted, s, { strict: false }).switches;
} catch {
diets = 0;
}
@@ -640,7 +658,7 @@ export function measureSlice(manifest, schedule, opts = {}) {
totals,
// The whole diet record, for the finale's detailed runs (`deck.finale.dietRuns`): only when it asks.
...(dietRunsOn(manifest?.render?.chrome?.deck?.finale?.dietRuns)
- ? { record: dietRecord(own, s, regimeTrack, readings, isObj(manifest.render.chrome.deck.finale.dietRuns) ? manifest.render.chrome.deck.finale.dietRuns : {}) }
+ ? { record: dietRecord(counted, s, regimeTrack, readings, isObj(manifest.render.chrome.deck.finale.dietRuns) ? manifest.render.chrome.deck.finale.dietRuns : {}) }
: {}),
};
}
diff --git a/umtool/report-to-video/measure-slice.test.mjs b/umtool/report-to-video/measure-slice.test.mjs
@@ -5,12 +5,15 @@ import assert from "node:assert/strict";
import test from "node:test";
import {
- isRealtimeLoss, kindOf, lossRuns, measureOn, measureSettingsProblems, measureSlice, pinnedRows, spokenAt, spokenNumbers,
+ isRealtimeLoss, isUsable, kindOf, lossRuns, measureOn, measureSettingsProblems, measureSlice, pinnedRows, spokenAt, spokenNumbers,
validateMeasureSettings,
} from "./measure-slice.mjs";
import { estimateSchedule, validateChrome } from "./deck.mjs";
import { scheduleSlices } from "./modules/index.mjs";
import { validateClaims } from "./factcheck.mjs";
+import { goalBoard } from "./measure-goals.mjs";
+import { boundAgrees, measureScoreboard, measureTotals } from "./measure-totals.mjs";
+import { nextReading } from "./panel-model.mjs";
const SCHEMA = {
kind: "measure",
@@ -195,7 +198,7 @@ test("the settings: their shape, their scopes against the ledger, and when a cut
assert.deepEqual(validateMeasureSettings(undefined), []);
assert.deepEqual(validateMeasureSettings({ scopes: ["weight"], scale: { min: 220, max: 400 }, asOf: "2026-11-05" }), []);
assert.deepEqual(validateMeasureSettings({ scopes: [], scale: { min: 4, max: 2 }, asOf: "Nov 5", x: 1 }), [
- "render.chrome.deck.measure.x is not a measure setting (scopes, scale, asOf)",
+ "render.chrome.deck.measure.x is not a measure setting (scopes, scale, asOf, ghosts)",
"render.chrome.deck.measure.scopes must be a list of the ledger's track keys (at least one)",
"render.chrome.deck.measure.scale.min must be below scale.max",
"render.chrome.deck.measure.asOf must be a date (YYYY-MM-DD)",
@@ -276,3 +279,90 @@ test("a promise's outcome: how it ended, and \"kept\" keeps it -- the totals unt
assert.equal(kept.totals.promises[0].kept, true);
assert.equal(plain.state.at(-1).promises[0].outcome, null);
});
+
+// ---------------------------------------------------------------------------
+// The operator's rulings of 6 Nov: a bound that agrees with the weight in force does not move it; an unresolved
+// row and another speaker's count in no tally.
+// ---------------------------------------------------------------------------
+
+test("boundAgrees: a bound the specific weight satisfies agrees; one it contradicts, or a bound in force, does not", () => {
+ const at = (value, extra = {}) => ({ value, qualifier: null, ...extra });
+ assert.equal(boundAgrees({ value: 300, qualifier: ">" }, at(342)), true);
+ assert.equal(boundAgrees({ value: 300, qualifier: ">" }, at(291)), false, "contradicts: new information");
+ assert.equal(boundAgrees({ value: 300, qualifier: ">" }, at(300)), false, "300 is not over 300");
+ assert.equal(boundAgrees({ value: 300, qualifier: "<" }, at(291)), true);
+ assert.equal(boundAgrees({ value: 300, qualifier: "<" }, at(305)), false);
+ assert.equal(boundAgrees({ value: 390, qualifier: "≈" }, at(388)), true);
+ assert.equal(boundAgrees({ value: 390, qualifier: "≈" }, at(380)), false);
+ assert.equal(boundAgrees({ value: 335, range: [330, 340] }, at(337)), true);
+ assert.equal(boundAgrees({ value: 335, range: [330, 340] }, at(342)), false);
+ assert.equal(boundAgrees({ value: 342 }, at(300)), false, "a specific reading always moves it");
+ assert.equal(boundAgrees({ value: 300, qualifier: ">" }, null), false, "nothing in force: as today");
+ assert.equal(boundAgrees({ value: 300, qualifier: ">" }, at(320, { qualifier: ">" })), false, "a bound in force is replaced as today");
+});
+
+test("a bound that agrees with the weight in force leaves the needle and the number; one that contradicts moves them", () => {
+ const rows = (...extra) => [
+ row({ id: "a1", date: "2025-05-01", population: "current", value: 342, display: "342 lb", entryId: "c3" }),
+ ...extra,
+ ];
+ const sliceOf = (ledger) => measureSlice({ ...manifest(), ledger }, { segments: SEGMENTS }, { words: WORDS, clock: CLOCK, asOf: "2025-07-10" });
+ const currentAfter = (sl, id) => sl.state[sl.events.findIndex((e) => e.row === id) + 1].current;
+ // ">300" at 342: the 342 stands -- its event is still there (its ghost tick, the trail's point).
+ const agree = sliceOf(rows(row({ id: "a2", date: "2025-05-10", population: "current", value: 300, qualifier: ">", display: ">300 lb", entryId: "c4" })));
+ assert.equal(currentAfter(agree, "a2").row, "a1");
+ assert.equal(currentAfter(agree, "a2").value, 342);
+ assert.ok(agree.events.some((e) => e.row === "a2" && e.kind === "stated"));
+ // "<300" at 342 contradicts it: new information, the needle moves.
+ const contra = sliceOf(rows(row({ id: "a2", date: "2025-05-10", population: "current", value: 300, qualifier: "<", display: "<300 lb", entryId: "c4" })));
+ assert.deepEqual([currentAfter(contra, "a2").row, currentAfter(contra, "a2").qualifier], ["a2", "<"]);
+ // A bound with nothing specific in force behaves as it did: it is the reading.
+ const first = sliceOf([row({ id: "a2", date: "2025-05-10", population: "current", value: 300, qualifier: ">", display: ">300 lb", entryId: "c4" })]);
+ assert.equal(currentAfter(first, "a2").row, "a2");
+ // The panel's reading cell keeps the same rule.
+ const prev = nextReading(null, row({ id: "a1", date: "2025-05-01", population: "current", value: 342, display: "342 lb" }), SCHEMA);
+ assert.equal(nextReading(prev, row({ id: "a2", date: "2025-05-10", population: "current", value: 300, qualifier: ">", display: ">300 lb" }), SCHEMA).row, "a1");
+ assert.equal(nextReading(prev, row({ id: "a3", date: "2025-05-10", population: "current", value: 300, qualifier: "<", display: "<300 lb" }), SCHEMA).row, "a3");
+});
+
+test("an unresolved row (a joke) counts in no tally -- goals set, the goal, diets, promises, the odometer, under 300 -- pinned or not", () => {
+ const sliceOf = (ledger) => measureSlice({ ...manifest(), ledger }, { segments: SEGMENTS }, { words: WORDS, clock: CLOCK, asOf: "2025-07-10" });
+ const plain = sliceOf(LEDGER);
+ const joke = { scopeConfidence: "unresolved" };
+ const extra = [
+ // w44's shape: "only way I'm losing 100 lbs is by amputation" -- unpinned, and a pinned one besides.
+ row({ id: "j1", date: "2025-06-07", population: "goal_loss", value: -100, display: "lose 100", ...joke }),
+ row({ id: "j2", date: "2025-06-07", population: "goal", value: 200, display: "200", entryId: "c5", ...joke }),
+ row({ id: "j3", date: "2025-06-07", scope: "regime", population: "status", value: "glp1", event: "start", display: "glp1", entryId: "c5", ...joke }),
+ row({ id: "j4", date: "2025-06-07", population: "delta", value: -150, display: "-150", entryId: "c5", ...joke }),
+ row({ id: "j5", date: "2025-06-07", population: "promise", value: null, display: "a joke promise", entryId: "c5", ...joke }),
+ ];
+ const sl = sliceOf([...LEDGER, ...extra]);
+ for (const k of ["goals", "goalRepeats", "diets", "lost", "runs", "under300"]) assert.deepEqual(sl.totals[k], plain.totals[k], k);
+ assert.deepEqual(sl.totals.promises.map((p) => p.row), plain.totals.promises.map((p) => p.row));
+ const last = sl.state.at(-1), was = plain.state.at(-1);
+ for (const k of ["goal", "goals", "diet", "lost", "current"]) assert.deepEqual(last[k], was[k], k);
+ // Pinned, it is still an event (on screen), marked; the goal board passes over it.
+ assert.equal(sl.events.find((e) => e.row === "j2").unresolved, true);
+ assert.equal(plain.events.find((e) => e.row === "w11").unresolved, undefined, "a usable row's event is as it was");
+ assert.ok(!goalBoard(sl).some((b) => b.active.some((g) => g.row === "j2")));
+ assert.equal(isUsable({ scopeConfidence: "unresolved" }), false);
+ assert.equal(isUsable({ scopeConfidence: "read" }), true);
+});
+
+test("the scoreboard's tallies (goals set, diets, pledges) count neither an unresolved row nor another speaker's", () => {
+ const base = [
+ row({ id: "g1", date: "2025-01-01", population: "goal", value: 250, display: "250" }),
+ row({ id: "r1", date: "2025-01-02", scope: "regime", population: "status", value: "keto", event: "start", display: "keto" }),
+ ];
+ const noise = [
+ row({ id: "g2", date: "2025-02-01", population: "goal_loss", value: -100, display: "lose 100", scopeConfidence: "unresolved" }),
+ row({ id: "g3", date: "2025-02-02", population: "goal", value: 200, display: "200", speaker: "madamsavvy" }),
+ row({ id: "r2", date: "2025-02-03", scope: "regime", population: "status", value: "carnivore", event: "start", display: "carnivore", speaker: "madamsavvy" }),
+ row({ id: "r3", date: "2025-02-04", scope: "regime", population: "status", value: "glp1", event: "start", display: "glp1", scopeConfidence: "unresolved" }),
+ ];
+ const board = (ledger) => measureScoreboard(measureTotals(ledger, SCHEMA, { strict: false })).final;
+ const a = board(base), b = board([...base, ...noise]);
+ assert.deepEqual([b.goals.count, b.diets.count, b.pledges.count], [a.goals.count, a.diets.count, a.pledges.count]);
+ assert.equal(b.goals.last.id, "g1");
+});
diff --git a/umtool/report-to-video/measure-totals.mjs b/umtool/report-to-video/measure-totals.mjs
@@ -1056,7 +1056,9 @@ export function measureTotals(ledger, schema, { strict = true } = {}) {
for (const e of all) {
const gaps = measureGaps(e, s);
const ruled = gaps.length === 0;
- const settled = ruled && e.scopeConfidence !== "unresolved";
+ // Counted only when it is a usable claim of HIS: an `unresolved` scope (a joke, a misattributed line) and another
+ // speaker's row (`speaker`) are in the record and on screen, never in a tally (operator, 6 Nov).
+ const settled = ruled && e.scopeConfidence !== "unresolved" && !(typeof e.speaker === "string" && e.speaker.trim());
const tr = trackOf(s, e.scope);
const at = plotDate(e);
const flags = [];
@@ -1610,6 +1612,41 @@ export function freshestReading(claim, at, prev) {
return !prev || dateKey(at) > dateKey(prev.at);
}
+/** A range his words give ("330-340", "220–240 lb"), as `[lo, hi]`, or null. */
+export function displayRange(display) {
+ const m = /(\d+(?:\.\d+)?)\s*[-–]\s*(\d+(?:\.\d+)?)/.exec(String(display ?? ""));
+ if (!m) return null;
+ const lo = Number(m[1]);
+ const hi = Number(m[2]);
+ return Number.isFinite(lo) && Number.isFinite(hi) && hi > lo ? [lo, hi] : null;
+}
+
+/**
+ * Does a QUALIFIED reading agree with the SPECIFIC one in force -- so it is no
+ * new figure and the current weight stays (operator, 6 Nov: "If a range is
+ * provided (e.g. 'over 300') and we already match with a specific number
+ * (e.g. 342), don't change the current weight")? `bound` and `specific` are
+ * `{ value, qualifier?, range? }`. Agrees when `specific` is a plain number (no
+ * qualifier, no range) and `bound` is a qualified one it satisfies: ">300"
+ * by anything over 300, "<300" by anything under, "≈390" by 387 to 391 (the
+ * dial's wedge), a range by anything inside it. A bound that CONTRADICTS the
+ * specific reading (">300" against 291) is new information: it does not agree,
+ * and it moves the reading as any other does.
+ */
+export function boundAgrees(bound, specific) {
+ if (!bound || !specific) return false;
+ const c = Number(specific.value);
+ if (!Number.isFinite(c) || specific.qualifier || Array.isArray(specific.range)) return false;
+ const v = Number(bound.value);
+ const r = Array.isArray(bound.range) && bound.range.length === 2 ? bound.range : null;
+ if (r) return c >= r[0] && c <= r[1];
+ if (!Number.isFinite(v)) return false;
+ if (bound.qualifier === ">") return c > v;
+ if (bound.qualifier === "<") return c < v;
+ if (bound.qualifier === "≈") return c >= v - 3 && c <= v + 1;
+ return false;
+}
+
/**
* A goal as a weight, when it can be one.
*
diff --git a/umtool/report-to-video/modules/dial.mjs b/umtool/report-to-video/modules/dial.mjs
@@ -2,9 +2,13 @@
// the instruments' column (instruments.mjs, deck.mjs instrumentsGeometry). A
// red needle swings to every weight he states, on the word, overshoots and
// settles; "almost", "over", "under" draw a wedge; his remembered weights are
-// grey ghost ticks, the latest a long ghost needle with its as-of date; his
-// latest goal an amber tick on the bezel; the 300 lb mark accented; the
-// weight in big digits under the hub. chrome-instruments.mjs writes the page.
+// grey ghost ticks, the latest a long ghost needle with its as-of date; every
+// goal in force a mark on the bezel, the CLOSEST (measure-goals.mjs) the full
+// amber tick with its words, a missed one struck in red; with
+// `deck.measure.ghosts`, a faint tick on the rim for every weight he has
+// claimed, coloured by how often (measure-ghosts.mjs); the 300 lb mark
+// accented; the weight in big digits under the hub. chrome-instruments.mjs
+// writes the page.
import path from "node:path";
import { instrumentsGeometry } from "../deck.mjs";
@@ -21,7 +25,7 @@ export default defineModule({
kind: "overlay-whole",
slot: "instruments",
title: "Scale dial",
- summary: "A bathroom-scale face: the needle swings to each weight he states, his remembered weights as ghosts, his goal on the bezel.",
+ summary: "A bathroom-scale face: the needle swings to each weight he states, his remembered weights as ghosts, every goal in force on the bezel (the closest headlined), and -- with deck.measure.ghosts -- a faint tick for every weight he has claimed.",
configKey: "render.chrome.deck.dial",
defaults: DIAL_DEFAULTS,
validate: settingsOf("dial").validate,
@@ -29,7 +33,7 @@ export default defineModule({
ui: [
{ key: "mark", type: "number", min: 0, max: 2000, step: 1, label: "Accented weight", default: 300 },
{ key: "ghosts", type: "boolean", label: "Remembered weights as ghosts", default: true },
- { key: "goal", type: "boolean", label: "The latest goal on the bezel", default: true },
+ { key: "goal", type: "boolean", label: "Every goal in force on the bezel, the closest headlined", default: true },
{ key: "finale", type: "boolean", label: "Large in the finale", default: true },
{ key: "label", type: "text", label: "Over the digits", default: DIAL_DEFAULTS.label },
{ key: "placement", type: "enum", options: ["column", "corner"], label: "Where the instruments stand", default: "column" },
@@ -40,11 +44,14 @@ export default defineModule({
],
docs: {
heading: "Scale dial",
- intro: "A bathroom-scale face at the top of the instruments' column (the right of the frame; the clip moves to the left -- `instrumentsGeometry`, 1248×702 footage beside a 600 px column at 1920×1080). It reads the schedule's `measure` (the measure ledger's slice): the red needle swings to each STATED weight at its event's `t` (the spoken word) with a spring (`back.out`, 0.9 s) and rests there -- a frame at rest is reused, not captured again; a qualifier draws a wedge in pounds (≈ 3 under to 1 over, `>` 10 up, `<` 10 down); every REMEMBERED weight is a grey tick, the latest a long ghost needle with its as-of date; the latest goal is an amber tick on the bezel and its words under the digits. It comes and goes with the deck (a card, the finale). With any instrument on, the posts stay in the footage box (`posts.shift` does not apply), and the side panel (`threads`, `flips`) and the posts feed are refused.",
+ intro: "A bathroom-scale face at the top of the instruments' column (the right of the frame; the clip moves to the left -- `instrumentsGeometry`, 1248×702 footage beside a 600 px column at 1920×1080). It reads the schedule's `measure` (the measure ledger's slice): the red needle swings to each STATED weight at its event's `t` (the spoken word) with a spring (`back.out`, 0.9 s) and rests there -- a frame at rest is reused, not captured again; a BOUND that agrees with the specific weight in force (\">300\" while he is at 342, \"≈390\" at 388, \"330-340\" at 337) is no new figure and moves neither the needle nor the number (measure-totals.mjs `boundAgrees`; it still leaves its claim ghost), while one that contradicts it (\">300\" at 291) moves them as any reading does; a qualifier draws a wedge in pounds (≈ 3 under to 1 over, `>` 10 up, `<` 10 down); every REMEMBERED weight is a grey tick, the latest a long ghost needle with its as-of date. GOALS (measure-goals.mjs `goalBoard`): every goal in force at the playhead is a mark on the bezel at its weight -- in force from the moment the cut shows it until he meets it in time, a newer goal of the same HORIZON replaces it (the same deadline day, the same deadline words, or both undated), or the record's date passes its day. The HEADLINE is the CLOSEST of them -- the least still to lose from his latest stated weight (a range to its top), ties to the soonest deadline -- the full amber tick, its words under the digits (`GOAL 320 · BY APR 2026`); the others a thin amber tick, no words; a range an amber band too. A goal whose day passes with his latest weight over it is MISSED: struck in the needle's red with a red flash, the line under the digits `MISSED 320 · BY APR 2026` for 6 s (`MISS_HOLD`), then gone; a day passing with his weight under it (a reading after the day) leaves quietly. A goal's day: the ledger's `due`, else his `deadline` words read (\"by Christmas\", \"by the end of 2026\"), else the row's `asOf`. Any page that shows a goal reads the same board: `goalBoard(schedule.measure)` -> `[{ t, active, headline, missed, cur }]`, `goalsAt(board, t)`. It comes and goes with the deck (a card, the finale). With any instrument on, the posts stay in the footage box (`posts.shift` does not apply), and the side panel (`threads`, `flips`) and the posts feed are refused.",
rows: [
["`deck.dial`", "`true` · an object of the knobs below · `false` off · absent: ON when the cut draws a measure (`deck.measure` set), else off", "`umtool look <p> deck.dial=false`"],
["`deck.dial.mark`", "a weight, or `null` · default `300` (its tick and label in the accent)", "`umtool look <p> deck.dial.mark=300`"],
- ["`deck.dial.ghosts`, `.goal`", "bool · default `true` each", "`umtool look <p> deck.dial.ghosts=false`"],
+ ["`deck.dial.ghosts`, `.goal`", "bool · default `true` each (`.goal`: every goal in force, the closest headlined)", "`umtool look <p> deck.dial.ghosts=false`"],
+ ["`deck.measure.ghosts`", "`true` · `{opacity, tolerance, ramp, pulse}` · `false` / absent: off (the default). CLAIM GHOSTS (measure-ghosts.mjs), not `deck.dial.ghosts`: every weight he has claimed so far -- each stated weight the needle goes to and each remembered one, his own, in cut order -- leaves a thin faint tick across the dial's rim at its value, under everything else on the face; a value claimed again (within `tolerance` lb of the tick's first value; an `≈` value as its rounded number; `>300` and `<300` at 300) steps that tick along the `ramp` -- 1× faint, 2× warm, 3× and up hot, a little thicker each step -- and it pulses once as the repeat lands (`pulse`). In the finale every tick stays at its count at the cut's end. Seek-safe: a frame at t draws the claims before t", "`umtool look <p> deck.measure.ghosts=true`"],
+ ["`deck.measure.ghosts.opacity`, `.tolerance`", "0.15–0.9 (the 1× tick's; +0.2 a step, at most 0.95) · 0–5 lb · default `0.5`, `0.5`", "`umtool look <p> deck.measure.ghosts='{\"tolerance\":1}'`"],
+ ["`deck.measure.ghosts.ramp`, `.pulse`", "2–4 #hex, 1× first (the last for every count from there up), or `null`: the palette's muted, amber, and amber half way to the needle's red · bool · default `null`, `true`", "`umtool look <p> deck.measure.ghosts='{\"ramp\":[\"#98a29b\",\"#e8a33f\",\"#f37e47\"],\"pulse\":false}'`"],
["`deck.dial.needle`", "a #hex · default `#ff5a4e`", "`umtool look <p> deck.dial.needle='\"#ff5a4e\"'`"],
["`deck.dial.label`", "words over the digits, ≤ 40 · default `HE SAYS HE WEIGHS`", "`umtool look <p> deck.dial.label='\"…\"'`"],
["`deck.dial.finale`", "bool · default `true`: the dial and the odometer large in the finale (module `dial-finale`)", "`umtool look <p> deck.dial.finale=false`"],
diff --git a/umtool/report-to-video/modules/goals.mjs b/umtool/report-to-video/modules/goals.mjs
@@ -28,7 +28,7 @@ export default measureExtraModule({
rows: [
["`deck.goals`", "`true` · `false` · `{show, position, x, y, scale, hold, finale, max, color, countdown}` · default on with a measure slice", "`umtool look <p> deck.goals=false`"],
["`deck.goals.position`, `.x`/`.y`, `.scale`", "`top-left` `top-right` `bottom-left` `bottom-right` `top-center` `bottom-center` · design px · 0.5–2 · default `bottom-right`, unset, 1", "`umtool look <p> deck.goals.position=bottom-left`"],
- ["`deck.goals.position=shelf`", "its shelf form (`deck.shelf`): the count of goals set in a column, then the notes fanned sideways like the diet's tags -- the headline goal in front when the measure state names one (\`goals.headline\`: the closest goal in force) with \"+N more\" for the others in force, else the newest; a new goal landing from above as on the pile; each older one showing its goal's words in the strip beside it (all of each when there is room); a repeat comes to the front with its ×n. The fan takes the shelf's spare width (shelfLayout), up to its notes side by side. On the shelf it stays up from the first goal (`hold` unset). What the dial draws of the goal stays on the dial", "`umtool look <p> deck.shelf.items='[\"diet\",\"goals\"]' deck.goals.position=shelf`"],
+ ["`deck.goals.position=shelf`", "its shelf form (`deck.shelf`): the count of goals set in a column, then the notes fanned sideways like the diet's tags -- ordered by the dial's goal board (measure-goals.mjs \`goalsAt(goalBoard(schedule.measure), t)\`, so the shelf and the dial always agree): its headline -- the closest goal in force -- in front with \"+N more\" for the others in force, the rest by recency; a goal the board misses struck in red, MISSED on it, for the dial's 6 s; with no goal in force, the newest in front; a new goal landing from above as on the pile; each older one showing its goal's words in the strip beside it (all of each when there is room); a repeat comes to the front with its ×n. The fan takes the shelf's spare width (shelfLayout), up to its notes side by side. On the shelf it stays up from the first goal (`hold` unset). What the dial draws of the goal stays on the dial", "`umtool look <p> deck.shelf.items='[\"diet\",\"goals\"]' deck.goals.position=shelf`"],
["`deck.goals.max`, `.color`, `.countdown`", "1–8 notes · #hex paper · bool · default 4, the palette's amber, `true`", "`umtool look <p> deck.goals.max=6`"],
["`deck.goals.hold`, `.finale`", "0 (up from the first goal on) or 2–600 s after each · `hide` `show` · default 20, `hide`", "`umtool look <p> deck.goals.hold=0`"],
],
diff --git a/umtool/report-to-video/panel-model.mjs b/umtool/report-to-video/panel-model.mjs
@@ -19,7 +19,7 @@
// cell to THIS track's off regime, and only when it names what is
// open (offCloses: "off GLP-1" said three weeks into keto leaves
// Keto in the cell; the off-scope fix, eff32c8d).
-import { freshestReading, goalAbsolute, measureDisplay, measureQualifier, measureSchema, offCloses, plotDate } from "./measure-totals.mjs";
+import { boundAgrees, displayRange, freshestReading, goalAbsolute, measureDisplay, measureQualifier, measureSchema, offCloses, plotDate } from "./measure-totals.mjs";
/** The events that OPEN or sustain a regime segment, against those that close. */
export const OPENING = new Set(["start", "on"]);
@@ -47,6 +47,8 @@ export function offOf(schema, trackKey) {
export function nextReading(prev, row, schema) {
const at = plotDate(row);
if (!freshestReading(row, at, prev)) return prev;
+ // A bound the reading in force already satisfies (">300" at 342) leaves it as it is (boundAgrees).
+ if (row.population === "current" && boundAgrees({ value: row.value, qualifier: measureQualifier(row, schema), range: displayRange(row.display) }, prev && { ...prev, range: displayRange(prev.display) })) return prev;
return {
value: Number(row.value),
at,
diff --git a/umtool/report-to-video/shelf.test.mjs b/umtool/report-to-video/shelf.test.mjs
@@ -10,7 +10,8 @@ import path from "node:path";
import test from "node:test";
import { fileURLToPath } from "node:url";
-import { dietHtml, goalsHtml, tagWords, tagWordSize } from "./chrome-measure-extras.mjs";
+import { dietHtml, goalsHtml, shelfGoalStates, tagWords, tagWordSize } from "./chrome-measure-extras.mjs";
+import { goalBoard, goalsAt } from "./measure-goals.mjs";
import { shelfHtml, shelfNoteGeometry } from "./chrome-shelf.mjs";
import { deckGeometry, entryShelfNotes, estimateSchedule, instrumentsGeometry, parseShelfNote, validateChrome } from "./deck.mjs";
import { dietDays, dietStates, goalStates, dietTagsBox, GOALS_SHELF, goalsShelfWidth, measureExtraGeometry, measurePlacements, shelfLayout, streakStates } from "./measure-extras.mjs";
@@ -258,25 +259,30 @@ test("goals on the shelf: the count and the fanned notes, the fan taking the she
assert.match(html, /<div class="gc"><div class="gn" data-k="s0\.c">1<\/div><div class="gl">goal set<\/div><\/div>/);
assert.match(html, /class="note" data-k="s\d+\.n\d+" style="z-index:19"><div class="tape"><\/div><div class="nf"/);
assert.match(html, /<div class="nb"[^>]*><div class="bt">LOSE 100<\/div>/, "an older note shows its words beside the one in front");
- assert.equal(items.length, goalStates(schedule(), r).length);
+ // A block per state of the fan: each goal he sets, and each second the goal board alone changes (shelfGoalStates).
+ assert.equal(items.length, shelfGoalStates(schedule(), goalStates(schedule(), r)).length);
// Off the shelf: the pile in the footage, as it was.
assert.doesNotMatch(goalsHtml(schedule(), renderOf(INSTRUMENTS), { fonts: {} }).html, /class="gc"/);
});
-test("goals on the shelf: the headline goal leads when the state names one (goals.headline), with the ladder's count; else the newest", () => {
+test("goals on the shelf: the dial's goal board orders the fan -- its headline in front, +N more for the others in force", () => {
const r = renderOf(FAN);
const m = clone(MEASURE);
- // The state as the dial-ghosts lane writes it: goals an object with the headline (a goal carrying its row) and those in force.
- const firstGoal = m.events.findIndex((e) => e.kind === "goal" || e.kind === "goalLoss");
+ // Two goals in force at the end, the newer the more ambitious: the closer one leads, not the newest.
const lastGoal = m.events.map((e, i) => [e, i]).filter(([e]) => e.kind === "goal" || e.kind === "goalLoss").at(-1)[1];
- const hl = m.events[firstGoal].row;
- const s = m.state[lastGoal + 1];
- s.goals = { set: Array.isArray(s.goals) ? s.goals : [], headline: { row: hl }, active: [hl, "x", "y"] };
- const states = goalStates(schedule({ measure: m }), r);
- assert.equal(states.at(-1).headline, states[0].top, "the first goal's note heads the last state");
- assert.equal(states.at(-1).active, 3);
- const { html } = goalsHtml(schedule({ measure: m }), r, { fonts: {} });
- assert.match(html, /<div class="mo">\+2 more<\/div>/);
- // Without it, the newest leads, as before.
- assert.equal("headline" in goalStates(schedule(), r).at(-1), false);
+ const t = m.events[lastGoal].t;
+ m.events.splice(lastGoal + 1, 0, { ...m.events[lastGoal], t: t + 0.5, row: "far", kind: "goal", value: 221, display: "221", qualifier: null, deadline: null, due: null, asOf: null, range: undefined });
+ m.state.splice(lastGoal + 2, 0, { ...m.state[lastGoal + 1], t: t + 0.5 });
+ const sched = schedule({ measure: m });
+ const board = goalBoard(m);
+ const end = goalsAt(board, Infinity);
+ assert.ok(end.active.length > 1 && end.headline.row !== "far", "the fixture's last goal is closer than 221");
+ const shelf = shelfGoalStates(sched, goalStates(sched, r));
+ const last = shelf.at(-1);
+ const front = last.notes.find((n) => n.depth === 0);
+ assert.equal(front.key, last.headline, "the board's headline is in front");
+ assert.notEqual(front.key, "221 lb", "not the newest");
+ assert.equal(last.active, end.active.length);
+ const { html } = goalsHtml(sched, r, { fonts: {} });
+ assert.match(html, new RegExp(`<div class="mo">\\+${end.active.length - 1} more</div>`));
});