Archilyzer · Source

archilyzer

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

commit 8ad5197bceea9ff5e08579852cd81f8f34c19793
parent 3a87459044c2cc8bad6cd40bc4aea8cd4ae12b34
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 20 Oct 2026 17:14:17 -0400

wayback pages: one page→post citation builder for Import this capture and find-copy; a gone original named as such

- lib/citations/pageAsPost.ts pageCitationAsPost (the page kept as the
  post citation's fallback) is the one builder: find-copy's page mode
  re-exports it for its items' `as`, replacePageCitationWithRecord uses it
  and also takes find-copy's `as` directly, umtool's replacement uses it.
- pageCopyLinks / pageCaptureView take `originalGone`: the original's label
  is lane E's PAGE_ORIGINAL_GONE_LABEL — from the served record's flag, or
  the availability sidecar where a surface reads raw records (compose,
  the editor's rows, umtool's rail).
- fix the merge of archiveOrgClient (send and paced both kept).

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

Diffstat:
MOPERATING.md | 5++++-
Mcommon/controller/handEdits.ts | 20++++++++++----------
Mcommon/lib/archiveOrgClient.ts | 3+++
Acommon/lib/citations/pageAsPost.ts | 19+++++++++++++++++++
Mcommon/lib/waybackPages/view.test.ts | 10++++++++++
Mcommon/lib/waybackPages/view.ts | 22++++++++++++++++++----
Mcommon/publish/composeReports.ts | 10++++++++--
Mcommon/publish/findCopyPages.test.ts | 25+++++++++++++++++++++++--
Mcommon/publish/findCopyPages.ts | 11+++++------
Meditor/app/channels/[slug]/page.tsx | 13+++++++++----
Mplans/FACTS.md | 11++++++++---
Mumtool/lib/articles/evidence.ts | 10++++++++--
Mumtool/lib/articles/importCapture.ts | 10++--------
13 files changed, 127 insertions(+), 42 deletions(-)

diff --git a/OPERATING.md b/OPERATING.md @@ -186,7 +186,10 @@ pnpm ops capture-posts --json '{"slug":"old-blog","ids":["<recordId>"],"media":f Import (the editor's `import-page`), then **Cite this** on the record it made. A store article's citation becomes a `post` citation of the record, the page kept as its `fallback` (CITATIONS.md), written as a hand iteration — its quote checked against the record first. A site report is built from its draft, so umtool shows the replacement - citation to put there. `reports-prepare` then copies the record's shot like any post capture. + citation to put there. `reports-prepare` then copies the record's shot like any post capture. find-copy's page + mode builds its `as` with the same function, so both paths write the same citation (the page as its `fallback`). +- A page record whose original the liveness check found gone is labelled "Original gone — the Wayback Machine copy + is the only copy" everywhere its links are shown. - The MCP: `get_post` prints a page record's capture (kind, date, the original, the Wayback copy); `search_transcripts` takes `platforms: ["webpage"]` (with `content_types: ["post"]` for page records only). diff --git a/common/controller/handEdits.ts b/common/controller/handEdits.ts @@ -29,6 +29,7 @@ // // SERVER-ONLY. +import { pageCitationAsPost } from "../lib/citations/pageAsPost"; import type { Paths } from "../lib/paths"; import { getPaths } from "../lib/paths"; import { @@ -372,6 +373,10 @@ export type ImportedCaptureInput = { // The page record the capture became: its Wayback pages channel and id. channel: string; id: string; + // Or the rewritten citation itself, as find-copy's page mode names it per + // item (`as`, built by the same pageCitationAsPost): its channel and id are + // the record's. + as?: Extract<Citation, { kind: "post" }>; base?: number | null; }; @@ -413,18 +418,13 @@ export async function replacePageCitationWithRecord( if (!old) fail(`the report has no citation "${input.cite}"`); if (old!.kind !== "page") fail(`citation "${input.cite}" is a ${old!.kind}, not a page`); const page = old as Extract<Citation, { kind: "page" }>; - const channel = str(input.channel); - const rid = str(input.id); + if (input.as && input.as.kind !== "post") fail("`as` is a post citation"); + const channel = str(input.as?.channel ?? input.channel); + const rid = str(input.as?.id ?? input.id); if (!channel || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(channel)) fail("the channel is a channel's slug"); if (!rid) fail("name the page record's id"); - const { kind: _k, url, title, archiveUrl, ...commonFields } = page; - const citation = { - kind: "post", - channel, - id: rid, - ...commonFields, - fallback: { kind: "page", url, ...(title ? { title } : {}), ...(archiveUrl ? { archiveUrl } : {}) }, - } as Citation; + // One builder for both paths: find-copy's `as` is this same citation. + const citation = pageCitationAsPost(page, { channel, id: rid }) as Citation; const [check] = await checkAddedCitations([{ kind: "post", channel, id: rid, quote: page.quote }], { respellings: report.respellings, paths, diff --git a/common/lib/archiveOrgClient.ts b/common/lib/archiveOrgClient.ts @@ -352,6 +352,9 @@ export class ArchiveOrgClient { null, true, ); + }); + } + // A request SOMETHING ELSE makes (release 37 S4: a headless browser's load of // a Wayback replay page for a page record's shot), run in this client's // chain and gap: it waits for every earlier request and the gap, and the diff --git a/common/lib/citations/pageAsPost.ts b/common/lib/citations/pageAsPost.ts @@ -0,0 +1,19 @@ +// A PAGE citation as a POST citation of the page record its capture became +// (release 37): the ONE builder both paths use — umtool's Import this capture +// (controller/handEdits.ts replacePageCitationWithRecord) and find-copy's page +// mode (publish/findCopyPages.ts, its items' `as`) — so they write identical +// citations. Its words and editorial fields kept; the page's address, title +// and archived copy kept as its `fallback`. Pure, client-safe. + +import type { PageCitation, PostCitation } from "./schema"; + +export function pageCitationAsPost(c: PageCitation, pointTo: { channel: string; id: string }): PostCitation { + const { kind: _kind, url, title, archiveUrl, ...common } = c; + return { + kind: "post", + channel: pointTo.channel, + id: pointTo.id, + ...common, + fallback: { kind: "page", url, ...(title ? { title } : {}), ...(archiveUrl ? { archiveUrl } : {}) }, + }; +} diff --git a/common/lib/waybackPages/view.test.ts b/common/lib/waybackPages/view.test.ts @@ -7,6 +7,7 @@ import { test } from "node:test"; import assert from "node:assert/strict"; import type { Post } from "../posts"; import { pageRecordId } from "./types"; +import { PAGE_ORIGINAL_GONE_LABEL } from "./liveness"; import { isWholePageId, pageCaptureLine, pageCaptureView, pageKindLabel, pageVersionsLine } from "./view"; const URL_A = "https://blog.example/a.html"; @@ -74,3 +75,12 @@ test("no content, the fallback note, an item seen first in an earlier capture", assert.equal(pageKindLabel("newkind"), "Web page (newkind)"); }); + +test("an original known gone is named as such; the Wayback copy is the only copy", () => { + const r = { ...rec("20140305120000", "x"), isDeleted: true }; + const v = pageCaptureView(r)!; + assert.equal(v.originalGone, true); + assert.equal(v.links.original.label, PAGE_ORIGINAL_GONE_LABEL); + assert.equal(pageCaptureView(rec("20140305120000", "x"), [], { originalGone: true })!.links.original.label, PAGE_ORIGINAL_GONE_LABEL); + assert.equal(pageCaptureView(rec("20140305120000", "x"))!.links.original.label, "Original (may be gone)"); +}); diff --git a/common/lib/waybackPages/view.ts b/common/lib/waybackPages/view.ts @@ -17,6 +17,7 @@ import type { Post } from "../posts"; import type { PagePostInfo } from "./types"; import { waybackCaptureDate, waybackCitationLinks, type WaybackLink } from "../wayback"; +import { PAGE_ORIGINAL_GONE_LABEL } from "./liveness"; export const PAGE_KIND_LABELS: Record<string, string> = { generic: "Web page", @@ -59,6 +60,8 @@ export type PageCaptureView = { originalUrl: string; waybackUrl: string; links: { original: WaybackLink; copy: WaybackLink }; + // The original is known gone: the Wayback copy is the only copy. + originalGone?: boolean; title?: string; noContent?: boolean; // The extractor-fallback sentence. @@ -72,11 +75,17 @@ export type PageCaptureView = { // and "<archive> copy, <date>" (lib/wayback.ts waybackCitationLinks). Every // surface — compose's record view, this module's view, the MCP — goes through // it, so a record from another archive is one change here. -export function pageCopyLinks(page: Pick<PagePostInfo, "originalUrl" | "captureTs" | "waybackUrl" | "rawUrl">): { +// `originalGone`: the original is known gone (release 37 S5's check recorded +// it `deleted`) — the original is then named as such (PAGE_ORIGINAL_GONE_LABEL). +export function pageCopyLinks( + page: Pick<PagePostInfo, "originalUrl" | "captureTs" | "waybackUrl" | "rawUrl">, + o: { originalGone?: boolean } = {}, +): { original: WaybackLink; copy: WaybackLink; } { - return waybackCitationLinks(page); + const links = waybackCitationLinks(page); + return o.originalGone ? { ...links, original: { ...links.original, label: PAGE_ORIGINAL_GONE_LABEL } } : links; } export function pageFallbackNote(page: Pick<PagePostInfo, "extractorFallback">): string | undefined { @@ -129,11 +138,15 @@ export function pageVersionsLine(v: Pick<PageVersionsView, "count" | "changedOn" } export function pageCaptureView( - post: Pick<Post, "id" | "page" | "text">, + post: Pick<Post, "id" | "page" | "text"> & Partial<Pick<Post, "isDeleted" | "availability">>, siblings: ReadonlyArray<Pick<Post, "id" | "page" | "text">> = [], + // Whether the original is known gone; default: the record's own flag (the + // index merges the availability sidecar onto a served record). + o: { originalGone?: boolean } = {}, ): PageCaptureView | undefined { const page = post.page; if (!page) return undefined; + const originalGone = o.originalGone ?? (post.isDeleted === true || post.availability === "deleted"); const versions = pageVersions(post, siblings); const fallbackNote = pageFallbackNote(page); const firstSeen = @@ -145,7 +158,8 @@ export function pageCaptureView( captureDate: waybackCaptureDate(page.captureTs), originalUrl: page.originalUrl, waybackUrl: page.waybackUrl, - links: pageCopyLinks(page), + links: pageCopyLinks(page, { originalGone }), + ...(originalGone ? { originalGone: true } : {}), ...(page.title ? { title: page.title } : {}), ...(page.noContent ? { noContent: true } : {}), ...(fallbackNote ? { fallbackNote } : {}), diff --git a/common/publish/composeReports.ts b/common/publish/composeReports.ts @@ -764,7 +764,9 @@ export async function resolveReports(opts: ResolveReportsOptions): Promise<Resol const post = (await postOf(c.channel, c.id))!; // A page record (a Wayback capture, release 37 S4): the original, named // as possibly gone, then the Wayback copy — as an archived video's. - const page = post.page ? pageCopyLinks(post.page) : null; + const page = post.page + ? pageCopyLinks(post.page, { originalGone: (await postGoneState(paths.channelsDir, c.channel, c.id)) === "deleted" }) + : null; return defined({ channel: c.channel, channelTitle: config?.name ?? post.authorName, @@ -894,7 +896,11 @@ export async function resolveReports(opts: ResolveReportsOptions): Promise<Resol } as const; if (c.kind === "post") { const post = postsByChannel.get(c.channel)!.get(c.id)!; - const pageView = post.page ? pageCaptureView(post, [...postsByChannel.get(c.channel)!.values()]) : undefined; + const pageView = post.page + ? pageCaptureView(post, [...postsByChannel.get(c.channel)!.values()], { + originalGone: (await postGoneState(paths.channelsDir, c.channel, c.id)) === "deleted", + }) + : undefined; const postView: MomentPostView = { author: postAuthor(post), text: post.text, diff --git a/common/publish/findCopyPages.test.ts b/common/publish/findCopyPages.test.ts @@ -89,7 +89,15 @@ test("which channel covers a page; the date a citation asks for; the record a qu assert.equal(recordForQuote([{ id: "a", text: "x" }], "not there"), "a"); assert.deepEqual( pageCitationAsPost({ kind: "page", url: PAGE_ARTICLE_URL, title: "T", archiveUrl: "https://web.archive.org/web/1/x", quote: "q", label: "L", note: "n" }, { channel: "blog", id: "r1" }), - { kind: "post", channel: "blog", id: "r1", quote: "q", label: "L", note: "n" }, + { + kind: "post", + channel: "blog", + id: "r1", + quote: "q", + label: "L", + note: "n", + fallback: { kind: "page", url: PAGE_ARTICLE_URL, title: "T", archiveUrl: "https://web.archive.org/web/1/x" }, + }, ); }); @@ -145,7 +153,15 @@ test("a gone cited page: dry run names the nearest capture; the run imports it a const id = pageRecordId(PAGE_ARTICLE_LATER_TS, PAGE_ARTICLE_URL); assert.equal(item.outcome, "imported", item.detail); assert.deepEqual(item.pointTo, { channel: "old-blog", id }); - assert.deepEqual(item.as, { kind: "post", channel: "old-blog", id, date: "2015-06", quote: "Update: the fourth loaf rose.", label: "The post" }); + assert.deepEqual(item.as, { + kind: "post", + channel: "old-blog", + id, + date: "2015-06", + quote: "Update: the fourth loaf rose.", + label: "The post", + fallback: { kind: "page", url: PAGE_ARTICLE_URL }, + }); assert.deepEqual((await readAllPosts(dir)).map((p) => p.id), [id]); // Again: the channel holds the page — nothing fetched. @@ -227,3 +243,8 @@ test("a cited page record whose original is gone: held when its capture is store await wb.close(); } }); + +test("find-copy's `as` and Import this capture write the same citation (one builder, the page as its fallback)", async () => { + const { pageCitationAsPost: shared } = await import("../lib/citations/pageAsPost"); + assert.equal(pageCitationAsPost, shared); +}); diff --git a/common/publish/findCopyPages.ts b/common/publish/findCopyPages.ts @@ -37,6 +37,7 @@ import path from "node:path"; import type { Paths } from "../lib/paths"; import type { Citation, PageCitation, PostCitation } from "../lib/citations/schema"; +import { pageCitationAsPost } from "../lib/citations/pageAsPost"; import type { Post } from "../lib/posts"; import { readAllPosts, readPostAvailability } from "../lib/posts-server"; import { listChannelConfigs } from "../controller/channels"; @@ -161,12 +162,10 @@ export function recordForQuote(records: ReadonlyArray<Pick<Post, "id" | "text">> return records[0]!.id; } -// A page citation as a post citation of the record: its words and editorial -// fields kept; the record carries the URL, the title and the Wayback copy. -export function pageCitationAsPost(c: PageCitation, pointTo: { channel: string; id: string }): PostCitation { - const { kind: _kind, url: _url, title: _title, archiveUrl: _archive, ...common } = c; - return { kind: "post", channel: pointTo.channel, id: pointTo.id, ...common }; -} +// A page citation as a post citation of the record: the one builder, shared +// with umtool's Import this capture (lib/citations/pageAsPost.ts) — its words +// and editorial fields kept, the page kept as its `fallback`. +export { pageCitationAsPost }; // ─── find-copy, page mode ─── diff --git a/editor/app/channels/[slug]/page.tsx b/editor/app/channels/[slug]/page.tsx @@ -10,7 +10,7 @@ import { readPostAvailability, readPostFetchState, } from "yt-dlp-transcript-common/lib/posts-server"; -import { isPostGone, type Post } from "yt-dlp-transcript-common/lib/posts"; +import { isPostGone, type Post, type PostAvailabilityMap } from "yt-dlp-transcript-common/lib/posts"; import { resolveSocialFetcher } from "yt-dlp-transcript-common/social/fetchers"; import { describeOlderBackfill } from "yt-dlp-transcript-common/social/olderBackfill"; import "yt-dlp-transcript-common/social/blueskyFetcher"; @@ -191,7 +191,7 @@ export default async function ChannelDetailPage({ // A WAYBACK PAGES channel (release 37): its captures, its scope, Import a // capture — no fetcher, nothing to fetch. const pageRecords = isWaybackPagesChannel(config) ? (await readAllPosts(channelRoot)).filter((p) => p.page) : []; - const wayback = isWaybackPagesChannel(config) ? await waybackPagesRows(channelRoot, slug, pageRecords) : null; + const wayback = isWaybackPagesChannel(config) ? await waybackPagesRows(channelRoot, slug, pageRecords, postAvailability) : null; return ( <div className="flex flex-col gap-6"> <RunningJobsList jobs={socialRunningJobs} hideChannelSlug /> @@ -929,7 +929,12 @@ export default async function ChannelDetailPage({ // A Wayback pages channel's newest records (release 37 S1/S4): each with its // capture's view (the version list read off every record of the channel) and // its shot when captured. -async function waybackPagesRows(channelRoot: string, slug: string, all: Post[]) { +async function waybackPagesRows( + channelRoot: string, + slug: string, + all: Post[], + availability: PostAvailabilityMap, +) { const recent = [...all] .sort((a, b) => b.page!.captureTs.padEnd(14, "0").localeCompare(a.page!.captureTs.padEnd(14, "0"))) .slice(0, 20); @@ -943,7 +948,7 @@ async function waybackPagesRows(channelRoot: string, slug: string, all: Post[]) return { id: p.id, title: p.page!.title || p.text.split("\n")[0].slice(0, 120) || p.url, - view: pageCaptureView(p, all)!, + view: pageCaptureView(p, all, { originalGone: isPostGone(availability[p.id]?.availability) })!, ...(capture?.shot ? { shot: `${base}/${capture.shot.name}?v=${capture.shot.sha256.slice(0, 8)}` } : {}), ...(capture?.media.length ? { images: capture.media.length } : {}), }; diff --git a/plans/FACTS.md b/plans/FACTS.md @@ -11255,15 +11255,20 @@ parsed to 0 cues, indexing the video textless) is CLOSED by `200a3105` (transcri No outcome carries an availability (a capture says nothing about the original — S5's). - **How a capture is shown** (`lib/waybackPages/view.ts`, client-safe): `pageCaptureView(post, siblings)` → `{kind, kindLabel, captureDate, links: {original, copy}, noContent?, fallbackNote?, firstSeenDate?, versions?}`. - `pageCopyLinks` is THE one place the two link labels are made (today `waybackCitationLinks`). Whole-page = id shape + `pageCopyLinks` is THE one place the two link labels are made (today `waybackCitationLinks`); with + `originalGone` (the record `isDeleted`/`availability: "deleted"`, or the sidecar's verdict where a surface reads + raw records: compose via `postGoneState`, the editor's rows and umtool's rail via `readPostAvailability`) the + original's label is lane E's `PAGE_ORIGINAL_GONE_LABEL`. Whole-page = id shape `^\d{4,14}-[0-9a-f]{12}$` (`isWholePageId`; no hash in the client). Versions = whole-page records of the same `originalUrl`; `changedOn` = capture dates whose text differs from the one before. `PageCaptureFacts` (common/components) renders it on the moment page (`MomentPostView.page`), the post modal and the editor's records table; compose's post `RecordView` for a page record carries `originalLabel` + `downloads: [copy]`, and `CitationCard`'s post links now print them. - **The post citation's `fallback`** (`citations/schema.ts`, `pageFallbackSchema`, CITATIONS.md): `{kind: "page", - url, title?, archiveUrl?}` — the page citation a post citation replaced. Written only by - `replacePageCitationWithRecord` (controller/handEdits.ts): page → post of the record, common fields kept, quote + url, title?, archiveUrl?}` — the page citation a post citation replaced. ONE builder, + `lib/citations/pageAsPost.ts` `pageCitationAsPost(c, {channel, id})`, used by find-copy's page mode (its items' + `as`, re-exported from publish/findCopyPages.ts) and by `replacePageCitationWithRecord` (controller/handEdits.ts, + which also takes find-copy's `as` directly): page → post of the record, common fields kept, quote checked like a hand-added post's (refused when it does not check), a hand iteration (amend-or-new, as `addClaimByHand`). umtool `/api/articles/import-capture` (GET channels | GET ?job&slug | POST start | POST use) → `lib/articles/importCapture.ts`; a site report (not `ARTICLES_KEY`) gets the replacement back, never written. diff --git a/umtool/lib/articles/evidence.ts b/umtool/lib/articles/evidence.ts @@ -12,7 +12,8 @@ import { storeFor } from "./sites"; import { pageCaptureView, pageCopyLinks } from "yt-dlp-transcript-common/lib/waybackPages/view"; import type { PageCaptureView } from "yt-dlp-transcript-common/lib/waybackPages/view"; import { parseWaybackUrl } from "yt-dlp-transcript-common/lib/wayback"; -import { ARTICLES_KEY } from "@/lib/paths"; +import { ARTICLES_KEY, CHANNELS_DIR } from "@/lib/paths"; +import { readPostAvailability } from "yt-dlp-transcript-common/lib/posts-server"; // What a citation's EVIDENCE panel shows: the cited seconds with the transcript // around them, and something to play -- found, never fetched. @@ -160,7 +161,12 @@ export async function citationEvidence(siteId: string, report: Report, citeId: s const posts = await channelPosts(c.channel); const post = posts.get(c.id); const shot = await postShotFile(c.channel, c.id); - const page = post?.page ? pageCaptureView(post, [...posts.values()]) : undefined; + const avail = post?.page + ? await readPostAvailability(path.join(/* turbopackIgnore: true */ CHANNELS_DIR, c.channel)).catch(() => ({}) as Record<string, { availability?: string }>) + : {}; + const page = post?.page + ? pageCaptureView(post, [...posts.values()], { originalGone: (avail as Record<string, { availability?: string }>)[c.id]?.availability === "deleted" }) + : undefined; return { ...base, record: { channel: c.channel, id: c.id, ...(page?.title ? { title: page.title } : {}) }, diff --git a/umtool/lib/articles/importCapture.ts b/umtool/lib/articles/importCapture.ts @@ -4,6 +4,7 @@ import type { Report } from "yt-dlp-transcript-common/lib/report/schema"; import { parseWaybackUrl } from "yt-dlp-transcript-common/lib/wayback"; import { HandEditError, replacePageCitationWithRecord } from "yt-dlp-transcript-common/controller/handEdits"; import type { Citation } from "yt-dlp-transcript-common/lib/citations/schema"; +import { pageCitationAsPost } from "yt-dlp-transcript-common/lib/citations/pageAsPost"; import { ARTICLES_KEY, CHANNELS_DIR } from "@/lib/paths"; import { askEditor } from "./generation"; import { channelPosts } from "./article"; @@ -144,14 +145,7 @@ export async function captureImportStatus(jobId: string, slug: string): Promise< export function replacementCitation(report: Report, cite: string, slug: string, id: string): Citation { const c = report.citations?.[cite]; if (!c || c.kind !== "page") throw new ImportCaptureError(`citation ${cite} is not a page citation`); - const { kind: _kind, url, title, archiveUrl, ...common } = c; - return { - kind: "post", - channel: slug, - id, - ...common, - fallback: { kind: "page", url, ...(title ? { title } : {}), ...(archiveUrl ? { archiveUrl } : {}) }, - } as Citation; + return pageCitationAsPost(c, { channel: slug, id }); } /**