Archilyzer · Source

archilyzer

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

commit 2436ad41311b6419487a524cf1cb7f956abb0fc1
parent de1a0d84df4f01cd57eb325a52dade7c55530719
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 20 Oct 2026 09:01:58 -0400

wayback pages: the release 37 contract — page facts, the extractor interface, record ids, the site-extractor registry

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

Diffstat:
Acommon/lib/waybackPages/extractors/index.ts | 7+++++++
Acommon/lib/waybackPages/types.ts | 119+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 126 insertions(+), 0 deletions(-)

diff --git a/common/lib/waybackPages/extractors/index.ts b/common/lib/waybackPages/extractors/index.ts @@ -0,0 +1,7 @@ +// The site extractors, in the order a capture is offered to them (the first +// whose `matches` is true wins; none = the generic extractor). Release 37's +// S3 adds one import + one entry per kind here; nothing else edits this list. + +import type { PageExtractor } from "../types"; + +export const SITE_EXTRACTORS: readonly PageExtractor[] = []; diff --git a/common/lib/waybackPages/types.ts b/common/lib/waybackPages/types.ts @@ -0,0 +1,119 @@ +// Wayback pages (release 37, plans/release-37/wayback-pages.md): a non-video +// Wayback Machine capture as a first-class record — a Post on platform +// "webpage". This file is the CONTRACT the release's lanes code against: the +// record's `page` facts, what an extractor is, and how a record's id is made. +// Types and pure helpers only; no I/O. + +import { createHash } from "node:crypto"; +import type { WaybackProvenance } from "../wayback"; +import type { ForumPostInfo, PostMedia, PostRef } from "../posts"; + +// What an extractor recognised the capture as. "generic" is the fallback for +// every page no site extractor claims (articles, personal sites, Newgrounds). +export const PAGE_KINDS = [ + "generic", + "tumblr-post", + "tumblr-index", + "tweet", + "x-profile", + "forum-post", + "gdoc", + "yt-about", +] as const; +export type PageKind = (typeof PAGE_KINDS)[number]; + +// The facts of one capture a record came from (Post.page). Provenance is never +// lost: the original URL, the capture's timestamp, the replay URL and the raw +// (`id_`) URL are always present. +export type PagePostInfo = WaybackProvenance & { + kind: PageKind; + // From CDX when known. + title?: string; + mimetype?: string; + digest?: string; + status?: number; + // The content's own date (ISO-8601) when the extractor can read it; the + // record's createdAt is this, else the capture time. + publishedAt?: string; + // A split record (one item of a capture that holds many) seen in several + // captures is ONE record: the latest capture's facts win, the first + // capture's timestamp is kept here. + firstSeenTs?: string; + // The id of the first imported capture of the same originalUrl (a whole-page + // record that is a later version of a page already held). + versionOf?: string; + // The capture held only a shell (a JS app's frame, a doc's edit page): the + // record exists so the capture is accounted for, its text says so. + noContent?: boolean; + // Which extractor made the record, and its version, so a re-extract knows + // what is stale. + extractor: string; + extractorVersion: number; + // Tags the page gives the item (Tumblr tags). + tags?: string[]; +}; + +// What an extractor hands back per record, before it becomes a Post. The +// importer fills id, slug, channelSlug, platform, uploadDate, threadId, url +// and the provenance half of `page`. +export type PageRecordDraft = { + kind: PageKind; + // A stable id for an ITEM inside a capture: "tumblr-<postId>", + // "tweet-<statusId>", "kf-<postId>". Absent = the record is the whole page, + // and its id is pageRecordId(captureTs, originalUrl). + itemId?: string; + // The item's own permalink when it has one (a tweet's status URL, a Tumblr + // post's URL); else the capture's original URL is the record's url. + url?: string; + title?: string; + author?: string; + authorName?: string; + publishedAt?: string; + text: string; + links: string[]; + media?: PostMedia[]; + tags?: string[]; + noContent?: boolean; + replyTo?: PostRef; + quoted?: PostRef; + repostOf?: PostRef; + isReply?: boolean; + isRepost?: boolean; + // forum-post records: the shape the live forum channel uses, so the same + // thread's ids line up. + forum?: ForumPostInfo; +}; + +export type PageExtractInput = { + html: string; + // The capture: its provenance and what CDX said about it. + capture: WaybackProvenance & { mimetype?: string; digest?: string; status?: number }; +}; + +// One module per kind (S3), each pure: no network, no disk, no clock. A +// capture goes to the FIRST registered extractor whose `matches` is true, else +// to the generic extractor (S1). +export type PageExtractor = { + // A short stable name ("tumblr", "x", "xenforo", "gdoc", "yt-about"). + name: string; + // Bump when the output for the same input changes; a re-extract redoes + // records made by an older version. + version: number; + matches(originalUrl: URL, html: string): boolean; + extract(input: PageExtractInput): PageRecordDraft[]; +}; + +// A short, stable hash of a URL (12 hex chars of sha256). +export function urlHash(url: string): string { + return createHash("sha256").update(url).digest("hex").slice(0, 12); +} + +// The id of a whole-page record: one captured state of one page. +export function pageRecordId(captureTs: string, originalUrl: string): string { + return `${captureTs}-${urlHash(originalUrl)}`; +} + +// The thread a page's versions group under (groupIntoThreads). +export function pageThreadId(originalUrl: string): string { + return `page-${urlHash(originalUrl)}`; +}