commit 8c98644582c6c11d3fa547aa560f49015958155f
parent d65aac62059cba4333dfa2ad8e326990402519d5
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 14 Oct 2026 08:45:14 -0400
plans: umtool redesign — R3 as shipped (transparent agent runs)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
1 file changed, 150 insertions(+), 1 deletion(-)
diff --git a/plans/umtool-redesign.md b/plans/umtool-redesign.md
@@ -356,7 +356,8 @@ P0 design ─► P1 foundation ─┬─► P3 inbox/work/tools/URLs ─┬─
| P5 create + settings | `ux/p5` | in progress |
| P4a-2 article-rooted merge | `ux/p4a2` | in progress |
| P4a-3 song pieces | — | after P4a-2 |
-| R3, P4b, P6 | — | after R2 / P4a / all |
+| R3 transparent runs | `ux/r3` | shipped on the branch, awaiting review |
+| P4b, P6 | — | after P4a / all |
### P2a, as shipped
@@ -1394,3 +1395,151 @@ built (40 s) and restarted (`scripts/p4a-umtool.sh`). A first rollout attempt la
the then-live code into `.next` and was stopped before its restart; the build was let finish (identical code) and the
real rollout followed. Live: `/projects/quartering-diet` and its `?tab=cut|build|media` 200, an article's video project
200, `/browse/<p>` 307, the Overview tab `aria-current`, decisions API 828 rows with notes' hrefs intact.
+
+### R3, as shipped
+
+**What.** Transparent agent runs: a sweep records what it did as it does it, and umtool shows it step by step —
+live while it runs, a replay when it is done — with the quote checks that used to be invisible (kept, refused,
+dropped, and why). Old runs, which have only `turns.jsonl`, are projected the same way. A run's kept findings
+open as a research board, and a board's scope can start a run. Read-only on the corpus and the article store
+from umtool; the editor writes the trace.
+
+- **`trace.jsonl`** (`common/lib/report/draft/tasks/trace.ts`; `ITERATION_FILES` + `trace.jsonl`): one JSON object a
+ line, `{t, at, run, …}`, appended as the run goes (a queue of `appendFile`s, no lock: one writer per run; a failed
+ write is logged once and never fails the run). `run` is 1 for the file's first run, 2 for a resumed job's, ….
+ Events: `run {phase: start, task, model, extractor}`, `scope {source, channels, from, to, question, model,
+ extractor, origin, maxUsd, batchSize, seed: {chars}}`, `terms` (the pipeline's), `enumerate {query, n, ids,
+ partial, unreached, total, posts}` (read off `enumerate_matches`' own answer: its rows, COVERAGE PARTIAL, NEVER
+ REACHED), `read {tool, ids}`, `batch {k, of, ids, lines, model, usd, cut}` (the extractor's returned LINES),
+ `cost {step, usd, model, total, turn, calls, text}`, `check {quote, cite, ok, reason, stage, dropped, claim,
+ round}` (stages: `extract` — the pipeline's window check, every quote kept or dropped; `check`/`strict` — a
+ strict round's refusals; `drop` — a finding dropped, with the problem that took it; `final` — every quote kept),
+ `finding {section, claim, cites}`, `note`, `run {phase: end, status, summary, usd, minutes, coverage}`. An
+ agent's events carry `turn` and `phase` (`agent` | `repair`), so a step is put on the turn that made it. Caps:
+ 2,000 ids, 300 lines of 600 characters, quotes 1,200.
+- **Where it is written.** `runOnIteration` takes `trace: {task, model?, extractor?}`: it opens the trace once the
+ iteration is running, writes the start, hands the task `h.trace(e)` and `h.setCoverage(read)`, and writes the end
+ — and flushes — BEFORE the final status update, so a page that reads the iteration ended finds the trace's end
+ already there. `sweep-agent.ts` wraps the corpus tools (an enumeration's ids and coverage, a read's ids), the
+ extractor (`batch` with its lines and its cost), the agent's turn events (`cost` per turn, the repair round's as
+ `repair turn N`), each strict round's refusals, the drops (`dropFailedFindings` now also answers `items`: the
+ claim and the problem), and the kept report (`traceReport`). `sweep-pipeline.ts` the same over its own steps.
+- **`iteration.json` gains `coverage {matched, read, partial, unreached}`** (`iterationCoverageSchema`, optional;
+ readers ignore it if absent): distinct ids enumerated, distinct ids read (a batch, `get_transcripts`,
+ `get_transcript`, `get_post`), any capped scan, the channels never reached. Set on every ending, done or not.
+- **`/research/runs/<article>/<n>`** (`components/research/RunView.tsx`, `SpendChart.tsx`; canvas "Transparent
+ run"): the head — `<article> i<n>` as the title, `Run · replay`/`Run · live`, the question under it, then sweep ·
+ model · extractor · channels · dates · corpus · when · minutes · spend this run (and on the iteration when they
+ differ) · kept / dropped · the iteration's checks · status, and the notes; actions: the run picker (`Run 1 2 3`,
+ `?run=k`), **Replay** (`r`), **Open as a board** (`b`, the one filled action). Then ONE lit list, **Steps**:
+ scope, each turn (`t0`…, a repair's `r0`…) or a pipeline's enumerations and batches (`e1`, `b1`), findings,
+ quote checks, the end — each with its sub-line and the running spend in Meter. Beside it: three lanes (Batches,
+ Findings, Coverage), the lit step's detail (facts; the model's words; the calls; each enumeration with its ids
+ and partial / never reached; each batch with its ids and the extractor's lines on the READER surface; the
+ findings with their quotes; the checks grouped Dropped / Refused by a strict check / Kept, each quote on the
+ reader with its cite and **why**), and **Spend by step, cumulative**: a step line in Meter, an 8 px marker per
+ step, the lit step's in Signal, the endpoint labelled, three recessive gridlines; a crosshair snapping to the
+ nearest step with a tooltip (total strong, step secondary); a click on a column lights that step (the list is
+ its table view). **Live**: `GET /api/research/runs/<a>/<n>` every 2.5 s while the iteration is queued or running
+ and the tab is visible, one request at a time; the newest step is lit as it lands until the operator moves the
+ light. **Replay**: the steps lit one after another (650 ms) from the first; any key or click stops it.
+- **The turns.jsonl projection** (`lib/research/runs-view.ts`, pure, unit-tested): each response is a turn step
+ with its calls (inputs in a line; results were cut to nothing on an import), enumerations parsed where a
+ result survives, `extract_batch` calls as batches whose lines are null ("not kept"), and a **gap** step for the
+ quote checks ("kept / dropped not recorded", the iteration's own checks listed). A pipeline's `dropped` turns
+ are real checks. **Several run starts**: a "run started" note opens a run (an import's); a file without them
+ splits where a response's turn goes back to 0, unless a "repair round" note says it is the repair. Each run is
+ shown alone, its spend its own: an imported stopgap run logged its RUNNING total on each turn (the importer
+ kept it), so its step cost is the difference; the agent's own transcript logs each turn's. The iteration's
+ report is the last run's: findings and "Open as a board" are offered on the last run only.
+- **`/research/runs`**: every sweep iteration of the article store, newest first (model, status, `turns` when it
+ predates the trace, spend), each linking its run; **Agent runs** in Research's head reaches it.
+- **Open as a board** (`lib/research/runs-board.ts`, `POST /api/research/runs/<a>/<n>/board`): the case
+ `<article>-run<n>` (piece `c:<article>-run<n>`; `runBoardId` cuts the article so it stays a piece segment) is made
+ — titled with the report's title, its scope the iteration's channels and dates, its query the question — or
+ brought up to date. Its quotes are every quoted citation of the iteration's report, in the report's sections,
+ the finding as the claim line, through R2's `addQuote` (the same snapshot shape as a pin), each `by: "agent"`
+ (kept by `cleanQuote`; the slip says **by agent**); the case carries `run {article, n, at}` and its side panel
+ links **From run**. The cite's link is a moment link on the run's origin (its trace's scope, else its
+ sweep.md's links); its source is the run's corpus when offered, else the one serving that origin, else the
+ local corpus — so the board's Re-verify reads it like any pin. A second open adds what is new (`sameCite`) and
+ never touches the operator's claims, notes, sections or order. A run with no report is a 409.
+- **Run a sweep on this scope** (a board's side panel; `POST /api/research/cases/<id>/handoff {to: "sweep"}`):
+ R2's article hand-off without the seed (`planArticle(…, {seeded: false})` → `planScopeSweep` /
+ `confirmScopeSweep`): the case's query (else its title), its channels (else the quoted ones), dates and source;
+ the policy's sweep route — the API agent with the policy's extractor and cap, or the local model (no cap); a
+ route to Claude Code (a session's, not a job's) runs the API agent, and the plan says so. Local-only channels
+ are refused (a sweep makes an article). The dialog shows the corpus, the model and extractor and the cap;
+ confirmed, it answers the run's page, and the case records it (`what: "a sweep on the scope: <a> i<n>, job …"`).
+- **Hrefs** (`lib/research/runs-hrefs.ts`, pure): `runHref(article, n, {run?})`, `runsHref()`, `runApi`,
+ `runBoardApi`, `runBoardId`, `hasRunPage(kind)` (sweeps).
+
+**Not wired here, left to the owners** (their files): the Iterations tab's iteration row (`components/articles/
+IterationsTab.tsx`, P4a-2) and the Running list's report-draft row (`lib/activity.ts` `editorItem`'s `href`,
+P2b's) should link `runHref(article, n)` when `hasRunPage(kind)` — `lib/activity.ts` already has the place
+(`{article, n, task}`), and a sweep row's href becomes `runHref(place.article, place.n)`.
+
+| sha | what |
+|---|---|
+| `767f2681` | common: `trace.jsonl` (`tasks/trace.ts`), `runOnIteration`'s `trace` and `setCoverage`, both sweeps traced, `dropFailedFindings`' `items`, `iterationCoverageSchema`, `ITERATION_FILES` + `trace.jsonl`; `trace.test.ts` (8); `mcp/src/draftTasks.test.ts` asserts each sweep's trace and coverage, the dropped quote and why, and a seeded sweep's `scope.seed` (+1 test) |
+| `751b2eff` | umtool: the run page and `/research/runs`, the APIs, `runs-view.ts` (trace + turns projections), `runs-board.ts`, `runs-hrefs.ts`, the scope sweep (`planScopeSweep`/`confirmScopeSweep`, `to: "sweep"`), `by: "agent"` and `run` on a case, the board's button and From run, the run fixture, `runs.test.ts` (7) |
+| `2351d34e` | `e2e/run-trace.spec.ts` (6); **Agent runs** on Research; a Claude Code-routed scope sweep runs the API agent (plan says so); `boards.test.ts` +1 |
+| `15c4b813` | the replay assertion watches every frame; `[Unreleased]` bullets |
+| `d35e0c51` | `data-board-busy` on the board; `board.spec` waits for it before each move |
+
+**Gates.**
+
+| Gate | Result |
+|---|---|
+| repo-wide `tsc --noEmit` | clean at `767f2681` (common, mcp, editor, umtool), `751b2eff` (umtool) and `2351d34e` (repo-wide, exit 0); umtool's at every later commit |
+| common `pnpm --filter yt-dlp-transcript-common test` (`SETTINGS_FILE` at the primary's, read only) | **4104/4104** (+8: `trace.test.ts`) |
+| mcp `pnpm --filter yt-dlp-transcript-mcp test` | **364/364** (+1: the seeded sweep's trace; the sweep tests assert their traces) |
+| umtool unit (`node --test umtool/lib/*.test.mjs umtool/lib/*/*.test.mjs umtool/report-to-video/*.test.mjs`) | 834 tests, 832 pass, 2 skipped, 0 fail |
+| `pnpm --filter umtool test` | **24/24** (new: `runs.test.ts` 7 — the trace projection, live and torn lines, two trace runs, turns-only with two starts and running totals, the unmarked split, the small words, open as a board end to end with re-verify; `boards.test.ts` +1 — the scope sweep) |
+| editor unit `pnpm --filter editor test` | 297/297 |
+| `pnpm run test:scripts` (reads the capped build) | 985 tests, 983 pass, 2 skipped, 0 fail |
+| `pnpm archilyzer docs cli --check` | clean |
+| capped umtool `next build` (corpus linked, `MemoryMax=5G`, heavy slot) | exit 0; compiled 12.3 s, 44.6 s wall, 1.46 GB max RSS. The run page's and the board route's traces: 938 / 932 files, none from `transcripts/`, `export/public`, `.e2e-song` or `.env*`; the link removed |
+| capped editor `next build` (common changed) | exit 0; compiled 39.4 s, 1:13.6 wall, 2.36 GB max RSS |
+| editor e2e, the report-draft specs (`report-draft.spec.ts`, `ops-api.spec.ts`; `export/public` linked from the primary) | **17 passed, 0 failed**, 30 s |
+| full umtool e2e, run 1 (`2351d34e`) | 413 tests: 405 passed, 2 failed, 6 skipped, 8.3 min. Reds: `run-trace.spec` replay (asserted a 650 ms step with backed-off retries — now watched per frame, `15c4b813`) and `running.spec:185` (the drafts decision read empty once; green in every run since) |
+| `research` + `run-trace` + `running` specs | 21/21 |
+| full umtool e2e, run 2 (`15c4b813`) | 404 passed, 3 failed, 6 skipped, 7.8 min: `board.spec` 102/163/185 — an R2 race surfaced by the loaded machine (below), then `board`+`run-trace`+`running` 16/16 and 13/16 |
+| `board.spec` × 3 (`d35e0c51`) | 7/7, 7/7, 7/7 |
+| full umtool e2e, run 3 (`d35e0c51`) | **413 tests: 407 passed, 0 failed, 6 skipped** (the song-data skips), 7.9m; `run-trace.spec` 6/6 |
+
+**Screenshots and keys.** Job scratch `r3-shots/`: `/research/runs/piratesoftware-ai-friends/1?run=1` (the fallback on
+REAL data: the iteration's two files copied read-only into a scratch article store, run 1 of 3, `t4` lit) and the
+fixture's traced run (`runfix`, the quote checks lit; the batch lit with the chart's tooltip), 1366×768 and
+1440×900, dark and light; `dev/` holds the working shots (run 3 with the hover, the turns-only and live runs, the
+index). Against the canvas's Transparent run: the same two columns (the 330 px step list with `t`, label and
+sub-line, and the running spend in Meter; the detail pane), the three lanes (Batches, Findings, Coverage), the
+ids as mono chips, the spend chart as a Meter step line with the lit step's dot in Signal and the endpoint
+labelled, the gap step in italics. The real run's numbers match the canvas's (t0 $0.04 … t7 $0.64). Differences:
+the title is `<article> i<n>` with the question under it (the head's h1 truncates a long line; the question
+wraps), the run picker and the notes in the head, the extractor's lines on the reader surface, the checks
+grouped in the detail, Replay and Open as a board in the head, the key legend at the foot. **Keyboard only**
+(reduced motion): the rail's 11 stops, the trail's two links, Replay, Open as a board (each the 2 px Signal
+ring), the step list ONE stop (the lit line, dashed 1 px), then the footer's link; `j`/`k`, `Home`/`End` move the
+light and the detail follows; `r` replays to the end and stops; `b` opens the board.
+
+**Found and left.**
+- **R2's board refused a move pressed while the previous one was answering** (`busy`): the case file is written
+ before the answer lands, so a spec — or a fast operator — pressing `alt+j` twice saw the second dropped. On a
+ loaded machine `board.spec` went red 2 runs in 3. The board now says `data-board-busy` while it waits and the
+ spec waits for it; queueing the key instead of dropping it is left for R2's owner to judge.
+- **An imported stopgap run's spend per turn is a running total** (the importer kept the stopgap's own field); the
+ projection takes differences when the run has a stopgap note. The iteration's `usage` for such an import is
+ only its last attempt's (`$0.33` on piratesoftware-ai-friends while its first run alone shows `$1.83`); the head
+ says both when they differ.
+- **The trace is the editor's to write**: runs already in the store have none, and nothing back-fills one. A
+ run started before the editor restart writes none either.
+- **Open as a board takes the iteration's report** (the last run's), so it is offered on the last run only. A cite's
+ link needs the run's origin: an old run's comes from its sweep.md's links; a run with neither gets no link
+ (the board shows the cite without one).
+- **The live page polls the whole view** every 2.5 s (a trace of a few hundred lines is a few tens of KB); a
+ cursor (`?from=<line>`) is the next step if traces grow large.
+- **A scope sweep from a board with no channels** is refused with what to do; a case whose scope names a hub's
+ `<site>:<slug>` keys sweeps the slugs (R2's rule).
+- **Not wired** (above): the Iterations tab and the Running list link the run page through `runHref` once their
+ owners take it.