Archilyzer · Source

archilyzer

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

commit a9435de63eec7d7bd058b81eefed5b3ba913e171
parent f36ae5a1e64cc7d0bf3e2169fbba5bde45ce5f8a
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 20 Oct 2026 09:58:04 -0400

wayback pages: the Captures e2e spec, its fake origin and seam, docs (OPERATING, COMMANDS, ENVIRONMENT, FACTS, CHANGELOG)

wayback-captures.spec: scan on the fake Wayback (E2E_WAYBACK_ORIGIN_FILE),
the table, filter by year, Import selected and Import all in range queue one
import request each (E2E_IMPORT_PAGE_SEAM_FILE until S1's job is on main),
and wayback-import's dry run over HTTP.

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

Diffstat:
MCOMMANDS.md | 3+++
MENVIRONMENT.md | 2++
MOPERATING.md | 22++++++++++++++++++++++
Mcommon/lib/envVars.ts | 2++
Meditor/CHANGELOG.md | 1+
Meditor/e2e/servers.ts | 14++++++++++++++
Aeditor/e2e/wayback-captures.spec.ts | 124+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mplans/FACTS.md | 43+++++++++++++++++++++++++++++++++++++++++++
8 files changed, 211 insertions(+), 0 deletions(-)

diff --git a/COMMANDS.md b/COMMANDS.md @@ -56,6 +56,7 @@ Run from the repo root (in the container: `docker compose exec editor pnpm archi | `archilyzer run` | `<operation> <channel> [ids…] [--lane local\|remote]` | run one catalogued operation over a channel offline, as the editor's job does (sync, downloads and transcription are refused: they run in the editor; it does not see the editor's lanes, so not beside one on the same channel) | | `archilyzer archive-org refresh` | `<slug> [--dry-run]` | bring a channel's archive.org file records up to their provenance: a name-only mirror's title (where the item gives the file none) and upload date from its file name; offline, through the metadata history; prints old → new | | `archilyzer wayback refresh` | `<slug> [--titles <json>] [--dry-run]` | bring a channel's Wayback Machine copies up to the Wayback rules: wayback.json (original URL, capture time), the dir renamed to its canonical id through the snapshot's reconcile (roster moved with it), and with --titles (a file of id → {title, upload\_date}) a raw file's title and date; offline, skips a record a live job holds; prints old → new | +| `archilyzer wayback scan` | `<slug> [--dry-run] [--max-rows N] [--full]` | list the Wayback Machine's captures of a Wayback pages channel's targets (config wayback.targets) into its wayback-scan.json: the CDX API per target, paged with a resume key, collapse=digest, status 200, at most N rows (50000) a run, no bodies; a cut run continues next time, a complete one starts a new pass (--full: from each target's start); paced as archive.org asks, in this process — with the editor running use `pnpm ops wayback-scan`; --dry-run asks nothing and prints the next request per target | | `archilyzer feeds backfill-metadata` | `<slug> [--feed <url>] [--dry-run]` | complete a podcast channel's records (title, date, description, duration) from its RSS feed: one fetch of the feed (default: the channel's url), no media; --dry-run counts matched / unmatched / already complete and writes nothing | | `archilyzer media attach` | `<slug> <source> [--items <json\|@file>] [--match <regex>] [--create-records] [--replace] [--dry-run]` | give a channel's held videos their media from a LOCAL archive (a directory, a .zip read in place, a .7z) into the saved-video store, provenance recorded (archive, entry, sha256); the id from the folder's "(&lt;id&gt;)" or the file's yt-dlp suffix; --create-records writes a record for a video not held; --dry-run lists each folder's class and writes nothing; offline, nothing fetched | | `archilyzer media playable` | `<slug> [--ids <a,b>] [--trackers <url,url>] [--root <dir>] [--dry-run]` | remux a channel's saved containers losslessly (-c copy) into browser-playable mp4 (+faststart) or webm, one single-file torrent each (no web seed; --trackers is the announce list, outside the infohash), under playable/ beside the saved-video store; keyed by the source's sha256, so a re-run is a no-op; offline | @@ -157,6 +158,8 @@ Drives a running editor over HTTP (`/api/ops/*`, the same actions its pages run) | `import-post` | import-post imports ONE post by its URL into a posts channel of its platform: {"slug", "url"} — an X status (x.com/&lt;handle&gt;/status/&lt;id&gt;) or a Bluesky post (bsky.app/profile/&lt;handle&gt;/post/&lt;id&gt;, or its at:// URI). Read through the channel's own fetcher (gallery-dl for X, with the channel's login; the public AppView for Bluesky) as an import-post job on the platform's queue. Refused, before any job: a URL that is not a post, a channel that is not a posts channel of that platform or whose fetcher cannot read one post, a post the URL names as another account's, the platform held or cooling down. A post already archived is not read again; one the platform says is another account's is not written. The log ends with @@import-post {ok, slug, url, id, written, already?, post?, error?}. | `pnpm ops import-post --json '{"slug":"demo-x","url":"https://x.com/example/status/1700000000000000001"}' --wait` | | `wayback-lookup` | wayback-lookup answers the Wayback Machine's captures of a page (its CDX API): {"url"} or a record's {"slug", "id"} (its metadata's page, else its availability check's, else the playlist's), "okOnly"?: only the captures that recorded a 200, "limit"?: 100 (at most 500) -&gt; {url, found, captures: \[{timestamp, status, mimetype?, replayUrl}\]}, oldest first. One request through the editor's Wayback client, with archive.org's manners (one at a time, 2 s apart, 429s waited out). Read only. | `pnpm ops wayback-lookup --json '{"slug":"demo-channel","id":"dQw4w9WgXcQ","okOnly":true}'` | | `find-copy` | find-copy looks for a copy of every gone recording (deleted or private) a report cites, and fetches the cited windows from it, as a find-copy job: {"article"} \| {"articles": true} \| {"siteId"}, "dryRun"?, "retryFailed"? -&gt; {jobId}. Per YouTube recording, one at a time: the Wayback Machine when it holds the video (the check yt-dlp makes, not a capture of the page), then archive.org (a mirror of the upload: its identifier, a file name or its original URL names the id, and the file has the recording's length). A copy a fetch failed from at its source (404, 410, 403, unreachable; never our own format selector) is not picked again, unless "retryFailed": true. A copy's windows are cut with a lenient selector (a direct file of unknown height: then the best single file). Every copy's windows go to ONE fetch-windows job on the archive.org clip queue, the copy's URL as each window's page, so the clips land in the recording's own clips/ with the copy (wayback or archive.org, and its URL) in each window's provenance. A recording with no copy is left: its moments show their words only, marked "Source deleted". The log ends with @@find-copy {recordings: \[{slug, id, gone, watchUrl, youtubeId, windows, failedBefore, tried, copy?, outcome}\], items, stopped?, fetchJobId?, refused?}. dryRun looks and starts no fetch; a cancelled job starts none. The scope mode (release 31): {"slug"} \| {"siteId"}, "gone": "no-transcript" \| "all", "dryRun"?, "max"? (10, at most 200), "retryFailed"? -&gt; {jobId}. Every gone (deleted or private) video of the channel, or of the site's channels, that holds no audio or video ("no-transcript": and no transcript; "all": the transcribed ones too, after) is looked for the same way, at most max per run; a video whose last copy attempt found none or failed in the last 30 days is left out unless "retryFailed". Each copy's WHOLE audio is fetched into the video's own record (audio.&lt;fmt&gt;; its metadata stays the original's, the copy is in wayback.json or archiveorg.json and copy-attempts.json) by ONE fetch-copies job on archive.org's download queue, one at a time; the transcription lane then transcribes it like any downloaded audio. A video neither source holds is recorded none-found. dryRun asks the same (paced) questions and records and fetches nothing. The log ends with @@find-copy {scope, gone, dryRun, max, channels, eligible, skipped, looked: \[{slug, id, gone, noTranscript, watchUrl, youtubeId, tried, copy?, via?, outcome}\], left, items, stopped?, fetchJobId?, refused?}. | `pnpm ops find-copy --json '{"article":"demo-article","dryRun":true}'`<br>`pnpm ops find-copy --json '{"article":"demo-article"}' --wait`<br>`pnpm ops find-copy --json '{"article":"demo-article","retryFailed":true}' --wait`<br>`pnpm ops find-copy --json '{"siteId":"demo-site","gone":"no-transcript","dryRun":true}' --wait`<br>`pnpm ops find-copy --json '{"slug":"demo-channel","gone":"all","max":5}' --wait` | +| `wayback-scan` | wayback-scan lists the Wayback Machine's captures of a Wayback pages channel's targets (config wayback.targets) into its wayback-scan.json, as a wayback-scan job on archive.org's queue: {"slug", "dryRun"?, "maxRows"? (50000, at most 200000), "full"?} -&gt; {jobId}. The CDX API per target (its matchType exact \| prefix \| host \| domain, status 200, its mimes — text/html unless it names text/plain or application/json — collapse=digest, its from/to), in pages of 5,000 with a resume key; obvious assets (css, js, images, fonts) dropped unless the target's include names them. One row per distinct (URL, digest) with first/last seen. No bodies: import-page fetches a capture. A run cut short (the row cap, a refusal, a drain) keeps each target's resume key and the next continues; once every target is complete the next run is a new pass, from 30 days before the last began, and what it adds is marked new; "full" starts a new pass from each target's start. Paced as archive.org asks (one at a time, 2 s apart, 429/503 waited out; a refusal stops the job). dryRun asks nothing and writes nothing: it logs the next request per target. The log ends with @@wayback-scan {slug, dryRun, pass, newPass, targets: \[{url, match, requests, rows, added, complete, resumeKey?, next?}\], requests, rowsRead, added, totalRows, complete, stopped?, error?}. | `pnpm ops wayback-scan --json '{"slug":"demo-pages","dryRun":true}' --wait`<br>`pnpm ops wayback-scan --json '{"slug":"demo-pages"}' --wait` | +| `wayback-import` | wayback-import imports chosen rows of a Wayback pages channel's scan, one import-page job per row (the capture the content was first listed at), queued on archive.org's queue: {"slug", "keys"?: \["&lt;digest&gt; &lt;url&gt;", ...\]} or a range — "year"? (first seen), "prefix"? ("host/path/"), "q"? (text in the URL), "show"? (all \| new \| not-imported \| imported) — and "dryRun"? -&gt; {ok, slug, dryRun, chosen, queued: \[{key, url, jobId?}\], skipped: \[{key, why}\], left}. Rows already imported are skipped; at most 500 are queued a call (left: how many remain). The Captures tab's Import selected and Import all in range. | `pnpm ops wayback-import --json '{"slug":"demo-pages","year":"2014","show":"not-imported","dryRun":true}'` | | `report-draft` | report-draft runs a generation over an article's iteration as a report-draft job: {"task": "sweep" \| "revise-report" \| "revise-video" \| "research" \| a media draft, "article", ...} -&gt; {jobId, iteration, warnings?}. A sweep takes "question" and "channels" (and "from"/"to"): a new iteration; a revision takes "iteration" (the one it revises) and "feedback": a new iteration. A media draft — "narrate", "cut", "onscreen", "teaser", "flips", "threads", "youtube" — takes "iteration" (a done one; "entries"? entry ids, "force"? re-drafts a field that is a draft already; narrate "cards"?) and is a step on it: it drafts fields of the iteration's video manifest, never one the operator wrote. "copyOf" N runs iteration N again on "model". "extractorModel" is an API sweep's extractor (a Claude model id; default settings.generation.models.extractor). "model" defaults to settings.generation's route for the task (one routed to code needs a model named). A Claude model runs on draft:api, capped at "maxUsd" (default by task, never above caps.max), and is refused when the day's API total has reached caps.daily; a local model runs on draft:local, through the GPU arbiter, and is unloaded when it ends. The corpus is "source" (a handle), "build" (a composed build), or the newest build holding the channels. `job cancel <id>` stops it. The log ends with @@report-draft {article, iteration, task, status, summary, usd, minutes}; --wait prints it. A research run takes "question" ("channels"? "from"/"to"?) and "autonomy" (propose \| limits \| auto; default settings.generation.research): it searches the corpus, the web and archive.org and proposes acquisitions (archive.org imports, videos, new channels — always on no site —, posts, transcription, persisting), each with its reason and evidence, enqueuing what its autonomy and the settings' caps allow through the editor's own actions; the rest waits in the iteration's proposals.json. A sweep with "iteration" N CONTINUES research run N: its question, over its channels and every channel a done acquisition wrote into, the sweep's parent N; refused while N still waits, unless "force" (what is done so far). "seed" (a new sweep's, on a Claude model) is cited markdown in the /sweep shape — umtool's research board: kept as the iteration's seed.md, the report starts from it, and the sweep verifies and extends it. "ids" (a sweep's) restricts it to those recordings: an enumeration reads only their pages and answers only their rows, a read of another is refused. A "refresh" re-fetches an iteration's scope and folds in what changed: "iteration" (default: the current report's) — its question, its recorded enumerations and every channel its citations touch. One job on draft:refresh: the editor's own sync / refresh-report / transcribe-bucket (what landed) per video channel and fetch-posts per posts channel (a platform held or cooling down is skipped; transcribe-bucket is skipped, and said, while transcription is paused or no worker is enabled), then a local build of the site holding them (never a deploy); the enumerations again (new and changed recordings) and every cited quote read again (changed words, en vs en-orig, a source gone); nothing changed ends no-change, $0 — or partial, naming what a capped search did not reach. Else, within the caps ("model", "maxUsd", "extractorModel"; past one it ends held-by-cap with the delta and the estimate), a sweep restricted to the new recordings and a revision of the report: a new refresh iteration, refresh.json beside it. "fetch": false skips the fetch and the build; "dryRun": true answers {plan} and writes nothing. Its log ends with @@report-draft {…, refresh: {status, newIds, changed, drifted, deleted, summary}}. "verdicts" proposes a verdict for each UNRULED claim of a fact-check ("article"; "claims"? only those; "model"?, "maxUsd"?): the verdict bench's prompt, one claim per call, on a model in settings.generation.verdicts.models only (refused otherwise; none named: the first of them on the verdicts route). No iteration (iteration 0): the proposals go to the article's verdicts.proposed.json, never report.json; a claim the operator ruled, or whose proposal was reviewed, is not asked. Its log ends with @@report-draft {…, verdicts: {proposed, failed, skipped, promptVersion}}. | `pnpm ops report-draft --json '{"task":"sweep","article":"demo-article","question":"What does she say about the shop?","channels":["demo-channel"]}' --wait`<br>`pnpm ops report-draft --json '{"task":"revise-report","article":"demo-article","iteration":1,"feedback":"Drop the second finding."}'`<br>`pnpm ops report-draft --json '{"task":"research","article":"demo-article","question":"Where did the shop story start?","autonomy":"propose"}' --wait`<br>`pnpm ops report-draft --json '{"task":"sweep","article":"demo-article","iteration":1}'`<br>`pnpm ops report-draft --json '{"task":"refresh","article":"demo-article"}' --wait`<br>`pnpm ops report-draft --json '{"task":"refresh","article":"demo-article","dryRun":true}'`<br>`pnpm ops report-draft --json '{"task":"triage","article":"co-host-watch","question":"Who co-hosts?","channels":["demo-channel"],"terms":"co-host"}' --wait`<br>`pnpm ops report-draft --json '{"task":"verdicts","article":"demo-factcheck"}' --wait` | | `research-approve` | research-approve settles a research run's acquisitions: {"article", "iteration", "ids"?: \["p01", …\], "approve"?: true \| false, "note"?} -&gt; {outcomes: \[{id, status?, jobId?, note?, error?}\], research: {phase, autonomy, limits, spent, proposals, waitingOn: {approval, jobs}, continuedBy, autoContinue?}}. It first refreshes every enqueued acquisition from its jobs (all done: done; one failed: failed, naming it). approve: true runs each proposal through the editor's own action (past the run's autonomy and caps, never past a standing rule); false rejects it, note saying why. No ids: the run's state now. The phase is wait (approvals or jobs pending), ready (nothing pending: continue with report-draft {"task": "sweep", "iteration": N}) or continued. An `auto` run is continued by the editor itself once ready; autoContinue says how (continued by, held for a build, refused by a cap, and why). Refused while the run's job is going. | `pnpm ops research-approve --json '{"article":"demo-article","iteration":1,"ids":["p01","p03"],"approve":true}'` | | `verdict-review` | verdict-review settles one verdict proposal: {"article", "claim", "decision": "approve" \| "reject", "verdict", "at", "note"?} -&gt; {proposal}. "verdict" and "at" are the proposal you were shown (its verdicts.proposed.json entry): a compare-and-set, refused (409) when the proposal was replaced or reviewed since, its claim changed (the proposal is stale) or was ruled meanwhile. approve sets the claim's verdict to it (through the registry); reject leaves the claim unruled. Synchronous. | `pnpm ops verdict-review --json '{"article":"demo-factcheck","claim":"c04","decision":"approve","verdict":"PARTLY","at":"2026-10-15T10:00:00.000Z"}'` | diff --git a/ENVIRONMENT.md b/ENVIRONMENT.md @@ -235,6 +235,8 @@ Read only by a test harness, a fake binary or a test-mode branch. Never set one | `E2E_ODYSEE_PAGE_FIXTURE` | unset (a headless browser) | A JSON file of recorded Odysee page reads keyed by page URL (`"*"` for any): while set, the browser lookup answers from it instead of opening a browser (with no gap between lookups), and the player-page opener opens nothing. The editor's e2e server names a file in each slot's test data (`browser-lookup.spec`). | common/ytdlp/odyseePageReader.ts, common/ytdlp/storedUrlPageOpen.ts, common/ytdlp/odyseeBrowserLookup.ts | | `E2E_UMTOOL_ORIGIN_FILE` | unset (UMTOOL_URL) | A file holding one loopback origin; while it exists, umtool is that origin for the editor's Find clips — the stub umtool `find-clips.spec` starts. The editor's e2e server names a file in each slot's test data; anything but a loopback origin in it is ignored. | common/lib/umtoolUrl.ts | | `E2E_BLUESKY_ORIGIN_FILE` | unset (the real Bluesky) | A file holding one loopback origin; while it exists, the Bluesky AppView, bsky.app and its image CDN are that origin — the fake Bluesky a spec starts (`common/testing/social/fakeBluesky.mjs`). The editor's e2e server names a file in each slot's test data (`capture-posts.spec`); anything but a loopback origin in it is ignored. | common/social/blueskyEndpoints.ts | +| `E2E_WAYBACK_ORIGIN_FILE` | unset (the real Wayback Machine) | A file holding one loopback origin; while it exists, the Wayback Machine a Wayback pages scan asks is that origin — the fake Wayback a spec starts (`common/testing/web/fakeWayback.mjs`). The editor's e2e server names a file in each slot's test data (`wayback-captures.spec`); anything but a loopback origin in it is ignored. | common/lib/waybackPages/origin.ts | +| `E2E_IMPORT_PAGE_SEAM_FILE` | unset (an import is refused until the import-page job is in the build) | Release 37 S2's seam to S1's `import-page` job: while set, each import a Captures tab or `wayback-import` queues is appended to this file as one JSON line instead (`wayback-captures.spec` reads it). The editor's e2e server names a file in each slot's test data. | common/controller/waybackImport.ts | | `E2E_AUDIO_CHECK_DEBUG_PAUSE_MS` | off | A debugging pause inside the audio check. | common/ytdlp/audioCheckedDownload.ts | | `E2E_FAKE_YTDLP_AUDIO_CHECK_MODE` | — | Fake yt-dlp: which audio-check scenario to act out. | editor/e2e/fixtures/bin/fake-ytdlp.mjs | | `E2E_FAKE_YTDLP_CHUNK_DELAY_MS` | — | Fake yt-dlp: delay between written chunks. | editor/e2e/fixtures/bin/fake-ytdlp.mjs | diff --git a/OPERATING.md b/OPERATING.md @@ -82,6 +82,28 @@ pnpm ops import-video --json '{"slug":"example","url":"https://web.archive `pnpm archilyzer archive-org refresh <slug> --dry-run`, `pnpm archilyzer wayback refresh <slug> --dry-run`, `pnpm archilyzer feeds backfill-metadata <slug> --dry-run` (or `pnpm ops feed-metadata` on the editor). +### Wayback pages: scan, then choose + +```sh +pnpm ops wayback-scan --json '{"slug":"example-pages","dryRun":true}' --wait +pnpm ops wayback-scan --json '{"slug":"example-pages"}' --wait +pnpm ops wayback-import --json '{"slug":"example-pages","year":"2014","show":"not-imported","dryRun":true}' +pnpm ops wayback-import --json '{"slug":"example-pages","year":"2014","show":"not-imported"}' +``` + +- A Wayback pages channel names its scope in `config.wayback.targets` (`{url, match: exact | prefix | host | + domain, from?, to?, mime?, include?, exclude?}`). `wayback-scan` lists what the Wayback Machine holds of them + (its CDX API, no page bodies) into `channels/<slug>/wayback-scan.json`: one row per distinct content of a page, + first and last seen. At most 50,000 rows a run (`maxRows`); a cut run continues from where it stopped, a + complete one starts a new pass that marks what it adds as new (`full: true` rescans from the start). Dry run + first: it asks nothing and logs the next request per target. +- The channel page's **Captures** tab is the scan as a table: filter by year, path and text, then **Import + selected** or **Import all in range** — one `import-page` job per row, one at a time at archive.org's pace. + `wayback-import` is the same over HTTP (`keys` or a range; at most 500 a call). +- `wayback.auto: true` (the Captures tab's toggle) lets the download lane import rows a later scan adds, at the + same pace. Off by default: nothing crawls a host unless its channel opts in. +- Offline, without the editor: `pnpm archilyzer wayback scan <slug> --dry-run`. + ## Fetch and capture posts ```sh diff --git a/common/lib/envVars.ts b/common/lib/envVars.ts @@ -232,6 +232,8 @@ const DECLARED: EnvVarDecl[] = [ { name: "E2E_ODYSEE_PAGE_FIXTURE", audience: "test", default: "unset (a headless browser)", readBy: "common/ytdlp/odyseePageReader.ts, common/ytdlp/storedUrlPageOpen.ts, common/ytdlp/odyseeBrowserLookup.ts", doc: "A JSON file of recorded Odysee page reads keyed by page URL (`\"*\"` for any): while set, the browser lookup answers from it instead of opening a browser (with no gap between lookups), and the player-page opener opens nothing. The editor's e2e server names a file in each slot's test data (`browser-lookup.spec`)." }, { name: "E2E_UMTOOL_ORIGIN_FILE", audience: "test", default: "unset (UMTOOL_URL)", readBy: "common/lib/umtoolUrl.ts", doc: "A file holding one loopback origin; while it exists, umtool is that origin for the editor's Find clips — the stub umtool `find-clips.spec` starts. The editor's e2e server names a file in each slot's test data; anything but a loopback origin in it is ignored." }, { name: "E2E_BLUESKY_ORIGIN_FILE", audience: "test", default: "unset (the real Bluesky)", readBy: "common/social/blueskyEndpoints.ts", doc: "A file holding one loopback origin; while it exists, the Bluesky AppView, bsky.app and its image CDN are that origin — the fake Bluesky a spec starts (`common/testing/social/fakeBluesky.mjs`). The editor's e2e server names a file in each slot's test data (`capture-posts.spec`); anything but a loopback origin in it is ignored." }, + { name: "E2E_WAYBACK_ORIGIN_FILE", audience: "test", default: "unset (the real Wayback Machine)", readBy: "common/lib/waybackPages/origin.ts", doc: "A file holding one loopback origin; while it exists, the Wayback Machine a Wayback pages scan asks is that origin — the fake Wayback a spec starts (`common/testing/web/fakeWayback.mjs`). The editor's e2e server names a file in each slot's test data (`wayback-captures.spec`); anything but a loopback origin in it is ignored." }, + { name: "E2E_IMPORT_PAGE_SEAM_FILE", audience: "test", default: "unset (an import is refused until the import-page job is in the build)", readBy: "common/controller/waybackImport.ts", doc: "Release 37 S2's seam to S1's `import-page` job: while set, each import a Captures tab or `wayback-import` queues is appended to this file as one JSON line instead (`wayback-captures.spec` reads it). The editor's e2e server names a file in each slot's test data." }, { name: "E2E_AUDIO_CHECK_DEBUG_PAUSE_MS", audience: "test", default: "off", readBy: "common/ytdlp/audioCheckedDownload.ts", doc: "A debugging pause inside the audio check." }, { name: "E2E_FAKE_YTDLP_AUDIO_CHECK_MODE", audience: "test", default: "—", readBy: "editor/e2e/fixtures/bin/fake-ytdlp.mjs", doc: "Fake yt-dlp: which audio-check scenario to act out." }, { name: "E2E_FAKE_YTDLP_CHUNK_DELAY_MS", audience: "test", default: "—", readBy: "editor/e2e/fixtures/bin/fake-ytdlp.mjs", doc: "Fake yt-dlp: delay between written chunks." }, diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## [Unreleased] +- **Scan a Wayback pages channel, then choose what to import.** A channel whose config names `wayback.targets` (a page, a prefix, a host or a domain, with optional dates) has a **Captures** tab: **Scan now** lists what the Wayback Machine holds of them — one row per distinct version of each page, with when it was first and last seen — without fetching a single page, at archive.org's pace, at most 50,000 rows a run; **Continue scan** picks up where a run stopped, and a later scan marks what is **new**. Filter by year, path and text, then **Import selected** or **Import all in range** (asked to confirm above 50): one import job per capture, one at a time. Rows already imported are marked and skipped. The same over HTTP: `pnpm ops wayback-scan --json '{"slug":"<slug>"}'` and `pnpm ops wayback-import --json '{"slug":"<slug>","year":"2014"}'` (both take `dryRun`); offline, `pnpm archilyzer wayback scan <slug>`. With `wayback.auto: true` the download lane imports the captures later scans add, at the same pace; it is off unless a channel turns it on. - **Focus the queues on a site, or on some channels, from a terminal.** `pnpm ops channel-priority --json '{"focus":{"kind":"site","siteId":"<id>"}}'` does what the /channels focus bar's **Focus site** does: that site's channels lead every lane, and the focus follows the site's membership. `{"kind":"channels","slugs":[…]}` focuses a list and `{"kind":"none"}` ends the focus. `focus` goes alone in the body. Needs a restart of the editor. - **The clip editor can ask an assistant to label and rank the clip finder's proposals — optionally.** A **Suggest** button in the clip editor's side column asks the model your generation settings choose (the local model, the Claude API, or a Claude Code session through `/gen`) to name each proposal in at most six words, say in one line what makes it land, and rank them; the labels show on every clip and unused proposal, and **Sort by the assistant's rank** orders both lists by them. Labels made before the clips were proposed again are marked stale, not hidden. Nothing in the cut changes: the labels are suggestions. Without a model, or with no labels, the clip editor works as before. From a shell: `pnpm ops report-draft '{"task":"clips-suggest","project":"<dir>","dryRun":true}'` shows how many proposals and what it would cost first. - **Ask the assistant about a clip, and apply what it suggests with one click.** On a comment in the clip editor, **Ask the assistant** has the model read your comment, the clip's words and the clips around it, and reply in the thread (badged "agent"). When it suggests a concrete edit — new edges, a merge with the next clip, or leaving the clip out — the reply shows an **Apply** button; nothing changes until you click it, and Apply does exactly what the clip editor's own buttons do. The editor needs `UMTOOL_URL` set to post the reply. diff --git a/editor/e2e/servers.ts b/editor/e2e/servers.ts @@ -52,6 +52,16 @@ export function blueskyOriginFile(transcriptsDir: string): string { return join(transcriptsDir, ".fake-bluesky-origin"); } +/** The file naming a slot's fake Wayback (common/lib/waybackPages/origin.ts; wayback-captures.spec). */ +export function waybackOriginFile(transcriptsDir: string): string { + return join(transcriptsDir, ".fake-wayback-origin"); +} + +/** Where a slot's import-page requests land until S1's job is in the build (controller/waybackImport.ts). */ +export function importPageSeamFile(transcriptsDir: string): string { + return join(transcriptsDir, ".import-page-seam.jsonl"); +} + /** The file naming a slot's stub umtool (common/lib/umtoolUrl.ts; find-clips.spec). */ export function umtoolOriginFile(transcriptsDir: string): string { return join(transcriptsDir, ".fake-umtool-origin"); @@ -212,6 +222,10 @@ export function slotServers(slot: number, mode: E2EMode, env: Env = process.env) editorEnv.E2E_BLUESKY_ORIGIN_FILE = blueskyOriginFile(paths.transcriptsDir); // The same for the stub umtool find-clips.spec starts (lib/umtoolUrl.ts). editorEnv.E2E_UMTOOL_ORIGIN_FILE = umtoolOriginFile(paths.transcriptsDir); + // The fake Wayback a spec starts (wayback-captures.spec), and the file the + // import-page seam records requests in (release 37 S2). + editorEnv.E2E_WAYBACK_ORIGIN_FILE = waybackOriginFile(paths.transcriptsDir); + editorEnv.E2E_IMPORT_PAGE_SEAM_FILE = importPageSeamFile(paths.transcriptsDir); // The browser lookup's recorded page reads (browser-lookup.spec): set on // every slot, so the e2e server never opens a headless browser on the // network — the player-page opener refuses under it too. diff --git a/editor/e2e/wayback-captures.spec.ts b/editor/e2e/wayback-captures.spec.ts @@ -0,0 +1,124 @@ +// The Captures tab of a Wayback pages channel (release 37 S2), end to end over +// the fake Wayback (common/testing/web/fakeWayback.mjs, its scan listing), +// named to the test server through E2E_WAYBACK_ORIGIN_FILE (e2e/servers.ts). +// The real Wayback Machine is never contacted. +// +// Scan now runs a wayback-scan job (the CDX listing, no bodies) → the table → +// filter by year → Import selected and Import all in range queue one +// import-page request per row. Until S1's import-page job is in the build the +// requests go through the seam (E2E_IMPORT_PAGE_SEAM_FILE), which this spec +// reads. + +import { test, expect } from "@playwright/test"; +import { mkdir, readFile, rm, writeFile } from "node:fs/promises"; +import path from "node:path"; +import { startFakeWayback, SCAN_CAPTURES } from "yt-dlp-transcript-common/testing/web/fakeWayback.mjs"; +import { baseUrl } from "./baseUrl"; +import { resetData, resolvePath, testPaths } from "./helpers"; +import { importPageSeamFile, waybackOriginFile } from "./servers"; + +const AUTH = { authorization: "Bearer test-worker-token" }; +const SLUG = "synth-pages"; + +async function seamLines(file: string): Promise<{ slug: string; url: string; requestedBy?: string }[]> { + const text = await readFile(file, "utf8").catch(() => ""); + return text + .split("\n") + .filter(Boolean) + .map((l) => JSON.parse(l)); +} + +test("Captures: scan on the fake → the table → filter by year → Import selected and Import all in range queue one import each", async ({ + page, + request, +}) => { + test.setTimeout(120_000); + await resetData("empty"); + const transcripts = resolvePath(testPaths().transcriptsDir); + const channelRoot = path.join(transcripts, "channels", SLUG); + await mkdir(channelRoot, { recursive: true }); + await writeFile( + path.join(channelRoot, "config.json"), + JSON.stringify( + { + handling: "transcribe", + sourceKind: "social", + name: "Synth Blog (Wayback)", + url: "https://web.archive.org/web/*/blog.example*", + wayback: { targets: [{ url: "blog.example", match: "host" }] }, + }, + null, + 2, + ), + ); + const seam = importPageSeamFile(transcripts); + await rm(seam, { force: true }); + const wb = await startFakeWayback({ captures: SCAN_CAPTURES }); + const originFile = waybackOriginFile(transcripts); + await writeFile(originFile, wb.base); + try { + await page.goto(`/channels/${SLUG}/captures`); + await expect(page.getByRole("link", { name: "Captures tab" })).toHaveAttribute("aria-current", "page"); + await expect(page.getByLabel("captures status line")).toHaveText("Not scanned yet"); + + await page.getByRole("button", { name: "Scan now" }).click(); + const status = page.getByLabel("captures status line"); + await expect(status).toContainText("7 versions of 5 pages", { timeout: 30_000 }); + await expect(status).toContainText("0 imported"); + await expect(status).toContainText("complete"); + + // One listing, no bodies: matchType host, collapsed by digest, paged. + const cdx = wb.requests.filter((r) => r.path.startsWith("/cdx/")); + expect(cdx.length).toBe(1); + const q = new URL(cdx[0].path, "http://x").searchParams; + expect(q.get("matchType")).toBe("host"); + expect(q.get("collapse")).toBe("digest"); + expect(q.get("showResumeKey")).toBe("true"); + expect(wb.requests.some((r) => r.path.startsWith("/web/"))).toBe(false); + + const table = page.getByRole("table", { name: "captures table" }); + await expect(table.locator("tbody tr")).toHaveCount(7); + const p101b = page.getByRole("row", { name: "capture /post/101/first-post P101B" }); + await expect(p101b).toContainText("2015-04-05"); + await expect(p101b).toContainText("2 of 2"); + + // Filter: the 2015 rows. + await page.getByLabel("Year").selectOption("2015"); + await page.getByRole("button", { name: "Filter" }).click(); + await expect(page).toHaveURL(/year=2015/); + await expect(table.locator("tbody tr")).toHaveCount(4); + await expect(page.getByLabel("capture count")).toHaveText("4 rows match"); + + // Import selected: two rows → two requests, each the capture the content + // was first listed at. + await page.getByLabel("Select /post/101/first-post (2015-04-05)").check(); + await page.getByLabel("Select /tagged/bread (2015-07-08)").check(); + await page.getByRole("button", { name: "Import selected (2)" }).click(); + await expect(page.getByLabel("import result")).toContainText("Queued 2 import jobs."); + expect((await seamLines(seam)).map((l) => l.url).sort()).toEqual([ + "https://web.archive.org/web/20150405000000/https://blog.example/post/101/first-post", + "https://web.archive.org/web/20150708000000/https://blog.example/tagged/bread", + ]); + + // Import all in range: the filtered four (under the confirm threshold). + await page.getByRole("button", { name: "Import all in range (4)" }).click(); + await expect(page.getByLabel("import result")).toContainText("Queued 4 import jobs."); + const lines = await seamLines(seam); + expect(lines.length).toBe(6); + expect(lines.every((l) => l.slug === SLUG && l.requestedBy === "captures")).toBe(true); + + // The same over HTTP, as a dry run: nothing queued. + const res = await request.post(`${baseUrl}/api/ops/wayback-import`, { + headers: AUTH, + data: { slug: SLUG, prefix: "blog.example/post/", dryRun: true }, + }); + const body = (await res.json()) as { ok: boolean; chosen: number; queued: { url: string; jobId?: string }[] }; + expect(res.status()).toBe(200); + expect(body.chosen).toBe(4); + expect(body.queued.every((x) => x.jobId === undefined)).toBe(true); + expect((await seamLines(seam)).length).toBe(6); + } finally { + await rm(originFile, { force: true }); + await wb.close(); + } +}); diff --git a/plans/FACTS.md b/plans/FACTS.md @@ -11032,3 +11032,46 @@ parsed to 0 cues, indexing the video textless) is CLOSED by `200a3105` (transcri a0 alone is luma). `render.slide {travel 0–0.5 (0.08), blur 0–2 (0.5), grain 0–20 (2)}` (`SLIDE_DEFAULTS`, `validateSlide` inside `validateTransitionStyle`; `slide` is a LOOK_KEY). Grain: `noise=alls=<grain>:allf=t+u` on the D/2 nearest the seam of each plain-join edge (`blurSlideEdges`, the segment's own `t`). + +## Release 37 S2 — Wayback pages: the scan (`wayback-scan.json`) and the Captures tab + +- **`channels/<slug>/wayback-scan.json`** (lib/waybackPages/scanFile.ts, written compact and atomic by + controller/waybackScan.ts; read by the Captures tab and the lane): `{format: "archilyzer-wayback-scan", version: 1, + slug, pass, passStartedAt, previousPassStartedAt?, lastScanAt?, jobId?, targets: [{key, url, match, from?, to?, + resumeKey?, complete, rows, lastScanAt?, completedAt?, passFrom?}], rows: [{originalUrl, digest, firstTs, lastTs, + count, mimetype, status, pass}], summary: {pages, versions, byYear, byPrefix}}`. One row per distinct (original URL, + digest). Text tier, never published; moves with the channel dir (rename) and goes with it (delete); a media + relocation does not touch it. **Imported state is not in it**: `imported.ts` derives it from the channel's posts + (`page.originalUrl` by `pageUrlKey` — no scheme, host without www./default port — plus `page.digest`, or for a record + with no digest a `captureTs` in the row's first..last). +- **A target's key** (`waybackTargetKey`) is `[match, url, from, to, mimes]`; include/exclude only filter. A changed + key is a new target scanned from its start; a target the config drops loses its state, its rows stay. +- **The CDX request** (`scanCdxUrl`): `url` (host/domain targets: the hostname), `matchType`, `output=json`, + `fl=original,timestamp,digest,mimetype,statuscode`, `filter=statuscode:200`, `filter=mimetype:<escaped mimes joined + by |>` (default text/html), `collapse=digest`, `from` (the later of the target's and the pass's), `to`, `limit` + (≤ 5,000), `showResumeKey=true`, `resumeKey`. The JSON answer ends `[]`, `[<key>]` when rows remain. Through + `WaybackClient.cdxPage` (the `waybackClient` singleton's paced chain). A run reads ≤ `maxRows` (50,000; ≤ 200,000) + rows and ≤ 100 requests; the file is written after every page. +- **Passes**: a run continues incomplete targets from their resume keys; when every target is complete the next run + is pass n+1 asking `from` = previous pass start − 30 days (`PASS_OVERLAP_DAYS`), `full` = pass n+1 from each + target's start. A row is **new** iff `file.pass > 1 && row.pass === file.pass`. With collapse, `count` = listed + captures (a later sighting counts only outside [firstTs, lastTs]). +- **Assets** (css/js/images/fonts/media/archives by extension, `isAssetUrl`) are dropped unless the target's + `include` matches; `exclude` always wins. +- **Queue**: `wayback-scan` and every `import-page` run on `platform:archive.org` (`WAYBACK_QUEUE`). The job kind is + drainable, `needsText`, not an ingest kind (jobKinds.test's notIngest). +- **Imports from the scan** (controller/waybackImport.ts): one `import-page` request per row + `{slug, url: https://web.archive.org/web/<firstTs>/<originalUrl>, requestedBy}`; row key `<digest> <originalUrl>`; + imported rows skipped; ≤ 500 a call (`left`). Until S1's job is on main the starter is a seam: refused, or on the e2e + server appended to `E2E_IMPORT_PAGE_SEAM_FILE`. +- **`wayback.auto`** (controller/laneWaybackAuto.ts): the download lane's channel-scoped unit after the metadata-scan + pre-pick — an opted-in channel's rows with `pass > 1` not imported, oldest first, one per unit on the `archive.org` + platform slot (`platformInFlight`/gap/back-off like any platform), the child job awaited through `onJobEnd`; the + pending list cached 60 s per channel, each row offered once per runner. +- **The Captures tab** (`/channels/<slug>/captures`; ChannelTabs shows Overview | Captures for a channel whose raw + config names `wayback.targets`): filtered server-side by `?year=&prefix=&q=&show=&page=` (100 rows a page). Labels + the spec uses: "captures status line", "captures table", rows `capture <path> <digest>`, checkboxes + `Select <path> (<YYYY-MM-DD>)`, buttons "Scan now" / "Continue scan", "Import selected (N)", "Import all in range + (N)" (inline confirm above 50, "confirm import range"), "import result", "capture count". +- **E2E**: `E2E_WAYBACK_ORIGIN_FILE` (lib/waybackPages/origin.ts) puts web.archive.org on a spec's fake; the fake's + scan listing (`scanListing`, `SCAN_CAPTURES`, `scanRefuseFrom`) answers only requests with `showResumeKey=true`.