Archilyzer · Source

archilyzer

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

commit 84b71cf3fb4a7af3e2fe2535d05f9a87059d42d0
parent e83f2db462c297ff23820357230927d3e74134cb
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri,  6 Nov 2026 18:58:57 -0500

umtool gaps: gapWalls -- where a gap cannot go and why, for the bench to draw; a clip holds up to 40 gaps

gapWalls(entry) returns validateGaps's rules as spans and seconds a
waveform can draw: the span gaps lie in (the cut, else the extent), the
keep bands at its edges and beside each gap, and the marks no gap may
cover (the mute mark, each claim mark's or stamp's `at`), each with the
sentence that explains it. A seeded test holds it to validateGaps: a new
gap clear of every zone and mark is accepted, one reaching into either is
refused.

GAP_LIMITS.max 12 -> 40 (coordinator for the operator, 6 Nov: many gaps on
one long clip must be workable). Nothing downstream counts them:
gapFilterParts splits into as many kept pieces as there are, the fetch,
captions and chat clocks walk the list. Docs follow.

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

Diffstat:
Mumtool/docs/knobs.md | 4++--
Mumtool/docs/report-video.md | 2+-
Mumtool/report-to-video/gaps.mjs | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Mumtool/report-to-video/gaps.test.mjs | 54+++++++++++++++++++++++++++++++++++++++++++++++++++---
4 files changed, 110 insertions(+), 8 deletions(-)

diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -152,7 +152,7 @@ making two clips (a crossfade, a second rail pip, a second subtitle card). `gaps seconds (`report-to-video/gaps.mjs` is the rule and both clocks). - **The rule** (the writer's, the build's validators' and `umtool check`'s `clip-gap-invalid`, blocking): each gap - inside the clip's cut (`cutStart`–`cutEnd`, else its extent), at least 0.2 s, at most 12 of them, in order, apart, + inside the clip's cut (`cutStart`–`cutEnd`, else its extent), at least 0.2 s, at most 40 of them, in order, apart, and at least 0.5 s of material before the first, between any two and after the last. A window, cut or mark save that would leave a gap outside the cut is refused, as the mute mark's is. **A `muteFrom` or a claim mark's `at` strictly inside a gap is refused** (on its edge is fine: it lands at the join) — it names a second the cut never plays, and @@ -1246,7 +1246,7 @@ Its cut is `takes/<t>/out/<slug>.<name>.mp4` (the trailer reel: `<slug>.trailer. | a reel's title, the take it is cut from | **title** | `trailer-beats <p> --reel R title <text>\|none` · `take <t>\|none` | `{op: "settings", title?, take?}` | | play the reel from a take's master: the crossfades, the clock against the limit, the strip of beats; `M` a note on the beat on screen (anchor `reel`), `E` walk it, `N`/`P` beats, `[`/`]` notes | **Play the reel** → `/projects/<p>/trailer/play?reel=&take=` (the take picker) | `umtool notes <p>` reads the notes | `GET /api/report/reel?project&reel&take` · the master: `GET /api/report/reel/media?project&take&what=master` | | walk a beat: the reel's own editor on the clip bench's parts -- the master's waveform (its envelope, on the clip's source clock) with the zoom (`z`/`Z`/`f`/`F`, Ctrl/⌘ + wheel; ruler, overview, close-in pauses and words), the handles and nudges (`[` `]` in, `,` `.` out, Shift 0.5 s; `I`/`O` at the playhead) held to what the master rendered of the clip (said when a handle hits it), exact playback (`Space`, `-`/`=` speed), tighten to the sentence and snap an edge to a pause; saved in the clip's source seconds (`Enter`), `R` puts back, `B` back to the reel | **Walk it** / `E` → `/projects/<p>/trailer/walk?reel=&take=&beat=n` | `trailer-beats <p> --reel R set <n> <from>-<to> [--take <t>]` | `{op: "set", index, patch: {start, end}, take?}` · the master: `GET /api/report/file?project&path&v` · its envelope `GET /api/report/peaks?project&path&from&to` · its sound `GET /api/report/audio?project&path&from&to` | -| a beat's **gaps**: seconds cut out of its middle, in the clip's source seconds -- two moments of one clip as one beat of jump cuts (the clip gap rule: ≥ 0.2 s each, 0.5 s kept before, between and after, at most 12); cut as the clip's gap renders (hard cuts, the sound faded 0.025 s), never the beat-to-beat crossfade; Play the reel skips them and its clock counts kept seconds; a gap wholly inside one the master already cut out of the clip is refused | the walk: `Alt` + drag on the waveform (or **Select a gap** / `g`), **Cut gap** (`g`), **Hear it**, a click on a gap's band puts it back, `G` the one at the playhead, **Undo** | `trailer-beats <p> --reel R gap <n> add <from>-<to>` · `gap <n> remove <second>` · `gap <n> clear` | `{op: "set", index, patch: {gaps: [{from, to}…]}}` | +| a beat's **gaps**: seconds cut out of its middle, in the clip's source seconds -- two moments of one clip as one beat of jump cuts (the clip gap rule: ≥ 0.2 s each, 0.5 s kept before, between and after, at most 40); cut as the clip's gap renders (hard cuts, the sound faded 0.025 s), never the beat-to-beat crossfade; Play the reel skips them and its clock counts kept seconds; a gap wholly inside one the master already cut out of the clip is refused | the walk: `Alt` + drag on the waveform (or **Select a gap** / `g`), **Cut gap** (`g`), **Hear it**, a click on a gap's band puts it back, `G` the one at the playhead, **Undo** | `trailer-beats <p> --reel R gap <n> add <from>-<to>` · `gap <n> remove <second>` · `gap <n> clear` | `{op: "set", index, patch: {gaps: [{from, to}…]}}` | | a beat's verdict: `confirmed` (Y, and on to the next) or `note` (a note left on it) | the walk's **Confirm (Y)** · **Note (M)** · **Clear verdict** | `trailer-beats <p> --reel R verdict <n> confirmed\|note\|clear` | `{op: "set", index, patch: {verdict}}` | | cut it: a job on umtool's runner (one at a time, the heavy slot, its log, **Cancel**), the result playing with its local path; its record names the take's build, the master's mtime and the reel's version, so the Cut panel says when the master was re-rendered or the reel edited since | the Trailer page's **Cut the trailer**; its **Options**: close on the master's last S s (`--finale`), a file name (`--out`, a name only), a dry run | `umtool trailer <p> --reel <name> [--take <t>] [--finale S] [--out NAME] [--dry-run]` | `POST /api/report/reel {project, reel, take, finale?, out?, dryRun?}` · `?cancel=<job>` · `GET ?job=<id>` · the file: `…/reel/media?what=cut&reel=` | diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -183,7 +183,7 @@ the verdict". Play the cut skips it like a fact error; a take does not refuse it `gaps: [{from, to}]` (source seconds) takes seconds out of the middle of a clip, which then renders as ONE segment of jump cuts — one header, one pip, one subtitle card — rather than as two clips with a crossfade. Each gap lies inside -the CUT (the extent when there is none), at least 0.2 s, at most 12, apart, with 0.5 s kept at the edges and between +the CUT (the extent when there is none), at least 0.2 s, at most 40, apart, with 0.5 s kept at the edges and between them; a mute mark or claim mark inside one is refused. `umtool check` reports a malformed gap as `clip-gap-invalid`, **blocking**, as it does `clip-cut-outside`. The build trims the kept pieces on the frame grid and joins them with a 25 ms sound fade at each join; the cut record names the gaps, and every source-to-cut mapping reads it. Written by the diff --git a/umtool/report-to-video/gaps.mjs b/umtool/report-to-video/gaps.mjs @@ -6,7 +6,9 @@ // // SOURCE seconds, like `start`/`end`/`cutStart`/`cutEnd`. Each gap lies inside // the clip's CUT (its `cutStart`–`cutEnd`, else its extent), at least -// GAP_LIMITS.min long, at most GAP_LIMITS.max of them, sorted, apart, and with +// GAP_LIMITS.min long, at most GAP_LIMITS.max of them (40: a long clip cut down +// to its sentences; nothing downstream counts them -- gapFilterParts splits into +// as many pieces as there are), sorted, apart, and with // at least GAP_LIMITS.keep seconds of material before the first, between any // two and after the last: a sliver of picture between two jumps reads as a // glitch, not a cut. A `muteFrom` or a claim mark's `at` strictly INSIDE a gap @@ -29,7 +31,7 @@ // `validateGaps`. /** The rules a clip's gaps keep: seconds (min, keep) and a count (max). */ -export const GAP_LIMITS = Object.freeze({ min: 0.2, max: 12, keep: 0.5 }); +export const GAP_LIMITS = Object.freeze({ min: 0.2, max: 40, keep: 0.5 }); /** Each join's fade, in seconds: out over the end of the piece before, in over the start of the piece after -- short enough to keep a word, long enough not to click. */ export const GAP_FADE = 0.025; @@ -173,6 +175,58 @@ export function validateGaps(entry, where = `timeline entry ${entry?.id ?? "?"}` } /** + * WHERE A GAP CANNOT GO in a clip, and why -- validateGaps's rules as spans + * and seconds a waveform can draw (lane/clip-fixes; operator, 6 Nov: "the gap + * tool gets blocked at random invisible walls"). Every wall a gap dragged on + * the bench stops at is one of these: + * + * span where gaps lie at all (gapSpan: the cut, else the extent); `whose` + * says which, in the words validateGaps uses + * zones inside the span, the seconds no gap may reach into: GAP_LIMITS.keep + * after the span's start and before its end, and beside each gap + * (a span reaching INTO a gap is not refused -- it grows it, + * editGaps -- but one stopping short in its keep band is) + * marks the seconds no gap may COVER (strictly inside): the mute mark, each + * claim mark's or stamp's `at` + * + * A gap avoiding every zone's interior and covering no mark, at least + * GAP_LIMITS.min long, apart from the rest and under GAP_LIMITS.max of them, is + * one validateGaps accepts (gaps.test.mjs holds the two to each other). + * + * @param {Record<string, any>} entry + * @returns {{ span: { from: number, to: number }, whose: "cut" | "clip", + * zones: Array<{ from: number, to: number, kind: "keep-start" | "keep-end" | "keep-gap", why: string }>, + * marks: Array<{ at: number, kind: "mute" | "mark" | "stamp", id: string | null, why: string }> }} + */ +export function gapWalls(entry) { + const span = gapSpan(entry); + const whose = fin(entry?.cutStart) && fin(entry?.cutEnd) ? "cut" : "clip"; + const keep = GAP_LIMITS.keep; + const zones = []; + if (fin(span.from) && fin(span.to)) { + zones.push({ from: span.from, to: Math.min(span.to, span.from + keep), kind: "keep-start", why: `keep at least ${keep} s after the ${whose}'s start` }); + zones.push({ from: Math.max(span.from, span.to - keep), to: span.to, kind: "keep-end", why: `keep at least ${keep} s before the ${whose}'s end` }); + } + for (const g of gapsOf(entry)) { + const why = `keep at least ${keep} s between cuts — or drag into the gap ${g.from}–${g.to} to grow it`; + zones.push({ from: g.from - keep, to: g.from, kind: "keep-gap", why }); + zones.push({ from: g.to, to: g.to + keep, kind: "keep-gap", why }); + } + const marks = []; + if (fin(entry?.muteFrom)) marks.push({ at: entry.muteFrom, kind: "mute", id: null, why: `the mute mark (${entry.muteFrom}): a gap can't cover it — the cut never plays a second inside a gap` }); + for (const m of marksAt(entry)) { + const id = typeof m.id === "string" && m.id ? m.id : null; + marks.push({ + at: m.at, + kind: id ? "mark" : "stamp", + id, + why: `${id ? `the mark ${id}'s second` : "the stamp's second"} (${m.at}): a gap can't cover it — move it first, or cut around it`, + }); + } + return { span, whose, zones, marks }; +} + +/** * A clip beat's GAPS (lane/reel-bench): source seconds cut out of its middle, * so two moments of one clip play as one beat of jump cuts -- the same shape * and the same rule as a clip's gaps (gaps.mjs): each `{ from, to }` at least diff --git a/umtool/report-to-video/gaps.test.mjs b/umtool/report-to-video/gaps.test.mjs @@ -13,7 +13,7 @@ import path from "node:path"; import test from "node:test"; import { - GAP_FADE, GAP_LIMITS, editGaps, gapFilterParts, gapSeconds, gappedLength, gapsOf, gapsOnSegment, gapsText, gapsWithin, + GAP_FADE, GAP_LIMITS, editGaps, gapFilterParts, gapWalls, gapSeconds, gappedLength, gapsOf, gapsOnSegment, gapsText, gapsWithin, inGap, keptSpans, normalizeGaps, offsetIn, parseGapSpec, recordGaps, renderGaps, sourceAtOffset, validateGapEntries, validateGaps, } from "./gaps.mjs"; @@ -44,8 +44,10 @@ test("validateGaps: each refusal names what is wrong", () => { assert.match(one([{ from: 102.3, to: 103 }])[0], /after the cut's start/); assert.match(one([{ from: 117, to: 117.8 }])[0], /before the cut's end/); assert.match(one([{ from: 117, to: 119 }])[0], /outside the clip's cut/); - const many = Array.from({ length: 13 }, (_, k) => ({ from: 100 + k * 1.5, to: 100.3 + k * 1.5 })); - assert.match(validateGaps({ ...CLIP, start: 0, end: 200, cutStart: 99, cutEnd: 130, gaps: many })[0], /at most 12 gaps/); + // At most 40 (a long clip cut down to its sentences); 40 is fine, 41 is not. + const many = (n) => Array.from({ length: n }, (_, k) => ({ from: 100 + k * 1.5, to: 100.3 + k * 1.5 })); + assert.deepEqual(validateGaps({ ...CLIP, start: 0, end: 200, cutStart: 99, cutEnd: 170, gaps: many(40) }), []); + assert.match(validateGaps({ ...CLIP, start: 0, end: 200, cutStart: 99, cutEnd: 170, gaps: many(41) })[0], /at most 40 gaps/); assert.match(validateGaps({ type: "card", id: "k", gaps: G })[0], /only a clip/); }); @@ -219,3 +221,49 @@ test("fetchPieces: one padded span per kept piece; pieces under a minute apart a [{ from: 0, to: 103 }, { from: 397, to: 413 }, { from: 897, to: 1003 }], ); }); + + +// ---- the walls, drawn (lane/clip-fixes) ------------------------------------- + +test("gapWalls: the span, the keep bands at its edges and beside each gap, and the marks no gap may cover", () => { + const w = gapWalls({ ...CLIP, gaps: G, muteFrom: 116, claims: [{ id: "a", verdict: "FALSE", at: 104 }, { verdict: "FALSE", at: 112 }] }); + assert.deepEqual(w.span, { from: 102, to: 118 }); + assert.equal(w.whose, "cut"); + assert.deepEqual( + w.zones.map((z) => [z.kind, z.from, z.to]), + [["keep-start", 102, 102.5], ["keep-end", 117.5, 118], ["keep-gap", 104.5, 105], ["keep-gap", 107, 107.5], ["keep-gap", 109.5, 110], ["keep-gap", 110.5, 111]], + ); + assert.match(w.zones[0].why, /after the cut's start/); + assert.match(w.zones[2].why, /drag into the gap 105–107 to grow it/); + assert.deepEqual(w.marks.map((m) => [m.kind, m.at, m.id]), [["mute", 116, null], ["mark", 104, "a"], ["stamp", 112, null]]); + assert.match(w.marks[0].why, /can't cover it/); + // No cut: the extent, said as the clip's. + const x = gapWalls({ type: "clip", id: "x", start: 10, end: 20 }); + assert.deepEqual(x.span, { from: 10, to: 20 }); + assert.equal(x.whose, "clip"); + assert.deepEqual(x.marks, []); +}); + +test("gapWalls and validateGaps agree: a new gap clear of every zone and mark is accepted, one reaching into either is refused", () => { + const entry = { ...CLIP, gaps: G, muteFrom: 116, claims: [{ id: "a", verdict: "FALSE", at: 104 }, { verdict: "FALSE", at: 112.6 }] }; + const w = gapWalls(entry); + // A seeded walk: deterministic, many spans, every edge on the writer's 2 dp grid. + let seed = 7; + const rand = () => ((seed = (seed * 1103515245 + 12345) % 2147483648) / 2147483648); + let checked = 0; + for (let i = 0; i < 4000; i += 1) { + const a = Number((w.span.from + rand() * (w.span.to - w.span.from)).toFixed(2)); + const b = Number((a + 0.2 + rand() * 3).toFixed(2)); + if (b > w.span.to) continue; + // Touching or overlapping a gap is a merge (editGaps), not a wall: not this test's question. + if (G.some((g) => g.to >= a && g.from <= b)) continue; + const hitsZone = w.zones.some((z) => a < z.to - 0.02 && b > z.from + 0.02); + const nearZone = w.zones.some((z) => (Math.abs(a - z.to) <= 0.02 || Math.abs(b - z.from) <= 0.02)); + if (nearZone) continue; // within the writer's 0.02 tolerance of a band's edge + const coversMark = w.marks.some((m) => m.at > a && m.at < b); + const errs = validateGaps({ ...entry, gaps: normalizeGaps([...G, { from: a, to: b }]) }); + assert.equal(errs.length === 0, !hitsZone && !coversMark, `${a}–${b}: ${errs.join("; ") || "accepted"}`); + checked += 1; + } + assert.ok(checked > 500, `checked ${checked}`); +});