# Test kit Helpers for tests only; nothing in an app imports from here. Importable from every package as `yt-dlp-transcript-common/testing/` (the `.mjs` files carry `.d.mts` types, so the umtool `node --test` suites can use them too). ## Generation (release 27) Everything here is **synthetic**: invented channels, recordings, lines and posts. No real transcript, channel or person goes in these fixtures, ever. | File | What it is | | --- | --- | | `llm/fakeAnthropic.mjs` | A fake Messages API: scripted turns (`textTurn`, `toolTurn`, `pauseTurn`, `webSearchBlocks`, `thinkingBlock`, `errorTurn`, or a function of the request). It enforces the Sonnet 5.5 400s (temperature, forced `tool_choice`, `thinking: disabled`), signs thinking blocks so an edited history is refused, needs `x-api-key` = `FAKE_KEY`, and estimates usage, cache reads included. | | `llm/fakeOllama.mjs` | A fake ollama: `/api/chat` with `format` or tools, the 8k prompt cap and the 12k `num_ctx` cap as 400s, `stream: true` refused, `faultReply()` (`done: false`), the `keep_alive: 0` unload, `/api/tags`, `/api/ps`. | | images (both fakes) | Release 30: the fake Anthropic takes `image` blocks (base64 JPEG/PNG/GIF/WebP whose bytes match the media type, in a user turn — else a 400) and counts each at (w·h)/750 tokens; the fake ollama takes a message's `images` (base64 images — else a 400), each counted at `IMAGE_TOKENS` (1200) against the cap. `imagesOf(body)` (each) decodes a request's images with their sizes, for a scripted answer or an assertion. | | `frames/syntheticPoker.mjs` | Release 30: a synthetic poker stream for the frame scan — `makeSyntheticPokerStream(dir)` paints a fake client (a lobby, a table whose numbers change, a break, a bust) with ffmpeg's `color` + `drawtext` into a 210-s H.264 file (a keyframe every 2 s); `pokerTruthAt(t)` is what it shows at `t` (a fake model's answer), `SPOKEN_CUES` what the streamer "said" (two numbers that agree with the frames, one that does not). Nothing real: no stream, no client, no frames from the corpus. | | `draft/corpus.mjs` | Two channels of recordings with cues (`CHANNELS`), posts (`POSTS`), `ORIGIN`, `momentHref`, `postHref`, `cuesOf`, `recordOf`, and `writeDraftCorpus(dir)` — a composed public dir for the MCP's `--local`. | | `draft/sweeps/*.md` | sweep.md variants: `basic` (the canonical shape), `quotes-in-claims` (claims that carry quoted words — the rule they break), `multi-quote` (several quotes per link, several links per item), `posts-only`, `paragraphs` (paragraphs and a sub-heading between findings, a trailing Coverage section), `inexact` (a reversed quote fuzzy recall passes, a quote 200 s from its link, an exact one), `two-line` (a finding's quote and link on the lines under its claim), `fragment` (verbatim quotes that stop mid-thought — on a function word, or under four words — and one whole sentence). | | `draft/reports/`, `draft/manifests/` | `basic`, `posts-only`, `paragraphs` converted (`report.json`) and taken to a video manifest, as the converters make them today. | | `web/fakeWeb.mjs` | A fake web on loopback: a DuckDuckGo-shaped HTML search (`POST /html/`, links in the `uddg` redirect, an ad), pages, plain text, a long page, redirects and a redirect loop, a PDF, a 429 that clears (`busyTimes`), a 503 that does not. `web.searchUrl` is what `webSearch` takes. | | `archiveOrg/fakeArchiveOrg.mjs` | A fake archive.org on loopback: `/advancedsearch.php` (every word of `q` in an item's identifier, title or subject; `*` all) and `/metadata/` over invented items (`ITEMS`: a show's episodes with an original, a derivative and a JSON file, a restricted item, an audio tape). `ia.fetch` sends `https://archive.org/…` to it, for `new ArchiveOrgClient({ fetch: ia.fetch })`; `busyTimes` answers 429 first. | | `draft/manifests/full`, `flips` | Release 28: every media field a draft task writes, as the build accepts it today — per-entry `onscreen`, a narrated card, a teaser, `claim` verdicts, `render.chrome.threads` with a `thread` per clip (`full`), or `render.chrome.flips` (`flips`: one THEN/NOW pair over clips of different dates). Hand-written, not derived; `umtool/report-to-video/fixtures-r28.test.mjs` keeps them lint-clean. | | `draft/reports/ruled.report.json` | Release 28: a synthetic fact-check whose claims carry verdicts standing for operator rulings — every verdict at least once, each cited quote a cue of the corpus. The verdict bench's tests read it. | | `social/fakeBluesky.mjs` | Release 29: a fake Bluesky on loopback — the public AppView (`resolveHandle`, `getPosts` answering only live posts, images as `embed.images[].fullsize`), a bsky.app-shaped post page (`pageUrl(handle, rkey)`: the post in `[data-testid="postThreadItem-by-"]` inside page chrome, "Post not found" for a deleted one) for a headless screenshot, and PNG images. `bsky.fetch` sends `https://public.api.bsky.app`, `https://bsky.app` and `https://cdn.bsky.app` to it; `busyTimes` answers 429 first. | | `web/fakeWayback.mjs` | Release 29: a fake Wayback Machine — the CDX API (`/cdx/search/cdx`, `output=json` with its header row, `[]` for none, `filter=statuscode:`, `limit`, `matchType=prefix`) and capture pages (`/web/[id_]/`). `wb.fetch` sends `https://web.archive.org` to it; `busyTimes` 429s, `downTimes` 503s. Release 32 R8: a format's stream at `/web/id_/` (yt-dlp's `2id_` form) serves bytes (206 for a Range) for an id in `streams` (default `videos`), else 404 — `videos` without `streams` is the live "page captured, no video" case; `streamBusyTimes` 429s. Release 37 (lane A): PAGE captures served raw (`PAGE_CAPTURES`, `opts.pageCaptures`) — an article with nav/header/footer around an `
` (two captures), a body still carrying the toolbar insert and rewritten hrefs, a 3 MB page, a `text/plain` and an `image/jpeg` capture, and one that redirects off the archive; a timestamp with no capture of a known page answers 302 to the nearest; CDX honours `closest=`. Release 37 (lane E): Save Page Now — `POST /save` (the fake keys `FAKE_SPN_ACCESS`/`FAKE_SPN_SECRET` in `Authorization: LOW …`, else 401; `spn.busyTimes` 429s; `spn.refuseUrls` answered `error:blocked-url`) and `GET /save/status/` (`spn.pendingPolls` pending, then success at `SPN_CAPTURE_TS`, or `spn.failUrls` → `error:not-found`); a saved page is then served raw like a page capture (`spn.pages[url]` or a synthetic page); `wb.spnForms`, `wb.spnCaptures`. Release 37 (lane D): a Tumblr-themed index holding two posts (`PAGE_SPLIT_URL`/`PAGE_SPLIT_TS`, `PAGE_CAPTURES_SPLIT`, served by default) for the split-record shot, and `/web/im_/` answering a small PNG (`IMAGE_PNG`). | | `web/fakeRangedCdn.mjs` | Release 32 R7: a fake media CDN shaped like Odysee's `player.odycdn.com` — ranged GETs with a Referer answer 206 (`Content-Range`), unranged 429, no Referer 403, past the end 416; `refuseAfterBytes` (429/403 once a budget is served), `corruptOnce`, `ignoreRange`, `requireUnlock` + `unlockBytes` (served only after `cdn.unlock()` — a player's page open — lapsing after a budget; `cdn.lock()` takes it back). Release 32 R10: `dropAfterBytes` / `drops` / `dropGapBytes` cut the connection mid-body (undici's body read throws) or before any response (the fetch throws `fetch failed`); a cut request is `dropped: true`. `cdn.fetch` sends `https://player.odycdn.com` to it. | | `draft/corpus.mjs` `GONE_RECORD`, `GONE_AVAILABILITY` | Release 29: a recording deleted on its platform (`state: "deleted"`, cues kept; add it with `withRecords`) and the `availability.json` it carries on disk. The fake Wayback has one capture of its watch page. | | `audio/corruptAudio.mjs` | Release 30 lane Q: damaged audio for the salvage and refetch tests — `makeToneFile` (an AAC-in-MP4 tone-burst recording: a 0.3 s burst every 4 s, the bursts being the clock), `corruptBytes` (the same with a seeded run of its bytes overwritten: the frames there fail to decode, their timestamps survive), `readWavMono16`, `toneOnsets` (burst onsets in decoded samples), `burstTimes`, `hasFfmpeg`. Needs ffmpeg; the tests that use it skip without. | | `audio/syntheticVoice.mjs` | Release 34 N2: synthetic "voices" for the speaker-similarity tests — `syntheticVoice({f0, formants, seconds, phase})` (additive harmonics shaped by formant resonances, a syllable envelope and a vibrato; `phase` makes another take of the same voice), `withSilence`, and `VOICE_A` / `VOICE_B`, two voices TitaNet-small tells apart (cosine ~0.98 within a voice, ~0.63 across, measured). | | `audio/fakeSpeakerEmbed.mjs` | Release 34 N2: a stand-in for `scripts/speaker-embed.py` with its command line and JSON (`node fakeSpeakerEmbed.mjs --emb `): the "embedding" is the long-term spectrum (32 log-spaced Goertzel bands, dB, mean-removed, L2-normalised) — deterministic, and it separates `VOICE_A` from `VOICE_B`. Not a speaker model: set `VOICE_MATCH_PYTHON` to `node` and `VOICE_MATCH_SCRIPT` to it for a run with no python or model. | | `mirrors/mirrorCorpus.mjs` | Release 31 lane D: a synthetic creator (`synth-streamer`, "youtube": a public, a deleted and a private stream, removed shorts in and out of the window), its Rumble twin (`synth-streamer-rumble`: data dirs are URL slugs, ids embed ids) and a VOD mirror (`synth-vod-archive`, "odysee", titles `[VOD] SynthStreamer - MM/DD/YYYY - `, config `recordedDate` + `mirror.of`). `MIRROR_RECORDS` / `CREATOR_RECORDS` / `RUMBLE_RECORDS` are the matcher's input; `writeMirrorCorpus(channelsDir)` writes the three channels to disk (config, metadata, availability); `EXPECTED` is what a mirror scan finds (each status once or more, the removed uploads the mirror holds). | | `clips/reactionStream.mjs` | Release 35: a synthetic reaction stream (`reactionStream()`: a host interjecting over a narrated video — turns, words, cues, laugh windows; `reactionAudio()` its sound; `writeReactionCorpus(dir, o)` a channel on disk). Release 36: `twoVideoStream()` (an intro, video A by speaker 1, the host between, video B by speaker 2 with a pause and a stray cluster, an outro — what auto-scope reads), `reactionChat(o)` (a chat replay: a steady trickle and a burst of laugh tokens `lag` s after each laugh, `chatOnly` bursts), and `writeReactionCorpus`'s `two`, `chat` (live_chat.cues.json) and `meta` (keys into metadata.info.json) options. The "narration" is numbered filler words. | | `clips/reactionProject.mjs` | Release 36 lane D: a synthetic reactions PROJECT over `reactionStream()` — `reactionProject()` (reactions.json with a host and a subject, five moments of every kind, five proposals: three in the cut, two not; words.json; a video.manifest.json of the three clips), `writeReactionProject(dir, {note})` (them on disk, and a notes.json with an open comment on a clip), `labelAnswer(ids)` (a model's answer for the clip finder's labels, in `SUGGEST_ANSWER_SCHEMA`'s shape). | | `clips/assistProject.mjs` | Release 38 lane E: the video assistant's project — `assistManifest()` (the reactions project's three clips plus `r004`, a clip with a wide window, under a look: a 0.22 s blur slide, room at both edges, −16 LUFS, no header or footer), `assistDeckManifest()` (the same under the deck with the glitch on), `writeAssistProject(dir, {deck, note})` (on disk; `note`: a note on the whole project, `ASSIST_NOTE`), and `ASSIST_REQUESTS` — 29 requests in words, what a model answers (`{op, id, key, value}`) and the diff lines kept and the reasons refused (`answerOf(row)` is the answer in the schema's shape). | | `draft/runs/*.json` | One recorded run per generation task (release 27 S5): the model side, scripted — `turns` for the fake Anthropic (`sweep-agent`, `revise-report`, `revise-video`, `research`) or the fake ollama (`sweep-pipeline`, `narrate`; release 28's `flips`, `threads` and `youtube`, release 29's `social`, each with a `note` saying what it is run over and why its first answer is refused), with the question, channels or feedback it answers. `mcp/src/draftTasks.test.ts` runs each task over the synthetic corpus against them. | | `draft/derive.ts`, `draft/regenerate.ts` | How the derived files are made. After a converter change: `cd common && pnpm exec tsx testing/draft/regenerate.ts`, review the diff, commit. `fakes.test.ts` fails until they match. | As committed at S0, the `paragraphs` manifest showed two owed bugs: the title card had no `foot`, and the Coverage section became a bare chapter card. Release 27 S7 fixed both and regenerated the files: every title card has `foot: ""`, and a section with nothing to show (Coverage; `posts-only`'s Posts) gets no chapter card. ## Jobs and the seeder | File | What it is | | --- | --- | | `jobs/quiesce.ts` | `quiesceJobs()` and `settleJob(id)` for a test that runs managed jobs over a temp corpus. A job's status reads `done` before it stops writing: its log and sidecar, and the report regeneration its end arms, about 1 s later (`channels//snapshot.json`). `quiesceJobs` waits for all of it, firing a pending regeneration at once, before the test removes the corpus. `settleJob` waits for one job's end and sidecar. Their deadlines are backstops that throw naming what is still live. Import it as `yt-dlp-transcript-common/testing/jobs/quiesce.js`: TypeScript maps the `.js` to the `.ts` through the package's `exports`, tsx does the same, and `quiesce.ts` would need `allowImportingTsExtensions`. | | `seeder/fixture.ts` | The seeder tests' tracker, synthetic playable torrent and WebTorrent clients (`seederFixture`, `newClient`, `destroyClient`, `until`), and `childExecArgv()`: this process's flags without the test runner's, a value written after a space included. | | `seeder/webrtcScenario.ts` | The WebRTC seed-and-leech scenario as its own process. `controller/seeder.test.ts` runs it and reads its `RESULT`, `OPEN` and `STILL-ALIVE` lines. The child must report every tracker socket closed and exit by itself, or the parent kills it and fails saying what it last reported. | **A test file under a `[slug]` directory, run by path, runs nothing.** `tsx --test ` reads each path as a glob, so `[slug]` is a character class: no file matches, 0 tests run, and the run exits 0. The package's own `test` script is unaffected (its `app/**/*.test.ts` walks into the directory). For a few files by path, use `pnpm test:files …` (`scripts/test-files.mjs`): it escapes the path and fails a run of 0 tests. **No test reaches another host: `ARCHILYZER_NO_NETWORK=1`.** Every test script sets it (each package's `test`, `pnpm test:scripts`, `pnpm test:files`) and preloads `common/lib/noNetwork.mjs` into every node process the run starts, through `NODE_OPTIONS=--import=…`. Under it, any connection to a host that is not loopback fails with `ENONETWORK` naming the door, and so does a yt-dlp, ffmpeg, gallery-dl or curl spawn aimed at one. A browser gets a dead proxy. Loopback fakes keep working. **A test run by hand must export the same two:** ```sh ARCHILYZER_NO_NETWORK=1 NODE_OPTIONS="--import=$PWD/common/lib/noNetwork.mjs" tsx --test # from the repo root ``` `ARCHILYZER_NO_NETWORK_LOG=` writes one line per refusal, which finds a test whose code swallowed one. **Do not run a test file with a bare `tsx ` instead.** It runs, but outside the test runner `NODE_TEST_CONTEXT` is unset, and guards keyed on it are off. Under it the Odysee player-page opener (`ytdlp/storedUrlPageOpen.ts`) launches headless Chromium on odysee.com. The two stored-URL editor tests now name an empty `E2E_ODYSEE_PAGE_FIXTURE`, which keeps it closed whichever way they run.