commit 84a80a19d3523332f88eb82f73cd323961e35fd5
parent 51bbc9b1a105cfe04d50993ff41bbafa72e1d6f1
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 12 Nov 2026 03:57:33 -0500
gen local-sweep, and umtool's policy panel: the local sweep's two knobs (D2 round b)
`archilyzer gen local-sweep [--form neutral|sentence] [--read-aloud
flag|drop|off]` shows or writes settings.generation.localSweep, through the
editor or settings.json offline as the other gen verbs do; `gen policy`
shows it. umtool's /settings/generation has the same two choices, written
through the editor's settings action.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
7 files changed, 173 insertions(+), 3 deletions(-)
diff --git a/COMMANDS.md b/COMMANDS.md
@@ -44,6 +44,7 @@ Run from the repo root (in the container: `docker compose exec editor pnpm archi
| `archilyzer gen policy` | `[--json]` | the generation policy: where each task runs (code = Claude Code, api = the Claude API, local = the local model), the models, the caps and the day's Claude API spend — from the editor, or settings.json when none answers |
| `archilyzer gen preset` | `<code\|balanced\|api\|local>` | route every generation task by a preset (its routes are written; settings.generation.routes) |
| `archilyzer gen set` | `<task> <code\|api\|local>` | route one generation task (sweep, revise-report, revise-video, research; the media drafts cut, onscreen, teaser, flips, threads, narrate, youtube, social) |
+| `archilyzer gen local-sweep` | `[--form neutral\|sentence] [--read-aloud flag\|drop\|off]` | the local route's sweep (settings.generation.localSweep): who writes a finding's line — neutral: code (In <title> (<date>), on <topic>: "<quote>"; the model only picks the quote and labels its topic), sentence: the model, judged by a meaning check — and what happens to a quote whose transcript has a sign of reading aloud around it (a tweet, a headline, "it says"): flag keeps it marked to check by ear, drop leaves it out, off does not look; bare, what they are |
| `archilyzer gen run` | `<task> [<question\|feedback>] --article <id> [--via api\|local\|code] [--model <m>] [--iteration <n>] [--channels a,b] [--from YYYY-MM-DD] [--to YYYY-MM-DD] [--copy-of <n>] [--max-usd <usd>] [--cards a,b] [--entries a,b] [--force] [--autonomy propose\|limits\|auto] [--source <handle>\|--build <id>] [--wait]` | enqueue a report-draft job as `pnpm ops report-draft` does (--wait follows it; `sweep --iteration <n>` continues research run n); a media draft (cut, onscreen, teaser, flips, threads, narrate, youtube, social) is a step on --iteration <n>, takes no words, --entries limits it, --force re-drafts only fields a model drafted; EXITS 3 and runs nothing when the task is routed to code (Claude Code does it; --via overrides once) |
| `archilyzer reports move-to-articles` | `[--keep <site>/<id>,…] [--drafts] [--apply]` | ONE-OFF (release 26): every report a site lists, but the pages named by --keep, moved to transcripts/reports/ as an article — audience private, published in reports/index.json in the sites' order (a report with problems as a draft), dropped from its site; --drafts moves unlisted ones too. A dry run printing the plan unless --apply *(passthrough)* |
| `archilyzer reports convert` | `<sweep\|ask\|manifest> <in> --out <report.json> [--channels-dir <dir>] [--id <id>] [--title <title>]` | a /sweep report (markdown), an /ask answer or a report-to-video manifest as a report.json, written only when it validates (--channels-dir: widen spans from the cues, find posts' channels) |
diff --git a/common/bin/archilyzer.ts b/common/bin/archilyzer.ts
@@ -483,6 +483,14 @@ export const COMMANDS: Command[] = [
run: async (ctx) => (await import("./gen")).genSetRow(ctx),
},
{
+ path: ["gen", "local-sweep"],
+ usage:
+ "[--form neutral|sentence] [--read-aloud flag|drop|off] the local route's sweep (settings.generation.localSweep): who writes a finding's line — neutral: code (In <title> (<date>), on <topic>: \"<quote>\"; the model only picks the quote and labels its topic), sentence: the model, judged by a meaning check — and what happens to a quote whose transcript has a sign of reading aloud around it (a tweet, a headline, \"it says\"): flag keeps it marked to check by ear, drop leaves it out, off does not look; bare, what they are",
+ flags: { form: "string", "read-aloud": "string" },
+ maxPositionals: 0,
+ run: async (ctx) => (await import("./gen")).genLocalSweepRow(ctx),
+ },
+ {
path: ["gen", "run"],
usage:
"<task> [<question|feedback>] --article <id> [--via api|local|code] [--model <m>] [--iteration <n>] [--channels a,b] [--from YYYY-MM-DD] [--to YYYY-MM-DD] [--copy-of <n>] [--max-usd <usd>] [--cards a,b] [--entries a,b] [--force] [--autonomy propose|limits|auto] [--source <handle>|--build <id>] [--wait] enqueue a report-draft job as `pnpm ops report-draft` does (--wait follows it; `sweep --iteration <n>` continues research run n); a media draft (cut, onscreen, teaser, flips, threads, narrate, youtube, social) is a step on --iteration <n>, takes no words, --entries limits it, --force re-drafts only fields a model drafted; EXITS 3 and runs nothing when the task is routed to code (Claude Code does it; --via overrides once)",
diff --git a/common/bin/gen.test.ts b/common/bin/gen.test.ts
@@ -32,11 +32,13 @@ const BALANCED: GenPolicy = {
routes: { sweep: "code", "revise-report": "api", "revise-video": "local", narrate: "local", research: "api" },
models: { api: "claude-sonnet-5-5", local: "qwen3:8b", extractor: "claude-haiku-4-5" },
caps: { sweep: 5, revision: 2, narration: 1, daily: 20, max: 10 },
+ localSweep: { claimForm: "neutral", readAloud: "flag" },
};
// A store in memory, recording what it was asked to write.
function memoryStore(policy: GenPolicy = BALANCED, offline = false) {
const written: Record<string, string>[] = [];
+ const localSweeps: NonNullable<GenPolicy["localSweep"]>[] = [];
let p = structuredClone(policy);
const store: GenStore = {
where: offline ? "settings.json (test)" : "the editor at http://editor.test",
@@ -48,8 +50,13 @@ function memoryStore(policy: GenPolicy = BALANCED, offline = false) {
p = { ...p, routes, preset: "custom" };
return p;
},
+ writeLocalSweep: async (ls) => {
+ localSweeps.push(ls);
+ p = { ...p, localSweep: ls };
+ return p;
+ },
};
- return { store, written };
+ return { store, written, localSweeps };
}
test("gen policy prints the routes, models, caps and today's spend", async () => {
@@ -85,6 +92,27 @@ test("gen preset writes the preset's routes; gen set writes one; nonsense is a u
assert.equal(m.written.length, 2);
});
+test("gen local-sweep shows the claim form and the read-aloud rule, writes one or both, and refuses a value it does not know", async () => {
+ const c = capture();
+ const m = memoryStore();
+ const deps = { store: async () => m.store, runOps: async () => 0, out: c.out };
+ assert.equal(await gen.localSweepMain({}, deps), 0);
+ assert.match(c.lines[0]!, /^local sweep: claim form neutral \(code writes each line/);
+ assert.match(c.lines[1]!, /a quote that may be read aloud: flag \(kept, marked to check by ear\)/);
+ assert.equal(m.localSweeps.length, 0, "a bare call writes nothing");
+ assert.equal(await gen.localSweepMain({ readAloud: "drop" }, deps), 0);
+ assert.deepEqual(m.localSweeps[0], { claimForm: "neutral", readAloud: "drop" });
+ assert.equal(await gen.localSweepMain({ form: "sentence", readAloud: "off" }, deps), 0);
+ assert.deepEqual(m.localSweeps[1], { claimForm: "sentence", readAloud: "off" });
+ assert.ok(c.lines.includes("(written to the editor at http://editor.test)"));
+ for (const o of [{ form: "poem" }, { readAloud: "maybe" }]) assert.equal(await gen.localSweepMain(o, deps), 2, JSON.stringify(o));
+ assert.equal(m.localSweeps.length, 2);
+ // The policy shows it too.
+ const p = capture();
+ await gen.policyMain({ json: false }, { ...deps, out: p.out });
+ assert.ok(p.lines.some((l) => l.startsWith("local sweep: claim form sentence")));
+});
+
test("gen run exits 3 and runs nothing when the task is routed to code", async () => {
const c = capture();
const ran: string[][] = [];
@@ -198,6 +226,10 @@ test("the offline store reads and writes settings.json through the settings writ
const c = capture();
assert.equal(await gen.setMain({ preset: "api" }, { store: async () => store, runOps: async () => 0, out: c.out }), 0);
assert.equal((await store.read()).preset, "api");
+ // The local sweep's two knobs: the defaults, then written through the same writer.
+ assert.deepEqual((await store.read()).localSweep, { claimForm: "neutral", readAloud: "flag" });
+ assert.equal(await gen.localSweepMain({ form: "sentence", readAloud: "drop" }, { store: async () => store, runOps: async () => 0, out: c.out }), 0);
+ assert.deepEqual(JSON.parse(readFileSync(path.join(ROOT, "settings.json"), "utf8")).generation.localSweep, { claimForm: "sentence", readAloud: "drop" });
});
test("gen run research takes --autonomy; nothing else does", async () => {
diff --git a/common/bin/gen.ts b/common/bin/gen.ts
@@ -4,6 +4,9 @@
// archilyzer gen policy [--json] the routes, models, caps and the day's API spend
// archilyzer gen preset code|balanced|api|local route every task at once
// archilyzer gen set <task> code|api|local route one task
+// archilyzer gen local-sweep [--form neutral|sentence] [--read-aloud flag|drop|off]
+// the local sweep's claim form and read-aloud rule
+// (settings.generation.localSweep); bare: what they are
// archilyzer gen run <task> [<question|feedback>] --article <id> [--via api|local|code] […] [--wait]
// enqueue a report-draft job (`pnpm ops report-draft`);
// a media draft (cut, onscreen, teaser, flips, threads,
@@ -32,6 +35,11 @@ import type { CommandContext } from "./_cli";
import type { FlagValue } from "./_parseFlags";
import { REPO_ROOT, runChild } from "./_spawnBin";
import {
+ CLAIM_FORMS,
+ READ_ALOUD_MODES,
+ type ClaimForm,
+ type GenerationLocalSweep,
+ type ReadAloudMode,
GENERATION_PRESETS,
GENERATION_PRESET_NAMES,
GENERATION_ROUTES,
@@ -49,6 +57,7 @@ export type GenPolicy = {
routes: Record<string, GenerationRoute>;
models: { api: string; local: string; extractor?: string };
caps?: Record<string, number>;
+ localSweep?: GenerationLocalSweep;
};
export type GenUsage = { day: string; usd: number; jobs: number; daily: number };
@@ -60,6 +69,7 @@ export type GenStore = {
read(): Promise<GenPolicy>;
usage(): Promise<GenUsage | null>;
writeRoutes(routes: Record<string, GenerationRoute>): Promise<GenPolicy>;
+ writeLocalSweep(localSweep: GenerationLocalSweep): Promise<GenPolicy>;
};
export type GenDeps = {
@@ -85,9 +95,29 @@ export function policyFrom(value: unknown): GenPolicy | null {
routes,
models: { api: m.api, local: m.local, ...(typeof m.extractor === "string" ? { extractor: m.extractor } : {}) },
...(v.caps && typeof v.caps === "object" ? { caps: v.caps as Record<string, number> } : {}),
+ ...(localSweepFrom(v.localSweep) ? { localSweep: localSweepFrom(v.localSweep)! } : {}),
};
}
+function localSweepFrom(value: unknown): GenerationLocalSweep | null {
+ const v = value && typeof value === "object" ? (value as Record<string, unknown>) : null;
+ if (!v || !(CLAIM_FORMS as readonly unknown[]).includes(v.claimForm) || !(READ_ALOUD_MODES as readonly unknown[]).includes(v.readAloud)) return null;
+ return { claimForm: v.claimForm as ClaimForm, readAloud: v.readAloud as ReadAloudMode };
+}
+
+const FORM_WORDS: Record<ClaimForm, string> = {
+ neutral: "neutral (code writes each line: In <title> (<date>), on <topic>: \"<quote>\")",
+ sentence: "sentence (the model drafts each claim; a meaning check judges it)",
+};
+const READ_ALOUD_WORDS: Record<ReadAloudMode, string> = {
+ flag: "flag (kept, marked to check by ear)",
+ drop: "drop (left out)",
+ off: "off (not looked for)",
+};
+export function formatLocalSweep(ls: GenerationLocalSweep): string[] {
+ return [`local sweep: claim form ${FORM_WORDS[ls.claimForm]}`, ` a quote that may be read aloud: ${READ_ALOUD_WORDS[ls.readAloud]}`];
+}
+
const usd = (n: number) => `$${n.toFixed(2)}`;
export function formatPolicy(p: GenPolicy, usage: GenUsage | null): string[] {
@@ -102,6 +132,7 @@ export function formatPolicy(p: GenPolicy, usage: GenUsage | null): string[] {
(typeof c.daily === "number" ? ` · ${c.daily > 0 ? `daily ${usd(c.daily)}` : "no daily cap"}` : ""),
);
}
+ if (p.localSweep) lines.push(...formatLocalSweep(p.localSweep));
if (usage) lines.push(`today ${usage.day} (UTC): ${usd(usage.usd)} on the Claude API in ${usage.jobs} job(s)`);
return lines;
}
@@ -171,6 +202,13 @@ export async function editorStore(env: NodeJS.ProcessEnv = process.env, fetchImp
if (!p) throw new Error("the editor's answer carried no generation block");
return p;
},
+ async writeLocalSweep(localSweep) {
+ const a = await call("POST", "/api/ops/settings", { patch: { generation: { localSweep } } });
+ if (a.kind !== "ok") throw fail(a);
+ const p = policyFrom((a.body.value as Record<string, unknown> | undefined)?.generation);
+ if (!p) throw new Error("the editor's answer carried no generation block");
+ return p;
+ },
};
}
@@ -194,6 +232,11 @@ export async function offlineStore(): Promise<GenStore> {
await writeSettings({ ...s, generation: { ...s.generation, routes: { ...s.generation.routes, ...routes } as typeof s.generation.routes } });
return read();
},
+ async writeLocalSweep(localSweep) {
+ const s = getSettings();
+ await writeSettings({ ...s, generation: { ...s.generation, localSweep } });
+ return read();
+ },
};
}
@@ -201,7 +244,7 @@ export async function defaultStore(env: NodeJS.ProcessEnv = process.env): Promis
return (await editorStore(env)) ?? (await offlineStore());
}
-// ─── The four verbs ───
+// ─── The verbs ───
export async function policyMain(o: { json: boolean }, deps: GenDeps): Promise<number> {
const out = deps.out ?? console;
@@ -247,6 +290,41 @@ export async function setMain(o: { preset?: string; task?: string; route?: strin
return 0;
}
+// `gen local-sweep`: the local sweep's claim form and what it does with a
+// quote that may be read aloud (settings.generation.localSweep). Bare: what
+// they are.
+export async function localSweepMain(o: { form?: string; readAloud?: string }, deps: GenDeps): Promise<number> {
+ const out = deps.out ?? console;
+ if (o.form !== undefined && !(CLAIM_FORMS as readonly string[]).includes(o.form)) {
+ out.error(`gen local-sweep: --form is one of ${CLAIM_FORMS.join(", ")}`);
+ return 2;
+ }
+ if (o.readAloud !== undefined && !(READ_ALOUD_MODES as readonly string[]).includes(o.readAloud)) {
+ out.error(`gen local-sweep: --read-aloud is one of ${READ_ALOUD_MODES.join(", ")}`);
+ return 2;
+ }
+ const store = await deps.store();
+ if ("error" in store) {
+ out.error(`gen local-sweep: ${store.error}`);
+ return 1;
+ }
+ const p = await store.read();
+ if (!p.localSweep) {
+ out.error(`gen local-sweep: ${store.where} carries no generation.localSweep (an editor older than this checkout?)`);
+ return 1;
+ }
+ if (o.form === undefined && o.readAloud === undefined) {
+ for (const l of [...formatLocalSweep(p.localSweep), `(from ${store.where})`]) out.log(l);
+ return 0;
+ }
+ const saved = await store.writeLocalSweep({
+ claimForm: (o.form as ClaimForm | undefined) ?? p.localSweep.claimForm,
+ readAloud: (o.readAloud as ReadAloudMode | undefined) ?? p.localSweep.readAloud,
+ });
+ for (const l of [...formatLocalSweep(saved.localSweep ?? p.localSweep), `(written to ${store.where})`]) out.log(l);
+ return 0;
+}
+
// The report-draft body from `gen run`'s words, or why not. The editor judges
// the rest (controller/reportDraft.ts parseReportDraftBody).
export function runBody(task: string, text: string | undefined, flags: Record<string, FlagValue>): Record<string, unknown> | { error: string } {
@@ -360,6 +438,12 @@ export async function genSetRow(ctx: CommandContext): Promise<number> {
const [task, route] = ctx.positionals;
return setMain({ ...(task ? { task } : {}), ...(route ? { route } : {}) }, defaultDeps(ctx));
}
+export async function genLocalSweepRow(ctx: CommandContext): Promise<number> {
+ const str = (k: string) => (typeof ctx.flags[k] === "string" ? (ctx.flags[k] as string).trim() : undefined);
+ const form = str("form");
+ const readAloud = str("read-aloud");
+ return localSweepMain({ ...(form !== undefined ? { form } : {}), ...(readAloud !== undefined ? { readAloud } : {}) }, defaultDeps(ctx));
+}
export async function genRunRow(ctx: CommandContext): Promise<number> {
const [task, text] = ctx.positionals;
return runMain({ ...(task ? { task } : {}), ...(text ? { text } : {}), flags: ctx.flags }, defaultDeps(ctx));
diff --git a/umtool/components/articles/PolicyPanel.tsx b/umtool/components/articles/PolicyPanel.tsx
@@ -192,6 +192,37 @@ export default function PolicyPanel({
</Button>
</form>
+ <div className="micro pt-1">local sweep</div>
+ <div className="flex flex-wrap items-center gap-x-4 gap-y-1" data-policy-local-sweep={`${g.localSweep.claimForm} ${g.localSweep.readAloud}`}>
+ <label className="flex items-center gap-1.5">
+ <span className="text-[var(--color-dim)]">each finding's line</span>
+ <select
+ aria-label="local sweep claim form"
+ className={field}
+ value={g.localSweep.claimForm}
+ disabled={busy}
+ onChange={(e) => save({ localSweep: { ...g.localSweep, claimForm: e.target.value } }, "the local sweep's claim form")}
+ >
+ <option value="neutral">written by code: In title (date), on topic: quote</option>
+ <option value="sentence">drafted by the model, then checked</option>
+ </select>
+ </label>
+ <label className="flex items-center gap-1.5">
+ <span className="text-[var(--color-dim)]">a quote that may be read aloud</span>
+ <select
+ aria-label="local sweep read-aloud quotes"
+ className={field}
+ value={g.localSweep.readAloud}
+ disabled={busy}
+ onChange={(e) => save({ localSweep: { ...g.localSweep, readAloud: e.target.value } }, "the local sweep's read-aloud rule")}
+ >
+ <option value="flag">kept, marked to check by ear</option>
+ <option value="drop">left out</option>
+ <option value="off">not looked for</option>
+ </select>
+ </label>
+ </div>
+
<div className="micro pt-1">API key</div>
<div className="flex items-center gap-2" data-key-file-exists={policy.keyFile.exists ? "yes" : "no"}>
<code className="font-mono text-[11px]">{policy.keyFile.path}</code>
diff --git a/umtool/e2e/settings.spec.ts b/umtool/e2e/settings.spec.ts
@@ -87,6 +87,20 @@ test("generation: presets write their routes, a route alone makes it custom, cap
await again.getByRole("button", { name: "Save caps" }).click();
await expect(again.getByRole("textbox", { name: "cap sweep" })).toHaveValue("5");
+ // The local sweep's two knobs (demo epic D2): who writes a finding's line,
+ // and what happens to a quote that may be read aloud. The defaults, then
+ // each written through the editor and put back.
+ const local = again.locator("[data-policy-local-sweep]");
+ await expect(local).toHaveAttribute("data-policy-local-sweep", "neutral flag");
+ await again.getByRole("combobox", { name: "local sweep read-aloud quotes" }).selectOption("drop");
+ await expect(again.getByRole("status")).toHaveText("saved the local sweep's read-aloud rule");
+ expect(stubAsked("settings").at(-1)).toMatchObject({ patch: { generation: { localSweep: { claimForm: "neutral", readAloud: "drop" } } } });
+ await again.getByRole("combobox", { name: "local sweep claim form" }).selectOption("sentence");
+ await expect(local).toHaveAttribute("data-policy-local-sweep", "sentence drop");
+ await again.getByRole("combobox", { name: "local sweep claim form" }).selectOption("neutral");
+ await again.getByRole("combobox", { name: "local sweep read-aloud quotes" }).selectOption("flag");
+ await expect(local).toHaveAttribute("data-policy-local-sweep", "neutral flag");
+
await again.getByRole("button", { name: "balanced" }).click();
await expect(again).toHaveAttribute("data-policy-preset", "balanced");
});
diff --git a/umtool/lib/articles/generation.ts b/umtool/lib/articles/generation.ts
@@ -230,7 +230,7 @@ export async function readPolicy(): Promise<PolicyView> {
// What umtool may write of `generation`. The key file's path is not here: the
// panel shows it, and the editor's own settings page sets it.
-const POLICY_KEYS = ["routes", "models", "caps", "cacheTtl", "triage"] as const;
+const POLICY_KEYS = ["routes", "models", "caps", "cacheTtl", "triage", "localSweep"] as const;
/** Write the policy through the editor's settings action. Answers the policy as read back. */
export async function writePolicy(patch: Record<string, unknown>): Promise<PolicyView> {