Archilyzer · Source

archilyzer

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

commit 24ac4494d051136db8a61c8e8e9087d21d4d473d
parent d99e1bfbafe002c106c20141ce46f20c74a2d3a7
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 20 Oct 2026 15:35:29 -0400

plans: release 37 lane E — the record (live.md), FACTS "liveness, Save Page Now, find-copy for pages", OPERATING

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

Diffstat:
MOPERATING.md | 30++++++++++++++++++++++++++++++
Mplans/FACTS.md | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
Aplans/release-37/live.md | 128+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 209 insertions(+), 0 deletions(-)

diff --git a/OPERATING.md b/OPERATING.md @@ -134,6 +134,36 @@ pnpm ops wayback-import --json '{"slug":"example-pages","year":"2014","show":"no 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`. +### Is the original still up? Save it now; find a gone page's copy + +```sh +pnpm ops check-post-availability --json '{"slug":"old-blog"}' --wait +pnpm ops save-page-now --json '{"url":"https://blog.example/still-up.html","slug":"old-blog","dryRun":true}' +pnpm ops save-page-now --json '{"url":"https://blog.example/still-up.html","slug":"old-blog"}' --wait +pnpm ops find-copy --json '{"article":"<article>","pages":true,"dryRun":true}' --wait +pnpm ops find-copy --json '{"siteId":"<site>","pages":true,"channel":"old-blog"}' --wait +``` + +- **Originals** (the channel page's **Check originals**, `check-post-availability`): each page record's ORIGINAL + URL asked at its own site — never the Wayback Machine — one request per distinct URL, through the editor's web + pacer (3 s apart). `available` (a 2xx on the same site), `deleted` (404/410, or X's, Tumblr's, Google Docs' or + YouTube's "does not exist" page), `account_unavailable` (suspended, not shared), `error` otherwise, with the + status. A deleted original means the Wayback copy is the only copy; the record reads as deleted everywhere a + deleted post does (`posts-availability.json`, merged by the index). +- **Save Page Now** ("Ask the Wayback Machine to capture this now", on the channel page: any URL, or a record whose + original is still up): archive.org captures the page alone, the job waits for it, then imports the capture + into the channel. It needs archive.org's S3 keys (archive.org/account/s3.php): `ARCHIVE_ORG_S3_ACCESS` and + `ARCHIVE_ORG_S3_SECRET` in the editor's environment, or two such lines in the mode-600 file + `settings.archiveOrg.s3KeyFile` names (default `~/.config/archilyzer/archive-org.env`). Without them the button is + off and says why. One capture at a time, on archive.org's queue. Other code starts one with + `startSavePageNowJob({url, slug})` (`common/controller/savePageNow.ts`). +- **find-copy, page mode** (`"pages": true`): every `page` citation of a report whose original is gone gets the + Wayback capture nearest the citation's date imported into the Wayback pages channel named (`"channel"`), else + the one whose targets cover the page; a cited page record whose original is gone has its capture imported again + only when its body is not stored. A live page is left (save it now instead). The log's `@@find-copy` names, per + citation, the record to cite (`pointTo`) and the citation as a `post` citation of it (`as`); the report itself + is not rewritten. Dry run first: it asks the same paced questions and imports nothing. + ## Fetch and capture posts ```sh diff --git a/plans/FACTS.md b/plans/FACTS.md @@ -11186,3 +11186,54 @@ parsed to 0 cues, indexing the video textless) is CLOSED by `200a3105` (transcri brace-matched string-aware and `JSON.parse`d, or — when assigned as a JS string — unescaped (`\xNN`, `\uNNNN`) then parsed; renderers found by key anywhere (`channelAboutFullMetadataRenderer` | `aboutChannelViewModel`, `c4TabbedHeaderRenderer` | `pageHeaderViewModel`, `channelMetadataRenderer`). + +## Release 37 lane E: liveness, Save Page Now, find-copy for pages (verified 2026-10-20, branch `r37/live`) + +- **A page record's availability is its ORIGINAL URL's**, never the Wayback Machine's: `checkPostAvailability` + branches on `isWaybackPagesChannel` to `controller/checkPageAvailability.ts` (no fetcher needed). One request per + distinct `page.originalUrl` (`groupByOriginalUrl`); every record sharing it gets the verdict; `limit` counts URLs; + `stale` orders URLs by the OLDEST check among their records. The request side is + `lib/waybackPages/liveness-server.ts` `checkOriginalUrl`: through `webPacer` (3 s gap, 429/503 backed off), behind + `fetchRefusal` (the web fetch's private-host fence) on every hop, HEAD with manual redirects (≤ 5), a GET instead + when the HEAD answers 403/405/501 or when the final host has a gone-page marker (body read to 256 KB). Verdicts + (`lib/waybackPages/liveness.ts`): 404/410 `deleted`; 2xx on the same site (`sameSite`: www, http→https, same + registrable domain, two-label suffixes, twitter.com≡x.com, youtu.be≡youtube.com) `available` unless a + `PAGE_GONE_MARKERS` row matches the folded text; a 2xx after a redirect to another site, any other status, no + answer or a fence refusal `error`. Marker rows: X no-account / no-page (`deleted`), X suspended + (`account_unavailable`), Tumblr "There's nothing here" (`deleted`), Google Docs "file … does not exist" + (`deleted`) / "You need access|permission" (`account_unavailable`), YouTube "This channel does not exist" + (`deleted`) / terminated (`account_unavailable`) — each on its own hosts only. +- **`posts-availability.json` records gained `status?: number | null` and `reason?: string`** (the latest answer; + `readPostAvailability` keeps them; `mergePostAvailability(existing, obs, at, details?)` — the 4th arg optional). + History is still appended only on a change. The index's `isDeleted` comes from `deleted` as for every post. + `PAGE_ORIGINAL_GONE_LABEL` ("Original gone — the Wayback Machine copy is the only copy") is exported from + `liveness.ts` for the citation surfaces; nothing renders it yet. +- **Save Page Now** (`controller/savePageNow.ts`, job kind `save-page-now`, queue `platform:archive.org`, not + drainable/replayable): SPN2 `POST https://web.archive.org/save` (`url`, `capture_outlinks=0`, `Authorization: LOW + <access>:<secret>`) → `job_id`; `GET /save/status/<job_id>` every `SPN_POLL_MS` 10 s, at most `SPN_MAX_POLLS` 30; + success → `waybackPageUrl(timestamp, original_url)` and, with a slug, `startImportPageJob` (an import-page job + queued behind it; a refused import is `importError`, the capture stands). Requests go through + `WaybackClient.send` → `ArchiveOrgClient.send` (new: any method, same chain/gap/retry; a non-retryable status is + handed back with its body). Keys (`lib/waybackPages/savePageNow-server.ts` `readSpnKeys`): env + `ARCHIVE_ORG_S3_ACCESS` + `ARCHIVE_ORG_S3_SECRET` (both), else the mode-600 file `settings.archiveOrg.s3KeyFile` + (default `~/.config/archilyzer/archive-org.env`, lines `ARCHIVE_ORG_S3_ACCESS=` / `ARCHIVE_ORG_S3_SECRET=`); a + group/other-readable file is refused; a settings value that is not a path is refused (`looksLikeS3Key`, also in + `/api/ops/settings`). `redactSpnKeys` runs on every log line and error. Lane B's door: `startSavePageNowJob({url, + slug?})` (throws `SavePageNowRefusal`). +- **find-copy, page mode** (`publish/findCopyPages.ts`, ops `find-copy` with `pages: true`, a `find-copy` job on + `platform:archive.org`): `page` citations (grouped by URL) → `checkOriginalUrl` → gone (`deleted` | + `account_unavailable`) → the channel named or `channelsCovering` (a target's exact/prefix/host/domain over the + URL, `targetCoversUrl`) → held (the channel already has a record of the URL: no fetch) or `closestCapture(url, + captureAtOf(citation))` (its `date`, else its archiveUrl's timestamp, else today) → `importPage` inline (the run is + on the archive.org queue). `post` citations of a pages channel's record whose availability is gone: held when + `hasStoredCapture`, else its capture imported again. Each item carries `pointTo {channel, id}` (the record whose + text holds the quote, else the first) and `as` (the page citation as a `post` citation: `pageCitationAsPost`). + **The report is never rewritten here** (lane D's Import-this-capture owns rewriting with a fallback). `max` + default 10, at most 100. +- **The fake** (`testing/web/fakeWayback.mjs`, lane E block): `POST /save` (keys `FAKE_SPN_ACCESS` / + `FAKE_SPN_SECRET`, `spn.busyTimes` 429s, `spn.refuseUrls`), `GET /save/status/<id>` (`spn.pendingPolls`, then + success at `SPN_CAPTURE_TS`, or `spn.failUrls` → error:not-found); a saved page is then served raw like a page + capture; `wb.spnForms`, `wb.spnCaptures`; `requests[].method`. +- New ops: `check-post-availability {slug, mode?, limit?}` (any posts channel), `save-page-now {url, slug?, + dryRun?}`. UI: `components/WaybackLivePanel.tsx` under the pages panel (Check originals, the gone table, Save Page + Now field + per-live-record Capture now; off with `spnOffSentence` when no keys). diff --git a/plans/release-37/live.md b/plans/release-37/live.md @@ -0,0 +1,128 @@ +# Release 37 lane E — `r37/live`: liveness and saving what is still up (as shipped) + +The plan of record is [`wayback-pages.md`](wayback-pages.md) ("S5"). A page record (lane A) is a capture of a page; +this lane answers whether the page's ORIGINAL is still up — when it is not, the Wayback copy is the only copy — asks +the Wayback Machine to capture a page that is still up (Save Page Now), and teaches find-copy to find a copy of a +gone page a report cites. Rulings followed: no model anywhere; every operation has a button (Check originals, Ask the +Wayback Machine to capture this now, Capture now per live record) and an ops action; every archive.org request goes +through the polite Wayback client on the `platform:archive.org` queue, every original-site request through the +editor's web pacer — never a burst, never the Wayback Machine for liveness; synthetic fixtures only (the fake +Wayback's new SPN block, stub original sites); the S3 keys are never a setting value, never logged; commits end with +the one Co-Authored-By trailer. + +## What + +1. **Availability of a page record = its original URL's** (`controller/checkPageAvailability.ts`, reached from + `checkPostAvailability` for a Wayback pages channel). One request per distinct original URL (a split capture's + records and a page's versions share it), every record of it gets the verdict; `limit` counts URLs; `stale` orders + by the oldest check among a URL's records. The request (`lib/waybackPages/liveness-server.ts` + `checkOriginalUrl`): through `webPacer`, the web fetch's fence on every hop, HEAD with redirects followed by hand + (≤ 5), a GET when the HEAD is refused (403/405/501) or the platform has a "gone" page (body to 256 KB). The verdict + (`lib/waybackPages/liveness.ts`): `deleted` (404/410, or a `PAGE_GONE_MARKERS` row — X's "This account doesn't + exist" / "this page doesn't exist", Tumblr's "There's nothing here", Google Docs' "Sorry, the file you have + requested does not exist", YouTube's "This channel does not exist"), `account_unavailable` (X suspended, a Doc + not shared, a terminated YouTube account), `available` (2xx after redirects on the same site), `error` otherwise + with the status. Stored in `posts-availability.json` with the answer's `status` and `reason` (additive fields); + the index's `isDeleted` follows as for any post. The channel page's **Originals** (Check originals, "N of M + original URLs checked · K gone", the gone table with "the only copy" → the Wayback copy); ops + `check-post-availability` (new door, any posts channel); the CLI `archilyzer posts check` reaches the same branch. +2. **Save Page Now** (`controller/savePageNow.ts`, `lib/waybackPages/savePageNow{,-server}.ts`): job kind + `save-page-now` on `platform:archive.org`: SPN2 `POST /save` (`url`, `capture_outlinks=0`, `Authorization: LOW + <access>:<secret>`), status polled every 10 s (≤ 30), then with a slug an `import-page` job of the capture + (`startImportPageJob`). Keys: `ARCHIVE_ORG_S3_ACCESS` + `ARCHIVE_ORG_S3_SECRET` in the environment, else the + mode-600 file the new setting `archiveOrg.s3KeyFile` names (default `~/.config/archilyzer/archive-org.env`); + refused when others can read it; a settings value that is not a path is refused (also by `/api/ops/settings`, + without echoing it); `redactSpnKeys` over every log line and error. Refused before any request: no keys (the + button is off with that sentence), not http(s), a Wayback URL, not a pages channel, a video, X while private. + Requests through `WaybackClient.send` → `ArchiveOrgClient.send` (new: any method, same chain, gap and retry; a + non-retryable status handed back with its body). UI: the channel page's **Save Page Now** field ("Ask the Wayback + Machine to capture this now", also the plain field for a scan target's URL) and **Capture now** on each record + whose original answered. Ops `save-page-now {url, slug?, dryRun?}`. Lane B's door: `startSavePageNowJob({url, + slug?})`. +3. **find-copy, page mode** (`publish/findCopyPages.ts`; ops `find-copy` with `"pages": true`, `channel?`, `max?`, + `dryRun?`; one `find-copy` job on `platform:archive.org`): every `page` citation (grouped by URL) whose original is + gone → the channel named or the one whose targets cover it (`targetCoversUrl`) → held (a record of the URL is + already there) or the capture nearest the citation's date (`captureAtOf`: its date, else its archiveUrl's + timestamp, else today) via ONE `closestCapture`, imported inline (`importPage`); a cited page record whose + original is gone: held when its capture is stored, else imported again. Live pages are left ("save it now"), an + uncovered page is `no-channel`, a never-captured one `none-found`, a check that failed `error`. Each item names + `pointTo` (the record whose text holds the quote, else the first) and `as` (the page citation as a post + citation). Dry run: the same paced questions, nothing imported. +4. **The fake** (`testing/web/fakeWayback.mjs`, its own block): SPN `POST /save` and `GET /save/status/<id>` + (pending → success, 401 on wrong keys, 429s, refused and failed URLs), the saved page served raw afterwards, + `wb.spnForms` / `wb.spnCaptures`, `requests[].method`. + +## Interfaces + +- `lib/waybackPages/liveness.ts`: `PAGE_GONE_MARKERS`, `pageGoneMarker`, `hasGoneMarkers`, `foldPageText`, + `classifyOriginalAnswer`, `sameSite`, `siteOf`, `bareHost`, `groupByOriginalUrl`, `OriginalCheck`, + `PAGE_ORIGINAL_GONE_LABEL`. `liveness-server.ts`: `checkOriginalUrl(url, {pacer?, resolve?, allowPrivate?, + signal?})`, `LIVENESS_MAX_BODY_BYTES`. +- `controller/checkPageAvailability.ts`: `checkPageAvailability`, `selectUrlsToCheck`. + `CheckPostAvailabilityOptions.pageCheck?` (tests). +- `posts.ts` `PostAvailabilityRecord.status?` / `reason?`; `posts-server.ts` `mergePostAvailability(…, details?)`. +- `lib/waybackPages/savePageNow.ts`: `SPN_SAVE_URL`, `spnStatusUrl`, `spnSaveBody`, `spnAuthorization`, + `parseSpnSubmit`, `parseSpnStatus`, `spnOffSentence`, `SpnKeys`. `savePageNow-server.ts`: `readSpnKeys`, + `redactSpnKeys`. +- `controller/savePageNow.ts`: `planSavePageNow`, `savePageNow`, `queueSavePageNow`, **`startSavePageNowJob({url, + slug?, requestedBy?, paths?}) → {jobId}`** (throws `SavePageNowRefusal`), `savePageNowAvailability()`, + `SAVE_PAGE_NOW_JOB_KIND`, `SAVE_PAGE_NOW_RESULT_MARKER`, `SPN_POLL_MS`, `SPN_MAX_POLLS`. +- `ArchiveOrgClient.send`, `WaybackClient.send`. `archiveOrgTorrent.ts`: `ArchiveOrgFetchSettings.s3KeyFile`, + `DEFAULT_ARCHIVE_ORG_S3_KEY_FILE`, `looksLikeS3Key`. +- `publish/findCopyPages.ts`: `findPageCopies`, `citedPages`, `captureAtOf`, `targetCoversUrl`, `channelsCovering`, + `recordForQuote`, `pageCitationAsPost`, `defaultFindPageCopiesDeps`, `FIND_PAGE_COPY_DEFAULT_MAX`, + `FIND_PAGE_COPY_MAX_LIMIT`. +- Routes `POST /api/ops/check-post-availability {slug, mode?, limit?}`, `POST /api/ops/save-page-now {url, slug?, + dryRun?}`, `POST /api/ops/find-copy {…, pages: true, channel?, max?, dryRun?}`. Actions + `editor/app/channels/[slug]/waybackLiveActions.ts`. Component `components/WaybackLivePanel.tsx` (state from + `waybackLiveState.ts`). + +## Files + +common: `lib/waybackPages/{liveness,liveness-server,savePageNow,savePageNow-server}.ts` (+ `liveness.test.ts`), +`controller/{checkPageAvailability,savePageNow}.ts` (+ tests), `controller/checkPostAvailability.ts` (one branch), +`publish/findCopyPages.ts` (+ test), `lib/posts.ts`, `lib/posts-server.ts`, `lib/archiveOrgClient.ts`, +`lib/waybackClient.ts`, `lib/archiveOrgTorrent.ts`, `lib/settingsSchema.ts`, `lib/envVars.ts`, `jobs/jobKinds.ts`, +`bin/archilyzer.ts` (one description), `testing/web/fakeWayback.{mjs,d.mts}`, `testing/README.md`. editor: +`app/channels/[slug]/{page.tsx, waybackLiveActions.ts, waybackLiveState.ts, components/WaybackLivePanel.tsx}`, +`app/api/ops/{check-post-availability,save-page-now}/route.ts`, `app/api/ops/find-copy/route.ts`, +`app/api/ops/settings/route.ts`, `e2e/wayback-live.spec.ts`, `CHANGELOG.md`. scripts: `archilyzer-ops.mjs` (+ +test). Docs: OPERATING.md, COMMANDS.md, SETTINGS.md, ENVIRONMENT.md (regenerated), plans/FACTS.md. + +## Commits + +| sha | what | +|---|---| +| `442129c2` | the common half: liveness (markers, verdicts, the request), the pages branch of check-post-availability, Save Page Now (keys, client send, job), find-copy's page mode, the fake's SPN block, ops actions, generated docs | +| `fbd569ae` | the editor half: the channel page's Originals and Save Page Now, the ops routes (check-post-availability, save-page-now, find-copy pages, the settings refusal), e2e spec | +| (this) | the record, FACTS, OPERATING | + +Branched from main at d261ab33; main (14947e67, lane B) merged in before the first commit (three keep-both +conflicts: OPERATING.md, fakeWayback.mjs/.d.mts). + +## Gates + +All through the session's locks, from the worktree root. + +- `pnpm -r --no-bail --workspace-concurrency=1 exec tsc --noEmit`: clean on the merged tree before the commits. +- common: start (d261ab33) **4764 / 4762 pass / 0 fail / 2 skipped**; after (on 14947e67 + this lane) **4805 / + 4803 / 0 / 2** (+18 of this lane: liveness 7, checkPageAvailability 3, savePageNow 5, findCopyPages 3; the rest + lane B's). +- editor unit: 356 → **357 / 357** (lane B's +1; none of this lane's). +- test:scripts: 1316 (1312 + 4 skipped) → **1317: 1313 pass / 0 fail / 4 skipped** (+1: the ops actions' usage). +- Docs: `docs env --check`, `docs files --check`, `docs cli --check`, `settings example --check`: all 0 + (COMMANDS.md, ENVIRONMENT.md, SETTINGS.md, settings.json.example regenerated). +- e2e (editor, start mode, stamp `131742a50d76` at `fbd569ae`; the build 1116 s in the heavy slot): + `wayback-live.spec.ts` + `wayback-pages.spec.ts` **2 / 2 passed** (58.5 s; 25.6 s + 14.2 s). + +## Rulings followed / decisions + +- Liveness never asks the Wayback Machine, and an `error` is never a deletion (a 403 wall, a 5xx, a redirect to + another site, a DNS failure, the fence). +- A suspended account / an unshared document is `account_unavailable` (the enum's "may reverse"), not `deleted`. +- The S3 keys follow the Claude API key's pattern: environment first, else a mode-600 file whose PATH is the setting. +- SPN captures the page alone (`capture_outlinks=0`); the import is its own `import-page` job queued behind. +- find-copy's page mode imports inline (its job is on the archive.org queue) and does NOT rewrite the report: it + answers `pointTo` / `as`; rewriting a citation (with its fallback) is the report editor's (lane D). +- The availability check of a pages channel runs on the channel's own queue (`platform:webpage`), not archive.org's + (it never asks archive.org).