commit a07a830a4c96e2220fb9f564df115f4294f3e61b
parent 2686b01103fb24543229b88a2c23e14800d0f5d1
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 13 Oct 2026 10:51:51 -0400
common, umtool: prepare --only, the window pad contract pinned, the pipeline found from the module (release 27 S7)
`archilyzer reports prepare --article <id> --only`: the article being
readied answers for the run. The media is still prepared for every published
article (the articles' cache is one directory and a prepare prunes every clip
its run does not cite), but only that article's problems fail it — another's
are printed as warnings — and only it is exported, resolved over a host of it
alone (articlesWorkHost's `only`), so another article's gap cannot refuse it.
fetch-windows / fetchWindowManaged: `from`/`to` are the window with its
padding and `pad` is provenance — every caller pads before it asks. Tests pin
that a cached unpadded window never answers for a padded ask, and the
contract is written where the item and the cache check are.
umtool's driver finds report-to-video/ from its own module, so
`umtool build --dry` from anywhere but umtool/ names the real directory (the
Next server, whose module URLs are chunk paths, keeps its cwd).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
11 files changed, 229 insertions(+), 12 deletions(-)
diff --git a/COMMANDS.md b/COMMANDS.md
@@ -29,7 +29,7 @@ Run from the repo root (in the container: `docker compose exec editor pnpm archi
| `archilyzer build all` | `[--skip-archives]` | alias: publish index + publish build all --runner auto (containers when an engine answers, else serially on the host) |
| `archilyzer build hub` | | compose:hub + INSTANCE\_MODE=hub next build into export/out — a raw build, unstamped; to deploy the hub build it with `publish hub` |
| `archilyzer build homepage` | `[--no-source] [--private]` | compose + source publish + next build in homepage/ (reads the index as it stands), then the public build's audit (no private article, moment or X post); --no-source removes the published source instead; --private builds every published article into homepage/out-private instead (serve it with `pnpm --filter homepage start:private`; never deployed) |
-| `archilyzer reports prepare` | `<id> \| --article <articleId>` | cut every clip and copy every post capture the site's published reports cite into its report-media cache, before its build, then export the reports as files (reports export) when nothing is missing (exit 1 when a citation lacks media or an export fails; default id: SITE\_ID); --article: the articles' cache (transcripts/reports/), every published article plus that one |
+| `archilyzer reports prepare` | `<id> \| --article <articleId> [--only]` | cut every clip and copy every post capture the site's published reports cite into its report-media cache, before its build, then export the reports as files (reports export) when nothing is missing (exit 1 when a citation lacks media or an export fails; default id: SITE\_ID); --article: the articles' cache (transcripts/reports/), every published article plus that one; --only: that article answers for the run — its problems fail it, another article's are warnings, and only it is exported |
| `archilyzer reports export` | `<id> [--report <reportId>] \| --article <articleId>` | \[--formats html,pdf,md,slides,slides-pdf,zip\] \[--allow-missing-media\] write the site's published reports as files (report.html, report.pdf, report.md, slides.html, slides.pdf, evidence-pack.zip) into its report-exports staging, where compose publishes them from (exit 1 on a problem; a PDF skipped for want of a browser is a note; default id: SITE\_ID); --article: one article (transcripts/reports/), published or a draft |
| `archilyzer reports check` | `<id> [--reports <a,b>] \| --article <articleId>` | \[--allow-missing-media\] what compose would say about the site's reports, with no build: each report validated, every cited quote checked against its record, every cited moment's prepared media present and current, the report video under the publish limit (exit 1 with the list; --reports checks those, drafts included; default id: SITE\_ID); --article: one article (transcripts/reports/), published or a draft, as the homepage's compose would |
| `archilyzer reports verify-quotes` | `<report.json> \| --article <articleId>` | \[--json\] every video, audio and post quote of one report against its record with compose's own check: the best score and track, and the en-orig track's score where the record has one — a quote that matches a served `en` rewrite and not en-orig is reported (exit 1 when any quote drifted) |
diff --git a/common/bin/archilyzer.ts b/common/bin/archilyzer.ts
@@ -269,13 +269,19 @@ export const COMMANDS: Command[] = [
{
path: ["reports", "prepare"],
usage:
- "<id> | --article <articleId> cut every clip and copy every post capture the site's published reports cite into its report-media cache, before its build, then export the reports as files (reports export) when nothing is missing (exit 1 when a citation lacks media or an export fails; default id: SITE_ID); --article: the articles' cache (transcripts/reports/), every published article plus that one",
- flags: { article: "string" },
+ "<id> | --article <articleId> [--only] cut every clip and copy every post capture the site's published reports cite into its report-media cache, before its build, then export the reports as files (reports export) when nothing is missing (exit 1 when a citation lacks media or an export fails; default id: SITE_ID); --article: the articles' cache (transcripts/reports/), every published article plus that one; --only: that article answers for the run — its problems fail it, another article's are warnings, and only it is exported",
+ flags: { article: "string", only: "boolean" },
maxPositionals: 1,
run: async ({ positionals, flags, env }) => {
const article = articleFrom(positionals, flags, "reports prepare");
if (article === null) return 2;
- if (article) return (await import("./reports-prepare")).main({ article, signal: interrupted() });
+ if (flags.only === true && !article) {
+ console.error("reports prepare: --only answers for one article: give --article <id>");
+ return 2;
+ }
+ if (article) {
+ return (await import("./reports-prepare")).main({ article, only: flags.only === true, signal: interrupted() });
+ }
const siteId = siteIdFrom(positionals, env, "reports prepare");
if (!siteId) return 2;
return (await import("./reports-prepare")).main({ siteId, signal: interrupted() });
diff --git a/common/bin/reports-article.test.ts b/common/bin/reports-article.test.ts
@@ -112,6 +112,35 @@ test("prepare --article: the articles' cache, every published article plus the o
assert.equal(existsSync(path.join(paths.exportIndexDir, "sites")), false, "no site's staging touched");
});
+test("prepare --article <id> --only: that article answers for the run — its gaps fail it, another's are warnings, it alone is exported (release 27 S7)", async () => {
+ // An article whose own moments are all prepared: another's gap is a warning.
+ writeJson(articleFile(paths, "solo"), {
+ format: "archilyzer-report",
+ version: 1,
+ id: "solo",
+ kind: "sweep",
+ title: "Article solo",
+ sections: [{ id: "s", title: "S", body: "Nothing cited here." }],
+ });
+ const exportOptions = { paths, openPdfPrinter: async () => ({ missing: "no browser in the test" }) };
+ const ok = capture();
+ assert.equal(await prepareMain({ article: "solo", only: true, exportOptions }, ok.out), 0, ok.text());
+ assert.match(ok.text(), /warning: 1 problem\(s\) in OTHER articles — not this one's/);
+ assert.match(ok.text(), /missing-media: lone\/abc1\/10\.00-20\.00 \(cited by pub#c1\)/);
+ assert.ok(existsSync(path.join(STAGING, "report-exports", "solo", "report.html")), "this article is exported");
+ // The cache still holds every published article's moments: nothing pruned, the index whole.
+ const index = readJson<{ problems: { citations: string[] }[] }>(path.join(STAGING, "report-media", "index.json"));
+ assert.deepEqual(index.problems.map((p) => p.citations), [["pub#c1"]]);
+ // Its own gap fails the run, named.
+ const own = capture();
+ assert.equal(await prepareMain({ article: "draft", only: true, exportOptions }, own.out), 1);
+ assert.match(own.text(), /reports prepare --article draft --only: 1 problem\(s\):/);
+ assert.match(own.text(), /the article was not exported/);
+ // --only needs an article.
+ const bad = capture();
+ assert.equal(await prepareMain({ siteId: "x", only: true }, bad.out), 2);
+});
+
test("export --article: one article's files under .export-index/articles/, its history in reports/<id>/history-git", async () => {
const c = capture();
assert.equal(
diff --git a/common/bin/reports-prepare.ts b/common/bin/reports-prepare.ts
@@ -12,11 +12,22 @@
// Exit 0 when every cited moment has its media and every export was written;
// 1 when any problem is listed (the manifest is written either way, problems
// included); 2 for a site that does not exist.
+//
+// `--article <id> --only` (release 27 S7): the article being readied is what
+// the run answers for. The media is still prepared for every published
+// article too — the articles' cache is one directory and a prepare prunes
+// every clip its run does not cite — but only THAT article's problems fail
+// the run (another's are printed as warnings), and only it is exported.
import { getPaths } from "../lib/paths";
import { formatReportMediaProblems, prepareReportMedia } from "../publish/reportMedia";
-import { exportAfterPrepare, formatReportExportProblems, type ExportSiteReportsOptions } from "../publish/reportExports";
-import { articlesWorkHost, type ReportHost } from "../publish/reportHost";
+import {
+ exportAfterPrepare,
+ exportSiteReports,
+ formatReportExportProblems,
+ type ExportSiteReportsOptions,
+} from "../publish/reportExports";
+import { articlesWorkHost, isArticleProblem, type ReportHost } from "../publish/reportHost";
type Out = { log: (s: string) => void; error: (s: string) => void };
@@ -25,13 +36,19 @@ export async function main(
// The site, or `article` — one article id: the articles' run.
siteId?: string;
article?: string;
+ // With `article`: answer for that article alone (above).
+ only?: boolean;
signal?: AbortSignal;
// Passed to the export at the end (tests inject the PDF printer and zip).
exportOptions?: Partial<Pick<ExportSiteReportsOptions, "openPdfPrinter" | "zipBin" | "paths" | "settings">>;
},
out: Out = console,
): Promise<number> {
- const who = opts.article ? `--article ${opts.article}` : opts.siteId;
+ const who = opts.article ? `--article ${opts.article}${opts.only ? " --only" : ""}` : opts.siteId;
+ if (opts.only && !opts.article) {
+ out.error("reports prepare: --only answers for one article: give --article <id>");
+ return 2;
+ }
let index;
let host: ReportHost | undefined;
try {
@@ -46,6 +63,7 @@ export async function main(
out.error(`reports prepare: ${(err as Error).message}`);
return opts.signal?.aborted ? 1 : 2;
}
+ if (opts.only && opts.article) return onlyArticle(opts.article, index, opts, out);
if (index.problems.length > 0) {
out.error(`reports prepare ${who}: ${index.problems.length} problem(s):`);
for (const line of formatReportMediaProblems(index.problems)) out.error(` ${line}`);
@@ -69,3 +87,45 @@ export async function main(
for (const line of formatReportExportProblems(exported.problems)) out.error(` ${line}`);
return 1;
}
+
+// The rest of a `--only` run: this article's problems fail it, another's are
+// warnings, and this article alone is exported (resolved over a host of it
+// alone, so another article's gap cannot refuse it).
+async function onlyArticle(
+ article: string,
+ index: Awaited<ReturnType<typeof prepareReportMedia>>,
+ opts: Parameters<typeof main>[0],
+ out: Out,
+): Promise<number> {
+ const who = `--article ${article} --only`;
+ const own = index.problems.filter((p) => isArticleProblem(p, article));
+ const others = index.problems.filter((p) => !isArticleProblem(p, article));
+ if (others.length > 0) {
+ out.log(`reports prepare ${who}: warning: ${others.length} problem(s) in OTHER articles — not this one's:`);
+ for (const line of formatReportMediaProblems(others)) out.log(` ${line}`);
+ }
+ if (own.length > 0) {
+ out.error(`reports prepare ${who}: ${own.length} problem(s):`);
+ for (const line of formatReportMediaProblems(own)) out.error(` ${line}`);
+ out.error("reports prepare: the article was not exported (its evidence media is not complete).");
+ return 1;
+ }
+ let exported;
+ try {
+ const paths = opts.exportOptions?.paths ?? getPaths();
+ exported = await exportSiteReports({
+ host: await articlesWorkHost(paths, [article], { only: true }),
+ reportId: article,
+ signal: opts.signal,
+ onLog: out.log,
+ ...opts.exportOptions,
+ });
+ } catch (err) {
+ out.error(`reports prepare: export: ${(err as Error).message}`);
+ return 1;
+ }
+ if (exported.problems.length === 0) return 0;
+ out.error(`reports prepare ${who}: export: ${exported.problems.length} problem(s):`);
+ for (const line of formatReportExportProblems(exported.problems)) out.error(` ${line}`);
+ return 1;
+}
diff --git a/common/controller/fetchWindows.test.ts b/common/controller/fetchWindows.test.ts
@@ -398,3 +398,26 @@ test("a Twitch record's v<n> is fetched into, and read from, its data/<n>/ (rele
const written = await readFile(path.join(paths.channelsDir, "c", "data", fresh, "clips", "5.00-15.00.mp4"), "utf8");
assert.equal(written, "mp4");
});
+
+// Release 27 S7 (the owed "pad" bug): `from`/`to` are the window, padding
+// included, and `pad` is provenance. A cached UNPADDED window of the cited
+// span must not answer for the padded ask — it is fetched, and the sidecar
+// records the pad.
+test("a cached unpadded window does not cover a padded ask: it is fetched, its pad recorded", async () => {
+ const paths = await corpus();
+ const clips = path.join(paths.channelsDir, "c", "data", "v1", "clips");
+ await mkdir(clips, { recursive: true });
+ // The cited span alone, as an unpadded fetch left it.
+ await writeFile(path.join(clips, "10.00-20.00.mp4"), "mp4");
+ const h = harness();
+ const before = await spawns();
+ const padded = { ...item("v1", "/pad", 7, 23), pad: 3 };
+ const r = await go(paths, [padded], h);
+ assert.deepEqual([r.cached.length, r.fetched.length], [0, 1], "fetched, not answered from the unpadded window");
+ assert.equal((await spawns()) - before, 1);
+ const sidecar = JSON.parse(await readFile(path.join(clips, "7.00-23.00.json"), "utf8")) as { pad?: number };
+ assert.equal(sidecar.pad, 3);
+ // Asked again, the padded window answers — and the unpadded ask is served by it too.
+ const again = await go(paths, [padded, item("v1", "/exact", 10, 20)], harness());
+ assert.deepEqual([again.cached.length, again.fetched.length], [2, 0]);
+});
diff --git a/common/controller/fetchWindows.ts b/common/controller/fetchWindows.ts
@@ -116,6 +116,14 @@ export type FetchWindowsItem = {
// `<reportId>#<citationId>`, or a manifest's clip id.
clipId?: string;
reason?: string;
+ // How many of the window's seconds, each side, are padding around what is
+ // cited — PROVENANCE, recorded in the window's sidecar. `from` and `to` are
+ // the window, padding included: every caller pads before it asks
+ // (fetch-via-editor.mjs and the MCP's fetch_clip `max(0, start - pad)`,
+ // `end + pad`; the release 27 chain the same), so a cached window covers an
+ // item only when it holds all of [from, to] — padding seconds included. An
+ // unpadded window on disk never answers for a padded ask (release 27 S7 pins
+ // it). Sending the cited span with `pad` set fetches the span unpadded.
pad?: number;
// The page URL when the caller has it; else resolved as the single fetch does.
webpageUrl?: string;
diff --git a/common/publish/reportHost.ts b/common/publish/reportHost.ts
@@ -153,9 +153,15 @@ export function hostCorpusLink(host: ReportHost, channel: string, params: Record
// is not published yet (a draft being readied). Its prepared media and
// exports therefore serve both homepage builds. An included id with no
// report.json is refused.
+//
+// `only: true` (release 27 S7) is `include` alone, published or not: the
+// host one article's EXPORT is resolved over, so another article's gap does
+// not refuse it. Never prepare over it: the articles' media cache is one
+// directory, and a prepare prunes every clip its run does not cite.
export async function articlesWorkHost(
paths: Pick<Paths, "articlesDir" | "exportIndexDir" | "channelsDir">,
include: readonly string[] = [],
+ opts: { only?: boolean } = {},
): Promise<ReportHost> {
for (const id of include) {
if (!isReportId(id)) throw new Error(`"${id}" is not an article id`);
@@ -163,9 +169,16 @@ export async function articlesWorkHost(
throw new Error(`no article "${id}" (no reports/${id}/report.json)`);
}
}
+ if (opts.only) return articlesReportHost(paths, { audience: "private", published: [...new Set(include)] });
const published = await publishedArticleIds("private", paths);
return articlesReportHost(paths, {
audience: "private",
published: [...published, ...include.filter((id) => !published.includes(id))],
});
}
+
+// The problems that are `articleId`'s own: a problem of its report, or of a
+// moment one of its citations cites (`<id>#<citation>`).
+export function isArticleProblem(p: { report?: string; citations?: readonly string[] }, articleId: string): boolean {
+ return p.report === articleId || (p.citations ?? []).some((c) => c.startsWith(`${articleId}#`));
+}
diff --git a/common/ytdlp/fetchWindowManaged.test.ts b/common/ytdlp/fetchWindowManaged.test.ts
@@ -122,3 +122,25 @@ test("a rumble.com upload served progressive is retried once without the HLS opt
assert.equal(hasPicky(mine[1]), false);
assert.equal(await readFile(res.file, "utf8"), "mp4");
});
+
+// Release 27 S7 (the owed "pad" bug): from/to are the window, padding
+// included; a cached window of the unpadded span must not answer for a padded
+// ask, and a window that holds the padded seconds does.
+test("a cached unpadded window does not cover a padded ask; a padded one covers it and the unpadded span", async () => {
+ delete process.env.FAKE_MODE;
+ const videoDir = await setup("pad");
+ await mkdir(path.join(videoDir, "clips"), { recursive: true });
+ await writeFile(path.join(videoDir, "clips", "10.00-20.00.mp4"), "mp4");
+ const before = (await runs()).length;
+ const padded = { ...opts(videoDir), videoUrl: "https://example.test/v1", from: 7, to: 23, provenance: { requestedBy: "test", pad: 3 } };
+ const res = await fetchWindowManaged(padded);
+ assert.equal(res.cached, false, "the unpadded window did not answer");
+ assert.deepEqual([res.from, res.to], [7, 23]);
+ assert.equal((await runs()).length - before, 1);
+ const again = await fetchWindowManaged(padded);
+ assert.equal(again.cached, true);
+ const exact = await fetchWindowManaged({ ...padded, from: 10, to: 20 });
+ assert.equal(exact.cached, true);
+ // The tightest window that holds the ask: the unpadded one for the unpadded span.
+ assert.deepEqual([exact.from, exact.to], [10, 20]);
+});
diff --git a/common/ytdlp/fetchWindowManaged.ts b/common/ytdlp/fetchWindowManaged.ts
@@ -167,7 +167,9 @@ export async function fetchWindowManaged(
// ASK THE CACHE FIRST, and accept a WIDER file. A report cites the same
// stream more than once; without containing-window reuse a generous fetch for
- // one clip is worthless to the neighbour it already covers.
+ // one clip is worthless to the neighbour it already covers. `from`/`to` are
+ // the window WITH its padding (`provenance.pad` only records how much), so an
+ // unpadded window on disk never answers for a padded ask (release 27 S7).
const hit = await findContainingClipWindow(videoDir, from, to);
if (hit) {
opts.onLog(
diff --git a/umtool/lib/report/driver.mjs b/umtool/lib/report/driver.mjs
@@ -8,10 +8,37 @@
//
// The client sends a PROJECT and a PRESET NAME. It never sends a path, an argv
// or an env map -- the same contract /api/browse/build already keeps.
+import { existsSync } from "node:fs";
import path from "node:path";
+import { fileURLToPath } from "node:url";
+
+/**
+ * This package's own root (umtool/): bin/ lives here, and so does
+ * report-to-video/.
+ *
+ * FROM THE MODULE, not the cwd (release 27 S7): `umtool build <p> --dry` run
+ * from the repository root printed `cd <repo>/report-to-video`, a directory
+ * that does not exist, and a umtool CLI run from anywhere else did the same.
+ * The module's own path names the package wherever the process stands. Under
+ * the Next server Turbopack rewrites module URLs into .next/server/chunks
+ * (lib/paths.ts, SONG_CODE), where no report-to-video/ is found — the server
+ * keeps its cwd, which `next dev` and `next start` set to the package root.
+ */
+function packageRoot() {
+ try {
+ const dir = path.resolve(/* turbopackIgnore: true */ path.dirname(fileURLToPath(import.meta.url)), "..", "..");
+ if (existsSync(path.join(/* turbopackIgnore: true */ dir, "report-to-video", "build-video.mjs"))) return dir;
+ } catch {
+ // Not a file: URL (a bundle): the cwd, below.
+ }
+ return path.resolve(/* turbopackIgnore: true */ process.cwd());
+}
+
+/** This package's own root. bin/ lives here, and so does report-to-video/. */
+export const UMTOOL_DIR = packageRoot();
/** Where the pipeline lives. One place, so a move is one edit. */
-export const PIPELINE_DIR = path.resolve(/* turbopackIgnore: true */ process.cwd(), "report-to-video");
+export const PIPELINE_DIR = path.join(/* turbopackIgnore: true */ UMTOOL_DIR, "report-to-video");
const script = (name) => path.join(/* turbopackIgnore: true */ PIPELINE_DIR, name);
@@ -412,9 +439,6 @@ export function checkSourcesSteps(projects, env = {}) {
// decision the report's author already wrote down.
// ---------------------------------------------------------------------------
-/** This package's own root. bin/ lives here, and so does report-to-video/. */
-export const UMTOOL_DIR = path.resolve(/* turbopackIgnore: true */ process.cwd());
-
const tool = (name) => path.join(/* turbopackIgnore: true */ UMTOOL_DIR, "bin", name);
/** The interpreter a project's own scripts are run with. */
diff --git a/umtool/lib/report/driver.test.mjs b/umtool/lib/report/driver.test.mjs
@@ -83,3 +83,33 @@ test("one card's narration: narrate-via-editor --only, its voice kept in out/",
assert.deepEqual(s.argv.slice(2), ["/r/p/video.manifest.json", "--out", "/r/p/out", "--only", "k1", "--progress", "ndjson"]);
assert.deepEqual(s.env, {}, "the token is the server's environment's, never the step's");
});
+
+// Release 27 S7: `umtool build --dry` printed `cd <cwd>/report-to-video` —
+// the pipeline was found from the cwd, so a CLI run from anywhere but umtool/
+// named a directory that is not there.
+test("the pipeline is found from the module, whatever the cwd", async () => {
+ const { execFileSync } = await import("node:child_process");
+ const { existsSync, mkdtempSync, rmSync } = await import("node:fs");
+ const os = await import("node:os");
+ const path = await import("node:path");
+ const { fileURLToPath } = await import("node:url");
+ const here = path.dirname(fileURLToPath(import.meta.url));
+ const want = path.resolve(here, "..", "..", "report-to-video");
+ const { PIPELINE_DIR, UMTOOL_DIR } = await import("./driver.mjs");
+ assert.equal(PIPELINE_DIR, want);
+ assert.equal(UMTOOL_DIR, path.resolve(here, "..", ".."));
+ assert.ok(existsSync(path.join(PIPELINE_DIR, "build-video.mjs")));
+ const elsewhere = mkdtempSync(path.join(os.tmpdir(), "driver-cwd-"));
+ try {
+ const printed = execFileSync(
+ process.execPath,
+ ["--input-type=module", "-e", `import { PIPELINE_DIR } from ${JSON.stringify(path.join(here, "driver.mjs"))}; console.log(PIPELINE_DIR);`],
+ { cwd: elsewhere, encoding: "utf8" },
+ ).trim();
+ assert.equal(printed, want);
+ const steps = buildSteps({ id: "p", dir: "/r/p" }, { preset: "fast" });
+ assert.ok(steps.every((s) => s.cwd === want));
+ } finally {
+ rmSync(elsewhere, { recursive: true, force: true });
+ }
+});