commit 323693922df9ac6a7d0b0de6d0ee2435ee0bca9a
parent c9eb780daf142d39a0b89f026d5ebd69eb6338ea
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 19 Oct 2026 01:07:10 -0400
plans: release 35 C1 as shipped -- the clip finder's analysis (record)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
1 file changed, 91 insertions(+), 0 deletions(-)
diff --git a/plans/release-35/clip-analysis.md b/plans/release-35/clip-analysis.md
@@ -0,0 +1,91 @@
+# Release 35 lane C1 — `r35/clip-analysis`: finding the clips (as shipped)
+
+The plan of record is [clip-finder.md](clip-finder.md); this lane is its analysis half: from a long recording's
+speaker turns, words and sound to clip proposals in a report-video manifest, each marked as the assistant's, and
+`reactions.json` beside it. Lane C2 (`r35/clip-editor`) is the review UI over the same two shapes.
+
+## What
+
+- **`common/lib/clips/`** (plain ESM + `.d.mts`, exported as `yt-dlp-transcript-common/lib/clips/*.mjs`):
+ - `clips.mjs` — pure: `assignRoles` (host = most turns < 8 s × widest spread over 20 bins; subject = most seconds
+ of the rest; < 1 % of the speech never wins; a third cluster whose TitaNet centroid is ≥ 0.6 like the host's or
+ subject's takes that role with `sameAs`; the operator's roles stand), `laughEvents` (runs ≥ `laughMin`, joined
+ across 0.5 s, mean score), `textLaughs` / `energyLaughs` (the no-model fallback), `attributeLaughs` (a host turn
+ overlapping makes it the host's), `findMoments`, `momentSpan` / `buildProposals` (setup → reaction → tail,
+ snapped to word gaps, merged, capped), `stableIds`, `rankIntoTarget`, and `analyze` (all of it).
+ - `assist.mjs` — `validateAssist`, `clipFromProposal`, `fixedClips`, `applyProposals` (the one proposal-to-clip
+ writer: an untouched assistant clip is moved in place or removed; everything else stays).
+ - `reactions.mjs` — `readReactions`, `writeReactions` (tmp + rename), `operatorRoles`, **`setSpeakerRole`** (C2's
+ write: the operator's "This is the host").
+ - `scan.mjs` — `resolveTagger`, `tagWavs`, `runAudioScan` (1 s windows / 0.5 s hop: level always, laugh score with
+ the tagger; 300 s chunks, one tagger process per 4), `centroidPieces`, `speakerCentroids` (voiceMatch's
+ `embedWavs` + `robustCentroid`).
+- **`scripts/audio-tag.py`** — sherpa-onnx `AudioTagging` (CED-mini), modelled on `speaker-embed.py`: wavs in,
+ per-window probabilities of the requested classes out (JSON, 4 dp, one thread). Proved on the model's bundled
+ `test_wavs/4.wav` (laughter): whole-file family sum 0.99; per-window 0.84 peak; the JS driver over the same file
+ in 4 s chunks gives the same 19 values as the script alone.
+- **umtool** (`umtool/lib/report/reactions.mjs`): `loadRecording` (diarization required — the refusal names
+ `archilyzer diarize backfill --scope video:<channel>/<id>`; words from `<project>/words.json` > corpus
+ `transcript.json` > cues), `recordingAudio`, `scanRecording` (cached in `<project>/scans/`), `proposalPass`,
+ `proposeProject` (manifest via `replaceManifest` with a token and an undo point, retried on a stale token;
+ ruled and locked clips protected), `clipsCommand` (`umtool clips analyze|propose|show`), `clipsSteps` (the job).
+ `scaffold.mjs` gains `--seed reactions` (and `seedsFor().reactions`); `umtool new --seed reactions` then runs
+ `clips analyze` unless `--no-analyze`. `/api/report/clips` (GET summary / job, POST start, cancel). The
+ new-project form's seed "highlights" (+ target) and Create's line **Highlights from a recording**, which starts
+ the analyze job after creating the project.
+- **The validator:** `validateAssist` in report-to-video's build validators and `lint.mjs validatorErrors`, and in
+ umtool's manifest writer's `structureErrors`. The renderer ignores the key.
+- **Test kit:** `testing/clips/reactionStream.mjs` (a synthetic reaction stream: turns, words, cues, laugh windows,
+ its sound, and `writeReactionCorpus`), `testing/audio/fakeAudioTag.mjs` (the shim's stand-in: it hears the
+ stream's 1.5 kHz laugh tone). The umtool e2e app runs the fake tagger (`AUDIO_TAG_*` in playwright.config.ts).
+
+## The shapes (owned here; C2 codes against them)
+
+Exactly the plan's, plus optional keys (FACTS.md, "Release 35 lane C1"): `source.wordsFrom`, `source.audio`,
+`source.audioKind`, `speakers[].sameAs`, `laughs[].src` ("text" | "energy"; absent = the model), `laughSource`,
+`scans`, `madeAt`, `proposedAt`, `rolesChangedAt`; `speaker: null` on a laugh or moment heard in no turn; an unused
+proposal has `clipId: null`. A proposal's `start`/`end` IS the clip's cut (`cutStart`/`cutEnd`); the clip's
+window is 1.5 s wider each side (`assist.original` carries all four).
+
+## Rulings followed
+
+- The UI works without AI: every step is signal processing plus two small local models (CED-mini, TitaNet), and the
+ no-model fallback (transcript markers + energy) runs the whole loop. Nothing calls an LLM; no network.
+- Fetches and transcription are not done here: words come from `pnpm ops transcribe {words: true, out}`; the sound
+ is whatever the corpus already holds.
+- Records state rulings, not reasons; no corpus content in fixtures (the stream is numbered filler words).
+
+## Commits
+
+| sha | what |
+|---|---|
+| `9da7c408` | common: lib/clips — roles, laughs, moments, proposals, reactions.json, the assist key; test kit stream |
+| `318eb9d2` | common: the laugh scan + voice centroids, scripts/audio-tag.py, the fake tagger |
+| `ada3e840` | umtool: `--seed reactions`, `umtool clips analyze\|propose\|show`, validateAssist wired |
+| `98a208e9` | umtool: seedsFor's reactions key; the frames test's words kept |
+| `71d70f47` | umtool: the form's "highlights" seed, Create's line, the clips job route; create.spec |
+| `9911841f` | docs: cli.md, report-video.md "Highlights", FACTS, ENVIRONMENT.md (AUDIO_TAG_*), CHANGELOG |
+| (this) | plans: this record |
+
+## Gates (all through the shared lock, from the worktree root)
+
+- `pnpm -r --no-bail --workspace-concurrency=1 exec tsc --noEmit` — clean at `ada3e840` (8.7 min, the lock shared)
+ and at `71d70f47`'s tree (umtool tsc after the e2e edits: clean).
+- common `pnpm --filter yt-dlp-transcript-common test` — 4648 tests, 4646 pass, 2 skipped (the one failure in that
+ run was `ENVIRONMENT.md is stale`, an artefact of editing envVars.ts mid-run; regenerated and re-run green). Before
+ this lane: 4627 (21 new: clips.test.ts 16, scan.test.ts 5).
+- `pnpm run test:scripts` — 1182 tests, 1178 pass, 0 fail, 4 skipped (before: 1175; 7 new in
+ `umtool/lib/report/reactions.test.mjs`; `scaffold-frames.test.mjs` updated for seedsFor's new key).
+- `pnpm archilyzer docs env --check` — clean (ENVIRONMENT.md regenerated: four `AUDIO_TAG_*` rows).
+- e2e `create.spec.ts` (umtool, `E2E_MODE=dev`): see the report.
+- No build: the slice changes umtool, and its one e2e spec ran under `next dev`.
+
+## Found and left
+
+- The plan's example shows a proposal's span wider than its clip's cut; here the proposal IS the cut and the window
+ is the pad. Same keys, recorded above.
+- CED's per-class outputs are independent sigmoids, so the family's sum can pass 1; it is clamped. On 1 s windows the
+ scores run lower than on a whole laugh (0.84 peak vs 0.99 on the bundled laugh file): `laughMin` 0.25 is the plan's
+ default, to be calibrated on the first case (`--laugh-min`).
+- Multi-host streams (more than one host role) are later (the plan's "Later"): `setSpeakerRole` keeps one host and
+ one subject.