Archilyzer · Source

archilyzer

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

commit 00cefdd5e4517b54d9ac8cb381c646d5c618d979
parent 8d0b1e068df8d0902f2ce58ef9b90678bd484fa9
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 18 Nov 2026 15:45:00 -0500

review 1 S12: an Instagram page's capture goes into no public pages channel while Instagram is private, and a flip to private is tombstoned and caught

A Wayback pages channel scoped to instagram.com is an Instagram posts channel,
as one scoped to x.com is an X one; the hub's tombstones and the homepage's
deploy check ask one question for both platforms. X's answers are pinned.

Co-Authored-By: Claude <noreply@anthropic.com>

Diffstat:
Mcommon/controller/importPage.ts | 23+++++++++++++++++++----
Mcommon/lib/builtHomepage.test.ts | 18++++++++++++++++++
Mcommon/lib/builtHomepage.ts | 23+++++++++++++++++------
Mcommon/lib/instagram/visibility.test.ts | 47+++++++++++++++++++++++++++++++++++++++++++++++
Mcommon/lib/postsVisibility.ts | 37++++++++++++++++++++++++++++++++++---
Mcommon/lib/waybackPages/urls.ts | 15+++++++++++++++
Mcommon/publish/tombstones.test.ts | 35+++++++++++++++++++++++++++++++++++
Mcommon/publish/tombstones.ts | 15++++++++++-----
8 files changed, 195 insertions(+), 18 deletions(-)

