Archilyzer · Source

archilyzer

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

commit 8491dd04fff13964b7f58fa501cbdb0cbc0a82e2
parent fbb239a7b170a1b39e81fa22828f5171f8754c4e
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon, 26 Oct 2026 22:14:13 -0400

Merge lane/inbox-fixes: check reads a clip with its own media; window-overlap judged on what plays; umtool link <project> <site>/<report>

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mumtool/bin/umtool.mjs | 44++++++++++++++++++++++++++++++++++++++++++--
Mumtool/docs/cli.md | 16++++++++++++++++
Mumtool/lib/projects/report.mjs | 35++++++++++++++++++++++++++++++-----
Aumtool/lib/report/article-link.test.mjs | 46++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/lib/report/local-media-clip.test.mjs | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/report/manifest.mjs | 40++++++++++++++++++++++++++++++++++++++++
Aumtool/lib/report/window-overlap.test.mjs | 109+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 341 insertions(+), 7 deletions(-)

diff --git a/umtool/bin/umtool.mjs b/umtool/bin/umtool.mjs @@ -98,7 +98,7 @@ import { createSnapshot, listSnapshots, readSnapshot } from "../lib/report/snaps import { diffManifests, formatChange } from "../lib/report/manifest-diff.mjs"; import { EXPORT_FORMATS, exportProject } from "../lib/report/export.mjs"; import path from "node:path"; -import { updateClip, updateStorage } from "../lib/report/manifest.mjs"; +import { updateArticleLink, updateClip, updateStorage } from "../lib/report/manifest.mjs"; import { withEditNotes } from "../lib/report/edit-guard.mjs"; import { hms } from "umtool-report-to-video/attribution"; import { buildSteps, checkSourcesSteps, PRESETS } from "../lib/report/driver.mjs"; @@ -106,13 +106,14 @@ import { sourceCountOf } from "umtool-report-to-video/manifest-sources"; import { runBuildOverHttp, umtoolBase } from "../lib/report/buildRun.mjs"; import { CHAIN_STEP_NAMES, chainStepsOf, planChain } from "../lib/report/chain.mjs"; import { spawn } from "node:child_process"; +import { stat } from "node:fs/promises"; import { openIndex, signRecord } from "../lib/projects/index-db.mjs"; import { pipelineProcessesFor } from "../lib/report/busy.mjs"; import { probeTools } from "../lib/tools.mjs"; import { notesCommand } from "../lib/annotations/cli.mjs"; import { scaffoldReportVideo } from "../lib/projects/scaffold.mjs"; import { rootsReport } from "../lib/system/roots.mjs"; -import { ARTICLES_DIR, MEDIA_ROOT, MEDIA_TIERED } from "../lib/paths.mjs"; +import { ARTICLES_DIR, ARTICLES_KEY, MEDIA_ROOT, MEDIA_TIERED, SITES_DIR } from "../lib/paths.mjs"; import { deliverablesState, moveDeliverables, @@ -713,6 +714,8 @@ function usage() { " a schedule is written through the editor: `pnpm ops report-schedule`)", " umtool folders [--json]", " umtool kinds [--json]", + " umtool link <project> <site>/<report> | --clear [--json] the manifest names its article (a top-level", + " `article`): what settles link-ambiguous; noted for the generator on a generated manifest", " umtool window <project> <clip> [--start S] [--end E] [--lock|--lock-end|…]", " attribution too: --title, --date YYYY-MM-DD, --cite, --cite-url, --quote", " --correction TEXT what the REPORT got wrong here (never rendered)", @@ -819,6 +822,7 @@ function usage() { const COMMANDS = { ls: cmdLs, window: cmdWindow, + link: cmdLink, // The video knobs (plans/video-knobs-ui.md): lib/report/knobsCli.mjs. set: async () => process.exit(await (await import("../lib/report/knobsCli.mjs")).setCommand(argv.slice(argv.indexOf("set") + 1))), look: async () => process.exit(await (await import("../lib/report/knobsCli.mjs")).lookCommand(argv.slice(argv.indexOf("look") + 1))), @@ -1005,6 +1009,42 @@ async function cmdWindow() { } } +// `umtool link <project> <site>/<report>`: the manifest names the article it is +// the video of (lib/articles/links.mjs, the second way). Through the writer the +// app would use (lib/report/manifest.mjs updateArticleLink: the lock, the +// snapshot, the CLI's formatting) and the same edit guard as `window`. +async function cmdLink() { + const p = await pick(positional[0]); + const clear = has("--clear"); + const article = clear ? null : positional[1]; + if (!clear && !article) die("which article? `umtool link <project> <site>/<report>` (or --clear)"); + // A link to an article that is not there links nothing. Said, not refused: + // the article may be on its way (a site's report is written by the editor). + let missing = false; + if (article) { + const [site, report] = String(article).split("/"); + const dir = + site === ARTICLES_KEY ? path.join(ARTICLES_DIR, report ?? "") : path.join(SITES_DIR, site ?? "", "reports", report ?? ""); + missing = !(await stat(dir).then((st) => st.isDirectory(), () => false)); + } + try { + const { result: res, editNotes } = await withEditNotes(p, () => updateArticleLink(p.dir, article)); + if (json) return out({ ok: true, project: p.id, ...res, missing, editNotes }); + if (!res.changed) console.log(`${p.id}: already ${res.article ? `linked to ${res.article}` : "unlinked"} — nothing written`); + else console.log(`${p.id}: article ${res.was ?? "(none)"} -> ${res.article ?? "(none)"}`); + if (missing) console.log(` no article at ${article} yet — the link waits for it`); + if (editNotes && (editNotes.added || editNotes.updated || editNotes.errors.length)) { + console.log( + editNotes.errors.length + ? ` edit NOT noted (${editNotes.errors.join("; ")}) — ${editNotes.generatedBy} will overwrite it on the next rebuild` + : ` edit noted for ${editNotes.generatedBy} — port it into the generator's inputs, or its next rebuild drops it`, + ); + } + } catch (e) { + die(e?.message ?? String(e)); + } +} + // What the REPORT got wrong, collected for the next pass. // // Markdown, and the moment link is the QR's own target -- so a bullet can be diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -23,6 +23,7 @@ Inbox cannot disagree about what is wrong with one. | `inbox [--all] [--json]` | the decisions grouped and ranked by piece (`a:<site>/<report>`, `p:<project>`): Your call, Review, Blocking, Notes, Open, Ready to finish, Quiet — one card per piece and kind, and how many sit hidden on parked or done pieces (`--all` lists them). Every decision, songs' and articles' included; runs `bin/inbox.ts` through tsx | | `folders [--json]` · `kinds [--json]` | the tree, the registry | | `window <project> <clip> [--start S] [--end E] [--lock] [--lock-end] [--no-lock-end] [--note …]` | edit a window | +| `link <project> <site>/<report>` · `link <project> --clear` | the manifest names the article it is the video of (settles `link-ambiguous`) | | `set <project> <clip> key=value …` | a clip's **knobs**: `claim.at` `claim.hold` `claim.stamp` `claim.count` `claim.label` (the first mark's, or `--mark <id>`'s), its **marks** `mark.add=<verdict>[@<sec>]` `mark.remove=<id>` `mark.verdict=<verdict>` `marks=<json>`, `audio.offset` `audio.gain` `audio.fadeIn` `audio.fadeOut`, its picture's **blur** `blur.on=true` `blur.caption=…` `blur.strength` `blur.from` `blur.to` (`blur.on=` clears it; [knobs.md](knobs.md#a-clips-picture-blurred)); `key=` clears one ([knobs.md](knobs.md#marks)) | | `look <project> key=value …` | the cut's **knobs**: `factcheck.stamp.*`, `factcheck.verdicts.<V>.stampLabel\|label\|color`, `deck.markers=<json>`, `deck.markerLayout`, `variants=<json>`, and the look's keys ([knobs.md](knobs.md)) | | `variants <project> [--take <t>] [--list] [--json]` | **Make variants**: the encode ladder of the build (or of a take's); `--list` what was made and the build's sync report, each clip's lag (past a frame flagged) ([knobs.md](knobs.md)) | @@ -138,6 +139,21 @@ c01: 43.12–61.48 -> 43.12–61.48 `--no-lock-end` **removes** the key rather than writing `false`: these manifests are read by humans, and `"lockEnd": false` reads like a decision. +## `link` names the article a project is the video of + +An article links to a project its iterations made, to one whose manifest names it +(a top-level `"article": "<site>/<report>"`), or to the ONE project sharing its slug. +Two sharing it (a piece's takes, with no project manifest above them) link to neither, +and the inbox says `link-ambiguous`. `umtool link` writes that key through +`updateArticleLink` (the lock, an `auto-before-link` snapshot, the CLI's formatting) and +the same edit guard as `window`; `--clear` removes it: + +``` +$ umtool link candace/polemic-flips/takes/flips articles/polemic-flips +candace/polemic-flips/takes/flips: article (none) -> articles/polemic-flips + edit noted for polemics/video/make-videos.py — port it into the generator's inputs, or its next rebuild drops it +``` + ## `show` lists the sources and the snapshots One row per distinct `(channel, video)`: which clips use it, whether its cue diff --git a/umtool/lib/projects/report.mjs b/umtool/lib/projects/report.mjs @@ -38,6 +38,7 @@ const segmentDirs = (outDir) => [ ]; import { adjudicationGaps, ledgerTotals, unadjudicatedOf } from "umtool-report-to-video/ledger-totals"; import { widen } from "umtool-report-to-video/resolve-windows"; +import { montageOn } from "umtool-report-to-video/montage"; import { fileSig, pathCache } from "../pathCache.mjs"; // widen() and the cache's window naming are IMPORTED, never reimplemented. The @@ -541,7 +542,9 @@ export async function noCuesFix(m, e, file) { export const cuePathFor = (m, e, channelsDir) => { const chan = channelFor(m, e); - if (!chan) return null; + // A clip with its own media (`src`, `cues`) names no corpus video: there is + // no cue file to find, and path.join(undefined) would throw. + if (!chan || e.video == null) return null; // The record's directory: a Twitch v<n> is data/<n>/ (release 23 F1b). return path.join(resolveVideoDirSync(channelsDir ?? GLOBAL_CHANNELS_DIR(), chan, e.video), "transcript.cues.json"); }; @@ -761,6 +764,9 @@ export async function sourcesOf(dir, { manifest = null } = {}) { const byKey = new Map(); for (const e of clipsOf(m)) { + // A clip with its own media (`src`, `cues`) is not a corpus source: the + // decisions skip it for the same reason (the build checks its paths). + if (e.src != null) continue; const chan = channelFor(m, e); const key = `${chan}/${e.video}`; if (!byKey.has(key)) byKey.set(key, { chan, video: e.video, clips: [] }); @@ -834,7 +840,7 @@ export async function summariseReport(ctx) { const build = await buildStateOf(dir, m); const runtime = clips.reduce((n, e) => n + Math.max(0, (e.end ?? 0) - (e.start ?? 0)), 0); - const sources = new Set(clips.map((e) => `${channelFor(m, e)}/${e.video}`)).size; + const sources = new Set(clips.map((e) => (e.src != null ? `src:${e.src}` : `${channelFor(m, e)}/${e.video}`))).size; const locked = clips.filter((e) => e.lock).length; // The source facts the dashboard's Sources panel and /browse read. The cue @@ -1177,15 +1183,34 @@ export async function reportDecisions(ctx, summary) { // Two clips from one source that overlap play as the same footage twice. // resolve-windows de-overlaps them -- unless the earlier one has lockEnd, // where it warns and refuses. That refusal is the decision. - const sorted = [...list].sort((a, b) => a.start - b.start); + // + // Judged on what PLAYS: a clip's cut when it has the pair (the build + // honours the pair or neither), else its extent. Two extents that overlap + // while their cuts do not repeat nothing (quartering-slow-news s51/s52). + // + // And not a crossfade SEAM: the next clip in the timeline starting no more + // than one transition before this one ends is the fade laying the same + // seconds over themselves, which plays as one take -- the overlap is what + // makes it continuous (make-videos.py's unoverlap() writes exactly that; + // 21 of 25 overlaps on the shelf were these). A montage joins hard cuts. + const D = montageOn(m.render ?? {}) ? 0 : Number(m.render?.transition ?? 0.5) || 0; + const timelineIndex = new Map((m.timeline ?? []).map((t, i) => [t, i])); + const played = (e) => + Number.isFinite(Number(e.cutStart)) && Number.isFinite(Number(e.cutEnd)) + ? { from: Number(e.cutStart), to: Number(e.cutEnd) } + : { from: e.start, to: e.end }; + const sorted = [...list].sort((a, b) => played(a).from - played(b).from); for (let i = 0; i < sorted.length - 1; i += 1) { const a = sorted[i]; const b = sorted[i + 1]; - if (a.end <= b.start) continue; + const overlap = played(a).to - played(b).from; + if (overlap <= 0) continue; + const seam = timelineIndex.get(b) === timelineIndex.get(a) + 1 && overlap <= D + 0.01; + if (seam) continue; add( "window-overlap", a.id, - `overlaps ${b.id} by ${(a.end - b.start).toFixed(1)}s` + + `overlaps ${b.id} by ${overlap.toFixed(1)}s` + (a.lockEnd ? " and has lockEnd, so nothing will trim it" : ""), a.lockEnd ? "open" : "info", { href: clipHref(a.id) }, diff --git a/umtool/lib/report/article-link.test.mjs b/umtool/lib/report/article-link.test.mjs @@ -0,0 +1,46 @@ +// updateArticleLink: the writer behind `umtool link`, the only way to settle a +// link-ambiguous article (two projects share its slug) without a hand edit. +// +// Run with: pnpm test:scripts +import assert from "node:assert/strict"; +import { mkdir, mkdtemp, readdir, readFile, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import test from "node:test"; + +import { updateArticleLink } from "./manifest.mjs"; + +test("names the article, is a no-op when it already does, clears, and refuses a bad id", async () => { + const dir = await mkdtemp(path.join(tmpdir(), "article-link-")); + try { + await mkdir(dir, { recursive: true }); + const file = path.join(dir, "video.manifest.json"); + const manifest = { schemaVersion: 1, slug: "polemic-flips", title: "T", timeline: [{ type: "clip", id: "a", video: "v", start: 1, end: 2 }] }; + await writeFile(file, JSON.stringify(manifest, null, 2) + "\n"); + + const r1 = await updateArticleLink(dir, "articles/polemic-flips"); + assert.equal(r1.changed, true); + assert.equal(r1.was, null); + const after = JSON.parse(await readFile(file, "utf8")); + assert.equal(after.article, "articles/polemic-flips"); + assert.deepEqual(after.timeline, manifest.timeline, "nothing else moves"); + // The CLI's formatting (indent 2, trailing newline), so the diff is one line. + assert.match(await readFile(file, "utf8"), /\n {2}"article": "articles\/polemic-flips"\n\}\n$/); + // Snapshotted first. + assert.ok((await readdir(path.join(dir, "revisions"))).some((f) => f.includes("auto-before-link"))); + + const r2 = await updateArticleLink(dir, "articles/polemic-flips"); + assert.equal(r2.changed, false); + + await assert.rejects(updateArticleLink(dir, "polemic-flips"), /<site>\/<report>/); + await assert.rejects(updateArticleLink(dir, "articles/Polemic Flips"), /<site>\/<report>/); + await assert.rejects(updateArticleLink(dir, "../x/y"), /<site>\/<report>/); + + const r3 = await updateArticleLink(dir, null); + assert.equal(r3.changed, true); + assert.equal(r3.was, "articles/polemic-flips"); + assert.equal("article" in JSON.parse(await readFile(file, "utf8")), false); + } finally { + await rm(dir, { recursive: true, force: true }); + } +}); diff --git a/umtool/lib/report/local-media-clip.test.mjs b/umtool/lib/report/local-media-clip.test.mjs @@ -0,0 +1,58 @@ +// A clip with its own media (`src` + `cues`, no `video`) is a supported shape +// (report-to-video/local-media.mjs). The checker used to send its undefined +// `video` into path.join() through sourcesOf -> cuePathFor, so `umtool check` +// reported the WHOLE project as "unreadable" (blocking) and every other +// decision on it was lost -- candace/video, 6 of 142 clips local. +// +// Run with: pnpm test:scripts +import assert from "node:assert/strict"; +import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import test from "node:test"; + +import { decisionsFor, summarise } from "../projects/core.mjs"; +import { cuePathFor, readClipDetail, sourcesOf } from "../projects/report.mjs"; +import { walkProjects } from "../projects/walk.mjs"; + +test("a local-media clip does not make the project unreadable, and is not a corpus source", async () => { + const root = await mkdtemp(path.join(tmpdir(), "local-media-clip-")); + try { + const channelsDir = path.join(root, "channels"); + const reportsRoot = path.join(root, "reports"); + await mkdir(path.join(channelsDir, "chan", "data", "here"), { recursive: true }); + const dir = path.join(reportsRoot, "cut"); + await mkdir(path.join(dir, "clips"), { recursive: true }); + await writeFile(path.join(dir, "clips", "local.mp4"), ""); + await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify({ + schemaVersion: 1, slug: "cut", title: "Cut", + provenance: { channelSlug: "chan", channelsDir: path.relative(dir, channelsDir), siteOrigin: "https://example.test" }, + render: { width: 1920, height: 1080, fps: 30, transition: 0.5 }, + timeline: [ + { type: "clip", id: "a", video: "here", start: 10, end: 20, cite: 10 }, + { type: "clip", id: "b", src: "clips/local.mp4", cues: "clips/local.transcript.json", start: 0, end: 5, cite: 0 }, + ], + }, null, 2)); + const [ref] = (await walkProjects(reportsRoot)).filter((p) => p.id === "cut"); + + const ds = await decisionsFor(ref, reportsRoot); + assert.deepEqual(ds.filter((d) => d.kind === "unreadable"), [], "the project reads"); + // The corpus clip is still checked: its cue file is missing. + assert.ok(ds.some((d) => d.kind === "clip-no-cues" && d.target === "chan/here")); + assert.ok(!ds.some((d) => String(d.target).includes("undefined")), "nothing names chan/undefined"); + + const card = await summarise(ref, reportsRoot); + assert.ok(!card.flags.some((f) => /could not be read/.test(f)), card.flags.join("; ")); + + const src = await sourcesOf(dir); + assert.deepEqual(src.rows.map((r) => r.key), ["chan/here"], "the local clip is not a corpus source row"); + + assert.equal(cuePathFor({ provenance: { channelSlug: "chan" } }, { src: "clips/local.mp4" }, channelsDir), null); + + // The project page's clip rows read too. + const detail = await readClipDetail(dir); + assert.ok(detail, "the clip detail reads"); + } finally { + await rm(root, { recursive: true, force: true }); + } +}); diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs @@ -1301,6 +1301,46 @@ export async function updateStorage(dir, { deliverables } = {}, { token = null } } +/** + * The manifest's article link: a top-level `"article": "<site>/<report>"` + * (lib/articles/links.mjs, the second way -- the one a person or an agent + * chooses). It is what settles `link-ambiguous`: an article two projects share + * a slug with links to neither until one of them names it, and nothing wrote + * the key but a hand edit. The build never reads it. + * + * `null` (or "") removes it. Snapshotted first (`auto-before-link`); a no-op + * writes nothing. + * + * @param {string} dir + * @param {string | null} article `<site>/<report>`, e.g. `articles/polemic-flips` + * @param {{ token?: string | null }} [opts] + * @returns {Promise<{ article: string | null, was: string | null, token: string | null, changed: boolean, snapshot?: unknown }>} + */ +export async function updateArticleLink(dir, article, { token = null } = {}) { + const next = article == null || String(article).trim() === "" ? null : String(article).trim(); + if (next !== null) { + const parts = next.split("/"); + if (parts.length !== 2 || !parts.every((x) => ARTICLE_SEGMENT_RE.test(x))) { + throw new Error(`an article is <site>/<report> (e.g. articles/polemic-flips), not ${JSON.stringify(article)}`); + } + } + return withManifestLock(async () => { + const current = await manifestToken(dir); + if (token !== null && current !== token) throw new StaleToken(token, current); + const manifest = JSON.parse(await readFile(manifestFile(dir), "utf8")); + const was = typeof manifest.article === "string" ? manifest.article : null; + if (was === next) return { article: was, was, token: current, changed: false }; + const snapshot = await autoSnapshot(dir, "link"); + if (next === null) delete manifest.article; + else manifest.article = next; + const nextToken = await writeManifestAtomic(dir, manifest); + return { article: next, was, token: nextToken, changed: true, snapshot }; + }); +} +/** A site id or a report id: lib/paths.mjs SEGMENT_RE, which this file does not import. */ +const ARTICLE_SEGMENT_RE = /^[a-z0-9][a-z0-9-]{0,63}$/; + + // --------------------------------------------------------------------------- // STRUCTURE: re-ordering the cut, and the edits that add or remove a thing. // diff --git a/umtool/lib/report/window-overlap.test.mjs b/umtool/lib/report/window-overlap.test.mjs @@ -0,0 +1,109 @@ +// `window-overlap` is about footage that PLAYS twice. Two shapes on the shelf +// overlapped on paper and repeated nothing, and made 22 of its 25 cards: +// +// - a crossfade seam: the next clip in the timeline starts one transition +// before this one ends, so the fade lays the same seconds over themselves +// (make-videos.py's unoverlap(), every hasan-leads polemic); +// - two extents that overlap while the cuts that play do not +// (quartering-slow-news s51/s52). +// +// Run with: pnpm test:scripts +import assert from "node:assert/strict"; +import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import test from "node:test"; + +import { decisionsFor } from "../projects/core.mjs"; +import { walkProjects } from "../projects/walk.mjs"; + +async function overlapsOf(timeline, render = {}) { + const root = await mkdtemp(path.join(tmpdir(), "window-overlap-")); + try { + const channelsDir = path.join(root, "channels"); + const reportsRoot = path.join(root, "reports"); + const vdir = path.join(channelsDir, "chan", "data", "vid"); + await mkdir(vdir, { recursive: true }); + // Punctuated cues covering everything, every one closing a sentence, so the + // only decisions about these clips are the overlaps. + const cues = Array.from({ length: 200 }, (_, i) => ({ start: i, end: i + 1, text: `Line ${i}.` })); + await writeFile(path.join(vdir, "transcript.cues.json"), JSON.stringify({ cues })); + const dir = path.join(reportsRoot, "cut"); + await mkdir(dir, { recursive: true }); + await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify({ + schemaVersion: 1, slug: "cut", title: "Cut", + provenance: { channelSlug: "chan", channelsDir: path.relative(dir, channelsDir), siteOrigin: "https://example.test" }, + render: { width: 1920, height: 1080, fps: 30, ...render }, + timeline: timeline.map((e) => ({ type: "clip", video: "vid", cite: Math.floor(e.start), lock: true, ...e })), + }, null, 2)); + const [ref] = (await walkProjects(reportsRoot)).filter((p) => p.id === "cut"); + return (await decisionsFor(ref, reportsRoot)) + .filter((d) => d.kind === "window-overlap") + .map((d) => `${d.target}: ${d.why}`); + } finally { + await rm(root, { recursive: true, force: true }); + } +} + +test("a crossfade seam between back-to-back clips is not an overlap", async () => { + // b starts exactly one transition (0.5 s) before a ends, and follows it. + assert.deepEqual( + await overlapsOf([{ id: "a", start: 10, end: 20 }, { id: "b", start: 19.5, end: 30 }], { transition: 0.5 }), + [], + ); + // The default transition is the build's: 0.5. + assert.deepEqual(await overlapsOf([{ id: "a", start: 10, end: 20 }, { id: "b", start: 19.5, end: 30 }]), []); +}); + +test("more than a transition, a clip not next in the timeline, a hard cut, a montage: still overlaps", async () => { + assert.deepEqual( + await overlapsOf([{ id: "a", start: 10, end: 20 }, { id: "b", start: 18, end: 30 }], { transition: 0.5 }), + ["a: overlaps b by 2.0s"], + ); + assert.deepEqual( + await overlapsOf( + [{ id: "a", start: 10, end: 20 }, { id: "x", start: 50, end: 60 }, { id: "b", start: 19.5, end: 30 }], + { transition: 0.5 }, + ), + ["a: overlaps b by 0.5s"], + ); + // b plays BEFORE a: the fade into a is not the seam with b. + assert.deepEqual( + await overlapsOf([{ id: "b", start: 19.5, end: 30 }, { id: "a", start: 10, end: 20 }], { transition: 0.5 }), + ["a: overlaps b by 0.5s"], + ); + assert.deepEqual( + await overlapsOf([{ id: "a", start: 10, end: 20 }, { id: "b", start: 19.5, end: 30 }], { transition: 0 }), + ["a: overlaps b by 0.5s"], + ); + // A montage joins its segments hard, whatever `transition` says. + assert.deepEqual( + await overlapsOf([{ id: "a", start: 10, end: 20 }, { id: "b", start: 19.5, end: 30 }], { transition: 0.5, montage: {} }), + ["a: overlaps b by 0.5s"], + ); +}); + +test("judged on the cuts that play when a clip has the pair", async () => { + // Extents overlap by 1.8 s; the cuts are 3 s apart (quartering-slow-news s51/s52). + assert.deepEqual( + await overlapsOf( + [ + { id: "s51", start: 89.18, end: 99.14, cutStart: 91.68, cutEnd: 96.64 }, + { id: "s52", start: 97.34, end: 107.82, cutStart: 99.84, cutEnd: 105.32 }, + ], + { transition: 0 }, + ), + [], + ); + // Half a pair renders the whole extent, so the extent is what is judged. + assert.deepEqual( + await overlapsOf( + [ + { id: "s51", start: 89.18, end: 99.14, cutStart: 91.68 }, + { id: "s52", start: 97.34, end: 107.82 }, + ], + { transition: 0 }, + ), + ["s51: overlaps s52 by 1.8s"], + ); +});