commit fa73181d3c40021cfe3ba2875f85dd8cd71fa072
parent 88f9d97a67921dc555bc087a4cd4ac9dedea333b
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 20 Oct 2026 10:26:51 -0400
plans: release 37 lane A — the record (core.md), FACTS "page records", OPERATING "Pages from the Wayback Machine"
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
3 files changed, 213 insertions(+), 0 deletions(-)
diff --git a/OPERATING.md b/OPERATING.md
@@ -82,6 +82,36 @@ 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).
+### Pages from the Wayback Machine
+
+```sh
+pnpm ops create-channel --json '{"fields":{"name":"Old blog","handling":"transcribe","url":"https://web.archive.org/web/*/blog.example/*"}}'
+pnpm ops import-page --json '{"slug":"old-blog","url":"https://web.archive.org/web/<timestamp>/https://blog.example/a-post.html","dryRun":true}'
+pnpm ops import-page --json '{"slug":"old-blog","url":"https://web.archive.org/web/<timestamp>/https://blog.example/a-post.html"}' --wait
+pnpm ops import-page --json '{"slug":"old-blog","url":"https://blog.example/a-post.html","at":"20140301"}' --wait
+pnpm ops reextract-pages --json '{"slug":"old-blog","dryRun":true}' --wait
+```
+
+- A capture of a page that is NOT a video (a blog post, an About page, a deleted document, a group's old site) is
+ a page record in a **Wayback pages** channel (platform `webpage`): the New channel form makes one of a Wayback
+ URL of such a page (`web.archive.org/web/*/<target>*` is a prefix, `*.<host>` a domain, one page exact), or
+ choose "Wayback pages" and edit the targets (`config.wayback`, CHANNEL.md). A capture of a video stays
+ `import-video`'s.
+- `import-page` imports ONE capture: its replay URL, or the page's own URL and `at` (`YYYYMMDD[hhmmss]`) for the
+ capture nearest that date. The channel page's **Import a capture** is the same, with a date picker. One job per
+ capture, on archive.org's queue and pace; the raw (`id_`) body is fetched (at most 2 MB; html, plain text or
+ JSON), redirects followed inside the archive only, and the record names the capture it landed on. A capture
+ already held is not fetched again.
+- The body is kept under `channels/<slug>/pages/<captureTs>-<hash>/` (`raw.html.gz`, `capture.json`); the records
+ are the channel's posts (search, the MCP, a site build — the index picks them up on its next build). A record's
+ date is the page's own when it says one, else the capture's; a later capture of the same page is a version of
+ the first (`page.versionOf`).
+- `reextract-pages` (the channel page's **Re-extract**) re-reads every stored body with the extractor it goes to
+ now — no request — and replaces the records when anything changed. Offline with the editor stopped:
+ `pnpm archilyzer wayback pages reextract <slug> --dry-run`.
+- An x.com / twitter.com capture is private exactly as X posts are (`social.x.visibility`): while X is private,
+ only a Wayback pages channel whose target is on X takes one, and a public site leaves that channel out.
+
## Fetch and capture posts
```sh
diff --git a/plans/FACTS.md b/plans/FACTS.md
@@ -11032,3 +11032,62 @@ 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 lane A: page records — Wayback pages channels, import-page (verified 2026-10-20, branch `r37/core`)
+
+- **Platform `"webpage"`** is in `Platform`/`PLATFORM_VALUES`/`SOCIAL_PLATFORM_VALUES`/`isSocialPlatform`
+ (`common/lib/platform.ts`) and `PostPlatform`/`POST_PLATFORM_VALUES`/`isPostPlatform`/`postPlatformLabel` ("Web
+ page", `common/lib/posts.ts`). `detectPlatform` never answers it: a web.archive.org URL is a capture of something
+ else. A **Wayback pages channel** is `sourceKind: "social"` + `platform: "webpage"` (`isWaybackPagesChannel`,
+ `lib/waybackPages/config.ts`), so the posts index pass, `publishedMemberSlugs`, search, `get_post` and compose read
+ it with no reader of their own. `fetchPosts` and `fetchPostsAction` refuse it (`WAYBACK_PAGES_NOT_FETCHED`; info
+ for the scheduler): nothing crawls.
+- **`config.wayback`** = `{targets: [{url, match: exact|prefix|host|domain, from?, to?, mime?, include?, exclude?}],
+ collapse?: "digest"}` (`coerceWaybackPagesConfig`; an invalid target is dropped, none = the key omitted). The form
+ posts it as ONE hidden JSON field `waybackTargets` (`WaybackTargetsField.tsx`; `parseChannelForm` refuses a bad row
+ by number; `CHANNEL_FORM_FIELDS` has `wayback`, so a form save rewrites it whole — a key added inside it later must
+ get a form field). `waybackTargetFromUrl` reads `web.archive.org/web/*/<t>*` (prefix), `*.<host>` (domain),
+ `/web/2014*/…` (from = to = 2014) and a capture URL (exact). The handle is the first target's host.
+- **`Post.page`** is `PagePostInfo` (`lib/waybackPages/types.ts`); `parsePagePostInfo` (`parse.ts`, client-safe)
+ drops a page missing provenance or extractor, never the post; a kind is any `[a-z][a-z0-9-]*` (not checked against
+ `PAGE_KINDS`, so a newer extractor's records stay readable). Additive in this lane: `extractorFallback?: {from,
+ fromVersion, error}` (a site extractor threw or made nothing; the record is generic's).
+- **The client:** `WaybackClient.getCapture(ts, url, {maxBytes?})` reads `/web/<ts>id_/<url>` through
+ `ArchiveOrgClient.getBounded` (new: `redirect: "manual"`, the body streamed to the cap, the gap counted from the
+ body's end). Cap `WAYBACK_PAGE_MAX_BYTES` 2 MB (a constant; no settings key); mimetypes `PAGE_MIMETYPES`
+ (text/html, text/plain, application/json); at most `WAYBACK_MAX_REDIRECTS` 5, each inside web.archive.org and
+ re-formed as `id_`; the answer's `finalTs`/`originalUrl` are the LAST capture's. Refusals are
+ `WaybackCaptureRefusal` codes `mimetype | too-large | offsite-redirect | redirect-loop | not-archived`.
+ `closestCapture(url, at)` = one CDX request `closest=<at>&sort=closest&limit=5&filter=statuscode:200`, re-sorted by
+ distance. The process client honours `E2E_WAYBACK_ORIGIN_FILE` (`waybackTestOrigin`).
+- **On disk:** `channels/<slug>/pages/<captureTs>-<urlHash>/raw.html.gz` + `capture.json` (`StoredCapture`:
+ originalUrl, captureTs, mimetype, contentType, bytes, sha256, fetchedAt, extractor, extractorVersion,
+ extractorFallback?, requestedTs?/requestedUrl? when redirected, records = the ids it made). The dir name is
+ `pageRecordId`. Body first, then capture.json (tmp + rename each): a capture.json means a whole body. At the
+ channel root, not `data/<id>/`: the media tier never moves it.
+- **Records:** `draftToPost` (`toPost.ts`): id = itemId else pageRecordId; createdAt = publishedAt else the capture
+ time (`captureTsIso`); author = draft author else the host; threadId = `pageThreadId(originalUrl)`, a tweet's =
+ the status it answers else its own. **The split-record merge** (`mergePageRecord`, inside `upsertPosts`): the
+ later capture's facts win, `firstSeenTs` = the earliest, the stored createdAt (its shard) kept; compared by
+ `stableRecordJson(asStored(...))` because parsePost and draftToPost order keys differently. `assignPageVersions`:
+ every later whole-page capture of an original names the earliest as `versionOf`.
+- **The generic extractor** (`extractors/generic.ts`, "generic" v1): toolbar insert / `wm-ipp*` / `/_static/` /
+ wombat / `__wm.` stripped; nav, aside, form, script… and header/footer (a header inside an article kept) pruned;
+ main = `<main>`/`[role=main]`, else top-level `<article>`s, else the densest block; dates not believed after the
+ capture (+1 day); links un-rewritten and absolute; images as `/web/<ts>im_/<src>`. `extractPage` (`extract.ts`)
+ offers HTML only to `SITE_EXTRACTORS`; `decodeCaptureBody` reads the header's, else the document's, charset.
+- **import-page** (`controller/importPage.ts`): job kind `import-page` (needsText, not drainable/replayable, an
+ ingest kind) on `WAYBACK_PAGES_QUEUE` = `queueKeyForUrl("https://web.archive.org/")` = `platform:archive.org`.
+ `planImportPage` refuses (no job) a non-pages channel, a listing URL, a bare URL with no `at`, a video
+ (`videoPageOf`: "use import-video"), and — with `social.x.visibility` private — an X capture into a channel that is
+ not X-scoped (`xCaptureRefusal`). A 14-digit capture already stored is not fetched. The log ends `@@import-page
+ {…}`. Lane B's door: `startImportPageJob({slug, url, at?, requestedBy?}) → {jobId}` (throws `ImportPageRefusal`).
+ No reindex at import: the index picks the records up on its next build, as for a post fetch.
+- **reextract-pages** (`controller/reextractPages.ts`): recomputes every stored capture's records (oldest first,
+ merged), re-assigns versions, and replaces the channel's posts WHOLE with `replaceChannelPosts` (posts-server: each
+ shard tmp + rename, stale shards removed, posts-archive rewritten) when anything differs; a record whose capture is
+ not stored is kept. Stale = capture.json's extractor/version is not `chooseExtractor`'s now, or it fell back. A job
+ on the same queue as import-page (the editor's Re-extract, `pnpm ops reextract-pages`); the CLI runs in-process.
+- **X:** `isXPostsChannel` (`lib/postsVisibility.ts`) also answers true for a Wayback pages channel whose target (or
+ url) is on x.com / twitter.com / mobile.twitter.com, so `publishedMemberSlugs` leaves it out of a public site while
+ X is private.
diff --git a/plans/release-37/core.md b/plans/release-37/core.md
@@ -0,0 +1,124 @@
+# Release 37 lane A — `r37/core`: the client, the record, one-page import (as shipped)
+
+The plan of record is [`wayback-pages.md`](wayback-pages.md) ("What a record is", "What a channel is", S1). This lane
+makes a Wayback Machine capture of a page that is not a video a first-class record: a `Post` on platform `"webpage"`
+in a **Wayback pages** channel, imported one capture at a time (`import-page`), its raw body kept so its records can be
+re-derived offline (`reextract-pages`). Rulings followed: the UI works with no model (nothing here calls one); every
+CLI operation has a button (Import a capture, Re-extract); every request to archive.org goes through the polite client
+on the `platform:archive.org` queue, one capture per job, no crawling; synthetic fixtures only (the fake Wayback);
+commits end with the one Co-Authored-By trailer.
+
+## What
+
+1. **Platform `"webpage"`** — in `Platform`, `PLATFORM_VALUES`, `SOCIAL_PLATFORM_VALUES`, `isSocialPlatform`,
+ `defaultWebpageUrl` (`common/lib/platform.ts`) and `PostPlatform`, `POST_PLATFORM_VALUES`, `isPostPlatform`,
+ `postPlatformLabel` ("Web page"), `postPermalink` (`common/lib/posts.ts`). `detectPlatform` does not answer it (a
+ web.archive.org URL is a capture of something else). A Wayback pages channel is `sourceKind: "social"` +
+ `platform: "webpage"`, so the posts index pass, the per-site posts manifests, compose, search and `get_post` carry
+ its records with no reader of their own (proved through the real `buildIndex` and `compose-site`). The MCP's post
+ markdown prints a page's author plain (no "@"); a video manifest leaves a page citation out with a warning, as it
+ does a forum post. A post fetch refuses a Wayback pages channel (`WAYBACK_PAGES_NOT_FETCHED`, info for the
+ scheduler's skip): nothing is fetched unattended.
+2. **`Post.page`** (`PagePostInfo`), validated by `parsePagePostInfo` (`lib/waybackPages/parse.ts`, client-safe): a
+ page without its provenance or extractor is dropped, never the post.
+3. **`WaybackClient.getCapture(ts, url, {raw, maxBytes?})`** — the `id_` body through `ArchiveOrgClient.getBounded`
+ (new: a manual-redirect GET whose body is read to the cap and no further, the gap counted from its end). 2 MB cap
+ (`WAYBACK_PAGE_MAX_BYTES`, a constant — no settings key fits); text/html, text/plain, application/json only;
+ redirects followed by hand inside web.archive.org only (≤ 5, re-formed as `id_`), the FINAL capture's timestamp
+ and URL answered; `WaybackCaptureRefusal` (`mimetype`, `too-large`, `offsite-redirect`, `redirect-loop`,
+ `not-archived`). `closestCapture(url, at)`: one CDX request with `closest`/`sort=closest`, 200s only, re-sorted by
+ distance (`waybackCdxUrl` gained `closest`). The process client honours `E2E_WAYBACK_ORIGIN_FILE`.
+4. **Storage** — `channels/<slug>/pages/<captureTs>-<urlHash>/raw.html.gz` + `capture.json`
+ (`lib/waybackPages/store-server.ts`): body first, then capture.json, each tmp + rename. At the channel root,
+ never under `data/<id>/`, so the media tier never moves it.
+5. **The generic extractor** (`extractors/generic.ts`, v1) and **`extractPage`** (`extract.ts`): toolbar insert,
+ `wm-ipp*`, `/_static/`, wombat and `__wm.` stripped; furniture pruned; `<main>`/`[role=main]`, else top-level
+ `<article>`s, else the densest block; headings, paragraphs, `- ` list items, `> ` blockquotes, `<pre>`, link text,
+ image alts; title og:title → `<title>` → h1; author/date from JSON-LD, meta and `<time>`, a date after the capture
+ not believed; links un-rewritten and absolute against the original; images as `/web/<ts>im_/<src>`. Plain text and
+ JSON as they are. The dispatcher offers HTML to `SITE_EXTRACTORS` in order; a throw or no record falls back to
+ generic and the record says so (`page.extractorFallback`). `decodeCaptureBody` decodes by the header's, else the
+ document's, charset.
+6. **Draft → Post** (`toPost.ts`) and **the split-record merge** inside `upsertPosts`: the later capture's facts
+ win, `firstSeenTs` keeps the earliest, the stored createdAt (and shard) is kept; records compared by sorted-key
+ JSON of what a reader reads back. `assignPageVersions`: later whole-page captures of a page name the first as
+ `versionOf`. `replaceChannelPosts` (posts-server) rewrites a channel's posts whole for a re-extract.
+7. **`import-page`** (`controller/importPage.ts`): job kind on `platform:archive.org` (`needsText`, an ingest kind),
+ the ops action `{slug, url, at?, dryRun?}`, the CLI `archilyzer wayback pages import`, the channel page's **Import
+ a capture** (URL + date picker, the job linked). Refused before any job: no channel, not a pages channel, a
+ listing or a bare URL with no date, a video ("use import-video"), an X capture outside an X-scoped channel while
+ X is private. A stored capture is not fetched again. `startImportPageJob` is lane B's door.
+ **`reextract-pages`** (`controller/reextractPages.ts`): every stored capture re-read (no request), stale counted
+ (extractor/version not what it would go to now, or a fallback), records replaced when anything differs (a record
+ whose capture is not stored is kept); a job on the same queue (ops + the channel page's **Re-extract**), and the
+ CLI `archilyzer wayback pages reextract` in-process (editor stopped).
+8. **The channel kind** — `config.wayback = {targets: [{url, match, from?, to?, mime?, include?, exclude?}],
+ collapse?}` (`lib/waybackPages/config.ts`, in `channelConfigSchema.ts`, CHANNEL.md). The New channel form detects
+ a Wayback URL of a non-video page (`isWaybackPagesUrl`) or takes "Wayback pages" as the platform; targets are rows
+ (`WaybackTargetsField.tsx`) posted as one JSON field; `waybackTargetFromUrl` derives the first; the handle is its
+ host; "Fetch posts now" is not offered. `create-channel` over ops takes the same fields (`waybackTargets`).
+9. **X** — `isXPostsChannel` answers true for a Wayback pages channel scoped on x.com / twitter.com /
+ mobile.twitter.com, so a public site leaves it out while `social.x.visibility` is private.
+10. **The fake** — `fakeWayback.mjs` serves page captures raw (an article in furniture, two captures; a toolbar
+ body; 3 MB; text/plain; image/jpeg; an off-archive redirect), 302s a missing timestamp to the nearest, and its
+ CDX honours `closest`.
+
+## Interfaces
+
+- `PostPlatform` + `"webpage"`; `Post.page?: PagePostInfo`; `PagePostInfo.extractorFallback?` (additive, the one
+ change to the shared contract).
+- `WaybackClient.getCapture`, `closestCapture`, `WaybackRawCapture`, `WaybackCaptureRefusal`,
+ `WAYBACK_PAGE_MAX_BYTES`, `WAYBACK_MAX_REDIRECTS`, `waybackTestOrigin`; `ArchiveOrgClient.getBounded`,
+ `BoundedResponse`; `waybackCdxUrl(url, {closest})`.
+- `lib/waybackPages/`: `config.ts` (`WaybackTarget`, `WaybackPagesConfig`, `coerceWaybackPagesConfig`,
+ `coerceWaybackTarget`, `isWaybackPagesChannel`, `waybackTargetFromUrl`, `waybackTargetHost`), `urls.ts`
+ (`PAGE_MIMETYPES`, `parsePageCaptureAsk`, `videoPageOf`, `captureTsIso`, `isXHostUrl`, `isXTargetUrl`,
+ `isWaybackPagesUrl`), `parse.ts`, `extract.ts` (`extractPage`, `chooseExtractor`, `decodeCaptureBody`),
+ `extractors/generic.ts` (`genericExtractor`, `stripWaybackChrome`, `unrewriteWaybackUrl`, `absoluteOriginalUrl`,
+ `waybackImageUrl`), `toPost.ts` (`draftToPost`, `mergePageRecord`, `assignPageVersions`, `isWholePageRecord`,
+ `stableRecordJson`, `asStored`), `store-server.ts` (`StoredCapture`, `writeStoredCapture`, `listStoredCaptures`,
+ `readStoredCaptureBody`, `hasStoredCapture`, `countStoredCaptures`, …).
+- `controller/importPage.ts`: `planImportPage`, `importPage`, `queueImportPage`, **`startImportPageJob({slug, url,
+ at?, requestedBy?, paths?}) → {jobId}`** (throws `ImportPageRefusal`), `recordsOfCapture`, `xCaptureRefusal`,
+ `WAYBACK_PAGES_QUEUE`, `IMPORT_PAGE_JOB_KIND`, `IMPORT_PAGE_RESULT_MARKER`. `controller/reextractPages.ts`:
+ `reextractPages`, `queueReextractPages`, `REEXTRACT_PAGES_*`.
+- `posts-server.ts`: `replaceChannelPosts`. `fetchPosts.ts`: `WAYBACK_PAGES_NOT_FETCHED`.
+- Routes: `POST /api/ops/import-page`, `POST /api/ops/reextract-pages`. Actions:
+ `editor/app/channels/[slug]/waybackPagesActions.ts`.
+
+## Files
+
+common: `lib/platform.ts`, `lib/posts.ts`, `lib/posts-server.ts`, `lib/postsVisibility.ts`, `lib/channelConfig.ts`,
+`lib/channelConfigSchema.ts` (+ test's key count), `lib/archiveOrgClient.ts`, `lib/waybackClient.ts`
+(+ `waybackClient.pages.test.ts`), `lib/waybackPages/{config,urls,parse,extract,toPost,store-server}.ts`,
+`lib/waybackPages/types.ts` (one additive field), `lib/waybackPages/extractors/generic.ts`, tests
+`lib/waybackPages/{config,toPost}.test.ts`, `extractors/generic.test.ts`, `controller/importPage.ts` (+ test),
+`controller/reextractPages.ts`, `controller/fetchPosts.ts`, `jobs/jobKinds.ts`, `bin/wayback-pages.ts`,
+`bin/archilyzer.ts`, `bin/compose-site.waybackPages.test.ts`, `lib/envVars.ts`, `lib/citations/schema.ts` (two doc
+strings), `lib/report/{convert-server,convertManifest}.ts`, `testing/web/fakeWayback.{mjs,d.mts}`,
+`testing/README.md`. mcp: `src/server.ts` (one condition). editor: `app/channels/[slug]/{page.tsx,
+waybackPagesActions.ts, socialActions.ts, components/WaybackPagesPanel.tsx}`,
+`app/channels/components/{ChannelForm.tsx, WaybackTargetsField.tsx, parseChannelForm.ts (+ test),
+channelConfigToForm.ts}`, `app/api/ops/{import-page,reextract-pages}/route.ts`, `e2e/wayback-pages.spec.ts`,
+`e2e/servers.ts`, `playwright.config.ts`, `CHANGELOG.md`. scripts: `archilyzer-ops.mjs` (+ test). Docs: OPERATING.md
+("Pages from the Wayback Machine"), COMMANDS.md, CHANNEL.md, CITATIONS.md, ENVIRONMENT.md (regenerated),
+plans/FACTS.md ("Release 37 lane A: page records").
+
+## Gates
+
+See `$T/r37a-report.md` for the numbers as run; summarised here at the lane's tip.
+
+## Rulings followed / decisions
+
+- No settings key for the 2 MB cap (none fits): a constant plus the `maxBytes` option.
+- The record uses the FINAL capture after redirects (timestamp and original URL); `capture.json` keeps what was
+ asked (`requestedTs`, `requestedUrl`).
+- No reindex at import: the index picks the records up on its next build, exactly as after a post fetch (which
+ reindexes nothing either).
+- X visibility is per CHANNEL (the index and compose rule is channel-level): an X-scoped pages channel is an X
+ channel; while X is private an X capture into any other pages channel is refused, so no X capture can reach a
+ public site through a non-X channel.
+- A page kind is validated as a word, not against `PAGE_KINDS`, so an older reader keeps a newer extractor's
+ records.
+- `reextract-pages` rewrites the channel's posts whole (it may move a record's month); every other writer stays
+ append-only.