diff --git a/common/controller/importPage.ts b/common/controller/importPage.ts @@ -51,7 +51,7 @@ import { ArchiveOrgRequestError } from "../lib/archiveOrgClient"; import { waybackClient as defaultWaybackClient, type WaybackClient } from "../lib/waybackClient"; import { runManagedFunction, type StreamActionResult } from "../jobs/streamCommand"; import { isWaybackPagesChannel } from "../lib/waybackPages/config"; -import { isXHostUrl, videoPageOf } from "../lib/waybackPages/urls"; +import { isInstagramHostUrl, isXHostUrl, videoPageOf } from "../lib/waybackPages/urls"; import { parseArchiveCaptureAsk, type ArchiveCaptureAsk } from "../lib/archives/ask"; import { unwrapArchiveTodayHtml, mapArchiveTodayMedia } from "../lib/archives/archiveToday"; import { ARCHIVE_TODAY_QUEUE, ArchiveTodayRequestError, type ArchiveTodayClient } from "../lib/archives/archiveTodayClient"; @@ -66,7 +66,12 @@ import { writeStoredCapture, type StoredCapture, } from "../lib/waybackPages/store-server"; -import { isXPostsChannel, xPostsVisibility } from "../lib/postsVisibility"; +import { + instagramPostsVisibility, + isInstagramPostsChannel, + isXPostsChannel, + xPostsVisibility, +} from "../lib/postsVisibility"; import type { Post } from "../lib/posts"; export const IMPORT_PAGE_JOB_KIND = "import-page"; @@ -76,7 +81,7 @@ export const IMPORT_PAGE_RESULT_MARKER = "@@import-page "; // on the queue a web.archive.org URL routes to. export const WAYBACK_PAGES_QUEUE = queueKeyForUrl("https://web.archive.org/"); -type VisibilitySettings = { social?: { x?: { visibility?: unknown } } }; +type VisibilitySettings = { social?: { x?: { visibility?: unknown }; instagram?: { visibility?: unknown } } }; export type ImportPagePlan = { config: ChannelConfig; @@ -90,13 +95,23 @@ export function importPageQueueOf(ask: Pick<ArchiveCaptureAsk, "source">): strin return ask.source === "archive.today" ? ARCHIVE_TODAY_QUEUE : WAYBACK_PAGES_QUEUE; } -// The refusal an X capture meets in this channel, or null. +// The refusal an X capture — or an Instagram one (lane instagram) — meets in +// this channel, or null. One question for both platforms: every call site +// asks it of a capture's original URL before the capture is written. export function xCaptureRefusal( config: ChannelConfig, slug: string, originalUrl: string, settings: VisibilitySettings, ): string | null { + if (isInstagramHostUrl(originalUrl)) { + if (instagramPostsVisibility(settings) !== "private") return null; + if (isInstagramPostsChannel(config)) return null; + return ( + `${originalUrl} is on Instagram, whose posts are private here (social.instagram.visibility is not "public"); ` + + `import an Instagram capture into a Wayback pages channel whose target is on instagram.com, which a public site leaves out — not into ${slug}` + ); + } if (!isXHostUrl(originalUrl)) return null; if (xPostsVisibility(settings) !== "private") return null; if (isXPostsChannel(config)) return null; diff --git a/common/lib/builtHomepage.test.ts b/common/lib/builtHomepage.test.ts @@ -90,3 +90,21 @@ test("while X posts are private: no X post's moment and no X captures; public X assert.equal(builtHomepageProblem(xMoment, { paths, settings: {} }), null); assert.equal(builtHomepageProblem(xMedia, { paths, settings: {} }), null); }); + +// INSTAGRAM (lane instagram): private unless social.instagram.visibility is +// "public" — a homepage built while it was public is caught after the flip. +test("while Instagram posts are private (the default): no Instagram post's moment and no Instagram captures; public ones pass", () => { + put(path.join(paths.channelsDir, "igchan", "config.json"), { sourceKind: "social", platform: "instagram" }); + const IG_PUBLIC = { social: { instagram: { visibility: "public" } } }; + const igMoment = out({ "m/igchan/3500000000000000001/moment.json": moment("/articles/open/") }); + assert.match(builtHomepageProblem(igMoment, { paths, settings: {} }) ?? "", /moment igchan\/3500000000000000001 is an Instagram post, and Instagram posts are private \(social\.instagram\.visibility\)/); + const igMedia = out({ "media/posts/igchan/3500000000000000001/01-1.jpg": "jpg" }); + assert.match(builtHomepageProblem(igMedia, { paths, settings: {} }) ?? "", /media\/posts\/igchan\/, an Instagram channel's captures/); + assert.equal(builtHomepageProblem(igMoment, { paths, settings: IG_PUBLIC }), null); + assert.equal(builtHomepageProblem(igMedia, { paths, settings: IG_PUBLIC }), null); + // X's answers are what they were, whatever Instagram's setting. + const xMoment = out({ "m/xchan/123/moment.json": moment("/articles/open/") }); + assert.equal(builtHomepageProblem(xMoment, { paths, settings: {} }), null); + assert.equal(builtHomepageProblem(xMoment, { paths, settings: IG_PUBLIC }), null); + assert.match(builtHomepageProblem(xMoment, { paths, settings: { ...X_PRIVATE.social ? { social: { ...X_PRIVATE.social, instagram: { visibility: "public" } } } : {} } }) ?? "", /is an X post/); +}); diff --git a/common/lib/builtHomepage.ts b/common/lib/builtHomepage.ts @@ -26,7 +26,7 @@ import { existsSync, readdirSync, readFileSync } from "node:fs"; import path from "node:path"; import type { Paths } from "./paths"; -import { isXPostsChannel, xPostsVisibility } from "./postsVisibility"; +import { anyPostsPlatformPrivate, withheldPostsPlatform } from "./postsVisibility"; import { ARTICLES_REPORTS_BASE, reportBaseDir } from "./report/routes"; export const HOMEPAGE_BUILD_STAMP = "homepage-build.json"; @@ -34,7 +34,7 @@ export const HOMEPAGE_BUILD_STAMP = "homepage-build.json"; export type HomepageAuditOptions = { paths?: Pick<Paths, "articlesDir" | "channelsDir">; // `social.x.visibility`; asked only with `paths`. - settings?: { social?: { x?: { visibility?: unknown } } }; + settings?: { social?: { x?: { visibility?: unknown }; instagram?: { visibility?: unknown } } }; }; const readJson = (file: string): unknown => { @@ -98,14 +98,19 @@ export function homepageAudienceProblem(outDir: string, opts: HomepageAuditOptio } } - const xPrivate = xPostsVisibility(opts.settings ?? {}) === "private"; - const configs = new Map<string, boolean>(); - const isX = (slug: string) => { + // A posts platform that is private now (X by its setting; Instagram unless + // set public): which one withholds a channel, or null. + const settings = opts.settings ?? {}; + const xPrivate = anyPostsPlatformPrivate(settings); + const configs = new Map<string, "x" | "instagram" | null>(); + const withheld = (slug: string) => { if (!configs.has(slug)) { - configs.set(slug, isXPostsChannel(readJson(path.join(paths.channelsDir, slug, "config.json")) as never)); + configs.set(slug, withheldPostsPlatform(readJson(path.join(paths.channelsDir, slug, "config.json")) as never, settings)); } return configs.get(slug)!; }; + const isX = (slug: string) => withheld(slug) === "x"; + const isInstagram = (slug: string) => withheld(slug) === "instagram"; const articlePrefix = ARTICLES_REPORTS_BASE; for (const m of momentFiles(outDir)) { const view = readJson(m.file) as { citedIn?: { href?: unknown }[] } | null; @@ -119,12 +124,18 @@ export function homepageAudienceProblem(outDir: string, opts: HomepageAuditOptio if (xPrivate && isX(m.key.split("/")[0])) { return `the homepage build's moment ${m.key} is an X post, and X posts are private (social.x.visibility) — rebuild the homepage`; } + if (xPrivate && isInstagram(m.key.split("/")[0])) { + return `the homepage build's moment ${m.key} is an Instagram post, and Instagram posts are private (social.instagram.visibility) — rebuild the homepage`; + } } if (xPrivate) { for (const slug of dirs(path.join(outDir, "media", "posts"))) { if (isX(slug)) { return `the homepage build carries media/posts/${slug}/, an X channel's captures, and X posts are private (social.x.visibility) — rebuild the homepage`; } + if (isInstagram(slug)) { + return `the homepage build carries media/posts/${slug}/, an Instagram channel's captures, and Instagram posts are private (social.instagram.visibility) — rebuild the homepage`; + } } } return null; diff --git a/common/lib/instagram/visibility.test.ts b/common/lib/instagram/visibility.test.ts @@ -11,6 +11,9 @@ import { } from "../postsVisibility"; import { sanitizeSocial } from "../../social/xCookieSource"; import { isSourcelessPostsChannel } from "../sourcelessPosts"; +import { anyPostsPlatformPrivate, withheldPostsPlatform } from "../postsVisibility"; +import { xCaptureRefusal } from "../../controller/importPage"; +import { isInstagramHostUrl, isInstagramTargetUrl } from "../waybackPages/urls"; const IG = { sourceKind: "social" as const, platform: "instagram" as const }; const X = { sourceKind: "social" as const, platform: "twitter" as const }; @@ -72,3 +75,47 @@ test("the social block keeps instagram's visibility and drops the rest", () => { instagram: { visibility: "private" }, }); }); + +// A Wayback pages channel scoped to instagram.com is an Instagram posts +// channel, as one scoped to x.com is an X one (review 1, S12). +const PAGES = (url: string) => ({ sourceKind: "social" as const, platform: "webpage" as const, wayback: { targets: [{ url }] } }); + +test("a Wayback pages channel whose target is on instagram.com follows Instagram's setting", () => { + assert.equal(isInstagramTargetUrl("instagram.com/example.account"), true); + assert.equal(isInstagramTargetUrl("https://www.instagram.com/example.account/"), true); + assert.equal(isInstagramTargetUrl("example.com/instagram.com"), false); + assert.equal(isInstagramHostUrl("https://notinstagram.com/x"), false); + const igPages = PAGES("instagram.com/example.account") as never; + const otherPages = PAGES("example.com/blog") as never; + assert.equal(isInstagramPostsChannel(igPages), true); + assert.equal(isInstagramPostsChannel(otherPages), false); + assert.equal(isXPostsChannel(igPages), false); + assert.equal(postsVisibleTo(publicSite, igPages, {}), false); + assert.equal(postsVisibleTo(publicSite, igPages, IG_PUBLIC), true); + assert.equal(postsVisibleTo(publicSite, otherPages, {}), true); + // Which setting withholds a channel now. + assert.equal(withheldPostsPlatform(IG, {}), "instagram"); + assert.equal(withheldPostsPlatform(IG, IG_PUBLIC), null); + assert.equal(withheldPostsPlatform(X, {}), null); + assert.equal(withheldPostsPlatform(X, { social: { x: { visibility: "private" } } }), "x"); + assert.equal(withheldPostsPlatform(BLUESKY, { social: { x: { visibility: "private" } } }), null); + assert.equal(anyPostsPlatformPrivate({}), true, "Instagram is private by default"); + assert.equal(anyPostsPlatformPrivate(IG_PUBLIC), false); +}); + +test("a capture of an instagram.com page goes into no public pages channel while Instagram is private; X's refusal is what it was", () => { + const url = "https://www.instagram.com/example.account/"; + const other = PAGES("example.com/blog") as never; + const igPages = PAGES("instagram.com/example.account") as never; + assert.match( + xCaptureRefusal(other, "some-pages", url, {}) ?? "", + /is on Instagram, whose posts are private here \(social\.instagram\.visibility is not "public"\); import an Instagram capture into a Wayback pages channel whose target is on instagram\.com, which a public site leaves out — not into some-pages/, + ); + assert.equal(xCaptureRefusal(igPages, "ig-pages", url, {}), null); + assert.equal(xCaptureRefusal(other, "some-pages", url, IG_PUBLIC), null); + assert.equal(xCaptureRefusal(other, "some-pages", "https://example.com/a", {}), null); + // X: refused only while X is private, with X's own sentence. + const xUrl = "https://x.com/example/status/1"; + assert.equal(xCaptureRefusal(other, "some-pages", xUrl, {}), null); + assert.match(xCaptureRefusal(other, "some-pages", xUrl, { social: { x: { visibility: "private" } } }) ?? "", /is on X, whose posts are private here \(social\.x\.visibility "private"\)/); +}); diff --git a/common/lib/postsVisibility.ts b/common/lib/postsVisibility.ts @@ -37,7 +37,7 @@ import { isSocialChannel, type ChannelConfig } from "./channelConfig"; import { isPrivateSite, type Site } from "./siteSchema"; import type { InstagramPostsVisibility, XPostsVisibility } from "../social/xCookieSource"; import { isWaybackPagesChannel } from "./waybackPages/config"; -import { isXTargetUrl } from "./waybackPages/urls"; +import { isInstagramTargetUrl, isXTargetUrl } from "./waybackPages/urls"; import { isXTrendingChannel } from "./xTrending/config"; // What the rule reads of a config: its kind and platform, and for a Wayback @@ -72,9 +72,40 @@ export function xPostsVisibility(settings: { } // An Instagram channel: the posts of a social channel whose platform is -// Instagram. +// Instagram — and, as for X, a Wayback pages channel whose scope is on +// instagram.com (a target there, or such a URL as its own): Instagram's +// captures are Instagram posts, private by the same setting. import-page keeps +// them out of every other Wayback pages channel while Instagram is private +// (controller/importPage.ts, xCaptureRefusal). export function isInstagramPostsChannel(config: VisibilityConfig | null | undefined): boolean { - return isSocialChannel(config) && config?.platform === "instagram"; + if (!isSocialChannel(config)) return false; + if (config?.platform === "instagram") return true; + if (!isWaybackPagesChannel(config)) return false; + if (config?.wayback?.targets.some((t) => isInstagramTargetUrl(t.url))) return true; + const url = config?.url ?? ""; + if (!url) return false; + const inner = /^https?:\/\/(?:web|wayback)\.archive\.org\/web\/[^/]*\/(.+)$/i.exec(url)?.[1]; + return isInstagramTargetUrl(inner ?? url); +} + +// WHICH PRIVATE SETTING WITHHOLDS A CHANNEL'S POSTS FROM PUBLIC SITES NOW, or +// null: "x" (an X channel while social.x.visibility is private), "instagram" +// (an Instagram channel while social.instagram.visibility is not public). The +// one question the tombstones (publish/tombstones.ts) and the homepage's +// deploy check (lib/builtHomepage.ts) ask, so a flip to private is withdrawn +// and caught for either platform. +export function withheldPostsPlatform( + config: VisibilityConfig | null | undefined, + settings: VisibilitySettings, +): "x" | "instagram" | null { + if (isXPostsChannel(config)) return xPostsVisibility(settings) === "private" ? "x" : null; + if (isInstagramPostsChannel(config)) return instagramPostsVisibility(settings) === "private" ? "instagram" : null; + return null; +} + +// Whether any posts platform is private now (nothing to withhold when none is). +export function anyPostsPlatformPrivate(settings: VisibilitySettings): boolean { + return xPostsVisibility(settings) === "private" || instagramPostsVisibility(settings) === "private"; } // `social.instagram.visibility`, resolved: absent (or anything unknown) is diff --git a/common/lib/waybackPages/urls.ts b/common/lib/waybackPages/urls.ts @@ -140,6 +140,21 @@ export function isXHostUrl(url: string): boolean { } } +// Whether `url` is on Instagram: a capture of it follows +// `social.instagram.visibility` exactly as Instagram posts do. +export function isInstagramHostUrl(url: string): boolean { + try { + return new URL(url).hostname.toLowerCase().replace(/^www\./, "") === "instagram.com"; + } catch { + return false; + } +} + +// Whether a target URL (scheme optional) is on Instagram. +export function isInstagramTargetUrl(url: string): boolean { + return isInstagramHostUrl(/^https?:\/\//i.test(url) ? url : `https://${url.replace(/^\*\./, "")}`); +} + // Whether a target URL (scheme optional) is on X. export function isXTargetUrl(url: string): boolean { return isXHostUrl(/^https?:\/\//i.test(url) ? url : `https://${url.replace(/^\*\./, "")}`); diff --git a/common/publish/tombstones.test.ts b/common/publish/tombstones.test.ts @@ -314,3 +314,38 @@ test("hubNameableChannels: the pools of the sites that are not private, never a ["a", "b", "c"], ); }); + +// INSTAGRAM (lane instagram): the same withdrawal, with the other default — an +// Instagram channel a non-private site carries is tombstoned unless +// social.instagram.visibility is "public". X's list is what it was. +test("withdrawnXChannels names Instagram channels too while Instagram posts are private; X's output is unchanged by it", async () => { + const root = mkdtempSync(path.join(tmpdir(), "tombstones-ig-")); + try { + const paths = { + channelsDir: path.join(root, "channels"), + exportSharedPostsDir: path.join(root, "shared", "posts"), + } as Paths; + const config = (slug: string, platform: string) => + writeJson(path.join(paths.channelsDir, slug, "config.json"), { handling: "transcribe", url: `https://example.test/${slug}`, sourceKind: "social", platform }); + config("a-x", "twitter"); + config("ig-public-site", "instagram"); + config("ig-private-only", "instagram"); + config("sky", "bluesky"); + for (const slug of ["a-x", "ig-public-site", "ig-private-only", "sky"]) sharedTree(paths.exportSharedPostsDir, slug, 1); + const members = (...slugs: string[]) => slugs.map((slug) => ({ slug, groupId: "default" })); + const sites = [ + { channels: members("a-x", "ig-public-site", "sky") }, + { audience: "private" as const, channels: members("ig-private-only") }, + ]; + const xPrivate = { social: { x: { visibility: "private" } } }; + const igPublic = { social: { instagram: { visibility: "public" } } }; + // Instagram private by default: its channel on the public site is withdrawn; the private-only one is never named. + assert.deepEqual(await withdrawnXChannels(paths, {}, sites), ["ig-public-site"]); + assert.deepEqual(await withdrawnXChannels(paths, igPublic, sites), []); + // X's own list, with Instagram public: exactly what X's rule gave before. + assert.deepEqual(await withdrawnXChannels(paths, { social: { ...xPrivate.social, ...igPublic.social } }, sites), ["a-x"]); + assert.deepEqual(await withdrawnXChannels(paths, xPrivate, sites), ["a-x", "ig-public-site"]); + } finally { + rmSync(root, { recursive: true, force: true }); + } +}); diff --git a/common/publish/tombstones.ts b/common/publish/tombstones.ts @@ -49,7 +49,7 @@ import { type ChannelPostsManifest, type PostsManifest, } from "../lib/posts"; -import { isXPostsChannel, xPostsVisibility } from "../lib/postsVisibility"; +import { anyPostsPlatformPrivate, withheldPostsPlatform } from "../lib/postsVisibility"; import { isPrivateSite, type Site } from "../lib/siteSchema"; import { readChannelConfig } from "../controller/channels"; import { ownDir, writePublicFile } from "../bin/_publicFile"; @@ -180,14 +180,17 @@ export function tombstoneNoStoreForHub(tombstones: readonly PostsTombstone[]): s * only paths the edge can still hold. PRIVATE DATA IS NEVER NAMED ON THE HUB: * an X channel carried only by private sites, or by no site, gets no * tombstone, because its slug in a public bundle would itself publish it. - * Empty while X posts are public. + * Empty while X posts are public. INSTAGRAM THE SAME (lane instagram): an + * Instagram channel on a non-private site is tombstoned while Instagram posts + * are private — which they are unless `social.instagram.visibility` is + * "public" — so a flip from public back to private withdraws what was served. */ export async function withdrawnXChannels( paths: Paths, - settings: { social?: { x?: { visibility?: unknown } } }, + settings: { social?: { x?: { visibility?: unknown }; instagram?: { visibility?: unknown } } }, sites: readonly Pick<Site, "audience" | "channels">[], ): Promise<string[]> { - if (xPostsVisibility(settings) !== "private") return []; + if (!anyPostsPlatformPrivate(settings)) return []; const onPublicSite = hubNameableChannels(sites); let entries: string[]; try { @@ -201,7 +204,9 @@ export async function withdrawnXChannels( const out: string[] = []; for (const slug of entries) { if (!onPublicSite.has(slug)) continue; - if (isXPostsChannel(await readChannelConfig(paths, slug))) out.push(slug); + // An X channel while X is private; an Instagram channel while Instagram is + // (it is unless set public): the same withdrawal for both. + if (withheldPostsPlatform(await readChannelConfig(paths, slug), settings)) out.push(slug); } return out; }