Archilyzer · Source

archilyzer

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

commit db0d56c067e64787080bb45403dcd8c467f35b95
parent 02f5e182b1392cc5ee4ab7707b4a4b213ae270a2
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Sat, 10 Oct 2026 12:03:50 -0400

sites: citedChannels — channels in the cited scope (schema, SITE.md)

A separate site.json key, `citedChannels: [{slug}]`: channels a site's reports
may cite without the site publishing them. Trimmed, blanks and repeats dropped,
a slug already in `channels` dropped (the pool wins); absent reads `[]`, written
only when non-empty. `siteChannelSlugs` stays pool-only and moves beside the new
`siteCitableChannelSlugs` (pool plus cited) and `isCitedOnlyChannel` in
siteSchema.ts (re-exported by site.ts). The `channels` and `search` docs say
what the pool is; SITE.md regenerated.

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

Diffstat:
MSITE.md | 23+++++++++++++++++++++--
Mcommon/lib/fileSchemaDocs.ts | 2++
Mcommon/lib/site.ts | 7+------
Mcommon/lib/siteSchema.test.ts | 80+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcommon/lib/siteSchema.ts | 84++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
5 files changed, 185 insertions(+), 11 deletions(-)

diff --git a/SITE.md b/SITE.md @@ -20,6 +20,7 @@ Regenerate this file with `pnpm --filter yt-dlp-transcript-common exec tsx bin/f | [`groups`](#groups) | list — see below | | [`defaultGroupId`](#defaultgroupid) | `"default"` | | [`channels`](#channels) | `[]` | +| [`citedChannels`](#citedchannels) | `[]` | | [`cloudflareProject`](#cloudflareproject) | absent | | [`accent`](#accent) | absent | | [`siteUrl`](#siteurl) | absent | @@ -126,7 +127,7 @@ Default: `"default"` ## `channels` -The channels this site exposes. A channel absent from this list is not built or deployed for this site even though its data exists in the pool. +The channels this site exposes — its pool: what it builds, browses, searches and lists in its `/corpus.json`, and the pool its citations resolve against. A channel absent from this list is not built or deployed for this site even though its data exists in the pool (a channel in `citedChannels` publishes only what this site's reports cite). #### `channels[]` @@ -144,6 +145,24 @@ Default: [] ``` +## `citedChannels` + +Channels in the cited scope: channels this site's reports may cite without the site publishing them. A cited-only channel publishes only what the reports cite — the moment pages and their clips — with no browse page, search entry, transcripts, subs, digests or `/corpus.json` entry, and its moments link no corpus page. A slug already in `channels` is dropped (the pool wins). Written only when non-empty; absent = none. It fails closed: a reader that does not know the key drops it, and compose then refuses a citation of the channel as `not-in-site` — it never publishes the channel's transcripts. + +#### `citedChannels[]` + +Per entry — each entry spells its own values. + +| Key | Description | +|---|---| +| `slug` | Channel slug (its directory name under `transcripts/channels/`). Trimmed; blank and duplicate slugs are dropped, and so is a slug already in `channels`. | + +Default: + +```json +[] +``` + ## `cloudflareProject` Cloudflare Pages project name this site deploys to (`wrangler pages deploy out --project-name <cloudflareProject>`). Trimmed; blank = none. @@ -205,7 +224,7 @@ Default: ## `search` -Whether this site publishes its searchable corpus. Opt-OUT: absent/true = on, only an explicit `false` is written. Off = report-only: the site publishes only its `reports` and the moments they cite — no search, browse, transcripts or archives; `channels` is the pool its citations resolve against, and its `/corpus.json` says `"scope": "cited"`. A report-only site is never listed (as `listed: false`, whatever `listed` says). Legacy `publish: "cited"` reads as `false`. +Whether this site publishes its searchable corpus. Opt-OUT: absent/true = on, only an explicit `false` is written. Off = report-only: the site publishes only its `reports` and the moments they cite — no search, browse, transcripts or archives; `channels` is the pool its citations resolve against (with `citedChannels`), and its `/corpus.json` says `"scope": "cited"`. A report-only site is never listed (as `listed: false`, whatever `listed` says). Legacy `publish: "cited"` reads as `false`. Default: `true` diff --git a/common/lib/fileSchemaDocs.ts b/common/lib/fileSchemaDocs.ts @@ -27,6 +27,7 @@ import { SOCIAL_LINK_FIELD_DOCS } from "./settingsSchema"; import { RELATED_SITE_GROUP_FIELD_DOCS, SITE_CHANNEL_MEMBERSHIP_FIELD_DOCS, + SITE_CITED_CHANNEL_FIELD_DOCS, SITE_FIELD_DOCS, SITE_PUBLISH_FIELD_DOCS, parseSite, @@ -51,6 +52,7 @@ const SITE_NESTED: Partial<Record<keyof Site, KeyTable[]>> = { socialLinks: [{ path: "socialLinks[]", docs: SOCIAL_LINK_FIELD_DOCS }], groups: [{ path: "groups[]", docs: CHANNEL_GROUP_FIELD_DOCS }], channels: [{ path: "channels[]", docs: SITE_CHANNEL_MEMBERSHIP_FIELD_DOCS }], + citedChannels: [{ path: "citedChannels[]", docs: SITE_CITED_CHANNEL_FIELD_DOCS }], relatedSites: [{ path: "relatedSites[]", docs: RELATED_SITE_GROUP_FIELD_DOCS }], publish: [{ path: "publish", docs: SITE_PUBLISH_FIELD_DOCS }], }; diff --git a/common/lib/site.ts b/common/lib/site.ts @@ -18,6 +18,7 @@ import { isValidSiteId, parseSite, parseSiteUrl, + siteChannelSlugs, sitePublishProblem, siteToDisk, type Site, @@ -100,12 +101,6 @@ export function resolveHubUrl( return site.hubUrl ?? parseSiteUrl(settings.homepageUrl); } -// The set of channel slugs a site exposes. Used to scope the editor's -// site-specific views (dashboard, channels) down to one site's membership. -export function siteChannelSlugs(site: Site): Set<string> { - return new Set(site.channels.map((c) => c.slug)); -} - // siteId -> that site's channel slugs: the one shape `resolveFocusSlugs` // (lib/channelPriority.ts) resolves a `{kind:"site"}` focus against. // diff --git a/common/lib/siteSchema.test.ts b/common/lib/siteSchema.test.ts @@ -11,10 +11,14 @@ import { SITE_KEYS, channelsOnlyOnUnlistedSites, clampSitePublishPolicy, + isCitedOnlyChannel, isCitedSite, isListedSite, parseSite, + parseSiteCitedChannels, parseSiteReports, + siteChannelSlugs, + siteCitableChannelSlugs, siteFieldsSchema, sitePublishPolicy, sitePublishProblem, @@ -71,6 +75,7 @@ test("empty, null, [] and a number all read as the defaults, every key emitted", assert.deepEqual(want.relatedSites, []); assert.equal(want.search, true); assert.deepEqual(want.reports, []); + assert.deepEqual(want.citedChannels, []); assert.equal(want.socialLinks, undefined); assert.ok("socialLinks" in want); for (const raw of [null, [], 3, "x", undefined]) { @@ -239,6 +244,7 @@ function fixtures(): Array<[string, unknown]> { ], defaultGroupId: "b", channels: [{ slug: "c1", groupId: "a", order: 3 }, { slug: "c2", groupId: "q" }], + citedChannels: [{ slug: " k1 " }, { slug: "k1" }, { slug: "" }, { slug: "c1" }, "k2", { slug: "k3" }], cloudflareProject: "p", siteUrl: "https://s.example//", listed: false, @@ -532,3 +538,77 @@ test("writeSite refuses a public deploy policy with no cloudflareProject, naming await writeSite({ ...base, cloudflareProject: "proj", publish: { auto: "production" } }, paths); assert.deepEqual(getSite("s", paths).publish, { auto: "production" }); }); + +// RELEASE 23: the cited scope — channels a site's reports may cite without the +// site publishing them. +test("citedChannels: trimmed, blanks and repeats dropped, a pool slug dropped, absent reads []", () => { + assert.deepEqual( + parseSiteCitedChannels([{ slug: " a " }, { slug: "a" }, { slug: "" }, { slug: " " }, "b", null, { slug: 3 }, { slug: "c" }]), + [{ slug: "a" }, { slug: "c" }], + ); + for (const v of [undefined, null, "a", { slug: "a" }, 5]) { + assert.deepEqual(parseSite("s", v === undefined ? {} : { citedChannels: v }).citedChannels, [], String(v)); + } + // The pool wins: a slug already in `channels` is not cited-only. + const site = parseSite("s", { + channels: [{ slug: "pool" }], + citedChannels: [{ slug: "pool" }, { slug: "critic" }, { slug: "critic" }], + }); + assert.deepEqual(site.citedChannels, [{ slug: "critic" }]); + assert.deepEqual([...siteChannelSlugs(site)], ["pool"]); + assert.deepEqual([...siteCitableChannelSlugs(site)].sort(), ["critic", "pool"]); + assert.equal(isCitedOnlyChannel(site, "critic"), true); + assert.equal(isCitedOnlyChannel(site, "pool"), false); + assert.equal(isCitedOnlyChannel(site, "nobody"), false); + // A hand-built Site holding a slug in both reads as the pool's. + assert.equal(isCitedOnlyChannel({ channels: [{ slug: "x" }], citedChannels: [{ slug: "x" }] }, "x"), false); + assert.deepEqual([...siteCitableChannelSlugs({ channels: [] })], []); +}); + +test("citedChannels: written only when non-empty, re-parsed and pool-filtered on the way out", () => { + assert.equal("citedChannels" in siteToDisk(parseSite("s", {})), false); + assert.equal("citedChannels" in siteToDisk(parseSite("s", { citedChannels: [] })), false); + const site = parseSite("s", { channels: [{ slug: "pool" }], citedChannels: [{ slug: "critic" }] }); + const disk = siteToDisk(site) as Record<string, unknown>; + assert.deepEqual(disk.citedChannels, [{ slug: "critic" }]); + // Written beside the pool, after `channels`. + const keys = Object.keys(disk); + assert.equal(keys.indexOf("citedChannels"), keys.indexOf("channels") + 1); + // A caller's list is re-parsed: blanks, repeats and pool slugs are not persisted. + assert.deepEqual( + siteToDisk({ ...site, citedChannels: [{ slug: " critic " }, { slug: "critic" }, { slug: "pool" }, { slug: "" }] }) + .citedChannels, + [{ slug: "critic" }], + ); + assert.equal("citedChannels" in siteToDisk({ ...site, citedChannels: [{ slug: "pool" }] }), false); +}); + +test("writeSite → getSite round-trips citedChannels, and patchSite keeps the key", async () => { + const paths = scratchPaths(await mkdtemp(path.join(os.tmpdir(), "site-"))); + const site = parseSite("s", { + channels: [{ slug: "pool" }], + citedChannels: [{ slug: "critic" }, { slug: "other-critic" }], + search: false, + reports: ["one"], + }); + await writeSite(site, paths); + assert.deepEqual(getSite("s", paths), site); + const disk = JSON.parse(await readFile(siteConfigFile(paths, "s"), "utf8")); + assert.deepEqual(disk.citedChannels, [{ slug: "critic" }, { slug: "other-critic" }]); + // A surface that patches another key leaves the cited scope as it is. + const patched = await patchSite("s", { reports: ["one", "two"] }, paths); + assert.deepEqual(patched?.citedChannels, [{ slug: "critic" }, { slug: "other-critic" }]); + // Emptied, the key leaves the file. + await patchSite("s", { citedChannels: [] }, paths); + const after = JSON.parse(await readFile(siteConfigFile(paths, "s"), "utf8")); + assert.equal("citedChannels" in after, false); + assert.deepEqual(getSite("s", paths).citedChannels, []); +}); + +test("channelsOnlyOnUnlistedSites ignores cited-only slugs: the cited scope publishes no channel", () => { + const sites = [ + parseSite("shown", { channels: [{ slug: "shared" }], citedChannels: [{ slug: "critic" }] }), + parseSite("hidden", { listed: false, channels: [{ slug: "secret" }], citedChannels: [{ slug: "critic2" }] }), + ]; + assert.deepEqual([...channelsOnlyOnUnlistedSites(sites)], ["secret"]); +}); diff --git a/common/lib/siteSchema.ts b/common/lib/siteSchema.ts @@ -62,6 +62,15 @@ export const SITE_CHANNEL_MEMBERSHIP_FIELD_DOCS: FieldDocs<SiteChannelMembership order: "Optional explicit ordering hint within the site (lower first); floored to an integer.", }; +// Each field is documented in SITE_CITED_CHANNEL_FIELD_DOCS below. +export type SiteCitedChannel = { + slug: string; +}; + +export const SITE_CITED_CHANNEL_FIELD_DOCS: FieldDocs<SiteCitedChannel> = { + slug: "Channel slug (its directory name under `transcripts/channels/`). Trimmed; blank and duplicate slugs are dropped, and so is a slug already in `channels`.", +}; + // Each field is documented in RELATED_SITE_GROUP_FIELD_DOCS below. export type RelatedSiteGroup = { label?: string; @@ -148,6 +157,7 @@ export type Site = { groups: ChannelGroup[]; defaultGroupId: string; channels: SiteChannelMembership[]; + citedChannels?: SiteCitedChannel[]; cloudflareProject?: string; accent?: string; siteUrl?: string; @@ -181,7 +191,9 @@ export const SITE_FIELD_DOCS: FieldDocs<Site> = { defaultGroupId: "The group a channel falls into when its membership names none (or an unknown one). Must name a configured group on save; on read an unknown value resolves to the first group.", channels: - "The channels this site exposes. A channel absent from this list is not built or deployed for this site even though its data exists in the pool.", + "The channels this site exposes — its pool: what it builds, browses, searches and lists in its `/corpus.json`, and the pool its citations resolve against. A channel absent from this list is not built or deployed for this site even though its data exists in the pool (a channel in `citedChannels` publishes only what this site's reports cite).", + citedChannels: + "Channels in the cited scope: channels this site's reports may cite without the site publishing them. A cited-only channel publishes only what the reports cite — the moment pages and their clips — with no browse page, search entry, transcripts, subs, digests or `/corpus.json` entry, and its moments link no corpus page. A slug already in `channels` is dropped (the pool wins). Written only when non-empty; absent = none. It fails closed: a reader that does not know the key drops it, and compose then refuses a citation of the channel as `not-in-site` — it never publishes the channel's transcripts.", cloudflareProject: "Cloudflare Pages project name this site deploys to (`wrangler pages deploy out --project-name <cloudflareProject>`). Trimmed; blank = none.", accent: @@ -197,7 +209,7 @@ export const SITE_FIELD_DOCS: FieldDocs<Site> = { relatedSites: "Pulls specific siblings to the front of the footer's cross-site list, in named groups. Siblings not named here fall into a trailing \"Other sites\" group. Absent/empty = one flat list of every sibling.", search: - "Whether this site publishes its searchable corpus. Opt-OUT: absent/true = on, only an explicit `false` is written. Off = report-only: the site publishes only its `reports` and the moments they cite — no search, browse, transcripts or archives; `channels` is the pool its citations resolve against, and its `/corpus.json` says `\"scope\": \"cited\"`. A report-only site is never listed (as `listed: false`, whatever `listed` says). Legacy `publish: \"cited\"` reads as `false`.", + "Whether this site publishes its searchable corpus. Opt-OUT: absent/true = on, only an explicit `false` is written. Off = report-only: the site publishes only its `reports` and the moments they cite — no search, browse, transcripts or archives; `channels` is the pool its citations resolve against (with `citedChannels`), and its `/corpus.json` says `\"scope\": \"cited\"`. A report-only site is never listed (as `listed: false`, whatever `listed` says). Legacy `publish: \"cited\"` reads as `false`.", pwa: "Whether this site ships an installable PWA (service worker + web manifest). Default false: a \"dumb instance\" that serves the CORS-enabled JSON federation contract but is not independently installable, so a visitor trusts only the hub PWA. Stored only when true.", archives: @@ -286,6 +298,35 @@ export function isListedSite(site: Pick<Site, "listed" | "audience" | "search">) return site.listed !== false && !isPrivateSite(site) && !isCitedSite(site); } +// THE POOL: the channel slugs a site exposes — builds, browses, searches and +// lists in its corpus.json. Pool-only: a cited-only channel (`citedChannels`) +// is not here. Used to scope the editor's site-specific views (dashboard, +// channels) and everything a build publishes per channel. +export function siteChannelSlugs(site: Pick<Site, "channels">): Set<string> { + return new Set(site.channels.map((c) => c.slug)); +} + +// THE CITABLE SET: the pool plus the cited-only channels — what a report on +// this site may cite (compose's and reportMedia's membership checks). Never a +// publish set: a cited-only channel publishes only the moments cited. +export function siteCitableChannelSlugs( + site: Pick<Site, "channels" | "citedChannels">, +): Set<string> { + const out = siteChannelSlugs(site); + for (const c of site.citedChannels ?? []) out.add(c.slug); + return out; +} + +// THE ONE PREDICATE for a cited-only channel on a site: in `citedChannels` and +// not in the pool (the pool wins, as the parser drops such a slug anyway). +export function isCitedOnlyChannel( + site: Pick<Site, "channels" | "citedChannels">, + slug: string, +): boolean { + if (site.channels.some((c) => c.slug === slug)) return false; + return (site.citedChannels ?? []).some((c) => c.slug === slug); +} + // The channels whose content belongs to unlisted sites alone: exposed by at // least one site, and by no listed one. No public total counts them. A channel // a listed site also exposes is not here (it is credited to the listed site), @@ -329,6 +370,33 @@ export function parseSiteChannels(input: unknown): SiteChannelMembership[] { return out; } +// Parse the cited-only channels: trimmed slugs, blanks and repeats dropped, +// order preserved. Dropping a slug already in `channels` is the object step's +// (it needs the sibling key). +export function parseSiteCitedChannels(input: unknown): SiteCitedChannel[] { + if (!Array.isArray(input)) return []; + const out: SiteCitedChannel[] = []; + const seen = new Set<string>(); + for (const raw of input) { + if (!raw || typeof raw !== "object") continue; + const r = raw as Record<string, unknown>; + const slug = typeof r.slug === "string" ? r.slug.trim() : ""; + if (!slug || seen.has(slug)) continue; + seen.add(slug); + out.push({ slug }); + } + return out; +} + +// The cited-only channels with any slug the pool already holds removed. +function citedOutsidePool( + cited: readonly SiteCitedChannel[], + channels: readonly SiteChannelMembership[], +): SiteCitedChannel[] { + const pool = new Set(channels.map((c) => c.slug)); + return cited.filter((c) => !pool.has(c.slug)); +} + // Normalize a raw siteUrl into a trimmed absolute http(s) URL with no trailing // slash, or undefined when missing/not a usable absolute URL. Relative or // scheme-less values are rejected — a cross-site link must be absolute. @@ -406,6 +474,8 @@ export const siteFieldsSchema = z.object({ // Resolved against `groups` in the object step below. defaultGroupId: settingsField((v): unknown => v).describe(d.defaultGroupId), channels: settingsField(parseSiteChannels).describe(d.channels), + // A slug already in `channels` is dropped in the object step below. + citedChannels: settingsField(parseSiteCitedChannels).describe(d.citedChannels), cloudflareProject: settingsField((v): string | undefined => typeof v === "string" && v.trim() ? v.trim() : undefined, ).describe(d.cloudflareProject), @@ -435,7 +505,7 @@ export const siteFieldsSchema = z.object({ publish: settingsField(parseSitePublish).describe(d.publish), }); -// The whole schema: the per-key object, then the three sibling-dependent +// The whole schema: the per-key object, then the four sibling-dependent // fields. // // THE OBJECT STEP ALSO RE-EMITS EVERY KEY, in order. zod 4 omits a key that was @@ -461,6 +531,8 @@ export const siteSchema = z.preprocess(migrateLegacyPublish, siteFieldsSchema).t } return c; }), + // The pool wins: a cited-only slug the pool already holds is dropped. + citedChannels: citedOutsidePool(s.citedChannels, s.channels), // A private site at most builds; no Pages project, no deploy policy. publish: s.publish ? { auto: clampSitePublishPolicy(s, s.publish.auto) } : undefined, }; @@ -490,6 +562,10 @@ export function siteToDisk(site: Site): Site { const channels = parseSiteChannels(site.channels).filter( (c) => !c.groupId || groups.some((g) => g.id === c.groupId), ); + const citedChannels = citedOutsidePool( + parseSiteCitedChannels(site.citedChannels), + channels, + ); const relatedSites = parseRelatedSites(site.relatedSites); const reports = parseSiteReports(site.reports); const accent = parseAccentSetting(site.accent); @@ -512,6 +588,8 @@ export function siteToDisk(site: Site): Site { groups, defaultGroupId: site.defaultGroupId, channels, + // None is the default: only a non-empty cited scope is persisted. + ...(citedChannels.length > 0 ? { citedChannels } : {}), ...(site.cloudflareProject && site.cloudflareProject.trim() ? { cloudflareProject: site.cloudflareProject.trim() } : {}),