Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit cc37294c03d86c9d3dfcad92fddb9ce5e32518f9
parent 9a494d7c03968a29c6dd19e1f284b0df67fa0d67
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 14 Oct 2026 07:31:03 -0400

umtool: e2e/run-trace.spec.ts and its fixture (a traced run, a turns-only run with two starts, a live one); Agent runs on Research; a Claude Code-routed scope sweep runs the API agent; the checks line shortened

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mcommon/lib/report/draft/tasks/trace.test.ts | 2+-
Mumtool/app/research/page.tsx | 12+++++++++---
Mumtool/components/research/RunView.tsx | 2+-
Aumtool/e2e/run-trace.spec.ts | 190+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/research/boards.test.ts | 27+++++++++++++++++++++++++++
Mumtool/lib/research/handoff.ts | 8++++++--
Mumtool/lib/research/runs-view.ts | 2+-
Mumtool/lib/research/runs.test.ts | 2+-
8 files changed, 236 insertions(+), 9 deletions(-)

diff --git a/common/lib/report/draft/tasks/trace.test.ts b/common/lib/report/draft/tasks/trace.test.ts @@ -137,7 +137,7 @@ test("runOnIteration with a trace: the run's start and end lines, the body's eve assert.equal(out.status, "failed"); const lines = await readTrace(paths, "cov", 1); assert.deepEqual(lines.map((l) => l.t), ["run", "scope", "check", "run"]); - assert.deepEqual([lines[0]!.phase, (lines[0] as { model?: string }).model, (lines[0] as { task?: string }).task], ["start", "qwen3:8b", "sweep-pipeline"]); + assert.deepEqual([(lines[0] as { phase?: string }).phase, (lines[0] as { model?: string }).model, (lines[0] as { task?: string }).task], ["start", "qwen3:8b", "sweep-pipeline"]); const end = lines.at(-1) as Extract<TraceEvent, { t: "run"; phase: "end" }>; assert.equal(end.phase, "end"); assert.equal(end.status, "failed"); diff --git a/umtool/app/research/page.tsx b/umtool/app/research/page.tsx @@ -5,6 +5,7 @@ import { buttonVariants } from "@/components/ui/button"; import { listCases } from "@/lib/research/boards"; import { scopeFrom, scopeOf } from "@/lib/research/corpus"; import { researchArchiveHref } from "@/lib/research/hrefs"; +import { runsHref } from "@/lib/research/runs-hrefs"; import { listSources } from "@/lib/research/sources"; import type { ScopeSummary } from "@/lib/research/types"; @@ -40,9 +41,14 @@ export default async function ResearchPage({ searchParams }: { searchParams: Pro active="research" crumbs={[{ label: "research" }]} actions={ - <Link href={researchArchiveHref({ source: scope.source === sources[0].handle ? undefined : scope.source })} className={buttonVariants({ variant: "outline", size: "sm" })}> - Archive inventory - </Link> + <> + <Link href={runsHref()} prefetch={false} className={buttonVariants({ variant: "outline", size: "sm" })}> + Agent runs + </Link> + <Link href={researchArchiveHref({ source: scope.source === sources[0].handle ? undefined : scope.source })} className={buttonVariants({ variant: "outline", size: "sm" })}> + Archive inventory + </Link> + </> } /> <ResearchView diff --git a/umtool/components/research/RunView.tsx b/umtool/components/research/RunView.tsx @@ -458,7 +458,7 @@ export default function RunView({ initial }: { initial: View }) { } below={ <div className="grid gap-1.5 pt-1"> - <p className="display m-0 max-w-[1000px] text-[19px] leading-[1.2] text-text" data-run-question=""> + <p className="display m-0 max-w-[1000px] text-[17px] leading-[1.25] text-text-2" data-run-question=""> {h.question ?? h.title ?? "No question recorded"} </p> <div className="flex flex-wrap items-center gap-x-2 gap-y-1 text-[12.5px] text-muted" data-run-meta=""> diff --git a/umtool/e2e/run-trace.spec.ts b/umtool/e2e/run-trace.spec.ts @@ -0,0 +1,190 @@ +import { test, expect, type Page } from "@playwright/test"; +import { appendFileSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import { BOARD_CASE } from "./fixtures/research-fixture.mjs"; +import { + DROPPED, + KEPT_KEEPER, + LIVE_ARTICLE, + REPAIRED, + RUN_ARTICLE, + RUN_QUESTION, + TURNS_ARTICLE, + jsonLines, + liveTraceNext, +} from "./fixtures/run-trace-fixture.mjs"; +import { researchCaseHref, researchHref } from "../lib/research/hrefs"; +import { runBoardId, runHref, runsHref } from "../lib/research/runs-hrefs"; +import { WARM_TIMEOUT, warm } from "./warm"; + +// --------------------------------------------------------------------------- +// Transparent runs (plans/umtool-redesign.md, R3) on the run fixture +// (e2e/fixtures/run-trace-fixture.mjs): a traced sweep replayed step by step +// with a dropped quote and its reason; an imported turns-only run whose two +// starts are two runs; a run still going, followed live as its trace grows; +// "Open as a board"; and a sweep planned from a case's scope. +// --------------------------------------------------------------------------- + +const HERE = path.dirname(fileURLToPath(import.meta.url)); +const FIXTURE = path.join(HERE, "..", ".e2e-song"); +const liveTrace = path.join(FIXTURE, "articles", LIVE_ARTICLE, "iterations", "1", "trace.jsonl"); +const runBoardDir = path.join(FIXTURE, ".umtool", "research", runBoardId(RUN_ARTICLE, 1)); + +const steps = (page: Page) => page.getByRole("group", { name: "Steps" }); +const lit = (page: Page) => steps(page).locator("[data-lit-line][data-lit]"); +const step = (page: Page, id: string) => steps(page).locator(`[data-lit-line][data-lit-id="${id}"]`); +const detail = (page: Page) => page.locator("[data-detail]"); + +let liveHead = ""; + +test.beforeAll(async ({ playwright }) => { + test.setTimeout(WARM_TIMEOUT); + liveHead = readFileSync(liveTrace, "utf8"); + await warm(playwright, [runHref(RUN_ARTICLE, 1), runsHref(), `/api/research/runs/${RUN_ARTICLE}/1`, researchCaseHref(BOARD_CASE)]); +}); + +test.afterAll(() => { + // What the specs wrote, put back: the live trace, the run's board. + writeFileSync(liveTrace, liveHead); + rmSync(runBoardDir, { recursive: true, force: true }); +}); + +test("a traced run: the head, its steps with their spend, the lit step's detail, a dropped quote and why", async ({ page }) => { + await page.goto(runHref(RUN_ARTICLE, 1)); + await expect(page.locator("[data-run-mode]")).toHaveAttribute("data-run-mode", "replay"); + await expect(page.locator("[data-run-question]")).toHaveText(RUN_QUESTION); + const meta = page.locator("[data-run-meta]"); + await expect(meta).toContainText("Sonnet 5.5 · Haiku 4.5 extractor"); + await expect(meta).toContainText("harbor-radio, night-desk"); + await expect(meta).toContainText("0.55 min"); + await expect(page.locator("[data-run-usd]")).toHaveText("$0.18"); + await expect(page.locator("[data-run-checks]")).toContainText("2 kept · 1 dropped"); + // The rail lights Research; the trail reaches every run. + await expect(page.locator('a[aria-current][href="/research"]')).toBeVisible(); + await expect(page.getByRole("navigation", { name: "Breadcrumb" }).getByRole("link", { name: "runs" })).toHaveAttribute("href", runsHref()); + + // The steps, in order, with the running spend. + await expect(steps(page).locator("[data-lit-line]")).toHaveCount(8); + expect(await steps(page).locator("[data-lit-line]").evaluateAll((els) => els.map((e) => e.getAttribute("data-lit-id")))).toEqual([ + "scope", + "t0", + "t1", + "t2", + "r0", + "findings", + "checks", + "end", + ]); + await expect(step(page, "t1").locator("[data-step-usd]")).toHaveText("$0.10"); + await expect(step(page, "checks")).toContainText("2 kept · 1 dropped"); + await expect(page.locator("[data-lane-coverage]")).toContainText("3 matched · 3 read · complete"); + await expect(page.locator("[data-spend-end]")).toHaveText("$0.18"); + + // The first step is lit: the scope. + await expect(lit(page)).toHaveAttribute("data-lit-id", "scope"); + await expect(detail(page)).toContainText("lighthouse budget"); + // j: the enumeration, its ids. + await steps(page).locator("[data-lit-line][data-lit]").focus(); + await page.keyboard.press("j"); + await expect(lit(page)).toHaveAttribute("data-lit-id", "t0"); + await expect(detail(page).locator("[data-enumeration]")).toContainText("3 matched"); + await expect(detail(page).locator("[data-ids] code")).toHaveCount(3); + // The batch: the extractor's own lines, on the reader surface. + await page.keyboard.press("j"); + await expect(detail(page).locator("[data-batch-lines]")).toContainText(REPAIRED.now); + // The checks: the dropped quote, its reason; the refused one repaired and kept. + await step(page, "checks").click(); + const dropped = detail(page).locator("[data-check-group=dropped] [data-check=dropped]"); + await expect(dropped).toHaveCount(1); + await expect(dropped).toContainText(DROPPED.quote); + await expect(dropped.locator("[data-check-reason]")).toHaveText(`why: ${DROPPED.reason}`); + await expect(detail(page).locator("[data-check-group=kept] [data-check=kept]")).toHaveCount(2); + await expect(detail(page).locator("[data-check-group=refused]")).toContainText(REPAIRED.was); + // The spend chart lights the same step. + await step(page, "t2").click(); + await expect(page.locator("[data-spend-point=t2]")).toHaveAttribute("data-lit-point", ""); +}); + +test("replay: r lights every step in turn, from the first to the end", async ({ page }) => { + await page.goto(runHref(RUN_ARTICLE, 1)); + await expect(steps(page)).toHaveAttribute("data-hydrated", ""); + await page.locator("body").press("r"); + await expect(page.locator("[data-replay]")).toHaveAttribute("data-replay", "on"); + await expect(lit(page)).toHaveAttribute("data-lit-id", "t2", { timeout: 10_000 }); + await expect(lit(page)).toHaveAttribute("data-lit-id", "end", { timeout: 10_000 }); + await expect(page.locator("[data-replay]")).toHaveAttribute("data-replay", "off"); +}); + +test("a run before the trace: turns.jsonl with two run starts is two runs, never summed; its checks are a gap", async ({ page }) => { + await page.goto(runHref(TURNS_ARTICLE, 1)); + await expect(page.locator("[data-run-mode]")).toContainText("from turns.jsonl"); + const picker = page.getByRole("navigation", { name: "Runs" }); + await expect(picker.getByRole("link")).toHaveCount(2); + await expect(picker.getByRole("link", { name: "2" })).toHaveAttribute("aria-current", "page"); + await expect(page.locator("[data-run-notes]")).toContainText("2 run starts"); + expect(await steps(page).locator("[data-lit-line]").evaluateAll((els) => els.map((e) => e.getAttribute("data-lit-id")))).toEqual(["scope", "t0", "t1", "t2", "t3", "checks"]); + await expect(step(page, "checks")).toHaveAttribute("data-gap", ""); + await expect(step(page, "checks")).toContainText("kept / dropped not recorded"); + await expect(page.locator("[data-run-usd]")).toHaveText("$0.16"); + await expect(page.locator("[data-lane-coverage]")).toContainText("not recorded"); + + await picker.getByRole("link", { name: "1" }).click(); + await expect(page).toHaveURL(new RegExp(`/research/runs/${TURNS_ARTICLE}/1\\?run=1$`)); + await expect(picker.getByRole("link", { name: "1" })).toHaveAttribute("aria-current", "page"); + await expect(page.locator("[data-run-usd]")).toHaveText("$0.09"); + expect(await steps(page).locator("[data-lit-line]").evaluateAll((els) => els.map((e) => e.getAttribute("data-lit-id")))).toEqual(["scope", "t0", "t1", "t2", "checks"]); + await step(page, "t1").click(); + await expect(detail(page).locator("[data-lines-missing]")).toBeVisible(); +}); + +test("live: a running sweep's page follows its trace as it grows", async ({ page }) => { + await page.goto(runHref(LIVE_ARTICLE, 1)); + await expect(page.locator("[data-run-mode]")).toHaveAttribute("data-run-mode", "live"); + await expect(steps(page).locator("[data-lit-line]")).toHaveCount(2); + await expect(lit(page)).toHaveAttribute("data-lit-id", "t0"); + appendFileSync(liveTrace, jsonLines(liveTraceNext())); + await expect(step(page, "t1")).toBeVisible({ timeout: 10_000 }); + await expect(lit(page)).toHaveAttribute("data-lit-id", "t1"); + await expect(page.locator("[data-run-usd]")).toHaveText("$0.08"); + await expect(page.getByRole("button", { name: /^Replay/ })).toBeDisabled(); +}); + +test("open as a board: the run's kept findings become quotes by the agent; the board links back", async ({ page }) => { + await page.goto(runHref(RUN_ARTICLE, 1)); + await page.getByRole("button", { name: /^Open as a board/ }).click(); + const status = page.locator("[data-run-status-line]"); + await expect(status).toContainText("Board made: 2 quotes added"); + await status.getByRole("link", { name: "Open the board" }).click(); + await expect(page).toHaveURL(new RegExp(`/research/${runBoardId(RUN_ARTICLE, 1)}$`)); + const board = page.getByRole("group", { name: "Board" }); + await expect(board.locator("[data-quote]")).toHaveCount(2); + await expect(board.locator("[data-by=agent]")).toHaveCount(2); + await expect(board.locator("[data-slip]").first()).toContainText(REPAIRED.now); + await expect(board).toContainText(KEPT_KEEPER); + await expect(page.locator("[data-case-run]").getByRole("link")).toHaveAttribute("href", runHref(RUN_ARTICLE, 1)); + // Again: nothing added twice; the button says it updates. + await page.goto(runHref(RUN_ARTICLE, 1)); + await page.getByRole("button", { name: /^Update the board/ }).click(); + await expect(page.locator("[data-run-status-line]")).toContainText("Board updated: 0 quotes added, 2 already on it"); +}); + +test("a case's scope: Run a sweep on this scope plans it (no seed, the model and cap shown); the runs index lists every sweep", async ({ page }) => { + await page.goto(researchCaseHref(BOARD_CASE)); + await page.getByRole("button", { name: "Run a sweep on this scope" }).click(); + const dlg = page.locator('dialog[data-handoff="sweep"]'); + await expect(dlg).toContainText("Run a sweep on this scope"); + await expect(dlg).toContainText("Corpus"); + 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(); + await page.keyboard.press("Escape"); + await expect(dlg).toBeHidden(); + + await page.goto(researchHref()); + await page.getByRole("link", { name: "Agent runs" }).click(); + await expect(page).toHaveURL(/\/research\/runs$/); + for (const a of [RUN_ARTICLE, TURNS_ARTICLE, LIVE_ARTICLE]) await expect(page.locator(`[data-run-row="${a}/1"]`)).toBeVisible(); + await page.locator(`[data-run-row="${RUN_ARTICLE}/1"]`).getByRole("link").click(); + await expect(page).toHaveURL(new RegExp(`/research/runs/${RUN_ARTICLE}/1$`)); +}); diff --git a/umtool/lib/research/boards.test.ts b/umtool/lib/research/boards.test.ts @@ -178,3 +178,30 @@ test("hand-off to a video: a plan, then a project whose timeline is the board's assert.match(again.refusals.join(" "), /already exists/); assert.equal((await boards.readCase("lighthouse-budget")).handoffs.length, 2); }); + +test("R3: a sweep on the case's scope — no seed, the policy's route (Claude Code's runs the API agent); confirmed, it answers the run's page", async () => { + const { boards, handoff } = lib; + // The stand-in policy routes sweeps to Claude Code: a session's, so the API agent runs it, and the plan says so. + const { plan } = await handoff.planScopeSweep("lighthouse-budget"); + assert.equal(plan.seeded, false); + assert.equal(plan.seed.chars, 0); + assert.deepEqual(plan.refusals, []); + assert.match(plan.warnings.join(" "), /routes sweeps to Claude Code, which runs in a session; this sweep runs the API agent on claude-sonnet-5-5/); + assert.equal(plan.model, "claude-sonnet-5-5"); + assert.equal(plan.capUsd, 4); + assert.deepEqual(plan.channels.sort(), ["harbor-radio", "harbor-radio-rumble", "night-desk"]); + // A local model named for it: no cap, no extractor. + const local = (await handoff.planScopeSweep("lighthouse-budget", { model: "qwen3:8b" })).plan; + assert.deepEqual([local.model, local.capUsd, local.extractor ?? null], ["qwen3:8b", null, null]); + const before = asked.length; + const out = await handoff.confirmScopeSweep("lighthouse-budget", {}); + assert.deepEqual(out, { href: "/research/runs/lighthouse-budget/1", jobId: "job-1", iteration: 1 }); + const sent = asked.slice(before).find((a) => a.url === "/api/ops/report-draft")!.body; + assert.equal(sent.task, "sweep"); + assert.equal(sent.seed, undefined, "no seed: the scope alone"); + assert.equal(sent.model, "claude-sonnet-5-5"); + assert.equal(sent.question, "lighthouse budget"); + assert.equal(sent.source, source); + const h = (await boards.readCase("lighthouse-budget")).handoffs.at(-1)!; + assert.match(h.what!, /^a sweep on the scope: lighthouse-budget i1, job job-1$/); +}); diff --git a/umtool/lib/research/handoff.ts b/umtool/lib/research/handoff.ts @@ -40,7 +40,8 @@ import type { ArticlePlan, CaseDoc, VideoPlan } from "./case-types"; // "Run a sweep on this scope" (R3) is the same door without the seed: a // report-draft sweep over the case's scope (its query, channels, dates and // source), on the policy's sweep route -- the API agent and its extractor, or -// the local pipeline -- planned and confirmed the same way, and answered with +// the local pipeline; a route to Claude Code (a session's, not a job's) runs +// the API agent, as a seeded sweep does -- planned and confirmed the same way, and answered with // the run's page (/research/runs/<article>/<n>), which follows it live. // // RESEARCH RULES: a board holding a local-only quote (Candace's channels, @@ -104,7 +105,10 @@ export async function planArticle( } else if (over.model?.trim()) { model = over.model.trim(); } else if (route === "code") { - refusals.push("the policy routes sweeps to Claude Code, which runs in a session, not here: route sweeps to the API or the local model in Settings"); + // Claude Code runs in a session, not as an editor job: the API agent + // runs it here, as a seeded sweep does, and the plan says so. + model = p.generation.models.api; + warnings.push(`the policy routes sweeps to Claude Code, which runs in a session; this sweep runs the API agent on ${model}`); } else { model = route === "api" ? p.generation.models.api : p.generation.models.local; } diff --git a/umtool/lib/research/runs-view.ts b/umtool/lib/research/runs-view.ts @@ -163,7 +163,7 @@ function checksStep(checks: RunCheck[], id = "checks"): RunStep { const kept = checks.filter((c) => c.ok && c.stage === "final").length; const dropped = checks.filter((c) => c.dropped).length; const refused = checks.filter((c) => !c.ok && !c.dropped).length; - s.sub = [`${thousands(kept)} kept`, `${thousands(dropped)} dropped`, refused ? `${thousands(refused)} refused, then repaired or dropped` : ""].filter(Boolean).join(" · "); + s.sub = [`${thousands(kept)} kept`, `${thousands(dropped)} dropped`, refused ? `${thousands(refused)} refused` : ""].filter(Boolean).join(" · "); s.detail.checks = checks; return s; } diff --git a/umtool/lib/research/runs.test.ts b/umtool/lib/research/runs.test.ts @@ -64,7 +64,7 @@ test("a trace: scope, the turns with their enumeration and batch, findings, chec assert.equal(Math.round(t1.stepUsd! * 100) / 100, 0.05, "the turn and its extractor"); assert.deepEqual(v.steps.map((s) => s.usd), [null, 0.05, 0.1, 0.16, 0.18, null, null, 0.18]); const checks = v.steps.find((s) => s.kind === "checks")!; - assert.equal(checks.sub, "2 kept · 1 dropped · 3 refused, then repaired or dropped"); + assert.equal(checks.sub, "2 kept · 1 dropped · 3 refused"); const drop = checks.detail.checks.find((c) => c.dropped)!; assert.deepEqual([drop.quote, drop.reason, drop.claim], [DROPPED.quote, DROPPED.reason, DROPPED.claim]); assert.equal(v.steps.find((s) => s.kind === "findings")!.detail.findings[1]!.cites[0]!.quote, KEPT_KEEPER);