commit 580543775501562e6a18df5a56d58076fb3a3d13
parent a88342b80ff7b1fbd236eefed5d17450c07602aa
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 14 Oct 2026 13:20:33 -0400
refresh: the coverage rule in the daily check (unchecked, with why — never a silent 0 or a card); the sources gone said by where; changed recordings not tracked before an older parent
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
15 files changed, 228 insertions(+), 44 deletions(-)
diff --git a/common/controller/reportRefresh.ts b/common/controller/reportRefresh.ts
@@ -176,6 +176,7 @@ export async function planRefresh(body: ReportDraftBody, deps: ReportDraftDeps):
const m = refreshModel(gen, body);
if (m.note) warnings.push(m.note);
if (basis.from === "question") warnings.push(`i${n} recorded no enumeration: its question is searched again as one query`);
+ if (!basis.countsKnown) warnings.push(`changed recordings are not tracked before ${basis.at.slice(0, 10)}: i${n} recorded no matching-line counts (new ones are still found)`);
if (!basis.knownComplete) warnings.push(`i${n} kept no whole match set: a recording counts as new only when it was uploaded on or after ${basis.at.slice(0, 10)}`);
const parentIt = basis.queriesOf === n ? it : await readIteration(body.article, basis.queriesOf, paths).catch(() => null);
const parentUsd = parentIt ? Object.values(parentIt.usage).reduce((s, u) => s + u.usd, 0) : 0;
@@ -487,7 +488,12 @@ export async function diskRecordOf(channelsDir: string, slug: string, id: string
if (v.length) tracks.push({ name, cues: v });
}
const state = stateFromAvailability(await resolveEffectiveAvailability(dir).catch(() => null));
- return { cues: tracks[0]?.cues ?? [], tracks, ...(state !== "available" ? { state } : {}) };
+ // The platform a deletion is said on: its metadata's page.
+ const meta = entries.includes("metadata.info.json")
+ ? await readFile(path.join(dir, "metadata.info.json"), "utf8").then((t) => JSON.parse(t) as { webpage_url?: unknown }, () => null)
+ : null;
+ const platform = detectPlatform(typeof meta?.webpage_url === "string" ? meta.webpage_url : null);
+ return { cues: tracks[0]?.cues ?? [], tracks, ...(state !== "available" ? { state, ...(platform ? { platform } : {}) } : {}) };
}
/** A refresh iteration's refresh.json, or null. */
diff --git a/common/lib/report/draft/refresh/basis.ts b/common/lib/report/draft/refresh/basis.ts
@@ -221,6 +221,7 @@ export async function refreshBasis(article: string, n: number, paths?: StorePath
fromKind = "question";
}
const known: Record<string, number | null> = found?.known ? { ...found.known } : found ? knownOf(found.perQuery) : {};
+ const countsKnown = !!found && (found.from === "refresh" ? Object.values(known).some((c) => c !== null) : [...found.perQuery.values()].some((rows) => Object.values(rows).some((c) => c !== null)));
const knownComplete = !!found && (found.from === "refresh" || found.from === "trace" || [...found.perQuery.values()].some((rows) => Object.keys(rows).length > 0));
for (const c of cited) if (c.kind !== "post" && !(c.id in known)) known[c.id] = null;
return {
@@ -233,6 +234,7 @@ export async function refreshBasis(article: string, n: number, paths?: StorePath
from: fromKind,
known,
knownComplete,
+ countsKnown,
cited,
source: found?.source ?? null,
at: it.endedAt ?? it.updatedAt,
diff --git a/common/lib/report/draft/refresh/delta.ts b/common/lib/report/draft/refresh/delta.ts
@@ -145,7 +145,7 @@ export async function deltaCandidates(
// A recording as a refresh reads it: its cues (the primary track) and every
// track it has (named: `transcript.en.vtt`, `transcript.en-orig.vtt`,
// `transcript.json` …), and its platform state when it is not available.
-export type RecordRead = { cues: readonly WordCue[]; tracks?: { name: string; cues: readonly WordCue[] }[]; state?: string | null };
+export type RecordRead = { cues: readonly WordCue[]; tracks?: { name: string; cues: readonly WordCue[] }[]; state?: string | null; platform?: string | null };
export type QuoteReaders = {
// The recording (the disk, the build); null: not in the archive.
@@ -203,7 +203,7 @@ export async function recheckQuotes(cited: readonly CitedQuote[], readers: Quote
const en = (rec.tracks ?? []).find((x) => isEn(x.name) && !isEnOrig(x.name));
const orig = (rec.tracks ?? []).find((x) => isEnOrig(x.name));
const enOrig = en && orig ? enOrigDifference(en.cues, orig.cues, cite) : null;
- const extra = { ...(state ? { state } : {}), ...(enOrig ? { enOrig } : {}) };
+ const extra = { ...(state ? { state, ...(rec.platform ? { platform: rec.platform } : {}) } : {}), ...(enOrig ? { enOrig } : {}) };
if (verdict.status === "ok") {
out.push(verdict.nowAt !== undefined ? { ...base, status: "moved", nowAt: verdict.nowAt, ...extra } : { ...base, status: "ok", ...extra });
} else {
@@ -234,18 +234,29 @@ export async function computeDelta(
const quotes = await recheckQuotes(basis.cited, readers, o.signal ? { signal: o.signal } : {});
const drifted = quotes.filter((q) => q.status === "drifted").map((q) => q.citation);
const deleted = [...new Set(quotes.filter((q) => q.status === "missing" || q.state).map((q) => `${q.channel}/${q.id}`))];
+ const goneFromArchive = [...new Set(quotes.filter((q) => q.status === "missing").map((q) => `${q.channel}/${q.id}`))];
+ const removed = new Map<string, { source: string; state: string; platform: string | null }>();
+ for (const q of quotes) {
+ const source = `${q.channel}/${q.id}`;
+ if (q.status !== "missing" && q.state && !removed.has(source)) removed.set(source, { source, state: q.state, platform: q.platform ?? null });
+ }
const enOrig = quotes.filter((q) => q.enOrig).map((q) => q.citation);
- const status = newIds.length || cand.changed.length || drifted.length || deleted.length ? "changed" : "no-change";
+ const changed = basis.countsKnown ? cand.changed : [];
+ const status = newIds.length || changed.length || drifted.length || deleted.length ? "changed" : "no-change";
return {
at: (o.now ?? new Date()).toISOString(),
status,
matched: Object.keys(cand.matchedSet).length,
newIds,
new: newIds.map((id) => cand.rows.get(id)!).filter(Boolean),
- changed: cand.changed,
+ changed: basis.countsKnown ? cand.changed : [],
+ changedTracked: basis.countsKnown,
+ ...(basis.countsKnown ? {} : { changedSince: basis.at }),
unmatched: cand.unmatched,
drifted,
deleted,
+ goneFromArchive,
+ removedOnPlatform: [...removed.values()],
enOrig,
quotes,
partial: cand.partial,
diff --git a/common/lib/report/draft/refresh/refresh.test.ts b/common/lib/report/draft/refresh/refresh.test.ts
@@ -19,7 +19,7 @@ import type { CorpusToolsLike, TaskDeps } from "../tasks/types";
import { fromTrace, fromTurns, knownOf, refreshBasis } from "./basis";
import { deltaCandidates, recheckQuotes, type RecordRead } from "./delta";
import { estimateUpdateUsd, refresh, refreshFeedback, type RefreshHooks } from "./task";
-import { deltaLine, type RefreshFile } from "./types";
+import { deltaLine, goneParts, outcomeOf, type RefreshDelta, type RefreshFile } from "./types";
const tmp = await mkdtemp(path.join(os.tmpdir(), "refresh-"));
after(() => rm(tmp, { recursive: true, force: true }));
@@ -181,6 +181,7 @@ test("refreshBasis: the iteration's trace, the report's quotes; a revision reads
assert.deepEqual(b.scope.channels, ["synth-kitchen", "synth-other", "synth-social"], "the trace's scope, plus every channel cited");
assert.deepEqual(b.known, { "pie-02": 2, "bread-01": 1 });
assert.equal(b.knownComplete, true);
+ assert.equal(b.countsKnown, true);
assert.deepEqual(b.cited.map((c) => c.citation), ["c1", "c2", "c3"]);
assert.equal(b.source, "local:/fake/build/out");
@@ -202,6 +203,7 @@ test("refreshBasis: the iteration's trace, the report's quotes; a revision reads
assert.equal(q.from, "question");
assert.deepEqual(q.queries, [{ query: "contest" }]);
assert.equal(q.knownComplete, false);
+ assert.equal(q.countsKnown, false);
assert.deepEqual(Object.keys(q.known).sort(), ["bread-01", "pie-02"], "the cited are known");
});
@@ -386,7 +388,7 @@ test("the estimate and the revision's feedback", () => {
assert.match(fb, /^A REFRESH of i3 \(made 2026-10-01\)/);
assert.match(fb, /NEW FINDINGS[\s\S]*it was rigged/);
assert.match(fb, /QUOTES THAT CHANGED[\s\S]*"I paid for the new mixer myself" \(synth-kitchen\/bread-01 @ 0:10\) — now: "I bought the mixer"/);
- assert.match(fb, /SOURCES GONE FROM THEIR PLATFORM[\s\S]*synth-kitchen\/pie-02 \(deleted\)/);
+ assert.match(fb, /SOURCES GONE FROM THEIR PLATFORM[\s\S]*synth-kitchen\/pie-02 \(deleted on its platform\)/);
});
test("a refresh iteration names its parent; refresh.json is an iteration file", async () => {
@@ -396,3 +398,37 @@ test("a refresh iteration names its parent; refresh.json is an iteration file",
await createIteration("synth", { kind: "refresh", model: "m", parent: 1 }, paths);
await writeIterationFile("synth", 2, "refresh.json", { ok: 1 }, paths);
});
+
+test("the sources gone, said by where; changes not tracked before an older parent, never a silent 0", async () => {
+ const d = { newIds: [], changed: [], drifted: [], deleted: ["a/1", "a/2", "b/3", "c/4"], goneFromArchive: ["c/4"], removedOnPlatform: [{ source: "a/1", state: "deleted", platform: "youtube" }, { source: "a/2", state: "deleted", platform: "youtube" }, { source: "b/3", state: "private", platform: "rumble" }] };
+ assert.deepEqual(goneParts(d), ["2 sources deleted on YouTube", "1 source made private on Rumble", "1 source gone from the archive"]);
+ assert.equal(deltaLine({ ...d, deleted: ["c/4"], goneFromArchive: ["c/4"], removedOnPlatform: [] }), "1 source gone from the archive");
+ assert.equal(deltaLine({ newIds: [], changed: [], drifted: [], deleted: ["x/1"] }), "1 source deleted", "a record from before the split");
+
+ // A trace with no counts: the refresh says changes were not tracked, and the outcome's `changed` is null.
+ const paths = store();
+ await doneSweep(paths);
+ const noCounts = TRACE.map((e) => (e.t === "enumerate" ? { ...e, counts: undefined } : e));
+ await writeIterationFile("synth", 1, "trace.jsonl", noCounts.map((e) => JSON.stringify(e)).join("\n") + "\n", paths);
+ const b = await refreshBasis("synth", 1, paths);
+ assert.equal(b.countsKnown, false);
+ await createIteration("synth", { kind: "refresh", model: "claude-sonnet-5-5", parent: 1 }, paths);
+ const h = harness({ recs: BASE.map((r) => (r.id === "bread-01" ? { ...r, lines: [...r.lines, "the contest came up twice"] } : r)) });
+ const out = await refresh({ article: "synth", n: 2, model: "claude-sonnet-5-5", extractorModel: "claude-haiku-4-5", maxUsd: 3, fetch: false }, h.deps(paths));
+ assert.equal(out.status, "done");
+ const f = (await readJson(iterationFile(paths, "synth", 2, "refresh.json"))) as RefreshFile;
+ assert.equal(f.delta?.changedTracked, false);
+ assert.deepEqual(f.delta?.changed, [], "bread-01's lines changed, but nothing recorded them before");
+ assert.equal(f.delta?.changedSince, f.basis.at);
+ assert.ok(f.warnings.some((w) => w.startsWith(`changed recordings are not tracked before ${f.basis.at.slice(0, 10)}`)), f.warnings.join("; "));
+ assert.equal(outcomeOf(f).changed, null);
+ assert.equal(outcomeOf({ ...f, delta: { ...(f.delta as RefreshDelta), changedTracked: true } }).changed, 0);
+});
+
+test("a source deleted on its platform: the recheck carries the platform the summary names", async () => {
+ const out = await recheckQuotes(
+ [{ citation: "c1", kind: "video", channel: "synth-kitchen", id: "pie-02", start: 5, end: 9.8, quote: "I did not enter the contest this year" }],
+ { recordOf: recordReader(BASE, { "pie-02": { state: "deleted", platform: "youtube" } }) },
+ );
+ assert.deepEqual({ status: out[0]!.status, state: out[0]!.state, platform: out[0]!.platform }, { status: "ok", state: "deleted", platform: "youtube" });
+});
diff --git a/common/lib/report/draft/refresh/task.ts b/common/lib/report/draft/refresh/task.ts
@@ -45,6 +45,7 @@ import {
REFRESH_VERSION,
deltaLine,
outcomeOf,
+ platformName,
type BuildStep,
type FetchStep,
type RefreshBasis,
@@ -130,7 +131,7 @@ export function refreshFeedback(o: { parent: number; since: string; delta: Refre
parts.push(
[
"SOURCES GONE FROM THEIR PLATFORM (the archive keeps them; their quotes still verify) — keep their findings, and say in the summary that these were since removed:",
- ...[...new Map(deleted.map((q) => [`${q.channel}/${q.id}`, q])).values()].map((q) => `- ${q.channel}/${q.id} (${q.state})`),
+ ...[...new Map(deleted.map((q) => [`${q.channel}/${q.id}`, q])).values()].map((q) => `- ${q.channel}/${q.id} (${q.state} on ${platformName(q.platform)})`),
].join("\n"),
);
}
@@ -177,6 +178,7 @@ async function refreshBody(h: TaskHandle, input: RefreshInput): Promise<TaskOutc
queries: basis.queries,
from: basis.from,
knownComplete: basis.knownComplete,
+ countsKnown: basis.countsKnown,
source: basis.source,
at: basis.at,
knownCount: Object.keys(basis.known).length,
@@ -191,6 +193,7 @@ async function refreshBody(h: TaskHandle, input: RefreshInput): Promise<TaskOutc
await save();
h.log(`refresh of ${h.article} ${iterationLabel(parent)}: ${basis.queries.length} quer${basis.queries.length === 1 ? "y" : "ies"} (from its ${basis.from}), ${channels.length} channel(s), ${basis.cited.length} cited quote(s)`);
if (basis.from === "question") warnings.push(`i${parent} recorded no enumeration: its question is searched again as one query`);
+ if (!basis.countsKnown) warnings.push(`changed recordings are not tracked before ${basis.at.slice(0, 10)}: i${parent} recorded no matching-line counts (new ones are still found)`);
if (!basis.knownComplete) warnings.push(`i${parent} kept no whole match set: a recording counts as new only when it was uploaded on or after ${basis.at.slice(0, 10)}`);
h.trace({ t: "note", text: `refresh of ${iterationLabel(parent)}: ${basis.queries.map((q) => q.query).join(", ")} over ${channels.join(", ")}` });
const stages = input.fetch === false ? 2 : 4;
diff --git a/common/lib/report/draft/refresh/types.ts b/common/lib/report/draft/refresh/types.ts
@@ -43,6 +43,9 @@ export type RefreshBasis = {
// recorded (null: not recorded), summed over the queries. The report's own
// cited recordings are in it.
known: Record<string, number | null>;
+ // Whether `known` carries matching-line counts (a trace from umtool R4 on, a
+ // refresh's record): without them a changed recording cannot be told.
+ countsKnown: boolean;
// Whether `known` is the whole match set then. When it is not (a run whose
// answers were not kept, or the question alone), a recording counts as new
// only when it was uploaded on or after `at`'s day.
@@ -80,8 +83,10 @@ export type QuoteRecheck = {
// drifted: the words over the quote's seconds now; moved: where they start now
now?: string;
nowAt?: number;
- // The recording's platform state when it is gone from the platform (deleted, private).
+ // The recording's platform state when it is gone from the platform (deleted,
+ // private), and the platform.
state?: string;
+ platform?: string;
// The en track and the en-orig track's words over the cite, when they differ.
enOrig?: { en: string; orig: string };
message?: string;
@@ -100,6 +105,10 @@ export type RefreshDelta = {
new: MatchedRow[];
// Matched before and now, their matching lines changed (a transcript replaced or re-cut).
changed: string[];
+ // Whether changes could be told (the basis recorded matching lines); when not,
+ // `changed` is empty because nothing was tracked before `changedSince`.
+ changedTracked: boolean;
+ changedSince?: string;
// Matched before, not now (with a complete scan).
unmatched: string[];
// Citations whose words are not at their cite now.
@@ -107,6 +116,10 @@ export type RefreshDelta = {
// The cited sources (`<channel>/<id>`) that are gone: not in the archive,
// or deleted / private on their platform.
deleted: string[];
+ // The same, split: gone from the archive, and deleted or private on their
+ // platform (the archive keeps those).
+ goneFromArchive: string[];
+ removedOnPlatform: { source: string; state: string; platform: string | null }[];
// Citations whose en and en-orig tracks differ over the cite.
enOrig: string[];
quotes: QuoteRecheck[];
@@ -171,7 +184,8 @@ export type RefreshFile = {
export type RefreshOutcome = {
status: RefreshStatus;
newIds: number;
- changed: number;
+ // null: changes were not tracked (the parent recorded no matching-line counts).
+ changed: number | null;
drifted: number;
deleted: number;
summary: string;
@@ -181,7 +195,7 @@ export function outcomeOf(f: Pick<RefreshFile, "status" | "summary" | "delta">):
return {
status: f.status,
newIds: f.delta?.newIds.length ?? 0,
- changed: f.delta?.changed.length ?? 0,
+ changed: f.delta && f.delta.changedTracked === false ? null : (f.delta?.changed.length ?? 0),
drifted: f.delta?.drifted.length ?? 0,
deleted: f.delta?.deleted.length ?? 0,
summary: f.summary,
@@ -190,13 +204,46 @@ export function outcomeOf(f: Pick<RefreshFile, "status" | "summary" | "delta">):
const plural = (n: number, one: string, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
+const PLATFORM_NAMES: Record<string, string> = {
+ youtube: "YouTube",
+ rumble: "Rumble",
+ odysee: "Odysee",
+ twitch: "Twitch",
+ kick: "Kick",
+ archiveorg: "archive.org",
+ bitchute: "BitChute",
+ twitter: "X",
+ bluesky: "Bluesky",
+};
+/** A platform's name as a person writes it ("YouTube"); unknown: "its platform". */
+export const platformName = (p: string | null | undefined) => (p ? (PLATFORM_NAMES[p] ?? p) : "its platform");
+
+/** The sources gone, said by where: "1 source deleted on YouTube", "1 gone from the archive". */
+export function goneParts(d: Pick<RefreshDelta, "deleted"> & Partial<Pick<RefreshDelta, "goneFromArchive" | "removedOnPlatform">>): string[] {
+ // A record from before the split: its count, unsplit.
+ if (!d.goneFromArchive && !d.removedOnPlatform) return d.deleted.length ? [`${plural(d.deleted.length, "source")} deleted`] : [];
+ const out: string[] = [];
+ const by = new Map<string, number>();
+ for (const r of d.removedOnPlatform ?? []) {
+ const k = `${r.state === "private" ? "made private" : "deleted"} on ${platformName(r.platform)}`;
+ by.set(k, (by.get(k) ?? 0) + 1);
+ }
+ for (const [k, n] of by) out.push(`${plural(n, "source")} ${k}`);
+ const gone = d.goneFromArchive?.length ?? 0;
+ if (gone) out.push(`${plural(gone, "source")} gone from the archive`);
+ return out;
+}
+
/** The delta in one line, as the umtool page shows it. */
-export function deltaLine(d: Pick<RefreshDelta, "newIds" | "changed" | "drifted" | "deleted">, since?: string | null): string {
+export function deltaLine(
+ d: Pick<RefreshDelta, "newIds" | "changed" | "drifted" | "deleted"> & Partial<Pick<RefreshDelta, "goneFromArchive" | "removedOnPlatform">>,
+ since?: string | null,
+): string {
const parts = [
d.newIds.length ? `${plural(d.newIds.length, "new recording")} ${d.newIds.length === 1 ? "matches" : "match"}` : null,
d.changed.length ? `${plural(d.changed.length, "recording")} changed` : null,
d.drifted.length ? `${plural(d.drifted.length, "quote")} changed` : null,
- d.deleted.length ? `${plural(d.deleted.length, "source")} deleted` : null,
+ ...goneParts(d),
].filter(Boolean);
return parts.length ? parts.join(" · ") : `Nothing new${since ? ` since ${since.slice(0, 10)}` : ""}`;
}
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -2,8 +2,8 @@
## [Unreleased]
- **Refresh an article: fetch what is new, see what changed, update.** `pnpm ops report-draft --json '{"task": "refresh", "article": "<id>"}' --wait` (or umtool's **Refresh…**) takes the article's current report — or the iteration named by `"iteration"` — and runs ONE job on its own lane, `draft:refresh`: it fetches the report's scope and every channel its citations touch through the editor's own actions (`sync`, the channel's report, `transcribe-bucket` for only what landed; `fetch-posts` for a posts channel; a platform held or cooling down is skipped and said), builds the site whose build holds them locally (never a deploy), searches again with the report's own recorded enumerations (its trace; an older run's turns; else its question) and reads every cited quote again (words changed, `en` against `en-orig`, a source gone). Nothing changed: the new `refresh` iteration ends **no change**, $0. Something changed: a sweep of only the new and changed recordings, then a revision of the report with its findings and the quote fixes, within the caps — past one it ends **held by the cap** with the delta and the estimate. What it found is the iteration's `refresh.json`; the log ends `@@report-draft {…, refresh: {status, newIds, changed, drifted, deleted, summary}}`. `"fetch": false` reads the corpus as it stands; `"dryRun": true` answers the plan and writes nothing. Needs a restart of the editor and umtool.
-- **umtool's Refresh: plan, then confirm.** The article piece's **⋯ → Refresh…**, the Iterations tab's **Refresh…** and the Next card (when one is suggested) open the plan — the iteration refreshed and what it searches again, each channel's fetches or why one is skipped, the site built, the model, the cap and the day's spend — and **Refresh** starts the job (the Running list follows it). The Overview then says what it found: "1 new recording matches · 1 quote changed" (or "Nothing new since <date>"), the new recordings, the quotes that changed and what they say now, the fetches and the build, the spend or the cap that held it; a refresh's card on the Iterations tab carries the same line. A refresh with a report is an **iteration ready** card like any other; making it current stays yours.
-- **The Inbox suggests a refresh.** Once a day per active article with a current report (parked, done and muted pieces are skipped), umtool runs the report's enumerations again over the corpus it read — no fetch, no model — and an article with new matches gets a **Review** card, "3 new recordings mention this since 2026-10-01: …", whose action is **Refresh**. A refresh the cap held is a **Your call** card until something newer runs. The check is kept in `REPORTS_ROOT/.umtool/refresh-check.json`; `umtool refresh --check` runs it now.
+- **umtool's Refresh: plan, then confirm.** The article piece's **⋯ → Refresh…**, the Iterations tab's **Refresh…** and the Next card (when one is suggested) open the plan — the iteration refreshed and what it searches again, each channel's fetches or why one is skipped, the site built, the model, the cap and the day's spend — and **Refresh** starts the job (the Running list follows it). The Overview then says what it found: "1 new recording matches · 1 quote changed" (or "Nothing new since <date>"), the new recordings, the quotes that changed and what they say now, the fetches and the build, the spend or the cap that held it; the sources gone are said by where ("1 source deleted on YouTube", "1 source gone from the archive"), and for an iteration made before match counts were kept, changed recordings are "not tracked before <date>" rather than none; a refresh's card on the Iterations tab carries the same line. A refresh with a report is an **iteration ready** card like any other; making it current stays yours.
+- **The Inbox suggests a refresh.** Once a day per active article with a current report (parked, done and muted pieces are skipped), umtool runs the report's enumerations again over the corpus it read — no fetch, no model — and an article with new matches gets a **Review** card, "3 new recordings mention this since 2026-10-01: …", whose action is **Refresh**. The check reads the build the report read, else the research corpus — and only when that corpus holds every channel of the report's scope: otherwise the article is **unchecked**, with why ("the build holding harbor-radio is not on this machine; channels not in the research corpus: …"), and gets no card. A refresh the cap held is a **Your call** card until something newer runs. The check is kept in `REPORTS_ROOT/.umtool/refresh-check.json`; `umtool refresh --check` runs it now and prints the unchecked ones with their reason.
- **`umtool refresh <article>`** prints the plan; `--yes` starts it; `--no-fetch` skips the fetch and the build; `--check [<article>]` runs the daily check.
- **A sweep can be restricted to given recordings: `"ids"`.** `report-draft {"task": "sweep", …, "ids": ["…"]}` keeps them in the iteration's scope: an enumeration answers only their rows, a read of another recording is refused, and the free-text search is not offered (the pipeline reads exactly those). A refresh's update uses it.
- **A sweep's trace keeps each enumeration's matching lines** (`counts`), so a later refresh can tell a recording whose transcript changed; a refresh adds `fetch`, `build` and `delta` lines to its own trace.
diff --git a/umtool/bin/refresh.ts b/umtool/bin/refresh.ts
@@ -38,9 +38,9 @@ if (has("--check")) {
}
for (const c of out.checked) {
console.log(
- c.error
- ? `${c.article} i${c.iteration}: not checked — ${c.error}`
- : `${c.article} i${c.iteration}: ${c.newCount} new recording${c.newCount === 1 ? "" : "s"} since ${c.since.slice(0, 10)}${c.titles.length ? ` (${c.titles.join(", ")})` : ""}${c.partial ? " — partial" : ""}`,
+ c.status === "unchecked"
+ ? `${c.article} i${c.iteration}: UNCHECKED — ${c.reason ?? c.error ?? "no corpus here holds its scope"}`
+ : `${c.article} i${c.iteration}: ${c.newCount} new recording${c.newCount === 1 ? "" : "s"} since ${c.since.slice(0, 10)}${c.titles.length ? ` (${c.titles.join(", ")})` : ""}${c.partial ? " — partial" : ""} · over ${c.corpus ?? c.source}`,
);
}
for (const s of out.skipped) console.log(`${s.article}: ${s.why}`);
diff --git a/umtool/components/articles/RefreshSummary.tsx b/umtool/components/articles/RefreshSummary.tsx
@@ -68,7 +68,12 @@ export default function RefreshSummary({ row, iterationsHref }: { row: RefreshRo
)}
{row.deleted.length > 0 && (
<p className="text-[12.5px] text-doubt-text" data-refresh-deleted={row.deleted.length}>
- Gone: <span className="font-mono">{row.deleted.join(", ")}</span>
+ {row.gone.join(" · ")}: <span className="font-mono">{row.deleted.join(", ")}</span>
+ </p>
+ )}
+ {row.counts.changed === null && (
+ <p className="text-[12px] text-muted" data-refresh-untracked="">
+ {row.warnings.find((w) => w.startsWith("changed recordings are not tracked")) ?? "changed recordings are not tracked for this iteration"}
</p>
)}
<p className="text-[12px] text-muted" data-refresh-steps="">
diff --git a/umtool/e2e/fixtures/editor-stub.mjs b/umtool/e2e/fixtures/editor-stub.mjs
@@ -724,7 +724,7 @@ function finishRefresh(job, parent, p) {
const since = p.endedAt ?? p.updatedAt;
const quote = "the lighthouse budget was never approved";
const delta = quiet
- ? { at, status: "no-change", matched: 4, newIds: [], new: [], changed: [], unmatched: [], drifted: [], deleted: [], enOrig: [], quotes: [{ citation: "c1", kind: "video", channel: "harbor-radio", id: "hr-2019a", start: 600, status: "ok", quote }], partial: false, unreached: [], matchedSet: { "hr-2019a": 1, "hr-2022a": 1, "hr-2024a": 1, "hr-2026a": 1 } }
+ ? { at, status: "no-change", matched: 4, newIds: [], new: [], changed: [], changedTracked: true, unmatched: [], drifted: [], deleted: [], goneFromArchive: [], removedOnPlatform: [], enOrig: [], quotes: [{ citation: "c1", kind: "video", channel: "harbor-radio", id: "hr-2019a", start: 600, status: "ok", quote }], partial: false, unreached: [], matchedSet: { "hr-2019a": 1, "hr-2022a": 1, "hr-2024a": 1, "hr-2026a": 1 } }
: {
at,
status: "changed",
@@ -734,7 +734,10 @@ function finishRefresh(job, parent, p) {
changed: [],
unmatched: [],
drifted: ["c1"],
+ changedTracked: true,
deleted: [],
+ goneFromArchive: [],
+ removedOnPlatform: [],
enOrig: [],
quotes: [{ citation: "c1", kind: "video", channel: "harbor-radio", id: "hr-2019a", start: 600, status: "drifted", quote, now: "the lighthouse budget was not approved that year", nowAt: 600 }],
partial: false,
diff --git a/umtool/e2e/fixtures/refresh-fixture.mjs b/umtool/e2e/fixtures/refresh-fixture.mjs
@@ -45,19 +45,22 @@ export const REFRESH_REPORT = {
sections: [{ id: "the-budget", title: "The budget", claims: [{ id: "k1", text: "The budget was never approved", citations: ["c1"] }] }],
};
-export function makeRefreshFixture({ articles, source }) {
- const it1 = path.join(articles, REFRESH_ARTICLE, "iterations", "1");
+// `article` and `channels`: another article like it (the unit tests' checks of
+// a build that is gone, or a scope the research corpus does not hold).
+export function makeRefreshFixture({ articles, source, article = REFRESH_ARTICLE, channels = ["harbor-radio"] }) {
+ const REFRESH_ARTICLE_ = article;
+ const it1 = path.join(articles, REFRESH_ARTICLE_, "iterations", "1");
put(path.join(it1, "iteration.json"), {
format: "archilyzer-iteration",
version: 1,
- article: REFRESH_ARTICLE,
+ article: REFRESH_ARTICLE_,
n: 1,
kind: "sweep",
parent: null,
copyOf: null,
model: "claude-sonnet-5-5",
question: REFRESH_QUESTION,
- scope: { channels: ["harbor-radio"] },
+ scope: { channels },
status: "done",
usage: { "claude-sonnet-5-5": { usd: 0.4, inputTokens: 20000, outputTokens: 1000, calls: 3 } },
coverage: { matched: 4, read: 4, partial: false, unreached: [] },
@@ -71,14 +74,15 @@ export function makeRefreshFixture({ articles, source }) {
path.join(it1, "trace.jsonl"),
[
ev({ t: "run", phase: "start", task: "sweep-agent", model: "claude-sonnet-5-5" }),
- ev({ t: "scope", source, channels: ["harbor-radio"], question: REFRESH_QUESTION, model: "claude-sonnet-5-5" }),
+ ev({ t: "scope", source, channels, question: REFRESH_QUESTION, model: "claude-sonnet-5-5" }),
ev({ t: "enumerate", query: RESEARCH_PHRASE, n: 4, ids: ["hr-2019a", "hr-2022a", "hr-2024a", "hr-2026a"], partial: false, unreached: [], counts: { "hr-2019a": 1, "hr-2022a": 1, "hr-2024a": 1, "hr-2026a": 1 } }),
ev({ t: "run", phase: "end", status: "done", summary: "ok", usd: 0.4, minutes: 1 }),
].join("\n") + "\n",
);
- put(path.join(it1, "report.json"), REFRESH_REPORT);
- put(path.join(articles, REFRESH_ARTICLE, "report.json"), REFRESH_REPORT);
- put(path.join(articles, REFRESH_ARTICLE, "iterations", "current.json"), {
+ const report = { ...REFRESH_REPORT, id: REFRESH_ARTICLE_ };
+ put(path.join(it1, "report.json"), report);
+ put(path.join(articles, REFRESH_ARTICLE_, "report.json"), report);
+ put(path.join(articles, REFRESH_ARTICLE_, "iterations", "current.json"), {
format: "archilyzer-iterations-current",
version: 1,
report: 1,
@@ -86,5 +90,5 @@ export function makeRefreshFixture({ articles, source }) {
video: null,
reportAt: AT,
});
- return { article: REFRESH_ARTICLE };
+ return { article: REFRESH_ARTICLE_ };
}
diff --git a/umtool/e2e/refresh.spec.ts b/umtool/e2e/refresh.spec.ts
@@ -71,7 +71,7 @@ test("the daily check finds the recording the sweep never saw: the Inbox's sugge
expect(r.ok()).toBe(true);
const out = (await r.json()) as { checked: { article: string; newCount: number; newIds: string[]; titles: string[]; since: string }[] };
expect(out.checked).toHaveLength(1);
- expect(out.checked[0]).toMatchObject({ article: REFRESH_ARTICLE, newCount: 1, newIds: [REFRESH_NEW.id], titles: [REFRESH_NEW.title] });
+ expect(out.checked[0]).toMatchObject({ article: REFRESH_ARTICLE, status: "checked", newCount: 1, newIds: [REFRESH_NEW.id], titles: [REFRESH_NEW.title] });
await page.goto(urls.homeHref());
const card = page.locator(`[data-lit-line][data-piece='${PIECE}'][data-card='refresh-available']`);
diff --git a/umtool/lib/articles/refresh.ts b/umtool/lib/articles/refresh.ts
@@ -1,5 +1,5 @@
import { readIterationFile, readIterations, type Iteration } from "yt-dlp-transcript-common/lib/report/iterations";
-import { REFRESH_FORMAT, deltaLine, type RefreshFile, type RefreshPlan } from "yt-dlp-transcript-common/lib/report/draft/refresh/types";
+import { REFRESH_FORMAT, deltaLine, goneParts, type RefreshFile, type RefreshPlan } from "yt-dlp-transcript-common/lib/report/draft/refresh/types";
import { articleHref } from "@/lib/hrefs";
import { ARTICLES_KEY } from "@/lib/articles/key.mjs";
import { askEditor, enqueueDraft } from "./generation";
@@ -40,11 +40,14 @@ export type RefreshRow = {
// The refresh's own: running, no-change, updated, held-by-cap, failed, cancelled.
refresh: RefreshFile["status"] | null;
summary: string;
- counts: { newIds: number; changed: number; drifted: number; deleted: number };
+ // changed: null when the refreshed iteration recorded no matching-line counts (not tracked).
+ counts: { newIds: number; changed: number | null; drifted: number; deleted: number };
// The new recordings' titles (up to 8), the quotes that changed.
news: { id: string; title: string | null; date: string | null }[];
drifted: { citation: string; quote: string; now: string | null }[];
deleted: string[];
+ // The sources gone, said by where ("1 source deleted on YouTube", "1 source gone from the archive").
+ gone: string[];
fetch: { channel: string; action: string; status: string; reason: string | null }[];
build: { site: string | null; status: string; reason: string | null } | null;
update: { estimateUsd: number; capUsd: number | null; refusal: string | null; usd: number | null; model: string } | null;
@@ -64,10 +67,11 @@ function rowOf(it: Iteration, f: RefreshFile | null, hasReport: boolean): Refres
status: it.status,
refresh: f?.status ?? null,
summary: f?.summary || (d ? deltaLine(d, f?.basis.at) : it.status === "queued" ? "Queued" : it.status === "running" ? "Fetching and searching again…" : (it.error ?? "")),
- counts: { newIds: d?.newIds.length ?? 0, changed: d?.changed.length ?? 0, drifted: d?.drifted.length ?? 0, deleted: d?.deleted.length ?? 0 },
+ counts: { newIds: d?.newIds.length ?? 0, changed: d && d.changedTracked === false ? null : (d?.changed.length ?? 0), drifted: d?.drifted.length ?? 0, deleted: d?.deleted.length ?? 0 },
news: (d?.new ?? []).slice(0, 8).map((r) => ({ id: r.id, title: r.title, date: r.date })),
drifted: (d?.quotes ?? []).filter((q) => q.status === "drifted").slice(0, 8).map((q) => ({ citation: q.citation, quote: q.quote, now: q.now ?? null })),
deleted: d?.deleted ?? [],
+ gone: d ? goneParts(d) : [],
fetch: (f?.fetch ?? []).map((s) => ({ channel: s.channel, action: s.action, status: s.status, reason: s.reason ?? null })),
build: f?.build ? { site: f.build.site, status: f.build.status, reason: f.build.reason ?? null } : null,
update: f?.update ? { estimateUsd: f.update.estimateUsd, capUsd: f.update.capUsd, refusal: f.update.refusal ?? null, usd: f.update.usd ?? null, model: f.update.model } : null,
diff --git a/umtool/lib/inbox/refresh.test.ts b/umtool/lib/inbox/refresh.test.ts
@@ -84,6 +84,8 @@ test("the daily check: the current report's enumeration again over the corpus it
assert.equal(c.error, undefined, c.error);
assert.deepEqual({ newCount: c.newCount, newIds: c.newIds, titles: c.titles, iteration: c.iteration }, { newCount: 1, newIds: [fixture.REFRESH_NEW.id], titles: [fixture.REFRESH_NEW.title], iteration: 1 });
assert.match(c.source, /^local:.*research-public$/);
+ assert.equal(c.status, "checked");
+ assert.match(c.corpus ?? "", /^its own build \(local:.*research-public\)$/);
// Kept: today's is not checked again.
const again = await mod.refresh.runRefreshChecks(pieces, { only: fixture.REFRESH_ARTICLE });
assert.deepEqual(again, { checked: [], skipped: [{ article: fixture.REFRESH_ARTICLE, why: "checked today" }] });
@@ -125,6 +127,25 @@ test("the Inbox's cards: refresh-available in Review (action Refresh, the plan o
await mod.lifecycle.setLifecycle(`a:articles/${fixture.REFRESH_ARTICLE}`, "active");
});
+test("the coverage rule: its own build gone, the research corpus holding the scope is a real check (said); a scope no corpus here holds is UNCHECKED with why — never 0 new, never a card", async () => {
+ const articles = process.env.ARTICLES_DIR!;
+ fixture.makeRefreshFixture({ articles, source: `local:${path.join(tmp, "gone-build", "out")}`, article: "refresh-gone" });
+ fixture.makeRefreshFixture({ articles, source: `local:${path.join(tmp, "gone-build", "out")}`, article: "refresh-wide", channels: ["harbor-radio", "nowhere-chan"] });
+ const [graph, life, mutes] = await ctx();
+ const pieces = mod.refresh.checkable(graph, life, mutes);
+ const gone = (await mod.refresh.runRefreshChecks(pieces, { only: "refresh-gone" })).checked[0]!;
+ assert.equal(gone.status, "checked");
+ assert.match(gone.corpus ?? "", /^the research corpus \(local:.*research-public\)$/);
+ assert.equal(gone.newCount, 1, "the research corpus holds harbor-radio: a real answer");
+ const wide = (await mod.refresh.runRefreshChecks(pieces, { only: "refresh-wide" })).checked[0]!;
+ assert.equal(wide.status, "unchecked");
+ assert.equal(wide.reason, "the build holding harbor-radio, nowhere-chan is not on this machine; channels not in the research corpus: nowhere-chan");
+ assert.deepEqual({ newCount: wide.newCount, newIds: wide.newIds }, { newCount: 0, newIds: [] });
+ const rows = await mod.refresh.refreshDecisions(graph, life, mutes, { background: false });
+ assert.ok(rows.some((r) => r.kind === "refresh-available" && r.piece === "a:articles/refresh-gone"));
+ assert.ok(!rows.some((r) => r.piece === "a:articles/refresh-wide"), "an unchecked article gets no card");
+});
+
test("the plan and the start are the editor's: a dry run, then report-draft refresh", async () => {
const plan = await mod.articles.planArticleRefresh(fixture.REFRESH_ARTICLE, { fetch: false });
assert.equal(plan.article, fixture.REFRESH_ARTICLE);
diff --git a/umtool/lib/inbox/refresh.ts b/umtool/lib/inbox/refresh.ts
@@ -13,7 +13,7 @@ import { lifecycleOf, type LifecycleRead } from "@/lib/lifecycle";
import { isMuted, type MutesRead } from "@/lib/mutes";
import { REPORTS_ROOT } from "@/lib/paths";
import type { Piece, PieceGraph } from "@/lib/pieces";
-import { openSource } from "@/lib/research/sources";
+import { localDir, openSource } from "@/lib/research/sources";
// ---------------------------------------------------------------------------
// A REFRESH, SUGGESTED (plans/umtool-redesign.md, R4) -- two Inbox kinds:
@@ -37,6 +37,13 @@ import { openSource } from "@/lib/research/sources";
// `umtool refresh --check` run it now. Muted, parked and done pieces are
// skipped; so is an article a refresh newer than the check already covers.
//
+// THE COVERAGE RULE — no silent zeros. A check reads the build the iteration
+// read when it is on this machine and holds every channel of its scope; else
+// Research's local corpus, when THAT holds every channel. When neither does,
+// the article is `unchecked`, with the reason ("the build holding harbor-radio
+// is not on this machine; channels not in the research corpus: x, y") — never
+// "0 new" — and it gets no card; `umtool refresh --check` prints it.
+//
// SERVER-ONLY.
// ---------------------------------------------------------------------------
@@ -49,6 +56,11 @@ export const MAX_CHECK_QUERIES = 12;
export type CheckEntry = {
article: string;
+ // checked: a real answer (`corpus` says over which); unchecked: no corpus here
+ // holds the scope (`reason`), so nothing is claimed.
+ status: "checked" | "unchecked";
+ corpus?: string;
+ reason?: string;
// The iteration checked (the current report's) and when it was made.
iteration: number;
since: string;
@@ -111,19 +123,42 @@ function enumerateOver(source: ShardSource): EnumerateFn {
};
}
-// The corpus an article's check reads: the build its iteration read, when it
-// is on this machine, else Research's local corpus.
-async function sourceFor(recorded: string | null): Promise<{ handle: string; source: ShardSource }> {
+// The channels a composed dir holds (its corpus.json), or null when it is not there.
+async function heldChannels(dir: string): Promise<string[] | null> {
+ try {
+ const c = JSON.parse(await readFile(/* turbopackIgnore: true */ path.join(dir, "corpus.json"), "utf8")) as { channels?: { slug?: unknown }[] };
+ return (c.channels ?? []).map((x) => x?.slug).filter((x): x is string => typeof x === "string");
+ } catch {
+ return null;
+ }
+}
+
+type Picked = { ok: true; handle: string; source: ShardSource; corpus: string } | { ok: false; reason: string };
+
+// The corpus an article's check reads (the coverage rule, above): the build its
+// iteration read when it is here and holds the scope, else Research's local
+// corpus when it holds the scope, else none — with why.
+export async function pickCheckCorpus(recorded: string | null, channels: readonly string[]): Promise<Picked> {
+ const lacking = (held: string[]) => channels.filter((c) => !held.includes(c));
+ let own: string;
if (recorded?.startsWith("local:")) {
const dir = recorded.slice("local:".length);
- const ok = await stat(/* turbopackIgnore: true */ path.join(dir, "corpus.json")).then(() => true, () => false);
- if (ok) {
+ const held = await heldChannels(dir);
+ if (held && !lacking(held).length) {
const reg = new SourceRegistry({ kind: "local", dir });
- return { handle: recorded, source: (await reg.resolve(undefined)).source };
+ return { ok: true, handle: recorded, source: (await reg.resolve(undefined)).source, corpus: `its own build (${recorded})` };
}
+ own = held ? `its build does not hold ${lacking(held).join(", ")}` : `the build holding ${channels.join(", ")} is not on this machine`;
+ } else {
+ own = recorded ? `it read ${recorded}, not a build on this machine` : "it recorded no corpus";
}
+ const dir = localDir();
+ const held = await heldChannels(dir);
+ if (!held) return { ok: false, reason: `${own}; the research corpus (${dir}) is not there` };
+ const missing = lacking(held);
+ if (missing.length) return { ok: false, reason: `${own}; channels not in the research corpus: ${missing.join(", ")}` };
const opened = await openSource(null);
- return { handle: opened.option.handle, source: opened.source };
+ return { ok: true, handle: opened.option.handle, source: opened.source, corpus: `the research corpus (${opened.option.handle})` };
}
/** The articles a check is for: the store's, active (not parked, done or muted). */
@@ -145,13 +180,19 @@ export async function checkArticle(article: string, now = new Date()): Promise<C
const its = (await readIterations(article, sitesPaths()).catch(() => null))?.iterations ?? [];
const looked = its.filter((it) => it.kind === "refresh" && it.parent === n && it.status === "done").sort((a, b) => b.n - a.n)[0];
const basis = await refreshBasis(article, looked?.n ?? n, sitesPaths());
- const { handle, source } = await sourceFor(basis.source);
+ const picked = await pickCheckCorpus(basis.source, basis.scope.channels);
+ if (!picked.ok) {
+ return { ...base, status: "unchecked", reason: picked.reason, since: basis.at, newCount: 0, newIds: [], titles: [], source: "", partial: false };
+ }
+ const { handle, source } = picked;
const c = await deltaCandidates({ queries: basis.queries.slice(0, MAX_CHECK_QUERIES), scope: basis.scope }, enumerateOver(source), {
...(basis.knownComplete ? { known: basis.known } : { since: basis.at }),
});
const newIds = c.newIds.filter((id) => !(id in basis.known));
return {
...base,
+ status: "checked",
+ corpus: picked.corpus,
since: basis.at,
newCount: newIds.length,
newIds: newIds.slice(0, 20),
@@ -160,7 +201,7 @@ export async function checkArticle(article: string, now = new Date()): Promise<C
partial: c.partial,
};
} catch (e) {
- return { ...base, since: "", newCount: 0, newIds: [], titles: [], source: "", partial: false, error: (e as Error).message };
+ return { ...base, status: "unchecked", reason: (e as Error).message, since: "", newCount: 0, newIds: [], titles: [], source: "", partial: false, error: (e as Error).message };
}
}
@@ -248,7 +289,8 @@ export async function refreshDecisions(graph: PieceGraph, life: LifecycleRead, m
// New recordings since the current report, by today's check.
if (!pieces.includes(p)) continue;
const c = kept.articles[article];
- if (!c || c.error || c.newCount <= 0 || c.iteration !== read.current.report) continue;
+ // An unchecked article (no corpus here holds its scope) claims nothing: no card.
+ if (!c || c.error || c.status === "unchecked" || c.newCount <= 0 || c.iteration !== read.current.report) continue;
// A refresh made after the check already looked (or is looking).
if (its.some((it) => it.kind === "refresh" && it.parent === c.iteration && Date.parse(it.createdAt) >= Date.parse(c.checkedAt))) continue;
if (its.some((it) => it.kind === "refresh" && (it.status === "queued" || it.status === "running"))) continue;