commit a88342b80ff7b1fbd236eefed5d17450c07602aa
parent 78c9bc13b6eaec20077084827a875a84316ccd31
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 14 Oct 2026 13:11:56 -0400
plans: umtool redesign — R4, as shipped (refresh: fetch, what changed, update; the suggestion card)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
1 file changed, 182 insertions(+), 1 deletion(-)
diff --git a/plans/umtool-redesign.md b/plans/umtool-redesign.md
@@ -439,7 +439,7 @@ edition reviewed with the operator before the schedule is left on.
| P4a-3 song pieces | `ux/p4a3` → `main` `3d69d6c6` | LIVE 2026-10-14 (umtool oN73I6F3…) |
| R3 transparent runs | `ux/r3` → `main` `6362cf40` | LIVE 2026-10-14 (editor HqcZW4aJ…, umtool 85Ultdj2…) |
| P4b benches + Media | `ux/p4b` → `main` `e66dd702` | LIVE 2026-10-14 (umtool ktVxkFBl…) |
-| R4 refresh | `ux/r4` | in progress |
+| R4 refresh | `ux/r4` | shipped on the branch, not merged |
| R5 recurring reports | — | after R4 |
| R6 triage first | — | after R5 |
| Co-host pilot | — | after R6 (operator-approved) |
@@ -2359,3 +2359,184 @@ narration benches and clip benches c01/c03 200 with the bench head; `/drafts` 30
`drafts-unreviewed` rows are new), notes' hrefs end `note=<id>`. P6 audit: "Draft with is off here" reads clipped — name
the action whole.
+### R4, as shipped
+
+**What.** Refresh: a report iteration that is "fetch what is new, check it, update" — cheap and deterministic until
+something changed. ONE editor job (`report-draft {"task": "refresh"}`) over a new `refresh` iteration whose parent is
+the iteration refreshed; umtool plans it, confirms it, shows what it found, and suggests it.
+
+- **The engine** (`common/lib/report/draft/refresh/`; the task beside the others, `runTask`'s `refresh`):
+ - `types.ts` — `refresh.json` (`archilyzer-refresh` v1: the basis it searched again with, each fetch step, the build,
+ the corpus, the delta, the update, warnings, the one-line summary, `status` running · no-change · updated ·
+ held-by-cap · failed · cancelled), `RefreshPlan`, `RefreshOutcome` (what iteration.json keeps as `refresh` and the
+ log's marker carries), `deltaLine` ("1 new recording matches · 1 quote changed", "Nothing new since <date>").
+ - `basis.ts` `refreshBasis(article, n)` — what an iteration was built from: its own `refresh.json` (a refresh of a
+ refresh: its queries and the match set it saw), else its trace's last run (`scope`, each `enumerate` with its ids
+ and, new, `counts`), else its `turns.jsonl` (the agent's `enumerate_matches` calls with their arguments and, when
+ an import kept them, their rows; the pipeline's terms), walking up the lineage for a revision; else its question
+ as the one query (said). The report's quoted citations, and every cited recording counted as known.
+ `knownComplete` false (a run whose answers were not kept, or the question) makes "new" mean "uploaded on or after
+ the iteration's day".
+ - `delta.ts` — `deltaCandidates({queries, scope}, corpus | enumerateFn, {known?, since?})`, the candidates on their
+ own (R6's tier 0 and umtool's daily check call it): each distinct query once; new against `known` (or by upload
+ date from `since`); changed = matched before and now with different matching lines; unmatched (a complete scan
+ only). `recheckQuotes(cited, {recordOf, postTextOf})` — R2's word check at each cite on every track the record has
+ (ok, moved, drifted with the words there now, missing), the platform state (deleted, private), `en` vs `en-orig`.
+ `computeDelta` both; `deleted` counts sources (`channel/id`), `drifted` citations.
+ - `fetch.ts` `fetchAndBuild(scope, hooks)` — stage 1 on its own: per video channel `sync`, then `refresh-report` and
+ `transcribe-bucket` for ONLY the recordings that landed (the channel report's "downloaded, not transcribed" bucket
+ after the sync against the one before — never a channel's backlog); per posts channel `fetch-posts`; a platform held
+ or cooling down skipped with the editor's sentence; channels side by side (the platform queues pace them); then
+ `publish {"verb": "build", "siteId", "force": false}` for the site whose build holds the channels (the parent's build
+ first) — through the publish lock, never a deploy — every job waited for (polled; a step past `waitMs`, default 6 h,
+ is left running and said).
+ - `task.ts` `refresh` — `runOnIteration` (kind `refresh`, traced as task `refresh`): stage 1; the corpus opened after
+ the build; stage 2 (`delta` in the trace) — nothing changed ends `no-change`, $0; stage 3 within the caps
+ (`capRefusal(estimate)`: the job's cap, the daily cap, and "about $X more would pass the daily cap"; a refusal ends
+ `held-by-cap` with the estimate) — the sweep restricted to the new and changed recordings over the parent's
+ question and recorded queries (the API agent with its extractor, or the local pipeline; 70% of the cap), its
+ findings then handed to `reviseReportBody` as feedback with the drifted quotes ("drop it; add it again with the
+ words there now if the claim stands"), the sources gone, and those deleted from their platform; the revision's
+ report is the iteration's. A sweep that finds nothing and no drift ends `no-change` (with what it read). The
+ estimate is the parent's spend per recording read (else $0.08) × recordings + $0.30. The iteration ends `done`
+ whatever the refresh's status; only a failed revision or a cancel fails it. `sweepAgentBody`, `sweepPipelineBody`
+ and `reviseReportBody` are exported for it (additive).
+ - The sweep's **`ids` restriction** (`tasks/restrict.ts`; a general sweep option — R6's escalation path):
+ `report-draft {"task": "sweep", …, "ids"}` keeps the ids in the iteration's scope; the agent's `enumerate_matches`
+ answers only their rows (and says so), `get_transcripts`/`extract_batch` drop other ids (none left refuses),
+ `get_transcript`/`get_post`/`get_thread` refuse another id, `search_transcripts` is not offered, the preamble says
+ so; the pipeline's worklist is those ids, each read even when its terms did not find it.
+ - `lib/report/quoteWords.ts` — R2's check moved to common (`wordsOf`, `holdsWords`, `windowAround`,
+ `checkWordsInWindow`, `enOrigDifference`); umtool's `verifyQuote` calls it, its API and answers unchanged.
+ - `iterations.ts`: kind `refresh` (a parent, no feedback), `refresh.json` an iteration file (JSON), scope `ids`.
+ `trace.ts`: `fetch`, `build`, `delta` events; `enumerate.counts`; `enumerateOf` answers each row
+ (`rows`: channel, date, matches, title) and `countsOf`. Both sweeps record `counts`.
+- **The editor's side** (`common/controller/reportRefresh.ts`): `refreshTarget` (the iteration named, else
+ current.json's report, else the newest done one with a report), `refreshModel` (the sweep route's model; a sweep
+ routed to Claude Code runs the API model here, said), `planRefresh` (the dry run: each channel's actions or why
+ skipped, the site, the corpus, model, cap, the day's spend, the estimate's rate), `enqueueRefresh` (the iteration,
+ then one `report-draft` job on **`draft:refresh`** — a new queue, so a refresh waiting on fetches never holds
+ `draft:api`; no daily-cap refusal at the ask, stage 3 asks), the job's hooks over the editor (its jobs, channel
+ configs, `heldPlatformRefusal`/`platformCooldownRemainingMs`, channel snapshots, the builds, a disk reader of a cited
+ recording's tracks and platform state — `diskRecordOf`, not publish's `readCitedRecord`: a controller may not import
+ publish/), the usage rows (task `refresh`) and the marker. `reportDraft.ts`: task `refresh` (no route of its own),
+ keys `ids`, `fetch`, `dryRun`, a refresh refused a question or a scope.
+- **R5's seam** (named for the coordinator): `fetchScope(scope, deps, {prefer?, signal?, log?, build?})` in
+ `controller/reportRefresh.ts` — stage 1 for any `{channels, from?, to?}`, awaited, answering `{fetch, build,
+ warnings}` (each step done, skipped with why, refused, failed or still running); and the refresh itself:
+ `enqueueReportDraft({task: "refresh", article, iteration?}, deps)` (or `enqueueRefresh`) — its job's `done` ends
+ with the iteration's `refresh.json` (`readRefreshFile(article, n, paths)`) whose `status` is `no-change`, `updated` or
+ `held-by-cap`. Both need `deps.refreshEditor`, the editor's in-process door
+ (`editor/app/api/ops/_researchEditor.ts` `refreshEditor`).
+- **The ops route** (`editor/app/api/ops/report-draft`): `task: "refresh"`; `dryRun: true` answers `{ok, plan}`. The
+ in-process door (`refreshEditor`: sync, fetch-posts, refresh-report, transcribe-bucket, publish — build only; a
+ deploy is refused) is `_researchEditor.ts`'s factored `inProcessEditor`. `pnpm ops report-draft --json
+ '{"task":"refresh","article":"x"}' --wait` prints the marker. COMMANDS.md regenerated.
+- **umtool**:
+ - `lib/articles/refresh.ts` — `planArticleRefresh`, `startArticleRefresh` (through `enqueueDraft`, `fetch` now one of
+ its keys), `readRefreshes` (each refresh iteration with what its refresh.json kept). `GET/POST
+ /api/articles/refresh` (`{article, iteration?, fetch?, confirm?}` → plan, or `{jobId, iteration, href}`).
+ - `components/articles/RefreshDialog.tsx` — the plan then **Refresh**: Refreshes (i<n>, kind, made, the question),
+ Searched again (the queries, the match set then, the quotes read again), Fetch (each channel's actions, or
+ "skipped — <why>"), Build (the site, "locally, if anything changed — never deployed"), Update (model, extractor,
+ "spends up to $X", the rate, today's spend); refusals and warnings; one dialog per page (`RefreshHost`), opened by
+ the ⋯ menu's **Refresh…** (`RefreshMenuItem`), the Iterations tab's **Refresh…** (`RefreshButton`) or `?refresh=1`
+ (the Next card's and the Inbox card's action); after **Refresh** "Refresh i<n> is running (job …)" and the page
+ reads again.
+ - `components/articles/RefreshSummary.tsx` (the Overview, under Iterations): "Refresh · i<n>" with its state
+ (running, no change, updated, held by the cap, failed), the line, the new recordings, the quotes that changed and
+ what they say now, the sources gone, the fetches and the build, the spend or the estimate; "Review in Iterations →"
+ when it has a report; `RefreshWatch` reads the page again every 4 s while it runs. The Iterations tab: the
+ refresh's line on its card (`IterationRow.refresh`, additive), and **Refresh…** in the tab's head (P4b had freed
+ the tab).
+ - `lib/inbox/refresh.ts` (add-only; two kinds): **refresh-available** (Review) — the daily check per active store
+ article with a current report (parked, done and muted skipped): the newest done refresh of it, else the report
+ itself, as the basis, `deltaCandidates` over the build it read when it is on this machine (the MCP's
+ `SourceRegistry`), else Research's local corpus — the MCP engine's `enumerate`, no fetch, no model, at most 12
+ queries; kept a UTC day per article and iteration in `REPORTS_ROOT/.umtool/refresh-check.json` (one writer, temp +
+ rename). The Inbox only reads it; a stale one is checked in the background, one at a time, in the app's server only
+ (`NEXT_RUNTIME`; a CLI never waits on it), off with `UMTOOL_REFRESH_CHECK=0` (the e2e server). The card goes when a
+ refresh made after the check exists or one is running. **refresh-held** (Your call) — the newest refresh of an
+ article `held-by-cap`, until a later iteration runs. Both act **Refresh** → `?refresh=1`. `groups.mjs`/`what.mjs`
+ gain the two kinds only. `POST /api/articles/refresh/check {article?, force?}` runs it now.
+ - `umtool refresh <article> [--iteration N] [--no-fetch] [--yes] [--json]` and `umtool refresh --check [<article>]
+ [--force]` (`bin/refresh.ts`, through tsx like `inbox`).
+ - The e2e stub answers `report-draft` refresh (a plan; an iteration running then done with its refresh.json —
+ updated, or no-change for an id ending `-quiet`).
+
+| sha | what |
+|---|---|
+| `f1982eef` | common: the refresh (`draft/refresh/`: types, basis, delta, task), the sweep's `ids` restriction (`tasks/restrict.ts`), `quoteWords.ts` (R2's check, umtool's `verifyQuote` on it), iteration kind `refresh` + `refresh.json` + scope `ids`, trace `fetch`/`build`/`delta` and `enumerate.counts`, `controller/reportRefresh.ts`, `reportDraft`'s task and keys, `draft:refresh`; the editor route's `refresh`/`dryRun` and the in-process refresh door; `refresh.test.ts` (10), `mcp/src/refreshTask.test.ts` (1) |
+| `3f33efe6` | editor: `_reportRefresh.test.ts` (7), `fetch.ts` `fetchAndBuild` and R5's `fetchScope` seam, `fetchHooksOf`; the ops help and COMMANDS.md |
+| `5f444574` | editor e2e: `report-draft.spec` +3 (the plan then no change, an update with the restricted sweep, the editor's own door: a real sync and channel report) |
+| `92fab5e7` | umtool: `lib/articles/refresh.ts`, `/api/articles/refresh` (+ `/check`), `RefreshDialog`/`RefreshSummary`/`RefreshWatch`, the ⋯ item, the Overview's summary, `lib/inbox/refresh.ts` (the daily check, refresh-available, refresh-held), `bin/refresh.ts`, the stub's refresh, `refresh-fixture.mjs`, `refresh.spec` (5), `lib/inbox/refresh.test.ts` (3), `UMTOOL_REFRESH_CHECK=0` on the e2e server |
+| `57c7eb7a` | merge `main` `d49737da` (P4a-3, P4b) — no conflict |
+| `e78e2ae8` | the Iterations tab's **Refresh…** and a refresh's line on its card (`IterationRow.refresh`); `diskRecordOf` (architecture test: a controller may not import publish/) |
+| `fed5716a` | the plan opens on a client navigation to `?refresh=1` (the Next card on its own page); `[Unreleased]` bullets |
+| `bed1e9d2` | the card reads "new recordings match"; a skipped step names its action |
+
+**Gates.**
+
+| Gate | Result |
+|---|---|
+| repo-wide `tsc --noEmit` | clean at `f1982eef`, `3f33efe6`, `92fab5e7`, `e78e2ae8` (repo-wide); umtool's at `fed5716a`, `bed1e9d2` |
+| common `pnpm --filter yt-dlp-transcript-common test` (`SETTINGS_FILE` at the primary's, read only) | **4114/4114** (+10: `refresh/refresh.test.ts`; `trace.test.ts`'s `enumerateOf` assertion has `rows`). A first run was 4113: `architecture.test.ts` refused `controller/reportRefresh.ts -> publish/composeReports` (fixed in `e78e2ae8`: `diskRecordOf`) |
+| mcp `pnpm --filter yt-dlp-transcript-mcp test` | **365/365** (+1: `refreshTask.test.ts`, the update end to end — the restricted sweep's enumeration answered the new row only, the revision added its finding) |
+| umtool unit (`node --test umtool/lib/*.test.mjs umtool/lib/*/*.test.mjs umtool/report-to-video/*.test.mjs`) | 854 tests, 852 pass, 2 skipped, 0 fail |
+| `pnpm --filter umtool test` (now `lib/research/*.test.ts lib/inbox/*.test.ts`) | **27/27** (+3: `lib/inbox/refresh.test.ts` — the daily check over the refresh fixture and Research's local corpus, the two kinds, parked skipped, the plan and the start against a stand-in editor) |
+| editor unit `pnpm --filter editor test` | **304/304** (+7: `_reportRefresh.test.ts` — the body, the plan, refusals, the job on `draft:refresh` with no change and $0, held by the daily cap with no model, R5's `fetchScope`, the door never deploys) |
+| `pnpm run test:scripts` (reads the capped build) | 1005 tests, 1003 pass, 2 skipped, 0 fail |
+| `pnpm archilyzer docs cli --check` | clean (COMMANDS.md regenerated for the refresh and `ids`) |
+| capped umtool `next build` (corpus linked, `MemoryMax=5G`, heavy slot) | exit 0; compiled 13.9 s, 41 s wall, 1.53 GB max RSS; the link removed |
+| capped editor `next build` (common changed) | exit 0; compiled 41 s, 1:34 wall, 2.47 GB max RSS |
+| editor e2e `report-draft.spec` + `ops-api.spec` (`export/public` linked from the primary) | **20 passed, 0 failed** (57 s at `5f444574`; again at the tip, 35 s): the three refresh tests among them — the plan then no change, an update over the fake Anthropic, the editor's own door (a real sync of `slow-b` and its channel report as jobs) |
+| full umtool e2e, run 1 (`e78e2ae8`) | 458 tests: 451 passed, 1 failed, 6 skipped, 10.6 min. Red: `refresh.spec` — the Next card's action on its own page kept the dialog's host mounted, so `?refresh=1` did not open it; fixed in `fed5716a` |
+| `refresh` + `inbox` + `piece` + `article-iterations` (`fed5716a`) | 44/45: `inbox.spec`'s rail count 35 against the page's 34 (below); `article-iterations` + `inbox` + `refresh` again 22/22 |
+| `refresh` + `inbox` + `piece` + `inbox-engine` + `running` (`bed1e9d2`) | 49/49 |
+| full umtool e2e, run 2 (`bed1e9d2`) | 458 tests: 449 passed, 3 failed, 6 skipped, 9.4 min. Reds: `board.spec` 102 (a claim typed under load landed in the title) and the two after it that read that state; R2's spec, no file of it touched here |
+| `board.spec` × 3 (`bed1e9d2`) | 7/7, 7/7, 7/7 |
+
+**Screenshots** (job scratch `r4-shots/`, 1366×768, dark and light, on the e2e fixture with the refresh fixture written
+in and the stub editor): `suggestion-inbox` (the Inbox's Review card "1 new recording mentions this since 2026-10-14:
+Harbor Radio 52: storm season", action Refresh), `suggestion-next-card` (the article's Overview, the Next card the same
+call), `refresh-plan` (the plan dialog: the iteration and its query, harbor-radio's three actions, otherchan skipped as
+held, the build of priv, the cap and today's spend), `refreshed-summary` (the Overview after the run: "1 new recording
+matches · 1 quote changed", the new recording, the quote and what it says now, the fetches and the build, $0.31 spent),
+`refreshed-iterations` (the refresh's card with its line, **Refresh…** in the tab's head). No canvas screen exists for
+Refresh; the dialog is HandoffDialog's (the R2 plan-then-confirm) and the summary the Overview's own Card.
+**Keyboard only** (production build, reduced motion): Tab reaches **More**, Enter opens it, Tab reaches **Refresh…**
+(the 2 px Signal ring), Enter opens the plan with the focus inside the dialog, Escape closes it.
+
+**Found and left.**
+- **A refresh waits on the editor's own queues.** A sync on a busy platform queue, a transcription behind a long
+ backlog, a site build behind others: the job waits (up to 6 h a step, then reads what is there and says so). It holds
+ only `draft:refresh`, never `draft:api` or `draft:local`. The build is never forced, so a site that nothing changed
+ is not rebuilt — but one that did is a whole site build (Jeralyzer's is long), by design: a sweep reads only a
+ composed build.
+- **`transcribe-bucket` only for what landed** needs the channel's report from before the sync; a channel with no
+ report yet transcribes nothing (said: "what landed is not known"). Its auto-transcribe lane still does what its policy
+ says.
+- **"Changed" recordings need the counts** a sweep records from this release on; a parent from before has none (only new
+ ones are found). A parent whose answers were never kept (an import with its results cut, or a run with no
+ enumeration — the question searched as one phrase) finds new recordings only by upload date, so an old video
+ transcribed late is missed; the plan says which.
+- **"Deleted" counts sources gone from the archive AND those deleted or private on their platform** (the archive keeps
+ them, and their quotes still verify); the update keeps their findings and says so in the summary.
+- **The update runs on the sweep route's model**, not the parent's; a sweep routed to Claude Code runs the API model
+ (said in the plan). The estimate is the parent's own spend per recording read — rough by design.
+- **refresh-held's action reopens the plan**: there is no "run just the update". A second refresh fetches and searches
+ again (cheap when nothing moved: the build is skipped as fresh).
+- **The daily check reads the build the iteration read when it is on this machine, else Research's local corpus**
+ (`export/public`: whichever site was composed last). An article whose build is gone and whose channels the local
+ corpus lacks checks to 0 new, silently. It runs in umtool's server, one article at a time, at most 12 queries each
+ (a large build is ~10 s a query).
+- **The run page (R3) does not list refresh iterations** (`hasRunPage` is the sweeps'); a refresh's trace is there
+ (fetch, build, delta, then the restricted sweep's own events) for R5/R6 or a later run-page change to show.
+- **The editor e2e exercises the door with a real sync and channel report** (the fake yt-dlp); `transcribe-bucket` for
+ what landed and the held-platform skip are unit-tested (common `refresh.test.ts`). The umtool e2e's editor is the
+ stub (a canned refresh).
+- **`inbox.spec`'s first test went red once in a targeted run** (`article-iterations` + `inbox` + `piece` +
+ `refresh`): the rail's count 35 against the page's 34 — the rail's 10 s memo caught the count mid-change after
+ `article-iterations`' stub job finished. Green in the full runs and in a rerun of the same three specs (22/22); the
+ refresh kinds add no card there (no check file; `UMTOOL_REFRESH_CHECK=0`). Not this lane's to change.
+- **Not done:** a refresh's own run page; "make current automatically" (R5's living report decides that).