commit 0101029a7e777aa2de67dffe2dbe3c03afa92195
parent 0ad2231fcf782fb2e6252ddc0a6856032b5dbecd
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 11 Nov 2026 11:11:54 -0500
umtool: a scope sweep takes its own dates and says what it reads (D2 item 1)
A question may carry a date range: "Run a sweep on this scope" now has From
and To fields (the scope's dates to start with), sent with the confirm as
dateFrom/dateTo and checked by the plan (YYYY-MM-DD, not backwards). For a
local model the plan says what the run reads before it starts: the top N
recordings by rarity x hits plus one per year-quarter a rare term hits, and
about how long on this machine's measured seconds a call.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
5 files changed, 87 insertions(+), 14 deletions(-)
diff --git a/umtool/app/api/research/cases/[id]/handoff/route.ts b/umtool/app/api/research/cases/[id]/handoff/route.ts
@@ -10,7 +10,7 @@ export const dynamic = "force-dynamic";
// { to: "article", confirm: true, … } -> { href, jobId, iteration }
// { to: "video", slug?, title? } -> { plan: VideoPlan }
// { to: "video", confirm: true, … } -> { href }
-// { to: "sweep", article?, model?, question? } -> { plan: ArticlePlan } (seeded: false)
+// { to: "sweep", article?, model?, question?, dateFrom?, dateTo? } -> { plan: ArticlePlan } (seeded: false; the dates override the scope's)
// { to: "sweep", confirm: true, … } -> { href (the run's page), jobId, iteration }
// An article is a seeded report-draft sweep the editor runs (it spends: the
// plan says on what model, under which cap); a video is a project scaffolded
@@ -28,7 +28,13 @@ export async function POST(request: Request, ctx: { params: Promise<{ id: string
return ok(confirm ? await confirmArticle(id, over) : { plan: (await planArticle(id, over)).plan });
}
if (b.to === "sweep") {
- const over = { ...(s("article") ? { article: s("article") } : {}), ...(s("model") ? { model: s("model") } : {}), ...(s("question") ? { question: s("question") } : {}) };
+ const over = {
+ ...(s("article") ? { article: s("article") } : {}),
+ ...(s("model") ? { model: s("model") } : {}),
+ ...(s("question") ? { question: s("question") } : {}),
+ ...(s("dateFrom") ? { dateFrom: s("dateFrom") } : {}),
+ ...(s("dateTo") ? { dateTo: s("dateTo") } : {}),
+ };
return ok(confirm ? await confirmScopeSweep(id, over) : { plan: (await planScopeSweep(id, over)).plan });
}
if (b.to === "video") {
diff --git a/umtool/components/research/HandoffDialog.tsx b/umtool/components/research/HandoffDialog.tsx
@@ -3,6 +3,7 @@
import { useEffect, useState } from "react";
import { buttonVariants } from "@/components/ui/button";
import { Dialog } from "@/components/ui/dialog";
+import { controlClass } from "@/components/ui/field";
import { researchCaseHandoffApi } from "@/lib/research/hrefs";
import type { ArticlePlan, HandoffPlan, VideoPlan } from "@/lib/research/case-types";
@@ -29,7 +30,7 @@ function Row({ k, children }: { k: string; children: React.ReactNode }) {
);
}
-function ArticleBody({ p }: { p: ArticlePlan }) {
+function ArticleBody({ p, dates, setDates }: { p: ArticlePlan; dates?: { from: string; to: string }; setDates?: (d: { from: string; to: string }) => void }) {
return (
<dl className="grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1.5 text-[12.5px]">
<Row k="Article">
@@ -37,9 +38,30 @@ function ArticleBody({ p }: { p: ArticlePlan }) {
</Row>
<Row k="Question">{p.question}</Row>
<Row k="Channels">{p.channels.join(", ") || "—"}</Row>
- {(p.dateFrom || p.dateTo) && (
+ {dates && setDates ? (
<Row k="Dates">
- {p.dateFrom ?? "…"} – {p.dateTo ?? "…"}
+ <span className="inline-flex flex-wrap items-center gap-1.5">
+ <label className="inline-flex items-center gap-1">
+ From
+ <input type="date" aria-label="From" className={controlClass} value={dates.from} onChange={(e) => setDates({ ...dates, from: e.target.value })} />
+ </label>
+ <label className="inline-flex items-center gap-1">
+ To
+ <input type="date" aria-label="To" className={controlClass} value={dates.to} onChange={(e) => setDates({ ...dates, to: e.target.value })} />
+ </label>
+ </span>
+ </Row>
+ ) : (
+ (p.dateFrom || p.dateTo) && (
+ <Row k="Dates">
+ {p.dateFrom ?? "…"} – {p.dateTo ?? "…"}
+ </Row>
+ )
+ )}
+ {p.reading && (
+ <Row k="Reads">
+ the top {p.reading.recordings} recordings by rarity × hits, plus one per year-quarter a rare term hits (at most {p.reading.spreadMax})
+ {p.reading.minutes !== undefined ? `; about ${p.reading.minutes} min of model time` : ""}
</Row>
)}
{p.seeded !== false ? (
@@ -109,13 +131,19 @@ export default function HandoffDialog({
const [plan, setPlan] = useState<HandoffPlan | null>(null);
const [error, setError] = useState<string | null>(null);
const [working, setWorking] = useState(false);
+ // A scope sweep's dates (D2): the scope's, changeable here for this run.
+ const [dates, setDates] = useState<{ from: string; to: string }>({ from: "", to: "" });
useEffect(() => {
setPlan(null);
setError(null);
if (!to) return;
let live = true;
post<{ plan: HandoffPlan }>(researchCaseHandoffApi(caseId), { to })
- .then((r) => live && setPlan(r.plan))
+ .then((r) => {
+ if (!live) return;
+ setPlan(r.plan);
+ if (r.plan.to === "article") setDates({ from: r.plan.dateFrom ?? "", to: r.plan.dateTo ?? "" });
+ })
.catch((e: Error) => live && setError(e.message));
return () => {
live = false;
@@ -127,7 +155,12 @@ export default function HandoffDialog({
setWorking(true);
setError(null);
try {
- const r = await post<{ href: string }>(researchCaseHandoffApi(caseId), { to, confirm: true, ...(plan.to === "article" ? { article: plan.article } : { slug: plan.slug }) });
+ const r = await post<{ href: string }>(researchCaseHandoffApi(caseId), {
+ to,
+ confirm: true,
+ ...(plan.to === "article" ? { article: plan.article } : { slug: plan.slug }),
+ ...(to === "sweep" ? { dateFrom: dates.from, dateTo: dates.to } : {}),
+ });
onDone(r.href, plan.to === "article" ? `The sweep for ${plan.article} is queued${to === "sweep" ? ": its run page follows it" : ""}` : `Project ${plan.slug} written`);
} catch (e) {
setError((e as Error).message);
@@ -145,7 +178,7 @@ export default function HandoffDialog({
Reading the plan…
</p>
)}
- {plan && (plan.to === "article" ? <ArticleBody p={plan} /> : <VideoBody p={plan} />)}
+ {plan && (plan.to === "article" ? <ArticleBody p={plan} {...(to === "sweep" ? { dates, setDates } : {})} /> : <VideoBody p={plan} />)}
{plan && plan.refusals.length > 0 && (
<ul data-refusals="" className="mt-3 grid list-none gap-1 p-0 text-[12.5px] text-reject-text">
{plan.refusals.map((r) => (
diff --git a/umtool/e2e/run-trace.spec.ts b/umtool/e2e/run-trace.spec.ts
@@ -183,6 +183,9 @@ test("a case's scope: Run a sweep on this scope plans it (no seed, the model and
await expect(dlg).not.toContainText("the board as cited markdown");
await expect(dlg).toContainText(/Runs on\s*(claude-|qwen)/);
await expect(dlg.getByRole("button", { name: /^Start the sweep/ })).toBeVisible();
+ // The run's own dates (D2 item 1): two date fields, the scope's to start with.
+ await expect(dlg.getByLabel("From", { exact: true })).toBeVisible();
+ await expect(dlg.getByLabel("To", { exact: true })).toBeVisible();
await page.keyboard.press("Escape");
await expect(dlg).toBeHidden();
@@ -193,3 +196,13 @@ test("a case's scope: Run a sweep on this scope plans it (no seed, the model and
await page.locator(`[data-run-row="${RUN_ARTICLE}/1"]`).getByRole("link").click();
await expect(page).toHaveURL(new RegExp(`/research/runs/${RUN_ARTICLE}/1$`));
});
+
+test("a scope sweep's plan takes the run's own dates (D2 item 1); bad or backwards dates are refused", async ({ request }) => {
+ const url = `/api/research/cases/${BOARD_CASE}/handoff`;
+ const plan = (await (await request.post(url, { data: { to: "sweep", dateFrom: "2024-01-01", dateTo: "2024-12-31" } })).json()).plan;
+ expect([plan.dateFrom, plan.dateTo, plan.seeded]).toEqual(["2024-01-01", "2024-12-31", false]);
+ const back = (await (await request.post(url, { data: { to: "sweep", dateFrom: "2024-12-31", dateTo: "2024-01-01" } })).json()).plan;
+ expect(back.refusals).toContain("the dates run backwards: 2024-12-31 is after 2024-01-01");
+ const bad = (await (await request.post(url, { data: { to: "sweep", dateFrom: "June 2024" } })).json()).plan;
+ expect(bad.refusals).toContain('the "from" date "June 2024" is not YYYY-MM-DD');
+});
diff --git a/umtool/lib/research/case-types.ts b/umtool/lib/research/case-types.ts
@@ -167,6 +167,8 @@ export type ArticlePlan = {
channels: string[];
dateFrom?: string;
dateTo?: string;
+ /** A local sweep's reading set (D2): the top `recordings` by rarity × hits, plus one per year-quarter a rare term hits (at most `spreadMax`); `minutes`: the estimate on this machine's measured seconds a call. */
+ reading?: { recordings: number; spreadMax: number; minutes?: number };
source: string;
model: string | null;
/** The API agent's extractor (the policy's), when the sweep runs on Claude. */
diff --git a/umtool/lib/research/handoff.ts b/umtool/lib/research/handoff.ts
@@ -16,6 +16,7 @@ import { CaseError, recordHandoff } from "./cases.mjs";
import { boardGroups, caseView, mutateBoard } from "./boards";
import { boardGate } from "./case-private";
import type { ArticlePlan, CaseDoc, VideoPlan } from "./case-types";
+import { CALLS_PER_RECORDING, MEASURED_SECONDS_PER_CALL, readingSize } from "yt-dlp-transcript-common/lib/report/draft/tasks/selection";
// ---------------------------------------------------------------------------
// HAND-OFFS from a board (plans/umtool-redesign.md, R2), both PLAN THEN
@@ -61,9 +62,13 @@ function channelsOf(doc: CaseDoc): string[] {
// ── the article ──
+export type ArticleOver = { article?: string; model?: string; question?: string; dateFrom?: string; dateTo?: string };
+
+const YMD = /^\d{4}-\d{2}-\d{2}$/;
+
export async function planArticle(
id: string,
- over: { article?: string; model?: string; question?: string } = {},
+ over: ArticleOver = {},
o: { seeded?: boolean } = {},
): Promise<{ plan: ArticlePlan; seed: string }> {
const seeded = o.seeded !== false;
@@ -81,6 +86,11 @@ export async function planArticle(
const localChannels = channels.filter((c) => isLocalOnly(c));
if (!seeded && localChannels.length) refusals.push(`${localChannels.join(", ")} ${localChannels.length === 1 ? "is" : "are"} local-only: a sweep makes an article, which can be published`);
const question = (over.question ?? doc.scope.query ?? doc.title).trim();
+ // The sweep's dates (D2): the run's own when the plan names them, else the scope's.
+ const dateFrom = over.dateFrom ?? doc.scope.dateFrom;
+ const dateTo = over.dateTo ?? doc.scope.dateTo;
+ for (const [k, v] of [["from", dateFrom], ["to", dateTo]] as const) if (v && !YMD.test(v)) refusals.push(`the "${k}" date "${v}" is not YYYY-MM-DD`);
+ if (dateFrom && dateTo && YMD.test(dateFrom) && YMD.test(dateTo) && dateFrom > dateTo) refusals.push(`the dates run backwards: ${dateFrom} is after ${dateTo}`);
if (seeded) {
const drifted = doc.quotes.filter((q) => q.verify?.status === "drifted" || q.verify?.status === "missing").length;
if (drifted) warnings.push(`${drifted} ${drifted === 1 ? "quote" : "quotes"} drifted or missing at the last re-verify: the sweep checks every quote again`);
@@ -134,8 +144,9 @@ export async function planArticle(
articleExists,
question,
channels,
- ...(doc.scope.dateFrom ? { dateFrom: doc.scope.dateFrom } : {}),
- ...(doc.scope.dateTo ? { dateTo: doc.scope.dateTo } : {}),
+ ...(dateFrom ? { dateFrom } : {}),
+ ...(dateTo ? { dateTo } : {}),
+ ...(!seeded && model && !model.startsWith("claude-") ? { reading: readingOf(model) } : {}),
source: doc.scope.source,
model,
extractor,
@@ -152,7 +163,7 @@ export async function planArticle(
};
}
-export async function confirmArticle(id: string, over: { article?: string; model?: string; question?: string }): Promise<{ href: string; jobId: string; iteration: number }> {
+export async function confirmArticle(id: string, over: ArticleOver): Promise<{ href: string; jobId: string; iteration: number }> {
const { plan, seed } = await planArticle(id, over);
if (plan.refusals.length) throw new CaseError(plan.refusals.join("; "), 409);
if (plan.policyError) throw new CaseError(`the editor cannot be asked: ${plan.policyError}`, 502);
@@ -177,9 +188,17 @@ export async function confirmArticle(id: string, over: { article?: string; model
// ── a sweep on the case's scope (R3) ──
-export const planScopeSweep = (id: string, over: { article?: string; model?: string; question?: string } = {}) => planArticle(id, over, { seeded: false });
+export const planScopeSweep = (id: string, over: ArticleOver = {}) => planArticle(id, over, { seeded: false });
+
+/** What a local sweep reads (D2): the top N by rarity × hits plus the date spread, and about how long. */
+function readingOf(model: string): NonNullable<ArticlePlan["reading"]> {
+ const recordings = readingSize();
+ const spreadMax = Math.ceil(recordings / 2);
+ const perCall = MEASURED_SECONDS_PER_CALL[model];
+ return { recordings, spreadMax, ...(perCall ? { minutes: Math.round((recordings * CALLS_PER_RECORDING * perCall) / 60) } : {}) };
+}
-export async function confirmScopeSweep(id: string, over: { article?: string; model?: string; question?: string }): Promise<{ href: string; jobId: string; iteration: number }> {
+export async function confirmScopeSweep(id: string, over: ArticleOver): Promise<{ href: string; jobId: string; iteration: number }> {
const { plan } = await planScopeSweep(id, over);
if (plan.refusals.length) throw new CaseError(plan.refusals.join("; "), 409);
if (plan.policyError) throw new CaseError(`the editor cannot be asked: ${plan.policyError}`, 502);