commit 2147a99ac4bce7651eb2898a45cb7415c051a7d7
parent 429b4a3d23bcf2354b9e6868e7d491b4167f68e5
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 14 Oct 2026 03:15:25 -0400
plans: umtool redesign — R1, as shipped (research over the MCP's engine, the reading log, the inventory; gates, live parity); CHANGELOG
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
2 files changed, 123 insertions(+), 1 deletion(-)
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -1,6 +1,10 @@
# Changelog
## [Unreleased]
+- **umtool has a Research page, `/research`.** Ask the corpus (a phrase, a `/regex/`, or `a near:8 b`) in the local corpus, a published site or the hub; the scope chips (channels, dates, state on the platform, videos or streams, posts) say what the scope **holds** before anything runs: channels, videos, the years, and transcripts vs captions once a search has counted them. A search reads the whole scope once, with the MCP's own `enumerate_matches` engine (the same total and the same recordings), and says **full coverage** or **Partial — not reached:** the channels a cap left unread, with the mirrors it folded. Results are lit lines grouped by recording, the match marked, with year, channel, text, state and reading facets that narrow what is shown. The reader on the right shows the transcript around the lit hit with its cue lit, **−**/**+** to narrow or widen it, **Copy citation** in the house format, **Play from** a clip or source this machine holds, and **Fetch clip** through the editor's fetch-window route, as `fetch_clip` asks. Keys: `j`/`k` lines, `r` read, `s` skip, `u` unread, `c` copy citation, `/` the ask bar. Needs a restart of umtool.
+- **Research keeps a reading log.** Every hit is read, skipped or unread, and the header says **read 37 of 97**. The log is umtool's, under `REPORTS_ROOT/.umtool/research/sessions/`, one per query and scope, never in the corpus.
+- **umtool's archive inventory, `/research/archive`.** Channels × years: the videos the editor holds (its `GET /api/ops/coverage`, the MCP's `channel_coverage`) or the videos the source publishes, on the Meter ramp, gaps over 60 days marked, nothing held as —. Hover or focus a cell for what it holds, published, deleted or unlisted, and transcripts vs captions; the arrow keys walk the grid; **Table** lists the same numbers. When umtool has no `WORKER_TOKEN` or the editor does not answer, the page says which, and for the local corpus reads the held counts on disk instead.
+- **The MCP's enumerate is shared as data.** `enumerate_matches` renders `mcp/src/enumerate.ts`, which umtool calls through the new `yt-dlp-transcript-mcp/research` export; `fetch_clip`'s cite-to-directory mapping is `clipTarget.ts`, and a caller can name itself to the editor (`requestedBy`). Nothing an agent sees changed.
- **umtool drafts each section of a report video with a model you pick.** A video project made from an article's iteration has a **draft** section: for the cut, the on-screen titles, the teaser, the flips, the threads, the narration and the YouTube text, **Draft with** and a model (the generation policy's models, the task's route chosen first), **force** (re-drafts only what a model drafted; what you wrote or edited is never replaced), and for a per-entry task the entries to draft. The job's progress shows while it runs; when it ends the page shows what it wrote, skipped and had refused by a check, the **drafted by** badge with **Approve** and **Reject**, and any draft kept aside with **Use this**. A project not made from an iteration says so and offers none. The article's Iterations tab gains the same drafts beside **Narrate**. Needs a restart of umtool.
- **Draft everything.** One button on the Iterations tab (or `umtool chain <article> <n> --draft-all [--model M]`) runs the chain with every media draft in it, on the model you choose: the cut, on-screen, teaser, flips, threads and narration after the manifest, then the voices, a fast build and the podcast, then the YouTube text, whose chapters are re-muxed so `out/youtube.txt` is written. A draft the editor refuses or that fails is marked failed and the chain carries on; one with nothing to draft, or flips and threads with no on-screen deck (or with the other panel on), is skipped. It does not attach the video to the article: review the drafts first. Started again, it resumes after the last draft that ran. Needs a restart of umtool.
- **A site's Delete shows its plan before anything goes.** On `/sites`, **Delete** lists what would be removed (the site, its publish state and last bundle, its staging), how much, what is kept and what refuses; **Confirm delete** removes it. A site with a deploy target, a recorded deploy or reports of its own is refused unless you tick the box and press **Delete with force**; a site whose directory is a link, or a publish stage running, is refused outright. The delete is `pnpm ops delete-site`'s, so it now removes the build state too.
diff --git a/plans/umtool-redesign.md b/plans/umtool-redesign.md
@@ -348,7 +348,7 @@ P0 design ─► P1 foundation ─┬─► P3 inbox/work/tools/URLs ─┬─
| P0 design | — (`~/reports/umtool-redesign/canvas.html`, version 2) | signed off 2026-10-14 |
| P2a engine | `ux/p2a` → `main` `fe1cb2d3` | LIVE 2026-10-14 (umtool BUILD_ID 4aRwqu6sh…) |
| P1 foundation | `ux/p1` → `main` `37354f70` | LIVE 2026-10-14 (umtool BUILD_ID LQxTh16Pe…) |
-| R1 research | `ux/r1` | in progress |
+| R1 research | `ux/r1` | shipped on the branch, gates green; awaiting review and merge |
| P3 inbox/work/tools/URLs | `ux/p3` | in progress |
| P2b, P4a, P5, R3, P4b, P6 | — | wait for r28 on `main` |
@@ -544,3 +544,121 @@ capped) and restarted (`~/reports/umtool-redesign/scripts/p1-umtool.sh`). Live s
`/browse/decisions`, `/articles`, `/sites`, `/mix` 200; no cookie leaves `<html>` unstamped, `umtool-theme=light`
serves `data-theme="light"`; the rail renders; the decisions API unchanged (825 rows). Ruling on the lane's question:
the Signal-as-link uses in r28's files are swept in P4a, after r28 lands, not now.
+
+### R1, as shipped
+
+**What.** Research, first-class: `/research` (ask, scope, results, facets, reader, reading log) and
+`/research/archive` (the inventory), over the MCP's own engine, read-only on the corpus.
+
+- **The engine, shared as data** (`mcp/`, additive):
+ - `src/enumerate.ts`: `enumerate(source, args, opts)` is `enumerate_matches`' scan, and the tool now renders its
+ result. `parseSearchArgs` and `strArray` moved there from `server.ts` unchanged. Options a structured caller adds:
+ `includeSnippets` and `snippetsPerVideo` (which recordings match does not change), and `onRecord`.
+ - `searchTranscripts` gains `onRecord`: every record the video pass reads, before any filter or match.
+ - `src/clipTarget.ts`: `fetch_clip`'s cite-to-directory mapping (record channel, `extractVideoId` of its URL for
+ Rumble), factored out of `handleFetchClip`. `fetchClip` takes `requestedBy` (default `mcp`).
+ - `yt-dlp-transcript-mcp/research` (`src/research.ts`): the export umtool imports. No MCP SDK in it.
+- **`umtool/lib/research/`** (server unless noted):
+ - `sources.ts`: the picker. Local = `TRANSCRIPT_LOCAL_DIR`, else `EXPORT_PUBLIC_DIR`, else `<repo>/export/public`
+ (the MCP's default); every `sites/*/site.json` with a `siteUrl` as `remote:`; the hub from
+ `TRANSCRIPT_HUB_URL` or `settings.json` `homepageUrl`. Only an offered handle opens. Sources are the MCP's
+ `SourceRegistry`, cached on `globalThis`; a local one reopens when its `corpus.json` changes.
+ - `corpus.ts`: `scopeOf` (channels, videos and the upload span from the summaries index, filters applied by the
+ engine's own `passesFilters`), `runSearch` (one `enumerate`, snippets on, never paged; hits with timecodes,
+ marks, track, state, duration, mirrors; facets; the session's log; memo 10 min × 8), `windowOf` (cues ±span
+ around the cite, the nearest cue lit, the citation, local media).
+ - **The track census.** Shard records carry `transcriptFormat` (`vtt` = captions, `*-json` = our transcription,
+ absent = unknown). Nothing published counts it per scope, so a search counts it through `onRecord`, per
+ channel, only when it read the channel whole (records seen = the manifest's `slugToPage`). The scope line
+ says "counted by the first full search" until then, and "N of M channels counted" when partial.
+ - `coverage.ts`: published (summaries, by upload year and state) and held (the editor's
+ `GET /api/ops/coverage?slug=&gapDays=60`, as `channel_coverage` asks it). No `WORKER_TOKEN`, an unreachable
+ editor, a 503 (its ops surface off), a 401 or a route it does not have each say which; for the local corpus the
+ held counts are then `common/controller/channelCoverage.ts` on `CHANNELS_DIR`, read only. A 404
+ `Channel "x" not found` is that channel's answer.
+ - `fetch.ts`: Fetch clip = `validateFetchClipArgs` → `resolveClipTarget` → `fetchClip(…, {requestedBy:
+ "umtool"})`, `wait_seconds: 0`, polled by `{job}`. `media.ts`: what plays from this machine (clip windows,
+ `source-media.*`, `audio.*` under the editor's directory id), served by name from the server's own scan, with ranges.
+ - Pure (browser-safe, `node --test`): `query.mjs` (phrase, `/regex/`, `a near:N b` → a regex within one caption
+ line; `markRanges` mirrors `buildMatcher`: substring or regex plus the fired aliases), `facets.mjs` (`trackOf`,
+ facets with zero years kept, the house citation: `"quote" [title @ m:ss](url)`, `[post by a, d](url)`),
+ `rules.mjs` (`candace-owens`, `realcandaceo` local-only, marked on every hit and chip), `log.mjs` (the reading
+ log), `session.mjs` (the session key, node:crypto). `hrefs.ts`: the URL builders (lib/hrefs.ts is P3's).
+- **Routes** `app/api/research/{sources,scope,search,window,coverage,log,media,fetch}`: JSON, `no-store`, errors in
+ words (400 bad input, 404 nothing there, 502 a source that cannot be read).
+- **The reading log**: `REPORTS_ROOT/.umtool/research/sessions/<16 hex>.json`, keyed by query + scope until R2's
+ cases; `{format: "umtool-research-log", session, query, scope, updatedAt, marks}`; the lifecycle store's
+ discipline (serialised, temp + rename, an unreadable file never overwritten, 409).
+- **`/research`** (`components/research/`): the ask bar (`/` focuses it; the hint says phrase, regex or near), scope
+ chips as native `<details>` (source, channels, dates, platform state, videos/streams, + Posts) and the **holds**
+ line before anything runs; the honest header (**N recordings · full coverage** or **Partial — not reached:**, lines,
+ pages, mirrors folded, aliases, "showing n of N", **read x of N**); results as ONE global LitList grouped by
+ recording (timecode, the match marked, read state; the CiteThread on the lit line only); the facets column (year
+ histogram with zeros, channel, text, state, reading; each narrows what is drawn, never re-runs); the ReaderPane
+ (the window with its cue lit and centred, −/+ span, **Copy citation** the one go, **Play from**, **Fetch clip**,
+ the citation as fine print). Keys `j`/`k`, `r` read, `s` skip (both move to the next recording), `u` unread, `c`
+ copy, `/` ask. The query and scope are in the URL (`replaceState`); a `?q=` link runs on arrival. 200 recordings
+ are drawn at a time ("Show 200 more").
+- **`/research/archive`**: channels × years, numbered cells on `--m1..m5` with their inks, the canvas's bins
+ (50/200/600/1,200), the doubt line under a gap year (over 60 days), — for none; Videos held / Videos published;
+ hover or focus for the tooltip (held, published, missing states, transcripts vs captions); arrow keys walk it; Table.
+- `components/ui/cite-thread.tsx` (`ReaderThread`): the 0:00 and end labels give way when the cite's label would
+ sit on them (seen on a cite at 98% of a recording).
+- e2e: `e2e/fixtures/research-fixture.mjs` writes `research-public/` (4 channels, 12 recordings 2019–2026,
+ captions and transcriptions, one deleted, one unlisted, a Rumble mirror cluster, a local-only slug) and two held
+ channels in `CHANNELS_DIR`; `playwright.config.ts` sets `TRANSCRIPT_LOCAL_DIR` to it; `research-enumerate.ts`
+ runs `enumerate_matches` through `createCorpusTools` for the spec.
+
+| Commit | What |
+|---|---|
+| `90d78927` | mcp: `enumerate.ts` (the scan as data, the tool renders it), `clipTarget.ts`, `requestedBy`, `onRecord`, the `./research` export; umtool depends on the mcp package |
+| `915b8e60` | merge `ux/integration` (release 28 on `main`) |
+| `3616a180` | `lib/research` (sources, corpus, coverage, fetch, media, log, query, facets, rules, hrefs, types), the eight routes, the research fixture, `parity.test.ts` |
+| `33ed3d22` | `/research`, `/research/archive`, `e2e/research.spec.ts`, the fixture wired into make-fixture and the config |
+| `210c1548` | the session key moves to `session.mjs`: `facets.mjs` stays browser-safe |
+| `aad7e2d9` | the reader centres the cited cue; ReaderThread labels give way; sites by `siteTitle`; copy only the lit hit's citation |
+
+**Gates.**
+
+| Gate | Result |
+|---|---|
+| repo-wide `tsc --noEmit` | clean (after the merge and at the tip) |
+| `pnpm --filter umtool typecheck` | clean |
+| umtool unit, `node --test umtool/lib/*.test.mjs umtool/lib/*/*.test.mjs umtool/report-to-video/*.test.mjs` | 783 tests, 781 pass, 2 skipped, 0 fail (13 new: query 4, facets 6, log 3) |
+| `pnpm --filter umtool test` (new: `tsx --test lib/research/*.test.ts`) | 9/9: parity with `enumerate_matches` through `createCorpusTools` on 5 asks (phrase, regex, one channel, a date window, deleted only), the search's facets, the scope preview and census, the window and citation, the inventory's disk fallback |
+| `pnpm run test:scripts` (now with `umtool/lib/research/*.test.mjs`; reads the capped build's traces) | 934 tests, 932 pass, 2 skipped, 0 fail |
+| mcp `pnpm --filter yt-dlp-transcript-mcp test` | 363/363 after the merge (11 new in `enumerate.test.ts`) |
+| editor unit `pnpm --filter editor test` (imports `createCorpusTools`) | 295/295 |
+| capped umtool `next build` (corpus linked, `MemoryMax=5G`, through the heavy slot) | exit 0; compiled 14.8 s, 45 s wall, 1.31 GB max RSS. The ten research routes' traces: 821–842 files each, none from `transcripts/`, `export/public`, `.e2e-song`, `.next-e2e` or `.env*` |
+| full umtool e2e (`pnpm --filter umtool run e2e`, detached, queued) | 348 tests: 342 passed, 0 failed, 6 skipped (the song-data capability skips), 8.8 min. `research.spec.ts` 9/9, 18 s |
+
+**Live check (read-only, offline tsx, 2026-10-14).** The primary's `export/public` (composed for Rekietalyzer:
+`rekietalaw`, `rekietalaw-rumble`, 2,950 videos), REPORTS_DIR in scratch:
+
+| Query | `enumerate_matches` (createCorpusTools) | Research `runSearch` | Same ids, same order |
+|---|---|---|---|
+| `lawsuit` | 1,654, complete, 9.6 s | 1,654, complete, 209 mirrors folded, 90 pages, 10.0 s | yes |
+| `contempt of court` | 70, complete, 10.4 s | 70, complete, 6 mirrors folded, 90 pages, 9.9 s | yes |
+
+After those scans the scope line read 2 channels · 2,950 videos · 2017–2026 · transcripts 9% · captions 74% · unknown
+17% (506 records carry no `transcriptFormat`) · 3 aliases.
+
+**Screenshots and keys.** `/research` (a search, the reader on a lit hit) and `/research/archive` at 1366×768 and
+1440×900, both themes, on the real local corpus with held counts from the live editor's coverage route (read only),
+in the job's scratch `r1-shots/`. Compared with the canvas: same columns (results, 176 px facets, the reader at
+`minmax(360px, 34%)`), the lit line, the meter histogram, the reader with the cue lit. Keyboard-only: every control
+of both pages takes Tab with the 2 px ring (rail 12 stops, then the ask bar, Search, the source, five chips, the
+list's one stop, the facets, the reader's cues); `/`, `j`/`k`, `r`/`s`/`u`, `c` and the inventory's arrows work
+from the keyboard alone; reduced motion is the LitList's.
+
+**Found and left.**
+- No `near` operator exists in the engine; `a near:N b` compiles to a regex and matches inside one caption line, and
+ the ask bar says so.
+- Transcripts vs captions is known only for what a search has read whole (in memory, per source); a published site
+ has no per-scope count. A census survives until umtool restarts or the local corpus is recomposed.
+- The reading log is per query + scope; R2's cases carry their own. A Candace hit is marked local only; R1 exports
+ nothing, and R2's board export must refuse `isLocalOnly` (rules.mjs). The X archive is never put on a site; R1
+ puts nothing on one.
+- On a hub, two member sites with the same channel slug share a facet row and a log key.
+- Not touched (P3's): the rail (no Research place yet: `/research` lights none), `lib/hrefs.ts`, `globals.css`,
+ `AppShell`, `redirects.mjs`. The only shared primitive touched is `ReaderThread`'s labels.