commit 6f46372016505887cbc4ab0902c6def11701fac0
parent 757a391cd718924fd28117bdf26ee216a8c4b3df
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Fri, 23 Oct 2026 01:34:08 -0400
report-to-video: marks -- an entry's claims: [mark, …], each its own stamp and tally step
A lone claim is a list of one and schedules byte for byte as before (a
randomized comparison with the pre-marks stampSchedule is a test). On a
segment stamping two or more marks, each with `at` lands at its own second,
those without land back to back before the out, and a stamp leaves in time to
be gone as the next comes in. validateClaims refuses claim beside claims, a
mark outside the window, and two drawn stamps on one entry closer than the
first's hold. The segment's `claim` is the first mark (the pip's verdict);
`claims` rides beside it for two or more.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
4 files changed, 453 insertions(+), 46 deletions(-)
diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs
@@ -145,7 +145,7 @@ import {
} from "./deck.mjs";
// The effects region (`render.chrome.fx`, release 35): pure, in fx.mjs.
import { fxOn, fxQuoteSpan, resolveFx, fxWhipJoins, fxWipeJoins, fxWordsOf, fxZoomJoins, validateFxEntries } from "./fx.mjs";
-import { claimOf, stampsDrawn, validateClaims } from "./factcheck.mjs";
+import { marksOf, stampsDrawn, validateClaims } from "./factcheck.mjs";
import { AUDIO_ON_CLOCK, clipAudioFilters, clipAudioOf, offsetWindow, validateClipAudioEntries } from "./clip-audio.mjs";
import { validateFinaleEntries } from "./finale.mjs";
import { SYNC_FILE, writeSyncReport } from "./sync-report.mjs";
@@ -4969,10 +4969,11 @@ export async function measureChromeSchedule({ manifest, entries, segments, D })
// claimed clip's segment really starts at, from its cut record (snapped,
// room included). Read only then.
let clipClock = null;
- if (entries.some((e) => claimOf(e)?.at !== undefined)) {
+ const timedMarks = (e) => marksOf(e).some((c) => c.at !== undefined);
+ if (entries.some(timedMarks)) {
clipClock = new Map();
for (let i = 0; i < entries.length; i += 1) {
- if (claimOf(entries[i])?.at === undefined || !segments[i]) continue;
+ if (!timedMarks(entries[i]) || !segments[i]) continue;
const rec = await readCutRecord(segments[i]).catch(() => null);
if (Number.isFinite(rec?.start)) clipClock.set(entries[i].id, rec.start);
}
diff --git a/umtool/report-to-video/clip-marks.test.mjs b/umtool/report-to-video/clip-marks.test.mjs
@@ -0,0 +1,260 @@
+// MARKS (plans/clip-marks.md): an entry's `claims: [mark, …]` -- each mark
+// its own stamp and tally step at its own `at`. A lone `claim` is a list of
+// one, and a cut whose entries carry one claim each schedules, stamps and
+// counts exactly as it did before marks.
+//
+// Run with: pnpm test:scripts
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import {
+ CLAIM_MARKS_MAX, claimOf, marksOf, normalizeMarks, rawMarksOf, resolveFactcheck, roundStamps, STAMP_MOTION,
+ stampSchedule, tallyFinals, tallySteps, validateClaims,
+} from "./factcheck.mjs";
+import { deckSchedule } from "./deck.mjs";
+import { deckCues } from "./chrome-deck.mjs";
+import { stampCues } from "./chrome-stamp.mjs";
+
+const PALETTE = { bg: "#12101a", fg: "#f4f1ea", muted: "#9a93ad", accent: "#a97bff", amber: "#ffc860" };
+const CHROME = { engine: "hyperframes", layout: "deck", deck: {} };
+const RENDER = { width: 1920, height: 1080, fps: 30, transition: 0.5, palette: PALETTE, chrome: CHROME };
+const PROV = { siteOrigin: "https://example.test", channelSlug: "demo-channel" };
+const near = (a, b, msg) => assert.ok(Math.abs(a - b) < 1e-3, `${msg}: ${a} != ${b}`);
+
+// ---- the shape ----------------------------------------------------------------
+
+test("normalizeMarks: each mark normalised; 1–8, one id once; errors named claims[k]", () => {
+ assert.deepEqual(
+ normalizeMarks([{ id: "a", verdict: "PARTLY", at: 12, count: 1 }, { id: "a.2", verdict: "CONTRADICTED", stamp: true }]),
+ [{ id: "a", verdict: "PARTLY", at: 12 }, { id: "a.2", verdict: "CONTRADICTED" }],
+ );
+ assert.throws(() => normalizeMarks([]), /at least one mark/);
+ assert.throws(() => normalizeMarks({ id: "a" }), /claims must be a list/);
+ const nine = Array.from({ length: CLAIM_MARKS_MAX + 1 }, (_, i) => ({ id: `m${i}`, verdict: "PARTLY" }));
+ assert.throws(() => normalizeMarks(nine), /9 marks \(at most 8\)/);
+ assert.throws(() => normalizeMarks([{ id: "a", verdict: "PARTLY" }, { id: "a", verdict: "PARTLY" }]), /the mark a is on this entry twice/);
+ assert.throws(() => normalizeMarks([{ id: "a", verdict: "PARTLY" }, { id: "b", verdict: "PARTLY", hold: 0.1 }]), /^Error: claims\[1\]\.hold must be from 0\.5 to 10/);
+});
+
+test("marksOf / claimOf / rawMarksOf: a lone claim is a list of one; claimOf is the first mark", () => {
+ const one = { type: "clip", id: "c", claim: { id: "k", verdict: "PARTLY" } };
+ const two = { type: "clip", id: "c", claims: [{ id: "k", verdict: "PARTLY" }, { id: "k.2", verdict: "CONTRADICTED", at: 3 }] };
+ assert.deepEqual(marksOf(one), [{ id: "k", verdict: "PARTLY" }]);
+ assert.deepEqual(marksOf(two).map((m) => m.id), ["k", "k.2"]);
+ assert.deepEqual(claimOf(two), { id: "k", verdict: "PARTLY" });
+ assert.deepEqual(marksOf({ ...two, type: "teaser" }), []);
+ assert.deepEqual(marksOf({ ...two, claim: { id: "x", verdict: "PARTLY" } }), [], "both set: none (validateClaims refuses it)");
+ assert.equal(claimOf({ type: "clip", id: "c" }), null);
+ assert.equal(rawMarksOf(two).length, 2);
+ assert.equal(rawMarksOf({ claim: null }).length, 0);
+});
+
+// ---- validation -----------------------------------------------------------------
+
+const clip = (id, start, end, extra) => ({ type: "clip", id, start, end, ...extra });
+
+test("validateClaims: claim and claims together refused; a mark's at in the window; one id, one verdict across entries", () => {
+ const both = { timeline: [clip("c1", 0, 30, { claim: { id: "k", verdict: "PARTLY" }, claims: [{ id: "k", verdict: "PARTLY" }] })] };
+ assert.match(validateClaims(both)[0], /timeline\[0\] \(c1\): claim and claims are both set/);
+ const out = { timeline: [clip("c1", 100, 130, { claims: [{ id: "a", verdict: "PARTLY", at: 101 }, { id: "b", verdict: "PARTLY", at: 131 }] })] };
+ assert.match(validateClaims(out)[0], /timeline\[0\] \(c1\)\.claims\[1\]\.at 131 is outside the clip's window 100–130/);
+ const split = {
+ timeline: [
+ clip("c1", 0, 30, { claims: [{ id: "a", verdict: "PARTLY" }, { id: "b", verdict: "CORROBORATED", at: 20 }] }),
+ clip("c2", 40, 60, { claim: { id: "b", verdict: "CONTRADICTED" } }),
+ ],
+ };
+ assert.match(validateClaims(split)[0], /timeline\[1\] \(c2\)\.claim b is CONTRADICTED here and CORROBORATED at timeline\[0\] \(c1\)/);
+ assert.match(validateClaims({ timeline: [clip("c1", 0, 30, { claims: [] })] })[0], /claims must name at least one mark/);
+ assert.match(validateClaims({ timeline: [{ type: "teaser", id: "t", claims: [{ id: "a", verdict: "PARTLY" }] }] })[0], /\.claims: a teaser is not evidence/);
+});
+
+test("validateClaims: two stamps on one entry may not overlap -- the first's hold (else stamp.seconds) before the next lands", () => {
+ const two = (a, b, extra = {}, render = RENDER) => ({
+ render,
+ timeline: [clip("c1", 100, 140, { claims: [{ id: "a", verdict: "PARTLY", at: a, ...extra }, { id: "b", verdict: "PARTLY", at: b }] })],
+ });
+ assert.deepEqual(validateClaims(two(110, 113)), [], "3 s apart: the default 3 s hold has passed");
+ const [msg] = validateClaims(two(110, 111.5));
+ assert.match(msg, /timeline\[0\] \(c1\)\.claims: the marks a \(at 110\) and b \(at 111\.5\) overlap -- a's stamp stays 3 s; land b at 113 or later, or shorten a's hold/);
+ assert.deepEqual(validateClaims(two(110, 111.5, { hold: 1.5 })), [], "a shorter hold");
+ assert.deepEqual(validateClaims(two(110, 111.5, { stamp: false })), [], "a mark that draws nothing overlaps nothing");
+ // The order written does not matter: they are taken in landing order.
+ assert.equal(validateClaims(two(111.5, 110)).length, 1);
+ // stamp.seconds is the cut's.
+ const long = { ...RENDER, chrome: { ...CHROME, factcheck: { stamp: { seconds: 5 } } } };
+ assert.equal(validateClaims(two(110, 113, {}, long)).length, 1);
+ // A mark that stamps on a later entry (its id carried on) is not drawn here.
+ const carried = {
+ render: RENDER,
+ timeline: [
+ clip("c1", 100, 140, { claims: [{ id: "a", verdict: "PARTLY", at: 110 }, { id: "b", verdict: "PARTLY", at: 111 }] }),
+ clip("c2", 200, 240, { claim: { id: "a", verdict: "PARTLY" } }),
+ ],
+ };
+ assert.deepEqual(validateClaims(carried), []);
+});
+
+// ---- the schedule -----------------------------------------------------------------
+
+// Three 10 s segments, D 0.5: starts 0, 9.5, 19; c2's source starts at 200.
+const SEGS = (marks) => [
+ { id: "c1", start: 0, duration: 10, claim: null },
+ { id: "c2", start: 9.5, duration: 10, claim: marks[0], ...(marks.length > 1 ? { claims: marks } : {}), sourceFrom: 200 },
+ { id: "c3", start: 19, duration: 10, claim: null },
+];
+const TOTAL = 29;
+
+test("stampSchedule: two marks with `at` on one clip -- each lands at its own second, each steps the tally", () => {
+ const stamps = stampSchedule({
+ segments: SEGS([{ id: "a", verdict: "CORROBORATED", at: 201 }, { id: "a.2", verdict: "CORROBORATED", at: 205, count: 2 }]),
+ D: 0.5, total: TOTAL, render: RENDER,
+ });
+ assert.deepEqual(stamps.map((s) => s.claim), ["a", "a.2"]);
+ near(stamps[0].landed, 10.5, "a: 1 s into c2");
+ near(stamps[1].landed, 14.5, "a.2: 5 s into c2");
+ near(stamps[0].out[0], stamps[0].at + 3, "a stays stamp.seconds");
+ assert.ok(stamps[0].out[1] <= stamps[1].at + 1e-9, "a is gone before a.2 comes in");
+ const steps = tallySteps(stamps);
+ assert.deepEqual(steps.map((s) => [s.verdict, s.count, s.step]), [["CORROBORATED", 1, 1], ["CORROBORATED", 3, 2]]);
+ assert.deepEqual(tallyFinals(stamps).CORROBORATED, 3);
+});
+
+test("stampSchedule: a stamp whose hold reaches the next leaves early, gone as the next comes in", () => {
+ const [a, b] = stampSchedule({
+ segments: SEGS([{ id: "a", verdict: "PARTLY", at: 201, hold: 6 }, { id: "b", verdict: "PARTLY", at: 204 }]),
+ D: 0.5, total: TOTAL, render: RENDER,
+ });
+ near(a.out[1], b.at, "a's leaving ends where b starts");
+ near(a.out[1] - a.out[0], 0.5, "over the transition's length");
+});
+
+test("stampSchedule: two marks without `at` land in order, back to back -- the last as a lone claim would", () => {
+ const [a, b] = stampSchedule({
+ segments: SEGS([{ id: "a", verdict: "PARTLY" }, { id: "b", verdict: "CONTRADICTED" }]), D: 0.5, total: TOTAL, render: RENDER,
+ });
+ const [lone] = stampSchedule({ segments: SEGS([{ id: "b", verdict: "CONTRADICTED" }]), D: 0.5, total: TOTAL, render: RENDER });
+ assert.deepEqual(b, lone, "the last: exactly a lone claim's stamp");
+ near(a.out[1], b.at, "a gone as b comes in");
+ near(a.out[0], b.at - 0.5, "a leaves over the transition's length");
+ near(a.at, a.out[0] - 3, "a stays stamp.seconds");
+ near(a.landed, a.at + STAMP_MOTION.slam, "a lands a slam after it starts");
+ assert.ok(a.landed < b.landed);
+});
+
+test("stampSchedule: a mark id carried on to a later clip stamps once, there", () => {
+ const segments = [
+ { id: "c1", start: 0, duration: 10, claim: { id: "a", verdict: "PARTLY" }, claims: [{ id: "a", verdict: "PARTLY" }, { id: "b", verdict: "PARTLY" }] },
+ { id: "c2", start: 9.5, duration: 10, claim: { id: "a", verdict: "PARTLY" } },
+ ];
+ const stamps = stampSchedule({ segments, D: 0.5, total: 19.5, render: RENDER });
+ assert.deepEqual(stamps.map((s) => [s.claim, s.segment]), [["b", "c1"], ["a", "c2"]]);
+});
+
+test("stamp cues: two stamps on one clip are two stamp elements, in landing order", () => {
+ const stamps = roundStamps(stampSchedule({
+ segments: SEGS([{ id: "a", verdict: "PARTLY", at: 201 }, { id: "b", verdict: "PARTLY", at: 205 }]), D: 0.5, total: TOTAL, render: RENDER,
+ }));
+ const { init, cues } = stampCues({ factcheck: { stamps } }, RENDER);
+ assert.ok("st0" in init && "st1" in init);
+ assert.deepEqual([...new Set(cues.filter((c) => c.k.startsWith("st")).map((c) => c.why.split(" ")[1]))], ["a", "b"]);
+});
+
+// ---- byte identity: one claim per clip is what it always was -------------------------
+
+/** stampSchedule as it was before marks (main at lane/clip-marks' base), verbatim. */
+function legacyStampSchedule({ segments, D, total, render }) {
+ const seconds = resolveFactcheck(render).stamp.seconds;
+ const last = new Map();
+ segments.forEach((s, i) => { if (s.claim) last.set(s.claim.id, i); });
+ return [...last.entries()]
+ .sort((a, b) => a[1] - b[1])
+ .map(([claim, i]) => {
+ const seg = segments[i];
+ const c = seg.claim;
+ const next = segments[i + 1];
+ const out = !next
+ ? [total - 0.3, total]
+ : D > 0 ? [next.start, next.start + D] : [next.start - 0.3, next.start];
+ const from = seg.start + (i > 0 ? D : 0);
+ const stay = c.hold ?? seconds;
+ const knobs = {
+ ...(c.count !== undefined && c.count !== 1 ? { count: c.count } : {}),
+ ...(c.stamp === false ? { stamp: false } : {}),
+ ...(c.label !== undefined ? { label: c.label } : {}),
+ };
+ if (c.at !== undefined && Number.isFinite(seg.sourceFrom)) {
+ const want = seg.start + (c.at - seg.sourceFrom);
+ const landed = Math.min(Math.max(seg.start, want), out[0]);
+ const at = Math.max(seg.start, landed - STAMP_MOTION.slam);
+ const leave = Math.min(at + stay, out[0]);
+ const own = leave < out[0] ? [leave, leave + (out[1] - out[0])] : out;
+ return { claim, verdict: c.verdict, segment: seg.id, at, landed, out: own, ...knobs };
+ }
+ const at = Math.min(Math.max(from, out[0] - stay), out[0]);
+ const landed = Math.min(at + STAMP_MOTION.slam, out[0]);
+ return { claim, verdict: c.verdict, segment: seg.id, at, landed, out, ...knobs };
+ });
+}
+
+test("stampSchedule: one claim per clip -- the stamps it always placed, byte for byte (200 random cuts)", () => {
+ let seed = 7;
+ const rand = () => ((seed = (seed * 16807) % 2147483647) / 2147483647);
+ const verdicts = ["CORROBORATED", "PARTLY", "CONTRADICTED"];
+ for (let n = 0; n < 200; n += 1) {
+ const D = rand() < 0.2 ? 0 : 0.5;
+ const count = 2 + Math.floor(rand() * 8);
+ let t = 0;
+ const segments = [];
+ for (let i = 0; i < count; i += 1) {
+ const duration = 1 + rand() * 20;
+ const sourceFrom = Math.round(rand() * 5000);
+ const claimed = rand() < 0.6;
+ const id = `k${Math.floor(rand() * 5)}`;
+ const claim = claimed
+ ? {
+ id,
+ verdict: verdicts[Number(id.slice(1)) % 3],
+ ...(rand() < 0.5 ? { at: sourceFrom + rand() * duration } : {}),
+ ...(rand() < 0.3 ? { hold: 0.5 + rand() * 5 } : {}),
+ ...(rand() < 0.2 ? { count: 2 } : {}),
+ ...(rand() < 0.2 ? { stamp: false } : {}),
+ ...(rand() < 0.2 ? { label: "X" } : {}),
+ }
+ : null;
+ segments.push({ id: `c${i}`, start: t, duration, claim, sourceFrom });
+ t += duration - (i < count - 1 ? D : 0);
+ }
+ const args = { segments, D, total: t, render: RENDER };
+ assert.equal(JSON.stringify(roundStamps(stampSchedule(args))), JSON.stringify(roundStamps(legacyStampSchedule(args))), `cut ${n}`);
+ }
+});
+
+test("deckSchedule: `claim` and `claims: [claim]` are the same schedule; a lone claim writes no `claims`", () => {
+ const c = { id: "k", verdict: "PARTLY", at: 203.4 };
+ const entries = (e2) => [{ type: "clip", id: "c1", video: "v1", start: 10, end: 20 }, { type: "clip", id: "c2", video: "v2", start: 200, end: 210, ...e2 }];
+ const one = deckSchedule({ entries: entries({ claim: c }), durs: [10, 10], D: 0.5, render: RENDER, provenance: PROV });
+ const list = deckSchedule({ entries: entries({ claims: [c] }), durs: [10, 10], D: 0.5, render: RENDER, provenance: PROV });
+ assert.equal(JSON.stringify(list), JSON.stringify(one));
+ assert.equal("claims" in one.segments[1], false);
+});
+
+test("deckSchedule: two marks on a clip -- `claim` the first (the pip's verdict), `claims` both, two stamps, the finals count both", () => {
+ const render = { ...RENDER, chrome: { ...CHROME, deck: { pip: { color: "verdict" } } } };
+ const marks = [{ id: "s1", verdict: "CORROBORATED", at: 201 }, { id: "g1", verdict: "CONTRADICTED", at: 206 }];
+ const entries = [
+ { type: "clip", id: "c1", video: "v1", start: 10, end: 20 },
+ { type: "clip", id: "c2", video: "v2", start: 200, end: 210, claims: marks },
+ { type: "clip", id: "c3", video: "v3", start: 300, end: 310, claim: { id: "s2", verdict: "CORROBORATED" } },
+ ];
+ const s = deckSchedule({ entries, durs: [10, 10, 10], D: 0.5, render, provenance: PROV, clipClock: new Map([["c2", 200]]) });
+ assert.deepEqual(s.segments[1].claim, marks[0]);
+ assert.deepEqual(s.segments[1].claims, marks);
+ assert.equal(s.segments[1].sourceFrom, 200);
+ assert.deepEqual(s.factcheck.stamps.map((x) => [x.claim, x.segment]), [["s1", "c2"], ["g1", "c2"], ["s2", "c3"]]);
+ near(s.factcheck.stamps[0].landed, 10.5, "s1");
+ near(s.factcheck.stamps[1].landed, 15.5, "g1");
+ assert.deepEqual(tallyFinals(s.factcheck.stamps), { CORROBORATED: 2, PARTLY: 0, CONTRADICTED: 1, NOT_FOUND: 0, UNTESTABLE: 0 });
+ const { pips } = deckCues(s, render);
+ assert.equal(pips.find((p) => p.id === "c2").verdict, "CORROBORATED", "a multi-mark clip's pip: its first mark's verdict");
+});
diff --git a/umtool/report-to-video/deck.mjs b/umtool/report-to-video/deck.mjs
@@ -19,7 +19,7 @@ import { COMPOSITION_PARAMS } from "yt-dlp-transcript-common/lib/report/fxParams
import { attributionParts, deckSubtitle } from "./attribution.mjs";
import {
- claimOf, originalUrlAt, resolveFactcheck, roundStamps, stampSchedule, validateFactcheck,
+ claimOf, marksOf, originalUrlAt, resolveFactcheck, roundStamps, stampSchedule, validateFactcheck,
} from "./factcheck.mjs";
import { threadOf, threadSchedule, threadsOn, validateThreads } from "./threads.mjs";
import { flipSchedule, flipsOn, validateFlips } from "./flips.mjs";
@@ -945,7 +945,7 @@ export function deckQrUrl(entry, provenance = {}, { links = DECK_DEFAULTS.qr.lin
* transition: number, total: number, multiChannel: boolean,
* segments: Array<{ id: string, type: string, start: number, duration: number,
* end: number, title: string, subtitle: string, qrUrl: string|null,
- * hideDeck: boolean, claim?: { id: string, verdict: string } }>,
+ * hideDeck: boolean, claim?: { id: string, verdict: string }, claims?: Array<{ id: string, verdict: string }> }>,
* factcheck?: { stamps: Array<{ claim: string, verdict: string, segment: string,
* at: number, landed: number, out: [number, number] }> } }}
*/
@@ -984,12 +984,15 @@ export function deckSchedule({
// A claim stamped at a source second (`claim.at`) needs the source second
// its segment starts at: the cut record's (`clipClock`), else the play
// window's estimate. Only then: a cut without `at` places what it did.
+ // An entry's marks (`claims`, two or more) ride beside its first.
const stamped = stampSchedule({
segments: segs.map((s, i) => {
- const claim = claimOf(entries[i]);
- if (claim?.at === undefined) return { ...s, claim };
+ const marks = marksOf(entries[i]);
+ const claim = marks[0] ?? null;
+ const many = marks.length > 1 ? { claims: marks } : {};
+ if (!marks.some((c) => c.at !== undefined)) return { ...s, claim, ...many };
const e = entries[i];
- return { ...s, claim, sourceFrom: clipClock?.get(e.id) ?? fxClock?.get(e.id) ?? playWindow(e, render).from };
+ return { ...s, claim, ...many, sourceFrom: clipClock?.get(e.id) ?? fxClock?.get(e.id) ?? playWindow(e, render).from };
}),
D, total, render,
});
@@ -1057,9 +1060,11 @@ export function deckSchedule({
...(dipOf(e, fps) ? { dip: dipOf(e, fps) } : {}),
// Only on an entry that carries a claim (factcheck.mjs), likewise.
...(claimOf(e) ? { claim: claimOf(e) } : {}),
+ // Its marks, only when it carries two or more (`claim` is the first).
+ ...(marksOf(e).length > 1 ? { claims: marksOf(e) } : {}),
// And on one stamped at a source second, the second its segment starts
// at -- what placed the stamp, kept for a preview to place it again.
- ...(claimOf(e)?.at !== undefined ? { sourceFrom: round(clipClock?.get(e.id) ?? fxClock?.get(e.id) ?? playWindow(e, render).from) } : {}),
+ ...(marksOf(e).some((c) => c.at !== undefined) ? { sourceFrom: round(clipClock?.get(e.id) ?? fxClock?.get(e.id) ?? playWindow(e, render).from) } : {}),
// Only on a finale clip, likewise.
...(finIds.has(e.id) ? { finale: true } : {}),
};
diff --git a/umtool/report-to-video/factcheck.mjs b/umtool/report-to-video/factcheck.mjs
@@ -8,6 +8,10 @@
// lands and the count steps), "hold" (seconds on screen),
// "stamp": false (counts, draws nothing), "count" (steps
// the tally by n), "label" (the stamp's words)
+// -- or MARKS: "claims": [ { "id": "k3", "verdict": … }, … ]
+// (2–8; each its own stamp and tally step at its own
+// `at`, with its own knobs). A lone `claim` is a list of
+// one, and the writers keep writing `claim` for one mark.
// render.chrome: "factcheck": { "verdicts": { "PARTLY": { "label": "Half true", "stampLabel": "Half" } },
// "stamp": { "show": true, "seconds": 3, "position": "top-left",
// "scale": 1, "motion": "slam", "opacity": 1 },
@@ -80,6 +84,9 @@ export const CLAIM_LIMITS = Object.freeze({ hold: Object.freeze([0.5, 10]), coun
/** The keys a `claim` may carry. */
export const CLAIM_KEYS = Object.freeze(["id", "verdict", "at", "hold", "stamp", "count", "label"]);
+/** The most marks (`claims`) one entry may carry. */
+export const CLAIM_MARKS_MAX = 8;
+
/**
* The stamp's motion, in seconds: it slams in over `slam` (landing is when the
* tally steps), flashes up over `flashUp` and down over `flashDown`; the
@@ -235,17 +242,69 @@ export function claimKnobs(claim) {
return knobs;
}
-/** An entry's claim when it carries a sound one, else null. Never throws. */
-export function claimOf(entry) {
- if (!entry || entry.type === "teaser") return null;
+/**
+ * An entry's marks as written: its `claims` list, else its lone `claim` as a
+ * list of one, else none. Not normalised (marksOf is).
+ *
+ * @returns {unknown[]}
+ */
+export function rawMarksOf(entry) {
+ if (!isObj(entry)) return [];
+ if (Array.isArray(entry.claims)) return entry.claims;
+ return entry.claim === undefined || entry.claim === null ? [] : [entry.claim];
+}
+
+/**
+ * A `claims` value, normalised: each mark through normalizeClaim (its errors
+ * named `claims[k].…`), 1 to CLAIM_MARKS_MAX of them, each id once. Throws a
+ * sentence on a shape no writer should store.
+ *
+ * @returns {Array<NonNullable<ReturnType<typeof normalizeClaim>>>}
+ */
+export function normalizeMarks(v) {
+ if (!Array.isArray(v)) throw new Error("claims must be a list of marks [{ id, verdict, … }]");
+ if (!v.length) throw new Error("claims must name at least one mark (remove the key for none)");
+ if (v.length > CLAIM_MARKS_MAX) throw new Error(`claims holds ${v.length} marks (at most ${CLAIM_MARKS_MAX})`);
+ const seen = new Set();
+ return v.map((m, k) => {
+ let c;
+ try {
+ c = normalizeClaim(m);
+ } catch (err) {
+ throw new Error(String(err.message).replace(/^claim\b/, `claims[${k}]`));
+ }
+ if (!c) throw new Error(`claims[${k}] must be { id, verdict }`);
+ if (seen.has(c.id)) throw new Error(`claims[${k}]: the mark ${c.id} is on this entry twice -- one mark, one id`);
+ seen.add(c.id);
+ return c;
+ });
+}
+
+/**
+ * An entry's MARKS, normalised: each `{ id, verdict, …knobs }`, in the order
+ * written. None on a teaser, or on a shape that does not normalise. Never
+ * throws.
+ */
+export function marksOf(entry) {
+ if (!isObj(entry) || entry.type === "teaser") return [];
try {
- return normalizeClaim(entry.claim);
+ if (Array.isArray(entry.claims)) return entry.claim === undefined || entry.claim === null ? normalizeMarks(entry.claims) : [];
+ const c = normalizeClaim(entry.claim);
+ return c ? [c] : [];
} catch {
- return null;
+ return [];
}
}
/**
+ * An entry's claim when it carries a sound one, else null: its FIRST mark --
+ * the one its pip and rail take their verdict's colour from. Never throws.
+ */
+export function claimOf(entry) {
+ return marksOf(entry)[0] ?? null;
+}
+
+/**
* Every `claim` in the timeline, checked: its shape, that it is not on a
* teaser (a full-frame finale is no evidence), and that every entry naming a
* claim id names the same verdict. The build refuses with these before it
@@ -256,25 +315,60 @@ export function claimOf(entry) {
export function validateClaims(manifest) {
const errors = [];
const verdictOf = new Map();
- (manifest?.timeline ?? []).forEach((e, i) => {
- if (e?.claim === undefined || e?.claim === null) return;
+ const timeline = Array.isArray(manifest?.timeline) ? manifest.timeline : [];
+ // The last entry carrying each id: a mark stamps there, and only there.
+ const lastOf = new Map();
+ timeline.forEach((e, i) => {
+ for (const m of rawMarksOf(e)) if (isObj(m) && typeof m.id === "string") lastOf.set(m.id.trim(), i);
+ });
+ timeline.forEach((e, i) => {
+ const many = Array.isArray(e?.claims);
+ const one = e?.claim !== undefined && e?.claim !== null;
+ if (!many && !one) return;
const where = `timeline[${i}] (${e.id ?? "?"})`;
- if (e.type === "teaser") { errors.push(`${where}.claim: a teaser is not evidence for a claim`); return; }
- let c;
+ const key = many ? "claims" : "claim";
+ if (many && one) { errors.push(`${where}: claim and claims are both set -- one mark is \`claim\`, two or more \`claims\``); return; }
+ if (e.type === "teaser") { errors.push(`${where}.${key}: a teaser is not evidence for a claim`); return; }
+ let marks;
try {
- c = normalizeClaim(e.claim);
+ marks = many ? normalizeMarks(e.claims) : [normalizeClaim(e.claim)];
} catch (err) {
errors.push(`${where}.${err.message}`);
return;
}
- // `at` is the entry's own clock: a second of the source inside its window.
- if (c.at !== undefined && Number.isFinite(e.start) && Number.isFinite(e.end) && (c.at < e.start || c.at > e.end)) {
- errors.push(`${where}.claim.at ${c.at} is outside the clip's window ${e.start}–${e.end} (source seconds)`);
+ marks.forEach((c, k) => {
+ const name = many ? `claims[${k}]` : "claim";
+ // `at` is the entry's own clock: a second of the source inside its window.
+ if (c.at !== undefined && Number.isFinite(e.start) && Number.isFinite(e.end) && (c.at < e.start || c.at > e.end)) {
+ errors.push(`${where}.${name}.at ${c.at} is outside the clip's window ${e.start}–${e.end} (source seconds)`);
+ }
+ const seen = verdictOf.get(c.id);
+ if (seen && seen.verdict !== c.verdict) {
+ errors.push(`${where}.${name} ${c.id} is ${c.verdict} here and ${seen.verdict} at ${seen.where} -- one claim, one verdict`);
+ } else if (!seen) verdictOf.set(c.id, { verdict: c.verdict, where });
+ });
+ // Marks stamped on one entry at their own seconds: one's stamp must have
+ // stayed its hold before the next lands. (Marks without `at` are laid back
+ // to back by the schedule; a mark that stamps on a later entry, or draws
+ // nothing, is not drawn here.)
+ if (marks.length > 1) {
+ const hold = resolveFactcheck(manifest?.render).stamp.seconds;
+ const timed = marks
+ .filter((c) => c.at !== undefined && c.stamp !== false && lastOf.get(c.id) === i)
+ .sort((a, b) => a.at - b.at);
+ for (let k = 1; k < timed.length; k += 1) {
+ const a = timed[k - 1];
+ const b = timed[k];
+ const stay = a.hold ?? hold;
+ if (b.at - a.at < stay - 1e-9) {
+ const free = Math.round((a.at + stay) * 100) / 100;
+ errors.push(
+ `${where}.claims: the marks ${a.id} (at ${a.at}) and ${b.id} (at ${b.at}) overlap -- ${a.id}'s stamp stays ${stay} s; ` +
+ `land ${b.id} at ${free} or later, or shorten ${a.id}'s hold`,
+ );
+ }
+ }
}
- const seen = verdictOf.get(c.id);
- if (seen && seen.verdict !== c.verdict) {
- errors.push(`${where}.claim ${c.id} is ${c.verdict} here and ${seen.verdict} at ${seen.where} -- one claim, one verdict`);
- } else if (!seen) verdictOf.set(c.id, { verdict: c.verdict, where });
});
return errors;
}
@@ -307,45 +401,92 @@ export function validateClaims(manifest) {
* tally's step), `stamp: false` (counted, not drawn), `label` (the stamp's
* words). A claim without knobs stamps exactly as it always did.
*
+ * MARKS (a segment's `claims`, two or more): each mark is its own stamp and
+ * tally step, stamped on the last segment carrying its id. On a segment that
+ * stamps two or more, each mark with `at` lands as above; those without land
+ * in order, back to back, the last as a lone claim would (the one before
+ * leaving as the next comes in); and, in landing order, a stamp leaves in
+ * time to be gone as the next one starts. A segment stamping one mark places
+ * it exactly as a lone claim.
+ *
* `segments` are the schedule's, in order, each `{ id, start, duration,
- * claim?, sourceFrom? }` (`claim` as `claimOf` gives it).
+ * claim?, claims?, sourceFrom? }` (`claim` as `claimOf` gives it, `claims`
+ * as `marksOf`; `claims` wins when both are set).
*
* @returns {Array<{ claim: string, verdict: string, segment: string, at: number,
* landed: number, out: [number, number], count?: number, stamp?: false, label?: string }>}
*/
export function stampSchedule({ segments, D, total, render }) {
const seconds = resolveFactcheck(render).stamp.seconds;
+ const marksAt = (s) => (Array.isArray(s.claims) && s.claims.length ? s.claims : s.claim ? [s.claim] : []);
+ // Each mark id's last segment: where it stamps.
const last = new Map();
- segments.forEach((s, i) => { if (s.claim) last.set(s.claim.id, i); });
- return [...last.entries()]
- .sort((a, b) => a[1] - b[1])
- .map(([claim, i]) => {
+ segments.forEach((s, i) => { for (const c of marksAt(s)) last.set(c.id, i); });
+ const bySegment = new Map();
+ for (const [id, i] of last) {
+ if (!bySegment.has(i)) bySegment.set(i, []);
+ bySegment.get(i).push(marksAt(segments[i]).find((c) => c.id === id));
+ }
+ const knobsOf = (c) => ({
+ ...(c.count !== undefined && c.count !== 1 ? { count: c.count } : {}),
+ ...(c.stamp === false ? { stamp: false } : {}),
+ ...(c.label !== undefined ? { label: c.label } : {}),
+ });
+ return [...bySegment.entries()]
+ .sort((a, b) => a[0] - b[0])
+ .flatMap(([i, marks]) => {
const seg = segments[i];
- const c = seg.claim;
const next = segments[i + 1];
const out = !next
? [total - 0.3, total]
: D > 0 ? [next.start, next.start + D] : [next.start - 0.3, next.start];
const from = seg.start + (i > 0 ? D : 0);
- const stay = c.hold ?? seconds;
- const knobs = {
- ...(c.count !== undefined && c.count !== 1 ? { count: c.count } : {}),
- ...(c.stamp === false ? { stamp: false } : {}),
- ...(c.label !== undefined ? { label: c.label } : {}),
- };
- if (c.at !== undefined && Number.isFinite(seg.sourceFrom)) {
- // The cut's second the source's `at` plays at, inside the segment
- // and before its stamp has to leave.
+ const leaving = out[1] - out[0];
+ // A mark at its source second: the cut's second the source's `at`
+ // plays at, inside the segment and before its stamp has to leave.
+ const timed = (c) => {
+ const stay = c.hold ?? seconds;
const want = seg.start + (c.at - seg.sourceFrom);
const landed = Math.min(Math.max(seg.start, want), out[0]);
const at = Math.max(seg.start, landed - STAMP_MOTION.slam);
const leave = Math.min(at + stay, out[0]);
- const own = leave < out[0] ? [leave, leave + (out[1] - out[0])] : out;
- return { claim, verdict: c.verdict, segment: seg.id, at, landed, out: own, ...knobs };
+ const own = leave < out[0] ? [leave, leave + leaving] : out;
+ return { claim: c.id, verdict: c.verdict, segment: seg.id, at, landed, out: own, ...knobsOf(c) };
+ };
+ const isTimed = (c) => c.at !== undefined && Number.isFinite(seg.sourceFrom);
+ if (marks.length === 1) {
+ const c = marks[0];
+ if (isTimed(c)) return [timed(c)];
+ const stay = c.hold ?? seconds;
+ const at = Math.min(Math.max(from, out[0] - stay), out[0]);
+ const landed = Math.min(at + STAMP_MOTION.slam, out[0]);
+ return [{ claim: c.id, verdict: c.verdict, segment: seg.id, at, landed, out, ...knobsOf(c) }];
+ }
+ // Two or more on this segment. The untimed, back to back from the
+ // segment's out: the last as a lone claim, each before it gone as the
+ // one after comes in.
+ const placed = new Map();
+ let until = null; // when the stamp after this one comes in
+ for (const c of marks.filter((m) => !isTimed(m)).reverse()) {
+ const stay = c.hold ?? seconds;
+ const own = until === null ? out : [Math.max(from, until - leaving), Math.max(from, until - leaving) + leaving];
+ const at = Math.min(Math.max(from, own[0] - stay), own[0]);
+ const landed = Math.min(at + STAMP_MOTION.slam, own[0]);
+ placed.set(c.id, { claim: c.id, verdict: c.verdict, segment: seg.id, at, landed, out: own, ...knobsOf(c) });
+ until = at;
+ }
+ for (const c of marks) if (isTimed(c)) placed.set(c.id, timed(c));
+ // In landing order, each drawn stamp gone by the time the next drawn one starts.
+ const stamps = marks.map((c) => placed.get(c.id)).sort((a, b) => a.at - b.at || a.landed - b.landed);
+ const drawn = stamps.filter((s) => s.stamp !== false);
+ for (let k = 0; k + 1 < drawn.length; k += 1) {
+ const s = drawn[k];
+ const nextAt = drawn[k + 1].at;
+ if (s.out[1] <= nextAt) continue;
+ const go = Math.max(s.landed, nextAt - leaving);
+ s.out = [go, Math.max(go, Math.min(go + leaving, nextAt))];
}
- const at = Math.min(Math.max(from, out[0] - stay), out[0]);
- const landed = Math.min(at + STAMP_MOTION.slam, out[0]);
- return { claim, verdict: c.verdict, segment: seg.id, at, landed, out, ...knobs };
+ return stamps;
});
}