commit bedbb057dc812fa7ec3040c8ebafd5825648f8da
parent a06da009e93a34df2c00429de6b2f0ea83b61650
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 2 Nov 2026 02:03:02 -0500
umtool: the sites a cut's links depend on, each with its deploy's date, and a warning when cited videos are newer than it (UI notes #9)
- lib/report/siteDeploys.mjs: every origin a clip QR opens, named by the site whose site.json siteUrl it is (SITES_DIR, read only), dated by the corpus.json generatedAt the last link check recorded (out/links.json; never fetched here); the cited videos newer than that deploy -- uploaded after it, or transcribed here after it -- whose link the check did not find open
- the check: site-deploy-behind (open, one row per site), its settle "Publish <site>" -> POST /api/report/publish-site -> the editor's ops build-deploy (its publish queue, through the heavy slot); fix `pnpm ops build-deploy --json '{"siteId":…}'`
- the Overview's "Sites the links depend on": host, site id, links and clips, the deploy date, the newer videos, Publish <site> and Check links
- #8 (the QR check against corpus.json) shipped in 3f5f084f/cfd2d911; its "Publish anilyzer" button is this one
- the editor stub answers build-deploy; unit tests (lib/report/ui-ops.test.mjs); docs: knobs.md, inbox.md, cli.md
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
14 files changed, 533 insertions(+), 7 deletions(-)
diff --git a/umtool/app/api/report/publish-site/route.ts b/umtool/app/api/report/publish-site/route.ts
@@ -0,0 +1,65 @@
+import { projectRef } from "@/lib/projects";
+import { kindMakesTakes } from "@/lib/projects/kinds.mjs";
+import { readManifest } from "@/lib/projects/report.mjs";
+import { askEditor, EditorError } from "@/lib/articles/generation";
+import { refuseCaller } from "@/lib/report/caller";
+import { readLinkCheck } from "@/lib/report/linkCheck.mjs";
+import { projectSites, sitesByOrigin } from "@/lib/report/siteDeploys.mjs";
+import { SITES_DIR } from "@/lib/paths.mjs";
+
+export const dynamic = "force-dynamic";
+
+// PUBLISH A SITE THE CUT CITES (UI notes 2026-10-30, #8 and #9): the
+// project page's "Publish <site>" beside a site whose deploy is older than
+// videos the cut cites there. UMTOOL BUILDS AND DEPLOYS NOTHING: it asks the
+// editor (POST /api/ops/build-deploy {siteId}, the shared WORKER_TOKEN), whose
+// publish queue runs the build and then the deploy, one stage at a time, each
+// through the heavy slot -- so in render mode it waits for the render. The
+// editor's refusal (a private site, no Pages project, the publish lane held)
+// is answered in its own words.
+//
+// GET ?project=<id> the sites the cut's links depend on (siteDeploys.mjs)
+// POST { project, siteId } -> { ok, siteId, jobId }: only a site the cut's links open
+const headers = { "cache-control": "no-store" };
+
+async function sitesOf(dir: string) {
+ const m = await readManifest(dir);
+ return projectSites(m ?? {}, await readLinkCheck(dir), { sites: sitesByOrigin(SITES_DIR) });
+}
+
+export async function GET(request: Request) {
+ const url = new URL(request.url);
+ const project = await projectRef(url.searchParams.get("project") ?? "");
+ if (!project) return Response.json({ error: "no such project" }, { status: 404, headers });
+ return Response.json({ sites: await sitesOf(project.dir) }, { headers });
+}
+
+export async function POST(request: Request) {
+ const refused = refuseCaller(request, "/api/report/publish-site");
+ if (refused) return refused;
+ const b = (await request.json().catch(() => null)) as { project?: unknown; siteId?: unknown } | null;
+ if (!b || typeof b !== "object") return Response.json({ error: "bad json" }, { status: 400, headers });
+ const project = await projectRef(String(b.project ?? ""));
+ if (!project) return Response.json({ error: "no such project" }, { status: 404, headers });
+ if (!kindMakesTakes(project.kind)) return Response.json({ error: "publishing a cited site is a report video's" }, { status: 400, headers });
+ const siteId = String(b.siteId ?? "");
+ const sites = await sitesOf(project.dir);
+ if (!sites.some((s) => s.siteId && s.siteId === siteId)) {
+ const named = sites.map((s) => s.siteId).filter(Boolean);
+ return Response.json(
+ { error: `"${siteId}" is not a site this cut's links open${named.length ? ` (they open ${named.join(", ")})` : ""}` },
+ { status: 400, headers },
+ );
+ }
+ try {
+ const r = await askEditor<{ jobId?: string; jobs?: { siteId: string; jobId: string }[] }>("/api/ops/build-deploy", {
+ method: "POST",
+ body: { siteId },
+ });
+ const jobId = r.jobs?.find((j) => j.siteId === siteId)?.jobId ?? r.jobId ?? null;
+ return Response.json({ ok: true, siteId, jobId }, { headers });
+ } catch (e) {
+ const status = e instanceof EditorError ? e.status : 500;
+ return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status, headers });
+ }
+}
diff --git a/umtool/components/projects/report/DecisionSettle.tsx b/umtool/components/projects/report/DecisionSettle.tsx
@@ -42,7 +42,13 @@ export default function DecisionSettle({
headers: { "content-type": "application/json" },
body: JSON.stringify({ project, file: settle.file }),
})
- : await fetch("/api/report/links", {
+ : settle.kind === "publish-site"
+ ? await fetch("/api/report/publish-site", {
+ method: "POST",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify({ project, siteId: settle.siteId }),
+ })
+ : await fetch("/api/report/links", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ project, ...(settle.fix ? { fix: true } : {}) }),
@@ -53,6 +59,7 @@ export default function DecisionSettle({
fixed?: { clip: string }[];
notes?: string[];
left?: { label: string | null; after: string }[];
+ jobId?: string | null;
};
if (!r.ok) {
setErr(j.error ?? `HTTP ${r.status}`);
@@ -68,6 +75,10 @@ export default function DecisionSettle({
`${moved} marker${moved === 1 ? "" : "s"} moved` +
(left.length ? ` · left by hand: ${left.map((l) => `${l.label ? `"${l.label}"` : "a marker"} after ${l.after}`).join(", ")}` : ""),
);
+ } else if (settle.kind === "publish-site") {
+ // The editor's publish queue runs it; nothing here changes until the deploy lands and a check reads it.
+ setSaid(`queued on the editor's publish queue${j.jobId ? ` (job ${j.jobId})` : ""} — Check links once it is deployed`);
+ return;
} else setSaid("saved");
router.refresh();
} catch (e) {
@@ -81,7 +92,7 @@ export default function DecisionSettle({
<span className="inline-flex items-center gap-2" data-settle={settle.kind}>
<button
type="button"
- data-settle-button={settle.kind === "patch" ? settle.clip : settle.kind === "patch-markers" ? settle.file : "links"}
+ data-settle-button={settle.kind === "patch" ? settle.clip : settle.kind === "patch-markers" ? settle.file : settle.kind === "publish-site" ? `publish-${settle.siteId}` : "links"}
disabled={busy}
onClick={() => void run()}
className={buttonVariants({ variant: settle.kind === "patch" ? "go" : "outline", size: "sm" })}
@@ -90,10 +101,12 @@ export default function DecisionSettle({
? `writes ${Object.keys(settle.patch).join(", ")} on ${settle.clip} through the window writer`
: settle.kind === "patch-markers"
? `each marker of ${settle.file} after a clip that is gone takes the cut's marker of the same label`
- : "resolves every clip QR against the site it links (corpus.json → the shard's record), one request at a time per host"
+ : settle.kind === "publish-site"
+ ? `asks the editor to build and deploy ${settle.siteId} (its publish queue, through the heavy slot)`
+ : "resolves every clip QR against the site it links (corpus.json → the shard's record), one request at a time per host"
}
>
- {busy ? (settle.kind === "check-links" ? "Checking…" : "Saving…") : settle.label}
+ {busy ? (settle.kind === "check-links" ? "Checking…" : settle.kind === "publish-site" ? "Asking the editor…" : "Saving…") : settle.label}
</button>
{said && !err && (
<span data-settle-said="" className="text-[11.5px] text-text-2">
diff --git a/umtool/components/projects/report/OverviewTab.tsx b/umtool/components/projects/report/OverviewTab.tsx
@@ -15,6 +15,7 @@ import type { Decision } from "@/lib/decisions";
import type { PieceFrame } from "@/lib/pieces/frame";
import { TONE, hms, type ReportTabProps } from "./shared";
import DecisionSettle from "./DecisionSettle";
+import ProjectSites from "./ProjectSites";
import { manifestToken } from "@/lib/report/manifest.mjs";
// The Overview tab (canvas "Piece · Overview"): the Next card, then the
@@ -117,6 +118,8 @@ export default async function OverviewTab({ project, detail, frame }: ReportTabP
</ul>
</section>
+ <ProjectSites project={project} detail={detail} />
+
{frame.board && (
<section data-piece-board={frame.board.id}>
<h2 className="micro mb-1.5">Research board</h2>
diff --git a/umtool/components/projects/report/ProjectSites.tsx b/umtool/components/projects/report/ProjectSites.tsx
@@ -0,0 +1,84 @@
+import { stat } from "node:fs/promises";
+import { readLinkCheck } from "@/lib/report/linkCheck.mjs";
+import { dayOf, projectSites, sitesByOrigin } from "@/lib/report/siteDeploys.mjs";
+import { SITES_DIR } from "@/lib/paths.mjs";
+import type { ProjectRef } from "@/lib/project-types";
+import DecisionSettle from "./DecisionSettle";
+import type { ClipDetail } from "./shared";
+
+// THE SITES THIS CUT'S LINKS DEPEND ON (UI notes 2026-10-30, #9), on the
+// piece's Overview: each site a clip QR opens, named from its site.json, with
+// its deploy's date -- the corpus.json `generatedAt` the last link check read
+// (out/links.json; this never fetches) -- and the cited videos newer than that
+// deploy. "Publish <site>" asks the editor to build and deploy it; "Check
+// links" reads every site again. The same answer is the check's
+// `site-deploy-behind` row (lib/report/siteDeploys.mjs).
+
+const STATE: Record<string, string> = {
+ ok: "",
+ unreachable: "couldn't reach it at the last check",
+ "no-corpus": "it publishes no corpus.json",
+ unchecked: "not checked yet",
+};
+
+export default async function ProjectSites({ project, detail }: { project: ProjectRef; detail: ClipDetail }) {
+ const m = detail.manifest as Record<string, unknown>;
+ const doc = await readLinkCheck(project.dir);
+ const records = new Map<string, { uploadDate: string | null; landedAt: string | null }>();
+ for (const e of detail.entries) {
+ if (e.kind !== "clip") continue;
+ const cueFile = (e as { cueFile?: string | null }).cueFile;
+ const st = cueFile ? await stat(cueFile).catch(() => null) : null;
+ records.set(e.id, {
+ uploadDate: (e as { uploadDate?: string | null }).uploadDate ?? null,
+ landedAt: st ? new Date(st.mtimeMs).toISOString() : null,
+ });
+ }
+ const sites = projectSites(m, doc, { sites: sitesByOrigin(SITES_DIR), recordOf: (id: string) => records.get(id) ?? null });
+ if (!sites.length) return null;
+ return (
+ <section data-project-sites={sites.length}>
+ <h2 className="micro mb-1.5">Sites the links depend on</h2>
+ <ul className="space-y-1.5">
+ {sites.map((s) => (
+ <li
+ key={s.origin}
+ data-link-site={s.host}
+ data-link-site-id={s.siteId ?? undefined}
+ data-link-site-deployed={dayOf(s.deployedAt) ?? undefined}
+ data-link-site-newer={s.newer.length}
+ className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-1.5 text-[12.5px]"
+ >
+ <div className="flex flex-wrap items-baseline gap-2">
+ <a href={s.origin} target="_blank" rel="noreferrer" className="ink-link font-mono text-[12px]">
+ {s.host}
+ </a>
+ {s.siteId && <span className="text-text-2">{s.siteId}</span>}
+ <span className="ml-auto font-mono text-[11.5px] text-meter">
+ {s.links} link{s.links === 1 ? "" : "s"} · {s.clips.length} clip{s.clips.length === 1 ? "" : "s"}
+ </span>
+ </div>
+ <p className="text-[12px] text-muted" data-link-site-deploy="">
+ {s.deployedAt ? `deployed ${dayOf(s.deployedAt)} (its corpus.json)` : "deploy date unknown"}
+ {STATE[s.state] ? ` · ${STATE[s.state]}` : ""}
+ {doc?.checkedAt ? ` · checked ${doc.checkedAt.slice(0, 16).replace("T", " ")}` : ""}
+ </p>
+ {s.newer.length > 0 && (
+ <p className="text-[12px] text-doubt-text" data-link-site-warning="">
+ {s.newer.length} cited video{s.newer.length === 1 ? " is" : "s are"} newer than this deploy:{" "}
+ {s.newer.slice(0, 6).map((n) => `${n.clip} (${n.why})`).join(", ")}
+ {s.newer.length > 6 ? ` and ${s.newer.length - 6} more` : ""}
+ </p>
+ )}
+ <div className="mt-1 flex flex-wrap items-center gap-2">
+ {s.siteId && s.newer.length > 0 && (
+ <DecisionSettle project={project.id} settle={{ kind: "publish-site", siteId: s.siteId, label: `Publish ${s.siteId}` }} />
+ )}
+ <DecisionSettle project={project.id} settle={{ kind: "check-links", label: doc ? "Check links again" : "Check links" }} />
+ </div>
+ </li>
+ ))}
+ </ul>
+ </section>
+ );
+}
diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md
@@ -26,7 +26,7 @@ Inbox cannot disagree about what is wrong with one.
| `window <project> <clip> --start S --end E --move-stamp first\|nearest\|<s>` · `--clear-stamp` · `--move-mute nearest` · `--clear-mute` | a window edit refused because a stamp's second (`claim.at`, a mark's `at`) or the mute mark would fall outside it, with the fix in the same write: the stamp to the first second that plays, the nearest, or `<s>`, or its `at` cleared; the mute mark to the nearest second, or cleared (never inside a gap). A refused `window` names these flags ([clip-bench.md](clip-bench.md#saving)) |
| `window <project> <clip> --verdict confirmed\|incorrect [--correction T]` · `window <project> <clip> --reject <why> [--note T]` | what the walk said: `--reject` is the walk's **Reject ▾** kept in place (`not-matching`/`wrong-speaker`: incorrect, the note its correction; `irrelevant`/`repeats`/`weak`/`privacy`/`other`: rejected, the note its `rejectNote`); `umtool timeline <p> reject` takes it out ([report-video.md](report-video.md#verdict--what-the-walk-said)) |
| `window <project> <clip> --walk-note T` · `--star` / `--no-star` · `--repeat-of <clip>` | what the walk said that is not a verdict: an editorial note (not a correction) and the ★ favourite, a trailer candidate (`trailer <project> --candidates [--json]` lists them as beats); a deliberate repeat ([knobs.md](knobs.md#a-clip)) |
-| `links <project> [--json] [--fix]` | do the clip QRs open on their sites? `corpus.json` → the channel's manifest → `slugToPage` → the shard's record, one request at a time, shards from the cue cache; recorded in `out/links.json`, which `check` reads (`link-dead` blocking, `links-unverified`, `links-unchecked`); `--fix` rewrites a Twitch id the site serves as `v<id>`; **exit 1** when a link is dead ([knobs.md](knobs.md#do-the-qr-links-open)) |
+| `links <project> [--json] [--fix]` | do the clip QRs open on their sites? `corpus.json` → the channel's manifest → `slugToPage` → the shard's record, one request at a time, shards from the cue cache; recorded in `out/links.json`, which `check` reads (`link-dead` blocking, `links-unverified`, `links-unchecked`); `--fix` rewrites a Twitch id the site serves as `v<id>`; **exit 1** when a link is dead ([knobs.md](knobs.md#do-the-qr-links-open)). The same record dates each site's deploy: a cited video newer than it is `site-deploy-behind` ([knobs.md](knobs.md#the-sites-the-links-depend-on)) |
| `patch-markers <project> [<file>.patch.json] [--fix] [--json]` | take patches whose deck markers name a clip not in the cut (a take made with one is refused); `--fix` gives each the `after` of the cut's marker of the same label; **exit 1** when one is left ([knobs.md](knobs.md#take-patches-follow-a-removal)) |
| `window <project> <clip> --take <take> …` | a **take's** clip (walk a take): the same fields, written into the take's patch (`takes/<take>/take.json`) with an undo point first; the project's manifest is untouched ([clip-bench.md](clip-bench.md#walking-a-take)) |
| `walk <project> [--take <take>] [--all] [--json]` | the clip bench's **walk**: every clip in walk order with its window, verdict and whether a fetched file holds it, and (→) the ones the walk visits — fetched and needing a verdict; `--all` every fetched one; `--take` walks a take (a draft too); the bench's address to start at |
diff --git a/umtool/docs/inbox.md b/umtool/docs/inbox.md
@@ -70,6 +70,7 @@ on (`decisionTab`, `songTabOfSection`).
| `link-dead` | blocking | the recorded link check (`umtool links`, out/links.json) found clip QRs that don't open on their site — one row per site, the clips and the first reason | Fix the links |
| `links-unverified` | info | the link check could not reach a site (offline, a timeout, no corpus.json) | Check links again |
| `links-unchecked` | info | archive links never checked, or changed since the check | Check links |
+| `site-deploy-behind` | open | a site the QRs open whose deploy (its recorded corpus.json `generatedAt`) is older than cited videos whose links the check did not find open — one row per site ([knobs.md](knobs.md#the-sites-the-links-depend-on)) | Publish <site> |
| `no-punctuation` | info | a source's ASR has no terminators — one row per project | Check the windows |
| `clip-cue-gap` | open | the cue file ends before a clip does (`cues end 880 s · c03 needs 897 s`), one row per source | Fix the window |
| `claim-unadjudicated` | blocking | a `ledger[]` entry missing any of the six adjudication fields — one row per entry | Adjudicate claim |
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -87,6 +87,19 @@ site: *12 of 124 QR links don't open on anilyzer.pages.dev (deployed 2026-10-09)
the site serves as `v<id>`, and only a link still exactly what the check saw — through the window writer,
then checks again. A platform link (YouTube's own page) is not an archive link and is not checked.
+### The sites the links depend on
+
+The project page's Overview names every site a clip QR opens (**Sites the links depend on**): the site
+whose `site.json` `siteUrl` is that origin, how many links and clips it carries, and its deploy's date
+— the `corpus.json` `generatedAt` the last link check read (`out/links.json`; the page never fetches;
+**Check links** reads them again). A cited video **newer than that deploy** — uploaded after it, or
+transcribed here after it — whose link the check did not find open is named under it, and is the
+check's `site-deploy-behind` row (open, one per site): *anilyzer's deploy is from 2026-10-09; 3 cited
+videos are newer: …*. Its **Publish anilyzer** asks the editor to build and deploy that site (`POST
+/api/report/publish-site {project, siteId}` → the editor's ops `build-deploy`, its publish queue, each
+stage through the heavy slot); from a terminal, `pnpm ops build-deploy --json '{"siteId":"anilyzer"}'`.
+A link the check opened is on the site, whatever its dates say.
+
## Gaps inside a clip
A clip may leave seconds out of its middle: you suggest one long clip and cut a gap or two out of it, rather than
diff --git a/umtool/e2e/fixtures/editor-stub.mjs b/umtool/e2e/fixtures/editor-stub.mjs
@@ -938,6 +938,17 @@ function generationRoute(req, res, url, auth) {
req.resume();
return json(res, 200, { ok: true, key: "autoQueue", value: lanes });
}
+ // "Publish <site>" (umtool's /api/report/publish-site, UI notes #9): the
+ // editor's build-deploy alias. Recorded; a site named "refused" is refused
+ // the way the editor refuses a private one.
+ if (req.method === "POST" && url.pathname === "/api/ops/build-deploy") {
+ return readBody(req, (body) => {
+ requests.push({ route: "build-deploy", ...(body ?? {}), authorization: auth });
+ record();
+ if (body?.siteId === "refused") return json(res, 400, { ok: false, error: "refused is private: it never deploys" });
+ return json(res, 200, { ok: true, jobId: `deploy-${nextJob}`, jobs: [{ siteId: body?.siteId, jobId: `deploy-${nextJob++}` }], skipped: [] });
+ });
+ }
if (req.method === "POST" && url.pathname === "/api/ops/lane") {
return readBody(req, (body) => {
requests.push({ route: "lane", ...(body ?? {}), authorization: auth });
diff --git a/umtool/lib/decisions.ts b/umtool/lib/decisions.ts
@@ -89,7 +89,8 @@ export type Decision = {
settle?:
| { kind: "patch"; clip: string; patch: Record<string, unknown>; label: string }
| { kind: "check-links"; label: string; fix?: boolean }
- | { kind: "patch-markers"; file: string; label: string };
+ | { kind: "patch-markers"; file: string; label: string }
+ | { kind: "publish-site"; siteId: string; label: string };
/** The clips a project-wide row is about (a site's dead links). */
clips?: string[];
diff --git a/umtool/lib/inbox/groups.mjs b/umtool/lib/inbox/groups.mjs
@@ -133,6 +133,7 @@ const ACTION_LABEL = {
"link-dead": "Fix the links",
"links-unverified": "Check links again",
"links-unchecked": "Check links",
+ "site-deploy-behind": (d) => (d.settle?.kind === "publish-site" ? d.settle.label : "Publish the site"),
"no-punctuation": "Check the windows",
"manifest-invalid": "Fix the manifest",
"stale-build": "Rebuild the video",
diff --git a/umtool/lib/inbox/what.mjs b/umtool/lib/inbox/what.mjs
@@ -38,6 +38,7 @@ export const WHAT = {
"link-dead": "QR links that don't open",
"links-unverified": "links not verified",
"links-unchecked": "links not checked",
+ "site-deploy-behind": "a cited site's deploy is behind the cut",
"no-punctuation": "windows without punctuation",
"manifest-invalid": "manifest invalid",
"stale-build": "video out of date",
diff --git a/umtool/lib/projects/report.mjs b/umtool/lib/projects/report.mjs
@@ -18,7 +18,7 @@ import { rawCacheOf } from "../report/raw-cache.mjs";
import { rejectionOf } from "../report/rejectReasons.mjs";
import { resolveVideoDirSync } from "yt-dlp-transcript-common/lib/videoDir-server.mjs";
import { deliverablesState, finishCommand, outDirState, leftoversOf } from "../report/storage.mjs";
-import { CHANNELS_DIR, inside, resolveInRoots } from "../paths.mjs";
+import { CHANNELS_DIR, SITES_DIR, inside, resolveInRoots } from "../paths.mjs";
import { channelName, cleanTitle } from "umtool-report-to-video/attribution";
import { archiveMomentUrl } from "umtool-report-to-video/site-links";
import { deckOn, resolveDeck, teaserTitle } from "umtool-report-to-video/deck";
@@ -46,6 +46,7 @@ import { fileSig, pathCache } from "../pathCache.mjs";
import { citeOffsets } from "../report/citeFollow.mjs";
import { PATCH_FILE_RE, stalePatchMarkers } from "../report/patchMarkers.mjs";
import { linkVerdicts, linksFile, readLinkCheck } from "../report/linkCheck.mjs";
+import { deployBehindWhy, projectSites, sitesByOrigin } from "../report/siteDeploys.mjs";
// widen() and the cache's window naming are IMPORTED, never reimplemented. The
// bench's "extend to sentence end" has to be the same function the CLI runs, or
@@ -1071,6 +1072,10 @@ export const REPORT_DECISION_KINDS = [
"links-unverified",
// Links never checked, or changed since the check. `info`, with Check links.
"links-unchecked",
+ // A site the QRs open whose deploy (its recorded corpus.json generatedAt)
+ // is older than videos the cut cites there, and the check did not find
+ // those open (siteDeploys.mjs). `open`, with Publish <site>.
+ "site-deploy-behind",
];
/**
@@ -1225,6 +1230,8 @@ export async function reportDecisions(ctx, summary) {
}
const unpunctuated = [];
+ /** @type {Map<string, { uploadDate: string | null, landedAt: string | null }>} */
+ const recordByClip = new Map();
for (const [key, list] of byVideo) {
const file = cuePathFor(m, list[0], channelsDir);
const doc = file ? await readCues(file) : null;
@@ -1248,6 +1255,12 @@ export async function reportDecisions(ctx, summary) {
}
if (doc.punctuationRate < 0.1) unpunctuated.push(key);
+ // What the site-deploy row reads (siteDeploys.mjs): the recording's upload
+ // date and when its transcript landed here.
+ {
+ const st = await stat0(file);
+ for (const e of list) recordByClip.set(e.id, { uploadDate: doc.uploadDate ?? null, landedAt: st ? new Date(st.mtimeMs).toISOString() : null });
+ }
for (const e of list) {
// The standing rule, mechanised. One 14-clip cut shipped with 8 clips
@@ -1618,6 +1631,22 @@ export async function reportDecisions(ctx, summary) {
}
}
+ // --- is each site's deploy recent enough? (siteDeploys.mjs) --------------
+ // From the same recorded check: the deploy's date is its corpus.json's
+ // generatedAt. A cited video newer than it, whose link the check did not
+ // find open, is not on the site yet.
+ {
+ const doc = await readLinkCheck(dir);
+ for (const site of projectSites(m, doc, { sites: sitesByOrigin(SITES_DIR), recordOf: (cid) => recordByClip.get(cid) ?? null })) {
+ if (!site.newer.length) continue;
+ add("site-deploy-behind", site.host, deployBehindWhy(site), "open", {
+ fix: site.siteId ? `pnpm ops build-deploy --json '{"siteId":"${site.siteId}"}'` : `umtool links ${id}`,
+ ...(site.siteId ? { settle: { kind: "publish-site", siteId: site.siteId, label: `Publish ${site.siteId}` } } : {}),
+ clips: site.newer.map((n) => n.clip),
+ });
+ }
+ }
+
// --- the build -----------------------------------------------------------
if (s.build.stale) {
add(
diff --git a/umtool/lib/report/siteDeploys.mjs b/umtool/lib/report/siteDeploys.mjs
@@ -0,0 +1,155 @@
+// Which sites does this cut's QR links depend on, and is each one's deploy
+// recent enough to hold what the cut cites? (UI notes 2026-10-30, #9)
+//
+// On the Ember cut anilyzer's publish policy was "build" only: nothing said
+// the video being made cited a site that had not been deployed since 9 Oct.
+// The link check (linkCheck.mjs, #8) already reads each site's corpus.json and
+// records its `generatedAt` -- the day the deployed bundle's data was built --
+// in out/links.json. This module reads that record (it never fetches):
+//
+// - the SITES: every origin a clip QR the cut draws opens (linksOf), each
+// named by the site whose site.json `siteUrl` it is (SITES_DIR, read only)
+// and dated by the recorded corpus.json;
+// - the cited videos NEWER than that deploy: a clip on that site whose
+// recording was uploaded after it, or whose transcript landed here after
+// it, and whose link the check did not find open (a link the check opened
+// is on the site, whatever its dates say).
+//
+// The check row `site-deploy-behind` (lib/projects/report.mjs) is one per site
+// with such clips, its settle "Publish <site>" asking the editor to build and
+// deploy that site (POST /api/report/publish-site -> the editor's ops
+// build-deploy). Plain ESM: the CLI runs it under bare node.
+import { readdirSync, readFileSync } from "node:fs";
+import path from "node:path";
+import { archiveLinkOf, linksOf } from "./linkCheck.mjs";
+
+/** `https://x.pages.dev/` -> `https://x.pages.dev`; null for anything not http(s). */
+export function originOf(url) {
+ try {
+ const u = new URL(String(url));
+ return u.protocol === "http:" || u.protocol === "https:" ? u.origin : null;
+ } catch {
+ return null;
+ }
+}
+
+/**
+ * Every site with a `siteUrl`, by its origin: `{ siteId, title }`. Read once
+ * per call (a handful of small files); a site.json that does not parse is
+ * skipped.
+ * @param {string} sitesDir
+ * @returns {Map<string, { siteId: string, title: string | null }>}
+ */
+export function sitesByOrigin(sitesDir) {
+ const out = new Map();
+ let ids = [];
+ try {
+ ids = readdirSync(/* turbopackIgnore: true */ sitesDir);
+ } catch {
+ return out;
+ }
+ for (const id of ids.sort()) {
+ let doc;
+ try {
+ doc = JSON.parse(readFileSync(/* turbopackIgnore: true */ path.join(sitesDir, id, "site.json"), "utf8"));
+ } catch {
+ continue;
+ }
+ const origin = originOf(doc?.siteUrl);
+ if (!origin || out.has(origin)) continue;
+ out.set(origin, { siteId: id, title: typeof doc?.siteTitle === "string" ? doc.siteTitle : typeof doc?.title === "string" ? doc.title : null });
+ }
+ return out;
+}
+
+/** `20261020` / `2026-10-20` / an ISO time -> `2026-10-20`, else null. */
+export function dayOf(v) {
+ const s = String(v ?? "").trim();
+ if (/^\d{8}$/.test(s)) return `${s.slice(0, 4)}-${s.slice(4, 6)}-${s.slice(6, 8)}`;
+ const m = /^(\d{4}-\d{2}-\d{2})/.exec(s);
+ return m ? m[1] : null;
+}
+
+/**
+ * The sites the cut's links depend on, with each one's deploy and the cited
+ * videos newer than it. Pure over its inputs.
+ *
+ * @param {Record<string, any>} m the manifest
+ * @param {{ origins?: Record<string, any>, links?: Array<{ clip: string, url: string, state: string }>, checkedAt?: string } | null} linkDoc out/links.json
+ * @param {{ sites?: Map<string, { siteId: string, title: string | null }>, recordOf?: (clipId: string) => { uploadDate?: string | null, landedAt?: string | null } | null }} [opts]
+ * `recordOf`: what is known of the clip's recording here -- its upload date
+ * and when its transcript landed (the cue file's mtime, ISO).
+ * @returns {Array<{
+ * origin: string, host: string, siteId: string | null, title: string | null,
+ * deployedAt: string | null, state: "ok" | "unreachable" | "no-corpus" | "unchecked",
+ * clips: string[], links: number,
+ * newer: Array<{ clip: string, why: string, day: string }>,
+ * }>}
+ */
+export function projectSites(m, linkDoc, { sites = new Map(), recordOf = () => null } = {}) {
+ /** @type {Map<string, { clips: Set<string>, links: Array<{ clip: string, url: string }> }>} */
+ const by = new Map();
+ for (const l of linksOf(m)) {
+ const a = archiveLinkOf(l.url);
+ if (!a) continue;
+ if (!by.has(a.origin)) by.set(a.origin, { clips: new Set(), links: [] });
+ const g = /** @type {{ clips: Set<string>, links: Array<{ clip: string, url: string }> }} */ (by.get(a.origin));
+ g.clips.add(l.clip);
+ g.links.push(l);
+ }
+ const checked = new Map((linkDoc?.links ?? []).map((l) => [`${l.clip}\u0000${l.url}`, l.state]));
+ const out = [];
+ for (const [origin, g] of by) {
+ const o = linkDoc?.origins?.[origin] ?? null;
+ const deployedAt = typeof o?.generatedAt === "string" ? o.generatedAt : null;
+ const deployDay = dayOf(deployedAt);
+ const site = sites.get(origin) ?? null;
+ const newer = [];
+ if (deployDay) {
+ const seen = new Set();
+ for (const l of g.links) {
+ if (seen.has(l.clip)) continue;
+ // The check opened it: the record is on the site.
+ if (checked.get(`${l.clip}\u0000${l.url}`) === "ok") continue;
+ const r = recordOf(l.clip) ?? {};
+ const up = dayOf(r.uploadDate);
+ const landed = dayOf(r.landedAt);
+ if (up && up > deployDay) {
+ seen.add(l.clip);
+ newer.push({ clip: l.clip, why: `uploaded ${up}`, day: up });
+ } else if (landed && landed > deployDay) {
+ seen.add(l.clip);
+ newer.push({ clip: l.clip, why: `transcribed here ${landed}`, day: landed });
+ }
+ }
+ }
+ let host = origin;
+ try {
+ host = new URL(origin).host;
+ } catch {
+ /* the origin as written */
+ }
+ out.push({
+ origin,
+ host,
+ siteId: site?.siteId ?? null,
+ title: site?.title ?? (typeof o?.title === "string" ? o.title : null),
+ deployedAt,
+ state: o ? o.state : "unchecked",
+ clips: [...g.clips],
+ links: g.links.length,
+ newer,
+ });
+ }
+ return out.sort((a, b) => b.links - a.links || a.host.localeCompare(b.host));
+}
+
+/** The check row's sentence for one site with newer videos. */
+export function deployBehindWhy(s) {
+ const list = s.newer.slice(0, 6).map((n) => `${n.clip} (${n.why})`).join(", ");
+ const more = s.newer.length > 6 ? ` and ${s.newer.length - 6} more` : "";
+ return (
+ `${s.siteId ?? s.host}'s deploy is from ${dayOf(s.deployedAt)}; ${s.newer.length} cited video${s.newer.length === 1 ? " is" : "s are"} newer: ${list}${more}` +
+ ` — publish the site before the video ships, or link elsewhere`
+ );
+}
diff --git a/umtool/lib/report/ui-ops.test.mjs b/umtool/lib/report/ui-ops.test.mjs
@@ -0,0 +1,149 @@
+// Operations UI (UI notes 2026-10-30): the sites a cut's links depend on and
+// their deploys (#9).
+//
+// Run with: pnpm test:scripts
+import assert from "node:assert/strict";
+import { mkdir, mkdtemp, readFile, rm, utimes, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import test from "node:test";
+
+// SITES_DIR is read when lib/paths.mjs loads: point it at this file's own
+// sites before anything imports it.
+const SITES = await mkdtemp(path.join(tmpdir(), "ui-ops-sites-"));
+process.env.SITES_DIR = SITES;
+await mkdir(path.join(SITES, "anilyzer"), { recursive: true });
+await writeFile(path.join(SITES, "anilyzer", "site.json"), JSON.stringify({ siteTitle: "Anilyzer", siteUrl: "https://site.test/" }));
+await mkdir(path.join(SITES, "other"), { recursive: true });
+await writeFile(path.join(SITES, "other", "site.json"), JSON.stringify({ siteTitle: "Other", siteUrl: "https://other.test" }));
+test.after(() => rm(SITES, { recursive: true, force: true }));
+
+const { dayOf, deployBehindWhy, originOf, projectSites, sitesByOrigin } = await import("./siteDeploys.mjs");
+const { runLinkCheck } = await import("./linkCheck.mjs");
+const { decisionsFor } = await import("../projects/core.mjs");
+const { walkProjects } = await import("../projects/walk.mjs");
+
+const SITE = "https://site.test";
+const url = (chan, id, t, site = SITE) => `${site}/?v=${encodeURIComponent(`${chan}/${id}`)}&t=${t}`;
+const manifestOf = (timeline, extra = {}) => ({
+ schemaVersion: 1,
+ slug: "cut",
+ title: "Cut",
+ provenance: { channelSlug: "c", siteOrigin: SITE },
+ render: { width: 1920, height: 1080, fps: 30 },
+ timeline,
+ ...extra,
+});
+
+/** A fake archive: corpus.json generatedAt 2026-10-09, channel c holding `ids`. */
+function fakeSite(ids = ["v1"]) {
+ return async (u) => {
+ const p = new URL(String(u)).pathname;
+ const json = (doc) => ({ ok: true, status: 200, json: async () => doc });
+ if (p === "/corpus.json") {
+ return json({ spec: 5, generatedAt: "2026-10-09T10:00:00.000Z", site: { title: "Site" }, channels: [{ slug: "c", manifests: { transcripts: `${SITE}/transcripts/c/manifest.json` } }] });
+ }
+ if (p === "/transcripts/c/manifest.json") return json({ pageCount: 1, slugToPage: Object.fromEntries(ids.map((i) => [i, 0])) });
+ if (p === "/transcripts/c/page-0000.json") return json(ids.map((id) => ({ id })));
+ return { ok: false, status: 404, json: async () => ({}) };
+ };
+}
+
+/** A project in a temp root: channel c's v1..v3, each with cues and an upload date. */
+async function project(timeline, { uploads = {}, landed = {}, extra = {} } = {}) {
+ const root = await mkdtemp(path.join(tmpdir(), "ui-ops-"));
+ const channelsDir = path.join(root, "channels");
+ const reportsRoot = path.join(root, "reports");
+ for (const v of ["v1", "v2", "v3"]) {
+ const vdir = path.join(channelsDir, "c", "data", v);
+ await mkdir(vdir, { recursive: true });
+ const cues = Array.from({ length: 200 }, (_, i) => ({ start: i, end: i + 1, text: `Line ${i}.` }));
+ const file = path.join(vdir, "transcript.cues.json");
+ await writeFile(file, JSON.stringify({ cues, uploadDate: uploads[v] ?? "20260901", webpageUrl: `https://www.youtube.com/watch?v=${v}` }));
+ const at = new Date(landed[v] ?? "2026-09-02T00:00:00Z");
+ await utimes(file, at, at);
+ }
+ const dir = path.join(reportsRoot, "cut");
+ await mkdir(dir, { recursive: true });
+ const m = manifestOf(timeline.map((e) => ({ type: "clip", channel: "c", video: "v1", lock: true, ...e })), extra);
+ m.provenance.channelsDir = path.relative(dir, channelsDir);
+ await writeFile(path.join(dir, "video.manifest.json"), `${JSON.stringify(m, null, 2)}\n`);
+ const decisions = async () => {
+ const [ref] = (await walkProjects(reportsRoot)).filter((p) => p.id === "cut");
+ return decisionsFor(ref, reportsRoot);
+ };
+ const manifest = async () => JSON.parse(await readFile(path.join(dir, "video.manifest.json"), "utf8"));
+ return { root, reportsRoot, dir, channelsDir, decisions, manifest, done: () => rm(root, { recursive: true, force: true }) };
+}
+
+// ---- #9 the sites a cut's links depend on -----------------------------------
+
+test("originOf, dayOf, sitesByOrigin: a site is named by the origin of its siteUrl", () => {
+ assert.equal(originOf("https://site.test/"), "https://site.test");
+ assert.equal(originOf("mailto:x@y"), null);
+ assert.equal(dayOf("20261020"), "2026-10-20");
+ assert.equal(dayOf("2026-10-09T10:00:00.000Z"), "2026-10-09");
+ assert.equal(dayOf("soon"), null);
+ const s = sitesByOrigin(SITES);
+ assert.deepEqual(s.get("https://site.test"), { siteId: "anilyzer", title: "Anilyzer" });
+ assert.equal(sitesByOrigin(path.join(SITES, "nope")).size, 0);
+});
+
+test("projectSites: each origin with its deploy; videos newer than it, unless the check opened their link", () => {
+ const m = manifestOf([
+ { type: "clip", id: "a", video: "v1", start: 10, end: 20 },
+ { type: "clip", id: "b", video: "v2", start: 10, end: 20 },
+ { type: "clip", id: "c", video: "v3", start: 10, end: 20 },
+ { type: "clip", id: "d", video: "v3", start: 30, end: 40, citeUrl: url("c", "v3", 30, "https://other.test") },
+ { type: "clip", id: "y", video: "yt", start: 1, end: 2, citeUrl: "https://www.youtube.com/watch?v=yt&t=1s" },
+ ]);
+ const doc = {
+ checkedAt: "2026-11-01T10:00:00.000Z",
+ origins: { [SITE]: { state: "ok", generatedAt: "2026-10-09T10:00:00.000Z" } },
+ links: [
+ { clip: "a", url: url("c", "v1", 10), state: "ok" },
+ { clip: "b", url: url("c", "v2", 10), state: "dead" },
+ ],
+ };
+ const rec = { a: { uploadDate: "20261020" }, b: { uploadDate: "20261020" }, c: { uploadDate: "20260101", landedAt: "2026-10-21T08:00:00Z" }, d: { uploadDate: "20261030" } };
+ const sites = projectSites(m, doc, { sites: sitesByOrigin(SITES), recordOf: (id) => rec[id] ?? null });
+ assert.deepEqual(
+ sites.map((s) => [s.host, s.siteId, s.state, s.deployedAt, s.links, s.newer.map((n) => `${n.clip} ${n.why}`)]),
+ [
+ // a was opened by the check: on the site, whatever its date says.
+ ["site.test", "anilyzer", "ok", "2026-10-09T10:00:00.000Z", 3, ["b uploaded 2026-10-20", "c transcribed here 2026-10-21"]],
+ // Never checked: no deploy date, so nothing can be newer than it.
+ ["other.test", "other", "unchecked", null, 1, []],
+ ],
+ );
+ assert.equal(
+ deployBehindWhy(sites[0]),
+ "anilyzer's deploy is from 2026-10-09; 2 cited videos are newer: b (uploaded 2026-10-20), c (transcribed here 2026-10-21) — publish the site before the video ships, or link elsewhere",
+ );
+});
+
+test("the check: site-deploy-behind, one row per site with newer videos, its settle Publish <site>", async () => {
+ const p = await project(
+ [{ id: "a", video: "v1", start: 10, end: 20, cite: 10 }, { id: "b", video: "v2", start: 10, end: 20, cite: 10 }],
+ { uploads: { v2: "20261020" } },
+ );
+ try {
+ // Never checked: no deploy date, no row.
+ assert.equal((await p.decisions()).filter((d) => d.kind === "site-deploy-behind").length, 0);
+ // The site has v1 only (built 9 Oct); v2 was uploaded on the 20th.
+ await runLinkCheck(p.dir, await p.manifest(), { fetchImpl: fakeSite(["v1"]), cacheDir: null, gapMs: 0 });
+ const rows = (await p.decisions()).filter((d) => d.kind === "site-deploy-behind");
+ assert.equal(rows.length, 1);
+ assert.equal(rows[0].severity, "open");
+ assert.equal(rows[0].target, "site.test");
+ assert.match(rows[0].why, /^anilyzer's deploy is from 2026-10-09; 1 cited video is newer: b \(uploaded 2026-10-20\)/);
+ assert.deepEqual(rows[0].settle, { kind: "publish-site", siteId: "anilyzer", label: "Publish anilyzer" });
+ assert.equal(rows[0].fix, `pnpm ops build-deploy --json '{"siteId":"anilyzer"}'`);
+ assert.deepEqual(rows[0].clips, ["b"]);
+ // Redeployed with v2: the check opens it, and the row goes.
+ await runLinkCheck(p.dir, await p.manifest(), { fetchImpl: fakeSite(["v1", "v2"]), cacheDir: null, gapMs: 0 });
+ assert.equal((await p.decisions()).filter((d) => d.kind === "site-deploy-behind").length, 0);
+ } finally {
+ await p.done();
+ }
+});