commit 45e7e78cc19867a19f743d5ae7fb03b167636a57
parent d02d6265f873d3bdf497e33b291fda6a5e6dd1a0
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 4 Nov 2026 14:08:14 -0500
umtool: a take --from another reuses a post item whose key still matches -- its record and combo files ride with its segment, and nothing of a post item is written through a link (operator, 4 Nov: "make sure you handle caching well")
Before, every post item was rebuilt in a --from take: its record (.post.json, the key) was not among the
segment files linked, and build-video unlinked a post item's linked files before building it. Now
SEGMENT_FILE_SUFFIXES carries .post.json, .combo.json and .plain.mp4, a post item's files stay linked, and its
record and its combo record are written through a rename (as its segment already was), so the other take's
files are never written through. Proven on a copy: captions-proof-5 --from captions-proof-4 after one caption's
hold changed -- 7 post items "unchanged — its segment kept" (and a combo kept), 1 rebuilt; the other take's
record untouched (its own inode and content).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
5 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md
@@ -743,6 +743,20 @@ post, it undoes a cut's `fast`). It rides the narration's knobs (`postNarrationK
schedule, the build, Play and the deck's estimate all honour it. An un-narrated post has no
read gaps to shorten (its `hold` is its length).
+### Caching: the segment key
+
+A post segment is rebuilt only when its key changes (`<id>.post.json`'s `key`). The entry is in it -- a
+caption's text and knobs, the clock fx, the narration's `pace`, the item's id (a repeated item is its own
+segment) -- and `postFxKeyFields` (`post-render.mjs`) APPENDS what the entry does not carry: `captionV` and
+`clockV` (the chip's and the clock's drawing, bumped when their look changes), `clock` (the plan: this post's
+time, the time it runs from -- the item before's, when that one is a clock item -- the mode, a forced rewind,
+the zone) and `pace` (the gap knobs a cut-level pace resolved to). An item with none of these adds nothing, so
+its key is the one it had before they existed and a take `--from` an earlier one reuses its segment.
+A take `--from` another hard-links a post item's record (`.post.json`) and its combo pass's files (`.combo.json`,
+`.plain.mp4`) with its segment (`SEGMENT_FILE_SUFFIXES`), and a post item's files are no longer detached before
+its build: a matching key keeps the linked segment, and every write of a rebuilt one goes through a rename, so
+the other take's files are never written through (before, every post item was rebuilt in a `--from` take).
+
### A repeated item
`umtool timeline <p> duplicate <id>` copies a post item to just after itself under a fresh
diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs
@@ -2475,7 +2475,9 @@ async function buildMontageWall({ M, entries, render, outDir, timeline, provenan
* started `--from` another keeps the intro's file, and the crossfade batch
* over it, instead of copying the intro in again).
*/
-export const SEGMENT_FILE_SUFFIXES = Object.freeze([".mp4", ".cut.json", ".teaser.json", ".narration.json", ".intro.json", ".quote.txt", ".attrib.txt", ".channel.txt"]);
+// A post item's record (`.post.json`, its key: post-render.mjs) and its combo pass's (`.combo.json`, the badge-less
+// `.plain.mp4`) ride with its segment, so a take --from another reuses a post item whose key still matches.
+export const SEGMENT_FILE_SUFFIXES = Object.freeze([".mp4", ".cut.json", ".teaser.json", ".narration.json", ".intro.json", ".quote.txt", ".attrib.txt", ".channel.txt", ".post.json", ".combo.json", ".plain.mp4"]);
/**
* Before an entry's segment is rebuilt: each of its files in `segDir` that is
@@ -6403,7 +6405,9 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly
render, encode: encodeArgs(render), outDir, manifestDir, workers: CHROME_WORKERS, emit: (ev, f) => EMIT(ev, f),
});
}
- if (entry.type !== "teaser" && entry.type !== "clip") {
+ // A post item's files are kept linked: its build reuses them when its key matches and writes every one of
+ // them through a rename (post-render.mjs, post-combo-render.mjs), never through a link into another take.
+ if (entry.type !== "teaser" && entry.type !== "clip" && entry.type !== "post") {
await detachSegmentFiles(path.join(outDir, "segments"), entry.id);
}
if (entry.type === "card") {
diff --git a/umtool/report-to-video/post-clock.test.mjs b/umtool/report-to-video/post-clock.test.mjs
@@ -125,3 +125,8 @@ test("THE SEGMENT KEY (post-render.mjs postFxKeyFields): nothing for a plain ite
assert.deepEqual(postFxKeyFields(plain, { postNarration: { pace: "fast" } }).pace, { pace: "fast", lead: 0.1, tail: 0.15, ramp: 0.3, linger: 0.45 });
assert.equal(postFxKeyFields({ ...plain, narration: { ...plain.narration, pace: "fast", linger: 1 } }, {}).pace.linger, 1);
});
+
+test("a take --from another carries a post item's record (its key) and combo files with its segment, so a matching item is reused", async () => {
+ const { SEGMENT_FILE_SUFFIXES } = await import("./build-video.mjs");
+ for (const s of [".mp4", ".post.json", ".combo.json", ".plain.mp4"]) assert.ok(SEGMENT_FILE_SUFFIXES.includes(s), s);
+});
diff --git a/umtool/report-to-video/post-combo-render.mjs b/umtool/report-to-video/post-combo-render.mjs
@@ -200,7 +200,10 @@ export async function applyPostCombo(seg, entry, { combo, render, outDir, box, e
}
await rename(tmp, seg);
const out = sigOf(await stat(seg));
- await writeFile(/* turbopackIgnore: true */ record, JSON.stringify({ version: 1, id: entry.id, key, out, count: combo.count, at: cp.at, media: combo.media, region: cp.place.region, sfx: sfx ? combo.knobs.sfx : "off" }, null, 2) + "\n", "utf8");
+ // Through a rename: the record may be a link into the take this one was made --from.
+ const recTmp = `${record}.${process.pid}.tmp`;
+ await writeFile(/* turbopackIgnore: true */ recTmp, JSON.stringify({ version: 1, id: entry.id, key, out, count: combo.count, at: cp.at, media: combo.media, region: cp.place.region, sfx: sfx ? combo.knobs.sfx : "off" }, null, 2) + "\n", "utf8");
+ await rename(recTmp, record);
emit("note", { message: `${entry.id}: combo ×${combo.count} at ${cp.at.toFixed(2)} s${sfx ? ` (sfx ${combo.knobs.sfx})` : ""}` });
return seg;
}
diff --git a/umtool/report-to-video/post-render.mjs b/umtool/report-to-video/post-render.mjs
@@ -769,7 +769,10 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box
await rename(tmp, seg);
// The follow frames are in the segment now: a rebuild shoots them again (they are many, and the key decides).
if (cards.follow) await rm(path.dirname(cards.follow.list), { recursive: true, force: true });
- await writeFile(record, JSON.stringify({ version: 1, id: entry.id, key, layout: layout.mode, total: plan.total, steps: plan.steps.length, ...(zooms.length ? { zooms: zooms.map((z) => ({ i: z.i, at: z.t, source: z.source, span: z.span, region: z.region, word: z.word })) } : {}), ...(cards.captions?.length ? { captions: cards.captions.map((c) => ({ i: c.i, at: c.t, source: c.source, span: c.span, place: c.placed.place, box: { x: c.placed.x, y: c.placed.y, width: c.placed.width, height: c.placed.height }, word: c.placed.word, covers: c.placed.covers, moves: c.track.filter((p, k, a) => k && (p.dx !== a[k - 1].dx || p.dy !== a[k - 1].dy)).length })) } : {}), ...(narration ? { narration: { take: take.file, ...plan.narration, gainDb: narration.gainDb, measured: narration.lufs, ...(bleeps ? { slurs: { mode: bleeps.mode, spans: bleeps.spans } } : {}) } } : {}), ...(cards.follow ? { follow: { blocks: plan.follow.blocks.length, shots: cards.follow.shots, frames: cards.follow.frames, pan: cards.follow.path.segments.length, max: cards.follow.path.max } } : {}) }, null, 2) + "\n", "utf8");
+ // Through a rename: the record may be a link into the take this one was made --from (never written through).
+ const recTmp = `${record}.${process.pid}.tmp`;
+ await writeFile(recTmp, JSON.stringify({ version: 1, id: entry.id, key, layout: layout.mode, total: plan.total, steps: plan.steps.length, ...(zooms.length ? { zooms: zooms.map((z) => ({ i: z.i, at: z.t, source: z.source, span: z.span, region: z.region, word: z.word })) } : {}), ...(cards.captions?.length ? { captions: cards.captions.map((c) => ({ i: c.i, at: c.t, source: c.source, span: c.span, place: c.placed.place, box: { x: c.placed.x, y: c.placed.y, width: c.placed.width, height: c.placed.height }, word: c.placed.word, covers: c.placed.covers, moves: c.track.filter((p, k, a) => k && (p.dx !== a[k - 1].dx || p.dy !== a[k - 1].dy)).length })) } : {}), ...(narration ? { narration: { take: take.file, ...plan.narration, gainDb: narration.gainDb, measured: narration.lufs, ...(bleeps ? { slurs: { mode: bleeps.mode, spans: bleeps.spans } } : {}) } } : {}), ...(cards.follow ? { follow: { blocks: plan.follow.blocks.length, shots: cards.follow.shots, frames: cards.follow.frames, pan: cards.follow.path.segments.length, max: cards.follow.path.max } } : {}) }, null, 2) + "\n", "utf8");
+ await rename(recTmp, record);
emit("note", {
message: narration
? `${entry.id}: post item ${plan.total.toFixed(1)} s, narrated (${take.file}: ${plan.narration.seconds.toFixed(1)} s from ${plan.narration.at} s, muffled to ${plan.narration.voiceEnd.toFixed(1)} s)`