Archilyzer · Source

archilyzer

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

commit ac2d4fac19e6824f8b3b1e6306ae2c9b607820bd
parent e8079ff1cc9b221f95bbc079467ba58701160baf
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Sat, 17 Oct 2026 00:16:10 -0400

plans: release 32 R7 as shipped — the stored-URL ranged download, the player's page first; FACTS; CHANGELOG

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

Diffstat:
Meditor/CHANGELOG.md | 1+
Mplans/FACTS.md | 73+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aplans/release-32/odysee-ranged.md | 113+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 187 insertions(+), 0 deletions(-)

diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## [Unreleased] +- **A full Odysee download can read the file the record already stores, the way Odysee's player does.** When Odysee answers yt-dlp with 429, the media URL in the video's `metadata.info.json` (on Odysee's CDN) is read in ranges with the page's Referer and Origin — no yt-dlp, and after opening the video's page in a headless browser for a few seconds, since Odysee's CDN serves a file only once its player has — through the same audio check: probes as it grows, a roll-back on a malformed stretch, the final probe, then the configured audio. A refusal mid-file keeps what came down and the next run picks up from the last clean byte. A channel chooses it on its Configure form (**Stored media URL downloads**: never, fallback — when the page is rate-limited or the platform held — or only), and the video page's download offers it for one video when its record has such a URL; `pnpm ops transcribe-one`, `retry-bucket` and `download-missing` take `"storedUrl"`. Two such downloads on one platform are at least 20 minutes apart (Odysee's CDN allows one new file per rest), and a download this way never counts as Odysee answering cleanly. Needs a restart of the editor. - **A clip window can be cut from the media URL an Odysee record already stores, when Odysee's lookup is rate-limited.** `pnpm ops fetch-windows` takes `"storedUrl"`: `"fallback"` tries the page as before and, when the lookup answers 429, cuts the window from the file the record's `metadata.info.json` names on Odysee's CDN (`*.odycdn.com`) instead; `"only"` goes straight to that file and asks the page nothing. A held or cooling Odysee no longer refuses those windows — only the ones with no stored file are refused or left for a later run. Same queue, same gaps between fetches, the audio check still applies, and the window's provenance says `source: "stored-media-url"` with the host. The default, `"never"`, changes nothing; only Odysee is allowed. Needs a restart of the editor. - **umtool's drafts review is an audition deck: hear the cited moment, then keep it or cut it.** `/projects/<project>/review` shows one card per drafted field still waiting for a verdict: the drafted value large, the cited span of its clip playing (video when a window or saved video holds it, else audio marked "audio only"), and the quote under it lighting word by word as it is spoken. Swipe right, → or `k` keeps it (approves); left, ← or `x` cuts it (rejects — tap a reason chip or write a few words, never required); up, ↑ or `e` edits it on the card (on-screen text, narration, teaser lines and the YouTube title; Enter keeps it as edited); down, ↓ or `s` skips it to the back; space replays the span; `z` undoes the last keep, cut or skip. Tap a word to mark it misheard: the note says so. Every action is also a button (a bar under the thumb on a phone). The next card's media is already loading, and the deck ends with what was cut and skipped. Verdicts are the same `drafts.review.json` as before; **List** (`?view=list`) is the old list, whose reader now plays the span too. No model is needed for any of it. - **Fetch clip wherever a citation is shown in umtool.** When nothing on disk holds a cited span — on the deck, in the list's reader, on an article's evidence panel and its evidence walk — **Fetch clip** asks the editor for those seconds exactly as the MCP's `fetch_clip` does, shows its progress, and plays the window when it lands. A rate limit says the platform is rate-limiting; a window the audio check refused says the source served corrupt audio. The evidence panel plays video first and has **Play span** (from the span's start to its end). diff --git a/plans/FACTS.md b/plans/FACTS.md @@ -10086,3 +10086,76 @@ parsed to 0 cues, indexing the video textless) is CLOSED by `200a3105` (transcri `cut from the stored media URL (<host>) — <platform> lookup rate-limited|held` or `(asked: only)`. - Not wired: the single `/api/media/fetch-window` route and the MCP's `fetch_clip` (which posts to that route, not to fetch-windows), and any UI toggle. + +## Release 32 lane R7: a full download from the stored media URL, read the way the player reads it (verified 2026-10-17, branch `r32/odysee-ranged`) + +- **`ytdlp/storedUrlDownload.ts`** `storedUrlDownload({paths, videoDir, stored, channelConfig, audioFormat, audioCheck, + onLog, signal, deps?})`: sequential `Range: bytes=<offset>-<offset+chunk-1>` GETs (`STORED_URL_CHUNK_BYTES` = 8 MiB) + of `stored.url` with `storedMediaHeaders(stored)` (lib/storedMediaUrl.ts: `User-Agent` = `STORED_MEDIA_USER_AGENT`, + which moved there from fetchWindowManaged.ts and is re-exported by it; the pinned `Referer`; its `Origin`; + `Accept: */*`). No cookies, no yt-dlp. 206 + `Content-Range` (the start must equal the offset); 200 = the CDN ignored + the range, read as the whole file from 0; 416 = past the end; **429 and 403 → `rate-limited`** (partial kept); + 404/410/other → `http-error`; a thrown fetch or an empty body → `network`. +- **On disk, in the video dir:** the partial `audio.<ext>.stored.part` (`<ext>` = the URL path's when it is a media + extension, else mp4) and its resume state **`audio.<ext>.stored.part.json`** = `{version: 1, url, totalBytes, + goodBytes, updatedAt}` — `goodBytes` is the last probed-clean byte count (with the audio check off: every byte + written). Both are media-tier SCRATCH (`\.part$`, and the new `\.stored\.part\.json$` rule). A resume truncates the + partial to `goodBytes` when the state's `url` matches; a partial with no state (or another URL's) is deleted. The + finished file is renamed to `audio.<ext>` (the container), the state removed. +- **The audio check over this producer:** `resolveKnobs` (now exported from audioCheckedDownload.ts, taking + `{channelConfig, debugPauseMs?}`) and the AIMD cadence; a probe of the partial between reads once the live interval + has elapsed and it grew past the size gate; clean/partial → `goodBytes` advances (state written); malformed → + truncate to `goodBytes` (`rollback`, or `restart` at 0); more than `maxRollbacks` in a row → `failed-corrupt-source` + (partial kept). New `CheckpointAction` **`skip-not-yet-readable`**: ffmpeg cannot open the container ("Error opening + input" / "moov atom not found" / "Invalid data found") and nothing has probed clean yet — not corruption (an MP4 + whose index is longer than the first reads). Final probe of the whole file; malformed → one re-read from `goodBytes` + (0 when no checkpoint was clean); malformed again → `corrupt-full-source`, the container KEPT. Then + `transcodeAudio` to the channel's format (skipped when the container already is it) and `removeMediaFile` of the + container unless `keepSourceVideo`. +- **`downloadOneManaged({storedUrl?, storedUrlHeld?, storedUrlDeps?})`**: mode = request ?? channel + **`storedUrlDownloads`** (new key, CHANNEL.md) ?? `never` (`resolveStoredUrlMode`). Transcribe handling only; the + stored URL is read with `storedMediaUrl(data/<canonicalId>)` BEFORE the prefetch. `only` → no prefetch, no yt-dlp; + with no trusted stored URL → `failed`, `failureClass: per_video`, one `stored-url-ranged` attempt, nothing requested. + `fallback` → the page as always; a prefetch classified `rate_limit`, or a failed primary/auth retry whose tail + classifies `rate_limit`, goes to the stored URL. Inside the corrupt-source refetch (prepare/settle wrap it as any + download). `audioCheckApplies(config, PAGE url)`. +- **One new file per platform per rest:** `STORED_URL_NEW_FILE_GAP_MS` = 20 min under the platformGap key + **`stored-url:<platform>`** (`storedUrlGapKey`; in memory, process-wide). Waited out (`waitForPlatformGap`) before a + stored-URL download and set at its start and its end. Not shared with the clip cut (`clip-window:<platform>`). + The test seam `storedUrlDeps.gapMs` replaces it (no env knob). +- **THE PLAYER'S PAGE FIRST (the orchestrator's live finding, 2026-10-17):** Odysee's CDN serves a stream's original + file to a connection only AFTER a player has opened that video's page — cold ranged reads with the player's headers + got 429 (four windows, 20–40 min apart); right after a headless Chromium page view (the odysee.com page, ~10 s, + play, ~8 s) the player's requests got 200/206 and the ranged cut landed. How long the unlock lasts is unknown. + `ytdlp/storedUrlPageOpen.ts`: `PageOpener` (`{pageUrl, cdnHost, signal, onLog}` → `{ok, mediaStatuses, error?}`), + the real `openPlayerPage` (Playwright through `social/playwrightRuntime.ts`, headless, a fresh context, no cookies; + `PAGE_OPEN_SETTLE_MS` 10 s, a play click/`video.play()`, `PAGE_OPEN_PLAY_MS` 8 s; never throws), + `PAGE_OPEN_PLATFORMS = ["odysee"]`. `storedUrlDownload` takes `pageUrl` + `openPage` (null = none) and opens before + its first read; a 429/403 that follows bytes served since the last open opens the page again and re-asks the same + range; one straight after an open is `rate-limited` (no loop). The managed download passes the PAGE url and + `openPlayerPage` for PAGE_OPEN_PLATFORMS (`storedUrlDeps.openPage` injects one; tests never launch a browser), inside + the same gap. The attempt records `storedUrl.pageOpens`. Not wired into the clip cut (fetchWindowManaged's ffmpeg + path). +- **The record:** attempt kind **`stored-url-ranged`** (n: 1, `usedCookies: false`, `ytdlpExitCode` 0 = the file came + down whole, else 1) with `storedUrl: {host, why: "rate-limited"|"held"|"only", bytes, totalBytes?, resumedFrom?, + httpStatus?}` and `audioCheck` stats when the check applied. Status `ok-audio-checked` (check on) | `ok` | + `failed-corrupt-source` | `corrupt-full-source` | `failed-short-audio` | `failed`; `failureClass` set by the caller + (`writeOutcome`'s new `failureClass` override): rate_limit (429/403), network (fetch failure, 5xx), per_video (4xx), + unknown (cancel, extraction). The archive line is `<extractor> <id>` from metadata.info.json. Helpers in + lib/downloadOutcome.ts: `storedUrlAttemptOf(record)` (the last attempt's `storedUrl`) and `askedPlatform(record)` + (any attempt that is not `stored-url-ranged`). +- **Never settled clean by a stored-URL success:** `runManagedDownloads` calls `onPlatformBackoff("rate_limit")` for an + `ok*` record whose stored attempt says `rate-limited`, and decrements `requestCounter` for a record that asked the + platform nothing (so a run of `only`/held downloads does not lift a hold). The lane (`autoRunner`): an `ok*` record + with a stored attempt → `{outcome: "transcribed", failureClass: "rate_limit"}` after a rate-limited lookup, else + `viaStoredUrl: true` — `applyUnitOutcome` then retires the video and touches no backoff/hold/pace. The lane still + does not PICK on a held or cooling platform. +- **Editor:** `storedUrl` on the ops bodies of `transcribe-one` (refused with `file`), `retry-bucket` and + `download-missing` (`app/api/ops/_storedUrl.ts` `optStoredUrlMode`), kept in their job specs for Retry. A HELD + platform's `download-missing`/`retry-bucket` with a stored mode (request or channel) runs instead of being refused, + as `storedUrl: "only", storedUrlHeld: true` (`runPipelineAction`). `whisperVideoAction(…, storedUrl?)`: with no audio + and a mode other than never, the download is `downloadOneManaged` (not the raw `download-one-audio` run), a non-`ok*` + record fails the job before transcription; single-video downloads record the platform backoff on a stored + refusal. UI: the Configure form's **Stored media URL downloads** select (`aria-label "stored media URL downloads"`, + Transcription section); the video page's re-download **Stored media URL** select (`aria-label "stored media URL"`) + shown only when the record stores a trusted URL and the channel is transcribe handling. diff --git a/plans/release-32/odysee-ranged.md b/plans/release-32/odysee-ranged.md @@ -0,0 +1,113 @@ +# Release 32 lane R7 — full Odysee downloads read the way the player reads (as shipped) + +Measured (2026-10-16): Odysee answers yt-dlp with 429 — its lookup API and its own fetch of the stored original-file +URL — while the player's ranged GETs of `player.odycdn.com/v6/streams/<claim>/<sd>.mp4` (Referer/Origin odysee.com, a +browser user agent, no cookies) get 206; the CDN allows one new original file after a rest. The clip-window path +already cuts that way (R5); full downloads (transcribe handling, audio) still went through yt-dlp and failed. + +**Found live during the lane (the orchestrator, 2026-10-17):** the CDN serves a stream's original file to a connection +only AFTER a player has opened that video's page. Cold ranged reads with the player's headers got 429 (four windows, +20–40 minutes apart); right after a headless Chromium page view of the same video (the odysee.com page, ~10 s, play, +~8 s) the player's own requests got 200/206 and the ranged cut landed (audio check clean). How long the unlock lasts is +unknown. + +## What + +- **The ranged downloader** (`common/ytdlp/storedUrlDownload.ts`): the WHOLE stored file in sequential 8 MiB Range + requests with the player's headers (`storedMediaHeaders`, `STORED_MEDIA_USER_AGENT` now in lib/storedMediaUrl.ts), + into `audio.<ext>.stored.part` with a resume state `audio.<ext>.stored.part.json` (`{url, totalBytes, goodBytes}`); + resumable from the last probed-clean byte; the abort signal honoured between and during reads; a 429/403 stops + with the partial kept (`rate-limited`). +- **The player's page first** (`common/ytdlp/storedUrlPageOpen.ts`): a named, injected `PageOpener`; the real + `openPlayerPage` is headless Chromium (the workspace's Playwright via `social/playwrightRuntime.ts`, a fresh context, + no cookies) on the video's page for 10 s, a play, 8 s more, never throwing. Odysee only (`PAGE_OPEN_PLATFORMS`). + Opened before the first ranged read of each run, inside the same 20-minute gap; a 429/403 after bytes were served + since the last open opens the page again and re-asks the range; one straight after an open gives up + (`rate-limited`, no loop of opens). The attempt records `pageOpens`. Tests inject a fake opener (the fake CDN's + `requireUnlock` / `unlockBytes` model the lock and its lapse) and never launch a browser. +- **The audio integrity pipeline over it:** the audio check's knobs (`resolveKnobs`, exported) and AIMD cadence, a + probe of the growing partial between reads, a malformed verdict rolling back to the last good byte (a truncate — + this loop is the producer, so no SIGSTOP and no `.good` copy), more than `maxRollbacks` in a row → + failed-corrupt-source; the final probe, one re-read from the last good byte, malformed again → corrupt-full-source + with the file kept; then the configured extraction and the container removed unless `keepSourceVideo`. A partial + ffmpeg cannot open yet, before anything probed clean, is `skip-not-yet-readable` (an MP4 index longer than the + first reads), not corruption. +- **In the managed download** (`downloadOneManaged`): `storedUrl: never | fallback | only` (else the channel's new + `storedUrlDownloads`, else never), transcribe handling, STORED_URL_PLATFORMS only. `only`: no prefetch, no yt-dlp + (no trusted stored URL → a per-video failure, nothing asked). `fallback`: after a rate-limited prefetch, or a + download (primary / auth retry) that ended rate-limited. Outcome sidecar with the new attempt kind + `stored-url-ranged` (`storedUrl: {host, why, bytes, totalBytes?, resumedFrom?, httpStatus?}` + audio-check stats), + the media tier's hook (writeOutcome), the archive line, the short-audio guard, and the corrupt-full-source refetch's + prepare/settle around it exactly as for a yt-dlp download. +- **Paced:** one new stored-URL file per platform per 20 minutes (`STORED_URL_NEW_FILE_GAP_MS`, platformGap key + `stored-url:<platform>`): waited out before, set at the start and the end, so a batch waits rather than 429s. +- **Never a clean settle:** a stored-URL success after a rate-limited lookup backs the platform off (batch and lane); + one that asked the platform nothing (`only`, held) does not count as a request (no clean settle of a manual run) and + the lane retires the video without touching the backoff, hold or pace (`viaStoredUrl`). +- **Editor:** `storedUrl` on `transcribe-one` (not with `file`), `retry-bucket`, `download-missing` (checked at the + door, kept on Retry). A held platform's download-missing / retry with a stored mode runs as `only` (`storedUrlHeld`). + Transcribe (the video page's and `transcribe-one`'s) with a stored mode downloads through the managed path, not the + raw one-video run; a non-ok record fails the job before transcription. +- **UI (the UI-without-AI rule):** the Configure form's **Stored media URL downloads** (never / fallback / only); the + video page's re-download **Stored media URL** select (inherit / never / fallback / only, naming the CDN host), shown + when the record stores a trusted URL, for both download modes. Ops help, COMMANDS.md, CHANNEL.md. + +## Files + +`common/ytdlp/storedUrlDownload.ts` (new), `common/ytdlp/storedUrlPageOpen.ts` (new), `common/ytdlp/downloadOneManaged.ts`, `common/ytdlp/audioCheckedDownload.ts` +(exports), `common/ytdlp/fetchWindowManaged.ts` (the UA constant re-exported), `common/ytdlp/runYtdlp.ts`, +`common/lib/storedMediaUrl.ts`, `common/lib/channelConfig.ts`, `common/lib/channelConfigSchema.ts`, +`common/lib/downloadOutcome.ts`, `common/lib/mediaTier.ts`, `common/jobs/unitOutcome.ts`, +`common/controller/autoRunner.ts`, `common/testing/web/fakeRangedCdn.mjs` (+ `.d.mts`, new), +`common/testing/audio/corruptAudio.mjs` (`faststart`), `editor/app/api/ops/_storedUrl.ts` (new), the +`transcribe-one`, `retry-bucket`, `download-missing` routes, `editor/app/channels/[slug]/pipelineActions.ts`, +`editor/app/channels/[slug]/videos/[id]/videoActions.ts`, `…/[id]/page.tsx`, `…/components/VideoPanel.tsx`, +`…/cards/RedownloadSection.tsx`, `editor/app/channels/components/{ChannelForm.tsx,parseChannelForm.ts,channelConfigToForm.ts}`, +`editor/app/jobs/jobReplayRegistry.ts`, `scripts/archilyzer-ops.mjs`, `COMMANDS.md`, `CHANNEL.md`. +Tests: `common/ytdlp/storedUrlDownload.test.ts` (14), `common/ytdlp/storedUrlManaged.test.ts` (10), +`common/jobs/unitOutcome.test.ts` (+1), `common/ytdlp/managedDownloadsSleep.test.ts` (+2), `common/lib/mediaTier.test.ts` +(+2 rows), `editor/app/api/ops/retry-bucket/route.test.ts` (+1), `editor/app/channels/components/parseChannelForm.test.ts` +(+1), `editor/e2e/stored-url-downloads.spec.ts` (2). + +| Commit | What | +| --- | --- | +| `066702da` | common: the ranged downloader + the audio check over it; `storedUrlDownloads`; `stored-url-ranged`; the fake CDN | +| `e750f34a` | common: the managed download's never/fallback/only, the 20-minute gap, never a clean settle (batch, lane) | +| `9d6d6c6d` | editor: `storedUrl` on the three ops routes and actions, the held door, Transcribe through the managed path; ops help, COMMANDS.md | +| `2689b720` | editor: the Configure field, the video page's option, the e2e spec | +| `01717bf5` | common: the player's page opened first (and again on a refusal after served bytes); the key-count test | +| (this commit) | this record, FACTS, CHANGELOG | + +## Gates + +All through the shared heavy lock, from the worktree root, at `01717bf5`: +- `pnpm -r --no-bail --workspace-concurrency=1 exec tsc --noEmit`: clean (0 errors). +- common: 4510 at the branch's start (4507 pass, 2 fail, 1 skipped — that run overlapped my first edits; the two were + this lane's own, the channel-config key count and an undeclared env var, both fixed) → **4537 (4536 pass, 0 fail, + 1 skipped)**. +- editor unit: 331 → **333/333**. +- test:scripts: **1052 (1048 pass + 4 skipped)**, unchanged count (ops help text only). +- mcp: **377/377** (not touched; run once at `2689b720`). +- `docs cli --check`, `docs files --check`, `docs env --check`: clean; `settings example --check` clean at `2689b720` + (no settings change). +- e2e `stored-url-downloads.spec.ts`, foreground: run 1 at `2689b720` 2/2 passed (17.4 s, start-mode build 64 s); run 2 + at `01717bf5` 2/2 passed (11.8 s, rebuild 56 s). + +## Rulings followed + +Opt-in (default never), the allowlist of one platform and its CDN hosts (R5's), one stream with real gaps (one new +file per rest), the audio check keyed on the PAGE url, no model and no live network in any test (a fake CDN on +loopback, a synthetic recording). Records state rulings. + +## Owed + +- The real page opener has never run in a test (by rule); the first live run is its proof. If the unlock turns out + shorter than an 8 MiB read, every chunk would re-open (each open is ~18 s): the log says so. +- The clip cut (fetchWindowManaged's ffmpeg path) does not open the page; `openPlayerPage` is exported for it. + +- The lane does not PICK units on a held or cooling platform even with `storedUrlDownloads: "only"` (the batch door + lets them through; the lane's scheduler is unchanged). +- The clip cut (fetch-windows, `clip-window:<platform>`) and the full download (`stored-url:<platform>`) keep separate + gaps; a cut and a download within 20 minutes of each other are not spaced by this. +- A yt-dlp `audio.<ext>.part` (and `.part.good`) left by a rate-limited audio-checked primary before a `fallback` is + not adopted (its bytes may be of another format); it stays as scratch beside the stored partial.