Archilyzer · Source

archilyzer

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

commit 7503ff70154b816308dede176f67d059d3de821d
parent 95163cce110b76d2c1bff370c1f268eb55bd8531
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Sun, 18 Oct 2026 17:25:14 -0400

plans: release 34 lane N3 record — the phrase finder, as shipped

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

Diffstat:
Aplans/release-34/phrase-finder.md | 115+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 115 insertions(+), 0 deletions(-)

diff --git a/plans/release-34/phrase-finder.md b/plans/release-34/phrase-finder.md @@ -0,0 +1,115 @@ +# Release 34 lane N3 — `r34/phrase-finder`: find the next montage phrase in the UI (as shipped) + +The catchphrase ranking of 2026-10-18 was made by a script a model wrote (a patched phraseScan for many phrases in one +pass, because one phrase took 2.5+ min under load). Operator rule (2026-10-16): what a model can do is doable in the +UI with no model. This lane makes the search a umtool page and a CLI, and a montage one click from a result. Nothing +here calls a model. + +## What + +1. **`phraseScanMany`** (`common/lib/montage/phraseScan.mjs`): every phrase in ONE pass over the transcripts — each cue + file read and parsed once, its text joined once (`joinCues`), every phrase matched in it (`hitsInJoined`); up to 16 + reads in flight, used in order. Each phrase's `{instances, hits, dropped, scanned}` is what `phraseScan` returns for + it alone: `phraseScan` keeps its code path, and the placing/folding is one shared `foldHits`. A phrase may carry its + own `exclude`. A twin's cues are re-read only when a hit is placed in it, so the preferred channel is never held in + memory (phraseScan holds every record of it). +2. **The cue-text cache** (`common/lib/montage/cueTextCache.mjs`): per channel one NDJSON file of each video's joined + cue text, times and five record fields, in video-id order, plus an index of each cue file's mtime and size. Streamed + a line at a time; rewritten only when something changed; a missing line falls back to the cue file and drops the + index. Never under the channels dir (umtool's is `<UMTOOL_CACHE_DIR>/phrase-text`). +3. **Plain words** (`common/lib/montage/phraseSource.mjs`, client-safe): `phraseSourceOf(text, "auto"|"words"|"regex")` + — words become `\bw1[\s,.\-]+w2…(?:s|es)?\b` (apostrophes optional, consonant+y → `(?:y|ies)`); `auto` takes a + phrase with a regular expression's characters as written. +4. **`umtool phrases`** (`umtool/lib/phrase-finder/{cli,scan,summary}.mjs`, one dispatch block in `bin/umtool.mjs`): + `"<p1>" "<p2>" --channels … --prefer … --exclude … [--words|--regex] [--samples N] [--no-cache] [--json|--full]`, and + the page's job form `--spec F --out F --progress` (NDJSON progress lines). `summarisePhrase`: count, by year (gaps as + 0), sparkline, Rumble/other (by platform), preferred/other (by channel), placed, speaker changes, excluded, raw hits, + per channel, 10 samples spread over the years. +5. **`/tools/phrases`** (`app/tools/phrases/page.tsx`, `components/tools/PhraseFinder.tsx`, `lib/phrase-finder/server.ts`, + `/api/phrase-finder`, `/api/phrase-finder/<id>`, `/api/phrase-finder/context`): phrase rows (Add phrase, ×, the mode, + "as words: /…/" under each), suggestions from `candidates.json`, the channel picker (filter, picked chips), prefer, + exclude, **Search** (a child process, one at a time, polled progress, Stop), Recent; per phrase the count, year bars, + the split, ten samples with **Play** (CitedClip: a window or saved video on disk, else Fetch clip) and **Transcript** + (the cues around it, the hit's lit); **Compared** for several phrases; **Create montage** (slug prefilled + `<phrase>-montage`). The next visit opens on the last search's settings (`last.json`). Rail: Tools → phrases; + `/tools` lists it under Montage; the jump palette has it. +6. **Create montage → the scaffold's phrase seed, from this search**: `/api/projects/new` with the seed's settings and + `scan: {id, row}`; `scaffoldReportVideo` takes `scan` (the finished answer) instead of reading the corpus again, + refused unless phrase, channels, prefer and exclude match. Same manifest, `phrase-scan.json` and README as a fresh + seed (unit-tested byte for byte). The seed's channel check now allows mixed-case channel dirs (`CHANNEL_SLUG_RE`). + +## Files + +common: `lib/montage/{phraseScan.mjs, phraseScan.d.mts, phraseSource.mjs, phraseSource.d.mts, cueTextCache.mjs, +cueTextCache.d.mts, phraseScanMany.test.ts}`, `package.json` (two exports). umtool: `lib/phrase-finder/{cli.mjs, +scan.mjs, scan.d.mts, summary.mjs, summary.d.mts, server.ts, types.ts}`, `lib/phrase-finder.test.mjs`, +`app/tools/phrases/page.tsx`, `components/tools/PhraseFinder.tsx`, `app/api/phrase-finder/{route.ts, [id]/route.ts, +context/route.ts}`, `bin/umtool.mjs` (usage + one dispatch line), `lib/hrefs.ts` (`phraseFinderHref`), +`lib/hrefs.test.mjs`, `components/AppNav.tsx`, `components/shell/JumpPalette.tsx`, `app/tools/page.tsx`, +`lib/projects/{scaffold.mjs, scaffold.ts}`, `lib/scaffold-phrase.test.mjs`, `e2e/phrase-finder.spec.ts`, +`e2e/visual-audit.spec.ts` (one page), `docs/{tools.md, cli.md, README.md}`. `plans/FACTS.md`, `editor/CHANGELOG.md`. + +| Commit | What | +| --- | --- | +| `f6ad3897` | common: phraseScanMany, phraseSource, the cue-text cache; 5 tests | +| `f8fa7ced` | umtool: the page, the API, `umtool phrases`, the scaffold's `scan`; 4 tests | +| `f6bb9374` | umtool: phrase-finder e2e, visual audit page, the answer folder made before writing (found by the e2e) | +| `e22f1ab3` | docs: tools.md, cli.md, FACTS, CHANGELOG | +| (this commit) | this record | + +## Measured (the real corpus, read-only, 2026-10-18) + +Channels the-quartering-rumble (prefer) + the-quartering, jeremy-hambly, quartering-live, cornbreadman: 23,312 +transcripts. Slow-news phrase = the project's `scan.py` regex; 25 phrases = it + the first 24 of the catchphrase +report's candidates. Page cache warm after the first run; one process per row (`/usr/bin/time`). + +| Run | Wall | Max RSS | +| --- | --- | --- | +| `phraseScan`, slow-news | 27.5 s | 560 MB | +| `phraseScanMany`, slow-news, no cache | 17.3 s | 192 MB | +| `phraseScanMany`, 25 phrases, no cache | 29.0 s | 424 MB | +| `phraseScanMany`, 25 phrases, building the cache | 36.3 s | 336 MB | +| `phraseScanMany`, 25 phrases, cache warm | 20.8 s | 278 MB | +| `phraseScanMany`, slow-news, cache warm | 6.4 s | 168 MB | + +The cache is 473 MB on disk for the five channels. Equal to `phraseScan` (deep-equal) on the real corpus for the +slow-news phrase (76 instances) and six candidates (nobody asked 141, dimensional chess 133, mostly peaceful 98, chef's +kiss 61, golly gee 83, can't make this up 88). A first cache design (one JSON per channel, parsed whole) peaked at +1.5–2.0 GB; the streamed NDJSON replaced it. + +## Gates + +All through the shared heavy lock, from the worktree root. +- `pnpm -r --no-bail --workspace-concurrency=1 exec tsc --noEmit`: clean before each commit. +- common: **4606 → 4611 (4610 pass, 1 skip)**; +5 `phraseScanMany.test.ts` (equivalence in three settings × three + cache states, the cache following a changed file and a removed video and a truncated cache file, nothing written + when nothing changed, progress, plain words). +- `pnpm run test:scripts`: **1141 → 1145 (1141 pass, 0 fail, 4 skip)**; +3 `umtool/lib/phrase-finder.test.mjs` + (checkSpec, the summary, `umtool phrases` job and terminal forms), +1 `scaffold-phrase.test.mjs` (a given scan makes + the same project). `hrefs.test.mjs` gains two assertions. +- umtool TS (`pnpm --filter umtool test`): 45/45, unchanged. +- `docs env --check`, `docs cli --check`, `docs files --check`: clean (no common env var, CLI row or file schema). +- umtool `next build` with the corpus linked (`ln -sT` + 5 GB cap): clean, 14.2 s compile; the phrase-finder routes' + `.nft.json` carry 1069 files, the same as `/api/phrases`, none under `transcripts/`. +- e2e (umtool, single specs, fixture): phrase-finder + phrase-seed: 2 passed, 1 failed (the answer folder, fixed); + phrase-finder **1/1** (12.9 s); visual-audit (with `/tools/phrases`) + a scratch screenshot spec (not committed) + **67/67** (1.4 min) — no horizontal scroll at 390 and 1366 px in either theme. +- Not run: editor, mcp, export, homepage (untouched). + +## Decisions + +- Suggestions come from catchphrase reports' `candidates.json` (`UMTOOL_PHRASE_CANDIDATES`, else every + `<REPORTS_ROOT>/<dir>/candidates.json`); no n-gram "Suggest" job (the report's mining is a heavier, separate tool). +- Create montage seeds from the finished search (`scan: {id, row}`) instead of scanning again in the request: on the + real corpus a re-scan would hold the request 17–30 s. The scaffold still scans when no search is given. +- A search is a child process (`umtool phrases`), not in-process: the memory stays out of the server, and the CLI and + the page run the same code. One search at a time (a second gets 409); it is not in the rail's Running list. +- The cache is on by default for the page and the CLI (`--no-cache` to skip). +- Rumble/other is by platform (`platform === "rumble"`), as the catchphrase report counted; the preferred channel's + share is in `--json` and `bySlug`. +- Mixed-case channel slugs are allowed by the phrase seed (they were refused, so HasanAbiVODs3 could never be seeded). + +## Rulings followed + +Nothing calls a model; every step is a page control; plain words in labels; no cards; synthetic fixtures only (the e2e +writes and removes its candidates file); the real corpus read only; the slow-news project not touched.