# Release 37 lane F — `r37/archive-sources`: archive.today, and any archive service, like Wayback (as shipped) The plan of record is [`wayback-pages.md`](wayback-pages.md) ("Added 2026-10-20 — lane F"). Operator, 2026-10-20: "include archive.today support like wayback, which we'll do on any other archive service we need to read". This lane puts an **archive-source layer** under the page import: the Wayback Machine becomes one source (an adapter over its existing client, no behaviour change) and archive.today the second — its timemap, its copies in every URL form, its rewritten snapshot unwrapped so the same extractors read it, its own paced client, and a headless-browser session for its check, never CAPTCHA solving. A page record says which source it came from (`page.source`, `page.archiveUrl`), `import-page` and a new read-only `archive-lookup` work across sources, the channel kind reads "Archived pages" in the UI, and a Wayback CDX 403 is a typed `excluded` refusal. Rulings followed: no model anywhere; every operation has a button (Import a capture with a source, Look up a page, Connect archive session, Settings → Archive sources); polite (one stream per source, archive.today 8 s apart and stopped by a 429); synthetic fixtures only; no real network in any test; commits end with the one Co-Authored-By trailer. ## Shared-shape changes (additive) - `PagePostInfo` (`lib/waybackPages/types.ts`): `source?: string` (absent = the Wayback Machine) and `archiveUrl?: string` (the copy's URL on that source). For such a record `waybackUrl` and `rawUrl` hold the copy's URL too (they are required): cite with `pageArchiveLink(page)` (`lib/archives/mementos.ts`), which names the source. `parsePagePostInfo` keeps both (a stored `"wayback"` is normalised away). - `StoredCapture` (`store-server.ts`): `source?`, `mementoUrl?`; `findStoredCaptureByMemento`. - `WaybackTarget` (`config.ts`): `sources?: ("wayback" | "archive.today")[]` (`targetSources(t)`; `["wayback"]` alone is not written). - `WaybackCaptureRefusalCode` gains `"excluded"`; `waybackCdxUrl` / `WaybackClient.captures` take `from`/`to`. - `DraftToPostContext.source?`, `ImportPageResult.{source, mementoUrl, refusal}`, `planImportPage`/ `queueImportPage`/`startImportPageJob`/`importPage` take `source`. - `settings.archives` (a 41st settings field). ## What 1. **The layer** `common/lib/archives/`: `ArchiveSource` (`id, label, queueKey, matchesUrl, parseMementoUrl, listCaptures, closestCapture, getCapture`), `ArchiveRefusal` (typed codes), the registry `ARCHIVE_SOURCES` + `sourceForUrl` + `archiveSource(id)` + `archiveRefusalOf(e)` + `archiveLookup` (`index.ts`), the Wayback adapter (`wayback.ts`), client-safe URL reading (`mementos.ts`, `ask.ts`). 2. **archive.today**: `archiveToday.ts` (pure: timemap link format, copy facts from Memento headers else the header bar, the check page, the unwrap, the media map) and `archiveTodayClient.ts` (one chain; gap 8 s + up to 25 % jitter; manual redirects inside archive.today; 502/503/504 retried; a 429 stops with a sentence and rests the client 30 min; a check is refused, after one read through the headless archive profile when allowed). One canonical host from settings for all seven names. `archiveTodaySession.ts`: the profile, `connectArchiveSession` (headed, only on the operator's click), `archiveSessionBrowser` (headless; waits a check out, never clicks). 3. **Import**: `import-page` takes an archive.today copy (`/`, `//`, `/newest|oldest/`) or `{url, at, source: "archive.today"}` (one timemap request), on `platform:archive.today`; the copy is stored AS SERVED with `source` + `mementoUrl` in `capture.json` and unwrapped each time it is read (`extractInputOfCapture`, shared with `reextract-pages`' staleness check); a short id is checked against the stored copies before any request, and for video / X after the read. The New channel form's kind reads **Archived pages** and reads an archive.today copy's URL as a target on archive.today; each target row has a sources choice. 4. **Excluded**: `WaybackExcludedError` (an `ArchiveOrgRequestError` 403) from `captures`/`closestCapture`, `WaybackCaptureRefusal("excluded")` from `getCapture`, `isWaybackExcluded`, `waybackExcludedOf` — surfaced by `wayback-lookup` (403, `refusal: "excluded"`), `import-page` and `archive-lookup` as "excluded from the Wayback Machine (cause unknown)". 5. **Ops / CLI / UI**: `archive-lookup {url, source?, limit?}`; `import-page` `source`; `archilyzer archive lookup`, `wayback pages import --source`; the channel page's Import a capture (a source select), **Look up a page** (each source's copies, an Import per copy), **Connect archive session**; Settings → **Archive sources** (host, gap, cool-down, the browser fallback, the session line and Connect). 6. **The fake**: `common/testing/web/fakeArchiveToday.mjs` (timemaps, copies wrapped as archive.today wraps them — `wrapLikeArchiveToday` — its redirects, a CAPTCHA page at any status, a plain 429; lane C's fixtures as copies via `fixtureCopy`), and `fakeWayback.mjs`'s `excluded` option (its own block). ## Adding an archive source One module and one registry entry; nothing else names a source. 1. `common/lib/archives/.ts` (pure reading: its listing format, a copy's facts, an unwrap if its copies are rewritten) and `Client.ts` (its paced client: one chain, its own gap, a 429 that stops, `E2E__ ORIGIN_FILE` for the e2e fake). Implement `ArchiveSource` (`types.ts`): `matchesUrl`, `parseMementoUrl`, `listCaptures`, `closestCapture`, `getCapture` — `getCapture` answers the body AS SERVED (what is stored) and `page`, the copy as the extractors read it; refusals are `ArchiveRefusal` with the existing codes. 2. Add its id to `ARCHIVE_SOURCE_IDS` (`types.ts`), its label to `ARCHIVE_SOURCE_LABELS` (`mementos.ts`), its URL form to `mementoSourceOf`, its id to `WAYBACK_TARGET_SOURCES` (`waybackPages/config.ts`, a leaf), and its entry to `ARCHIVE_SOURCES` (`index.ts`). 3. Teach `parseArchiveCaptureAsk` (`ask.ts`) its copy URLs, `importPage` a branch like `importArchiveTodayCopy` (or generalise that one: it already only uses the `ArchiveSource` surface plus the store), and `extractInputOfCapture` its unwrap; `importPageQueueOf` its queue. 4. A fake under `common/testing/web/`, unit tests (URL forms, listing parse, unwrap parity on lane C's fixtures, pacing, its 429 and its check), and its settings in `archives/settings.ts`. ## Interfaces (for lanes B, D, E after merge) - **B (scan/Captures):** `targetSources(target)` to know which sources a target scans; `archiveSource(id).listCaptures(url, {from, to, limit})` for a source other than Wayback; wrap `cdxPage` errors with `waybackExcludedOf(e, url)` (or check `isWaybackExcluded`) to show "excluded from the Wayback Machine (cause unknown)"; Import selected passes a row's `mementoUrl` to `startImportPageJob({slug, url: mementoUrl})` (an archive.today copy URL routes itself). - **D (cite):** `pageArchiveLink(page)` → `{source, label, url}` for every citation, shot and moment page of a page record — never `page.waybackUrl` as "Wayback" alone; `archiveSourceLabel(page.source)`. - **E (live):** `archiveLookup(url, {source?})` for availability across sources; `ARCHIVE_SOURCES` / `archiveSource("archive.today")` for find-copy; `archiveRefusalOf(e)` to read any source's refusal. ## Gates All through the session's locks, from the worktree root. Baseline (main b8458892 + this branch's first edits in flight): common 4764 tests (the 4 fails were this lane's own half-written env/settings docs, so 4762 pass / 2 skipped clean), editor 356/356, mcp 379/379, test:scripts 1317 (1313 pass / 4 skipped). Final, on the branch merged with main through r38/x-search (`60d35f87` + the regenerated CHANNEL.md/COMMANDS.md): - `pnpm -r … exec tsc --noEmit`: **clean** (also clean before each code commit and after the B and E merges). - common: **4919 tests / 4915 pass / 2 fail / 2 skipped** — the 2 were `cli-docs.test.ts` and `fileSchemaDocs.test.ts` (COMMANDS.md / CHANNEL.md not yet regenerated after the x-search merge); regenerated, those files and `settingsSchema.test.ts` re-run **39 / 39**. Before the x-search and D merges (B + E merged): **4839 / 4837 / 0 / 2**. This lane's own tests: `lib/archives/{mementos,archiveToday,archiveTodayClient,wayback}.test.ts`, `controller/importPage.archiveToday.test.ts` (+ B's form-save test extended with `sources`). - editor unit: **368 / 368** (357 / 357 after B + E). - mcp: **384 / 384**. - test:scripts: **1329: 1325 pass / 0 fail / 4 skipped** (one new: archive-lookup + import-page source). - Docs: `docs env --check`, `docs files --check`, `docs cli --check`, `settings example --check`: **all 0**. - e2e (editor, start mode, stamp `cbf0857e60a0` at `60d35f87`, build 297 s): `wayback-pages.spec.ts` + `archive-today-pages.spec.ts` **2 / 2 passed (1.1 min)** — archive-today-pages 31.6 s, wayback-pages 15.1 s. ## Rulings followed / decisions - **The stored body is the copy AS SERVED** (archive.today's rewritten snapshot, bar and all); it is unwrapped each time it is read, so a better unwrap is a `reextract-pages`, never a refetch. `getCapture` answers both (`body`, `page`). - **Records keep the id scheme** (`pageRecordId(captureTs, originalUrl)`): a Wayback capture and an archive.today copy of one page at the same second would share a record; judged negligible, and the second is not stored again. - **`waybackUrl`/`rawUrl` hold the archive.today copy's URL** for such a record (the fields are required; an older reader still links the copy) and `archiveUrl` + `source` say whose; `pageArchiveLink` is the one reader to use. - **A 429 from archive.today is never retried**: the run stops with a sentence and the process client rests 30 min (settable). 502/503/504 are retried three times. A check page at any status is a check, not a rate limit. - **The browser fallback is one headless read on the archive profile** (the forum browser's profile code), only when `archives.archiveTodayBrowser` is on and no e2e fake is active; it waits a check out and never clicks. A window opens only on Connect. - **Nearest by time**, not by digits, for archive.today (the Wayback client's CDX re-sort by digit distance is A's and untouched). - **archive.today's layout is as known**, unverified live (synthetic fixtures only): `#HEADER`/`#CONTENT`, `/o//` links, `old-src` images, Memento headers. If a live copy drops class names, site extractors will not claim it and the generic one reads it; the raw copy is kept for a later re-extract. - **The panel's region label stays "Wayback pages"** (an e2e contract of lanes A and B); only the New channel form's kind is renamed "Archived pages". - **find-copy's page mode (lane E)** asks `nearestAcrossSources` (Wayback, then archive.today; an exclusion passes on) and imports the row's own copy URL; given an explicit Wayback client (its tests) it stays Wayback-only. - **`cdxPage` (lane B)** maps a 403 to `WaybackExcludedError` (still an `ArchiveOrgRequestError` 403). - **`archilyzer archive lookup`** was added beside the ops action so the orchestrator can look without an editor.