commit b348a8688e6f5832ee716f259dbe453cf9ca936e
parent c143aa6f85f72b206f41e60aeb8f8cc1506a6fc2
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 14 Oct 2026 14:24:31 -0400
common, editor: recurring reports wired to R4 — a tick's stage 1 is fetchScope, a living tick is report-draft refresh (R5)
- controller/reportTick.ts r4Steps(draft): fetchAndBuild → fetchScope (the
editor's own paced fetches, then the local build of the site holding the
scope; a held or cooling platform, a channel no build holds, a build not
a site's are warnings on the tick, only a build that ran and failed fails
it); refresh → report-draft {"task":"refresh"} awaited, refresh.json's
status the outcome (updated → done, no-change, held-by-cap with the cap's
refusal and the estimate; a cap refusal at the ask is held too).
- The tick: a series computes its window first (an empty one fetches
nothing), then stage 1 over the window, then the edition; a living report
with a report runs the refresh, which does its own stage 1 (its report's
scope and every cited channel); its first sweep runs stage 1 first.
autoMakeCurrent acts only on `updated`. A tick's warnings are recorded
on it (`warnings`).
- editor/app/api/ops/_reportSchedule.ts wires both through refreshEditor.
- Specs: unit (r4Steps over stubbed calls: the warnings, a failed build,
each refresh status; the wired tick: living no-change/held/updated with
autoMakeCurrent, a series' fetch over its window, nothing fetched for an
empty window); report-draft.spec: a series edition over the fake model
(the sync through the editor's door, the window check, the sweep with
from/to, the edition's title) and a living report's refresh (no change,
$0, nothing made current); ops-api.spec's tick runs stage 1 and fails on
the missing build, saying so.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
7 files changed, 329 insertions(+), 40 deletions(-)
diff --git a/common/controller/reportSchedule.test.ts b/common/controller/reportSchedule.test.ts
@@ -349,12 +349,12 @@ test("series held by a cap: no edition (the next tick covers the window), the ti
assert.equal(s?.running, null);
});
-test("until R4 is wired: the fetch step refuses, and the tick fails saying so", async () => {
+test("without R4's steps (no editor door): the fetch step refuses, and the tick fails saying so", async () => {
const paths = store();
await createSchedule(parseCreate({ shape: "series", topic: "Unwired", channels: ["chan-a"], cadence: weekly, tz: TZ }), depsOf(paths));
const t = await runTick("unwired", { trigger: "now", jobId: "j1" }, depsOf(paths, { fetchAndBuild: notWiredFetch, refresh: notWiredRefresh }), ctx());
assert.equal(t.status, "failed");
- assert.match(t.reason ?? "", /not wired: R4's stage 1/);
+ assert.match(t.reason ?? "", /^not wired: no fetch-and-build step/);
});
// ─── the real generateEdition, as far as it runs without a model ───
@@ -383,3 +383,90 @@ test("generateEdition: a window with nothing in it is quiet ($0, no job); past t
assert.equal(await readIterationFile("real-2026-10-14", 1, "report.json", paths).catch(() => null), null);
void readFileSync;
});
+
+// ─── R4's steps, wired (r4Steps), over stubbed calls ───
+
+import { r4Steps, type R4Calls } from "./reportTick";
+
+type FetchResult = Awaited<ReturnType<R4Calls["fetchScope"]>>;
+const okJob = (jobId: string) => ({ ok: true as const, jobId, stream: new ReadableStream<string>(), done: Promise.resolve({ status: "done" as const, jobId }) });
+
+test("r4Steps.fetchAndBuild: stage 1 over the scope; a held platform is a warning, not a failure; a failed build fails", async () => {
+ const paths = store();
+ const draft = { paths, corpusTools: async () => assert.fail("no corpus") };
+ const asked: unknown[] = [];
+ const result = (over: Partial<FetchResult> = {}): FetchResult => ({
+ fetch: [
+ { channel: "chan-a", action: "sync", status: "done", jobId: "j1" },
+ { channel: "chan-b", action: "sync", status: "refused", reason: "youtube is held: skipped, as polite scraping asks" },
+ ],
+ build: { site: "site-x", status: "done", jobIds: ["b1"] },
+ warnings: ["chan-c is on no site"],
+ ...over,
+ });
+ const steps = r4Steps(draft, { fetchScope: async (scope, _d, o) => (asked.push({ scope, signal: !!o?.signal }), result()) });
+ const ok = await steps.fetchAndBuild({ channels: ["chan-a", "chan-b"], from: "2026-10-12", to: "2026-10-18" }, ctx());
+ assert.deepEqual(asked, [{ scope: { channels: ["chan-a", "chan-b"], from: "2026-10-12", to: "2026-10-18" }, signal: true }]);
+ assert.equal(ok.ok, true);
+ assert.deepEqual(ok.warnings, ["chan-c is on no site", "chan-b sync: youtube is held: skipped, as polite scraping asks"]);
+ const failed = await r4Steps(draft, { fetchScope: async () => result({ build: { site: "site-x", status: "failed", reason: "next build exited 1" } }) }).fetchAndBuild({ channels: ["chan-a"] }, ctx());
+ assert.deepEqual({ ok: failed.ok, status: !failed.ok && failed.status, reason: !failed.ok && failed.reason }, { ok: false, status: "failed", reason: "the local build of site-x failed: next build exited 1" });
+});
+
+test("r4Steps.refresh: report-draft refresh awaited; refresh.json's status is the outcome (updated, no-change, held-by-cap); a cap refusal is held", async () => {
+ const paths = store();
+ await doneIteration(paths, "shop");
+ const it2 = await createIteration("shop", { kind: "sweep", model: "claude-sonnet-5-5", question: "Q?", scope: { channels: ["chan-a"] } }, paths);
+ await updateIteration("shop", it2.n, { status: "done", usage: { "claude-sonnet-5-5": { usd: 0.8, inputTokens: 1, outputTokens: 1 } } }, paths);
+ const draft = { paths, corpusTools: async () => assert.fail("no corpus") };
+ const asked: Record<string, unknown>[] = [];
+ const file = (status: string, extra: Record<string, unknown> = {}) => ({ format: "archilyzer-refresh", status, summary: `${status} summary`, warnings: [], fetch: [{ channel: "chan-b", action: "sync", status: "refused", reason: "rumble is cooling down" }], ...extra });
+ const run = (status: string, extra: Record<string, unknown> = {}) =>
+ r4Steps(draft, {
+ enqueueReportDraft: (async (b: Record<string, unknown>) => (asked.push(b), { result: okJob("rj"), iteration: it2.n })) as never,
+ readRefreshFile: (async () => file(status, extra)) as never,
+ }).refresh("shop", { maxUsd: 3 }, ctx());
+ const updated = await run("updated");
+ assert.deepEqual(asked[0], { task: "refresh", article: "shop", maxUsd: 3 });
+ assert.deepEqual({ status: updated.status, iteration: updated.iteration, usd: updated.usd, jobId: updated.jobId }, { status: "done", iteration: it2.n, usd: 0.8, jobId: "rj" });
+ assert.deepEqual(updated.warnings, ["chan-b sync: rumble is cooling down"]);
+ assert.equal((await run("no-change")).status, "no-change");
+ const held = await run("held-by-cap", { update: { model: "m", estimateUsd: 4.5, capUsd: 5, refusal: "the day's Claude API spend is $20.00 … daily cap" } });
+ assert.deepEqual({ status: held.status, estimateUsd: held.estimateUsd, reason: held.reason }, { status: "held-by-cap", estimateUsd: 4.5, reason: "the day's Claude API spend is $20.00 … daily cap" });
+ const refused = await r4Steps(draft, {
+ enqueueReportDraft: (async () => ({ result: { ok: false, error: "the day's Claude API spend is $20.00 (2026-10-14, UTC), at or past the $20.00 daily cap (settings.generation.caps.daily) — refused" } })) as never,
+ }).refresh("shop", {}, ctx());
+ assert.equal(refused.status, "held-by-cap");
+});
+
+test("the wired tick: living updated + autoMakeCurrent is made current (only on updated); a series fetches its window, its warnings on the tick, nothing fetched for an empty window", async () => {
+ const paths = store();
+ await createSchedule(parseCreate({ shape: "living", topic: "Auto", channels: ["chan-a"], cadence: weekly, tz: TZ, autoMakeCurrent: true }), depsOf(paths));
+ await doneIteration(paths, "auto");
+ const made: string[] = [];
+ const extra = { makeCurrent: async (a: string, n: number) => made.push(`${a}/${n}`) };
+ const fetchCalls: unknown[] = [];
+ const steps = (refresh: StepOutcome): Partial<TickSteps> => ({
+ fetchAndBuild: async (scope) => (fetchCalls.push(scope), { ok: true, warnings: ["youtube is held: skipped"] }),
+ refresh: async () => refresh,
+ });
+ const noChange = await runTick("auto", { trigger: "now", jobId: "j1" }, depsOf(paths, steps({ status: "no-change", usd: 0, iteration: 2 }), NOW, extra), ctx());
+ assert.equal(noChange.status, "no-change");
+ const held = await runTick("auto", { trigger: "now", jobId: "j2" }, depsOf(paths, steps({ status: "held-by-cap", usd: 0, iteration: 3, estimateUsd: 4, reason: "daily cap", warnings: ["rumble is cooling down"] }), NOW, extra), ctx());
+ assert.deepEqual({ status: held.status, estimateUsd: held.estimateUsd, warnings: held.warnings }, { status: "held-by-cap", estimateUsd: 4, warnings: ["rumble is cooling down"] });
+ assert.deepEqual(made, []);
+ const updated = await runTick("auto", { trigger: "now", jobId: "j3" }, depsOf(paths, steps({ status: "done", usd: 1.1, iteration: 4 }), NOW, extra), ctx());
+ assert.equal(updated.status, "done");
+ assert.deepEqual(made, ["auto/4"]);
+ // A living report with a report: the refresh runs its own stage 1.
+ assert.deepEqual(fetchCalls, []);
+
+ await createSchedule(parseCreate({ shape: "series", topic: "Wired", channels: ["chan-a", "chan-b"], cadence: weekly, tz: TZ }), depsOf(paths));
+ const series = await runTick("wired", { trigger: "now", jobId: "j4" }, depsOf(paths, { ...steps({ status: "no-change", usd: 0 }), generateEdition: async () => ({ status: "done", usd: 0.5, iteration: 1 }) }), ctx());
+ assert.deepEqual(fetchCalls, [{ channels: ["chan-a", "chan-b"], from: "2026-10-07", to: "2026-10-13" }]);
+ assert.deepEqual({ status: series.status, warnings: series.warnings }, { status: "done", warnings: ["youtube is held: skipped"] });
+ assert.deepEqual((await readSchedule("wired", paths))?.ticks.at(-1)?.warnings, ["youtube is held: skipped"]);
+ // At once again: nothing to cover, nothing fetched.
+ await runTick("wired", { trigger: "now", jobId: "j5" }, depsOf(paths, steps({ status: "no-change", usd: 0 })), ctx());
+ assert.equal(fetchCalls.length, 1);
+});
diff --git a/common/controller/reportTick.ts b/common/controller/reportTick.ts
@@ -14,11 +14,14 @@
// triage?(...) reserved for R6 (triage first)
//
// THE TICK, by shape:
-// living fetchAndBuild → refresh → when `autoMakeCurrent`, the new
-// iteration made current, else left ready (an iteration-ready
-// Review card). A living report with no report yet takes its first
-// sweep instead of a refresh.
-// series fetchAndBuild → an EDITION: a new article
+// living refresh (R4's task: its own stage 1 over the report's scope and
+// every channel its citations touch, then what changed, then the
+// update) → on `updated` with `autoMakeCurrent`, the new iteration
+// made current, else left ready (an iteration-ready Review card).
+// A living report with no report yet takes fetchAndBuild and its
+// first sweep instead.
+// series the window first (an empty one fetches nothing), then
+// fetchAndBuild over it → an EDITION: a new article
// `<series>-<YYYY-MM-DD>` (the tick's day) over whole days — the
// day after the last edition's window end through the day before
// the tick (the first: the cadence's length back), never a day
@@ -54,6 +57,7 @@ import { readSchedule } from "../lib/report/schedule/store";
import { editionTitle, editionWindow, nothingToCover, type Edition, type Schedule, type Tick, type TickStatus } from "../lib/report/schedule/types";
import { dailyCapRefusal, dayUsage, utcDay } from "./generationUsage";
import { enqueueReportDraft, type ReportDraftDeps } from "./reportDraft";
+import { fetchScope, readRefreshFile } from "./reportRefresh";
import {
PENDING_PREFIX,
claimTick,
@@ -77,7 +81,9 @@ const SPEND_POLL_MS = 5_000;
export type StepCtx = { log: (line: string) => void; signal: AbortSignal };
-export type FetchOutcome = { ok: true; note?: string } | { ok: false; status: "failed" | "held-by-cap"; reason: string };
+// `warnings`: what stage 1 skipped and said (a held or cooling platform, a
+// channel no build holds) -- recorded on the tick, never its failure.
+export type FetchOutcome = { ok: true; note?: string; warnings?: string[] } | { ok: false; status: "failed" | "held-by-cap"; reason: string; warnings?: string[] };
export type StepStatus = "done" | "no-change" | "quiet" | "held-by-cap" | "failed" | "cancelled";
export type StepOutcome = {
@@ -91,6 +97,8 @@ export type StepOutcome = {
estimateUsd?: number;
// Recordings the window check matched.
matched?: number;
+ // What a step skipped and said (a refresh's fetch on a held platform).
+ warnings?: string[];
};
export type EditionInput = {
@@ -106,16 +114,20 @@ export type EditionInput = {
};
export type TickSteps = {
- fetchAndBuild(scope: { channels: string[] }, ctx: StepCtx): Promise<FetchOutcome>;
+ // Stage 1 over a scope: a series' edition (its window), a living report's
+ // first sweep. A living report's refresh runs its own stage 1 (over its
+ // report's scope and every channel its citations touch).
+ fetchAndBuild(scope: { channels: string[]; from?: string; to?: string }, ctx: StepCtx): Promise<FetchOutcome>;
refresh(article: string, o: { model?: string; maxUsd?: number }, ctx: StepCtx): Promise<StepOutcome>;
generateEdition(input: EditionInput, ctx: StepCtx): Promise<StepOutcome>;
// R6: a cheap pass that flags what is worth a sweep (not called yet).
triage?(input: { schedule: Schedule; window: { from: string; to: string } }, ctx: StepCtx): Promise<unknown>;
};
-// Until R4 is in this editor, its two steps refuse, saying so.
-export const NOT_WIRED_FETCH = "not wired: R4's stage 1 (fetch + local build) is not in this editor yet";
-export const NOT_WIRED_REFRESH = "not wired: R4's refresh (report-draft task refresh) is not in this editor yet";
+// Steps that refuse, saying so: what a deps without R4's wiring (r4Steps
+// below) gets — a test, or a process with no editor door.
+export const NOT_WIRED_FETCH = "not wired: no fetch-and-build step (R4's stage 1) in this process";
+export const NOT_WIRED_REFRESH = "not wired: no refresh step (R4's report-draft refresh) in this process";
export const notWiredFetch: TickSteps["fetchAndBuild"] = async () => ({ ok: false, status: "failed", reason: NOT_WIRED_FETCH });
export const notWiredRefresh: TickSteps["refresh"] = async () => ({ status: "failed", usd: 0, reason: NOT_WIRED_REFRESH });
@@ -247,6 +259,100 @@ export function editionGenerator(deps: EditionDeps): TickSteps["generateEdition"
};
}
+// ─── R4's steps (the seam, wired) ───
+
+/** What the R4 wiring calls (injectable: the unit tests stub them). */
+export type R4Calls = {
+ fetchScope: typeof fetchScope;
+ enqueueReportDraft: typeof enqueueReportDraft;
+ readRefreshFile: typeof readRefreshFile;
+};
+
+const stepWords = (x: { channel?: string; action?: string; site?: string | null; reason?: string }) => {
+ const what = [x.channel, x.action, x.site ? `build ${x.site}` : ""].filter(Boolean).join(" ");
+ return what ? `${what}: ${x.reason ?? "skipped"}` : (x.reason ?? "skipped");
+};
+
+/**
+ * fetchAndBuild and refresh over R4 (controller/reportRefresh.ts):
+ * fetchAndBuild `fetchScope` — each channel's paced fetches, then the
+ * local build of the site that holds them (never a deploy).
+ * A step refused or skipped (a held or cooling platform, a
+ * channel no build holds) is a WARNING on the tick; only a
+ * build that ran and failed fails it.
+ * refresh `report-draft {"task": "refresh"}` — its own stage 1, what
+ * changed, the update — awaited; its refresh.json's status
+ * is the outcome: updated → done (the new iteration),
+ * no-change, held-by-cap (with the cap's refusal and the
+ * estimate).
+ * Both need `deps.refreshEditor` (the editor's in-process door).
+ */
+export function r4Steps(draft: ReportDraftDeps, calls: Partial<R4Calls> = {}): Pick<TickSteps, "fetchAndBuild" | "refresh"> {
+ const c: R4Calls = { fetchScope, enqueueReportDraft, readRefreshFile, ...calls };
+ return {
+ fetchAndBuild: async (scope, ctx) => {
+ let r: Awaited<ReturnType<typeof fetchScope>>;
+ try {
+ r = await c.fetchScope(scope, draft, { signal: ctx.signal, log: ctx.log });
+ } catch (e) {
+ if (ctx.signal.aborted) throw e;
+ return { ok: false, status: "failed", reason: `the fetch could not run: ${(e as Error).message}` };
+ }
+ const warnings = [
+ ...r.warnings,
+ ...r.fetch.filter((f) => f.status === "refused" || f.status === "skipped" || f.status === "failed").map(stepWords),
+ ...(r.build && r.build.status !== "done" && r.build.status !== "failed" && r.build.reason ? [stepWords({ ...r.build, site: r.build.site })] : []),
+ ];
+ if (r.build?.status === "failed") {
+ return { ok: false, status: "failed", reason: `the local build${r.build.site ? ` of ${r.build.site}` : ""} failed${r.build.reason ? `: ${r.build.reason}` : ""}`, warnings };
+ }
+ const fetched = r.fetch.filter((f) => f.status === "done").length;
+ return { ok: true, note: `stage 1: ${fetched} fetch${fetched === 1 ? "" : "es"} done${r.build?.site ? `, ${r.build.site} built (${r.build.status})` : ""}`, warnings };
+ },
+ refresh: async (article, o, ctx) => {
+ const out = await c.enqueueReportDraft({ task: "refresh", article, ...(o.model ? { model: o.model } : {}), ...(o.maxUsd ? { maxUsd: o.maxUsd } : {}) }, draft);
+ if (!out.result.ok || !("iteration" in out)) {
+ const reason = (out.result as { error: string }).error;
+ return { status: isCapRefusal(reason) ? "held-by-cap" : "failed", usd: 0, reason };
+ }
+ const result = out.result as Extract<StreamActionResult, { ok: true }>;
+ void result.stream.cancel();
+ const n = out.iteration;
+ ctx.log(`refresh ${article} i${n}: job ${result.jobId}`);
+ const stop = () => getRegistry().cancel(result.jobId);
+ ctx.signal.addEventListener("abort", stop, { once: true });
+ try {
+ await result.done;
+ } finally {
+ ctx.signal.removeEventListener("abort", stop);
+ }
+ const it = await readIteration(article, n, draft.paths).catch(() => null);
+ const usd = it ? iterationUsd(it) : 0;
+ const f = await c.readRefreshFile(article, n, draft.paths).catch(() => null);
+ const warnings = [...(out.warnings ?? []), ...(f?.warnings ?? []), ...(f?.fetch ?? []).filter((x) => x.status === "refused" || x.status === "skipped").map(stepWords)];
+ const base = { iteration: n, usd, jobId: result.jobId, ...(warnings.length ? { warnings } : {}) };
+ ctx.log(`refresh ${article} i${n} ended ${f?.status ?? it?.status ?? "unread"}: ~$${usd.toFixed(2)}${f?.summary ? ` — ${f.summary}` : ""}`);
+ switch (f?.status) {
+ case "updated":
+ return { status: "done", ...base, ...(f.summary ? { reason: f.summary } : {}) };
+ case "no-change":
+ return { status: "no-change", ...base, reason: f.summary };
+ case "held-by-cap":
+ return {
+ status: "held-by-cap",
+ ...base,
+ reason: f.update?.refusal ?? f.summary,
+ ...(f.update?.estimateUsd !== undefined ? { estimateUsd: f.update.estimateUsd } : {}),
+ };
+ case "cancelled":
+ return { status: "cancelled", ...base, reason: "cancelled" };
+ default:
+ return { status: ctx.signal.aborted ? "cancelled" : "failed", ...base, reason: f?.summary || it?.error || `the refresh ended ${it?.status ?? "unread"}` };
+ }
+ },
+ };
+}
+
// ─── the tick ───
export type TickDeps = ScheduleDeps & {
@@ -304,10 +410,20 @@ export async function runTick(id: string, run: TickRun, deps: TickDeps, ctx: Ste
let edition: Edition | null = null;
try {
ctx.log(`${s.shape} ${id}: ${run.trigger === "now" ? "ticked now" : `the ${run.scheduledFor} window`}${run.missed ? ` (stands in for ${run.missed} missed)` : ""}`);
- const f = await deps.steps.fetchAndBuild({ channels: s.scope.channels }, ctx);
- if (!f.ok) return await finish({ status: f.status, usd: 0, reason: f.reason });
- if (f.note) ctx.log(f.note);
- if (ctx.signal.aborted) return await finish({ status: "cancelled", usd: 0, reason: "cancelled" });
+ // Stage 1 over a scope; what it skipped is the tick's warnings.
+ const warnings: string[] = [];
+ const stage1 = async (scope: { channels: string[]; from?: string; to?: string }): Promise<Tick | null> => {
+ const f = await deps.steps.fetchAndBuild(scope, ctx);
+ for (const w of f.warnings ?? []) {
+ warnings.push(w);
+ ctx.log(`warning: ${w}`);
+ }
+ if (!f.ok) return finish({ status: f.status, usd: 0, reason: f.reason, ...(warnings.length ? { warnings } : {}) });
+ if (f.note) ctx.log(f.note);
+ if (ctx.signal.aborted) return finish({ status: "cancelled", usd: 0, reason: "cancelled", ...(warnings.length ? { warnings } : {}) });
+ return null;
+ };
+ const warned = () => (warnings.length ? { warnings: [...new Set(warnings)] } : {});
if (s.shape === "living") {
const article = s.article ?? s.id;
@@ -315,13 +431,14 @@ export async function runTick(id: string, run: TickRun, deps: TickDeps, ctx: Ste
if (!(await hasReportToRefresh(article, deps.paths))) {
ctx.log(`${article} has no report yet: its first sweep`);
const back = addDays(today, -cadenceDays(s.cadence));
- out = await deps.steps.generateEdition(
- { schedule: s, article, title: null, window: { from: s.scope.from ?? back, to: today }, quietCheck: false },
- ctx,
- );
+ const window = { from: s.scope.from ?? back, to: today };
+ const stopped = await stage1({ channels: s.scope.channels, ...window });
+ if (stopped) return stopped;
+ out = await deps.steps.generateEdition({ schedule: s, article, title: null, window, quietCheck: false }, ctx);
} else {
out = await deps.steps.refresh(article, { ...(s.model ? { model: s.model } : {}), ...(s.caps?.maxUsd ? { maxUsd: s.caps.maxUsd } : {}) }, ctx);
}
+ warnings.push(...(out.warnings ?? []));
let reason = out.reason;
if (out.status === "done" && out.iteration && s.autoMakeCurrent) {
try {
@@ -338,6 +455,7 @@ export async function runTick(id: string, run: TickRun, deps: TickDeps, ctx: Ste
...(out.iteration ? { iteration: out.iteration } : {}),
...(reason ? { reason } : {}),
...(out.estimateUsd !== undefined ? { estimateUsd: out.estimateUsd } : {}),
+ ...warned(),
});
}
@@ -348,6 +466,8 @@ export async function runTick(id: string, run: TickRun, deps: TickDeps, ctx: Ste
return await finish({ status: "no-change", usd: 0, reason: nothingToCover(w.nextFrom) });
}
const window = w.window;
+ const stopped = await stage1({ channels: s.scope.channels, ...window });
+ if (stopped) return stopped;
const n = Math.max(0, ...(s.editions ?? []).map((e) => e.n)) + 1;
// Named for the tick's day (the window ends the day before it).
const article = await editionArticle(s, today, deps.paths);
@@ -381,6 +501,7 @@ export async function runTick(id: string, run: TickRun, deps: TickDeps, ctx: Ste
...(made ? { article, iteration: out.iteration } : {}),
...(out.reason ? { reason: out.reason } : {}),
...(out.estimateUsd !== undefined ? { estimateUsd: out.estimateUsd } : {}),
+ ...warned(),
});
} catch (e) {
const cancelled = ctx.signal.aborted;
diff --git a/common/lib/report/schedule/types.ts b/common/lib/report/schedule/types.ts
@@ -91,6 +91,8 @@ export const tickSchema = z.looseObject({
// Windows passed while the editor was away, that this one tick stood in for.
missed: z.number().int().nonnegative().optional(),
minutes: z.number().nonnegative().optional(),
+ // What its fetch skipped and said (a held or cooling platform): never its failure.
+ warnings: z.array(z.string()).optional(),
});
export type Tick = z.infer<typeof tickSchema>;
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -9,7 +9,7 @@
- **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.
- **Recurring reports.** umtool's Create has **A recurring report**: a topic, its scope (channels, or a research board's), a cadence (daily, weekly on a day, or every N days, at a time) and a shape — a **Living report** (one article kept current: each tick fetches what is new and updates it, the new iteration left for review unless "Make each update current without review" is on) or a **Series** (a new dated article each tick, "Co-host updates · week of 2026-10-12", over whole days — from the day after the last edition through the day before the tick, so weekly on Monday covers the Monday to Sunday before it and no day is read twice; a window nothing matches is a *quiet* edition — recorded, no article, $0; a Tick now with nothing new to cover makes no edition and says when the next one starts). **Plan the schedule** says the first tick, the model and the cap before anything is made. A series has its own page (the cadence chip "weekly · next Mon 06:00", Pause/Resume, **Tick now**, Edit cadence, Delete, the editions newest first, the tick log with each tick's spend); a living report wears the same chip in its article's head. Work has a **Recurring** facet; the Inbox puts a finished edition under Review and a failed or cap-held tick under Your call (**Tick now** / **Raise cap**). `umtool schedule list | show <id>` prints them. Needs a restart of umtool and of the editor.
- **The research board's `e`, `n` and `m` no longer lose the field.** Pressed while a move was still saving, the field took the focus and then lost it when the board redrew, and what was typed next landed on the board as commands (`s` toggled the speaker check, `x` asked to remove the quote). The field now takes the focus once the board has redrawn, and no key acts until it does.
-- **The editor keeps the schedules.** A new `report-schedule` lane ticks each recurring report when its window comes — one `report-tick` job at a time, never two of one schedule, never on an idle boot; a window missed while the editor was down is caught up by ONE tick. Hold it with `pnpm ops lane '{"lane":"report-schedule","held":true}'` (`settings.reportSchedule.held`); a tick in flight finishes, and Tick now still runs. Drive it with `pnpm ops report-schedule` (`list`, `create` — with `dryRun` the plan —, `update`, `pause`, `resume`, `delete` — the plan unless `confirm: true` —, `tick-now`). A tick is held, not run, past the day's API cap. Until umtool's Refresh (R4) is in the editor, a tick's fetch-and-build step is not wired and every tick ends failed saying so.
+- **The editor keeps the schedules.** A new `report-schedule` lane ticks each recurring report when its window comes — one `report-tick` job at a time, never two of one schedule, never on an idle boot; a window missed while the editor was down is caught up by ONE tick. Hold it with `pnpm ops lane '{"lane":"report-schedule","held":true}'` (`settings.reportSchedule.held`); a tick in flight finishes, and Tick now still runs. Drive it with `pnpm ops report-schedule` (`list`, `create` — with `dryRun` the plan —, `update`, `pause`, `resume`, `delete` — the plan unless `confirm: true` —, `tick-now`). Each tick first fetches what is new through the editor's own paced actions (Refresh's stage 1: the channels' syncs and posts, then a local build — never a deploy); a platform that is held or cooling down is skipped and said on the tick, not a failure. A living report's tick is a Refresh: no change costs nothing, an update is left for review (or made current with "make each update current"), and a refresh or sweep the cap holds is a Your call card.
- **umtool's benches are one shell.** The clip bench, the claim bench, the narration script, the takes and the drafts review share one frame that fits 1366×768 with no rail: a top bar (← the piece, which bench, **N of M**, ‹ prev / next ›, the keys), the work, a **verdict bar** asking ONE question with its consequence before you choose, and the source on the reader at the right. On the clip bench the transcript is the reader — the cited cue lit, its cite thread, **Copy citation**, **Play clip** — and a clip that ends mid-sentence asks "Extend c04 to the end of the sentence? It would end at 4:31:21 (+12.1 s), covering all of c05." with **Extend to 4:31:21** (or **Fetch to …** past what is fetched) and **Keep the cut here** (lockEnd) before the walk's **Yes, confirmed** / **No, note what is wrong**. The claim bench's context is its reader (`j`/`k` move the lit cue and seek the player) and **Save ruling** its verdict bar, saying what is still missing. Narration asks about the card in hand (`j`/`k`, `a` approve, `r` reject with its note); takes about the take being listened to (`n`/`p`, `l` like, `m` maybe, `x` no). Needs a restart of umtool.
- **A report video's Media tab is one surface for every drafted field.** Each field is a line — its words, **where it came from** (the draft file, when, by what model, which attempt was kept, and the rule a refused attempt broke: "attempt 2 of 2 chosen · attempt 1 failed: ✕ text in quotation marks"), its review — with **Approve draft** and **Reject** (a note), the drafts kept aside with **Use this**, grouped by section (cut, on-screen, teaser, flips, threads, narration, YouTube), each headed by its **Draft with <model>**; **Approve all N**, **Draft everything** (the draft-all chain, on the model chosen) and section chips above. `j`/`k` light a field, `a` approves it, `r` rejects it. The on-screen panel moved here from Build, whole. A release-25 narration (no mark in the manifest) shows its `narration-draft.json` attempts too. Needs a restart of umtool.
- **The drafts review is a bench: `/projects/<p>/review`.** The same field list, walked one field at a time: the verdict bar asks about the lit field ("Approve the drafted on-screen text of m01? A final build refuses it until it is approved."), the reader shows the clip it is drawn over with its cited cue lit. The Iterations tab's **Narrate**, media drafts and **Draft everything** are now a **Media drafts →** link to the iteration's video's Media tab.
diff --git a/editor/app/api/ops/_reportSchedule.ts b/editor/app/api/ops/_reportSchedule.ts
@@ -4,15 +4,15 @@ import { listChannelConfigs } from "yt-dlp-transcript-common/controller/channels
import { pickCorpusBuild } from "yt-dlp-transcript-common/lib/report/draft/tasks/corpusSource";
import {
editionGenerator,
- notWiredFetch,
- notWiredRefresh,
+ r4Steps,
type CountWindow,
type TickDeps,
} from "yt-dlp-transcript-common/controller/reportTick";
+import type { ReportDraftDeps } from "yt-dlp-transcript-common/controller/reportDraft";
import { armReportSchedule } from "yt-dlp-transcript-common/controller/reportScheduleRunner";
import { createCorpusTools } from "yt-dlp-transcript-mcp/callTool";
import { SourceRegistry, enumerate } from "yt-dlp-transcript-mcp/research";
-import { researchEditor } from "./_researchEditor";
+import { refreshEditor, researchEditor } from "./_researchEditor";
// THE RECURRING REPORTS' EDITOR SIDE (umtool R5): the deps a tick runs on,
// shared by the `report-schedule` route and the lane instrumentation.ts arms.
@@ -23,9 +23,13 @@ import { researchEditor } from "./_researchEditor";
// the build a sweep would read (the newest holding the
// channels): the schedule's terms, or any recording, in
// the window. 0 is a quiet edition.
-// fetchAndBuild, R4's (stage 1 fetch + local build; report-draft
-// refresh refresh): NOT WIRED until R4 is in this editor — each
-// refuses, and the tick ends failed saying so.
+// fetchAndBuild R4's stage 1 (controller/reportRefresh.ts fetchScope):
+// this editor's own paced fetches for the scope, then the
+// local build of the site holding it — through
+// refreshEditor, the same in-process door a refresh uses
+// refresh R4's `report-draft {"task":"refresh"}`, awaited; its
+// refresh.json's status is the tick's outcome
+// (common/controller/reportTick.ts r4Steps)
const countWindow: CountWindow = async (q) => {
const paths = getPaths();
@@ -50,17 +54,14 @@ const countWindow: CountWindow = async (q) => {
export function reportScheduleDeps(): TickDeps {
const paths = getPaths();
+ const draft: ReportDraftDeps = { paths, corpusTools: (source) => createCorpusTools({ source }), researchEditor, refreshEditor };
return {
paths,
settings: () => getSettings(),
knownChannels: async () => (await listChannelConfigs(paths)).map((c) => c.slug),
steps: {
- fetchAndBuild: notWiredFetch,
- refresh: notWiredRefresh,
- generateEdition: editionGenerator({
- draft: { paths, corpusTools: (source) => createCorpusTools({ source }), researchEditor },
- countWindow,
- }),
+ ...r4Steps(draft),
+ generateEdition: editionGenerator({ draft, countWindow }),
},
};
}
diff --git a/editor/e2e/ops-api.spec.ts b/editor/e2e/ops-api.spec.ts
@@ -928,10 +928,11 @@ test("publish: each verb enqueues its run of stages on the publish queue; a dupl
//
// `report-schedule` over HTTP: create (its plan first: the first tick, the
// model, the cap), list, Tick now — a `report-tick` job the server's registry
-// runs — pause, and delete (the plan, then the confirm). Until R4's stage 1
-// (fetch + local build) is wired into the editor, a tick's fetch step refuses
-// and the tick ends failed SAYING SO; that refusal is what the tick's line in
-// the schedule's history records here, and the Your call it raises.
+// runs — pause, and delete (the plan, then the confirm). The tick runs R4's
+// stage 1 through the editor's own door (the channel's sync, the fake
+// yt-dlp), then finds no composed build to read: it ends failed SAYING SO.
+// A tick that makes an edition over the fake model, and a living report's
+// refresh, are report-draft.spec's (the fake Anthropic lives there).
test("report-schedule: create (plan, then the schedule), list, tick now, pause, delete (plan, then confirm)", async ({ request }) => {
test.setTimeout(120_000);
await resetData("empty");
@@ -970,11 +971,12 @@ test("report-schedule: create (plan, then the schedule), list, tick now, pause,
const again = await ops(request, "report-schedule", { action: "tick-now", id: "r5-ops" });
if (again.status !== 200) expect(again.body.error).toMatch(/already queued or running/);
await expect
- .poll(async () => (await readJson<{ ticks: { status: string }[] }>(SERIES)).ticks.length, { timeout: 60_000 })
+ .poll(async () => (await readJson<{ ticks: { status: string }[] }>(SERIES)).ticks.length, { timeout: 90_000 })
.toBeGreaterThan(0);
- const s = await readJson<{ running: unknown; ticks: { status: string; reason?: string; trigger: string; jobId: string }[] }>(SERIES);
+ const s = await readJson<{ running: unknown; ticks: { status: string; reason?: string; trigger: string; jobId: string; warnings?: string[] }[] }>(SERIES);
expect(s.ticks[0]).toMatchObject({ trigger: "now", jobId: tick.body.jobId, status: "failed" });
- expect(s.ticks[0].reason).toMatch(/^not wired: R4's stage 1/);
+ expect(s.ticks[0].reason).toMatch(/^the window check failed: /);
+ expect(s.ticks[0].reason).not.toMatch(/not wired/);
await expect.poll(async () => (await readJson<{ running: unknown }>(SERIES)).running, { timeout: 30_000 }).toBeNull();
const job = await request.get(`${baseUrl}/api/ops/job/${tick.body.jobId}?tail=20`, { headers: AUTH });
const j = (await job.json()) as { job?: { kind: string; status: string }; tail?: string[] };
diff --git a/editor/e2e/report-draft.spec.ts b/editor/e2e/report-draft.spec.ts
@@ -319,3 +319,79 @@ test("a refresh through the editor's own door: the channel's sync and its report
expect(f.fetch.find((s: { action: string }) => s.action === "refresh-report")).toMatchObject({ status: "done" });
expect(f.status).toBe("no-change");
});
+
+// ─── recurring reports, wired to R4 (umtool R5) ───
+//
+// `report-schedule` tick-now over the fake model: a SERIES edition (stage 1
+// through the editor's own door — the channel's sync as a job, the build not
+// a site's and read as it stands, said as a warning — the window check over
+// the build, then the sweep with from/to) and a LIVING report's refresh (its
+// own stage 1, then what changed: no change, $0). The window is yesterday on
+// UTC (daily, tz UTC), the build holding a recording from yesterday.
+
+async function schedule(request: APIRequestContext, data: Record<string, unknown>) {
+ const res = await request.post(`${baseUrl}/api/ops/report-schedule`, { headers: AUTH, data });
+ return { status: res.status(), body: (await res.json()) as Record<string, unknown> & { ok?: boolean; error?: string; jobId?: string } };
+}
+
+const reportsDir = () => join(testPaths().transcriptsDir, "reports");
+const seriesJson = async (id: string) => JSON.parse(await readFile(join(reportsDir(), ".series", id, "series.json"), "utf8"));
+
+test("a recurring series ticks over the fake model: stage 1 through the editor's door, then an edition over yesterday", async ({ request }) => {
+ test.setTimeout(180_000);
+ await setup();
+ // The channel is this editor's (a sync runs the fake yt-dlp); the build holds a recording from yesterday (UTC).
+ await writeChannelConfig("synth-kitchen", { name: "Synth Kitchen" });
+ const y = new Date(Date.now() - 86_400_000).toISOString().slice(0, 10);
+ await writeDraftCorpus(join(testPaths().transcriptsDir, ".export-builds", "draft-e2e", "out"), {
+ channels: withRecords([{ ...LATE_RECORD, id: "contest-stream-y", slug: "synth-kitchen/contest-stream-y", uploadDate: y.replace(/-/g, "") }]),
+ });
+ const r = await run("sweep-agent");
+ api.push(...r.turns);
+ const made = await schedule(request, { action: "create", shape: "series", id: "r5-wired", topic: "Contest", question: r.question, channels: r.channels, cadence: "daily 06:00", tz: "UTC", model: r.model });
+ expect(made.status, made.body.error).toBe(200);
+ const tick = await schedule(request, { action: "tick-now", id: "r5-wired" });
+ expect(tick.status, tick.body.error).toBe(200);
+ const job = await jobUntil(request, tick.body.jobId!, (s) => ["done", "failed", "cancelled"].includes(s), 150_000);
+ const tail = (job.tail ?? []).join("\n");
+ expect(job.job?.status ?? job.status, tail).toBe("done");
+ const s = await seriesJson("r5-wired");
+ const t = s.ticks.at(-1);
+ expect(t, tail).toMatchObject({ status: "done", edition: 1, article: `r5-wired-${new Date().toISOString().slice(0, 10)}` });
+ expect(t.usd).toBeGreaterThan(0);
+ // The build is no site's: read as it stands, said on the tick.
+ expect((t.warnings ?? []).join("\n")).toMatch(/draft-e2e/);
+ expect(s.editions[0]).toMatchObject({ n: 1, status: "done", window: { from: y, to: y }, title: `Contest · ${y}`, iteration: 1 });
+ const it = await iterationJson(t.article, 1);
+ expect(it).toMatchObject({ kind: "sweep", status: "done", scope: { channels: ["synth-kitchen"], from: y, to: y } });
+ const report = JSON.parse(await readFile(join(reportsDir(), t.article, "iterations", "1", "report.json"), "utf8"));
+ expect(report.title).toBe(`Contest · ${y}`);
+ // Stage 1 ran the channel's sync through the editor (a job of its own).
+ expect(tail).toMatch(/stage 1: [1-9]\d* fetch(es)? done/);
+ expect(api.remaining()).toBe(0);
+});
+
+test("a living report ticks: R4's refresh runs its own stage 1, then nothing changed — no change, $0, nothing made current", async ({ request }) => {
+ test.setTimeout(180_000);
+ await setup();
+ await writeChannelConfig("synth-kitchen", { name: "Synth Kitchen" });
+ await doneBasicSweep("r5-living");
+ // The current report: i1.
+ await writeFile(join(reportsDir(), "r5-living", "iterations", "current.json"), JSON.stringify({ format: "archilyzer-iterations-current", version: 1, report: 1, reportFrom: 1, video: null }));
+ const made = await schedule(request, { action: "create", shape: "living", article: "r5-living", topic: "The contest", channels: ["synth-kitchen"], cadence: "weekly mon 06:00", tz: "UTC", autoMakeCurrent: true });
+ expect(made.status, made.body.error).toBe(200);
+ const tick = await schedule(request, { action: "tick-now", id: "r5-living" });
+ expect(tick.status, tick.body.error).toBe(200);
+ const job = await jobUntil(request, tick.body.jobId!, (s) => ["done", "failed", "cancelled"].includes(s), 150_000);
+ const tail = (job.tail ?? []).join("\n");
+ expect(job.job?.status ?? job.status, tail).toBe("done");
+ const s = JSON.parse(await readFile(join(reportsDir(), "r5-living", "schedule.json"), "utf8"));
+ expect(s.ticks.at(-1), tail).toMatchObject({ status: "no-change", usd: 0, iteration: 2, article: "r5-living" });
+ expect(s.ticks.at(-1).reason).toMatch(/^Nothing new since/);
+ const f = JSON.parse(await readFile(join(reportsDir(), "r5-living", "iterations", "2", "refresh.json"), "utf8"));
+ expect(f.status).toBe("no-change");
+ expect(f.fetch.find((x: { action: string }) => x.action === "sync")).toMatchObject({ channel: "synth-kitchen", status: "done" });
+ // autoMakeCurrent acts only on `updated`.
+ const cur = JSON.parse(await readFile(join(reportsDir(), "r5-living", "iterations", "current.json"), "utf8"));
+ expect(cur.report).toBe(1);
+});