commit fa27a90d60bdd39677586f200ac53abbd7f9b404
parent 0322c2868ab9d58a8f1a2fc11023f38e7d186111
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 9 Nov 2026 20:23:40 -0500
umtool: What needs you -- the Inbox's new calls: versions to judge, clips not walked, stale quote checks, a live case's new transcripts, X's jar; one-press settles on the cards (redesign L4)
- lib/inbox/{versions,walk,checks,caseCues,xJar}.mjs: pure, never throw; projectCalls.ts,
caseCues.ts, xJar.ts read the disk and the editor's services (askEditor, memoised,
waited on at most 1.5 s). diskDecisions adds them.
- groups.mjs: the kinds' groups, ranks and actions (Play and judge, Walk the clips, Run
quote-check, Scan again, Refresh X's cookies); mergeSettle gives a card the settle its
rows agree on.
- report.mjs: a moved quote's row settles by snapping the cut to the words (alignPatch),
a missing one by Run quote-check; a dead Rumble folder-id QR's settle is "Use embed ids".
- links route: fix through linksCli.mjs applyLinkFixes, the CLI's own path (siteVideo for
a Rumble folder id, one undo point).
- DecisionSettle: the quote-check press (POST /api/cli), size/className for the Inbox.
- InboxList: a card with a settle presses it in place; its title links where it is settled.
- needs-you.test.ts: the rows, the merge, and each source read from a temp tree and a
stand-in editor.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
21 files changed, 1028 insertions(+), 46 deletions(-)
diff --git a/umtool/app/api/report/links/route.ts b/umtool/app/api/report/links/route.ts
@@ -2,8 +2,7 @@ import { projectRef } from "@/lib/projects";
import { readManifest } from "@/lib/projects/report.mjs";
import { linkVerdicts, readLinkCheck, runLinkCheck } from "@/lib/report/linkCheck.mjs";
import { refuseCaller } from "@/lib/report/caller";
-import { withEditNotes } from "@/lib/report/guard";
-import { updateClip } from "@/lib/report/manifest.mjs";
+import { applyLinkFixes } from "@/lib/report/linksCli.mjs";
export const dynamic = "force-dynamic";
@@ -17,7 +16,10 @@ export const dynamic = "force-dynamic";
// GET ?project=<id> the recorded check (out/links.json) read against the manifest as it is now
// POST { project, fix? } check now, record it, and answer the same; `fix`: first
// rewrite every dead link the last check knows the fix for
-// (a Twitch id the site serves as v<id>) through the window writer
+// (a Twitch id the site serves as v<id>; a Rumble folder id as the
+// embed id the archive serves, `siteVideo` -- "Use embed ids")
+// through the window writer, after one undo point (linksCli.mjs
+// applyLinkFixes, `umtool links <p> --fix`'s own)
const headers = { "cache-control": "no-store" };
async function answer(dir: string, doc: Awaited<ReturnType<typeof readLinkCheck>>) {
@@ -43,16 +45,10 @@ export async function POST(request: Request) {
let m = await readManifest(project.dir);
if (!m) return Response.json({ error: "the project has no video.manifest.json" }, { status: 400, headers });
try {
- const fixed: { clip: string; from: string; to: string }[] = [];
+ let fixed: { clip: string; from: string; to: string; siteVideo?: string }[] = [];
if (b.fix === true) {
- const last = await readLinkCheck(project.dir);
- const now = new Map(((m.timeline ?? []) as { id: string; citeUrl?: string }[]).map((e) => [e.id, e.citeUrl]));
- for (const l of last?.links ?? []) {
- // Only a link still exactly what the check saw: an edit since is somebody's decision.
- if (l.state !== "dead" || !l.fix || now.get(l.clip) !== l.url) continue;
- await withEditNotes(project, () => updateClip(project.dir, l.clip, { citeUrl: l.fix }));
- fixed.push({ clip: l.clip, from: l.url, to: l.fix });
- }
+ // Only a clip still as the recorded check saw it: an edit since is somebody's decision.
+ fixed = (await applyLinkFixes(project, m, await readLinkCheck(project.dir), { guard: true })).fixed;
if (fixed.length) m = await readManifest(project.dir);
}
const doc = await runLinkCheck(project.dir, m);
diff --git a/umtool/app/page.tsx b/umtool/app/page.tsx
@@ -71,6 +71,8 @@ function toCard(group: string, c: GroupCard, lifecycle: LifecycleState, muted =
lifecycle,
...(muted ? { muted } : {}),
finish: c.kind === "looks-done",
+ project: c.project,
+ settle: c.settle ?? null,
};
}
diff --git a/umtool/components/inbox/InboxList.tsx b/umtool/components/inbox/InboxList.tsx
@@ -9,6 +9,8 @@ import { cn } from "@/lib/utils";
import { LifecycleButton, MuteButton, type LifecycleState } from "@/components/piece/Lifecycle";
import Menu from "@/components/piece/Menu";
import { PhoneOnly } from "@/components/shell/phone";
+import DecisionSettle from "@/components/projects/report/DecisionSettle";
+import type { Decision } from "@/lib/decisions";
// ---------------------------------------------------------------------------
// The Inbox's cards as ONE lit list (canvas "Inbox"): a group head, then a
@@ -45,6 +47,14 @@ export type InboxCard = {
finish?: boolean;
/** A report video's Play address (at the card's note), when the piece has one. */
play?: string | null;
+ /** The project the card's rows are about (its settle is pressed on it). */
+ project?: string;
+ /**
+ * ONE-CLICK (umtool redesign L4): the settle its rows agree on (lib/inbox/groups.mjs mergeSettle), pressed
+ * in place -- Use embed ids, Run quote-check, Snap the cut to the words, Check links -- through the
+ * routes the project page's Checks list presses (DecisionSettle). The card's title links where it is settled.
+ */
+ settle?: Decision["settle"] | null;
};
export type InboxGroup = {
@@ -117,6 +127,8 @@ export default function InboxList({ groups }: { groups: InboxGroup[] }) {
function Card({ card: c }: { card: InboxCard }) {
const parked = c.lifecycle !== "active";
+ // Pressed in place only on an active, unmuted card: a hidden one's action is its way back.
+ const oneClick = !!(c.settle && c.project && !parked && !c.muted && !c.finish);
return (
<LitLine
id={c.key}
@@ -132,7 +144,15 @@ function Card({ card: c }: { card: InboxCard }) {
>
<div className="min-w-0 basis-full sm:basis-auto">
<b className="line-clamp-2 font-medium text-inherit sm:block sm:truncate" data-card-title="">
- {c.title} <span className="font-normal text-muted-2">·</span> {c.what}
+ {oneClick ? (
+ <Link href={c.action.href} prefetch={false} data-card-link="" className="text-inherit no-underline hover:underline" title={c.action.label}>
+ {c.title} <span className="font-normal text-muted-2">·</span> {c.what}
+ </Link>
+ ) : (
+ <>
+ {c.title} <span className="font-normal text-muted-2">·</span> {c.what}
+ </>
+ )}
</b>
<small className="line-clamp-2 text-[12px] text-muted-2 sm:block sm:truncate">{c.why}</small>
</div>
@@ -146,6 +166,10 @@ function Card({ card: c }: { card: InboxCard }) {
<LifecycleButton piece={c.piece} title={c.title} from={c.lifecycle} to="active" label="Reactivate" variant="outline" size="md" className="lit-go max-md:min-h-11" />
) : c.finish && c.piece ? (
<LifecycleButton piece={c.piece} title={c.title} from={c.lifecycle} to="done" label="Mark done" variant="outline" size="md" className="lit-go max-md:min-h-11" />
+ ) : oneClick && c.settle && c.project ? (
+ <span data-card-settle={c.settle.kind}>
+ <DecisionSettle project={c.project} settle={c.settle} size="md" className="lit-go max-md:min-h-11" />
+ </span>
) : (
<Link href={c.action.href} prefetch={false} data-action-link="" className={cn(buttonVariants({ variant: "outline", size: "md" }), "lit-go max-md:min-h-11")}>
{c.action.label}
diff --git a/umtool/components/projects/report/DecisionSettle.tsx b/umtool/components/projects/report/DecisionSettle.tsx
@@ -3,22 +3,32 @@
import { useState } from "react";
import { useRouter } from "next/navigation";
import { buttonVariants } from "@/components/ui/button";
+import { cn } from "@/lib/utils";
import type { Decision } from "@/lib/decisions";
// The one-press settle beside a check row (lib/projects/report.mjs `settle`):
// a clip patch through the window writer -- "It's deliberate: b repeats a"
// (repeatOf), "Move to 12:34" (the clock and the QR back on the clip) -- or a
-// link check against the sites the QRs open. The row's `fix` is the same
-// thing from a terminal; nothing here needs a model.
+// link check against the sites the QRs open (with `fix`: the dead links whose
+// fix is known rewritten first -- a Twitch id as v<id>, a Rumble folder id as
+// its embed id, "Use embed ids"), or a quote check on the durable queue (POST
+// /api/cli, the registry's `quote-check` row: it transcribes through the
+// editor, so it queues). The row's `fix` is the same thing from a terminal;
+// nothing here needs a model. The Inbox's cards press the same buttons (L4).
export default function DecisionSettle({
project,
settle,
token = null,
+ size = "sm",
+ className,
}: {
project: string;
settle: NonNullable<Decision["settle"]>;
token?: string | null;
+ /** The Inbox's card draws it as its primary action: `md`, lit. */
+ size?: "sm" | "md";
+ className?: string;
}) {
const router = useRouter();
const [busy, setBusy] = useState(false);
@@ -42,6 +52,12 @@ export default function DecisionSettle({
headers: { "content-type": "application/json" },
body: JSON.stringify({ project, file: settle.file }),
})
+ : settle.kind === "quote-check"
+ ? await fetch("/api/cli", {
+ method: "POST",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify({ verb: "quote-check", values: { project, "--clips": settle.clips.join(",") } }),
+ })
: settle.kind === "publish-site"
? await fetch("/api/report/publish-site", {
method: "POST",
@@ -60,6 +76,7 @@ export default function DecisionSettle({
notes?: string[];
left?: { label: string | null; after: string }[];
jobId?: string | null;
+ queued?: { qid: string } | null;
};
if (!r.ok) {
setErr(j.error ?? `HTTP ${r.status}`);
@@ -75,6 +92,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 === "quote-check") {
+ // The queue runs it (the editor transcribes each clip); the row goes once the check is current.
+ setSaid(`queued${j.queued?.qid ? ` as ${j.queued.qid}` : ""} — ${settle.clips.length} clip${settle.clips.length === 1 ? "" : "s"}; see /jobs`);
+ return;
} 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`);
@@ -89,13 +110,13 @@ export default function DecisionSettle({
};
return (
- <span className="inline-flex items-center gap-2" data-settle={settle.kind}>
+ <span className="inline-flex flex-wrap items-center gap-x-2 gap-y-1" data-settle={settle.kind}>
<button
type="button"
- data-settle-button={settle.kind === "patch" ? settle.clip : settle.kind === "patch-markers" ? settle.file : settle.kind === "publish-site" ? `publish-${settle.siteId}` : "links"}
+ data-settle-button={settle.kind === "patch" ? settle.clip : settle.kind === "patch-markers" ? settle.file : settle.kind === "publish-site" ? `publish-${settle.siteId}` : settle.kind === "quote-check" ? "quote-check" : "links"}
disabled={busy}
onClick={() => void run()}
- className={buttonVariants({ variant: settle.kind === "patch" ? "go" : "outline", size: "sm" })}
+ className={cn(buttonVariants({ variant: settle.kind === "patch" ? "go" : "outline", size }), className)}
title={
settle.kind === "patch"
? `writes ${Object.keys(settle.patch).join(", ")} on ${settle.clip} through the window writer`
@@ -103,10 +124,14 @@ export default function DecisionSettle({
? `each marker of ${settle.file} after a clip that is gone takes the cut's marker of the same label`
: 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"
+ : settle.kind === "quote-check"
+ ? `umtool quote-check --clips ${settle.clips.join(",")} on the durable queue: the editor transcribes what each clip plays and its quote is found in it`
+ : settle.fix
+ ? "rewrites each dead link whose fix the last check knows (a Rumble folder id → its embed id, a Twitch id → v<id>) through the window writer, then checks again"
+ : "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…" : settle.kind === "publish-site" ? "Asking the editor…" : "Saving…") : settle.label}
+ {busy ? (settle.kind === "check-links" ? "Checking…" : settle.kind === "publish-site" ? "Asking the editor…" : settle.kind === "quote-check" ? "Queueing…" : "Saving…") : settle.label}
</button>
{said && !err && (
<span data-settle-said="" className="text-[11.5px] text-text-2">
diff --git a/umtool/lib/decisions.ts b/umtool/lib/decisions.ts
@@ -90,9 +90,13 @@ export type Decision = {
| { 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: "publish-site"; siteId: string; label: string };
+ | { kind: "publish-site"; siteId: string; label: string }
+ // Run the quote check on these clips (L4): `umtool quote-check <p> --clips …`, on the durable queue.
+ | { kind: "quote-check"; clips: string[]; label: string };
/** The clips a project-wide row is about (a site's dead links). */
clips?: string[];
+ /** The card's own title, when the rows name one ("3 versions to judge"); else the Inbox labels it by kind. */
+ what?: string;
// ---- The inbox's fields (lib/inbox.ts). ADDITIVE: a row without them is
// still a decision, and the reducers above never set them. ----
diff --git a/umtool/lib/inbox.ts b/umtool/lib/inbox.ts
@@ -27,6 +27,9 @@ import { readSchedules } from "./schedules";
import type { ScheduleView } from "./schedule-types";
import { refreshDecisions } from "./inbox/refresh";
import { sourceWatchDecisions } from "./inbox/sourceWatch";
+import { projectCallsAll } from "./inbox/projectCalls";
+import { xJarDecisions } from "./inbox/xJar";
+import { caseCuesDecisions } from "./inbox/caseCues";
// ---------------------------------------------------------------------------
// THE INBOX, AS DATA: every open decision (lib/projects.ts openDecisions: the
@@ -66,14 +69,26 @@ import { sourceWatchDecisions } from "./inbox/sourceWatch";
// per proposal, gone once approved or rejected (or the
// claim ruled by hand, or changed: a stale proposal)
// unreadable-proposals that file does not read: one Blocking row
+// version-unjudged a rendered version (or legacy take) with no verdict:
+// Play and judge (lib/inbox/versions.mjs, umtool
+// redesign L4 "What needs you")
+// clips-unwalked the draft's clips nobody walked, on a draft with a
+// render or a walk begun (lib/inbox/walk.mjs)
+// quote-check-stale clips the quote check no longer vouches for, with
+// Run quote-check in place (lib/inbox/checks.mjs)
+// case-new-cues a live research case's scope has new transcripts
+// since its last candidate scan (lib/inbox/caseCues.mjs)
+// x-jar-stale X's login is past its age and X work waits on it --
+// the editor's banner's rule (lib/inbox/xJar.mjs; the
+// one editor call here, memoised, never waited on long)
//
// -- each row given its piece, category, group, one action, lifecycle and
// `hidden` (lib/inbox/groups.mjs), ranked. One row per decision, never dropped:
// the MCP reads `items[]` (mcp/src/archivalTools.ts).
//
-// No editor call anywhere here: there is no "waiting on a cap" state (the daily
-// cap refuses at start, a per-job cap ends the run), and running jobs are the
-// rail's (lib/activity.ts readRunning).
+// One editor call only, X's jar (above): there is no "waiting on a cap" state
+// (the daily cap refuses at start, a per-job cap ends the run), and running
+// jobs are home's Running list (lib/activity.ts readRunning).
//
// SERVER ONLY.
// ---------------------------------------------------------------------------
@@ -90,6 +105,8 @@ export type GroupCard = {
what: string | null;
action: { label: string; href: string };
at: number;
+ /** The one-press settle the card offers in place, when its rows agree on one (groups.mjs mergeSettle). */
+ settle: Decision["settle"] | null;
};
export type GroupSummary = {
id: string;
@@ -392,7 +409,13 @@ export async function diskDecisions(graph: PieceGraph, life: LifecycleRead): Pro
.catch(() => [] as Decision[]);
// Re-sweep when complete (UI notes item 16): a report video's source watch that fired.
const sources = await sourceWatchDecisions().catch(() => [] as Decision[]);
- return [...perArticle.flat(), ...pieceDecisions(graph, life), ...drafts, ...proposals, ...refresh, ...recurring, ...sources];
+ // What needs you (L4): versions to judge, clips to walk, stale quote checks, a live case's new transcripts, X's jar.
+ const [calls, cases, xJar] = await Promise.all([
+ projectCallsAll().catch(() => [] as Decision[]),
+ caseCuesDecisions().catch(() => [] as Decision[]),
+ xJarDecisions().catch(() => [] as Decision[]),
+ ]);
+ return [...perArticle.flat(), ...pieceDecisions(graph, life), ...drafts, ...proposals, ...refresh, ...recurring, ...sources, ...calls, ...cases, ...xJar];
}
/**
diff --git a/umtool/lib/inbox/caseCues.mjs b/umtool/lib/inbox/caseCues.mjs
@@ -0,0 +1,60 @@
+// NEW TRANSCRIPTS ON A LIVE CASE (umtool redesign L4, "What needs you"): a
+// research case with a pipeline (`<case>/pipeline.json`, common's caseTypes.ts)
+// that is not done, whose candidate scan last ran at T, and whose scope's
+// channels have recordings transcribed (or their captions written) since T --
+// "14 new transcripts since the last scan". Review group; its action the case's
+// pipeline page, where Scan candidates runs the scan again.
+//
+// "Since the last refresh" is the candidates stage's last finished run
+// (stages.json): that is the read of the corpus the case's windows come from.
+// A case never scanned raises nothing -- there is no "since" to count from.
+//
+// Pure: lib/inbox/caseCues.ts lists the cases and counts the cues (the
+// transcript index's per-video mtimes; a fixture with no index, the files).
+
+export const CASE_NEW_CUES = "case-new-cues";
+
+/**
+ * The case's `since`: the candidates stage's last done run's end, as ms, or null.
+ * @param {Record<string, any> | null | undefined} stages readStages()
+ */
+export function lastScanOf(stages) {
+ const run = stages?.candidates;
+ if (!run || run.state !== "done") return null;
+ const ms = Date.parse(run.endedAt ?? run.startedAt ?? "");
+ return Number.isFinite(ms) ? ms : null;
+}
+
+/**
+ * The videos with cues newer than `since`: `{ channel, id, at }[]`, newest first.
+ * @param {Array<{ channel: string, id: string, at: number }>} rows
+ * @param {number} since
+ */
+export function newSince(rows, since) {
+ return (Array.isArray(rows) ? rows : [])
+ .filter((r) => r && Number.isFinite(r.at) && r.at > since)
+ .sort((a, b) => b.at - a.at || `${a.channel}/${a.id}`.localeCompare(`${b.channel}/${b.id}`));
+}
+
+/**
+ * One case's row, or null.
+ *
+ * @param {{ id: string, title: string, since: number, fresh: Array<{ channel: string, id: string, at: number }>, href: string }} o
+ */
+export function caseCuesDecision({ id, title, since, fresh, href }) {
+ const n = fresh?.length ?? 0;
+ if (!n) return null;
+ const channels = [...new Set(fresh.map((r) => r.channel))];
+ const when = new Date(since).toISOString().slice(0, 16).replace("T", " ");
+ return {
+ project: `research/${id}`,
+ projectTitle: title,
+ kind: CASE_NEW_CUES,
+ target: id,
+ what: `${n} new transcript${n === 1 ? "" : "s"} since the last scan`,
+ why: `${n} new transcript${n === 1 ? "" : "s"} since the last scan · ${when} UTC · on ${channels.slice(0, 4).join(", ")}${channels.length > 4 ? ` and ${channels.length - 4} more` : ""} — scan the candidates again`,
+ href,
+ severity: "open",
+ at: fresh[0].at,
+ };
+}
diff --git a/umtool/lib/inbox/caseCues.ts b/umtool/lib/inbox/caseCues.ts
@@ -0,0 +1,109 @@
+import { existsSync } from "node:fs";
+import { readdir, stat } from "node:fs/promises";
+import path from "node:path";
+import { caseChannels } from "yt-dlp-transcript-common/controller/caseCorpus";
+import { readDefinition, readStages } from "yt-dlp-transcript-common/lib/research/caseStore-server";
+import type { Decision } from "@/lib/decisions";
+import { CHANNELS_DIR, REPORTS_ROOT } from "@/lib/paths.mjs";
+import { caseDir, isCaseId, readCase, researchDir } from "@/lib/research/cases.mjs";
+import { researchCasePipelineHref } from "@/lib/research/hrefs";
+import { corpusPaths } from "@/lib/research/pipeline";
+import { caseCuesDecision, lastScanOf, newSince } from "./caseCues.mjs";
+
+// ---------------------------------------------------------------------------
+// New transcripts on a live case, for the Inbox (lib/inbox/caseCues.mjs says
+// what counts): every research case with a pipeline, not done, scanned at
+// least once; its scope's channels (common's caseChannels) and, per video,
+// when its cues were last written --
+//
+// the transcript index's `mtimes` (key [channel, video] -> transcriptMs /
+// subsMs, build-index's own record: channelSignature.ts reads the same) when
+// the index is there -- a key range per channel, no file opened;
+// else (a fixture, a corpus never indexed) the video directories' cue files.
+//
+// Kept per case and scan for ten minutes (new transcripts land in batches; the
+// rail asks every ten seconds). A case that cannot be read adds nothing; this
+// never throws. SERVER ONLY.
+// ---------------------------------------------------------------------------
+
+const MEMO_MS = 10 * 60_000;
+type Row = { channel: string; id: string; at: number };
+type Memo = Map<string, { at: number; value: Decision | null }>;
+const g = globalThis as typeof globalThis & { __umtoolCaseCuesMemo?: Memo };
+const memo: Memo = (g.__umtoolCaseCuesMemo ??= new Map());
+
+/** A cue file's name: the transcript and its sidecars, a caption track. */
+const CUE_FILE = /^(transcript\..+|.+\.vtt)$/;
+
+/** Per video of `slugs`, when its cues were last written (ms), from the index. */
+async function fromIndex(lmdbPath: string, slugs: string[]): Promise<Row[]> {
+ const { open } = await import("lmdb");
+ const root = open({ path: lmdbPath, readOnly: true, maxDbs: 14 });
+ try {
+ const mtimes = root.openDB<{ transcriptMs?: number | null; subsMs?: number | null }, [string, string]>({ name: "mtimes", encoding: "msgpack" });
+ const out: Row[] = [];
+ for (const slug of slugs) {
+ for (const { key, value } of mtimes.getRange({ start: [slug], end: [slug, ""] })) {
+ const k = key as [string, string];
+ if (k[0] !== slug) break;
+ const at = Math.max(value?.transcriptMs ?? 0, value?.subsMs ?? 0);
+ if (at > 0) out.push({ channel: slug, id: k[1], at });
+ }
+ }
+ return out;
+ } finally {
+ await root.close();
+ }
+}
+
+/** The same from the files: each video directory's newest cue file. */
+async function fromFiles(channelsDir: string, slugs: string[]): Promise<Row[]> {
+ const out: Row[] = [];
+ for (const slug of slugs) {
+ const data = path.join(/* turbopackIgnore: true */ channelsDir, slug, "data");
+ const ids = await readdir(/* turbopackIgnore: true */ data, { withFileTypes: true }).catch(() => []);
+ for (const d of ids) {
+ if (!d.isDirectory() || d.name.startsWith(".")) continue;
+ const names = await readdir(/* turbopackIgnore: true */ path.join(data, d.name)).catch(() => [] as string[]);
+ let at = 0;
+ for (const n of names) {
+ if (!CUE_FILE.test(n)) continue;
+ const s = await stat(/* turbopackIgnore: true */ path.join(data, d.name, n)).catch(() => null);
+ if (s && s.mtimeMs > at) at = s.mtimeMs;
+ }
+ if (at > 0) out.push({ channel: slug, id: d.name, at });
+ }
+ }
+ return out;
+}
+
+async function caseRow(id: string): Promise<Decision | null> {
+ const dir = caseDir(REPORTS_ROOT, id);
+ const def = await readDefinition(dir, id);
+ if (!def || def.status === "done") return null;
+ const since = lastScanOf(await readStages(dir));
+ if (since === null) return null;
+ const key = `${id}:${since}`;
+ const hit = memo.get(key);
+ if (hit && Date.now() - hit.at < MEMO_MS) return hit.value;
+ const paths = corpusPaths();
+ const { slugs } = await caseChannels(paths, def);
+ const rows = existsSync(/* turbopackIgnore: true */ paths.lmdbPath) ? await fromIndex(paths.lmdbPath, slugs) : await fromFiles(CHANNELS_DIR, slugs);
+ const title = (await readCase(REPORTS_ROOT, id).catch(() => null))?.title ?? id;
+ const value = caseCuesDecision({ id, title, since, fresh: newSince(rows, since), href: researchCasePipelineHref(id) }) as Decision | null;
+ for (const k of memo.keys()) if (k.startsWith(`${id}:`)) memo.delete(k);
+ memo.set(key, { at: Date.now(), value });
+ return value;
+}
+
+/** Every live case's "N new transcripts since the last scan". Never throws. */
+export async function caseCuesDecisions(): Promise<Decision[]> {
+ try {
+ const names = await readdir(/* turbopackIgnore: true */ researchDir(REPORTS_ROOT), { withFileTypes: true }).catch(() => []);
+ const ids = names.filter((d) => d.isDirectory() && isCaseId(d.name)).map((d) => d.name);
+ const rows = await Promise.all(ids.map((id) => caseRow(id).catch(() => null)));
+ return rows.filter((r): r is Decision => r !== null);
+ } catch {
+ return [];
+ }
+}
diff --git a/umtool/lib/inbox/checks.mjs b/umtool/lib/inbox/checks.mjs
@@ -0,0 +1,67 @@
+// QUOTE CHECKS GONE STALE (umtool redesign L4, "What needs you"): a project
+// that uses the quote check (`<p>/quote-check.json`, lib/report/quoteCheck.mjs)
+// and has clips the check no longer vouches for -- the cut or the quote changed
+// since its row (rowIsCurrent), or a clip with a quote that was never checked
+// -- is a call: one row per clip, one card per piece, its one-press action
+// **Run quote-check** on those clips (the durable queue: it transcribes through
+// the editor), its terminal twin `umtool quote-check <p> --clips a,b`.
+//
+// The failing rows themselves (moved, not-found) are the project reducer's,
+// blocking: clip-quote-moved / clip-quote-missing (lib/projects/report.mjs),
+// with their own one-press settles. A project with no quote-check.json raises
+// nothing here: the check is opt-in.
+//
+// Pure: lib/inbox/projectCalls.ts reads the manifest and the file.
+import { rowIsCurrent } from "../report/quoteCheck.mjs";
+
+export const QUOTE_CHECK_STALE = "quote-check-stale";
+
+/**
+ * The clips the check does not vouch for: `{ id, why: "stale" | "unchecked" }`, timeline order.
+ * @param {Array<Record<string, any>>} timeline
+ * @param {{ clips?: Record<string, any> } | null} doc readQuoteCheck()
+ */
+export function staleQuoteChecks(timeline, doc) {
+ const rows = doc?.clips && typeof doc.clips === "object" ? doc.clips : null;
+ if (!rows || !Object.keys(rows).length) return [];
+ const out = [];
+ for (const e of Array.isArray(timeline) ? timeline : []) {
+ if (e?.type !== "clip" || e.src || e.quoteRuled || !String(e.quote ?? "").trim()) continue;
+ const row = rows[e.id];
+ if (!row) out.push({ id: String(e.id), why: "unchecked" });
+ else if (!rowIsCurrent(row, e)) out.push({ id: String(e.id), why: "stale" });
+ }
+ return out;
+}
+
+/**
+ * The `quote-check-stale` rows of one project, each with the one-press settle
+ * for the whole set (the card's button runs the check on every clip it lists).
+ *
+ * @param {{ project: string, projectTitle: string, projectKind?: string, timeline: any[], doc: any, href: string, at: number }} o
+ */
+export function quoteCheckDecisions({ project, projectTitle, projectKind, timeline, doc, href, at }) {
+ const stale = staleQuoteChecks(timeline, doc);
+ if (!stale.length) return [];
+ const n = stale.length;
+ const what = `${n} quote check${n === 1 ? "" : "s"} out of date`;
+ const moved = stale.filter((s) => s.why === "stale").map((s) => s.id);
+ const never = stale.filter((s) => s.why === "unchecked").map((s) => s.id);
+ const list = (ids) => `${ids.slice(0, 6).join(", ")}${ids.length > 6 ? ` and ${ids.length - 6} more` : ""}`;
+ const why = [what, moved.length ? `cut or quote changed since: ${list(moved)}` : null, never.length ? `never checked: ${list(never)}` : null].filter(Boolean).join(" · ");
+ const clips = stale.map((s) => s.id);
+ return stale.map((s) => ({
+ project,
+ projectTitle,
+ ...(projectKind ? { projectKind } : {}),
+ kind: QUOTE_CHECK_STALE,
+ target: s.id,
+ what,
+ why,
+ href,
+ severity: "open",
+ at,
+ fix: `umtool quote-check ${project} --clips ${clips.join(",")}`,
+ settle: { kind: "quote-check", clips: [s.id], label: "Run quote-check" },
+ }));
+}
diff --git a/umtool/lib/inbox/groups.mjs b/umtool/lib/inbox/groups.mjs
@@ -71,6 +71,14 @@ const KIND_CATEGORY = {
// claims, each waiting on the operator's approve or reject.
"verdict-proposed": "review",
"unreadable-proposals": "fix",
+ // The redesign's "What needs you" (L4): a rendered version nobody judged,
+ // the draft's clips nobody walked, a research case's new transcripts since
+ // its last scan -- each something to look at; X's login when X work waits
+ // on it -- a fix, like a missing tool. A stale quote check is an open call.
+ "version-unjudged": "review",
+ "clips-unwalked": "review",
+ "case-new-cues": "review",
+ "x-jar-stale": "fix",
};
const CATEGORY_GROUP = {
@@ -99,7 +107,7 @@ export function groupOf(d) {
// Within a group: the brief's order first (proposals before failed runs), then
// everything else as equals.
-const KIND_RANK = { "worth-researching": 0, "research-proposal": 0, "iteration-failed": 1, "tick-held": 2, "tick-failed": 2, "tick-partial": 2, "iteration-ready": 0, "edition-ready": 0, "drafts-unreviewed": 1, "verdict-proposed": 1, "unreadable-notes": 0, "unreadable-proposals": 0, "refresh-held": 2, "refresh-available": 2, "sources-complete": 2 };
+const KIND_RANK = { "worth-researching": 0, "research-proposal": 0, "iteration-failed": 1, "tick-held": 2, "tick-failed": 2, "tick-partial": 2, "iteration-ready": 0, "edition-ready": 0, "drafts-unreviewed": 1, "verdict-proposed": 1, "unreadable-notes": 0, "unreadable-proposals": 0, "refresh-held": 2, "refresh-available": 2, "sources-complete": 2, "version-unjudged": 1, "case-new-cues": 2, "clips-unwalked": 3, "x-jar-stale": 0 };
const SEVERITY_RANK = { blocking: 0, open: 1, info: 2 };
// ONE primary action per decision, its button copy naming the result.
@@ -159,6 +167,11 @@ const ACTION_LABEL = {
"refresh-held": "Refresh",
"refresh-available": "Refresh",
"sources-complete": "Re-sweep",
+ "version-unjudged": "Play and judge",
+ "clips-unwalked": "Walk the clips",
+ "quote-check-stale": "Run quote-check",
+ "case-new-cues": "Scan again",
+ "x-jar-stale": "Refresh X's cookies",
};
const CATEGORY_LABEL = { fix: "Fix it", choose: "Decide", info: "Open", spend: "Decide", review: "Review", note: "Answer note", finish: "Mark done" };
@@ -266,13 +279,35 @@ export function summarizeGroups(items) {
what: d.what ?? null,
action: d.action ?? actionOf(d),
at: d.at ?? 0,
+ // The one-press settle the card offers in place (L4), when its rows agree on one.
+ settle: d.settle ?? null,
};
cardOf.set(key, card);
group.cards.push(card);
- }
+ } else card.settle = mergeSettle(card.settle, d.settle ?? null);
card.count += 1;
if ((SEVERITY_RANK[d.severity] ?? 3) < (SEVERITY_RANK[card.severity] ?? 3)) card.severity = d.severity;
card.at = Math.max(card.at, d.at ?? 0);
}
return out;
}
+
+/**
+ * The settle a CARD offers for all its rows (umtool redesign L4: one-click
+ * actions in the Inbox), from two rows' (lib/decisions.ts `settle`): a quote
+ * check runs on every clip either names; the same project-wide settle (a link
+ * check, a publish) is kept; anything else -- two clip patches, two different
+ * presses -- is no settle, and the card's link is the way. A row without one
+ * leaves the card without one.
+ *
+ * @param {Record<string, any> | null} a
+ * @param {Record<string, any> | null} b
+ */
+export function mergeSettle(a, b) {
+ if (!a || !b) return null;
+ if (a.kind === "quote-check" && b.kind === "quote-check") {
+ return { ...a, clips: [...new Set([...(a.clips ?? []), ...(b.clips ?? [])])] };
+ }
+ if (a.kind === "patch" || b.kind === "patch") return null;
+ return JSON.stringify(a) === JSON.stringify(b) ? a : null;
+}
diff --git a/umtool/lib/inbox/needs-you.test.ts b/umtool/lib/inbox/needs-you.test.ts
@@ -0,0 +1,242 @@
+// "What needs you" (umtool redesign L4): the Inbox's new decision sources --
+// versions to judge, clips not walked, stale quote checks, a live case's new
+// transcripts, X's jar -- as pure rows, then read from a temporary reports tree
+// and a stand-in editor; and the card's one-press settle (groups.mjs mergeSettle).
+//
+// Run with: pnpm --filter umtool exec tsx --test lib/inbox/needs-you.test.ts
+import { after, before, test } from "node:test";
+import assert from "node:assert/strict";
+import { createServer, type Server } from "node:http";
+import type { AddressInfo } from "node:net";
+import { mkdtempSync } from "node:fs";
+import { mkdir, rm, utimes, writeFile } from "node:fs/promises";
+import os from "node:os";
+import path from "node:path";
+
+// The environment BEFORE any module that reads lib/paths.mjs is loaded (checks.mjs reaches it through
+// quoteCheck.mjs): a static import would be hoisted above this and read the real ~/reports.
+const tmp = mkdtempSync(path.join(os.tmpdir(), "umtool-needs-you-"));
+process.env.CHANNELS_DIR = path.join(tmp, "channels");
+process.env.SITES_DIR = path.join(tmp, "sites");
+process.env.REPORTS_DIR = path.join(tmp, "reports");
+process.env.UMTOOL_XJAR_MEMO_MS = "0";
+const { VERSION_UNJUDGED, versionsDecisions, versionsToJudge } = await import("./versions.mjs");
+const { CLIPS_UNWALKED, walkDecisions } = await import("./walk.mjs");
+const { QUOTE_CHECK_STALE, quoteCheckDecisions, staleQuoteChecks } = await import("./checks.mjs");
+const { X_JAR_STALE, xJarDecision } = await import("./xJar.mjs");
+const { CASE_NEW_CUES, caseCuesDecision, lastScanOf, newSince } = await import("./caseCues.mjs");
+const { annotate, groupOf, mergeSettle, summarizeGroups } = await import("./groups.mjs");
+const { whatOf } = await import("./what.mjs");
+
+const take = (id: string, o: Record<string, unknown> = {}) => ({ id, label: id, previewSize: 100, previewMtimeMs: 0, builtAt: "2026-11-01T10:00:00Z", draft: false, quick: false, version: true, seconds: 95, ...o });
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+type Row = { kind: string; severity: string; [k: string]: any };
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+type Any = any;
+const annotated = (rows: Any[]): Row[] => annotate(rows as never[], { pieceOf: () => "p:x", lifecycleOf: () => "active" }) as Any[];
+
+test("versions to judge: rendered, no verdict, not superseded, not a draft, a quick render or a skipped take -- newest first", () => {
+ const takes = [
+ take("v1", { builtAt: "2026-11-01T10:00:00Z" }),
+ take("v2", { builtAt: "2026-11-03T10:00:00Z" }),
+ take("v3", { previewSize: null }),
+ take("d1", { draft: true }),
+ take("q1", { quick: true }),
+ take("liked"),
+ take("gone"),
+ take("clip"),
+ ];
+ const verdicts = { liked: { verdict: "like" }, gone: { verdict: null, superseded: { by: "v2" } } };
+ assert.deepEqual(versionsToJudge(takes, verdicts, { skip: (t) => t.id === "clip" }).map((t) => t.id), ["v2", "v1"]);
+ const rows = versionsDecisions({ project: "x", projectTitle: "X", takes, verdicts, playHref: (t) => `/projects/x/play?take=${t}`, skip: (t) => t.id === "clip" });
+ assert.equal(rows.length, 2);
+ assert.ok(rows.every((r) => r.kind === VERSION_UNJUDGED && r.href === "/projects/x/play?take=v2" && r.what === "2 versions to judge" && r.severity === "open"));
+ assert.match(rows[0].why, /^2 versions to judge · newest version v2 · 1:35 · rendered 2026-11-03/);
+ const [row] = annotated(rows);
+ assert.equal(groupOf(row), "review");
+ assert.equal(row.action.label, "Play and judge");
+ assert.deepEqual(versionsDecisions({ project: "x", projectTitle: "X", takes: [], verdicts: {}, playHref: () => "/" }), []);
+ // Shapes it does not know are left out, never thrown on.
+ assert.deepEqual(versionsToJudge(null as never, null as never), []);
+});
+
+test("clips not walked: only on a draft going somewhere -- a walk begun or a render made; the bench on the first in walk order", () => {
+ const clips = [
+ { id: "c03", verdict: "unreviewed" },
+ { id: "c01", verdict: "confirmed" },
+ { id: "c02", verdict: "unreviewed" },
+ ];
+ const base = { project: "x", projectTitle: "X", at: 5, benchHref: (c: string) => `/projects/x/clip/${c}` };
+ const rows = walkDecisions({ ...base, clips, rendered: false });
+ assert.deepEqual(rows.map((r) => r.target), ["c03", "c02"]);
+ assert.ok(rows.every((r) => r.kind === CLIPS_UNWALKED && r.href === "/projects/x/clip/c03" && r.what === "2 clips not walked"));
+ assert.match(rows[0].why, /2 clips not walked · 1 of 3 walked · next c03 — c03, c02/);
+ // Never walked and never rendered: a cut in the making, not yet a call.
+ assert.deepEqual(walkDecisions({ ...base, clips: clips.map((c) => ({ ...c, verdict: "unreviewed" })), rendered: false }), []);
+ assert.equal(walkDecisions({ ...base, clips: clips.map((c) => ({ ...c, verdict: "unreviewed" })), rendered: true }).length, 3);
+ assert.deepEqual(walkDecisions({ ...base, clips: clips.map((c) => ({ ...c, verdict: "confirmed" })), rendered: true }), []);
+ const [row] = annotated(rows);
+ assert.deepEqual([groupOf(row), row.action.label, whatOf(CLIPS_UNWALKED)], ["review", "Walk the clips", "clips not walked"]);
+});
+
+test("stale quote checks: a clip whose cut or quote changed since its row, or never checked, on a project that uses the check", () => {
+ const clip = (id: string, start: number, o: Record<string, unknown> = {}) => ({ type: "clip", id, video: "v", start, end: start + 5, quote: `Line ${start}`, ...o });
+ const row = (start: number, status = "ok") => ({ status, cut: { from: start, to: start + 5 }, quote: `Line ${start}` });
+ const timeline = [clip("a", 10), clip("b", 20, { cutStart: 21 }), clip("c", 30), clip("d", 40, { quoteRuled: true }), clip("e", 50, { quote: "" }), { type: "card", id: "k1" }];
+ const doc: Any = { version: 1, clips: { a: row(10), b: row(20, "moved"), d: row(1) } };
+ assert.deepEqual(staleQuoteChecks(timeline, doc), [
+ { id: "b", why: "stale" },
+ { id: "c", why: "unchecked" },
+ ]);
+ // No quote-check.json (or an empty one): the check is opt-in, nothing to say.
+ assert.deepEqual(staleQuoteChecks(timeline, { clips: {} }), []);
+ assert.deepEqual(staleQuoteChecks(timeline, null), []);
+ const rows = quoteCheckDecisions({ project: "x", projectTitle: "X", timeline, doc, href: "/projects/x", at: 1 });
+ assert.deepEqual(rows.map((r) => [r.kind, r.target, r.settle]), [
+ [QUOTE_CHECK_STALE, "b", { kind: "quote-check", clips: ["b"], label: "Run quote-check" }],
+ [QUOTE_CHECK_STALE, "c", { kind: "quote-check", clips: ["c"], label: "Run quote-check" }],
+ ]);
+ assert.equal(rows[0].fix, "umtool quote-check x --clips b,c");
+ assert.match(rows[0].why, /2 quote checks out of date · cut or quote changed since: b · never checked: c/);
+ // One card, one press over every clip it lists.
+ const [g] = (summarizeGroups(annotated(rows)) as Any[]).filter((x) => x.cards.length);
+ assert.equal(g.id, "open");
+ assert.deepEqual(g.cards[0].settle, { kind: "quote-check", clips: ["b", "c"], label: "Run quote-check" });
+ assert.equal(g.cards[0].action.label, "Run quote-check");
+});
+
+test("a card's settle: one quote check over every clip; the same project-wide press kept; two patches, or a row without one, none", () => {
+ const q = (c: string) => ({ kind: "quote-check", clips: [c], label: "Run quote-check" });
+ const links = { kind: "check-links", fix: true, label: "Use embed ids (2)" };
+ assert.deepEqual(mergeSettle(q("a"), q("b")), { kind: "quote-check", clips: ["a", "b"], label: "Run quote-check" });
+ assert.deepEqual(mergeSettle(links, { ...links }), links);
+ assert.equal(mergeSettle({ kind: "patch", clip: "a", patch: {}, label: "x" }, { kind: "patch", clip: "b", patch: {}, label: "x" }), null);
+ assert.equal(mergeSettle(links, null), null);
+ assert.equal(mergeSettle(links, { kind: "check-links", label: "Check links" }), null);
+});
+
+test("X's jar: a row only when an X alert is up (X work waits) -- the editor's three lines, Blocking", () => {
+ const x = { source: "profile", ageMinutes: 190, maxAgeMinutes: 60, fresh: false, loggedIn: true, at: null, readAt: "", summary: "" };
+ const alert = { service: "x", label: "X", family: "x", state: "stale", kind: "jar-age", raisedAt: "2026-11-09T10:00:00Z", headline: "X cookies are 3 h old (limit 60 min)", fix: "Refresh cookies (or Connect X account) on /settings — then Recheck.", detail: "2 X jobs are queued." };
+ assert.equal(xJarDecision({ alerts: [], x }, { href: "/s" }), null);
+ assert.equal(xJarDecision({ alerts: [{ ...alert, state: "ok-again" }], x }, { href: "/s" }), null);
+ assert.equal(xJarDecision({ alerts: [{ ...alert, family: "ytdlp", service: "rumble" }], x }, { href: "/s" }), null);
+ assert.equal(xJarDecision("not a payload", { href: "/s" }), null);
+ const row = xJarDecision({ alerts: [alert], x }, { href: "http://editor/settings" });
+ assert.ok(row);
+ assert.equal(row.kind, X_JAR_STALE);
+ assert.equal(row.severity, "blocking");
+ assert.equal(row.why, "X cookies are 3 h old (limit 60 min) Refresh cookies (or Connect X account) on /settings — then Recheck. 2 X jobs are queued.");
+ assert.equal(row.at, Date.parse("2026-11-09T10:00:00Z"));
+ const [a] = annotate([row], { pieceOf: () => null, lifecycleOf: () => "active" });
+ assert.deepEqual([a.group, a.action.label, a.hidden], ["blocking", "Refresh X's cookies", false]);
+});
+
+test("a live case's new transcripts: since its last done candidate scan; none before one ran", () => {
+ assert.equal(lastScanOf({}), null);
+ assert.equal(lastScanOf({ candidates: { state: "running", startedAt: "2026-11-01T00:00:00Z" } }), null);
+ const since = lastScanOf({ candidates: { state: "done", startedAt: "2026-11-01T00:00:00Z", endedAt: "2026-11-01T00:05:00Z" } });
+ assert.equal(since, Date.parse("2026-11-01T00:05:00Z"));
+ const rows = [
+ { channel: "a", id: "old", at: since! - 1 },
+ { channel: "a", id: "new1", at: since! + 10 },
+ { channel: "b", id: "new2", at: since! + 20 },
+ ];
+ const fresh = newSince(rows, since!);
+ assert.deepEqual(fresh.map((r) => r.id), ["new2", "new1"]);
+ const row = caseCuesDecision({ id: "lighthouse", title: "Lighthouse", since: since!, fresh, href: "/research/lighthouse/pipeline" });
+ assert.ok(row);
+ assert.deepEqual([row.kind, row.target, row.what, row.at], [CASE_NEW_CUES, "lighthouse", "2 new transcripts since the last scan", since! + 20]);
+ assert.match(row.why, /since the last scan · 2026-11-01 00:05 UTC · on b, a — scan the candidates again/);
+ assert.equal(caseCuesDecision({ id: "x", title: "x", since: since!, fresh: [], href: "/" }), null);
+ const [a] = annotate([row], { pieceOf: () => null, lifecycleOf: () => "active" });
+ assert.deepEqual([a.group, a.action.label], ["review", "Scan again"]);
+});
+
+// ─── read from disk and from a stand-in editor ────────────────────────────────
+
+let editor: Server;
+let services: unknown = { ok: true, alerts: [], pending: [] };
+
+before(async () => {
+ editor = createServer((req, res) => {
+ res.setHeader("content-type", "application/json");
+ if (req.url?.startsWith("/api/ops/services")) return res.end(JSON.stringify(services));
+ res.statusCode = 404;
+ res.end(JSON.stringify({ ok: false, error: "no route" }));
+ });
+ await new Promise<void>((r) => editor.listen(0, "127.0.0.1", r));
+ process.env.ARCHILYZER_EDITOR_URL = `http://127.0.0.1:${(editor.address() as AddressInfo).port}`;
+ process.env.WORKER_TOKEN = "t";
+
+ // A report video with two rendered versions (one judged), a walk begun, and a quote check gone stale.
+ const p = path.join(tmp, "reports", "ny-cut");
+ const clip = (id: string, start: number, o: Record<string, unknown> = {}) => ({ type: "clip", id, video: "vid", start, end: start + 4, cite: start, quote: `Line ${start}`, ...o });
+ await mkdir(p, { recursive: true });
+ await writeFile(
+ path.join(p, "video.manifest.json"),
+ JSON.stringify({ schemaVersion: 1, slug: "ny-cut", title: "The NY Cut", provenance: { channelSlug: "nychan" }, render: { width: 1920, height: 1080, fps: 30 }, timeline: [clip("c01", 10, { verdict: "confirmed" }), clip("c02", 20), clip("c03", 30)] }),
+ );
+ for (const [id, order] of [["v1", 1], ["v2", 2]] as const) {
+ await mkdir(path.join(p, "takes", id), { recursive: true });
+ await writeFile(path.join(p, "takes", id, "take.json"), JSON.stringify({ id, group: "cut", order, label: `Version ${order}`, kind: "similar", preview: "preview.mp4", version: true, window: "full", builtAt: `2026-11-0${order}T10:00:00Z` }));
+ await writeFile(path.join(p, "takes", id, "preview.mp4"), "mp4");
+ }
+ await writeFile(path.join(p, "takes", "verdicts.json"), JSON.stringify({ v1: { verdict: "like", note: "", at: "2026-11-02T00:00:00Z" } }));
+ await writeFile(path.join(p, "quote-check.json"), JSON.stringify({ version: 1, clips: { c02: { status: "ok", cut: { from: 19, to: 24 }, quote: "Line 20" } } }));
+
+ // A live case scanned on 1 Nov, its channel transcribed once before and twice after.
+ const c = path.join(tmp, "reports", ".umtool", "research", "ny-case");
+ await mkdir(c, { recursive: true });
+ const now = "2026-11-01T00:00:00Z";
+ await writeFile(path.join(c, "case.json"), JSON.stringify({ format: "umtool-research-case", version: 1, id: "ny-case", title: "The NY Case", scope: { source: "local" }, search: null, sessions: [], sections: [], quotes: [], notes: "", handoffs: [], counters: { quote: 0, section: 0 }, createdAt: now, updatedAt: now }));
+ await writeFile(path.join(c, "pipeline.json"), JSON.stringify({ format: "archilyzer-case-pipeline", version: 1, case: "ny-case", subjects: [], scope: { channels: ["nychan"], groups: [], sites: [] }, eras: [], groups: [], privateNames: { sha256: [], note: "" }, readerPrompts: { common: "" }, status: "reading", createdAt: now, updatedAt: now }));
+ await writeFile(path.join(c, "stages.json"), JSON.stringify({ candidates: { state: "done", startedAt: now, endedAt: "2026-11-01T00:05:00Z", by: "cli", pid: 1, log: [] } }));
+ for (const [id, when] of [["old", "2026-10-20T00:00:00Z"], ["new1", "2026-11-03T00:00:00Z"], ["new2", "2026-11-04T00:00:00Z"]]) {
+ const d = path.join(tmp, "channels", "nychan", "data", id);
+ await mkdir(d, { recursive: true });
+ await writeFile(path.join(d, "transcript.cues.json"), "{}");
+ await utimes(path.join(d, "transcript.cues.json"), new Date(when), new Date(when));
+ }
+});
+
+after(async () => {
+ editor?.close();
+ await rm(tmp, { recursive: true, force: true });
+});
+
+test("from disk: the report video's version to judge, its clips not walked, its stale quote check -- each kind once per row", async () => {
+ const { projectCallsAll } = await import("./projectCalls");
+ const rows = (await projectCallsAll()).filter((d) => d.project === "ny-cut");
+ const of = (k: string) => rows.filter((d) => d.kind === k).map((d) => d.target);
+ assert.deepEqual(of(VERSION_UNJUDGED), ["v2"]);
+ assert.equal(rows.find((d) => d.kind === VERSION_UNJUDGED)?.href, "/projects/ny-cut/play?take=v2");
+ assert.deepEqual(of(CLIPS_UNWALKED), ["c02", "c03"]);
+ assert.equal(rows.find((d) => d.kind === CLIPS_UNWALKED)?.href, "/projects/ny-cut/clip/c02");
+ // c02's row is for a cut it no longer plays; c01 and c03 were never checked.
+ assert.deepEqual(of(QUOTE_CHECK_STALE), ["c01", "c02", "c03"]);
+ assert.ok(rows.every((d) => d.projectTitle === "The NY Cut"));
+ // Read again with nothing changed: the same rows (the memo), and judging v2 drops it.
+ assert.deepEqual((await projectCallsAll()).filter((d) => d.project === "ny-cut"), rows);
+ await writeFile(path.join(tmp, "reports", "ny-cut", "takes", "verdicts.json"), JSON.stringify({ v1: { verdict: "like", note: "", at: "x" }, v2: { verdict: "maybe", note: "", at: "y" } }));
+ assert.deepEqual((await projectCallsAll()).filter((d) => d.project === "ny-cut" && d.kind === VERSION_UNJUDGED), []);
+});
+
+test("from disk: the live case's two new transcripts since its scan (the files, with no index)", async () => {
+ const { caseCuesDecisions } = await import("./caseCues");
+ const [row] = await caseCuesDecisions();
+ assert.ok(row);
+ assert.deepEqual([row.kind, row.project, row.projectTitle, row.href], [CASE_NEW_CUES, "research/ny-case", "The NY Case", "/research/ny-case/pipeline"]);
+ assert.equal(row.what, "2 new transcripts since the last scan");
+});
+
+test("from the editor: no row while no X work waits; the row once the jar's alert is up; none when the editor is gone", async () => {
+ const { xJarDecisions } = await import("./xJar");
+ assert.deepEqual(await xJarDecisions(), []);
+ services = { ok: true, alerts: [{ service: "x", label: "X", family: "x", state: "stale", kind: "jar-age", raisedAt: "2026-11-09T10:00:00Z", headline: "X cookies are 3 h old", fix: "Refresh cookies on /settings — then Recheck.", detail: "" }], pending: [] };
+ const [row] = await xJarDecisions();
+ assert.equal(row?.kind, X_JAR_STALE);
+ assert.equal(row?.href, `${process.env.ARCHILYZER_EDITOR_URL}/settings`);
+ await new Promise<void>((r) => editor.close(() => r()));
+ assert.deepEqual(await xJarDecisions(), []);
+});
diff --git a/umtool/lib/inbox/projectCalls.ts b/umtool/lib/inbox/projectCalls.ts
@@ -0,0 +1,106 @@
+import { stat, readdir } from "node:fs/promises";
+import path from "node:path";
+import type { Decision } from "@/lib/decisions";
+import { clipBenchHref, playHref, projectHref } from "@/lib/hrefs";
+import { projectRefs } from "@/lib/projects";
+import { kindMakesTakes } from "@/lib/projects/kinds.mjs";
+import { readManifest, reviewOf, walkOrder } from "@/lib/projects/report.mjs";
+import type { ProjectRef } from "@/lib/project-types";
+import { QUOTE_CHECK_FILE, readQuoteCheck } from "@/lib/report/quoteCheck.mjs";
+import { QUICK_CLIP_FOLDER, QUICK_CLIP_TAKE } from "@/lib/report/quickClip.mjs";
+import { listTakes, readVerdicts, takesDirOf, verdictsFileOf } from "@/lib/report/takes.mjs";
+import { quoteCheckDecisions } from "./checks.mjs";
+import { versionsDecisions } from "./versions.mjs";
+import { walkDecisions } from "./walk.mjs";
+
+// ---------------------------------------------------------------------------
+// A REPORT VIDEO'S CALLS THE REDUCER DOES NOT MAKE (umtool redesign L4, "What
+// needs you"), read from its disk for the Inbox:
+//
+// version-unjudged a rendered version (or legacy take) with no verdict
+// (lib/inbox/versions.mjs) -- Play and judge
+// clips-unwalked the draft's clips with no walk verdict, on a draft that
+// is going somewhere (lib/inbox/walk.mjs) -- Walk
+// quote-check-stale clips the quote check no longer vouches for
+// (lib/inbox/checks.mjs) -- Run quote-check
+//
+// One project that cannot be read adds nothing; nothing here throws. Each
+// project's rows are kept against a signature of the files they come from
+// (the manifest, quote-check.json, takes/ and each take's directory, the
+// verdicts), on globalThis: one cache per process, not per Next bundle.
+// SERVER ONLY.
+// ---------------------------------------------------------------------------
+
+type Memo = Map<string, { sig: string; value: Decision[] }>;
+const g = globalThis as typeof globalThis & { __umtoolProjectCallsMemo?: Memo };
+const memo: Memo = (g.__umtoolProjectCallsMemo ??= new Map());
+
+const stamp = async (file: string) => {
+ const s = await stat(/* turbopackIgnore: true */ file).catch(() => null);
+ return s ? `${Math.round(s.mtimeMs)}.${s.size}` : "-";
+};
+
+async function signatureOf(dir: string): Promise<string> {
+ const takes = takesDirOf(dir);
+ const entries = await readdir(/* turbopackIgnore: true */ takes).catch(() => [] as string[]);
+ const per = await Promise.all(entries.filter((n) => !n.startsWith(".")).sort().map(async (n) => `${n}@${await stamp(path.join(takes, n))}`));
+ const [man, qc, verdicts] = await Promise.all([stamp(path.join(dir, "video.manifest.json")), stamp(path.join(dir, QUOTE_CHECK_FILE)), stamp(verdictsFileOf(dir))]);
+ return [man, qc, verdicts, per.join(",")].join("|");
+}
+
+/** A take a quick clip made: a share, not a version to judge. */
+const isQuickClipTake = (ref: ProjectRef, take: { id: string }) => take.id === QUICK_CLIP_TAKE && (ref.id === QUICK_CLIP_FOLDER || ref.id.startsWith(`${QUICK_CLIP_FOLDER}/`));
+
+async function callsOf(ref: ProjectRef): Promise<Decision[]> {
+ const manifest = (await readManifest(ref.dir)) as Record<string, unknown> | null;
+ const title = typeof manifest?.title === "string" && manifest.title ? manifest.title : ref.name;
+ const base = { project: ref.id, projectTitle: title, projectKind: ref.kind };
+ const [{ takes }, verdicts] = await Promise.all([listTakes(ref.dir), readVerdicts(ref.dir)]);
+ const out: Decision[] = [];
+
+ out.push(
+ ...(versionsDecisions({
+ ...base,
+ takes,
+ verdicts,
+ playHref: (take: string) => playHref(ref.id, { take }),
+ skip: (t: Record<string, unknown>) => isQuickClipTake(ref, { id: String(t.id) }),
+ }) as Decision[]),
+ );
+
+ if (manifest) {
+ const timeline = (manifest.timeline ?? []) as Record<string, unknown>[];
+ const review = reviewOf(manifest);
+ const verdictOf = new Map(review.clips.map((c: { id: string; verdict: string }) => [c.id, c.verdict]));
+ const clips = walkOrder(timeline).map((e: { id: string }) => ({ id: String(e.id), verdict: verdictOf.get(e.id) ?? "unreviewed" }));
+ const rendered = takes.some((t: { previewSize: number | null; version: boolean }) => t.previewSize != null || t.version);
+ const at = await stat(/* turbopackIgnore: true */ path.join(ref.dir, "video.manifest.json")).then((s) => s.mtimeMs, () => 0);
+ out.push(...(walkDecisions({ ...base, clips, rendered, at, benchHref: (clip: string) => clipBenchHref(ref.id, clip) }) as Decision[]));
+ const doc = await readQuoteCheck(ref.dir);
+ const checkedAt = Date.parse(String((doc as { checkedAt?: string }).checkedAt ?? "")) || at;
+ out.push(...(quoteCheckDecisions({ ...base, timeline, doc, href: projectHref(ref.id), at: checkedAt }) as Decision[]));
+ }
+ return out;
+}
+
+async function projectCalls(ref: ProjectRef): Promise<Decision[]> {
+ const sig = await signatureOf(ref.dir);
+ const hit = memo.get(ref.id);
+ if (hit && hit.sig === sig) return hit.value;
+ const value = await callsOf(ref).catch(() => [] as Decision[]);
+ memo.set(ref.id, { sig, value });
+ return value;
+}
+
+/** Every report video's versions to judge, clips not walked and stale quote checks. Never throws. */
+export async function projectCallsAll(): Promise<Decision[]> {
+ try {
+ const refs = (await projectRefs()).filter((r) => kindMakesTakes(r.kind));
+ const live = new Set(refs.map((r) => r.id));
+ for (const id of memo.keys()) if (!live.has(id)) memo.delete(id);
+ const per = await Promise.all(refs.map((r) => projectCalls(r).catch(() => [] as Decision[])));
+ return per.flat();
+ } catch {
+ return [];
+ }
+}
diff --git a/umtool/lib/inbox/versions.mjs b/umtool/lib/inbox/versions.mjs
@@ -0,0 +1,80 @@
+// VERSIONS TO JUDGE (umtool redesign L4, "What needs you"): a saved version
+// (lib/report/versions.mjs) -- or a legacy take -- that has a RENDER and no
+// verdict is a call in the Inbox's Review group. One row per version (the API
+// keeps one row per decision), one card per piece ("3 versions to judge"), its
+// action Play and judge: Play on the newest of them (`?take=`), where the
+// verdict buttons are.
+//
+// Not a version to judge: a draft take (recorded, not rendered), a quick
+// draft-quality render, a superseded take (folded away by a person), and a
+// quick clip's one take (a share, not a version -- lib/report/quickClip.mjs).
+//
+// Pure: lib/inbox/projectCalls.ts reads the takes and verdicts and hands them
+// here. Never throws on a shape it does not know: it is left out.
+
+export const VERSION_UNJUDGED = "version-unjudged";
+
+const timeOf = (t) => {
+ const ms = Date.parse(t?.builtAt ?? t?.savedAt ?? "");
+ if (Number.isFinite(ms)) return ms;
+ return Number.isFinite(t?.previewMtimeMs) ? t.previewMtimeMs : 0;
+};
+
+/**
+ * The takes that wait on a verdict, newest first.
+ *
+ * @param {Array<Record<string, any>>} takes listTakes()'s takes
+ * @param {Record<string, { verdict?: string | null, superseded?: unknown }>} verdicts readVerdicts()
+ * @param {{ skip?: (take: Record<string, any>) => boolean }} [o]
+ */
+export function versionsToJudge(takes, verdicts, { skip = () => false } = {}) {
+ const v = verdicts && typeof verdicts === "object" ? verdicts : {};
+ return (Array.isArray(takes) ? takes : [])
+ .filter((t) => t && typeof t.id === "string")
+ .filter((t) => t.previewSize != null && t.draft !== true && t.quick !== true)
+ .filter((t) => !v[t.id]?.verdict && !v[t.id]?.superseded)
+ .filter((t) => !skip(t))
+ .sort((a, b) => timeOf(b) - timeOf(a) || String(a.id).localeCompare(String(b.id)));
+}
+
+/** The card's title: how many wait. */
+export function versionsWhat(waiting) {
+ const n = waiting.length;
+ return `${n} version${n === 1 ? "" : "s"} to judge`;
+}
+
+const day = (ms) => (ms ? new Date(ms).toISOString().slice(0, 10) : null);
+const mins = (s) => (Number.isFinite(s) && s > 0 ? `${Math.floor(s / 60)}:${String(Math.round(s % 60)).padStart(2, "0")}` : null);
+
+/**
+ * The `version-unjudged` rows of one project.
+ *
+ * @param {{
+ * project: string, projectTitle: string, projectKind?: string,
+ * takes: Array<Record<string, any>>, verdicts: Record<string, any>,
+ * playHref: (take: string) => string,
+ * skip?: (take: Record<string, any>) => boolean,
+ * }} o
+ */
+export function versionsDecisions({ project, projectTitle, projectKind, takes, verdicts, playHref, skip }) {
+ const waiting = versionsToJudge(takes, verdicts, { skip });
+ if (!waiting.length) return [];
+ const what = versionsWhat(waiting);
+ // The card's sentence is its newest row's (summarizeGroups keeps the first, ranked newest first).
+ const newest = waiting[0];
+ const href = playHref(newest.id);
+ const facts = [`${newest.version ? "version" : "take"} ${newest.id}`, newest.label && newest.label !== newest.id ? `“${newest.label}”` : null, mins(newest.seconds), day(timeOf(newest)) ? `rendered ${day(timeOf(newest))}` : null];
+ const why = `${what} · newest ${facts.filter(Boolean).join(" · ")} — play it and say like, maybe or no`;
+ return waiting.map((t) => ({
+ project,
+ projectTitle,
+ ...(projectKind ? { projectKind } : {}),
+ kind: VERSION_UNJUDGED,
+ target: t.id,
+ what,
+ why,
+ href,
+ severity: "open",
+ at: timeOf(t),
+ }));
+}
diff --git a/umtool/lib/inbox/walk.mjs b/umtool/lib/inbox/walk.mjs
@@ -0,0 +1,64 @@
+// CLIPS NOT WALKED (umtool redesign L4, "What needs you"): the working draft's
+// clips with no walk verdict (lib/projects/report.mjs reviewOf: "unreviewed")
+// are a call in the Review group -- one row per clip, one card per piece
+// ("12 clips not walked"), its action the clip bench on the first of them in
+// walk order (by source, then start: report.mjs walkOrder), the one that is
+// fetched first when any is.
+//
+// Only a draft that is GOING somewhere is waiting on a walk: one whose walk has
+// begun (a clip has a verdict), or that has a rendered take or a saved version.
+// A cut still being assembled, never walked and never rendered, is not yet a
+// call -- 78 of the 91 real report projects have unwalked clips (9 Nov), and an
+// Inbox that lists every cut in the making is one nobody reads.
+//
+// Pure: lib/inbox/projectCalls.ts reads the manifest and the takes and hands
+// the walk's rows here.
+
+export const CLIPS_UNWALKED = "clips-unwalked";
+
+/** The card's title. */
+export function walkWhat(n) {
+ return `${n} clip${n === 1 ? "" : "s"} not walked`;
+}
+
+/**
+ * The `clips-unwalked` rows of one project.
+ *
+ * `clips` in WALK order (reviewOf's rows, walkOrder); `rendered`: the project
+ * has a rendered take or a saved version.
+ *
+ * @param {{
+ * project: string, projectTitle: string, projectKind?: string,
+ * clips: Array<{ id: string, verdict: string, fetched?: boolean }>,
+ * rendered: boolean,
+ * at: number,
+ * benchHref: (clip: string) => string,
+ * }} o
+ */
+export function walkDecisions({ project, projectTitle, projectKind, clips, rendered, at, benchHref }) {
+ const rows = (Array.isArray(clips) ? clips : []).filter((c) => c && typeof c.id === "string");
+ const waiting = rows.filter((c) => c.verdict === "unreviewed");
+ if (!waiting.length) return [];
+ const walked = rows.length - waiting.length;
+ if (!walked && !rendered) return [];
+ const first = waiting.find((c) => c.fetched) ?? waiting[0];
+ const what = walkWhat(waiting.length);
+ const ids = waiting.map((c) => c.id);
+ const why =
+ `${what} · ${walked} of ${rows.length} walked · next ${first.id}` +
+ `${first.fetched === false && !waiting.some((c) => c.fetched) ? " (not fetched yet)" : ""}` +
+ ` — ${ids.slice(0, 6).join(", ")}${ids.length > 6 ? ` and ${ids.length - 6} more` : ""}`;
+ const href = benchHref(first.id);
+ return waiting.map((c) => ({
+ project,
+ projectTitle,
+ ...(projectKind ? { projectKind } : {}),
+ kind: CLIPS_UNWALKED,
+ target: c.id,
+ what,
+ why,
+ href,
+ severity: "open",
+ at,
+ }));
+}
diff --git a/umtool/lib/inbox/what.mjs b/umtool/lib/inbox/what.mjs
@@ -61,6 +61,13 @@ export const WHAT = {
"ambiguous-project": "two kinds match",
"machine-tool": "a required tool is missing",
"machine-disk": "disk nearly full",
+ "version-unjudged": "versions to judge",
+ "clips-unwalked": "clips not walked",
+ "quote-check-stale": "quote checks out of date",
+ "case-new-cues": "new transcripts since the last scan",
+ "x-jar-stale": "X's cookies are stale and X work waits",
+ "clip-quote-moved": "quotes heard away from the cut",
+ "clip-quote-missing": "quotes not heard in the cut",
};
/** A kind's words; an unknown kind reads as its id with spaces. */
diff --git a/umtool/lib/inbox/xJar.mjs b/umtool/lib/inbox/xJar.mjs
@@ -0,0 +1,40 @@
+// X'S LOGIN, WHEN X WORK WAITS (umtool redesign L4, "What needs you"): the
+// editor's cookie alerts (`GET /api/ops/services`, editor/app/lib/cookieAlerts.ts
+// over common/lib/serviceCookies.ts) carry X's jar age always, and an ALERT only
+// when the jar refused an X job or X jobs are queued behind it -- the rule the
+// editor's own banner draws by. So the Inbox shows the jar only when there is a
+// stale alert of X's family: one Blocking row, the editor's three short lines
+// (how old, the one thing to do, what it refused), its action the editor's
+// settings, where Refresh cookies / Connect X account and Recheck are.
+//
+// Nothing here asks X anything, and nothing refreshes the jar: a refresh is a
+// human click in the editor. Pure: lib/inbox/xJar.ts asks the editor.
+
+export const X_JAR_STALE = "x-jar-stale";
+
+/**
+ * The row, or null when no X work waits (or the payload is not one).
+ *
+ * @param {unknown} payload the services route's answer
+ * @param {{ href: string, now?: number }} o
+ */
+export function xJarDecision(payload, { href, now = Date.now() }) {
+ const p = /** @type {Record<string, any> | null} */ (payload && typeof payload === "object" ? payload : null);
+ const alerts = Array.isArray(p?.alerts) ? p.alerts : [];
+ const x = alerts.find((a) => a && a.family === "x" && a.state === "stale");
+ if (!x) return null;
+ const jar = p?.x && typeof p.x === "object" ? p.x : null;
+ const lines = [x.headline, x.fix, x.detail].map((s) => (typeof s === "string" ? s.trim() : "")).filter(Boolean);
+ const at = Date.parse(x.raisedAt ?? x.since ?? "") || now;
+ return {
+ project: "editor",
+ projectTitle: x.label ? `${x.label} login` : "X login",
+ kind: X_JAR_STALE,
+ target: x.service ?? "x",
+ why: lines.length ? lines.join(" ") : "X's cookies are past their age limit — refresh them on the editor's settings",
+ href,
+ severity: "blocking",
+ at,
+ ...(jar && Number.isFinite(jar.ageMinutes) ? { ageMinutes: jar.ageMinutes } : {}),
+ };
+}
diff --git a/umtool/lib/inbox/xJar.ts b/umtool/lib/inbox/xJar.ts
@@ -0,0 +1,45 @@
+import type { Decision } from "@/lib/decisions";
+import { askEditor, editorUrl } from "@/lib/articles/generation";
+import { xJarDecision } from "./xJar.mjs";
+
+// ---------------------------------------------------------------------------
+// X's jar, for the Inbox (lib/inbox/xJar.mjs says when it is a call): the
+// editor's services route asked through umtool's editor client (askEditor,
+// its WORKER_TOKEN), answered from a minute's memo, and never waited on for
+// more than WAIT_MS -- the Inbox and the rail's count read it, and an editor
+// that is slow or down must not slow them. Any failure is no row. SERVER ONLY.
+// ---------------------------------------------------------------------------
+
+/** UMTOOL_XJAR_MEMO_MS (the e2e suite's 0: each read asks the stub), else a minute. */
+const memoMs = () => {
+ const v = Number(process.env.UMTOOL_XJAR_MEMO_MS);
+ return Number.isFinite(v) && v >= 0 ? v : 60_000;
+};
+const WAIT_MS = 1500;
+
+type Memo = { at: number; value: Promise<Decision | null> } | null;
+const g = globalThis as typeof globalThis & { __umtoolXJarMemo?: Memo };
+
+/** Forget the memo (a spec that changed the stub's services; a Recheck). */
+export function clearXJarMemo(): void {
+ g.__umtoolXJarMemo = null;
+}
+
+async function ask(): Promise<Decision | null> {
+ const payload = await askEditor("/api/ops/services", { fresh: true });
+ return xJarDecision(payload, { href: `${editorUrl()}/settings` }) as Decision | null;
+}
+
+/** The X jar's row when X work waits on it, else none. Never throws. */
+export async function xJarDecisions({ fresh = false }: { fresh?: boolean } = {}): Promise<Decision[]> {
+ const m = g.__umtoolXJarMemo;
+ let value: Promise<Decision | null>;
+ if (m && !fresh && Date.now() - m.at < memoMs()) value = m.value;
+ else {
+ value = ask().catch(() => null);
+ g.__umtoolXJarMemo = { at: Date.now(), value };
+ }
+ const timeout = new Promise<null>((resolve) => setTimeout(() => resolve(null), WAIT_MS).unref?.());
+ const row = await Promise.race([value, timeout]).catch(() => null);
+ return row ? [row] : [];
+}
diff --git a/umtool/lib/projects/report.mjs b/umtool/lib/projects/report.mjs
@@ -1434,14 +1434,26 @@ export async function reportDecisions(ctx, summary) {
// there are any; a stale row -- the cut or the quote changed since -- says
// nothing).
{
- const { quoteGate, readQuoteCheck } = await import("../report/quoteCheck.mjs");
- for (const g of quoteGate(clips, await readQuoteCheck(dir))) {
+ const { alignPatch, quoteGate, readQuoteCheck } = await import("../report/quoteCheck.mjs");
+ const qdoc = await readQuoteCheck(dir);
+ for (const g of quoteGate(clips, qdoc)) {
const moved = g.status === "moved";
+ // The one press (L4, the Inbox's and the Checks list's): a moved quote's cut snapped to the words as heard
+ // (`window --align`'s patch, through the window writer); a quote not heard, checked again once refetched.
+ let settle = { kind: "quote-check", clips: [g.id], label: "Run quote-check" };
+ if (moved) {
+ try {
+ settle = { kind: "patch", clip: g.id, patch: alignPatch(clips.find((e) => e.id === g.id), qdoc.clips[g.id]), label: "Snap the cut to the words" };
+ } catch {
+ settle = null;
+ }
+ }
add(moved ? "clip-quote-moved" : "clip-quote-missing", g.id, g.why.replace("<p>", id), "blocking", {
href: clipHref(g.id),
fix: moved
? `umtool window ${id} ${g.id} --align # or --quote-ruled, having heard it`
: `umtool fetch ${id} --refetch ${g.id} && umtool quote-check ${id} --clips ${g.id} # or --quote-ruled, having heard it`,
+ ...(settle ? { settle } : {}),
});
}
}
@@ -1664,8 +1676,11 @@ export async function reportDecisions(ctx, summary) {
{
fix: rows.some((r) => r.fix) ? `umtool links ${id} --fix` : checkFix,
// The links whose fix is known (a Twitch id the site serves as v<id>) are rewritten in one press.
+ // A Rumble folder id the archive serves by its EMBED id (linkCheck.mjs fixSiteVideo, L1's mapping): Use embed ids.
settle: rows.some((r) => r.fix)
- ? { kind: "check-links", fix: true, label: `Fix ${rows.filter((r) => r.fix).length} link${rows.filter((r) => r.fix).length === 1 ? "" : "s"} (the site's v<id>)` }
+ ? rows.filter((r) => r.fix).every((r) => r.fixSiteVideo)
+ ? { kind: "check-links", fix: true, label: `Use embed ids (${rows.filter((r) => r.fix).length})` }
+ : { kind: "check-links", fix: true, label: `Fix ${rows.filter((r) => r.fix).length} link${rows.filter((r) => r.fix).length === 1 ? "" : "s"} (the site's v<id>)` }
: checkSettle,
clips: ids,
},
diff --git a/umtool/lib/report/linksCli.mjs b/umtool/lib/report/linksCli.mjs
@@ -82,22 +82,9 @@ export async function linksCommand(args, { root = REPORTS_ROOT, out = (s) => con
const fixed = [];
let undo = null;
if (flags.has("--fix")) {
- // ONE undo point before the rewrites (revisions/<stamp>-auto-before-links-fix): `umtool timeline <p> undo` takes them all back.
- if (doc.links.some((l) => l.state === "dead" && l.fix)) undo = await createSnapshot(project.dir, { label: `${AUTO_SNAPSHOT_PREFIX}links-fix` });
- for (const l of doc.links) {
- if (l.state !== "dead" || !l.fix) continue;
- // A Rumble folder id (linkCheck.mjs siteIdOf): the clip names the embed id the archive serves (`siteVideo`),
- // and a citeUrl that was the dead link moves with it; a QR built from the moment needs nothing else.
- if (l.fixSiteVideo) {
- const e = (m.timeline ?? []).find((x) => x?.id === l.clip);
- const patch = { siteVideo: l.fixSiteVideo, ...(e?.citeUrl === l.url ? { citeUrl: l.fix } : {}) };
- await withEditNotes(project, () => updateClip(project.dir, l.clip, patch));
- fixed.push({ clip: l.clip, from: l.url, to: l.fix, siteVideo: l.fixSiteVideo });
- continue;
- }
- await withEditNotes(project, () => updateClip(project.dir, l.clip, { citeUrl: l.fix }));
- fixed.push({ clip: l.clip, from: l.url, to: l.fix });
- }
+ const r = await applyLinkFixes(project, m, doc);
+ fixed.push(...r.fixed);
+ undo = r.undo;
if (fixed.length) {
m = await readManifest(project.dir);
doc = await runLinkCheck(project.dir, m, opts);
@@ -281,3 +268,48 @@ export async function linkPolicyCommand(args, { root = REPORTS_ROOT, out = (s) =
return e instanceof CliError ? 2 : 1;
}
}
+
+/**
+ * Rewrite every dead link `doc` knows the fix for, through the window writer,
+ * after ONE undo point (revisions/<stamp>-auto-before-links-fix: `umtool
+ * timeline <p> undo` takes them all back). The CLI's `--fix` over a check it
+ * just ran, and the page's (POST /api/report/links `fix`: the Checks list's
+ * and the Inbox's "Use embed ids") over the RECORDED one -- `guard`: only a
+ * clip still as that check saw it (its citeUrl the dead link, or no siteVideo
+ * yet for a Rumble folder id); an edit since is somebody's decision.
+ *
+ * A Rumble folder id (linkCheck.mjs siteIdOf, L1's mapping): the clip names the
+ * embed id the archive serves (`siteVideo`), and a citeUrl that was the dead
+ * link moves with it; a QR built from the moment needs nothing else. Any other
+ * fix (a Twitch id as v<id>) is the clip's citeUrl.
+ *
+ * @param {{ id: string, dir: string }} project
+ * @param {Record<string, any>} m the manifest the check read
+ * @param {{ links?: Array<Record<string, any>> } | null} doc
+ * @param {{ guard?: boolean }} [o]
+ */
+export async function applyLinkFixes(project, m, doc, { guard = false } = {}) {
+ const byId = new Map((m?.timeline ?? []).map((e) => [e?.id, e]));
+ const todo = (doc?.links ?? []).filter((l) => {
+ if (l.state !== "dead" || !l.fix) return false;
+ if (!guard) return true;
+ const e = byId.get(l.clip);
+ if (!e) return false;
+ return l.fixSiteVideo ? !e.siteVideo : e.citeUrl === l.url;
+ });
+ const fixed = [];
+ if (!todo.length) return { fixed, undo: null };
+ const undo = await createSnapshot(project.dir, { label: `${AUTO_SNAPSHOT_PREFIX}links-fix` });
+ for (const l of todo) {
+ if (l.fixSiteVideo) {
+ const e = byId.get(l.clip);
+ const patch = { siteVideo: l.fixSiteVideo, ...(e?.citeUrl === l.url ? { citeUrl: l.fix } : {}) };
+ await withEditNotes(project, () => updateClip(project.dir, l.clip, patch));
+ fixed.push({ clip: l.clip, from: l.url, to: l.fix, siteVideo: l.fixSiteVideo });
+ continue;
+ }
+ await withEditNotes(project, () => updateClip(project.dir, l.clip, { citeUrl: l.fix }));
+ fixed.push({ clip: l.clip, from: l.url, to: l.fix });
+ }
+ return { fixed, undo };
+}
diff --git a/umtool/lib/report/quoteCheck.test.mjs b/umtool/lib/report/quoteCheck.test.mjs
@@ -162,6 +162,10 @@ test("umtool check: a moved quote and a missing one are blocking, with the fix;
assert.match(ds[0].why, /a: its quote is heard \+13\.06 s from its cut — umtool window cut a --align/);
assert.equal(ds[0].fix, "umtool window cut a --align # or --quote-ruled, having heard it");
assert.match(ds[1].fix, /umtool fetch cut --refetch b/);
+ // The one press (L4): a moved quote's cut snapped to the words as heard (alignPatch); a missing one checked again.
+ assert.deepEqual(ds[0].settle, { kind: "patch", clip: "a", patch: alignPatch({ ...clip("a", 10), type: "clip" }, { ...row(10, "moved", { heard: { from: 23.06, to: 25 } }) }), label: "Snap the cut to the words" });
+ assert.equal(ds[0].settle.patch.lockCut, true);
+ assert.deepEqual(ds[1].settle, { kind: "quote-check", clips: ["b"], label: "Run quote-check" });
} finally {
await rm(root, { recursive: true, force: true });
}
diff --git a/umtool/playwright.config.ts b/umtool/playwright.config.ts
@@ -240,6 +240,8 @@ export default defineConfig({
// would otherwise enumerate every fixture article's corpus and add cards
// other specs count. refresh.spec runs the check itself, through its route.
`UMTOOL_REFRESH_CHECK=0 ` +
+ // The Inbox's X jar row (lib/inbox/xJar.ts) asks the stub's services on every read, not from a minute's memo.
+ `UMTOOL_XJAR_MEMO_MS=0 ` +
// The voice match's engine (release 34): the test kit's fake embedder,
// run by this node, in the place of scripts/speaker-embed.py and the
// TitaNet venv -- the same command line and JSON, no python, no model.