commit 41d075a8d1f27d61c874c79916e08278754694de parent 482b91ee7be86cd3811e1d73b96f48a51829983b Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st> Date: Sun, 11 Oct 2026 14:52:23 -0400 Merge branch 'r26/integration' into r26/store # Conflicts: # common/lib/builtExport.ts # common/publish/composeReports.ts # common/publish/composeReportsArticles.test.ts # common/publish/reportExports.ts # common/publish/reportHistory.ts # common/publish/reportHost.ts Diffstat:
96 files changed, 1310 insertions(+), 1084 deletions(-)
diff --git a/PUBLISH.md b/PUBLISH.md @@ -57,7 +57,8 @@ for exactly the records that can hold one. ### Reports and cited sites -A site with `reports` (site.json) has two more steps, before its build and on the +A site with `pages` (site.json — its reports, each served at `/pages/<id>/` and linked +from the header by its title; `reports` before release 26) has two more steps, before its build and on the host. First, **fetch the missing evidence**: *Fetch missing evidence* on the Reports tab, or `pnpm ops fetch-windows --json '{"siteId":"<id>"}' --wait`, fetches the window of every cited span whose media is not on disk, through the editor's managed @@ -117,12 +118,12 @@ and only a file of at most 24 MiB: a larger pack stays on the host; the page's download line lists what was published), its cited stills (never a saved source copy), one page per cited moment with the transcript lines around it, the prepared clips and captures — only those the published reports cite — and each report's revision -history: `reports/<id>/history/history.json` (every revision's number, date, commit, -report sha256, change summary and claim-level word diff, which `/reports/<id>/history/` -renders) and a dumb-HTTP clone at `reports/<id>/history/repo/`, staged as the source +history: `pages/<id>/history/history.json` (every revision's number, date, commit, +report sha256, change summary and claim-level word diff, which `/pages/<id>/history/` +renders) and a dumb-HTTP clone at `pages/<id>/history/repo/`, staged as the source mirror is (a fresh bare clone, `repack -a -d`, `update-server-info`, then only `HEAD`, `packed-refs`, `info/refs`, `objects/info/packs`, the packs and `refs/heads/main`), so -`git clone <siteUrl>/reports/<id>/history/repo` works. The deploy audit refuses any other +`git clone <siteUrl>/pages/<id>/history/repo` works. The deploy audit refuses any other file in a clone or one over 24 MiB, and counts the clone's files toward Pages' 20,000. Every quote is checked as it is composed: a span's against its cues within 5 s either side (read under the caption-track rule — `en-orig` first, then the first English track with cues — and against every diff --git a/REPORT.md b/REPORT.md @@ -7,7 +7,7 @@ One cited report, format `"archilyzer-report"`, version 1, persisted as `report. A report lives in one of two stores: - **An article** — `transcripts/reports/<reportId>/report.json`, published by the project homepage. `transcripts/reports/index.json` — `{"published": [ids]}` — is the published, ordered list; an article directory it does not name is a draft. An article's `audience` (below) says which homepage build carries it: the public one only `"public"` articles, the private one every published article. An article may cite any channel of the corpus. -- **A site's page** — `transcripts/sites/<siteId>/reports/<reportId>/report.json`, published by its site: the site's `reports` list in `site.json` is the published, ordered list — see [SITE.md](SITE.md). A page cites the site's `channels` and `citedChannels`. +- **A site's page** — `transcripts/sites/<siteId>/reports/<reportId>/report.json`, published by its site at `/pages/<reportId>/`: the site's `pages` list in `site.json` is the published, ordered list — see [SITE.md](SITE.md). A page cites the site's `channels` and `citedChannels`. `index.json` and an article's `audience` are written ONLY through `common/lib/report/registry.ts` (`configureArticle`, `setPublished`, `setArticlesOrder`, `patchArticle`, `writeArticle`: locked, validated, atomic) and `pnpm ops articles-config` (`{"id", "audience"?, "published"?, "position"?}`), never by hand. Only a sound article (no problem below) is published; a patch may not add a problem to an article. @@ -23,7 +23,7 @@ Regenerate this file with `pnpm --filter yt-dlp-transcript-common exec tsx bin/f |---|---|---| | `format` | yes | `"archilyzer-report"`. | | `version` | yes | `1`. | -| `id` | yes | The report's id: a lowercase slug (`[a-z0-9][a-z0-9-]*`, at most 64), its directory name under `reports/` and the last segment of its page, `/reports/<id>/`. Must match the directory. | +| `id` | yes | The report's id: a lowercase slug (`[a-z0-9][a-z0-9-]*`, at most 64), its directory name under `reports/` and the last segment of its page (on a site, `/pages/<id>/`). Must match the directory. | | `kind` | yes | `"factcheck"` — sections of claims, each with a verdict — or `"sweep"` — sections with no verdicts, or bodies with inline citations. | | `audience` | no | Who may read the report when it is an ARTICLE (in `transcripts/reports/`, published by the homepage): `"public"` — the public homepage build carries it — or `"private"` — only the private build (`archilyzer build homepage --private`, never deployed) does. Absent = `"private"`: going public is an explicit `pnpm ops articles-config`. Ignored on a site's page, which has its site's audience. | | `series` | no | The series the report belongs to: a recurring name for its kind of report. It is shown on its own line above the title, in the accent colour, at the head of the report's page, its exports and the report list (where a report with no series shows its kind instead), and is joined to the title as `<series>: <title>` where one line names the report (a page title, a link, a cited-in entry). | @@ -69,7 +69,7 @@ Regenerate this file with `pnpm --filter yt-dlp-transcript-common exec tsx bin/f ## The timeline -A report may keep a timeline: `entries`, dated blocks a reader sees newest first under **Timeline**, after the summary and before what the check found and the claims — on its page, in its exports and as one slide each. Entries of the same instant keep their order in the file. Each entry's id is its anchor (`#<id>`). Its citations are numbered with the rest, in the page's order. A report with a newer entry than its own `updated` is shown as updated then (the index, the header, the feeds). On a site with a public `siteUrl`, compose publishes the timeline as feeds beside the page — `/reports/<id>/feed.xml` (RSS 2.0) and `/reports/<id>/feed.json` (JSON Feed 1.1), one item per entry, its permalink the page at its anchor — and the page links them ("Subscribe", and `<link rel="alternate">`). A site with no `siteUrl` publishes no feed. +A report may keep a timeline: `entries`, dated blocks a reader sees newest first under **Timeline**, after the summary and before what the check found and the claims — on its page, in its exports and as one slide each. Entries of the same instant keep their order in the file. Each entry's id is its anchor (`#<id>`). Its citations are numbered with the rest, in the page's order. A report with a newer entry than its own `updated` is shown as updated then (the index, the header, the feeds). On a site with a public `siteUrl`, compose publishes the timeline as feeds beside the page — `/pages/<id>/feed.xml` (RSS 2.0) and `/pages/<id>/feed.json` (JSON Feed 1.1), one item per entry, its permalink the page at its anchor — and the page links them ("Subscribe", and `<link rel="alternate">`). A site with no `siteUrl` publishes no feed. #### `entries[]` diff --git a/SITE.md b/SITE.md @@ -26,7 +26,7 @@ Regenerate this file with `pnpm --filter yt-dlp-transcript-common exec tsx bin/f | [`siteUrl`](#siteurl) | absent | | [`listed`](#listed) | `true` | | [`audience`](#audience) | absent | -| [`reports`](#reports) | `[]` | +| [`pages`](#pages) | `[]` | | [`relatedSites`](#relatedsites) | `[]` | | [`search`](#search) | `true` | | [`pwa`](#pwa) | `false` | @@ -193,9 +193,9 @@ Who this site is built for. `"public"` (the default; absent) or `"private"`: the Default: absent -## `reports` +## `pages` -The site's published reports, in display order: report ids (lowercase slugs, `[a-z0-9][a-z0-9-]*`), each a directory under `sites/<siteId>/reports/`. A report directory not named here is a draft and is not published. Invalid and repeated ids are dropped. Absent/empty = no reports. +The site's pages, in order: report ids (lowercase slugs, `[a-z0-9][a-z0-9-]*`), each a directory under `sites/<siteId>/reports/` holding a report document. Each is served at `/pages/<id>/` and linked from the site's header by its title; a report directory not named here is a draft and is not published. Invalid and repeated ids are dropped. Absent/empty = no pages. Legacy `reports` (the key before release 26) reads as `pages` when `pages` is absent, and is never written. Default: @@ -224,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 (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`. +Whether this site publishes its searchable corpus. Opt-OUT: absent/true = on, only an explicit `false` is written. Off = pages only: the site publishes only its `pages` and the moments they cite — no search, browse, transcripts or archives; its home page is its first page; `channels` is the pool its citations resolve against (with `citedChannels`), and its `/corpus.json` says `"scope": "cited"`. A save with search off and no `pages` is refused. A search-off site is never listed (as `listed: false`, whatever `listed` says). Legacy `publish: "cited"` reads as `false`. Default: `true` diff --git a/common/bin/compose-hub.ts b/common/bin/compose-hub.ts @@ -121,7 +121,10 @@ export const SITE_ONLY_PUBLIC_ENTRIES: readonly string[] = [ "digests", "stats", "archives", - // A report site's reports, moments and cited media (publish/composeReports.ts). + // A site's pages (its reports), moments and cited media + // (publish/composeReports.ts), and where a site's reports were before + // release 26. + "pages", "reports", "m", "media", diff --git a/common/bin/compose-site.ts b/common/bin/compose-site.ts @@ -9,8 +9,8 @@ // public/transcripts/<slug>/ <- shared/transcripts/<slug>/ (site's members) // public/stats/* <- sites/<id>/stats/ (per-site) // public/chart-templates.json <- sites/<id>/chart-templates.json (per-site) -// public/reports/, m/, media/ <- the site's reports, resolved against the -// corpus (publish/composeReports.ts) +// public/pages/, m/, media/ <- the site's pages (its reports), resolved +// against the corpus (publish/composeReports.ts) // // Only the site's member channels are composed, so each deployed bundle holds // only that site's data. Checked-in static assets in public/ are left intact. diff --git a/common/bin/move-reports-to-articles.test.ts b/common/bin/move-reports-to-articles.test.ts @@ -41,14 +41,15 @@ const doc = (id: string, over: Record<string, unknown> = {}) => ({ sections: [{ id: "s", title: "S", body: "Words." }], ...over, }); -function site(id: string, reports: string[], extra: Record<string, unknown> = {}) { +// `key`: site-a is written with the pre-release-26 key, which reads as `pages`. +function site(id: string, pages: string[], extra: Record<string, unknown> = {}, key: "pages" | "reports" = "pages") { put(path.join(paths.sitesDir, id, "site.json"), { siteId: id, siteTitle: id, groups: [{ id: "default", name: "All", selectedByDefault: true }], defaultGroupId: "default", channels: [], - reports, + [key]: pages, ...extra, }); } @@ -60,7 +61,7 @@ function capture() { // Two sites: a report-only private one with two listed reports (one with a // problem) and a draft; a full one with a page it keeps and one to move. -site("site-a", ["alpha", "beta"], { search: false, audience: "private" }); +site("site-a", ["alpha", "beta"], { search: false, audience: "private" }, "reports"); put(path.join(reportDir("site-a", "alpha"), "report.json"), doc("alpha")); put(path.join(reportDir("site-a", "alpha"), "notes.json"), { format: "umtool-notes", version: 1, notes: [] }); put(path.join(reportDir("site-a", "alpha"), "history-git", "HEAD"), "ref: refs/heads/main\n"); @@ -105,7 +106,7 @@ test("a dry run prints the plan and writes nothing", async () => { assert.match(text, /move {3}site-a\/alpha → reports\/alpha\/ {2}published, audience private/); assert.match(text, /move {3}site-a\/beta → reports\/beta\/ {2}draft \(1 problem\(s\) in report\.json\)/); assert.match(text, /keep {3}site-b\/page-kept/); - assert.match(text, /retire site-a: search off and no reports left/); + assert.match(text, /retire site-a: search off and no pages left — saved with search on, as an empty site; delete it on \/sites/); assert.match(text, /3 to move \(2 published\), 1 kept, 0 refusal/); assert.match(text, /dry run: nothing moved/); assert.equal(snapshot(), before); @@ -119,8 +120,14 @@ test("--apply: moved whole, private, published in the sites' order, off the site assert.equal(existsSync(reportDir("site-a", "alpha")), false); assert.deepEqual(readJson(path.join(paths.articlesDir, "index.json")), { published: ["alpha", "gamma"] }); for (const id of ["alpha", "beta", "gamma"]) assert.equal(readJson(art(id, "report.json")).audience, "private", id); - assert.deepEqual(readJson(path.join(paths.sitesDir, "site-a", "site.json")).reports ?? [], []); - assert.deepEqual(readJson(path.join(paths.sitesDir, "site-b", "site.json")).reports, ["page-kept"]); + // The emptied search-off site is retired: no pages, search on (a save + // refuses search off with none); the legacy key is gone from both files. + const a = readJson(path.join(paths.sitesDir, "site-a", "site.json")); + assert.equal("pages" in a || "reports" in a || "search" in a, false, JSON.stringify(a)); + assert.equal(a.audience, "private"); + const b = readJson(path.join(paths.sitesDir, "site-b", "site.json")); + assert.deepEqual(b.pages, ["page-kept"]); + assert.equal("reports" in b, false); assert.ok(existsSync(path.join(reportDir("site-b", "page-kept"), "report.json"))); // The unlisted draft stays without --drafts. assert.ok(existsSync(path.join(reportDir("site-a", "draft-one"), "report.json"))); diff --git a/common/bin/move-reports-to-articles.ts b/common/bin/move-reports-to-articles.ts @@ -15,7 +15,7 @@ // id order, each site's reports in its order — through the registry // (configureArticle), which publishes only a sound article: one with // problems is moved as a DRAFT, and the plan says so; -// 4. the site's list drops it (patchSite). +// 4. the site's list (`pages`) drops it (patchSite). // `--drafts` moves the sites' unlisted report directories too, as drafts. // // REFUSED BEFORE ANYTHING MOVES: an id two sites both use, an id that @@ -24,8 +24,14 @@ // // Not moved: the staging a site's prepare and export wrote // (`.export-index/sites/<site>/report-{media,exports}/`) — run -// `archilyzer reports prepare --article <id>` for the articles afterwards. A -// search-off site left with no reports is named in the plan, to be retired. +// `archilyzer reports prepare --article <id>` for the articles afterwards. +// +// A SEARCH-OFF SITE LEFT WITH NO PAGES is retired: a save refuses a search-off +// site with none (siteSearchProblem, D5), so the patch that drops its last +// page turns its search on in the same write — it is saved as an empty site +// (no channels, no pages), which validates, builds nothing worth deploying and +// is never listed while private. The plan names it; delete it on /sites (or +// keep it) once the move is checked. Nothing about it is deleted here. // // Stop the editor's report jobs first (a prepare reads these directories). // Exit 0 when the plan is clean (and applied, with --apply); 1 when it was @@ -137,7 +143,17 @@ export async function applyMove(paths: Paths, plan: MovePlan, log: (line: string await moveDir(m.from, m.to); await patchArticle(m.id, { audience: "private" }, paths); if (m.publish) await configureArticle(m.id, { published: true }, paths); - if (m.listed) await patchSite(m.site, (cur) => ({ reports: siteList(cur).filter((x) => x !== m.id) }), paths); + if (m.listed) { + await patchSite( + m.site, + (cur) => { + const pages = siteList(cur).filter((x) => x !== m.id); + // Its last page gone, a search-off site is retired (see above). + return pages.length === 0 && isCitedSite(cur) ? { pages, search: true } : { pages }; + }, + paths, + ); + } log(`moved ${m.site}/${m.id} → reports/${m.id}/${m.publish ? " (published)" : " (draft)"}`); } } @@ -150,7 +166,9 @@ export function formatPlan(plan: MovePlan): string[] { ); } for (const k of plan.kept) out.push(`keep ${k} (a page of its site)`); - for (const s of plan.emptied) out.push(`retire ${s}: search off and no reports left`); + for (const s of plan.emptied) { + out.push(`retire ${s}: search off and no pages left — saved with search on, as an empty site; delete it on /sites`); + } for (const r of plan.refusals) out.push(`REFUSED ${r}`); out.push( `${plan.moves.length} to move (${plan.moves.filter((m) => m.publish).length} published), ${plan.kept.length} kept, ${plan.refusals.length} refusal(s).`, @@ -158,10 +176,9 @@ export function formatPlan(plan: MovePlan): string[] { return out; } -// A site's published list. Release 26 A5 renames site.json `reports` to -// `pages`; this reads either until the two branches meet. +// A site's published list: site.json `pages` (a legacy `reports` reads as it). function siteList(site: Site): string[] { - return (site as Site & { pages?: string[] }).pages ?? site.reports ?? []; + return site.pages ?? []; } const exists = async (p: string) => !!(await stat(p).catch(() => null)); diff --git a/common/bin/reports-check.ts b/common/bin/reports-check.ts @@ -80,7 +80,7 @@ export async function checkMain( return 2; } const site = getSite(opts.siteId, paths); - host = siteReportHost(paths, { ...site, reports: opts.reports ?? site.reports ?? [] }); + host = siteReportHost(paths, { ...site, pages: opts.reports ?? site.pages ?? [] }); } if (host.published.length === 0) { out.log(`reports check ${who}: the site publishes no reports — nothing to check.`); diff --git a/common/components/report/ReportIndex.tsx b/common/components/report/ReportIndex.tsx @@ -2,10 +2,9 @@ import Link from "next/link"; import type { ReportIndexView } from "../../lib/report/views"; import { EmptyState, Eyebrow, ReportName, dateLabel } from "./parts"; -// The report index: `/reports/`, and a cited site's home page when it has more -// than one report. One card per published report, in the site's order -// (site.json `reports`): its name, subtitle and dates -- its counts and tally -// are the report page's. `heading: null` draws no heading (the home page: the +// A report index: one card per published report, in the index's order: its +// name, subtitle and dates -- its counts and tally are the report page's. (A +// site has none since release 26: its header links each page by its title.) `heading: null` draws no heading (the home page: the // header already names the site). `empty` is what an index with nothing in it // says. diff --git a/common/components/report/exportSlides.test.ts b/common/components/report/exportSlides.test.ts @@ -64,7 +64,7 @@ function view(r = report()): ReportPageView { const FOOTER = { revision: 2, date: "2026-10-04", reportSha256: "ab".repeat(32) }; const images: Record<string, string> = { "/media/posters/abc123.png": "data:image/png;base64,AAA", - "/reports/demo/stills/a1.png": "data:image/png;base64,BBB", + "/pages/demo/stills/a1.png": "data:image/png;base64,BBB", "/media/posts/demo-social/123/shot.png": "data:image/png;base64,CCC", }; const html = (v = view(), siteUrl = "https://site.example/") => @@ -90,7 +90,7 @@ test("one file: the stylesheet and the script inline, every picture the resolver // The clip's poster on k1's evidence, the still on the section's; k2's // quote shows its post's words, not its capture. assert.deepEqual(srcs.sort(), ["data:image/png;base64,AAA", "data:image/png;base64,BBB"]); - assert.deepEqual(slidesImagePaths(view()), ["/media/posters/abc123.png", "/reports/demo/stills/a1.png"]); + assert.deepEqual(slidesImagePaths(view()), ["/media/posters/abc123.png", "/pages/demo/stills/a1.png"]); // The site's accent, on the light base. assert.match(out, /<html lang="en" class="rs-root" style="--brand:#6a4bc4;/); // Escaped, as everywhere. @@ -99,8 +99,8 @@ test("one file: the stylesheet and the script inline, every picture the resolver test("the way back: each slide links to its place in the article on the site; with no site, nowhere", () => { const out = html(); - assert.match(out, /href="https:\/\/site\.example\/reports\/demo\/#k1" data-slide-read="k1"/); - assert.match(out, /href="https:\/\/site\.example\/reports\/demo\/#report-end" data-slide-read="report-end"/); + assert.match(out, /href="https:\/\/site\.example\/pages\/demo\/#k1" data-slide-read="k1"/); + assert.match(out, /href="https:\/\/site\.example\/pages\/demo\/#report-end" data-slide-read="report-end"/); assert.doesNotMatch(html(view(), ""), /data-slide-read=/); // A citation's number goes to the reference list under the deck, which links out. assert.match(out, /<a href="#c-v1">\[1\]<\/a>/); @@ -114,7 +114,7 @@ test("a timeline entry is a slide: its date, its title, its first sentences", () out, /data-slide="entry:e1" data-slide-kind="entry" data-layout="statement"[^>]*>.*<b>Timeline<\/b> · 1 of 1.*<p class="rs-dates"><time datetime="2026-10-03T08:00:00Z">2026-10-03<\/time><\/p><h2 class="rs-h">An update<\/h2><div class="rs-statement"><div class="rs-md"><p>It moved<sup[^>]*><a href="#c-v1">\[1\]<\/a><\/sup>\. Then more\.<\/p>/s, ); - assert.match(out, /href="https:\/\/site\.example\/reports\/demo\/#e1" data-slide-read="e1"/); + assert.match(out, /href="https:\/\/site\.example\/pages\/demo\/#e1" data-slide-read="e1"/); }); test("the sources slide names which document this is", () => { @@ -133,7 +133,7 @@ test("the string slides mirror Slide.tsx: the same `rs-` classes, slide by slide const articles = out.split(/(?=<article class="rs-slide")/).slice(1).map((a) => a.slice(0, a.indexOf("</article>") + 10)); slides.forEach((s, i) => { const react = renderToStaticMarkup( - React.createElement(Slide, { slide: s, view: v, total: slides.length, pageUrl: "https://site.example/reports/demo/" }), + React.createElement(Slide, { slide: s, view: v, total: slides.length, pageUrl: "https://site.example/pages/demo/" }), ); assert.deepEqual(classes(articles[i]), classes(react), s.key); }); diff --git a/common/components/report/renderer.test.ts b/common/components/report/renderer.test.ts @@ -21,7 +21,7 @@ const history: ReportHistoryView = { reportId: "demo", title: "Demo", branch: "main", - clone: "/reports/demo/history/repo", + clone: "/pages/demo/history/repo", revisions: [{ revision: 1, date: "2026-10-01T09:00:00Z", commit: "c".repeat(40), reportSha256: "a".repeat(64), summary: [], claims: [] }], }; @@ -37,12 +37,12 @@ const moment: MomentPageView = { test("a history page links its report and its history.json under the site's base, or the one it is given", () => { const site = renderToStaticMarkup(h(ReportHistory, { view: history })); - assert.match(site, /href="\/reports\/demo\/"/); - assert.match(site, /href="\/reports\/demo\/history\/history.json"/); + assert.match(site, /href="\/pages\/demo\/"/); + assert.match(site, /href="\/pages\/demo\/history\/history.json"/); const other = renderToStaticMarkup(h(ReportHistory, { view: history, base: "/articles/" })); assert.match(other, /href="\/articles\/demo\/"/); assert.match(other, /href="\/articles\/demo\/history\/history.json"/); - assert.doesNotMatch(other, /href="\/reports\//); + assert.doesNotMatch(other, /href="\/pages\//); }); test("a moment opens in the archive at the view's corpus link, or the resolver's, or nowhere", () => { diff --git a/common/components/report/slides/ReportReader.tsx b/common/components/report/slides/ReportReader.tsx @@ -82,7 +82,7 @@ export function ReportReader({ series, views = READER_VIEWS, }: { - // The report's page view (/reports/<id>/page.json). + // The report's page view (`<base><id>/page.json`, lib/report/routes.ts). pagePath: string; title: string; series?: string; diff --git a/common/lib/archive/headers.test.ts b/common/lib/archive/headers.test.ts @@ -174,12 +174,12 @@ test("every rendered entry is one path line and one indented header", () => { }); // A report's timeline feeds (lib/report/feeds.ts) are served with their own -// media type, and readable cross-origin (no site CORS rule covers reports/). +// media type, and readable cross-origin (no site CORS rule covers pages/). const SITE_TYPES_BLOCK = `# Served with their own media type. -/reports/:report/feed.xml +/pages/:report/feed.xml Content-Type: application/rss+xml; charset=utf-8 Access-Control-Allow-Origin: * -/reports/:report/feed.json +/pages/:report/feed.json Content-Type: application/feed+json; charset=utf-8 Access-Control-Allow-Origin: * `; @@ -197,6 +197,6 @@ test("renderHeadersFile: a site's typed paths follow its CORS lines, before the test("the typed paths are the report feeds' files and media types", () => { assert.deepEqual( SITE_TYPED_PATHS, - REPORT_FEED_FORMATS.map((f) => ({ path: `/reports/:report/${REPORT_FEED_FILENAMES[f]}`, type: `${REPORT_FEED_MIME[f]}; charset=utf-8` })), + REPORT_FEED_FORMATS.map((f) => ({ path: `/pages/:report/${REPORT_FEED_FILENAMES[f]}`, type: `${REPORT_FEED_MIME[f]}; charset=utf-8` })), ); }); diff --git a/common/lib/archive/headers.ts b/common/lib/archive/headers.ts @@ -11,6 +11,7 @@ // `CONTRACT` / `ROOT_FILES`, no `node:*`. import { CONTRACT, ROOT_FILES } from "./contract"; +import { SITE_REPORTS_BASE } from "../report/routes"; // The single header every served document gets. All served data is public // static JSON with no credentials, so `*` is correct and is what lets a @@ -87,8 +88,8 @@ const NO_STORE_HEADER = "Cache-Control: no-store"; // Kept in step with lib/report/views.ts (REPORT_FEED_FILENAMES, REPORT_FEED_MIME) // by headers.test.ts. export const SITE_TYPED_PATHS: readonly { path: string; type: string }[] = [ - { path: "/reports/:report/feed.xml", type: "application/rss+xml; charset=utf-8" }, - { path: "/reports/:report/feed.json", type: "application/feed+json; charset=utf-8" }, + { path: `${SITE_REPORTS_BASE}:report/feed.xml`, type: "application/rss+xml; charset=utf-8" }, + { path: `${SITE_REPORTS_BASE}:report/feed.json`, type: "application/feed+json; charset=utf-8" }, ]; // Whether a `_headers` path rule (a literal path, or one ending in a `*` splat) diff --git a/common/lib/archive/reader-reports.test.ts b/common/lib/archive/reader-reports.test.ts @@ -27,7 +27,7 @@ const CITED_CORPUS = { site: { id: "demo-reports", title: "Demo reports", url: ORIGIN, scope: "cited", audience: "public" }, totals: { channels: 0, videos: 0 }, channels: [], - reports: { index: `${ORIGIN}/reports/index.json`, count: 1 }, + reports: { index: `${ORIGIN}/pages/index.json`, count: 1 }, }; const FULL_CORPUS = { @@ -35,7 +35,7 @@ const FULL_CORPUS = { kind: "site", site: { id: "demo-full", title: "Demo full", url: ORIGIN }, channels: [{ slug: "demo-channel", name: "Demo Channel", videoCount: 1 }], - reports: { index: `${ORIGIN}/reports/index.json`, count: 1 }, + reports: { index: `${ORIGIN}/pages/index.json`, count: 1 }, }; const INDEX: ReportIndexView = { @@ -46,7 +46,7 @@ const INDEX: ReportIndexView = { id: "demo-report", kind: "factcheck", title: "A demo report", - href: "/reports/demo-report/", + href: "/pages/demo-report/", citationCount: 1, claimCount: 1, tally: [{ verdict: "CORROBORATED", count: 1 }], @@ -101,8 +101,8 @@ test("remote: a cited site is an empty corpus with its reports, read without an const restore = installFetch( { [`${ORIGIN}/corpus.json`]: CITED_CORPUS, - [`${ORIGIN}/reports/index.json`]: INDEX, - [`${ORIGIN}/reports/demo-report/page.json`]: PAGE, + [`${ORIGIN}/pages/index.json`]: INDEX, + [`${ORIGIN}/pages/demo-report/page.json`]: PAGE, }, fetches, ); @@ -117,18 +117,18 @@ test("remote: a cited site is an empty corpus with its reports, read without an assert.deepEqual((await r.loadGroups()).groups, []); assert.equal((await r.videoIndex()).size, 0); await r.reports(); - assert.equal(fetches.filter((u) => u.endsWith("/reports/index.json")).length, 1, "the index is cached"); + assert.equal(fetches.filter((u) => u.endsWith("/pages/index.json")).length, 1, "the index is cached"); } finally { restore(); } }); -test("remote: a report id is one path segment — it cannot leave /reports/", async () => { +test("remote: a report id is one path segment — it cannot leave /pages/", async () => { const fetches: string[] = []; const restore = installFetch({ [`${ORIGIN}/corpus.json`]: CITED_CORPUS }, fetches); try { assert.equal(await new RemoteSource(ORIGIN).reportPage("../corpus"), null); - assert.deepEqual(fetches, [`${ORIGIN}/reports/..%2Fcorpus/page.json`]); + assert.deepEqual(fetches, [`${ORIGIN}/pages/..%2Fcorpus/page.json`]); } finally { restore(); } @@ -137,7 +137,7 @@ test("remote: a report id is one path segment — it cannot leave /reports/", as test("remote: a full site with reports reads its channels as before; one without has no reports", async () => { const restore = installFetch({ [`${ORIGIN}/corpus.json`]: FULL_CORPUS, - [`${ORIGIN}/reports/index.json`]: INDEX, + [`${ORIGIN}/pages/index.json`]: INDEX, }); try { const r = new RemoteSource(ORIGIN); @@ -194,8 +194,8 @@ async function writeDir(files: Record<string, unknown>): Promise<string> { test("local: a cited dir never falls back to a stale transcripts/ listing", async () => { const dir = await writeDir({ "corpus.json": CITED_CORPUS, - "reports/index.json": INDEX, - "reports/demo-report/page.json": PAGE, + "pages/index.json": INDEX, + "pages/demo-report/page.json": PAGE, // A stale channel tree a cited build must not be read as. "transcripts/demo-channel/manifest.json": { version: 1, pageCount: 0, slugToPage: {} }, }); @@ -226,7 +226,7 @@ test("local: a full dir with no reports reads as before", async () => { }); test("local: a page.json that is not a report page is an error, not an absence", async () => { - const dir = await writeDir({ "corpus.json": CITED_CORPUS, "reports/demo-report/page.json": { hello: 1 } }); + const dir = await writeDir({ "corpus.json": CITED_CORPUS, "pages/demo-report/page.json": { hello: 1 } }); try { await assert.rejects(() => new LocalSource(dir).reportPage("demo-report"), /not a report page view/); } finally { diff --git a/common/lib/archive/reader.ts b/common/lib/archive/reader.ts @@ -413,11 +413,11 @@ export interface ArchiveReader { // archive. Learned from corpus.json with the channel list. OPTIONAL: a stub // has no corpus.json, and a hub's members each have their own. scope?(): Promise<CorpusScope>; - // The site's report index (/reports/index.json, spec 5): one entry per + // The site's report index (/pages/index.json, spec 5): one entry per // published report. [] when it publishes none — absent, malformed, or a site // built before spec 5. Cached per source. reports?(): Promise<ReportIndexEntry[]>; - // One report's page view (/reports/<id>/page.json), every citation + // One report's page view (/pages/<id>/page.json), every citation // resolved; null when the site publishes no report of that id. reportPage?(id: string): Promise<ReportPageView | null>; } @@ -459,7 +459,7 @@ export function coerceReportPage(raw: unknown, id: string): ReportPageView { // A report id as ONE path segment of a URL. An id is a lowercase slug // (lib/report/schema.ts REPORT_ID_RE); anything else is encoded so it cannot -// leave /reports/ — it simply names no report. +// leave /pages/ — it simply names no report. function reportPagePathFor(id: string): string { return reportViewPath(encodeURIComponent(id)); } diff --git a/common/lib/builtExport.test.ts b/common/lib/builtExport.test.ts @@ -166,11 +166,11 @@ test("builtHubProblem accepts only a hub bundle", () => { }); // Found on main 2026-10-05: the export app renders its report and moment -// routes into EVERY build — `reports/index.html`, the `_none` placeholders — -// so a hub bundle always has `reports/` and `m/`, and listing them as site +// routes into EVERY build — `pages/index.html`, the `_none` placeholders — +// so a hub bundle always has `pages/` and `m/`, and listing them as site // data refused every hub. What is refused now is the report DATA a site's // compose writes there. -test("builtHubProblem: the shell's reports/ and m/ pages pass; report data, moment data and a real post do not", () => { +test("builtHubProblem: the shell's pages/ and m/ pages pass; report data, moment data and a real post do not", () => { const hub = tempOut(); try { writeFileSync(path.join(hub.dir, "hub-sites.json"), "[]"); @@ -180,10 +180,10 @@ test("builtHubProblem: the shell's reports/ and m/ pages pass; report data, mome }; // What `next build` renders for the export app's own routes. for (const rel of [ - "reports/index.html", - "reports/index.txt", - "reports/_none/index.html", - "reports/_none/history/index.html", + "pages/index.html", + "pages/index.txt", + "pages/_none/index.html", + "pages/_none/history/index.html", "m/_none/index.html", "m/_none/index.txt", ]) { @@ -199,22 +199,22 @@ test("builtHubProblem: the shell's reports/ and m/ pages pass; report data, mome return problem; }; for (const rel of [ - "reports/index.json", - "reports/r1/page.json", - "reports/r1/citations.json", - "reports/r1/citations.csv", - "reports/r1/evidence-pack.zip", - "reports/r1/history/history.json", - "reports/r1/history/repo/HEAD", + "pages/index.json", + "pages/r1/page.json", + "pages/r1/citations.json", + "pages/r1/citations.csv", + "pages/r1/evidence-pack.zip", + "pages/r1/history/history.json", + "pages/r1/history/repo/HEAD", "m/index.json", "m/jer/v1/0-10/moment.json", ]) { const problem = refusedFor(rel); assert.match(problem ?? "", /still carries a site's data/, rel); - assert.ok(problem!.includes(rel.endsWith("/HEAD") ? "reports/r1/history/repo/" : rel), `${rel}: ${problem}`); + assert.ok(problem!.includes(rel.endsWith("/HEAD") ? "pages/r1/history/repo/" : rel), `${rel}: ${problem}`); } // (The history clone is a directory: removing its HEAD leaves repo/.) - rmSync(path.join(hub.dir, "reports", "r1"), { recursive: true }); + rmSync(path.join(hub.dir, "pages", "r1"), { recursive: true }); assert.equal(builtHubProblem(hub.dir), null, "nothing left behind"); // A tombstone-only posts/ is the hub's own; one real post is a site's. @@ -376,12 +376,12 @@ function citedOut(extra: string[] = []): { dir: string; cleanup: () => void } { "downloads/index.html", "duplicates/index.html", "offline/index.html", - "reports/index.json", - "reports/index.html", - "reports/_none/index.html", - "reports/demo-report/index.html", - "reports/demo-report/page.json", - "reports/demo-report/stills/a01.png", + "pages/index.json", + "pages/index.html", + "pages/_none/index.html", + "pages/demo-report/index.html", + "pages/demo-report/page.json", + "pages/demo-report/stills/a01.png", "m/index.json", "m/_none/index.html", "m/demo-channel/abc123/10.00-20.00/index.html", @@ -426,6 +426,8 @@ test("a cited build holding anything corpus-shaped is refused — by the audit a "sw.js", "media/thumbnails/a.jpg", "media/stray.mp4", + // where a site's reports were published before release 26 + "reports/demo-report/page.json", ]) { const t = citedOut([extra]); try { @@ -466,15 +468,15 @@ test("a cited build over the Pages file limit is refused", () => { // A report's published history clone (publish/reportHistory.ts). const HISTORY_REPO_FILES = [ - "reports/demo-report/history/index.html", - "reports/demo-report/history/history.json", - "reports/demo-report/history/repo/HEAD", - "reports/demo-report/history/repo/packed-refs", - "reports/demo-report/history/repo/info/refs", - "reports/demo-report/history/repo/objects/info/packs", - "reports/demo-report/history/repo/refs/heads/main", - `reports/demo-report/history/repo/objects/pack/pack-${"a".repeat(40)}.pack`, - `reports/demo-report/history/repo/objects/pack/pack-${"a".repeat(40)}.idx`, + "pages/demo-report/history/index.html", + "pages/demo-report/history/history.json", + "pages/demo-report/history/repo/HEAD", + "pages/demo-report/history/repo/packed-refs", + "pages/demo-report/history/repo/info/refs", + "pages/demo-report/history/repo/objects/info/packs", + "pages/demo-report/history/repo/refs/heads/main", + `pages/demo-report/history/repo/objects/pack/pack-${"a".repeat(40)}.pack`, + `pages/demo-report/history/repo/objects/pack/pack-${"a".repeat(40)}.idx`, ]; test("a report's history clone passes the audit; anything else in it is refused, full build or cited", () => { @@ -484,10 +486,10 @@ test("a report's history clone passes the audit; anything else in it is refused, assert.equal(builtBundleProblem(t.dir, "reports-site"), null); assert.equal(builtSiteProblem(t.dir, "reports-site"), null); for (const leak of ["config", "hooks/pre-commit", "logs/HEAD", "description", "FETCH_HEAD"]) { - const f = path.join(t.dir, "reports", "demo-report", "history", "repo", leak); + const f = path.join(t.dir, "pages", "demo-report", "history", "repo", leak); mkdirSync(path.dirname(f), { recursive: true }); writeFileSync(f, "x"); - assert.match(reportHistoryProblem(t.dir)!, new RegExp(`history clone that are not published: reports/demo-report/history/repo/${leak}`)); + assert.match(reportHistoryProblem(t.dir)!, new RegExp(`history clone that are not published: pages/demo-report/history/repo/${leak}`)); assert.match(builtBundleProblem(t.dir, "reports-site")!, /history clone/); rmSync(f); } @@ -496,7 +498,7 @@ test("a report's history clone passes the audit; anything else in it is refused, } const full = bundle({ site: { siteId: "anilyzer" }, corpus: { spec: 5, site: { id: "anilyzer" } } }); try { - const f = path.join(full.dir, "reports", "r1", "history", "repo", "config"); + const f = path.join(full.dir, "pages", "r1", "history", "repo", "config"); mkdirSync(path.dirname(f), { recursive: true }); writeFileSync(f, "x"); assert.match(builtSiteProblem(full.dir, "anilyzer")!, /history clone/); diff --git a/common/lib/builtExport.ts b/common/lib/builtExport.ts @@ -18,6 +18,7 @@ import path from "node:path"; import { isCitedOnlyChannel, isCitedSite } from "./siteSchema"; import { REPORT_HISTORY_REPO_FILE_RE } from "./report/revisions"; import { homepageAudienceProblem, type HomepageAuditOptions } from "./builtHomepage"; +import { SITE_REPORTS_BASE, reportBaseDir } from "./report/routes"; import { MOMENTS_INDEX_PATH, REPORTS_INDEX_PATH, @@ -28,6 +29,9 @@ import { reportViewPath, } from "./report/views"; +// Where a site's reports (its pages) are in an out dir: `pages`. +const SITE_REPORTS_DIR = reportBaseDir(SITE_REPORTS_BASE); + /** * The site id of the build sitting in `outDir`, or null when there is no * readable build there (no directory, no site.json, unparseable, or a site.json @@ -201,9 +205,9 @@ export const CITED_OUT_ALLOWED_DIRS: readonly string[] = [ "downloads", "duplicates", "offline", - // What compose's reports stage writes: the reports and their stills, the + // What compose's reports stage writes: the pages and their stills, the // moment pages, the cited media (with each route's placeholder, `_none`). - "reports", + SITE_REPORTS_DIR, "m", "media", "icons", @@ -338,17 +342,17 @@ export function citedBuildProblem(outDir: string): string | null { } // A file inside a report's published history clone, by its out/-relative path. -const REPORT_HISTORY_REPO_DIR_RE = /^reports\/[^/]+\/history\/repo\//; +const REPORT_HISTORY_REPO_DIR_RE = new RegExp(`^${SITE_REPORTS_DIR}/[^/]+/history/repo/`); /** - * Why the reports' history clones in `outDir` (`reports/<id>/history/repo/`, + * Why the reports' history clones in `outDir` (`pages/<id>/history/repo/`, * publish/reportHistory.ts) may not ship, as one sentence — or null. Any * build, full or cited: a clone may hold only the dumb-HTTP files its stager * copies (REPORT_HISTORY_REPO_FILE_RE — never a config, hook or log of the * store), each within the publish limit (PUBLISH_MAX_FILE_BYTES). */ export function reportHistoryProblem(outDir: string): string | null { - const reportsDir = path.join(outDir, "reports"); + const reportsDir = path.join(outDir, SITE_REPORTS_DIR); let reports: Dirent[]; try { reports = readdirSync(reportsDir, { withFileTypes: true }); @@ -367,8 +371,8 @@ export function reportHistoryProblem(outDir: string): string | null { const rr = rel ? `${rel}/${e.name}` : e.name; if (e.isDirectory()) walk(p, rr); else { - if (!REPORT_HISTORY_REPO_FILE_RE.test(rr)) extra.push(`reports/${r.name}/history/repo/${rr}`); - const problem = publishFileSizeProblem(`reports/${r.name}/history/repo/${rr}`, statSync(p).size); + if (!REPORT_HISTORY_REPO_FILE_RE.test(rr)) extra.push(`${SITE_REPORTS_DIR}/${r.name}/history/repo/${rr}`); + const problem = publishFileSizeProblem(`${SITE_REPORTS_DIR}/${r.name}/history/repo/${rr}`, statSync(p).size); if (problem) oversize.push(problem); } } @@ -519,8 +523,8 @@ export function builtHubProblem(outDir: string): string | null { existsSync(path.join(outDir, tree)) && !(tree === "posts" && isTombstonePostsTree(path.join(outDir, tree))), ); - // reports/ and m/ are the export app's own routes, rendered into EVERY - // build (the hub's included: /reports/, /reports/_none/, /m/_none/) — their + // pages/ and m/ are the export app's own routes, rendered into EVERY + // build (the hub's included: /pages/_none/, /m/_none/) — their // shell pages are not data. What a site's reports stage writes is. const reportData = hubReportDataIn(outDir); if (reportData.length > 0) carried.push(...reportData); @@ -604,9 +608,9 @@ export function isTombstoneChannelDir(dir: string): boolean { // The per-site data trees a hub bundle must never carry (the trees of // compose-hub's SITE_ONLY_PUBLIC_ENTRIES). A `posts/` of tombstones only is -// the hub's own (isTombstonePostsTree). `reports/` and `m/` are NOT here: the +// the hub's own (isTombstonePostsTree). `pages/` and `m/` are NOT here: the // export app renders its report and moment routes into every build, the hub's -// too (`reports/index.html`, the `_none` placeholders), so their presence says +// too (the `_none` placeholders), so their presence says // nothing — hubReportDataIn looks for the report DATA inside them instead. // (Listing them refused every hub bundle from 2026-10-05.) const HUB_FORBIDDEN_TREES = [ @@ -621,7 +625,7 @@ const HUB_FORBIDDEN_TREES = [ ]; // The files only a site's reports stage writes (lib/report/views.ts names -// them; publish/composeReports.ts writes them), by name within reports/<id>/ +// them; publish/composeReports.ts writes them), by name within pages/<id>/ // and m/…: the report index, each report's page view, its citations, its // exports, its timeline's feeds and its revision history; the moment index // and each moment view. @@ -637,7 +641,7 @@ const REPORT_DATA_FILES = new Set<string>([ const MOMENT_DATA_FILE = path.posix.basename(momentViewPath("x")); /** - * The report and moment DATA in a bundle's `reports/` and `m/` (root-relative + * The report and moment DATA in a bundle's `pages/` and `m/` (root-relative * paths, at most a few): what a site's compose writes there, never what the * export app's own route pages are. Empty for a hub bundle, which carries the * shell pages only. @@ -659,7 +663,7 @@ export function hubReportDataIn(outDir: string, limit = 5): string[] { const child = `${rel}/${e.name}`; if (e.isDirectory()) { // A report's revision history clone (history/repo/) is data whatever it holds. - if (rel.startsWith("reports/") && e.name === "repo" && rel.endsWith("/history")) { + if (rel.startsWith(`${SITE_REPORTS_DIR}/`) && e.name === "repo" && rel.endsWith("/history")) { found.push(`${child}/`); continue; } @@ -669,7 +673,7 @@ export function hubReportDataIn(outDir: string, limit = 5): string[] { } } }; - walk("reports", (name, depth) => depth >= 1 && REPORT_DATA_FILES.has(name), 0); + walk(SITE_REPORTS_DIR, (name, depth) => depth >= 1 && REPORT_DATA_FILES.has(name), 0); walk("m", (name) => name === MOMENT_DATA_FILE, 0); return found.slice(0, limit); } diff --git a/common/lib/builtHomepage.ts b/common/lib/builtHomepage.ts @@ -27,7 +27,7 @@ import { existsSync, readdirSync, readFileSync } from "node:fs"; import path from "node:path"; import type { Paths } from "./paths"; import { isXPostsChannel, xPostsVisibility } from "./postsVisibility"; -import { ARTICLES_BASE, reportBaseDir } from "./report/routes"; +import { ARTICLES_REPORTS_BASE, reportBaseDir } from "./report/routes"; export const HOMEPAGE_BUILD_STAMP = "homepage-build.json"; @@ -81,7 +81,7 @@ export function homepageAudienceProblem(outDir: string, opts: HomepageAuditOptio const paths = opts.paths; if (!paths) return null; - const articlesDir = path.join(outDir, reportBaseDir(ARTICLES_BASE)); + const articlesDir = path.join(outDir, reportBaseDir(ARTICLES_REPORTS_BASE)); const built = dirs(articlesDir).filter((id) => existsSync(path.join(articlesDir, id, "page.json"))); const isPublic = new Map<string, boolean>(); const publicNow = (id: string) => { @@ -106,7 +106,7 @@ export function homepageAudienceProblem(outDir: string, opts: HomepageAuditOptio } return configs.get(slug)!; }; - const articlePrefix = ARTICLES_BASE; + const articlePrefix = ARTICLES_REPORTS_BASE; for (const m of momentFiles(outDir)) { const view = readJson(m.file) as { citedIn?: { href?: unknown }[] } | null; for (const c of view?.citedIn ?? []) { diff --git a/common/lib/corpus.ts b/common/lib/corpus.ts @@ -2,6 +2,7 @@ import type { PublicSiteDescriptor } from "./siteDescriptor"; import { AI_DOC_URL, PROJECT_GENERATOR } from "./project"; import { TAGS_FILENAME } from "./curatedTags"; import { REPORTS_INDEX_PATH, reportFullTitle } from "./report/views"; +import { SITE_REPORTS_BASE } from "./report/routes"; import { CONTRACT, archiveUrl, @@ -36,8 +37,8 @@ import { // version — an older reader ignores an unknown field, as it always has. // // v5: reports — a site may publish cited reports, announced as `reports` -// ({ index: "/reports/index.json" }, the report index the export's Reports -// pages read); and a CITED site (site.json `search: false`) publishes ONLY +// ({ index: "/pages/index.json" — "/reports/index.json" before release 26 +// A5 — the index of the site's pages); and a CITED site (site.json `search: false`) publishes ONLY // them, saying so as `site.scope: "cited"` with no channels and zero totals. // An older reader sees an empty corpus there, which is the safe reading: there // is no shard to fetch. @@ -215,7 +216,7 @@ export type SiteCorpus = { bulkArchives?: { manifest: string; note: string }; // Present when this site publishes at least one report (spec 5): the report // index, each entry linking its page; every report's page view and - // citations sit beside it under /reports/<id>/. + // citations sit beside it under /pages/<id>/. reports?: { index: string; count: number; description: string }; // Pointer to the human page on using the archive with AI: the homepage's AI // and MCP doc (AI_DOC_URL; the site's own /use-with-ai page until release @@ -341,8 +342,9 @@ export function buildSiteCorpus( count: opts.reportCount, description: "Cited reports. The index lists each report (title, kind, counts, " + - "`href` of its page); /reports/<id>/page.json is one report with every " + - "citation resolved, and /reports/<id>/citations.json (an " + + "`href` of its page); " + + `${SITE_REPORTS_BASE}<id>/page.json is one report with every ` + + `citation resolved, and ${SITE_REPORTS_BASE}<id>/citations.json (an ` + "archilyzer-citations set) and citations.csv are its citations as " + "data. A video or audio citation's moment page is /m/<channel>/<id>/" + "<start>-<end>/ (moment.json beside it), a post's /m/<channel>/<id>/.", @@ -512,15 +514,15 @@ function renderCitedLlmsTxt(corpus: SiteCorpus, reports: readonly LlmsReport[]): if (corpus.reports) { out.push( `- [Report index](${corpus.reports.index}): every report, as JSON; ` + - `/reports/<id>/page.json is one report with its citations resolved.`, + `${SITE_REPORTS_BASE}<id>/page.json is one report with its citations resolved.`, ); } pushReports(out, base, reports); out.push(""); out.push("## Citations"); out.push( - `- Each report's citations as data: /reports/<id>/citations.json (an ` + - `archilyzer-citations set) and /reports/<id>/citations.csv.`, + `- Each report's citations as data: ${SITE_REPORTS_BASE}<id>/citations.json (an ` + + `archilyzer-citations set) and ${SITE_REPORTS_BASE}<id>/citations.csv.`, ); out.push( `- A cited video or audio span has a moment page, /m/<channel>/<id>/<start>-<end>/ ` + diff --git a/common/lib/report/docs.ts b/common/lib/report/docs.ts @@ -53,9 +53,9 @@ export function renderReportMarkdown(): string { ); out.push( "- **A site's page** — `transcripts/sites/<siteId>/reports/<reportId>/report.json`, " + - "published by its site: the site's `reports` list in `site.json` is the published, " + - "ordered list — see [SITE.md](SITE.md). A page cites the site's `channels` and " + - "`citedChannels`.", + "published by its site at `/pages/<reportId>/`: the site's `pages` list in `site.json` " + + "is the published, ordered list — see [SITE.md](SITE.md). A page cites the site's " + + "`channels` and `citedChannels`.", ); out.push(""); out.push( @@ -108,7 +108,7 @@ export function renderReportMarkdown(): string { "the rest, in the page's order. A report with a newer entry than its own `updated` is " + "shown as updated then (the index, the header, the feeds). On a site with a public " + "`siteUrl`, compose publishes the timeline as feeds beside the page — " + - "`/reports/<id>/feed.xml` (RSS 2.0) and `/reports/<id>/feed.json` (JSON Feed 1.1), one " + + "`/pages/<id>/feed.xml` (RSS 2.0) and `/pages/<id>/feed.json` (JSON Feed 1.1), one " + "item per entry, its permalink the page at its anchor — and the page links them " + "(\"Subscribe\", and `<link rel=\"alternate\">`). A site with no `siteUrl` publishes no feed.", ); diff --git a/common/lib/report/export.test.ts b/common/lib/report/export.test.ts @@ -117,14 +117,14 @@ test("the heading: the series and the title (or the title alone), the dates and }); test("the heading's revision: this export's, linked to the history on the site", () => { - const history = { revision: 2, date: "2026-10-04", href: "/reports/demo/history/", current: true }; + const history = { revision: 2, date: "2026-10-04", href: "/pages/demo/history/", current: true }; const withRev = { ...opts, footer: { ...opts.footer, revision: 2 } }; assert.match( reportExportHtml({ ...view, history }, withRev), - /<p class="dates" data-report-dates="">2026-10-01 · updated 2026-10-04 · <a href="https:\/\/reports\.example\.org\/reports\/demo\/history\/">revision 2<\/a><\/p>/, + /<p class="dates" data-report-dates="">2026-10-01 · updated 2026-10-04 · <a href="https:\/\/reports\.example\.org\/pages\/demo\/history\/">revision 2<\/a><\/p>/, ); assert.match(reportExportHtml({ ...view, history }, { ...withRev, siteUrl: undefined }), /updated 2026-10-04 · revision 2<\/p>/); - assert.match(reportExportMarkdown({ ...view, history }, withRev), /^2026-10-01 · updated 2026-10-04 · \[revision 2\]\(https:\/\/reports\.example\.org\/reports\/demo\/history\/\)$/m); + assert.match(reportExportMarkdown({ ...view, history }, withRev), /^2026-10-01 · updated 2026-10-04 · \[revision 2\]\(https:\/\/reports\.example\.org\/pages\/demo\/history\/\)$/m); }); test("the three tiers: the quick take, what the check found, every claim from how it was checked", () => { @@ -186,7 +186,7 @@ test("verdicts, inline markers [n] to the reference list, and references with ev assert.doesNotMatch(html, /<video/, "a clip is linked, not played, in the one-file export"); assert.match(html, /Archived: <a href="https:\/\/archive\.example\.org\/p">/); assert.match(html, /quote match 97%/); - assert.match(html, /<footer class="export-footer" data-export-footer=""><p>2026-10-04 · report sha256 0123456789ab<\/p><p>Published at <a href="https:\/\/reports\.example\.org\/reports\/demo\/">/); + assert.match(html, /<footer class="export-footer" data-export-footer=""><p>2026-10-04 · report sha256 0123456789ab<\/p><p>Published at <a href="https:\/\/reports\.example\.org\/pages\/demo\/">/); }); test("without a site URL nothing links to the site; the pack's clip plays in place", () => { @@ -213,8 +213,8 @@ test("markdownToHtml: paragraphs, lists, quotes, code, headings under the page's "<h3>Head</h3>\n<p>A <em>word</em> and <strong>strong</strong>.</p>\n<ol><li>one</li><li>two</li></ol>\n" + "<blockquote><p>quoted</p></blockquote>\n<pre><code><b></code></pre>", ); - assert.equal(markdownToHtml("[site](/reports/x/)", () => undefined, { siteUrl: "https://s.example" }), '<p><a href="https://s.example/reports/x/">site</a></p>'); - assert.equal(markdownToHtml("[site](/reports/x/)", () => undefined), "<p>site</p>"); + assert.equal(markdownToHtml("[site](/pages/x/)", () => undefined, { siteUrl: "https://s.example" }), '<p><a href="https://s.example/pages/x/">site</a></p>'); + assert.equal(markdownToHtml("[site](/pages/x/)", () => undefined), "<p>site</p>"); }); test("the Markdown export: the heading lines, `label [n]` citations, numbered references, the footer", () => { @@ -246,7 +246,7 @@ test("the Markdown export: the heading lines, `label [n]` citations, numbered re const refs = [...md.matchAll(/^(\d+)\. “(.*)”/gm)].map((m) => `${m[1]}:${m[2]}`); assert.deepEqual(refs, ["1:one \\* two", "2:four", "3:five", "4:two", "5:three"]); assert.match(md, /Moment page: <https:\/\/reports\.example\.org\/m\/demo-channel\/abc123\/3126\.00-3151\.00\/>/); - assert.match(md, /---\n\n2026-10-04 · report sha256 0123456789ab\n\nPublished at <https:\/\/reports\.example\.org\/reports\/demo\/>\n$/); + assert.match(md, /---\n\n2026-10-04 · report sha256 0123456789ab\n\nPublished at <https:\/\/reports\.example\.org\/pages\/demo\/>\n$/); }); test("mdText escapes what Markdown would read; citedMarkdownToPlain numbers citations", () => { diff --git a/common/lib/report/exportHtml.ts b/common/lib/report/exportHtml.ts @@ -52,6 +52,7 @@ import { type SourceView, type SpanCitationView, } from "./views"; +import type { ReportBase } from "./routes"; // ─── The footer: which document this is ─── @@ -94,6 +95,9 @@ export type ReportExportOptions = { // The site's public URL (site.json `siteUrl`). Absent: no link to the site, // its moment pages or its clips (a private site has nowhere to link). siteUrl?: string; + // Where the build serves its reports (./routes.ts): the report's own page + // under `siteUrl`. A site's by default. + base?: ReportBase; footer: ReportExportFooter; }; @@ -606,7 +610,7 @@ export function reportExportHtml(view: ReportPageView, opts: ReportExportHtmlOpt const tally = isFactcheck ? verdictTally(view) : []; const groups = isFactcheck ? foundGroups(view) : []; const claimCount = view.sections.reduce((n, s) => n + s.claims.length, 0); - const pageUrl = siteLink(opts.siteUrl, reportPagePath(view.id)); + const pageUrl = siteLink(opts.siteUrl, reportPagePath(view.id, opts.base)); const ctx: ClaimContext = { view, subjectNoun, cite, opts }; // The heading, in the site's order: the series on one line and the title diff --git a/common/lib/report/exportMarkdown.ts b/common/lib/report/exportMarkdown.ts @@ -172,7 +172,7 @@ export function reportExportMarkdown(view: ReportPageView, opts: ReportExportOpt const out: string[] = []; const subject = view.subject ? view.sources[view.subject] : undefined; const subjectNoun = subject?.kind === "article" ? "article" : "source"; - const pageUrl = siteLink(opts.siteUrl, reportPagePath(view.id)); + const pageUrl = siteLink(opts.siteUrl, reportPagePath(view.id, opts.base)); const isFactcheck = view.kind === "factcheck"; // The series on its own line and the title as the heading (or the title diff --git a/common/lib/report/exportSlidesHtml.ts b/common/lib/report/exportSlidesHtml.ts @@ -45,6 +45,7 @@ import { type CitationView, type ReportPageView, } from "./views"; +import type { ReportBase } from "./routes"; export type ReportSlidesHtmlOptions = { // common/styles/slides.css, whole. @@ -52,6 +53,8 @@ export type ReportSlidesHtmlOptions = { // The site's accent on the light base (lib/accent.ts resolveAccent().light). accent: string; siteUrl?: string; + // Where the build serves its reports (./routes.ts); a site's by default. + base?: ReportBase; footer: ReportExportFooter; // A site-root image path → the <img src>, or undefined to leave it out. image: (sitePath: string) => string | undefined; @@ -271,7 +274,7 @@ function claimBody(s: ClaimSlide, x: Ctx): string { } function sourcesBody(s: SourcesSlide, x: Ctx): string { - const pageUrl = siteLink(x.opts.siteUrl, reportPagePath(x.view.id)); + const pageUrl = siteLink(x.opts.siteUrl, reportPagePath(x.view.id, x.opts.base)); return ( `<h2 class="rs-h">${escapeHtml(s.title)}</h2><div class="rs-figures">` + `<div class="rs-figure"><b>${s.references}</b><span>${s.references === 1 ? "reference" : "references"}</span></div>` + @@ -347,7 +350,7 @@ function slideHtml(s: SlideView, x: Ctx): string { break; } const mark = s.kind === "claim" && s.verdict ? verdictStyleOf(x.view, s.verdict).color : undefined; - const article = siteLink(x.opts.siteUrl, `${reportPagePath(x.view.id)}#${s.anchorId}`); + const article = siteLink(x.opts.siteUrl, `${reportPagePath(x.view.id, x.opts.base)}#${s.anchorId}`); return ( `<article class="rs-slide" data-slide="${escapeHtml(s.key)}" data-slide-kind="${s.kind}" data-layout="${s.layout}" data-fit="canvas"${style({ "--rs-mark": mark })}>` + `<span class="rs-band" aria-hidden="true"></span>${eyebrow(s, x.total)}<div class="rs-main">${body}</div>` + diff --git a/common/lib/report/feeds.test.ts b/common/lib/report/feeds.test.ts @@ -40,7 +40,7 @@ function report(): Report { date: "2026-10-05T09:30:00Z", updated: "2026-10-06", title: "Second", - body: "See [the section](#s1), [the index](/reports/) and [one](cite:v1).", + body: "See [the section](#s1), [the index](/pages/) and [one](cite:v1).", }, ], sections: [{ id: "s1", title: "Section", body: "A body." }], @@ -57,8 +57,8 @@ const view = (r: Report = report()): ReportPageView => { test("feed URLs beside the report's page", () => { assert.deepEqual(reportFeedUrls(SITE, "living"), { - rss: "https://site.example/reports/living/feed.xml", - json: "https://site.example/reports/living/feed.json", + rss: "https://site.example/pages/living/feed.xml", + json: "https://site.example/pages/living/feed.json", }); }); @@ -80,24 +80,24 @@ test("RSS 2.0: the channel, then one item per entry newest first, absolute links const xml = renderReportRss(view(), { siteUrl: SITE }); assert.match(xml, /^<\?xml version="1\.0" encoding="UTF-8"\?>\n<rss version="2\.0" xmlns:atom="http:\/\/www\.w3\.org\/2005\/Atom">\n<channel>\n/); assert.match(xml, /<title>Watch: Bits & <pieces><\/title>/); - assert.match(xml, /<link>https:\/\/site\.example\/reports\/living\/<\/link>/); + assert.match(xml, /<link>https:\/\/site\.example\/pages\/living\/<\/link>/); // No subtitle: the summary as plain text. assert.match(xml, /<description>It starts here\.<\/description>/); - assert.match(xml, /<atom:link href="https:\/\/site\.example\/reports\/living\/feed\.xml" rel="self" type="application\/rss\+xml"\/>/); + assert.match(xml, /<atom:link href="https:\/\/site\.example\/pages\/living\/feed\.xml" rel="self" type="application\/rss\+xml"\/>/); // The newest entry's update is the report's. assert.match(xml, /<lastBuildDate>Tue, 06 Oct 2026 00:00:00 GMT<\/lastBuildDate>/); const items = [...xml.matchAll(/<item>([\s\S]*?)<\/item>/g)].map((m) => m[1]); assert.equal(items.length, 2); assert.match(items[0], /<title>Second<\/title>/); - assert.match(items[0], /<link>https:\/\/site\.example\/reports\/living\/#newer<\/link>/); - assert.match(items[0], /<guid isPermaLink="true">https:\/\/site\.example\/reports\/living\/#newer<\/guid>/); + assert.match(items[0], /<link>https:\/\/site\.example\/pages\/living\/#newer<\/link>/); + assert.match(items[0], /<guid isPermaLink="true">https:\/\/site\.example\/pages\/living\/#newer<\/guid>/); assert.match(items[0], /<pubDate>Mon, 05 Oct 2026 09:30:00 GMT<\/pubDate>/); assert.match(items[1], /<title>First & "quoted"<\/title>/); // The body is HTML, escaped as text: a fragment link to the page, a // site-root link to the site, a citation's marker to its reference on the page. - assert.match(items[0], /<a href="https:\/\/site\.example\/reports\/living\/#s1">the section<\/a>/); - assert.match(items[0], /<a href="https:\/\/site\.example\/reports\/">the index<\/a>/); - assert.match(items[0], /one<sup class="cite"><a href="https:\/\/site\.example\/reports\/living\/#c-v1">\[1\]/); + assert.match(items[0], /<a href="https:\/\/site\.example\/pages\/living\/#s1">the section<\/a>/); + assert.match(items[0], /<a href="https:\/\/site\.example\/pages\/">the index<\/a>/); + assert.match(items[0], /one<sup class="cite"><a href="https:\/\/site\.example\/pages\/living\/#c-v1">\[1\]/); // Raw HTML in an entry is text, escaped twice over in the feed. assert.match(items[1], /&lt;b&gt;here&lt;\/b&gt;/); assert.doesNotMatch(xml, /<b>/); @@ -108,19 +108,19 @@ test("JSON Feed 1.1: the same items newest first, ids their permalinks, dates RF const feed = renderReportJsonFeed(view(), { siteUrl: SITE }); assert.equal(feed.version, JSON_FEED_VERSION); assert.equal(feed.title, "Watch: Bits & <pieces>"); - assert.equal(feed.home_page_url, "https://site.example/reports/living/"); - assert.equal(feed.feed_url, "https://site.example/reports/living/feed.json"); + assert.equal(feed.home_page_url, "https://site.example/pages/living/"); + assert.equal(feed.feed_url, "https://site.example/pages/living/feed.json"); assert.equal(feed.description, "It starts here."); assert.deepEqual( feed.items.map((i) => [i.id, i.url, i.title, i.date_published, i.date_modified]), [ - ["https://site.example/reports/living/#newer", "https://site.example/reports/living/#newer", "Second", "2026-10-05T09:30:00.000Z", "2026-10-06T00:00:00.000Z"], - ["https://site.example/reports/living/#older", "https://site.example/reports/living/#older", "First & \"quoted\"", "2026-10-02T00:00:00.000Z", undefined], + ["https://site.example/pages/living/#newer", "https://site.example/pages/living/#newer", "Second", "2026-10-05T09:30:00.000Z", "2026-10-06T00:00:00.000Z"], + ["https://site.example/pages/living/#older", "https://site.example/pages/living/#older", "First & \"quoted\"", "2026-10-02T00:00:00.000Z", undefined], ], ); assert.equal( feed.items[1].content_html, - '<p>It began<sup class="cite"><a href="https://site.example/reports/living/#c-w1">[2]</a></sup> <b>here</b>.</p>', + '<p>It began<sup class="cite"><a href="https://site.example/pages/living/#c-w1">[2]</a></sup> <b>here</b>.</p>', ); assert.equal("date_modified" in feed.items[1], false); // A round trip through JSON is the same feed. diff --git a/common/lib/report/reader-server.test.ts b/common/lib/report/reader-server.test.ts @@ -36,11 +36,12 @@ function publicDirWith(files: Record<string, unknown>): string { const page = (id: string) => ({ format: REPORT_PAGE_FORMAT, id, kind: "sweep", title: `Title ${id}`, sections: [] }); -test("the site's base is /reports/, and every path helper defaults to it", () => { - assert.equal(SITE_REPORTS_BASE, "/reports/"); - assert.equal(REPORTS_INDEX_PATH, "/reports/index.json"); - assert.equal(reportPagePath("a"), "/reports/a/"); - assert.equal(reportHistoryPagePath("a"), "/reports/a/history/"); +test("the site's base is /pages/, and every path helper defaults to it", () => { + assert.equal(SITE_REPORTS_BASE, "/pages/"); + assert.equal(REPORTS_INDEX_PATH, "/pages/index.json"); + assert.equal(reportPagePath("a"), "/pages/a/"); + assert.equal(reportHistoryPagePath("a"), "/pages/a/history/"); + assert.equal(reportBaseDir(SITE_REPORTS_BASE), "pages"); }); test("a base names every report path", () => { @@ -53,7 +54,7 @@ test("a base names every report path", () => { }); test("a base is lowercase segments with a slash on both ends", () => { - for (const ok of ["/reports/", "/pages/", "/a/b/"]) assert.ok(isReportBase(ok), ok); + for (const ok of ["/reports/", "/pages/", "/articles/", "/a/b/"]) assert.ok(isReportBase(ok), ok); for (const bad of ["reports/", "/reports", "/", "/Reports/", "//", "/../", 3]) assert.ok(!isReportBase(bad), String(bad)); assert.equal(reportBaseDir("/reports/"), "reports"); assert.equal(reportBaseDir("/a/b/"), "a/b"); diff --git a/common/lib/report/reader-server.ts b/common/lib/report/reader-server.ts @@ -55,6 +55,8 @@ export type ReportReader = { readReportHistory(reportId: string): ReportHistoryView | null; // The build's one report, when it publishes exactly one. onlyReportView(): ReportPageView | null; + // The build's first report in index order (a search-off site's home page). + firstReportView(): ReportPageView | null; // The moment keys to build pages for (only keys exactly as momentKey spells // them: each segment is a path segment of a page written to disk). momentKeys(): string[]; @@ -101,6 +103,10 @@ export function createReportReader(opts: ReportReaderOptions): ReportReader { const ids = reader.reportIds(); return ids.length === 1 ? reader.readReportView(ids[0]) : null; }, + firstReportView() { + const ids = reader.reportIds(); + return ids.length > 0 ? reader.readReportView(ids[0]) : null; + }, momentKeys() { const v = readView<MomentIndexView>(MOMENTS_INDEX_PATH, MOMENT_INDEX_FORMAT); return (Array.isArray(v?.moments) ? v.moments : []).filter((k) => parseMomentKey(k) !== null); diff --git a/common/lib/report/revisions.ts b/common/lib/report/revisions.ts @@ -4,7 +4,7 @@ // `archilyzer reports export` commits a revision to the report's own git // history whenever its report.json changed (publish/reportHistory.ts); the // commit message is `Revision N` and the lines of `reportChangeSummary`. The -// site's history page (`/reports/<id>/history/`) lists every revision with +// site's history page (`/pages/<id>/history/`) lists every revision with // that summary and a claim-level word diff against the one before // (`claimChanges`), both computed at compose into `history.json` // (ReportHistoryView), so the page only renders. @@ -30,7 +30,7 @@ export function reportHistoryViewPath(reportId: string, base: ReportBase = SITE_ return `${base}${reportId}/history/history.json`; } -// The dumb-HTTP clone of the report's history: `git clone <site>/reports/<id>/history/repo`. +// The dumb-HTTP clone of the report's history: `git clone <site>/pages/<id>/history/repo`. export function reportHistoryRepoPath(reportId: string, base: ReportBase = SITE_REPORTS_BASE): string { return `${base}${reportId}/history/repo`; } diff --git a/common/lib/report/routes.ts b/common/lib/report/routes.ts @@ -12,15 +12,19 @@ // // Pure, no imports: the export site's pages and the browser can use it. -// A base is a site-root path with a leading and a trailing slash: `/reports/`. +// A base is a site-root path with a leading and a trailing slash: `/pages/`. export type ReportBase = `/${string}/`; -// A site's reports. -export const SITE_REPORTS_BASE: ReportBase = "/reports/"; +// A site's reports: its pages (site.json `pages`), at `/pages/<id>/` (release +// 26 A5; `/reports/` before it). +export const SITE_REPORTS_BASE: ReportBase = "/pages/"; -// The homepage's articles (release 26 A3: the article store, published by the -// project homepage at /articles/<id>/). -export const ARTICLES_BASE: ReportBase = "/articles/"; +// The homepage's articles (plans/reports-on-homepage.md, A3): `/articles/<id>/`. +export const ARTICLES_REPORTS_BASE: ReportBase = "/articles/"; + +// Where a site's reports were published before release 26: compose still +// clears it from a public dir an older compose wrote. +export const LEGACY_SITE_REPORTS_DIR = "reports"; const BASE_RE = /^\/(?:[a-z0-9][a-z0-9-]*\/)+$/; @@ -29,8 +33,8 @@ export function isReportBase(v: unknown): v is ReportBase { return typeof v === "string" && BASE_RE.test(v); } -// The base's top directory under a public dir or an out dir, `reports` for -// `/reports/`. +// The base's top directory under a public dir or an out dir, `pages` for +// `/pages/`. export function reportBaseDir(base: ReportBase): string { return base.split("/").filter(Boolean).join("/"); } diff --git a/common/lib/report/schema.ts b/common/lib/report/schema.ts @@ -140,7 +140,7 @@ export type SlideSpec = z.infer<typeof slideSchema>; export type ReportSlidesSpec = z.infer<typeof reportSlidesSchema>; // A report id is its directory name under `reports/` and a path segment of its -// page (`/reports/<id>/`): a lowercase slug, like a site id. +// page (a site's `/pages/<id>/`): a lowercase slug, like a site id. export const REPORT_ID_RE = /^[a-z0-9][a-z0-9-]{0,63}$/; export function isReportId(v: unknown): v is string { @@ -150,7 +150,7 @@ export function isReportId(v: unknown): v is string { export const REPORT_FIELD_DOCS: FieldDocs<Report> = { format: `\`"${REPORT_FORMAT}"\`.`, version: `\`${REPORT_VERSION}\`.`, - id: "The report's id: a lowercase slug (`[a-z0-9][a-z0-9-]*`, at most 64), its directory name under `reports/` and the last segment of its page, `/reports/<id>/`. Must match the directory.", + id: "The report's id: a lowercase slug (`[a-z0-9][a-z0-9-]*`, at most 64), its directory name under `reports/` and the last segment of its page (on a site, `/pages/<id>/`). Must match the directory.", kind: '`"factcheck"` — sections of claims, each with a verdict — or `"sweep"` — sections with no verdicts, or bodies with inline citations.', audience: "Who may read the report when it is an ARTICLE (in `transcripts/reports/`, published by the homepage): `\"public\"` — the public homepage build carries it — or `\"private\"` — only the private build (`archilyzer build homepage --private`, never deployed) does. Absent = `\"private\"`: going public is an explicit `pnpm ops articles-config`. Ignored on a site's page, which has its site's audience.", diff --git a/common/lib/report/timeline.test.ts b/common/lib/report/timeline.test.ts @@ -44,7 +44,7 @@ function report(): Report { const view = (r: Report = report()): ReportPageView => buildReportPageView(r, { record: (c) => ({ channel: c.channel, id: c.id, title: `Record ${c.id}` }), - feeds: { rss: "https://site.example/reports/living/feed.xml", json: "https://site.example/reports/living/feed.json" }, + feeds: { rss: "https://site.example/pages/living/feed.xml", json: "https://site.example/pages/living/feed.json" }, }); test("a report with a timeline is sound", () => { @@ -126,8 +126,8 @@ test("cited-in: a citation in an entry links to the entry's anchor", () => { const index = buildCitedIn([r]); const entries = index["demo-channel/abc123/10.00-20.00"]; assert.deepEqual(entries[1], { reportId: "living", sectionId: null, claimId: null, entryId: "e9", citationId: "v1" }); - assert.equal(citedInHref(entries[1]), "/reports/living/#e9"); - assert.equal(citedInHref(entries[0]), "/reports/living/"); + assert.equal(citedInHref(entries[1]), "/pages/living/#e9"); + assert.equal(citedInHref(entries[0]), "/pages/living/"); const views = citedInViews(entries, [view(r)]); assert.equal(views[1].entryTitle, "Clip"); }); @@ -147,7 +147,7 @@ test("the page view: entries newest first with their dates; updated counts the n }); assert.equal(v.updated, "2026-10-05T09:30:00Z"); assert.equal(reportIndexEntry(v).updated, "2026-10-05T09:30:00Z"); - assert.equal(v.feeds?.rss, "https://site.example/reports/living/feed.xml"); + assert.equal(v.feeds?.rss, "https://site.example/pages/living/feed.xml"); const none = view({ ...report(), entries: undefined }); assert.equal(none.entries, undefined); assert.equal(none.feeds, undefined); diff --git a/common/lib/report/views.test.ts b/common/lib/report/views.test.ts @@ -90,7 +90,7 @@ const view = buildReportPageView(report, { record: (c) => record(c.channel, c.id), poster: (c) => (c.kind === "video" ? "/poster.png" : undefined), post: () => ({ author: "@someone", text: "three, and more" }), - downloads: { json: "/reports/demo/citations.json" }, + downloads: { json: "/pages/demo/citations.json" }, }); test("the fixture report here is sound", () => { @@ -131,7 +131,7 @@ test("a source citation names its document by id; the document (never its saved const s1 = view.citations.s1; assert.equal(s1.kind, "source"); if (s1.kind !== "source") return; - assert.equal(s1.image, "/reports/demo/stills/s1.png"); + assert.equal(s1.image, "/pages/demo/stills/s1.png"); assert.equal(s1.href, "https://example.org/a"); assert.equal(s1.sourceId, "s0"); assert.equal(s1.sourceTitle, "An article"); @@ -209,7 +209,7 @@ test("the view keeps the claim structure, with the source sentence as an id", () citations: ["v1", "a1"], }); assert.deepEqual(view.sections[1].claims[0].citations, ["a1"]); - assert.deepEqual(view.downloads, { json: "/reports/demo/citations.json" }); + assert.deepEqual(view.downloads, { json: "/pages/demo/citations.json" }); }); test("a section's citations, in number order; code is not citing", () => { @@ -229,7 +229,7 @@ test("the tally counts verdicts in the vocabulary's order; the index entry carri { verdict: "CONTRADICTED", count: 1 }, ]); const entry = reportIndexEntry(view); - assert.equal(entry.href, "/reports/demo/"); + assert.equal(entry.href, "/pages/demo/"); assert.equal(entry.citationCount, 5); assert.equal(entry.claimCount, 2); assert.deepEqual(entry.tally, verdictTally(view)); @@ -242,12 +242,12 @@ test("cited-in entries resolve to the claim's anchor with titles and the citatio assert.deepEqual( entries.map((e) => [e.href, e.claimTitle, e.claimText, e.verdict, e.verdictStyle?.label, e.number]), [ - ["/reports/demo/#c1", "One", "Claim one.", "CONTRADICTED", "Contradicted", 4], - ["/reports/demo/#c2", undefined, "Claim two.", "PARTLY", "Half", 4], + ["/pages/demo/#c1", "One", "Claim one.", "CONTRADICTED", "Contradicted", 4], + ["/pages/demo/#c2", undefined, "Claim two.", "PARTLY", "Half", 4], ], ); const summary = citedInViews(index["demo-channel/abc123/3126.00-3151.00"], [view]); - assert.equal(summary[0].href, "/reports/demo/"); + assert.equal(summary[0].href, "/pages/demo/"); assert.equal(citedInViews(index["demo-social/123"], []).length, 0); }); @@ -257,7 +257,7 @@ test("paths: the clip, the moment view and a report asset", () => { "/media/clips/demo-channel/-abc/1.00-2.50.mp4", ); assert.equal(momentViewPath("demo-social/123"), "/m/demo-social/123/moment.json"); - assert.equal(reportAssetPath("demo", "./stills/x.png"), "/reports/demo/stills/x.png"); + assert.equal(reportAssetPath("demo", "./stills/x.png"), "/pages/demo/stills/x.png"); assert.equal(sourceAnchor("s0"), "source-s0"); }); @@ -412,6 +412,6 @@ test("a report's video rides its page view as site-root paths; a report without const withVideo = { ...report, video: { src: "video.mp4", poster: "media/poster.jpg", caption: "The cut" } }; assert.deepEqual(validateReport(withVideo), []); const v = buildReportPageView(withVideo, { record: (c) => record(c.channel, c.id) }); - assert.deepEqual(v.video, { src: `/reports/${report.id}/video.mp4`, poster: `/reports/${report.id}/media/poster.jpg`, caption: "The cut" }); + assert.deepEqual(v.video, { src: `/pages/${report.id}/video.mp4`, poster: `/pages/${report.id}/media/poster.jpg`, caption: "The cut" }); assert.equal("video" in view, false); }); diff --git a/common/lib/report/views.ts b/common/lib/report/views.ts @@ -1,15 +1,17 @@ // REPORT AND MOMENT PAGE VIEWS — the JSON the reports stage of compose writes // under the export app's public dir, and the export app's pages read. One -// definition, so the writer and the reader cannot disagree: +// definition, so the writer and the reader cannot disagree. Every report path +// is under the base its build serves reports under (./routes.ts): a site's +// `/pages/` (its pages, site.json `pages`) below. // -// /reports/index.json ReportIndexView the report index (and a cited site's home) -// /reports/<reportId>/page.json ReportPageView one report, its citations resolved -// /reports/<reportId>/citations.{json,csv} the report's citations, for download -// /reports/<reportId>/feed.{xml,json} its timeline as RSS 2.0 and JSON Feed 1.1 (./feeds.ts), +// /pages/index.json ReportIndexView the site's pages, in order (its header's links) +// /pages/<reportId>/page.json ReportPageView one report, its citations resolved +// /pages/<reportId>/citations.{json,csv} the report's citations, for download +// /pages/<reportId>/feed.{xml,json} its timeline as RSS 2.0 and JSON Feed 1.1 (./feeds.ts), // for a report with entries on a site with a public URL -// /reports/<reportId>/stills/… a source citation's still, as the report names it -// /reports/<reportId>/history/history.json ReportHistoryView its revisions (lib/report/revisions.ts) -// /reports/<reportId>/history/repo/ a dumb-HTTP clone of its revision history +// /pages/<reportId>/stills/… a source citation's still, as the report names it +// /pages/<reportId>/history/history.json ReportHistoryView its revisions (lib/report/revisions.ts) +// /pages/<reportId>/history/repo/ a dumb-HTTP clone of its revision history // /m/index.json MomentIndexView every moment page to build // /m/<momentKey>/moment.json MomentPageView one moment: clip, cues, record, "cited in" // /media/clips/<channel>/<id>/<start>-<end>.mp4 a span's evidence clip @@ -479,6 +481,9 @@ export type ReportViewResolver = { history?: ReportHistoryRef; // The report's feeds (absolute URLs), carried only by a report with entries. feeds?: ReportFeeds; + // Where the build serves its reports (./routes.ts): the published path of a + // still or the report's video. A site's by default. + base?: ReportBase; }; function sourceView(id: string, s: Source): SourceView { @@ -563,7 +568,7 @@ export function buildReportPageView(report: Report, resolve: ReportViewResolver) sourceId: c.source, sourceTitle: s.title, sourceAccent: s.accent, - image: c.image ? reportAssetPath(report.id, c.image) : undefined, + image: c.image ? reportAssetPath(report.id, c.image, resolve.base) : undefined, href: s.url, }); break; @@ -606,8 +611,8 @@ export function buildReportPageView(report: Report, resolve: ReportViewResolver) subtitle: report.subtitle, video: report.video ? defined({ - src: reportAssetPath(report.id, report.video.src), - poster: report.video.poster ? reportAssetPath(report.id, report.video.poster) : undefined, + src: reportAssetPath(report.id, report.video.src, resolve.base), + poster: report.video.poster ? reportAssetPath(report.id, report.video.poster, resolve.base) : undefined, caption: report.video.caption, }) : undefined, @@ -788,7 +793,7 @@ export function foundGroups(view: Pick<ReportPageView, "sections">): FoundGroup[ } // The report's entry in the index. -export function reportIndexEntry(view: ReportPageView): ReportIndexEntry { +export function reportIndexEntry(view: ReportPageView, base: ReportBase = SITE_REPORTS_BASE): ReportIndexEntry { const tally = view.kind === "factcheck" ? verdictTally(view) : undefined; return defined({ id: view.id, @@ -798,7 +803,7 @@ export function reportIndexEntry(view: ReportPageView): ReportIndexEntry { subtitle: view.subtitle, published: view.published, updated: view.updated, - href: reportPagePath(view.id), + href: reportPagePath(view.id, base), citationCount: Object.keys(view.citations).length, claimCount: view.sections.reduce((n, s) => n + s.claims.length, 0), tally, diff --git a/common/lib/site.ts b/common/lib/site.ts @@ -20,6 +20,8 @@ import { parseSiteUrl, siteChannelSlugs, sitePublishProblem, + siteSearchProblem, + reservedSiteIdProblem, siteToDisk, type Site, } from "./siteSchema"; @@ -231,6 +233,8 @@ export async function writeSite( if (!isValidSiteId(site.siteId)) { throw new Error(`Invalid site id: ${String(site.siteId)}`); } + const reserved = reservedSiteIdProblem(site.siteId); + if (reserved) throw new Error(reserved); const groups = parseChannelGroups(site.groups); if (groups.length === 0) { throw new Error("At least one channel group is required"); @@ -245,6 +249,9 @@ export async function writeSite( // 18). A private one is clamped to "build" by siteToDisk, not refused. const publishProblem = sitePublishProblem(site); if (publishProblem) throw new Error(publishProblem); + // A search-off site publishes only its pages: one with none is refused (D5). + const searchProblem = siteSearchProblem(site); + if (searchProblem) throw new Error(searchProblem); // undefined socialLinks = inherit the global default; only validate/persist a // key when the site explicitly overrides (an array, even empty). // A link whose SVG is unchanged from the file on disk is kept as it is; a new @@ -268,7 +275,7 @@ export async function writeSite( } // PATCH SOME KEYS OF A SITE — the writer for a surface that owns a few keys and -// none of the others (the Reports tab's `reports`). The site is read from disk +// none of the others (the Reports tab's `pages`). The site is read from disk // INSIDE the file lock and the patch is applied to that, so a patch never // writes back a copy of the other keys read earlier, and two patches never // interleave. A function patch is given the site as it is now (to reorder a @@ -289,6 +296,13 @@ export async function patchSite( if (!fs.existsSync(file)) return null; const current = getSite(siteId, paths); const changes = typeof patch === "function" ? patch(current) : patch; + // `reports` became `pages` in release 26 (A5). A caller still patching the + // old key (a generator outside the repo) is refused, loudly: its write + // would otherwise be dropped, or replace the page list with a list built + // from a key the site no longer has. + if ("reports" in (changes as Record<string, unknown>)) { + throw new Error(`site.json "reports" is now "pages" (release 26): patch "pages" instead`); + } await writeSite({ ...current, ...changes, siteId }, paths); return getSite(siteId, paths); }); diff --git a/common/lib/siteSchema.test.ts b/common/lib/siteSchema.test.ts @@ -22,7 +22,10 @@ import { siteFieldsSchema, sitePublishPolicy, sitePublishProblem, + siteSearchProblem, siteToDisk, + RESERVED_SITE_IDS, + reservedSiteIdProblem, type Site, } from "./siteSchema"; import { getSite, patchSite, resolveRelatedSites, siteConfigFile, writeSite } from "./site"; @@ -74,7 +77,7 @@ test("empty, null, [] and a number all read as the defaults, every key emitted", assert.equal(want.listed, true); assert.deepEqual(want.relatedSites, []); assert.equal(want.search, true); - assert.deepEqual(want.reports, []); + assert.deepEqual(want.pages, []); assert.deepEqual(want.citedChannels, []); assert.equal(want.socialLinks, undefined); assert.ok("socialLinks" in want); @@ -249,7 +252,7 @@ function fixtures(): Array<[string, unknown]> { siteUrl: "https://s.example//", listed: false, search: false, - reports: ["r-one", "r-one", "Bad", "", 7, "r-two"], + pages: ["r-one", "r-one", "Bad", "", 7, "r-two"], relatedSites: [{ siteIds: ["x", "x", "BAD"] }, { label: " ", siteIds: [] }], pwa: true, archives: false, @@ -338,7 +341,7 @@ test("search: absent/true is on, only false is report-only, and only false is wr assert.equal(siteToDisk(off).search, false); assert.equal(isCitedSite({}), false); // A search-off site with no reports is still report-only (an empty index). - assert.equal(isCitedSite(parseSite("s", { search: false, reports: [] })), true); + assert.equal(isCitedSite(parseSite("s", { search: false, pages: [] })), true); }); test("legacy publish: \"cited\" reads as search off and is rewritten as search: false", () => { @@ -358,38 +361,85 @@ test("legacy publish: \"cited\" reads as search off and is rewritten as search: assert.equal(parseSite("s", { publish: "cited", search: true }).search, true); }); -test("reports: ordered slugs, invalid and repeated ids dropped, written only when non-empty", () => { +test("pages: ordered slugs, invalid and repeated ids dropped, written only when non-empty", () => { assert.deepEqual( parseSiteReports(["b-two", "a-one", "b-two", "Upper", "-lead", "has space", "", 3, null, "c3"]), ["b-two", "a-one", "c3"], ); for (const v of [undefined, null, "a-one", { a: 1 }, 5]) { - assert.deepEqual(parseSite("s", v === undefined ? {} : { reports: v }).reports, [], String(v)); + assert.deepEqual(parseSite("s", v === undefined ? {} : { pages: v }).pages, [], String(v)); } - const site = parseSite("s", { reports: ["z-last", "a-first", "a-first"] }); - assert.deepEqual(site.reports, ["z-last", "a-first"]); - assert.deepEqual(siteToDisk(site).reports, ["z-last", "a-first"]); - assert.equal("reports" in siteToDisk(parseSite("s", { reports: [] })), false); - assert.equal("reports" in siteToDisk(parseSite("s", { reports: ["BAD"] })), false); + const site = parseSite("s", { pages: ["z-last", "a-first", "a-first"] }); + assert.deepEqual(site.pages, ["z-last", "a-first"]); + assert.deepEqual(siteToDisk(site).pages, ["z-last", "a-first"]); + assert.equal("pages" in siteToDisk(parseSite("s", { pages: [] })), false); + assert.equal("pages" in siteToDisk(parseSite("s", { pages: ["BAD"] })), false); // siteToDisk re-parses a caller's list: a bad id handed to the writer is not persisted. - assert.deepEqual(siteToDisk({ ...site, reports: ["ok", "NOPE", "ok"] }).reports, ["ok"]); + assert.deepEqual(siteToDisk({ ...site, pages: ["ok", "NOPE", "ok"] }).pages, ["ok"]); }); -test("writeSite → getSite round-trips a report-only site and its reports; a full site writes neither key", async () => { +test("the reserved site ids are refused on save, and only those", async () => { + assert.deepEqual([...RESERVED_SITE_IDS], ["articles", "new"]); const paths = scratchPaths(await mkdtemp(path.join(os.tmpdir(), "site-"))); - const cited = parseSite("s", { search: false, reports: ["first", "second"] }); + for (const id of RESERVED_SITE_IDS) { + assert.match(reservedSiteIdProblem(id) ?? "", /is reserved/); + await assert.rejects(writeSite(parseSite(id, {}), paths), /is reserved/, id); + assert.equal(fs.existsSync(siteConfigFile(paths, id)), false, id); + } + for (const id of ["articles-2", "news", "my-articles"]) { + assert.equal(reservedSiteIdProblem(id), null, id); + await writeSite(parseSite(id, {}), paths); + assert.ok(fs.existsSync(siteConfigFile(paths, id)), id); + } +}); + +test("legacy reports (before release 26) reads as pages, is never written, and loses to pages", () => { + const legacy = parseSite("s", { search: false, reports: ["one", "two"] }); + assert.deepEqual(legacy.pages, ["one", "two"]); + assert.equal(legacy.search, false); + const disk = siteToDisk(legacy) as Record<string, unknown>; + assert.deepEqual(disk.pages, ["one", "two"]); + assert.equal("reports" in disk, false); + assert.equal("reports" in legacy, false); + assert.deepEqual(parseSite("s", { pages: ["new"], reports: ["old"] }).pages, ["new"]); + assert.deepEqual(parseSite("s", { pages: [], reports: ["old"] }).pages, []); +}); + +test("a search-off site with no pages is refused on save; with one, or with search on, it is not", async () => { + assert.match(siteSearchProblem({ search: false }) ?? "", /search is off and the site has no pages/); + assert.match(siteSearchProblem({ search: false, pages: ["BAD"] }) ?? "", /no pages/); + assert.equal(siteSearchProblem({ search: false, pages: ["one"] }), null); + assert.equal(siteSearchProblem({ search: true }), null); + assert.equal(siteSearchProblem({}), null); + const paths = scratchPaths(await mkdtemp(path.join(os.tmpdir(), "site-"))); + await assert.rejects(writeSite(parseSite("s", { search: false }), paths), /no pages/); + assert.equal(fs.existsSync(siteConfigFile(paths, "s")), false); + await writeSite(parseSite("s", { search: false, pages: ["one"] }), paths); + // A caller still patching the pre-release-26 key is refused, not ignored. + await assert.rejects( + patchSite("s", (cur) => ({ reports: ["two", ...(cur.pages ?? [])] }) as Partial<Site>, paths), + /"reports" is now "pages"/, + ); + // Unpublishing the last page of a search-off site is refused too. + await assert.rejects(patchSite("s", { pages: [] }, paths), /no pages/); + assert.deepEqual(getSite("s", paths).pages, ["one"]); +}); + +test("writeSite → getSite round-trips a search-off site and its pages; a full site writes neither key", async () => { + const paths = scratchPaths(await mkdtemp(path.join(os.tmpdir(), "site-"))); + const cited = parseSite("s", { search: false, pages: ["first", "second"] }); await writeSite(cited, paths); assert.deepEqual(getSite("s", paths), cited); const disk = JSON.parse(await readFile(siteConfigFile(paths, "s"), "utf8")); assert.equal(disk.search, false); assert.equal("publish" in disk, false); - assert.deepEqual(disk.reports, ["first", "second"]); - await writeSite({ ...cited, search: true, reports: [] }, paths); + assert.deepEqual(disk.pages, ["first", "second"]); + await writeSite({ ...cited, search: true, pages: [] }, paths); const plain = JSON.parse(await readFile(siteConfigFile(paths, "s"), "utf8")); assert.equal("search" in plain, false); - assert.equal("reports" in plain, false); + assert.equal("pages" in plain, false); assert.equal(getSite("s", paths).search, true); - assert.deepEqual(getSite("s", paths).reports, []); + assert.deepEqual(getSite("s", paths).pages, []); }); test("isListedSite is the key's default; channelsOnlyOnUnlistedSites keeps a shared channel with the listed site", () => { @@ -409,7 +459,7 @@ test("a report-only site is never listed, whatever `listed` says; a full site wi assert.equal(isListedSite({ search: false }), false); assert.equal(isListedSite({ search: false, listed: true }), false); assert.equal(isListedSite({ search: true }), true); - assert.equal(isListedSite(parseSite("full-with-reports", { reports: ["demo-report"] })), true); + assert.equal(isListedSite(parseSite("full-with-reports", { pages: ["demo-report"] })), true); const sites = [ parseSite("shown", { channels: [{ slug: "shared" }] }), parseSite("reports", { search: false, channels: [{ slug: "shared" }, { slug: "pool-only" }] }), @@ -450,34 +500,34 @@ test("writeSite → getSite round-trips, and the file holds only non-defaults", assert.equal("listed" in disk, false); assert.equal("search" in disk, false); assert.equal("publish" in disk, false); - assert.equal("reports" in disk, false); + assert.equal("pages" in disk, false); }); test("patchSite applies a patch to the site on disk now, keeps every other key, and never creates a site", async () => { const paths = scratchPaths(await mkdtemp(path.join(os.tmpdir(), "site-"))); - assert.equal(await patchSite("s", { reports: ["one"] }, paths), null); + assert.equal(await patchSite("s", { pages: ["one"] }, paths), null); assert.equal(fs.existsSync(siteConfigFile(paths, "s")), false); const site = parseSite("s", { siteTitle: "Mine", archives: false, search: false, - reports: ["one", "two"], + pages: ["one", "two"], }); await writeSite(site, paths); // Another writer changes a key after this caller last read the site: the // patch is applied to the file, not to the stale copy. await writeSite({ ...site, siteTitle: "Renamed" }, paths); - const patched = await patchSite("s", { reports: ["two", "one"] }, paths); - assert.deepEqual(patched, { ...site, siteTitle: "Renamed", reports: ["two", "one"] }); + const patched = await patchSite("s", { pages: ["two", "one"] }, paths); + assert.deepEqual(patched, { ...site, siteTitle: "Renamed", pages: ["two", "one"] }); assert.deepEqual(getSite("s", paths), patched); // A function patch sees the site as it is; two patches do not interleave. await Promise.all([ - patchSite("s", (cur) => ({ reports: [...(cur.reports ?? []), "three"] }), paths), - patchSite("s", (cur) => ({ reports: [...(cur.reports ?? []), "four"] }), paths), + patchSite("s", (cur) => ({ pages: [...(cur.pages ?? []), "three"] }), paths), + patchSite("s", (cur) => ({ pages: [...(cur.pages ?? []), "four"] }), paths), ]); - assert.deepEqual(getSite("s", paths).reports, ["two", "one", "three", "four"]); + assert.deepEqual(getSite("s", paths).pages, ["two", "one", "three", "four"]); // The id is the directory's, whatever a patch says. await patchSite("s", { siteId: "other" } as Partial<Site>, paths); assert.equal(getSite("s", paths).siteId, "s"); @@ -589,14 +639,14 @@ test("writeSite → getSite round-trips citedChannels, and patchSite keeps the k channels: [{ slug: "pool" }], citedChannels: [{ slug: "critic" }, { slug: "other-critic" }], search: false, - reports: ["one"], + pages: ["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); + const patched = await patchSite("s", { pages: ["one", "two"] }, paths); assert.deepEqual(patched?.citedChannels, [{ slug: "critic" }, { slug: "other-critic" }]); // Emptied, the key leaves the file. await patchSite("s", { citedChannels: [] }, paths); diff --git a/common/lib/siteSchema.ts b/common/lib/siteSchema.ts @@ -105,8 +105,9 @@ export function isPrivateSite(site: Pick<Site, "audience">): boolean { } // THE ONE PREDICATE for a report-only ("cited") site: search is off. Such a -// site publishes only its reports and the moments they cite (corpus.json -// `site.scope: "cited"`). Absent or true is a full, searchable site. +// site publishes only its pages (`pages`) and the moments they cite +// (corpus.json `site.scope: "cited"`). Absent or true is a full, searchable +// site. export function isCitedSite(site: Pick<Site, "search">): boolean { return site.search === false; } @@ -121,6 +122,18 @@ function migrateLegacyPublish(raw: unknown): unknown { return { ...r, search: false }; } +// LEGACY, release 26 only: `reports` (the published list before it was a +// site's pages) reads as `pages` when the file sets no `pages`. siteToDisk +// never writes `reports`, so the next save migrates the file; the data move +// (plans/reports-on-homepage.md, A7) rewrites every file that still has it. +function migrateLegacyReports(raw: unknown): unknown { + if (!raw || typeof raw !== "object" || Array.isArray(raw)) return raw; + const r = raw as Record<string, unknown>; + if (!("reports" in r)) return raw; + const { reports, ...rest } = r; + return rest.pages !== undefined ? rest : { ...rest, pages: reports }; +} + // A report id: a lowercase slug, the directory name under // `sites/<siteId>/reports/`. The grammar is the report document's own // (lib/report/schema.ts) — one definition. @@ -130,8 +143,9 @@ export function isValidReportId(id: unknown): id is string { return isReportId(id); } -// Parse the published report list: valid ids, first occurrence kept, order -// preserved. Anything else (a non-array, a bad or repeated id) is dropped. +// Parse a site's page list (`pages`: report ids): valid ids, first occurrence +// kept, order preserved. Anything else (a non-array, a bad or repeated id) is +// dropped. export function parseSiteReports(input: unknown): string[] { if (!Array.isArray(input)) return []; const out: string[] = []; @@ -163,7 +177,7 @@ export type Site = { siteUrl?: string; listed?: boolean; audience?: SiteAudience; - reports?: string[]; + pages?: string[]; relatedSites?: RelatedSiteGroup[]; search?: boolean; pwa?: boolean; @@ -204,12 +218,12 @@ export const SITE_FIELD_DOCS: FieldDocs<Site> = { "Whether the family lists this site. Opt-OUT: absent/true = listed, only an explicit `false` is written. An unlisted site still builds and deploys as before, and its own pages are unchanged; it is left out of the homepage (cards, chart, `/stats`), the hub (members, federated search, `/corpus.json`, `/llms.txt`), every other site's footer, and the published `channel-sites.json` and pooled `stats/`. A channel only unlisted sites expose is in none of the family's public totals; a channel a listed site also exposes is credited to the listed one. A private site and a report-only site (`search: false`) are never listed, whatever `listed` says.", audience: 'Who this site is built for. `"public"` (the default; absent) or `"private"`: the operator\'s own reading copy, built on this machine and never deployed — the deploy stage refuses it before any upload — Deploy production, Deploy preview, Deploy local, Build & deploy, Publish now, the publish lane, `archilyzer publish deploy`, docker/publish-site.sh — while a build without a deploy still works (its publish policy reads as `build`). A private site is never listed (as `listed: false`, whatever `listed` says), publishes no `hubUrl`, and its `/corpus.json` says `"audience": "private"`. Content kept from the public — X posts while `social.x.visibility` is `"private"` — is built only into private sites. Only `"private"` is written.', - reports: - "The site's published reports, in display order: report ids (lowercase slugs, `[a-z0-9][a-z0-9-]*`), each a directory under `sites/<siteId>/reports/`. A report directory not named here is a draft and is not published. Invalid and repeated ids are dropped. Absent/empty = no reports.", + pages: + "The site's pages, in order: report ids (lowercase slugs, `[a-z0-9][a-z0-9-]*`), each a directory under `sites/<siteId>/reports/` holding a report document. Each is served at `/pages/<id>/` and linked from the site's header by its title; a report directory not named here is a draft and is not published. Invalid and repeated ids are dropped. Absent/empty = no pages. Legacy `reports` (the key before release 26) reads as `pages` when `pages` is absent, and is never written.", 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 (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`.", + "Whether this site publishes its searchable corpus. Opt-OUT: absent/true = on, only an explicit `false` is written. Off = pages only: the site publishes only its `pages` and the moments they cite — no search, browse, transcripts or archives; its home page is its first page; `channels` is the pool its citations resolve against (with `citedChannels`), and its `/corpus.json` says `\"scope\": \"cited\"`. A save with search off and no `pages` is refused. A search-off 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: @@ -272,6 +286,14 @@ function parseSitePublish(v: unknown): SitePublish | undefined { return { auto }; } +// Why a save of this site's search switch is refused, or null: a site with +// search off publishes only its pages, so it needs one (D5, +// plans/reports-on-homepage.md — no report-only site without a page). +export function siteSearchProblem(site: Pick<Site, "search" | "pages">): string | null { + if (!isCitedSite(site) || parseSiteReports(site.pages).length > 0) return null; + return "search is off and the site has no pages — a search-off site publishes only its pages: add one, or turn search on"; +} + // siteId shares the group-id grammar: lowercase slug, used as a directory name. export const SITE_ID_RE = /^[a-z0-9][a-z0-9-]*$/; @@ -279,6 +301,18 @@ export function isValidSiteId(id: unknown): id is string { return typeof id === "string" && SITE_ID_RE.test(id); } +// Site ids a new site may not take (release 26, ruled): the editor's +// `/sites/articles` (the Articles tab) and `/sites/new` (the create form), and +// umtool's `articles/<id>`, would hide a site of that name. +export const RESERVED_SITE_IDS: readonly string[] = ["articles", "new"]; + +// Why a save of a site under this id is refused, or null. +export function reservedSiteIdProblem(id: string): string | null { + return RESERVED_SITE_IDS.includes(id) + ? `"${id}" is reserved (the editor's /sites/${id} and umtool's articles/ would hide a site of that name) — choose another id` + : null; +} + // THE ONE PREDICATE for `listed` (site.json's opt-out; absent = listed). Every // public output that enumerates the family's sites filters through it: the // homepage summary (lib/homepageSummary.ts), channel-sites.json and the pooled @@ -496,7 +530,7 @@ export const siteFieldsSchema = z.object({ audience: settingsField((v): SiteAudience | undefined => v === "private" ? "private" : undefined, ).describe(d.audience), - reports: settingsField(parseSiteReports).describe(d.reports), + pages: settingsField(parseSiteReports).describe(d.pages), relatedSites: settingsField(parseRelatedSites).describe(d.relatedSites), // Opt-out: only an explicit false is report-only. Absent/true stays on. search: settingsField((v): boolean => v !== false).describe(d.search), @@ -522,7 +556,7 @@ export const siteFieldsSchema = z.object({ // output lacks `socialLinks`, `accent`, … on a file that does not spell them — // where parseSite has always emitted them, present and `undefined`. Rebuilding // from SITE_KEYS keeps that shape (and the key order) exactly. -export const siteSchema = z.preprocess(migrateLegacyPublish, siteFieldsSchema).transform((s): Site => { +export const siteSchema = z.preprocess((raw) => migrateLegacyReports(migrateLegacyPublish(raw)), siteFieldsSchema).transform((s): Site => { const groups = s.groups; const resolved: Partial<Record<keyof Site, unknown>> = { ...s, @@ -576,7 +610,7 @@ export function siteToDisk(site: Site): Site { channels, ); const relatedSites = parseRelatedSites(site.relatedSites); - const reports = parseSiteReports(site.reports); + const pages = parseSiteReports(site.pages); const accent = parseAccentSetting(site.accent); const wordmarkLead = wordmarkLeadFor(site.headerTitle, site.wordmarkLead); const siteUrl = parseSiteUrl(site.siteUrl); @@ -608,7 +642,7 @@ export function siteToDisk(site: Site): Site { ...(site.listed === false ? { listed: false } : {}), // Public is the default: only the private audience is persisted. ...(isPrivateSite(site) ? { audience: "private" as const } : {}), - ...(reports.length > 0 ? { reports } : {}), + ...(pages.length > 0 ? { pages } : {}), ...(relatedSites.length > 0 ? { relatedSites } : {}), // Search is the default: only report-only is persisted (never `publish`). ...(isCitedSite(site) ? { search: false } : {}), diff --git a/common/publish/build.ts b/common/publish/build.ts @@ -811,10 +811,10 @@ async function buildPrivateHomepage( // after a private build. A public build composes them again. export async function clearHomepageArticles(paths: Paths): Promise<void> { const { reportPublicEntries } = await import("./composeReports"); - const { ARTICLES_BASE } = await import("../lib/report/routes"); + const { ARTICLES_REPORTS_BASE } = await import("../lib/report/routes"); const { HOMEPAGE_BUILD_STAMP } = await import("../lib/builtHomepage"); const pub = process.env.HOMEPAGE_PUBLIC_DIR ?? path.join(homepageDir(paths), "public"); - for (const entry of [...reportPublicEntries(ARTICLES_BASE), HOMEPAGE_BUILD_STAMP]) { + for (const entry of [...reportPublicEntries(ARTICLES_REPORTS_BASE), HOMEPAGE_BUILD_STAMP]) { await rm(path.join(pub, entry), { recursive: true, force: true }); } } diff --git a/common/publish/composeReports.test.ts b/common/publish/composeReports.test.ts @@ -284,8 +284,8 @@ async function seedCorpus() { }, ]); - seedSite("cited", { search: false, reports: [REPORT] }); - seedSite("full", { reports: [REPORT] }); + seedSite("cited", { search: false, pages: [REPORT] }); + seedSite("full", { pages: [REPORT] }); seedSite("plain", {}, false); await buildIndex({ paths, onLog: () => {} }); } @@ -326,11 +326,11 @@ test("a cited site: exactly its reports, moments, cited media and contract — t `media/clips/${def}.m4a`, `media/posts/${SOCIAL}/3kabc/photo.jpg`, `media/posts/${SOCIAL}/3kabc/shot.png`, - `reports/${REPORT}/citations.csv`, - `reports/${REPORT}/citations.json`, - `reports/${REPORT}/page.json`, - `reports/${REPORT}/stills/a01.png`, - "reports/index.json", + `pages/${REPORT}/citations.csv`, + `pages/${REPORT}/citations.json`, + `pages/${REPORT}/page.json`, + `pages/${REPORT}/stills/a01.png`, + "pages/index.json", "robots.txt", "site.json", "sitemap.xml", @@ -360,12 +360,12 @@ test("a cited site's contract: site.json without channels, corpus.json scope cit assert.equal(corpus.site.audience, "public"); assert.deepEqual(corpus.channels, []); assert.deepEqual(corpus.totals, { channels: 0, videos: 0 }); - assert.equal(corpus.reports?.index, "https://cited.example.test/reports/index.json"); + assert.equal(corpus.reports?.index, "https://cited.example.test/pages/index.json"); assert.equal(corpus.reports?.count, 1); const llms = readFileSync(pub("llms.txt"), "utf8"); assert.match(llms, /^# Site cited/); - assert.match(llms, /\[Checking a demo article\]\(https:\/\/cited\.example\.test\/reports\/demo-report\/\): Four claims, one stream/); + assert.match(llms, /\[Checking a demo article\]\(https:\/\/cited\.example\.test\/pages\/demo-report\/\): Four claims, one stream/); assert.match(llms, /there is no searchable corpus here/); assert.doesNotMatch(llms, /## Channels|shardScheme|page-<NNNN>|transcripts\//); @@ -373,8 +373,7 @@ test("a cited site's contract: site.json without channels, corpus.json scope cit const locs = [...sitemap.matchAll(/<loc>([^<]+)<\/loc>/g)].map((m) => m[1].replace("https://cited.example.test", "")); assert.deepEqual(locs, [ "/", - "/reports/", - "/reports/demo-report/", + "/pages/demo-report/", `/m/${VIDEOS}/abc123/10.00-20.00/`, `/m/${VIDEOS}/def456/5.00-9.00/`, `/m/${SOCIAL}/3kabc/`, @@ -387,7 +386,7 @@ test("a cited site's contract: site.json without channels, corpus.json scope cit type View = { citations: Record<string, { verification?: Record<string, unknown>; record?: Record<string, unknown>; shot?: string; text?: string; author?: string }> }; test("verification is computed at compose: a hand-typed block is overwritten, a page's dropped, en-orig read when en has no cues", () => { - const view = readJson<View>(pub("reports", REPORT, "page.json")); + const view = readJson<View>(pub("pages", REPORT, "page.json")); const v = view.citations.c01.verification!; assert.equal(v.quoteScore, 1); assert.equal(v.method, `${QUOTE_CHECK_METHOD}; text: transcript.en.vtt`, "the method names the transcript that matched"); @@ -435,7 +434,7 @@ test("moment pages: the clip with its pad, the bounded cue context, the post's c ); assert.deepEqual( span.citedIn.map((e) => e.href), - [`/reports/${REPORT}/#claim-1`], + [`/pages/${REPORT}/#claim-1`], ); const audio = readJson<Record<string, unknown>>(pub("m", VIDEOS, "def456", "5.00-9.00", "moment.json")); assert.equal(audio.kind, "audio"); @@ -456,14 +455,14 @@ test("moment pages: the clip with its pad, the bounded cue context, the post's c }); test("the citations as files: a valid citation set without the saved copy, and one CSV row per citation", () => { - const set = readJson(pub("reports", REPORT, "citations.json")); + const set = readJson(pub("pages", REPORT, "citations.json")); const parsed = parseCitationSet(set); assert.ok(parsed.ok, JSON.stringify(parsed.problems)); assert.deepEqual(parsed.problems, []); assert.deepEqual(Object.keys((set as { citations: object }).citations), ["a01", "c01", "p01", "c02", "w01"]); assert.ok(!JSON.stringify(set).includes("saved"), "a source's saved copy is never published"); - const csv = readFileSync(pub("reports", REPORT, "citations.csv"), "utf8").trimEnd().split("\r\n"); + const csv = readFileSync(pub("pages", REPORT, "citations.csv"), "utf8").trimEnd().split("\r\n"); assert.equal(csv[0], CITATIONS_CSV_COLUMNS.join(",")); assert.equal(csv.length, 6); assert.equal( @@ -485,7 +484,7 @@ test("a quote that drifted from its cues fails compose, before anything is writt ); return true; }); - assert.ok(!existsSync(pub("reports"))); + assert.ok(!existsSync(pub("pages"))); assert.ok(!existsSync(pub("site.json")), "a failed compose leaves public/ naming no site"); } finally { writeJson(file, report()); @@ -527,10 +526,10 @@ test("a report's video: copied beside its page and named in the view; a missing writeText(path.join(dir, "video.mp4"), "mp4-bytes"); writeText(path.join(dir, "poster.jpg"), "jpg-bytes"); await compose("cited"); - assert.equal(readFileSync(pub("reports", REPORT, "video.mp4"), "utf8"), "mp4-bytes"); - assert.equal(readFileSync(pub("reports", REPORT, "poster.jpg"), "utf8"), "jpg-bytes"); - const view = readJson<{ video?: unknown }>(pub("reports", REPORT, "page.json")); - assert.deepEqual(view.video, { src: `/reports/${REPORT}/video.mp4`, poster: `/reports/${REPORT}/poster.jpg`, caption: "The cut" }); + assert.equal(readFileSync(pub("pages", REPORT, "video.mp4"), "utf8"), "mp4-bytes"); + assert.equal(readFileSync(pub("pages", REPORT, "poster.jpg"), "utf8"), "jpg-bytes"); + const view = readJson<{ video?: unknown }>(pub("pages", REPORT, "page.json")); + assert.deepEqual(view.video, { src: `/pages/${REPORT}/video.mp4`, poster: `/pages/${REPORT}/poster.jpg`, caption: "The cut" }); writeFileSync(path.join(dir, "video.mp4"), Buffer.alloc(25 * 1024 * 1024)); await assert.rejects(compose("cited"), (e: unknown) => { assert.ok(e instanceof ComposeReportsError); @@ -579,14 +578,14 @@ test("a full site with reports keeps its corpus and links each moment into it", assert.equal(post.record.corpusUrl, `/?v=${SOCIAL}%2F3kabc&vm=post`); const llms = readFileSync(pub("llms.txt"), "utf8"); assert.match(llms, /## Reports[^]*Checking a demo article[^]*## Channels/); - assert.match(readFileSync(pub("sitemap.xml"), "utf8"), /\/reports\/demo-report\//); + assert.match(readFileSync(pub("sitemap.xml"), "utf8"), /\/pages\/demo-report\//); assert.equal(citedBuildProblem(paths.exportPublicDir), null, "the audit leaves a full build alone"); }); test("a site with no reports ships none of the last site's", async () => { await compose("cited"); await compose("plain"); - for (const entry of ["reports", "m", "media"]) assert.ok(!existsSync(pub(entry)), entry); + for (const entry of ["pages", "reports", "m", "media"]) assert.ok(!existsSync(pub(entry)), entry); const corpus = readJson<{ reports?: unknown }>(pub("corpus.json")); assert.equal(corpus.reports, undefined); }); @@ -603,43 +602,43 @@ test("a report's timeline: its feeds beside the page on a site with a public URL ["timeline", {}], ["timeline-private", { siteUrl: undefined, audience: "private" }], ] as const) { - seedSite(siteId, { search: false, reports: [REPORT], ...extra }); + seedSite(siteId, { search: false, pages: [REPORT], ...extra }); writeJson(path.join(paths.sitesDir, siteId, "reports", REPORT, "report.json"), withTimeline); } await compose("timeline"); - const page = readJson<{ entries: { id: string }[]; updated?: string; feeds?: Record<string, string> }>(pub("reports", REPORT, "page.json")); + const page = readJson<{ entries: { id: string }[]; updated?: string; feeds?: Record<string, string> }>(pub("pages", REPORT, "page.json")); assert.deepEqual(page.entries.map((e) => e.id), ["e-new", "e-old"]); assert.equal(page.updated, "2026-10-05T08:30:00Z"); assert.deepEqual(page.feeds, { - rss: `https://timeline.example.test/reports/${REPORT}/feed.xml`, - json: `https://timeline.example.test/reports/${REPORT}/feed.json`, + rss: `https://timeline.example.test/pages/${REPORT}/feed.xml`, + json: `https://timeline.example.test/pages/${REPORT}/feed.json`, }); - const index = readJson<{ reports: { updated?: string }[] }>(pub("reports", "index.json")); + const index = readJson<{ reports: { updated?: string }[] }>(pub("pages", "index.json")); assert.equal(index.reports[0].updated, "2026-10-05T08:30:00Z"); - const rss = readFileSync(pub("reports", REPORT, "feed.xml"), "utf8"); + const rss = readFileSync(pub("pages", REPORT, "feed.xml"), "utf8"); const items = [...rss.matchAll(/<link>([^<]+)<\/link>/g)].map((m) => m[1]); assert.deepEqual(items, [ - `https://timeline.example.test/reports/${REPORT}/`, - `https://timeline.example.test/reports/${REPORT}/#e-new`, - `https://timeline.example.test/reports/${REPORT}/#e-old`, + `https://timeline.example.test/pages/${REPORT}/`, + `https://timeline.example.test/pages/${REPORT}/#e-new`, + `https://timeline.example.test/pages/${REPORT}/#e-old`, ]); assert.match(rss, /<title>First & <update><\/title>/); - const feed = readJson<{ version: string; items: { id: string }[] }>(pub("reports", REPORT, "feed.json")); + const feed = readJson<{ version: string; items: { id: string }[] }>(pub("pages", REPORT, "feed.json")); assert.equal(feed.version, "https://jsonfeed.org/version/1.1"); assert.deepEqual(feed.items.map((i) => i.id.split("#")[1]), ["e-new", "e-old"]); // Served as what they are, and readable cross-origin. - assert.match(readFileSync(pub("_headers"), "utf8"), /\/reports\/:report\/feed\.xml\n {2}Content-Type: application\/rss\+xml; charset=utf-8\n/); - // The cited audit allows them (reports/ is the stage's own). + assert.match(readFileSync(pub("_headers"), "utf8"), /\/pages\/:report\/feed\.xml\n {2}Content-Type: application\/rss\+xml; charset=utf-8\n/); + // The cited audit allows them (pages/ is the stage's own). assert.equal(citedBuildProblem(paths.exportPublicDir), null); // No public URL: the page and its timeline, no feed — absolute links have nowhere to point. await compose("timeline-private"); - const priv = readJson<{ entries: unknown[]; feeds?: unknown }>(pub("reports", REPORT, "page.json")); + const priv = readJson<{ entries: unknown[]; feeds?: unknown }>(pub("pages", REPORT, "page.json")); assert.equal(priv.entries.length, 2); assert.equal(priv.feeds, undefined); - assert.ok(!existsSync(pub("reports", REPORT, "feed.xml"))); - assert.ok(!existsSync(pub("reports", REPORT, "feed.json"))); + assert.ok(!existsSync(pub("pages", REPORT, "feed.xml"))); + assert.ok(!existsSync(pub("pages", REPORT, "feed.json"))); }); // ─── Exports (publish/reportExports.ts) ─── @@ -732,20 +731,20 @@ test("reports export: every format from the resolved view, a self-contained HTML test("compose publishes the exports beside the report and lists them as downloads", async () => { await compose("cited"); for (const f of ["report.html", "report.pdf", "report.md", "slides.html", "slides.pdf", "evidence-pack.zip"]) { - assert.equal(sha(pub("reports", REPORT, f)), sha(path.join(reportExportDir(paths, "cited", REPORT), f)), f); + assert.equal(sha(pub("pages", REPORT, f)), sha(path.join(reportExportDir(paths, "cited", REPORT), f)), f); } - const view = readJson<{ downloads: Record<string, string> }>(pub("reports", REPORT, "page.json")); + const view = readJson<{ downloads: Record<string, string> }>(pub("pages", REPORT, "page.json")); assert.deepEqual(view.downloads, { - html: `/reports/${REPORT}/report.html`, - pdf: `/reports/${REPORT}/report.pdf`, - md: `/reports/${REPORT}/report.md`, - slides: `/reports/${REPORT}/slides.html`, - "slides-pdf": `/reports/${REPORT}/slides.pdf`, - zip: `/reports/${REPORT}/evidence-pack.zip`, - json: `/reports/${REPORT}/citations.json`, - csv: `/reports/${REPORT}/citations.csv`, + html: `/pages/${REPORT}/report.html`, + pdf: `/pages/${REPORT}/report.pdf`, + md: `/pages/${REPORT}/report.md`, + slides: `/pages/${REPORT}/slides.html`, + "slides-pdf": `/pages/${REPORT}/slides.pdf`, + zip: `/pages/${REPORT}/evidence-pack.zip`, + json: `/pages/${REPORT}/citations.json`, + csv: `/pages/${REPORT}/citations.csv`, }); - assert.equal(citedBuildProblem(paths.exportPublicDir), null, "the exports are within reports/, which the audit allows"); + assert.equal(citedBuildProblem(paths.exportPublicDir), null, "the exports are within pages/, which the audit allows"); }); test("reports export commits a revision when report.json changed; compose publishes the history, the page names it", async () => { @@ -783,19 +782,19 @@ test("reports export commits a revision when report.json changed; compose publis const history = readJson<{ clone: string; revisions: { revision: number; commit: string; reportSha256: string; date: string; summary: string[]; claims: { id: string }[] }[]; - }>(pub("reports", REPORT, "history", "history.json")); - assert.equal(history.clone, `https://cited.example.test/reports/${REPORT}/history/repo`); + }>(pub("pages", REPORT, "history", "history.json")); + assert.equal(history.clone, `https://cited.example.test/pages/${REPORT}/history/repo`); assert.deepEqual(history.revisions.map((x) => x.revision), [1, 2]); assert.equal(history.revisions[1].commit, m.revision?.commit); assert.equal(history.revisions[1].reportSha256, sha(file)); assert.equal(history.revisions[1].date, "2026-10-06T08:00:00Z"); assert.deepEqual(history.revisions[1].claims.map((c) => c.id), ["claim-1"]); - const repo = filesUnder(pub("reports", REPORT, "history", "repo")); + const repo = filesUnder(pub("pages", REPORT, "history", "repo")); assert.deepEqual(repo.filter((f) => !f.startsWith("objects/pack/")), ["HEAD", "info/refs", "objects/info/packs", "packed-refs", "refs/heads/main"]); assert.ok(repo.some((f) => f.endsWith(".pack"))); - const view = readJson<{ history: unknown }>(pub("reports", REPORT, "page.json")); - assert.deepEqual(view.history, { revision: 2, date: "2026-10-06T08:00:00Z", href: `/reports/${REPORT}/history/`, current: true }); - assert.match(readFileSync(pub("sitemap.xml"), "utf8"), new RegExp(`/reports/${REPORT}/history/`)); + const view = readJson<{ history: unknown }>(pub("pages", REPORT, "page.json")); + assert.deepEqual(view.history, { revision: 2, date: "2026-10-06T08:00:00Z", href: `/pages/${REPORT}/history/`, current: true }); + assert.match(readFileSync(pub("sitemap.xml"), "utf8"), new RegExp(`/pages/${REPORT}/history/`)); assert.equal(citedBuildProblem(paths.exportPublicDir), null); assert.equal(reportHistoryProblem(paths.exportPublicDir), null); } finally { @@ -803,7 +802,7 @@ test("reports export commits a revision when report.json changed; compose publis } // Edited since the newest revision and not exported: the page says so. await compose("cited"); - const view = readJson<{ history: { revision: number; current: boolean } }>(pub("reports", REPORT, "page.json")); + const view = readJson<{ history: { revision: number; current: boolean } }>(pub("pages", REPORT, "page.json")); assert.deepEqual([view.history.revision, view.history.current], [2, false]); // Exported again, the way back is revision 3. const back = await exportSiteReports({ siteId: "cited", paths, now: () => new Date("2026-10-06T09:00:00Z"), openPdfPrinter: fakePrinter([]), onLog: () => {} }); @@ -811,7 +810,7 @@ test("reports export commits a revision when report.json changed; compose publis assert.deepEqual(back.exported[0].manifest.revision?.summary, ["Verdict changed: claim-1 PARTLY → CONTRADICTED", "Claim edited: claim-1 (text)"]); // A site with no reports ships no history. await compose("plain"); - assert.ok(!existsSync(pub("reports"))); + assert.ok(!existsSync(pub("pages"))); }); test("an export of another version of the report is not published; a pack over the limit stays local", async () => { @@ -821,17 +820,17 @@ test("an export of another version of the report is not published; a pack over t writeFileSync(file, `${saved}\n`); try { await compose("cited"); - assert.ok(!existsSync(pub("reports", REPORT, "report.html"))); - const view = readJson<{ downloads: Record<string, string> }>(pub("reports", REPORT, "page.json")); + assert.ok(!existsSync(pub("pages", REPORT, "report.html"))); + const view = readJson<{ downloads: Record<string, string> }>(pub("pages", REPORT, "page.json")); assert.deepEqual(Object.keys(view.downloads), ["json", "csv"]); } finally { writeFileSync(file, saved); } truncateSync(path.join(dir, "evidence-pack.zip"), 25 * 1024 * 1024); await compose("cited"); - assert.ok(existsSync(pub("reports", REPORT, "report.html"))); - assert.ok(!existsSync(pub("reports", REPORT, "evidence-pack.zip"))); - const view = readJson<{ downloads: Record<string, string> }>(pub("reports", REPORT, "page.json")); + assert.ok(existsSync(pub("pages", REPORT, "report.html"))); + assert.ok(!existsSync(pub("pages", REPORT, "evidence-pack.zip"))); + const view = readJson<{ downloads: Record<string, string> }>(pub("pages", REPORT, "page.json")); assert.deepEqual(Object.keys(view.downloads), ["html", "pdf", "md", "slides", "slides-pdf", "json", "csv"]); }); @@ -896,11 +895,11 @@ test("a report's notes.json (umtool's operator notes) is never published, export // clips publish, its corpus does not, and no moment links into a corpus. test("a cited-only channel: its moment pages and clips publish on the citing site, its corpus never does", async () => { const pool = [{ slug: SOCIAL, groupId: "default" }]; - const citedScope = { reports: [REPORT], channels: pool, citedChannels: [{ slug: VIDEOS }] }; - seedSite("padded", { reports: [REPORT] }); + const citedScope = { pages: [REPORT], channels: pool, citedChannels: [{ slug: VIDEOS }] }; + seedSite("padded", { pages: [REPORT] }); seedSite("padded-private", { ...citedScope, audience: "private" }); seedSite("padded-cited", citedScope); - seedSite("unpadded", { reports: [REPORT], channels: pool }); + seedSite("unpadded", { pages: [REPORT], channels: pool }); await buildIndex({ paths, onLog: () => {} }); const abc = `${VIDEOS}/abc123/10.00-20.00`; @@ -928,7 +927,7 @@ test("a cited-only channel: its moment pages and clips publish on the citing sit // still links into this site's corpus. assert.equal(span.record.corpusUrl, undefined, siteId); assert.equal(readJson<Moment>(pub("m", SOCIAL, "3kabc", "moment.json")).record.corpusUrl, `/?v=${SOCIAL}%2F3kabc&vm=post`); - const view = readJson<View>(pub("reports", REPORT, "page.json")); + const view = readJson<View>(pub("pages", REPORT, "page.json")); assert.equal(view.citations.c01.record?.corpusUrl, undefined, siteId); assert.equal(view.citations.c02.record?.corpusUrl, undefined, siteId); assert.ok(view.citations.p01.record?.corpusUrl, siteId); @@ -946,7 +945,7 @@ test("a cited-only channel: its moment pages and clips publish on the citing sit // citations, the moment index and the sitemap do. const naming = files.filter( (f) => - !f.startsWith("reports/") && + !f.startsWith("pages/") && !f.startsWith("m/") && !f.startsWith("media/") && f !== "sitemap.xml" && diff --git a/common/publish/composeReports.ts b/common/publish/composeReports.ts @@ -10,14 +10,14 @@ // ONE STAGE, TWO HOSTS (release 26, plans/reports-on-homepage.md): the stage // is a resolver over a HOST (./reportHost.ts — whose reports, what they may // cite, where the record links go) and a writer into an OUTPUT ROOT. -// `composeReports` / `resolveSiteReports` are the site's (its `reports`, its +// `composeReports` / `resolveSiteReports` are the site's (its `pages`, its // `channels` + `citedChannels`, export/public); `composeHostReports` / // `resolveReports` take any host — the articles (`articlesReportHost`: the // whole corpus is citable, D4; the post visibility rule by the build's // audience) into the homepage's public dir. // // What it reads: -// - the site's `reports` (site.json, in order), each report.json parsed and +// - the site's `pages` (site.json, in order), each report.json parsed and // validated by the document's own checker (./reportMedia.ts // loadSiteReports); any problem fails the stage; // - per cited video/audio record: transcript.cues.json when it is fresh, @@ -148,53 +148,19 @@ import { import { publishableStoreExports, storeReportFileSha256, type PublishableReportExports } from "./reportExportFiles"; import { publishReportHistory, readReportHistoryView, reportHistoryRef, storeHistoryGitDir } from "./reportHistory"; import { hostCorpusLink, siteReportHost, type ReportHost } from "./reportHost"; -import { SITE_REPORTS_BASE, reportBaseDir, type ReportBase } from "../lib/report/routes"; import type { ReportHistoryRef, ReportHistoryView } from "../lib/report/revisions"; +import { LEGACY_SITE_REPORTS_DIR, SITE_REPORTS_BASE, reportBaseDir, type ReportBase } from "../lib/report/routes"; -// The public dir's entries this stage owns. Every compose removes them first. -// A host serving under another base owns that base's directory in place of -// `reports` (reportPublicEntries). -export const REPORT_PUBLIC_ENTRIES: readonly string[] = ["reports", "m", "media"]; - -export function reportPublicEntries(base: ReportBase = SITE_REPORTS_BASE): string[] { - return [reportBaseDir(base), "m", "media"]; +// The public dir's entries this stage owns for a host serving its reports +// under `base`: its reports, the moments, the cited media. Every compose +// removes them first — and the dir a site's reports were published under +// before release 26, so an older compose's reports never outlive it. +export function reportPublicEntries(base: ReportBase): string[] { + return [...new Set([reportBaseDir(base), LEGACY_SITE_REPORTS_DIR, "m", "media"])]; } -// THE BASE SHIM. lib/report/views.ts's view builders (buildReportPageView, -// reportIndexEntry) name a site's base for the paths they derive themselves — -// a still, the report's video, the index entry's link. A host serving under -// another base (the homepage's /articles/) has them moved here, until the -// builders take the base themselves (release 26 A5). -function rebased(p: string | undefined, id: string, base: ReportBase): string | undefined { - const from = `${SITE_REPORTS_BASE}${id}/`; - return p !== undefined && p.startsWith(from) ? `${base}${id}/${p.slice(from.length)}` : p; -} - -function rebaseView(view: ReportPageView, base: ReportBase): ReportPageView { - if (base === SITE_REPORTS_BASE) return view; - const citations = Object.fromEntries( - Object.entries(view.citations).map(([k, c]) => - c.kind === "source" && c.image ? [k, { ...c, image: rebased(c.image, view.id, base) }] : [k, c], - ), - ) as ReportPageView["citations"]; - return { - ...view, - citations, - ...(view.video - ? { - video: { - ...view.video, - src: rebased(view.video.src, view.id, base)!, - ...(view.video.poster ? { poster: rebased(view.video.poster, view.id, base) } : {}), - }, - } - : {}), - }; -} - -function rebaseIndexEntry(entry: ReportIndexEntry, base: ReportBase): ReportIndexEntry { - return base === SITE_REPORTS_BASE ? entry : { ...entry, href: rebased(entry.href, entry.id, base)! }; -} +// A site's. +export const REPORT_PUBLIC_ENTRIES: readonly string[] = reportPublicEntries(SITE_REPORTS_BASE); // The transcript lines a moment page shows either side of its span, and at // most how many: bounded context, never the record (plans/report-sites.md, @@ -247,10 +213,20 @@ export type ComposeReportsProblem = { // The kinds `allowMissingMedia` lets through: the page renders without a clip. const MEDIA_PROBLEMS: ReadonlySet<ComposeReportsProblemKind> = new Set(["missing-media", "stale-media"]); +// What a refusal calls the reports it could not compose: a site's pages, or +// the articles. +export function composedReportsNoun(host: Pick<ReportHost, "kind">): string { + return host.kind === "site" ? "the site's pages" : "the articles"; +} + export class ComposeReportsError extends Error { - constructor(readonly problems: ComposeReportsProblem[]) { + constructor( + readonly problems: ComposeReportsProblem[], + // Whose reports: composedReportsNoun(host). + what = "the site's pages", + ) { super( - `the site's reports cannot be composed (${problems.length} problem(s)):\n` + + `${what} cannot be composed (${problems.length} problem(s)):\n` + formatComposeReportsProblems(problems).map((l) => ` ${l}`).join("\n"), ); this.name = "ComposeReportsError"; @@ -717,7 +693,7 @@ export async function resolveReports(opts: ResolveReportsOptions): Promise<Resol const allowed = opts.allowMissingMedia ? problems.filter((p) => MEDIA_PROBLEMS.has(p.kind)) : []; const fatal = problems.filter((p) => !allowed.includes(p)); - if (fatal.length > 0) throw new ComposeReportsError(fatal); + if (fatal.length > 0) throw new ComposeReportsError(fatal, composedReportsNoun(host)); for (const line of formatComposeReportsProblems(allowed)) log(`[reports] allowed (--allow-missing-media): ${line}`); // ─── The views ─── @@ -805,7 +781,7 @@ export async function resolveReports(opts: ResolveReportsOptions): Promise<Resol return entry?.kind === "post" ? `/media/${entry.file}` : undefined; }; const views: ReportPageView[] = reports.map((report) => - rebaseView(buildReportPageView(report, { + buildReportPageView(report, { record: (c) => recordViews.get(c)!, post: (c) => { const post = postsByChannel.get(c.channel)?.get(c.id); @@ -814,13 +790,14 @@ export async function resolveReports(opts: ResolveReportsOptions): Promise<Resol downloads: opts.downloads?.(report.id), history: opts.history?.(report.id), feeds: opts.feeds?.(report.id), - }), host.base), + base: host.base, + }), ); const index: ReportIndexView = { format: REPORT_INDEX_FORMAT, version: REPORT_VIEWS_VERSION, - reports: views.map((v) => rebaseIndexEntry(reportIndexEntry(v), host.base)), + reports: views.map((v) => reportIndexEntry(v, host.base)), }; const moments: MomentPageView[] = []; @@ -920,7 +897,8 @@ export async function composeHostReports(opts: ComposeHostReportsOptions): Promi // Whatever an earlier compose left. rm removes a link, never its target (a // worktree's public/ entries may be links into the primary checkout). - for (const entry of reportPublicEntries(host.base)) { + const base = host.base; + for (const entry of reportPublicEntries(base)) { await rm(path.join(publicDir, entry), { recursive: true, force: true }); } if (host.published.length === 0) { @@ -943,9 +921,9 @@ export async function composeHostReports(opts: ComposeHostReportsOptions): Promi for (const id of host.published) { const gitDir = storeHistoryGitDir(host, id); try { - const view = await readReportHistoryView(gitDir, { reportId: id, siteUrl: host.siteUrl, base: host.base }); + const view = await readReportHistoryView(gitDir, { reportId: id, siteUrl: host.siteUrl, base }); if (!view) continue; - const ref = reportHistoryRef(view, await storeReportFileSha256(host, id), host.base); + const ref = reportHistoryRef(view, await storeReportFileSha256(host, id), base); if (!ref.current) log(`[reports] ${id}: report.json changed since revision ${ref.revision} — export again to commit it`); histories.set(id, { view, ref, gitDir }); } catch (e) { @@ -956,38 +934,34 @@ export async function composeHostReports(opts: ComposeHostReportsOptions): Promi }); } } - if (historyProblems.length > 0) throw new ComposeReportsError(historyProblems); + if (historyProblems.length > 0) throw new ComposeReportsError(historyProblems, composedReportsNoun(host)); // A timeline's feeds link absolutely: a site with no public URL publishes none. const siteUrl = host.siteUrl; const { reports, views, index, moments, mediaOf, cacheDir, allowed } = await resolveReports({ ...opts, history: (id) => histories.get(id)?.ref, - feeds: siteUrl ? (id) => reportFeedUrls(siteUrl, id, host.base) : undefined, + feeds: siteUrl ? (id) => reportFeedUrls(siteUrl, id, base) : undefined, downloads: (id) => ({ ...Object.fromEntries( - REPORT_EXPORT_FORMATS.filter((f) => exportsOf.get(id)?.files[f]).map((f) => [f, reportExportDownloadPath(id, f, host.base)]), + REPORT_EXPORT_FORMATS.filter((f) => exportsOf.get(id)?.files[f]).map((f) => [f, reportExportDownloadPath(id, f, base)]), ), - json: reportCitationsDownloadPath(id, "json", host.base), - csv: reportCitationsDownloadPath(id, "csv", host.base), + json: reportCitationsDownloadPath(id, "json", base), + csv: reportCitationsDownloadPath(id, "csv", base), }), }); // ─── Writing ─── - await writeOut(publicDir, reportsIndexPath(host.base), json(index)); + await writeOut(publicDir, reportsIndexPath(base), json(index)); for (let i = 0; i < reports.length; i++) { const report = reports[i]; const view = views[i]; - await writeOut(publicDir, reportViewPath(report.id, host.base), json(view)); - await writeOut(publicDir, reportCitationsDownloadPath(report.id, "json", host.base), json(citationSet(report, view))); - await writeOut(publicDir, reportCitationsDownloadPath(report.id, "csv", host.base), citationsCsv(view)); + await writeOut(publicDir, reportViewPath(report.id, base), json(view)); + await writeOut(publicDir, reportCitationsDownloadPath(report.id, "json", base), json(citationSet(report, view))); + await writeOut(publicDir, reportCitationsDownloadPath(report.id, "csv", base), citationsCsv(view)); if (siteUrl && view.feeds) { - await writeOut(publicDir, reportFeedPath(report.id, "rss", host.base), renderReportRss(view, { siteUrl, base: host.base })); - await writeOut( - publicDir, - reportFeedPath(report.id, "json", host.base), - json(renderReportJsonFeed(view, { siteUrl, base: host.base })), - ); + await writeOut(publicDir, reportFeedPath(report.id, "rss", base), renderReportRss(view, { siteUrl, base })); + await writeOut(publicDir, reportFeedPath(report.id, "json", base), json(renderReportJsonFeed(view, { siteUrl, base }))); log(`[reports] ${report.id}: feeds of ${view.entries?.length ?? 0} timeline entr${view.entries?.length === 1 ? "y" : "ies"}.`); } if (report.video && view.video) { @@ -1005,11 +979,11 @@ export async function composeHostReports(opts: ComposeHostReportsOptions): Promi const exported = exportsOf.get(report.id)?.files ?? {}; for (const f of REPORT_EXPORT_FORMATS) { const src = exported[f]; - if (src) await copyOut(publicDir, src, reportExportDownloadPath(report.id, f, host.base)); + if (src) await copyOut(publicDir, src, reportExportDownloadPath(report.id, f, base)); } const history = histories.get(report.id); if (history) { - const files = await publishReportHistory({ gitDir: history.gitDir, publicDir, view: history.view, base: host.base }); + const files = await publishReportHistory({ gitDir: history.gitDir, publicDir, view: history.view, base }); log(`[reports] ${report.id}: revision ${history.ref.revision}, history published (${files.length} repository files).`); } } @@ -1055,8 +1029,9 @@ function postAuthor(post: Post): string { const defined = <T extends object>(o: T): T => Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined)) as T; -// The site-root routes the reports add to a sitemap: the index, each report -// (and its history page, when it has one), each moment page. +// The site-root routes the reports add to a sitemap: each page (and its +// history page, when it has one), each moment page. A site has no index of +// its pages (its header links each one); a host under another base names it. export function reportRoutes( composed: Pick<ComposedReports, "reports" | "moments" | "histories">, base: ReportBase = SITE_REPORTS_BASE, @@ -1064,7 +1039,6 @@ export function reportRoutes( if (composed.reports.length === 0) return []; const histories = new Set(composed.histories ?? []); return [ - base, ...composed.reports.flatMap((r) => (histories.has(r.id) ? [r.href, reportHistoryPagePath(r.id, base)] : [r.href])), ...composed.moments.map((k) => momentPath(k)), ]; diff --git a/common/publish/composeReportsArticles.test.ts b/common/publish/composeReportsArticles.test.ts @@ -179,29 +179,32 @@ test("a private build: every published article in index.json's order, any corpus const composed = await composeHostReports({ paths, host, publicDir: OUT, settings: X_PRIVATE, ...quiet }); assert.deepEqual(composed.reports.map((r) => r.id), ["art-priv", "art-pub"]); assert.deepEqual(composed.moments, [`${LONE}/abc123/10.00-20.00`, `${X}/1800`]); - // Served under the homepage's base, /articles/: its files and its links. - const index = readJson<{ reports: { id: string; href: string }[] }>(path.join(OUT, "articles", "index.json")); - assert.deepEqual(index.reports.map((r) => [r.id, r.href]), [ - ["art-priv", "/articles/art-priv/"], - ["art-pub", "/articles/art-pub/"], - ]); - const page = readJson<{ downloads?: { json?: string } }>(path.join(OUT, "articles", "art-pub", "page.json")); - assert.equal(page.downloads?.json, "/articles/art-pub/citations.json"); - assert.equal(existsSync(path.join(OUT, "reports")), false); + const index = readJson<{ reports: { id: string }[] }>(path.join(OUT, "articles", "index.json")); + assert.deepEqual(index.reports.map((r) => r.id), ["art-priv", "art-pub"]); + // Served under the homepage's base: every href and published path is /articles/. + const page = readJson<{ id: string }>(path.join(OUT, "articles", "art-priv", "page.json")); + assert.equal(page.id, "art-priv"); + assert.deepEqual( + readJson<{ reports: { href: string }[] }>(path.join(OUT, "articles", "index.json")).reports.map((r) => r.href), + ["/articles/art-priv/", "/articles/art-pub/"], + ); + assert.ok( + readJson<{ citedIn: { href: string }[] }>(path.join(OUT, "m", LONE, "abc123", "10.00-20.00", "moment.json")).citedIn.every((e) => + e.href.startsWith("/articles/"), + ), + ); + assert.equal(existsSync(path.join(OUT, "pages")), false); assert.ok(existsSync(path.join(OUT, "media", "clips", LONE, "abc123", "10.00-20.00.mp4"))); assert.ok(existsSync(path.join(OUT, "media", "posts", X, "1800", "shot.png"))); // The draft is not published. assert.equal(existsSync(path.join(OUT, "articles", "art-draft")), false); // No archive named for the channel: the record links nowhere. - const moment = readJson<{ record: { corpusUrl?: string }; citedIn: { href: string }[] }>( - path.join(OUT, "m", LONE, "abc123", "10.00-20.00", "moment.json"), - ); + const moment = readJson<{ record: { corpusUrl?: string } }>(path.join(OUT, "m", LONE, "abc123", "10.00-20.00", "moment.json")); assert.equal(moment.record.corpusUrl, undefined); - assert.match(moment.citedIn[0].href, /^\/articles\/art-pub\//); // Feeds and history use the homepage's base (PROJECT_URL by default). assert.equal(host.siteUrl, "https://archilyzer.pages.dev"); // export/public is not this stage's output root here. - assert.equal(existsSync(path.join(paths.exportPublicDir, "reports")), false); + assert.equal(existsSync(path.join(paths.exportPublicDir, "articles")), false); }); test("a public build: only public articles; a record links into the listed site that publishes its channel", async () => { diff --git a/common/publish/reportExports.ts b/common/publish/reportExports.ts @@ -79,10 +79,12 @@ import { resolveAccent } from "../lib/accent"; import { REPORT_EXPORT_FILENAMES, REPORT_EXPORT_FORMATS, + reportPagePath, type ReportExportFormat, type ReportPageView, type SpanCitationView, } from "../lib/report/views"; +import type { ReportBase } from "../lib/report/routes"; import { importPlaywright } from "../social/playwrightRuntime"; import { citationSet, @@ -106,7 +108,6 @@ import { import type { ReportMediaIndex } from "./reportMedia"; import { storeReportDir, storeReportFile } from "../lib/report/store"; import { siteReportHost, type ReportHost } from "./reportHost"; -import { isReportBase } from "../lib/report/routes"; import { commitReportRevision, pendingRevision, @@ -321,7 +322,7 @@ function within(base: string, rel: string): string | undefined { } function reportFiles(host: ReportHost, view: ReportPageView, resolved: ResolvedSiteReports): ReportFiles { - const own = `${host.base}${view.id}/`; + const own = reportPagePath(view.id, host.base); return { local: (p) => { if (p.startsWith(own)) return within(storeReportDir(host, view.id), p.slice(own.length)); @@ -340,13 +341,9 @@ function reportFiles(host: ReportHost, view: ReportPageView, resolved: ResolvedS // A site-root path's place in the evidence pack: the site's media under // media/, the report's own files (its stills) under media/report/. -function packPathOf(view: ReportPageView, sitePath: string): string | undefined { - // The report's own files are under its base (a site's /reports/, the - // homepage's /articles/): `<base><id>/…`. - const at = sitePath.indexOf(`/${view.id}/`); - if (at >= 0 && isReportBase(sitePath.slice(0, at + 1))) { - return `media/report/${sitePath.slice(at + view.id.length + 2)}`; - } +function packPathOf(view: ReportPageView, sitePath: string, base?: ReportBase): string | undefined { + const own = reportPagePath(view.id, base); + if (sitePath.startsWith(own)) return `media/report/${sitePath.slice(own.length)}`; if (sitePath.startsWith("/media/")) return sitePath.slice(1); return undefined; } @@ -380,7 +377,7 @@ async function buildEvidencePack(o: { report: Report; view: ReportPageView; files: ReportFiles; - site: Pick<Site, "siteId" | "siteUrl">; + site: Pick<Site, "siteId" | "siteUrl"> & { base?: ReportBase }; footer: ReportExportFooter; markdown: string; outFile: string; @@ -401,7 +398,7 @@ async function buildEvidencePack(o: { const images = new Map<string, string>(); for (const p of [...viewImagePaths(o.view), ...(o.slides ? slidesOnlyImagePaths(o.view) : [])]) { const local = o.files.local(p); - const rel = packPathOf(o.view, p); + const rel = packPathOf(o.view, p, o.site.base); if (!local || !rel) continue; const data = await readFile(local).catch(() => null); if (!data) continue; @@ -413,7 +410,7 @@ async function buildEvidencePack(o: { if (c.kind !== "video" && c.kind !== "audio") continue; const clip = o.files.clip(c); if (!clip || clips.has(c.moment)) continue; - const rel = packPathOf(o.view, clip.sitePath); + const rel = packPathOf(o.view, clip.sitePath, o.site.base); const data = rel ? await readFile(clip.file).catch(() => null) : null; if (!rel || !data) continue; await put(rel, data); @@ -421,6 +418,7 @@ async function buildEvidencePack(o: { } const html = reportExportHtml(o.view, { siteUrl: o.site.siteUrl || undefined, + base: o.site.base, footer: o.footer, image: (p) => images.get(p), clip: (c) => clips.get(c.moment), @@ -432,6 +430,7 @@ async function buildEvidencePack(o: { reportSlidesHtml(o.view, { ...o.slides, siteUrl: o.site.siteUrl || undefined, + base: o.site.base, footer: o.footer, image: (p) => images.get(p), }), @@ -468,7 +467,7 @@ async function exportOneReport(o: { if (!reportJson) return { problems: [{ report: report.id, message: "its report.json cannot be read" }] }; return writeReportExports({ ...o, - site: { siteId: host.id, siteUrl: host.siteUrl, siteTitle: host.title, accent: host.accent }, + site: { siteId: host.id, siteUrl: host.siteUrl, siteTitle: host.title, accent: host.accent, base: host.base }, dir: storeExportDir(host, report.id), reportSha256: sha256Hex(reportJson), files: reportFiles(host, view, o.resolved), @@ -487,7 +486,9 @@ async function exportOneReport(o: { // changed report.json is committed as the next one. export async function writeReportExports(o: { dir: string; - site: Pick<Site, "siteId" | "siteUrl" | "siteTitle"> & { accent?: unknown }; + // `base`: where the build serves these reports (lib/report/routes.ts); a + // site's by default. + site: Pick<Site, "siteId" | "siteUrl" | "siteTitle"> & { accent?: unknown; base?: ReportBase }; report: Report; view: ReportPageView; reportSha256: string; @@ -528,6 +529,7 @@ export async function writeReportExports(o: { } const htmlOpts = { siteUrl, + base: site.base, footer, image: (p: string) => dataUris.get(p), clip: (c: SpanCitationView) => { @@ -551,12 +553,12 @@ export async function writeReportExports(o: { } } const slidesHtml = slidesLook - ? reportSlidesHtml(view, { ...slidesLook, siteUrl, footer, image: (p) => dataUris.get(p) }) + ? reportSlidesHtml(view, { ...slidesLook, siteUrl, base: site.base, footer, image: (p) => dataUris.get(p) }) : undefined; // The PDF prints what the page folds away (the evidence the document under // review gave itself) open. const printHtml = reportExportHtml(view, { ...htmlOpts, print: true }); - const markdown = reportExportMarkdown(view, { siteUrl, footer }); + const markdown = reportExportMarkdown(view, { siteUrl, base: site.base, footer }); const dir = o.dir; await rm(dir, { recursive: true, force: true }); diff --git a/common/publish/reportHistory.test.ts b/common/publish/reportHistory.test.ts @@ -166,7 +166,7 @@ test("the history view: each revision's hashes, summary and claim diff; the page const r2 = await commit(gitDir, reportJson({ text: "The bridge opened in 2019." }), "2026-03-08T12:00:00Z"); const view = await readReportHistoryView(gitDir, { reportId: "demo", siteUrl: "https://reports.example.org/" }); assert.ok(view); - assert.equal(view.clone, "https://reports.example.org/reports/demo/history/repo"); + assert.equal(view.clone, "https://reports.example.org/pages/demo/history/repo"); assert.deepEqual( view.revisions.map((r) => [r.revision, r.commit, r.reportSha256, r.date]), [ @@ -184,12 +184,12 @@ test("the history view: each revision's hashes, summary and claim diff; the page assert.deepEqual(reportHistoryRef(view, r2.reportSha256), { revision: 2, date: "2026-03-08T12:00:00Z", - href: "/reports/demo/history/", + href: "/pages/demo/history/", current: true, }); assert.equal(reportHistoryRef(view, sha("edited")).current, false); const relative = await readReportHistoryView(gitDir, { reportId: "demo" }); - assert.equal(relative?.clone, "/reports/demo/history/repo"); + assert.equal(relative?.clone, "/pages/demo/history/repo"); assert.equal(await readReportHistoryView(path.join(ROOT, "none"), { reportId: "demo" }), null); }); @@ -215,7 +215,7 @@ test("the published clone: an allowlisted dumb-HTTP repository that clones over for (const f of files) assert.match(f, REPORT_HISTORY_REPO_FILE_RE); assert.ok(files.includes("info/refs") && files.includes("objects/info/packs")); assert.ok(files.some((f) => f.endsWith(".pack"))); - const published = JSON.parse(readFileSync(path.join(publicDir, "reports", "demo", "history", "history.json"), "utf8")); + const published = JSON.parse(readFileSync(path.join(publicDir, "pages", "demo", "history", "history.json"), "utf8")); assert.deepEqual(published, view); const port = await freePort(); @@ -232,7 +232,7 @@ test("the published clone: an allowlisted dumb-HTTP repository that clones over }); }); const dest = path.join(ROOT, "clone", "cloned"); - execFileSync("git", ["clone", "--quiet", `http://127.0.0.1:${port}/reports/demo/history/repo`, dest], { + execFileSync("git", ["clone", "--quiet", `http://127.0.0.1:${port}/pages/demo/history/repo`, dest], { env: historyGitEnv(), stdio: "pipe", }); diff --git a/common/publish/reportHistory.ts b/common/publish/reportHistory.ts @@ -68,12 +68,12 @@ import { type ReportHistoryView, type ReportRevisionView, } from "../lib/report/revisions"; +import { SITE_REPORTS_BASE, type ReportBase } from "../lib/report/routes"; import { cleanGitEnv } from "./sourceAudit"; export { REPORT_HISTORY_REPO_FILE_RE }; import { siteReportDir } from "./reportMedia"; import { storeReportDir, type ReportStore } from "../lib/report/store"; -import type { ReportBase } from "../lib/report/routes"; export const REPORT_HISTORY_GIT_DIRNAME = "history-git"; export const REVISION_EXPORTS_FILENAME = "exports.json"; @@ -360,6 +360,8 @@ function emptyReport(like: Report): Report { // no revisions. `clone` is what `git clone` takes. export async function readReportHistoryView( gitDir: string, + // `base`: where the build serves its reports (lib/report/routes.ts); a + // site's by default. o: { reportId: string; siteUrl?: string; base?: ReportBase }, ): Promise<ReportHistoryView | null> { const stored = await readStoredRevisions(gitDir); @@ -399,7 +401,7 @@ export async function readReportHistoryView( export function reportHistoryRef( view: ReportHistoryView, currentSha256: string | null, - base?: ReportBase, + base: ReportBase = SITE_REPORTS_BASE, ): ReportHistoryRef { const last = view.revisions[view.revisions.length - 1]; return { @@ -462,7 +464,7 @@ export async function stageReportHistoryRepo(gitDir: string, destDir: string): P } // Publish a report's history under `publicDir`: history.json and the clone, -// at `<base><id>/history/` (`reports/<id>/history/` for a site). Answers the +// at `<base><id>/history/` (a site's `pages/<id>/history/`). Answers the // clone's files. export async function publishReportHistory(o: { gitDir: string; diff --git a/common/publish/reportHost.ts b/common/publish/reportHost.ts @@ -6,7 +6,7 @@ // // a SITE (its pages) the ARTICLES (the homepage) // files sites/<id>/reports/<r>/ reports/<r>/ -// published site.json `reports` reports/index.json, narrowed +// published site.json `pages` reports/index.json, narrowed // to `audience: "public"` for a // public build // may cite its `channels` + `citedChannels` any channel in the corpus (D4) @@ -15,6 +15,7 @@ // corpus link its own corpus, relative (none the listed public site that // on a cited site or for a publishes the channel, // cited-only channel) absolute; none without one +// served under /pages/<r>/ /articles/<r>/ // staging .export-index/sites/<id>/ .export-index/articles/ // history identity the site's title, PROJECT_NAME, // noreply@<id>.invalid noreply@articles.invalid @@ -36,14 +37,14 @@ import { type Site, } from "../lib/siteSchema"; import { publishedArticleIds } from "../lib/report/registry"; +import { ARTICLES_REPORTS_BASE, SITE_REPORTS_BASE, type ReportBase } from "../lib/report/routes"; import { isReportId, type ReportAudience } from "../lib/report/schema"; -import { ARTICLES_BASE, SITE_REPORTS_BASE, type ReportBase } from "../lib/report/routes"; import { articleReportStore, siteReportStore, storeReportFile, type ReportStore } from "../lib/report/store"; export type ReportHost = ReportStore & { // Where the build serves these reports (lib/report/routes.ts): a site's - // SITE_REPORTS_BASE, the homepage's ARTICLES_BASE. Every path compose - // writes and every link it builds hangs off it. + // `/pages/`, the homepage's `/articles/`. Every published path and href of + // theirs hangs off it. base: ReportBase; // A history commit's author (./reportHistory.ts) and an export's heading. title: string; @@ -78,7 +79,7 @@ export function siteReportHost(paths: Pick<Paths, "sitesDir" | "exportSitesIndex siteUrl: parseSiteUrl(site.siteUrl), accent: site.accent, audience: isPrivateSite(site) ? "private" : "public", - published: site.reports ?? [], + published: site.pages ?? [], listedBy: (id) => `the site lists report "${id}"`, citableProblem: (slug) => (citable.has(slug) ? null : notInSiteMessage(slug)), // No corpus page to link a moment to: a cited site publishes none, and a @@ -116,7 +117,7 @@ export async function articlesReportHost( const isChannel = new Map<string, boolean>(); return { ...articleReportStore(paths), - base: ARTICLES_BASE, + base: ARTICLES_REPORTS_BASE, title: PROJECT_NAME, siteUrl: opts.siteUrl === null ? undefined : (parseSiteUrl(opts.siteUrl ?? PROJECT_URL) ?? undefined), audience, diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## [Unreleased] +- **A site's reports are its pages.** site.json `reports` is now `pages` (a file that still says `reports` reads as `pages` for this release; saving writes `pages`). Each page is served at `/pages/<id>/` and linked from the site's header by its title, after Ask AI; there is no Reports index any more. A site with search off shows its first page as its home, and saving a site with search off and no pages is refused. The site form lists them as **Pages**. Rebuild each site that has pages. +- **Site ids `articles` and `new` are refused.** The editor's `/sites/articles` and `/sites/new` (and umtool's `articles/`) would hide a site of either name, so a save under one is refused, naming why. - **Orpheus 3B narrates too, on the GPU.** `pnpm ops tts` takes `"engine": "orpheus"` — Orpheus 3B with one of its eight stock speakers (`leah` by default, `zac` the male option, then tara, jess, leo, dan, mia, zoe), which performs the expressive tags (`<laugh>`, `<sigh>`, …) instead of dropping them. It runs on a local llama-server the editor starts for a batch of syntheses — after waiting for the machine's heavy slot and for any transcription on the GPU to finish — and stops once nothing more is queued, so its 4–5 GB of video memory is freed; the server's binary, libraries, port and GPU layers are `settings.tts.orpheus` (Ollama's bundled Vulkan build by default). Each chunk of 1–3 sentences gets up to three takes and the first that passes the checks is kept (it ended, no broken frames, a sane pace, no dead air); a chunk where none passes is kept anyway and flagged in the job's log and the sidecar. Its disclosure line ends "Built with Llama", as its licence (Llama 3.2 Community License + Apache-2.0) asks. About 1.8× slower than real time. `archilyzer tts setup --engine orpheus [--from <dir>]` installs it (3.5 GB of model). Needs a restart of the editor. - **Narration reads numbers, money, dates and links the way they are said, with Kokoro too.** "3,812" is "three thousand eight hundred twelve", "$12.50" "twelve dollars and fifty cents", "March 14th" "March fourteenth", "3:45" "three forty-five", "45%" "forty-five percent", a link its spoken host ("example dot com"), "Dr." "Doctor", "@name" "at name"; years are read as before. A synthesis made before this is made again the next time it is asked for. - **Narration in a local synthetic voice, as a job.** `pnpm ops tts` (`POST /api/ops/tts`) speaks a line — `{"text"}`, or `{"file"}` an absolute path to a UTF-8 text file, at most 20,000 characters — with a local text-to-speech engine and one of its stock voices, as a `tts-file` job on its own `tts` queue, one synthesis at a time. The default is Kokoro-82M with the voice `af_heart` (`settings.tts`: `engine`, `voice`, `speed`, `home`, `dir`; SETTINGS.md); `"engine": "espeak-ng"` needs no install. Years are read as they are said ("twenty twenty-four"); the expressive tags `<laugh>` `<chuckle>` `<sigh>` `<cough>` `<sniffle>` `<groan>` `<yawn>` `<gasp>` are dropped for an engine that cannot perform them, and any other `<…>` is refused, named, so a typo is never read aloud. The result — `{wav, seconds, engine, voice, cached, durationMs, waitedMs, sha, sampleRate, speed, disclosure}`, printed by `--wait` — names a 48 kHz mono WAV in the synthesis cache (`<repo>/.tts/cache` by default, never inside the corpus), or the `"out"` path it was copied to, with a sidecar beside it that marks it a synthetic voice; `disclosure` is the line a narrated export carries ("Narration: synthetic voice (Kokoro-82M · af_heart)"). The same words with the same voice and speed again are answered from the cache at once, with no engine run. There is no voice cloning and no reference audio: a voice is a name from the engine's list. Needs a restart of the editor. diff --git a/editor/app/sites/[siteId]/reports/page.tsx b/editor/app/sites/[siteId]/reports/page.tsx @@ -32,7 +32,7 @@ export const dynamic = "force-dynamic"; export const metadata: Metadata = { title: "Reports" }; // A SITE'S REPORTS: every report directory under `sites/<siteId>/reports/`, -// whether the site publishes it (site.json `reports`, in order) or it is a +// whether the site publishes it (site.json `pages`, in order) or it is a // draft, and what is wrong with it — the report's own checker, so this lists // what prepare and the build would refuse. Publish, unpublish and reorder write // that one key (lib/reportsActions.ts). The evidence media the published diff --git a/editor/app/sites/actions.ts b/editor/app/sites/actions.ts @@ -15,6 +15,7 @@ import { writeSite, deleteSite, isValidSiteId, + reservedSiteIdProblem, parseRelatedSites, parseSiteChannels, parseSiteUrl, @@ -51,6 +52,10 @@ export async function saveSiteAction( values, }; } + // `articles` and `new` are the editor's own /sites/ routes (writeSite refuses + // them too): said here, before anything else is read. + const reserved = reservedSiteIdProblem(siteId); + if (reserved) return { ok: false, error: reserved, values }; const siteTitle = String(formData.get("siteTitle") ?? "").trim(); const headerTitle = String(formData.get("headerTitle") ?? "").trim(); if (!siteTitle) { @@ -127,9 +132,9 @@ export async function saveSiteAction( return { ok: false, error: `Unknown publish policy "${publishAutoRaw}".`, values }; } const publishAuto = publishAutoRaw as PublishPolicy; - // Search (opt-out; off = report-only) and the report list, which is not on + // Search (opt-out; off = pages only) and the page list, which is not on // this form: the stored one is carried over. - let storedReports: Pick<Site, "reports"> | undefined; + let storedReports: Pick<Site, "pages"> | undefined; try { storedReports = getSite(siteId, getPaths()); } catch { diff --git a/editor/app/sites/components/ReportRowActions.tsx b/editor/app/sites/components/ReportRowActions.tsx @@ -9,7 +9,7 @@ import { } from "../lib/reportsActions"; // One report's buttons on the Reports tab: Publish for a draft; Up, Down and -// Unpublish for a published report. Each is one write of site.json `reports` +// Unpublish for a published report. Each is one write of site.json `pages` // (lib/reportsActions.ts); the action revalidates the tab, which re-renders // with the list as written. export function ReportRowActions({ diff --git a/editor/app/sites/components/SiteForm.tsx b/editor/app/sites/components/SiteForm.tsx @@ -416,16 +416,16 @@ export function SiteForm({ initial, channels, allSites, isNew }: Props) { Search </label> <p className="-mt-2 text-xs text-muted-foreground"> - Off: the site is its reports only. + Off: the site is its pages only, and needs at least one. </p> <div className="flex flex-col gap-1 text-sm"> - <span className="font-medium">Reports</span> - {initial.reports && initial.reports.length > 0 ? ( + <span className="font-medium">Pages</span> + {initial.pages && initial.pages.length > 0 ? ( <ol - aria-label="Published reports" + aria-label="Published pages" className="list-decimal pl-6 font-mono text-xs" > - {initial.reports.map((id) => ( + {initial.pages.map((id) => ( <li key={id}>{id}</li> ))} </ol> @@ -433,9 +433,10 @@ export function SiteForm({ initial, channels, allSites, isNew }: Props) { <span className="text-xs text-muted-foreground">None</span> )} <span className="text-xs text-muted-foreground"> - The published reports, in order (report ids under this site's - reports/ directory). Not edited here: saving this form keeps the list - as it is. + The site's pages, in order (report ids under this site's + reports/ directory), each at /pages/<id>/ and linked from the + header by its title. Not edited here: saving this form keeps the + list as it is. {!isNew && ( <> {" "}Publish, unpublish and reorder them on the{" "} diff --git a/editor/app/sites/lib/reportList.ts b/editor/app/sites/lib/reportList.ts @@ -36,7 +36,7 @@ export type ReportRowStatus = "ok" | "problems" | "invalid" | "missing"; export type ReportRow = { id: string; - // Its place in the site's published list (site.json `reports`), or null for + // Its place in the site's published list (site.json `pages`), or null for // a draft. position: number | null; status: ReportRowStatus; diff --git a/editor/app/sites/lib/reportListServer.ts b/editor/app/sites/lib/reportListServer.ts @@ -17,7 +17,7 @@ import { reportRows, type ReportFileRead, type ReportRow } from "./reportList"; // Every report of the site, published (in order) then drafts, each read and // validated. export async function readSiteReportRows(paths: Paths, site: Site): Promise<ReportRow[]> { - const published = site.reports ?? []; + const published = site.pages ?? []; const dirIds = await listReportDirs(paths, site.siteId); const ids = [...new Set([...published, ...dirIds])]; const reads = new Map<string, ReportFileRead>( @@ -60,7 +60,7 @@ export type ReportExportsRow = { export async function readSiteReportExports(paths: Paths, site: Site): Promise<ReportExportsRow[]> { return Promise.all( - (site.reports ?? []).map(async (reportId) => ({ + (site.pages ?? []).map(async (reportId) => ({ reportId, manifest: await readReportExportManifest(paths, site.siteId, reportId), publishable: await publishableReportExports(paths, site.siteId, reportId), diff --git a/editor/app/sites/lib/reportSiteKeys.test.ts b/editor/app/sites/lib/reportSiteKeys.test.ts @@ -17,15 +17,15 @@ test("search checked writes no key; unchecked (no field) writes search: false", assert.deepEqual(reportSiteKeysFromForm(form({ search: "on", publish: "cited" }), undefined), {}); }); -test("the stored report list is carried over in order; the form cannot set it", () => { - const stored = { reports: ["second", "first"] }; +test("the stored page list is carried over in order; the form cannot set it", () => { + const stored = { pages: ["second", "first"] }; assert.deepEqual( - reportSiteKeysFromForm(form({ search: "on", reports: "injected" }), stored), - { reports: ["second", "first"] }, + reportSiteKeysFromForm(form({ search: "on", pages: "injected" }), stored), + { pages: ["second", "first"] }, ); // An empty or missing stored list writes no key; a bad stored id is dropped. - assert.deepEqual(reportSiteKeysFromForm(form({ search: "on" }), { reports: [] }), {}); - assert.deepEqual(reportSiteKeysFromForm(form({ search: "on" }), { reports: ["ok", "NOT OK"] }), { - reports: ["ok"], + assert.deepEqual(reportSiteKeysFromForm(form({ search: "on" }), { pages: [] }), {}); + assert.deepEqual(reportSiteKeysFromForm(form({ search: "on" }), { pages: ["ok", "NOT OK"] }), { + pages: ["ok"], }); }); diff --git a/editor/app/sites/lib/reportSiteKeys.ts b/editor/app/sites/lib/reportSiteKeys.ts @@ -1,23 +1,24 @@ -// The site form's two report-site keys (site.json `search` and `reports`), +// The site form's two report-site keys (site.json `search` and `pages`), // pure so the parse is tested without a server (saveSiteAction calls it). // // `search` is the form's checkbox, opt-out like `archives`: an unchecked box -// sends no field and is written as `search: false` (report-only). A legacy +// sends no field and is written as `search: false` (pages only). A legacy // `publish: "cited"` read from the file is never written back. -// `reports` is NOT edited by this form (the site's Reports tab manages it): the +// `pages` is NOT edited by this form (the site's Reports tab manages it): the // Site is rebuilt from the form on save, so the list already stored is carried -// over, and saving any other field never drops a published report. +// over, and saving any other field never drops a published page. A search-off +// site with no pages is refused by writeSite (siteSearchProblem). import { parseSiteReports, type Site } from "yt-dlp-transcript-common/lib/site"; export function reportSiteKeysFromForm( formData: FormData, - stored: Pick<Site, "reports"> | undefined, -): Pick<Site, "search" | "reports"> { + stored: Pick<Site, "pages"> | undefined, +): Pick<Site, "search" | "pages"> { const search = formData.get("search") === "on"; - const reports = parseSiteReports(stored?.reports); + const pages = parseSiteReports(stored?.pages); return { ...(search ? {} : { search: false }), - ...(reports.length > 0 ? { reports } : {}), + ...(pages.length > 0 ? { pages } : {}), }; } diff --git a/editor/app/sites/lib/reportsActions.ts b/editor/app/sites/lib/reportsActions.ts @@ -14,7 +14,7 @@ import { withReportUnpublished, } from "./reportList"; -// THE REPORTS TAB'S WRITES: site.json `reports`, the site's published list. +// THE REPORTS TAB'S WRITES: site.json `pages`, the site's published list. // Each goes through patchSite, which reads the site inside the file lock and // applies the edit to the list as it is THEN — never a list the tab read // earlier — and writes the rest of the site back untouched. @@ -28,7 +28,7 @@ async function editReports(siteId: string, reportId: string, edit: Edit): Promis if (!isReportId(reportId)) return { ok: false, error: `"${reportId}" is not a valid report id` }; let written; try { - written = await patchSite(siteId, (current) => ({ reports: edit(current.reports ?? []) }), getPaths()); + written = await patchSite(siteId, (current) => ({ pages: edit(current.pages ?? []) }), getPaths()); } catch (err) { return { ok: false, error: err instanceof Error ? err.message : String(err) }; } diff --git a/editor/e2e/helpers.ts b/editor/e2e/helpers.ts @@ -180,6 +180,9 @@ export async function writeSite( ...(site.audience !== undefined ? { audience: site.audience } : {}), // The legacy report-only key, written as given (siteSchema migrates it). ...(site.publish !== undefined ? { publish: site.publish } : {}), + ...(site.pages !== undefined ? { pages: site.pages } : {}), + // The pre-release-26 page list, written as given (siteSchema reads it as `pages`). + ...(site.reports !== undefined ? { reports: site.reports } : {}), ...(site.relatedSites ? { relatedSites: site.relatedSites } : {}), }; await writeFile( diff --git a/editor/e2e/sites-crud.spec.ts b/editor/e2e/sites-crud.spec.ts @@ -388,13 +388,15 @@ test("archives + per-video transcript downloads opt-outs round-trip", async ({ await expect(downloads).toBeChecked(); }); -test("the search switch round-trips; a legacy publish: cited reads as off and saves as search: false", async ({ +test("the search switch round-trips; a legacy publish: cited reads as off and saves as search: false; legacy reports saves as pages", async ({ page, }) => { await resetData("empty"); - await writeSite("reportonly", { siteTitle: "Report Only", publish: "cited" }); + // A search-off site needs a page (release 26 A5): the legacy `reports` key + // reads as `pages`, and a save writes `pages`. + await writeSite("reportonly", { siteTitle: "Report Only", publish: "cited", reports: ["demo-page"] }); - type SearchSiteFile = { search?: boolean; publish?: string }; + type SearchSiteFile = { search?: boolean; publish?: string; pages?: string[]; reports?: string[] }; const file = `${testPaths().transcriptsDir}/sites/reportonly/site.json`; const search = page.getByRole("checkbox", { name: "Search", exact: true }); const save = async () => { @@ -412,7 +414,10 @@ test("the search switch round-trips; a legacy publish: cited reads as off and sa const site = await readJson<SearchSiteFile>(file); expect(site.search).toBe(false); expect("publish" in site).toBe(false); + expect(site.pages).toEqual(["demo-page"]); + expect("reports" in site).toBe(false); }).toPass({ timeout: 10_000 }); + await expect(page.getByRole("list", { name: "Published pages" }).getByRole("listitem")).toHaveText(["demo-page"]); await page.goto("/sites/reportonly/reports"); await expect(page.getByText("Reports only — search is off")).toBeVisible(); @@ -432,6 +437,20 @@ test("the search switch round-trips; a legacy publish: cited reads as off and sa await expect(page.getByText("Full archive — search is on")).toBeVisible(); }); + +test("a site with search off and no pages is refused on save", async ({ page }) => { + await resetData("empty"); + await writeSite("nopages", { siteTitle: "No Pages" }); + const file = `${testPaths().transcriptsDir}/sites/nopages/site.json`; + await page.goto("/sites/nopages"); + await page.getByRole("checkbox", { name: "Search", exact: true }).uncheck(); + await page.getByRole("button", { name: /save site/i }).click(); + // Filtered: Next's route announcer is a second (empty) role=alert. + await expect( + page.getByRole("alert").filter({ hasText: /search is off and the site has no pages/i }), + ).toBeVisible(); + expect("search" in (await readJson<{ search?: boolean }>(file))).toBe(false); +}); test("the listed opt-out round-trips, and a save of another field keeps it", async ({ page, }) => { diff --git a/export/app/(workspace)/page.tsx b/export/app/(workspace)/page.tsx @@ -2,19 +2,19 @@ import type { Metadata } from "next"; import { isCitedSite } from "yt-dlp-transcript-common/lib/siteSchema"; import { currentSite } from "../lib/site"; import { instanceMode } from "../lib/mode"; -import { REPORTS_BASE, onlyReportView, readReportIndex, reportMetadata } from "../lib/reports"; +import { REPORTS_BASE, firstReportView, reportMetadata } from "../lib/reports"; import NewSinceLastVisit from "../components/NewSinceLastVisit"; import HubHome from "../components/hub/HubHome"; -import ReportIndex from "yt-dlp-transcript-common/components/report/ReportIndex"; import ReportArticle from "yt-dlp-transcript-common/components/report/ReportArticle"; +import { EmptyState } from "yt-dlp-transcript-common/components/report/parts"; -// A cited site with one report: the home page IS the report, so its tab names -// the report as the report's own page does. Every other home keeps the -// layout's default title (the site's). +// A search-off site: the home page IS its first page, so its tab names the +// page as the page's own route does. Every other home keeps the layout's +// default title (the site's). export function generateMetadata(): Metadata { if (instanceMode() === "hub" || !isCitedSite(currentSite())) return {}; - const only = onlyReportView(); - return only ? reportMetadata(only) : {}; + const first = firstReportView(); + return first ? reportMetadata(first) : {}; } export default async function Home() { @@ -27,18 +27,21 @@ export default async function Home() { } const settings = currentSite(); - // A cited site publishes only its reports and their moments: its home is the - // report index (a static export has no redirect to send it there), and it - // has no summaries manifest, so countTranscripts() — which throws without - // one — is never reached: its module is not even loaded on this path. - // - // With ONE published report the home page IS that report (the header then - // links nothing: there is nowhere else to go). With more, the index -- no - // heading of its own: the header already names the site. + // A search-off site publishes only its pages and their moments: its home + // page IS its first page (the header links every page by its title, and + // links nothing when there is one: there is nowhere else to go). It has no + // summaries manifest, so countTranscripts() — which throws without one — is + // never reached: its module is not even loaded on this path. A search-off + // site with no page is refused on save (siteSearchProblem); one built + // anyway says so. if (isCitedSite(settings)) { - const only = onlyReportView(); - if (only) return <ReportArticle view={only} base={REPORTS_BASE} />; - return <ReportIndex index={readReportIndex()} heading={null} tagline={settings.homeTagline} />; + const first = firstReportView(); + if (first) return <ReportArticle view={first} base={REPORTS_BASE} />; + return ( + <EmptyState title="No pages"> + This site has not published a page yet. + </EmptyState> + ); } const { countTranscripts } = await import("yt-dlp-transcript-common/lib/transcripts"); const count = await countTranscripts(); diff --git a/export/app/components/Header.tsx b/export/app/components/Header.tsx @@ -14,7 +14,7 @@ import { headerMarkPalette } from "../lib/brand"; import { instanceMode } from "../lib/mode"; import { hasArchives } from "../lib/archives"; import { hasDuplicates } from "../lib/duplicates"; -import { hasReports, reportIds } from "../lib/reports"; +import { pageLinks } from "../lib/reports"; import { headerNavLinks } from "../lib/nav"; import { isCitedSite } from "yt-dlp-transcript-common/lib/siteSchema"; import MobileMenu from "./MobileMenu"; @@ -83,8 +83,7 @@ export default function Header() { const cited = isSite && isCitedSite(site); const navLinks = headerNavLinks({ cited, - singleReport: cited && reportIds().length === 1, - reports: isSite && hasReports(), + pages: isSite ? pageLinks() : [], duplicates: !cited && hasDuplicates(), downloads: !cited && hasArchives(), }); diff --git a/export/app/components/NotOnCitedSite.tsx b/export/app/components/NotOnCitedSite.tsx @@ -1,19 +1,17 @@ import Link from "next/link"; import { EmptyState, textLink } from "yt-dlp-transcript-common/components/report/parts"; -import { reportIds } from "../lib/reports"; // What a corpus-shaped route (search's chat, downloads, duplicates, offline) -// renders on a CITED site, which publishes only its reports and their moments. -// The route still exists in the static build (every route does); it shows -// nothing of the corpus and points at the home page -- the index, or the one -// report. +// renders on a CITED site (search off), which publishes only its pages and +// their moments. The route still exists in the static build (every route +// does); it shows nothing of the corpus and points at the home page — the +// site's first page. export function NotOnCitedSite({ title }: { title: string }) { - const one = reportIds().length === 1; return ( <EmptyState title={title}> - This site publishes its reports only.{" "} + This site publishes its pages only.{" "} <Link href="/" className={textLink}> - {one ? "Read the report" : "Read the reports"} + Go to the home page </Link> . </EmptyState> diff --git a/export/app/lib/nav.ts b/export/app/lib/nav.ts @@ -6,25 +6,26 @@ export type NavLink = { href: string; label: string; external?: boolean }; // build has. Ask AI is new: the chat was only reachable from the workspace // control or from Use with AI, which is not where anyone looks for it. Use // with AI is the homepage's AI and MCP doc (release 16 slice DX): off this -// site, so a plain <a> in the same tab, not a client navigation. Reports -// shows when this build has a report (public/reports/index.json). +// site, so a plain <a> in the same tab, not a client navigation. The site's +// pages (site.json `pages`, release 26 A5) are linked each by its title, in +// the site's order, after Ask AI — there is no index of them. // -// A CITED site (site.json `search: false`) publishes only its reports and -// their moments: no search, no chat, no downloads or duplicates, and nothing -// for an AI to read — its nav is Reports alone, or nothing when its one -// report IS the home page (`singleReport`). +// A CITED site (site.json `search: false`) publishes only its pages and their +// moments: no search, no chat, no downloads or duplicates, and nothing for an +// AI to read — its nav is its pages alone, or nothing when its one page IS the +// home page. export function headerNavLinks(has: { cited: boolean; - reports: boolean; + pages: readonly { href: string; label: string }[]; duplicates: boolean; downloads: boolean; - singleReport?: boolean; }): NavLink[] { - if (has.cited) return has.singleReport ? [] : [{ href: "/reports/", label: "Reports" }]; + const pages = has.pages.map((p) => ({ href: p.href, label: p.label })); + if (has.cited) return pages.length > 1 ? pages : []; return [ { href: "/", label: "Search" }, { href: "/ask/", label: "Ask AI" }, - ...(has.reports ? [{ href: "/reports/", label: "Reports" }] : []), + ...pages, ...(has.duplicates ? [{ href: "/duplicates", label: "Duplicates" }] : []), ...(has.downloads ? [{ href: "/downloads", label: "Downloads" }] : []), { href: AI_DOC_URL, label: "Use with AI", external: true }, diff --git a/export/app/lib/reports.test.ts b/export/app/lib/reports.test.ts @@ -22,7 +22,7 @@ fs.mkdirSync(publicDir, { recursive: true }); fs.mkdirSync(path.join(sitesDir, "demo-cited"), { recursive: true }); fs.writeFileSync( path.join(sitesDir, "demo-cited", "site.json"), - JSON.stringify({ siteTitle: "Demo Reports", search: false, reports: ["demo-factcheck"] }), + JSON.stringify({ siteTitle: "Demo Reports", search: false, pages: ["demo-factcheck"] }), ); process.env.EXPORT_PUBLIC_DIR = publicDir; process.env.TRANSCRIPTS_DIR = path.join(root, "transcripts"); @@ -31,23 +31,24 @@ process.env.SITE_ID = "demo-cited"; delete process.env.INSTANCE_MODE; const fixture = await import("../../fixtures/report-site/fixture"); -const reportPage = await import("../reports/[reportId]/page"); +const reportPage = await import("../pages/[reportId]/page"); const momentPage = await import("../m/[...moment]/page"); -const reportsIndexPage = await import("../reports/page"); const home = await import("../(workspace)/page"); const { headerNavLinks } = await import("./nav"); +const reports = await import("./reports"); const { default: ReportArticle } = await import("yt-dlp-transcript-common/components/report/ReportArticle"); const render = (el: React.ReactElement) => renderToStaticMarkup(el); -test("with no reports, each dynamic route builds its one placeholder page, which says so", async () => { +test("with no pages, each dynamic route builds its one placeholder page, which says so", async () => { assert.deepEqual(reportPage.generateStaticParams(), [{ reportId: "_none" }]); assert.deepEqual(momentPage.generateStaticParams(), [{ moment: ["_none"] }]); const r = render(await reportPage.default({ params: Promise.resolve({ reportId: "_none" }) })); - assert.match(r, /No reports/); + assert.match(r, /No pages/); const m = render(await momentPage.default({ params: Promise.resolve({ moment: ["_none"] }) })); assert.match(m, /No moments/); - assert.match(render(reportsIndexPage.default()), /No reports/); + // and a search-off site with none says so on its home page (a save refuses it). + assert.match(render(await home.default()), /No pages/); }); test("the fixture's view JSON is exactly what the builder makes of its report", () => { @@ -93,7 +94,7 @@ test("the report page: header, tally, sections and claims, inline cites, referen ); assert.match( header, - /<\/h1><p data-report-dates=""[^>]*>2026-10-01 · updated 2026-10-04 · <a href="\/reports\/demo-factcheck\/history\/" data-report-revision="2"[^>]*>revision 2<\/a><\/p><p data-report-feeds=""[^>]*>[^]*?Subscribe:[^]*?<\/p><div id="source-s0" data-subject-source="s0"/, + /<\/h1><p data-report-dates=""[^>]*>2026-10-01 · updated 2026-10-04 · <a href="\/pages\/demo-factcheck\/history\/" data-report-revision="2"[^>]*>revision 2<\/a><\/p><p data-report-feeds=""[^>]*>[^]*?Subscribe:[^]*?<\/p><div id="source-s0" data-subject-source="s0"/, ); // the view switch (release 22): right after the header, sticky under the // site's header (so it is in reach wherever the article is scrolled); @@ -140,15 +141,15 @@ test("the report page: header, tally, sections and claims, inline cites, referen assert.match(html, /<h3[^>]*><a href="#claim-2"[^>]*>He went back to the bridge every year.<\/a>/); assert.match(html, /<article id="claim-1"/); // the source sentence's still, under the claim - assert.match(html, /data-source-sentence="a01"[^]*?<img src="\/reports\/demo-factcheck\/stills\/a01.png"/); + assert.match(html, /data-source-sentence="a01"[^]*?<img src="\/pages\/demo-factcheck\/stills\/a01.png"/); // inline citations carry their report numbers and jump to the reference list assert.match(html, /data-inline-cite="c01"[^]*?href="#c-c01" data-cite-number="1"/); assert.match(html, /data-inline-cite="w01"[^]*?data-cite-number="4"/); // every numbered citation has its reference entry, in number order const refs = [...html.matchAll(/<li id="c-([^"]+)" value="(\d+)"/g)].map((m) => `${m[2]}:${m[1]}`); assert.deepEqual(refs, ["1:c01", "2:au1", "3:a01", "4:w01", "5:a02", "6:p01"]); - assert.match(html, /href="\/reports\/demo-factcheck\/citations.json" download=""/); - assert.match(html, /href="\/reports\/demo-factcheck\/citations.csv" download=""/); + assert.match(html, /href="\/pages\/demo-factcheck\/citations.json" download=""/); + assert.match(html, /href="\/pages\/demo-factcheck\/citations.csv" download=""/); const meta = await reportPage.generateMetadata({ params }); assert.equal(meta.title, "Demo Checks: Checking an example article"); // a claim's flag: a pill on its card; an unflagged claim carries none @@ -244,16 +245,16 @@ test("the fixture's own timeline: newest first, its feeds on the site's URL", () assert.deepEqual(view.entries?.map((e) => e.id), ["update-mail", "update-opening"]); assert.equal(view.updated, "2026-10-04"); assert.deepEqual(view.feeds, { - rss: `${fixture.FIXTURE_SITE_URL}/reports/demo-factcheck/feed.xml`, - json: `${fixture.FIXTURE_SITE_URL}/reports/demo-factcheck/feed.json`, + rss: `${fixture.FIXTURE_SITE_URL}/pages/demo-factcheck/feed.xml`, + json: `${fixture.FIXTURE_SITE_URL}/pages/demo-factcheck/feed.json`, }); }); test("a report's timeline: after In brief, before the claims, newest first, dated, each its anchor; Subscribe and the alternates with feeds", async () => { const view = fixture.buildFixtureReportView(); const feeds = { - rss: "https://reports.example.org/reports/demo-factcheck/feed.xml", - json: "https://reports.example.org/reports/demo-factcheck/feed.json", + rss: "https://reports.example.org/pages/demo-factcheck/feed.xml", + json: "https://reports.example.org/pages/demo-factcheck/feed.json", }; const entries = [ { id: "update-2", date: "2026-10-06T09:30:00Z", title: "A second update", body: "More [on stream](cite:c01)." }, @@ -272,8 +273,8 @@ test("a report's timeline: after In brief, before the claims, newest first, date assert.match(html, /updated <time dateTime="2026-10-06">2026-10-06<\/time>/); // The header: Subscribe, to both feeds. const header = html.slice(at("<header"), at("</header>")); - assert.match(header, /data-report-feeds=""[^]*?Subscribe:[^]*?<a href="https:\/\/reports\.example\.org\/reports\/demo-factcheck\/feed\.xml" type="application\/rss\+xml" data-feed="rss"/); - assert.match(header, /<a href="https:\/\/reports\.example\.org\/reports\/demo-factcheck\/feed\.json" type="application\/feed\+json" data-feed="json"/); + assert.match(header, /data-report-feeds=""[^]*?Subscribe:[^]*?<a href="https:\/\/reports\.example\.org\/pages\/demo-factcheck\/feed\.xml" type="application\/rss\+xml" data-feed="rss"/); + assert.match(header, /<a href="https:\/\/reports\.example\.org\/pages\/demo-factcheck\/feed\.json" type="application\/feed\+json" data-feed="json"/); const { reportMetadata } = await import("./reports"); assert.deepEqual(reportMetadata({ ...view, entries, feeds }).alternates, { types: { @@ -292,18 +293,18 @@ test("a video moment: the clip, quote, verification, cue lines, original link, c const html = render( await momentPage.default({ params: Promise.resolve({ moment: ["demo-channel", "abc123", "3126.00-3151.00"] }) }), ); - assert.match(html, /<video data-evidence-clip=""[^>]*poster="\/reports\/demo-factcheck\/stills\/poster.png"[^>]*src="\/media\/clips\/demo-channel\/abc123\/3126.00-3151.00.mp4"/); + assert.match(html, /<video data-evidence-clip=""[^>]*poster="\/pages\/demo-factcheck\/stills\/poster.png"[^>]*src="\/media\/clips\/demo-channel\/abc123\/3126.00-3151.00.mp4"/); assert.ok(html.includes("52:01–52:36"), "the padded clip's own span is stated"); assert.ok(html.includes("The bridge opened in the spring of twenty nineteen, I was there for it.")); assert.match(html, /data-quote-score="97"/); assert.equal([...html.matchAll(/data-in-span=""/g)].length, 2); assert.match(html, /href="https:\/\/media.example.org\/demo-channel\/abc123\?t=3126"[^>]*>Original at 52:06/); assert.match(html, /data-cited-in=""/); - assert.match(html, /href="\/reports\/demo-factcheck\/"[^>]*>Demo Checks: Checking an example article/); - assert.match(html, /href="\/reports\/demo-factcheck\/#claim-1"/); + assert.match(html, /href="\/pages\/demo-factcheck\/"[^>]*>Demo Checks: Checking an example article/); + assert.match(html, /href="\/pages\/demo-factcheck\/#claim-1"/); assert.ok(html.includes("— “He opened it himself”"), "a cited-in entry names the claim by its title"); assert.match(html, /<span>Summary<\/span>/, "a summary citation is named as the summary"); - assert.match(html, /href="\/reports\/demo-factcheck\/#claim-5"/); + assert.match(html, /href="\/pages\/demo-factcheck\/#claim-5"/); }); test("an audio moment plays audio; a post moment shows its shot, text and author", async () => { @@ -321,17 +322,11 @@ test("an audio moment plays audio; a post moment shows its shot, text and author }); test("an unknown moment or report under a listed route renders the empty state, never throws", async () => { - assert.match(render(await reportPage.default({ params: Promise.resolve({ reportId: "nope" }) })), /No reports/); + assert.match(render(await reportPage.default({ params: Promise.resolve({ reportId: "nope" }) })), /No pages/); assert.match(render(await momentPage.default({ params: Promise.resolve({ moment: ["..", "x"] }) })), /No moments/); }); -test("one report: /reports/ is no index, it forwards to the home page (the report)", () => { - const html = render(reportsIndexPage.default()); - assert.match(html, /<meta http-equiv="refresh" content="0; url=\/"/); - assert.doesNotMatch(html, /data-report-index/); -}); - -test("a cited site with one report: its home IS the report, and never counts transcripts", async () => { +test("a search-off site with one page: its home IS the page, and never counts transcripts", async () => { // There is no summaries manifest here: countTranscripts() would throw. const html = render(await home.default()); assert.match(html, /<h1[^>]*><span data-report-series=""[^>]*>Demo Checks<\/span> <span[^>]*>Checking an example article<\/span><\/h1>/); @@ -346,48 +341,46 @@ test("a cited site with one report: its home IS the report, and never counts tra assert.equal(home.generateMetadata().title, "Demo Checks: Checking an example article"); }); -test("a cited site with more than one report: its home is the index, with no heading of its own", async () => { - const file = path.join(publicDir, "reports", "index.json"); +test("a search-off site with more than one page: its home is the first, and the header links each by its title", async () => { + const file = path.join(publicDir, "pages", "index.json"); const original = fs.readFileSync(file, "utf8"); try { const index = JSON.parse(original); - const { series: _series, ...unseried } = index.reports[0]; - index.reports = [unseried, { ...index.reports[0], id: "demo-second", series: "On the Record", title: "A second report", href: "/reports/demo-second/" }]; + index.reports = [index.reports[0], { ...index.reports[0], id: "demo-second", series: "On the Record", title: "A second report", href: "/pages/demo-second/" }]; fs.writeFileSync(file, JSON.stringify(index)); const html = render(await home.default()); - assert.match(html, /data-report-index/); - assert.match(html, /data-report-entry="demo-factcheck"/); - assert.match(html, /data-report-entry="demo-second"/); - assert.doesNotMatch(html, /<h1/, "no heading: the header already names the site"); - assert.deepEqual(home.generateMetadata(), {}, "the index keeps the site's own title"); - // With more than one, /reports/ is the index, tally and all. - const idx = render(reportsIndexPage.default()); - assert.match(idx, /data-report-entry="demo-factcheck"/); - assert.doesNotMatch(idx, /claims ·|data-verdict-tally/, "counts and tally are the report page's"); - assert.doesNotMatch(idx, /http-equiv="refresh"/); - // A series is its own line above the title, in the accent, with no kind eyebrow. - const second = html.slice(html.indexOf('data-report-entry="demo-second"')); - assert.match(second, /<span data-report-series="" class="block font-semibold text-brand">On the Record<\/span> <span class="block font-normal">A second report<\/span>/); - assert.doesNotMatch(second.slice(0, second.indexOf("</li>")), /Fact-check/); - const first = html.slice(html.indexOf('data-report-entry="demo-factcheck"')); - assert.match(first.slice(0, first.indexOf("</li>")), /Fact-check/, "no series: the kind's eyebrow"); + assert.match(html, /<article data-report="demo-factcheck"/); + assert.doesNotMatch(html, /data-report-index/, "no index of pages"); + const reportMeta = await reportPage.generateMetadata({ params: Promise.resolve({ reportId: "demo-factcheck" }) }); + assert.deepEqual(home.generateMetadata(), reportMeta); + assert.deepEqual(reports.pageLinks(), [ + { href: "/pages/demo-factcheck/", label: "Checking an example article" }, + { href: "/pages/demo-second/", label: "A second report" }, + ]); } finally { fs.writeFileSync(file, original); } }); -test("the header nav: Reports when the build has one; a cited site has Reports alone, or nothing with one report", () => { - const full = headerNavLinks({ cited: false, reports: true, duplicates: false, downloads: true }); +test("the header nav: a full site links its pages by title after Ask AI; a search-off site its pages alone, or nothing with one", () => { + const pages = [ + { href: "/pages/one/", label: "Page one" }, + { href: "/pages/two/", label: "Page two" }, + ]; + const full = headerNavLinks({ cited: false, pages, duplicates: false, downloads: true }); assert.deepEqual( full.map((l) => l.label), - ["Search", "Ask AI", "Reports", "Downloads", "Use with AI"], + ["Search", "Ask AI", "Page one", "Page two", "Downloads", "Use with AI"], ); - assert.ok(!headerNavLinks({ cited: false, reports: false, duplicates: false, downloads: false }).some((l) => l.label === "Reports")); - assert.deepEqual(headerNavLinks({ cited: true, reports: true, duplicates: true, downloads: true }), [ - { href: "/reports/", label: "Reports" }, - ]); - // One report is the home page: nowhere else to go. - assert.deepEqual(headerNavLinks({ cited: true, reports: true, duplicates: false, downloads: false, singleReport: true }), []); + assert.equal(full[2].href, "/pages/one/"); + assert.deepEqual( + headerNavLinks({ cited: false, pages: [], duplicates: false, downloads: false }).map((l) => l.label), + ["Search", "Ask AI", "Use with AI"], + ); + assert.deepEqual(headerNavLinks({ cited: true, pages, duplicates: true, downloads: true }), pages); + // One page is the home page: nowhere else to go. + assert.deepEqual(headerNavLinks({ cited: true, pages: pages.slice(0, 1), duplicates: false, downloads: false }), []); + assert.ok(!full.some((l) => l.label === "Reports"), "no Reports index"); }); test.after(() => fs.rmSync(root, { recursive: true, force: true })); diff --git a/export/app/lib/reports.ts b/export/app/lib/reports.ts @@ -2,10 +2,11 @@ import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { createReportReader, reportMetadata } from "yt-dlp-transcript-common/lib/report/reader-server"; import { SITE_REPORTS_BASE } from "yt-dlp-transcript-common/lib/report/routes"; -// This site's reports and moments, read from its public dir by the shared -// reader (common/lib/report/reader-server.ts) under the site's base. The -// public dir is resolved on every read: getPaths() is cached on first use, and -// a test sets the environment before it is. +// This site's pages (site.json `pages`: its reports, at `/pages/<id>/`) and +// moments, read from its public dir by the shared reader +// (common/lib/report/reader-server.ts) under the site's base. The public dir +// is resolved on every read: getPaths() is cached on first use, and a test +// sets the environment before it is. const reader = createReportReader({ publicDir: () => getPaths().exportPublicDir, base: SITE_REPORTS_BASE }); @@ -13,14 +14,18 @@ const reader = createReportReader({ publicDir: () => getPaths().exportPublicDir, export const REPORTS_BASE = reader.base; export const readReportIndex = () => reader.readReportIndex(); -// Whether this build has a report to link to: drives the header's Reports link. -export const hasReports = () => reader.hasReports(); export const reportIds = () => reader.reportIds(); export const readReportView = (reportId: string) => reader.readReportView(reportId); export const readReportHistory = (reportId: string) => reader.readReportHistory(reportId); -// The build's one report, when it publishes exactly one: a cited site's home -// page IS that report. -export const onlyReportView = () => reader.onlyReportView(); +// The site's first page: a search-off site's home page IS that page. +export const firstReportView = () => reader.firstReportView(); + +// The header's links to the site's pages, in order: each by its title. +export function pageLinks(): { href: string; label: string }[] { + return (reader.readReportIndex()?.reports ?? []).flatMap((r) => + reportIds().includes(r.id) ? [{ href: r.href, label: r.title }] : [], + ); +} export const momentKeys = () => reader.momentKeys(); export const readMomentView = (key: string) => reader.readMomentView(key); diff --git a/export/app/pages/[reportId]/history/page.tsx b/export/app/pages/[reportId]/history/page.tsx @@ -0,0 +1,32 @@ +import type { Metadata } from "next"; +import { REPORT_PLACEHOLDER_ID, reportFullTitle } from "yt-dlp-transcript-common/lib/report/views"; +import ReportHistory from "yt-dlp-transcript-common/components/report/ReportHistory"; +import { EmptyState } from "yt-dlp-transcript-common/components/report/parts"; +import { REPORTS_BASE, readReportHistory, reportIds } from "../../../lib/reports"; + +// /pages/<reportId>/history/: a page's revisions, from +// /pages/<reportId>/history/history.json. Static: built for every page (and, +// with none, the placeholder, as /pages/<reportId>/ is); a page with no +// published history says so. +export const dynamicParams = false; + +export function generateStaticParams(): { reportId: string }[] { + const ids = reportIds(); + return (ids.length > 0 ? ids : [REPORT_PLACEHOLDER_ID]).map((reportId) => ({ reportId })); +} + +type Params = { params: Promise<{ reportId: string }> }; + +export async function generateMetadata({ params }: Params): Promise<Metadata> { + const view = readReportHistory((await params).reportId); + if (!view) return { title: "No history" }; + return { title: `Revision history — ${reportFullTitle(view)}` }; +} + +export default async function ReportHistoryPage({ params }: Params) { + const view = readReportHistory((await params).reportId); + if (!view) { + return <EmptyState title="No history">This page has no published revision history.</EmptyState>; + } + return <ReportHistory view={view} base={REPORTS_BASE} />; +} diff --git a/export/app/pages/[reportId]/page.tsx b/export/app/pages/[reportId]/page.tsx @@ -0,0 +1,36 @@ +import type { Metadata } from "next"; +import { REPORT_PLACEHOLDER_ID } from "yt-dlp-transcript-common/lib/report/views"; +import ReportArticle from "yt-dlp-transcript-common/components/report/ReportArticle"; +import { EmptyState } from "yt-dlp-transcript-common/components/report/parts"; +import { REPORTS_BASE, readReportView, reportIds, reportMetadata } from "../../lib/reports"; + +// /pages/<reportId>/: one of the site's pages (site.json `pages`), a report +// rendered from /pages/<reportId>/page.json. Static: every page is listed, +// nothing else resolves. A site with none builds the one placeholder page (a +// static export refuses an empty generateStaticParams), which says so. +export const dynamicParams = false; + +export function generateStaticParams(): { reportId: string }[] { + const ids = reportIds(); + return (ids.length > 0 ? ids : [REPORT_PLACEHOLDER_ID]).map((reportId) => ({ reportId })); +} + +type Params = { params: Promise<{ reportId: string }> }; + +export async function generateMetadata({ params }: Params): Promise<Metadata> { + const view = readReportView((await params).reportId); + if (!view) return { title: "No pages" }; + return reportMetadata(view); +} + +export default async function ReportPage({ params }: Params) { + const view = readReportView((await params).reportId); + if (!view) { + return ( + <EmptyState title="No pages"> + This site has not published a page yet. + </EmptyState> + ); + } + return <ReportArticle view={view} base={REPORTS_BASE} />; +} diff --git a/export/app/reports/[reportId]/history/page.tsx b/export/app/reports/[reportId]/history/page.tsx @@ -1,32 +0,0 @@ -import type { Metadata } from "next"; -import { REPORT_PLACEHOLDER_ID, reportFullTitle } from "yt-dlp-transcript-common/lib/report/views"; -import ReportHistory from "yt-dlp-transcript-common/components/report/ReportHistory"; -import { EmptyState } from "yt-dlp-transcript-common/components/report/parts"; -import { REPORTS_BASE, readReportHistory, reportIds } from "../../../lib/reports"; - -// /reports/<reportId>/history/: the report's revisions, from -// /reports/<reportId>/history/history.json. Static: built for every published -// report (and, with none, the placeholder, as /reports/<reportId>/ is); a -// report with no published history says so. -export const dynamicParams = false; - -export function generateStaticParams(): { reportId: string }[] { - const ids = reportIds(); - return (ids.length > 0 ? ids : [REPORT_PLACEHOLDER_ID]).map((reportId) => ({ reportId })); -} - -type Params = { params: Promise<{ reportId: string }> }; - -export async function generateMetadata({ params }: Params): Promise<Metadata> { - const view = readReportHistory((await params).reportId); - if (!view) return { title: "No history" }; - return { title: `Revision history — ${reportFullTitle(view)}` }; -} - -export default async function ReportHistoryPage({ params }: Params) { - const view = readReportHistory((await params).reportId); - if (!view) { - return <EmptyState title="No history">This report has no published revision history.</EmptyState>; - } - return <ReportHistory view={view} base={REPORTS_BASE} />; -} diff --git a/export/app/reports/[reportId]/page.tsx b/export/app/reports/[reportId]/page.tsx @@ -1,36 +0,0 @@ -import type { Metadata } from "next"; -import { REPORT_PLACEHOLDER_ID } from "yt-dlp-transcript-common/lib/report/views"; -import ReportArticle from "yt-dlp-transcript-common/components/report/ReportArticle"; -import { EmptyState } from "yt-dlp-transcript-common/components/report/parts"; -import { REPORTS_BASE, readReportView, reportIds, reportMetadata } from "../../lib/reports"; - -// /reports/<reportId>/: one report, from /reports/<reportId>/page.json. -// Static: every published report is listed, nothing else resolves. A site with -// none builds the one placeholder page (a static export refuses an empty -// generateStaticParams), which says so. -export const dynamicParams = false; - -export function generateStaticParams(): { reportId: string }[] { - const ids = reportIds(); - return (ids.length > 0 ? ids : [REPORT_PLACEHOLDER_ID]).map((reportId) => ({ reportId })); -} - -type Params = { params: Promise<{ reportId: string }> }; - -export async function generateMetadata({ params }: Params): Promise<Metadata> { - const view = readReportView((await params).reportId); - if (!view) return { title: "No reports" }; - return reportMetadata(view); -} - -export default async function ReportPage({ params }: Params) { - const view = readReportView((await params).reportId); - if (!view) { - return ( - <EmptyState title="No reports"> - This site has not published a report yet. - </EmptyState> - ); - } - return <ReportArticle view={view} base={REPORTS_BASE} />; -} diff --git a/export/app/reports/page.tsx b/export/app/reports/page.tsx @@ -1,32 +0,0 @@ -import type { Metadata } from "next"; -import ReportIndex from "yt-dlp-transcript-common/components/report/ReportIndex"; -import Link from "next/link"; -import { isCitedSite } from "yt-dlp-transcript-common/lib/siteSchema"; -import { textLink } from "yt-dlp-transcript-common/components/report/parts"; -import { readReportIndex, reportIds } from "../lib/reports"; -import { currentSite } from "../lib/site"; -import { instanceMode } from "../lib/mode"; - -export const metadata: Metadata = { title: "Reports" }; - -// The report index, from /reports/index.json (common/lib/report/views.ts). A -// cited site with more than one report renders the same index as its home -// page. A cited site with ONE report has no index: its home page is the -// report, so this route only forwards there (a static export has no server -// redirect; React hoists the refresh into the head). -export default function ReportsPage() { - const site = currentSite(); - if (instanceMode() === "site" && isCitedSite(site) && reportIds().length === 1) { - return ( - <> - <meta httpEquiv="refresh" content="0; url=/" /> - <p data-reports-forward="" className="mx-auto max-w-2xl text-sm text-muted-foreground"> - <Link href="/" className={textLink}> - {site.siteTitle} - </Link> - </p> - </> - ); - } - return <ReportIndex index={readReportIndex()} />; -} diff --git a/export/e2e-report/audit.spec.ts b/export/e2e-report/audit.spec.ts @@ -19,28 +19,27 @@ test("the built cited site passes the audit every deploy path asks", () => { expect(reportSiteAuditProblem()).toBeNull(); }); -test("it holds the reports, the moments, the cited media and the contract", () => { +test("it holds the pages, the moments, the cited media and the contract", () => { for (const rel of [ "index.html", - "reports/index.html", - "reports/index.json", - "reports/demo-factcheck/index.html", - "reports/demo-factcheck/page.json", - "reports/demo-factcheck/citations.json", - "reports/demo-factcheck/citations.csv", - "reports/demo-factcheck/report.html", - "reports/demo-factcheck/report.pdf", - "reports/demo-factcheck/report.md", - "reports/demo-factcheck/slides.html", - "reports/demo-factcheck/slides.pdf", - "reports/demo-factcheck/evidence-pack.zip", - "reports/demo-factcheck/stills/a01.png", - "reports/demo-factcheck/history/index.html", - "reports/demo-factcheck/history/history.json", - "reports/demo-factcheck/history/repo/HEAD", - "reports/demo-factcheck/history/repo/info/refs", - "reports/demo-factcheck/history/repo/objects/info/packs", - "reports/demo-factcheck/history/repo/refs/heads/main", + "pages/index.json", + "pages/demo-factcheck/index.html", + "pages/demo-factcheck/page.json", + "pages/demo-factcheck/citations.json", + "pages/demo-factcheck/citations.csv", + "pages/demo-factcheck/report.html", + "pages/demo-factcheck/report.pdf", + "pages/demo-factcheck/report.md", + "pages/demo-factcheck/slides.html", + "pages/demo-factcheck/slides.pdf", + "pages/demo-factcheck/evidence-pack.zip", + "pages/demo-factcheck/stills/a01.png", + "pages/demo-factcheck/history/index.html", + "pages/demo-factcheck/history/history.json", + "pages/demo-factcheck/history/repo/HEAD", + "pages/demo-factcheck/history/repo/info/refs", + "pages/demo-factcheck/history/repo/objects/info/packs", + "pages/demo-factcheck/history/repo/refs/heads/main", "m/index.json", "m/demo-channel/abc123/3126.00-3151.00/index.html", "m/demo-channel/abc123/3126.00-3151.00/moment.json", @@ -56,7 +55,10 @@ test("it holds the reports, the moments, the cited media and the contract", () = ]) { expect(has(rel), rel).toBe(true); } + // No index of the pages, and nothing where reports were before release 26. + for (const rel of ["pages/index.html", "reports"]) expect(has(rel), rel).toBe(false); const corpus = JSON.parse(fs.readFileSync(path.join(out, "corpus.json"), "utf8")); + expect(corpus.reports.index).toBe("https://reports.example.org/pages/index.json"); expect(corpus.site).toMatchObject({ id: "reportsite", scope: "cited" }); expect(corpus.reports.count).toBe(1); const site = JSON.parse(fs.readFileSync(path.join(out, "site.json"), "utf8")); diff --git a/export/e2e-report/fixtures/sites/reportsite/site.json b/export/e2e-report/fixtures/sites/reportsite/site.json @@ -5,5 +5,5 @@ "headerTitle": "Demo Reports", "siteUrl": "https://reports.example.org", "search": false, - "reports": ["demo-factcheck"] + "pages": ["demo-factcheck"] } diff --git a/export/e2e-report/overview.spec.ts b/export/e2e-report/overview.spec.ts @@ -6,7 +6,7 @@ import type { Page } from "@playwright/test"; // motion, a narrow screen, a keyboard arrival or the reader's choice — over // the cited fixture site (stage.ts; its deck is listed in slides.spec.ts). -const REPORT = "/reports/demo-factcheck/"; +const REPORT = "/pages/demo-factcheck/"; const switchIn = (page: Page) => page.locator("[data-report-views] [data-view-switch]"); const stage = (page: Page) => page.locator("[data-report-slides]"); diff --git a/export/e2e-report/report-site.spec.ts b/export/e2e-report/report-site.spec.ts @@ -9,10 +9,11 @@ import { reportChangeSummary, type ReportHistoryView } from "yt-dlp-transcript-c import { historyGitEnv } from "yt-dlp-transcript-common/publish/reportHistory"; import { readFixtureReport } from "../fixtures/report-site/fixture"; -// A cited site, as a reader meets it: its one report as the home page, the -// report (verdicts, tally, the source's sentence, numbered inline citations -// with previews, the reference list), the moment pages each citation opens, -// and the shell's pages that say this site publishes its reports only. Every +// A search-off ("cited") site, as a reader meets it: its one page (a report) +// as the home page, the page at /pages/<id>/ (verdicts, tally, the source's +// sentence, numbered inline citations with previews, the reference list), the +// moment pages each citation opens, and the shell's pages that say this site +// publishes its pages only. Every // test also holds the page's own requests to the cited promise (helpers.ts). // // The site is export/fixtures/report-site, staged and built by @@ -21,11 +22,11 @@ import { readFixtureReport } from "../fixtures/report-site/fixture"; // page (w01). It has two revisions (report.v1.json, then report.json), and // publishes their history. -const REPORT = "/reports/demo-factcheck/"; +const REPORT = "/pages/demo-factcheck/"; const VIDEO_MOMENT = "/m/demo-channel/abc123/3126.00-3151.00/"; const AUDIO_MOMENT = "/m/demo-podcast/ep-042/610.50-628.00/"; const POST_MOMENT = "/m/demo-social/1234567890/"; -const HISTORY = "/reports/demo-factcheck/history/"; +const HISTORY = "/pages/demo-factcheck/history/"; const inlineCite = (page: Page, id: string): Locator => page.locator(`[data-inline-cite="${id}"]`).first(); const preview = (page: Page, id: string): Locator => page.locator(`[data-cite-preview="${id}"]`); @@ -35,7 +36,7 @@ async function expectImageLoaded(img: Locator): Promise<void> { await expect.poll(() => img.evaluate((el) => (el as HTMLImageElement).naturalWidth)).toBeGreaterThan(0); } -test("one report: the home page IS the report, and the header links nothing", async ({ page }) => { +test("one page: the home page IS the page, and the header links nothing", async ({ page }) => { await page.goto("/"); // The series on one line, the title on the next, both in the heading. await expect(page.locator("h1")).toHaveText("Demo Checks Checking an example article"); @@ -69,10 +70,10 @@ test("the header at 375 px: the title and the card wrap, nothing scrolls sideway expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(375); }); -test("one report: /reports/ is no index, it forwards to the home page", async ({ page }) => { - await page.goto("/reports/"); - await expect(page).toHaveURL("/"); - await expect(page.locator("h1")).toContainText("Checking an example article"); +test("a site has no index of its pages: /pages/ and the old /reports/ are not found", async ({ request }) => { + for (const route of ["/pages/", "/reports/", "/reports/demo-factcheck/"]) { + expect((await request.get(route)).status(), route).toBe(404); + } }); test("the report: verdict chips, the tally, the source's sentence as a still, numbered inline citations", async ({ page }) => { @@ -347,7 +348,7 @@ test("the history lists both revisions, newest first: hashes, the change summary await expect(r2.locator('[data-claim-change="claim-5"]')).toHaveAttribute("data-status", "added"); await expect(page.locator('li[data-revision="1"] [data-claim-change]')).toHaveCount(0); await expect(page.locator("[data-history-clone]")).toHaveText( - "git clone https://reports.example.org/reports/demo-factcheck/history/repo", + "git clone https://reports.example.org/pages/demo-factcheck/history/repo", ); // The footer of every export names the revision and its report sha256. const md = await (await request.get(`${REPORT}report.md`)).text(); @@ -444,10 +445,10 @@ test("a post moment shows the captured shot and the post", async ({ page }) => { }); for (const route of ["/ask/", "/downloads/", "/duplicates/"]) { - test(`${route} says this site publishes its reports only`, async ({ page }) => { + test(`${route} says this site publishes its pages only`, async ({ page }) => { await page.goto(route); - await expect(page.getByText("This site publishes its reports only.")).toBeVisible(); - await expect(page.getByRole("link", { name: "Read the report" })).toHaveAttribute("href", "/"); + await expect(page.getByText("This site publishes its pages only.")).toBeVisible(); + await expect(page.getByRole("link", { name: "Go to the home page" })).toHaveAttribute("href", "/"); await expect(page.locator("header nav a")).toHaveCount(0); }); } diff --git a/export/e2e-report/slides.spec.ts b/export/e2e-report/slides.spec.ts @@ -18,7 +18,7 @@ import type { Page } from "@playwright/test"; // Every test also holds the page's requests to the cited promise (helpers.ts): // the slides are built from the report's own page.json, nothing else. -const REPORT = "/reports/demo-factcheck/"; +const REPORT = "/pages/demo-factcheck/"; // The article's switch (sticky under the site's header) or the overlay's. const switchIn = (page: Page, where: "article" | "overlay") => @@ -133,7 +133,7 @@ test("slides: a citation's number opens its card; the evidence shows the clip's const slide = stage(page).locator('[data-slide="claim:claim-1"]'); await expect(slide.locator('[data-verdict="CONTRADICTED"]')).toBeVisible(); const pic = slide.locator('[data-slide-evidence="c01"] img'); - await expect(pic).toHaveAttribute("src", "/reports/demo-factcheck/stills/poster.png"); + await expect(pic).toHaveAttribute("src", "/pages/demo-factcheck/stills/poster.png"); await expect.poll(() => pic.evaluate((el) => (el as HTMLImageElement).naturalWidth)).toBeGreaterThan(0); const number = slide.locator('[data-inline-cite="c01"] [data-cite-number]'); await number.click(); diff --git a/export/e2e-report/timeline.spec.ts b/export/e2e-report/timeline.spec.ts @@ -11,7 +11,7 @@ import { expect, test } from "./helpers"; // update-opening 2026-10-02 "The opening date, said on air" (updated 2026-10-04) // Both cite only c01, the summary's first citation, so no number moves. -const REPORT = "/reports/demo-factcheck/"; +const REPORT = "/pages/demo-factcheck/"; const SITE = "https://reports.example.org"; const RSS = `${SITE}${REPORT}feed.xml`; const JSON_FEED = `${SITE}${REPORT}feed.json`; diff --git a/export/fixtures/report-site/fixture.ts b/export/fixtures/report-site/fixture.ts @@ -85,7 +85,7 @@ const RECORDS: Record<string, RecordView> = { }, }; -const POSTER = "/reports/demo-factcheck/stills/poster.png"; +const POSTER = "/pages/demo-factcheck/stills/poster.png"; // A post's captured screenshot, where compose copies a cited capture // (publish/citedPostCaptures.ts): committed under public/media/posts/. diff --git a/export/fixtures/report-site/public/m/demo-channel/abc123/3126.00-3151.00/moment.json b/export/fixtures/report-site/public/m/demo-channel/abc123/3126.00-3151.00/moment.json @@ -25,7 +25,7 @@ "src": "/media/clips/demo-channel/abc123/3126.00-3151.00.mp4", "start": 3121, "end": 3156, - "poster": "/reports/demo-factcheck/stills/poster.png" + "poster": "/pages/demo-factcheck/stills/poster.png" }, "cues": [ { @@ -71,7 +71,7 @@ "sectionId": null, "claimId": null, "citationId": "c01", - "href": "/reports/demo-factcheck/", + "href": "/pages/demo-factcheck/", "reportTitle": "Demo Checks: Checking an example article", "number": 1 }, @@ -81,7 +81,7 @@ "claimId": null, "entryId": "update-mail", "citationId": "c01", - "href": "/reports/demo-factcheck/#update-mail", + "href": "/pages/demo-factcheck/#update-mail", "reportTitle": "Demo Checks: Checking an example article", "entryTitle": "A reader asked about another year", "number": 1 @@ -92,7 +92,7 @@ "claimId": null, "entryId": "update-opening", "citationId": "c01", - "href": "/reports/demo-factcheck/#update-opening", + "href": "/pages/demo-factcheck/#update-opening", "reportTitle": "Demo Checks: Checking an example article", "entryTitle": "The opening date, said on air", "number": 1 @@ -102,7 +102,7 @@ "sectionId": "bridge", "claimId": "claim-1", "citationId": "c01", - "href": "/reports/demo-factcheck/#claim-1", + "href": "/pages/demo-factcheck/#claim-1", "reportTitle": "Demo Checks: Checking an example article", "sectionTitle": "The bridge", "claimTitle": "“He opened it himself”", @@ -119,7 +119,7 @@ "sectionId": "moving", "claimId": "claim-5", "citationId": "c01", - "href": "/reports/demo-factcheck/#claim-5", + "href": "/pages/demo-factcheck/#claim-5", "reportTitle": "Demo Checks: Checking an example article", "sectionTitle": "Moving away", "claimText": "He was at the opening.", diff --git a/export/fixtures/report-site/public/m/demo-podcast/ep-042/610.50-628.00/moment.json b/export/fixtures/report-site/public/m/demo-podcast/ep-042/610.50-628.00/moment.json @@ -50,7 +50,7 @@ "sectionId": null, "claimId": null, "citationId": "au1", - "href": "/reports/demo-factcheck/", + "href": "/pages/demo-factcheck/", "reportTitle": "Demo Checks: Checking an example article", "number": 2 }, @@ -59,7 +59,7 @@ "sectionId": "bridge", "claimId": "claim-1", "citationId": "au1", - "href": "/reports/demo-factcheck/#claim-1", + "href": "/pages/demo-factcheck/#claim-1", "reportTitle": "Demo Checks: Checking an example article", "sectionTitle": "The bridge", "claimTitle": "“He opened it himself”", @@ -76,7 +76,7 @@ "sectionId": "bridge", "claimId": "claim-2", "citationId": "au1", - "href": "/reports/demo-factcheck/#claim-2", + "href": "/pages/demo-factcheck/#claim-2", "reportTitle": "Demo Checks: Checking an example article", "sectionTitle": "The bridge", "claimText": "He went back to the bridge every year.", diff --git a/export/fixtures/report-site/public/m/demo-social/1234567890/moment.json b/export/fixtures/report-site/public/m/demo-social/1234567890/moment.json @@ -24,7 +24,7 @@ "sectionId": "moving", "claimId": "claim-3", "citationId": "p01", - "href": "/reports/demo-factcheck/#claim-3", + "href": "/pages/demo-factcheck/#claim-3", "reportTitle": "Demo Checks: Checking an example article", "sectionTitle": "Moving away", "claimText": "He has said many times that he would move away.", diff --git a/export/fixtures/report-site/public/pages/demo-factcheck/page.json b/export/fixtures/report-site/public/pages/demo-factcheck/page.json @@ -0,0 +1,284 @@ +{ + "format": "archilyzer-report-page", + "version": 1, + "id": "demo-factcheck", + "kind": "factcheck", + "series": "Demo Checks", + "title": "Checking an example article", + "subtitle": "Four claims about a demo channel, tested against what was said on air", + "summary": "The article makes four claims. The recordings support one, partly support another, and contradict a third; the fourth cannot be tested. The host said the opening date out loud [on stream](cite:c01), and later [repeated it](cite:au1).", + "method": "Each claim was searched for in the channel's transcripts and the guest's podcast, and checked against the city's public records.", + "published": "2026-10-01", + "updated": "2026-10-04", + "subject": "s0", + "sources": { + "s0": { + "id": "s0", + "kind": "article", + "title": "An example article about a demo channel", + "url": "https://example.org/articles/demo", + "publisher": "Example Gazette", + "author": "A. Writer", + "date": "2026-09-20", + "note": "Read in the edition published on the day; it has since been revised.", + "accent": "#8a6fb0", + "archives": [ + { + "label": "archive.org", + "url": "https://web.archive.org/web/2026/https://example.org/articles/demo", + "context": "as published on the day" + } + ] + } + }, + "verdicts": { + "CORROBORATED": { + "label": "Corroborated", + "color": "#3fbf7f" + }, + "PARTLY": { + "label": "Partly true", + "color": "#e3b23c" + }, + "CONTRADICTED": { + "label": "Contradicted", + "color": "#e5534b" + }, + "NOT_FOUND": { + "label": "Not found", + "color": "#8b93a7" + }, + "UNTESTABLE": { + "label": "Untestable", + "color": "#7d8fd6" + } + }, + "citations": { + "c01": { + "kind": "video", + "id": "c01", + "number": 1, + "quote": "The bridge opened in the spring of twenty nineteen, I was there for it.", + "verification": { + "quoteScore": 0.97, + "quoteCheckedAt": "2026-10-04T12:00:00Z", + "voiceChecked": true, + "method": "cue-window v1" + }, + "origin": "added", + "moment": "demo-channel/abc123/3126.00-3151.00", + "href": "/m/demo-channel/abc123/3126.00-3151.00/", + "start": 3126, + "end": 3151, + "record": { + "channel": "demo-channel", + "channelTitle": "Demo Channel", + "id": "abc123", + "title": "Demo stream: the bridge, the move, and the mail", + "date": "2026-01-10", + "platform": "youtube", + "originalUrl": "https://media.example.org/demo-channel/abc123?t=3126" + }, + "poster": "/pages/demo-factcheck/stills/poster.png" + }, + "au1": { + "kind": "audio", + "id": "au1", + "number": 2, + "quote": "Like I said before, spring twenty nineteen.", + "speaker": "The guest", + "verification": { + "quoteScore": 0.88, + "quoteCheckedAt": "2026-10-04T12:00:00Z" + }, + "moment": "demo-podcast/ep-042/610.50-628.00", + "href": "/m/demo-podcast/ep-042/610.50-628.00/", + "start": 610.5, + "end": 628, + "record": { + "channel": "demo-podcast", + "channelTitle": "Demo Podcast", + "id": "ep-042", + "title": "Episode 42: a guest looks back", + "date": "2026-02-02", + "originalUrl": "https://media.example.org/demo-podcast/ep-042?t=610" + } + }, + "a01": { + "kind": "source", + "id": "a01", + "number": 3, + "quote": "He opened the bridge himself in 2018.", + "sourceId": "s0", + "sourceTitle": "An example article about a demo channel", + "sourceAccent": "#8a6fb0", + "image": "/pages/demo-factcheck/stills/a01.png", + "href": "https://example.org/articles/demo" + }, + "w01": { + "kind": "page", + "id": "w01", + "number": 4, + "quote": "Opened to traffic: April 2019.", + "note": "The city's own record of the opening.", + "origin": "subject", + "href": "https://example.org/city/bridge-history", + "title": "Bridge history — city records", + "archiveUrl": "https://web.archive.org/web/2026/https://example.org/city/bridge-history" + }, + "a02": { + "kind": "source", + "id": "a02", + "number": 5, + "quote": "He has said many times that he would move away.", + "sourceId": "s0", + "sourceTitle": "An example article about a demo channel", + "sourceAccent": "#8a6fb0", + "href": "https://example.org/articles/demo" + }, + "p01": { + "kind": "post", + "id": "p01", + "number": 6, + "quote": "Never said I would move. Not once.", + "date": "2025-03-14", + "moment": "demo-social/1234567890", + "href": "/m/demo-social/1234567890/", + "record": { + "channel": "demo-social", + "channelTitle": "Demo Social", + "id": "1234567890", + "date": "2025-03-14", + "platform": "x", + "originalUrl": "https://media.example.org/demo-social/1234567890" + }, + "author": "@demo_account", + "text": "Never said I would move. Not once.\n\nPosted to settle it.", + "shot": "/media/posts/demo-social/1234567890/shot.png" + } + }, + "entries": [ + { + "id": "update-mail", + "date": "2026-10-04", + "title": "A reader asked about another year", + "body": "No other year turns up: every time he dates the opening it is the year he said [on stream](cite:c01)." + }, + { + "id": "update-opening", + "date": "2026-10-02", + "updated": "2026-10-04", + "title": "The opening date, said on air", + "body": "The host gave the year of the opening [on stream](cite:c01), the year the city's record names." + } + ], + "sections": [ + { + "id": "bridge", + "title": "The bridge", + "body": "The article's first chapter is about the bridge.", + "slide": { + "points": [ + "The article dates the opening to 2018", + "He says 2019 on stream, and [the city's record](cite:w01) agrees" + ], + "cite": "w01" + }, + "claims": [ + { + "id": "claim-1", + "title": "“He opened it himself”", + "text": "He opened the bridge himself in 2018.", + "verdict": "CONTRADICTED", + "gist": "It opened in 2019, as he says on stream and the city's record shows.", + "sourceQuote": "a01", + "findings": "He was there, but the bridge opened in 2019: he says so [on stream](cite:c01), and the [city's record](cite:w01) agrees.", + "citations": [ + "c01", + "w01", + "au1" + ] + }, + { + "id": "claim-2", + "text": "He went back to the bridge every year.", + "verdict": "PARTLY", + "gist": "Once is on record; every year is not.", + "findings": "He mentions going back [once](cite:au1); nothing in the recordings says every year.", + "citations": [ + "au1" + ], + "slide": { + "title": "Every year?", + "points": [ + "He mentions going back [once](cite:au1)", + "Nothing in the recordings says every year" + ] + } + } + ] + }, + { + "id": "moving", + "title": "Moving away", + "claims": [ + { + "id": "claim-3", + "text": "He has said many times that he would move away.", + "verdict": "CONTRADICTED", + "gist": "He denies ever saying it.", + "sourceQuote": "a02", + "findings": "The article [puts it as a habit](cite:a02); he [denies it outright](cite:p01).", + "citations": [ + "p01" + ], + "slide": { + "cite": "p01", + "layout": "quote" + } + }, + { + "id": "claim-4", + "text": "He privately regrets it.", + "verdict": "UNTESTABLE", + "flag": "No source given", + "findings": "Nothing public speaks to a private feeling.", + "citations": [] + }, + { + "id": "claim-5", + "text": "He was at the opening.", + "verdict": "CORROBORATED", + "findings": "He says [he was there](cite:c01).", + "citations": [ + "c01" + ] + } + ] + } + ], + "downloads": { + "html": "/pages/demo-factcheck/report.html", + "pdf": "/pages/demo-factcheck/report.pdf", + "md": "/pages/demo-factcheck/report.md", + "slides": "/pages/demo-factcheck/slides.html", + "slides-pdf": "/pages/demo-factcheck/slides.pdf", + "zip": "/pages/demo-factcheck/evidence-pack.zip", + "json": "/pages/demo-factcheck/citations.json", + "csv": "/pages/demo-factcheck/citations.csv" + }, + "feeds": { + "rss": "https://reports.example.org/pages/demo-factcheck/feed.xml", + "json": "https://reports.example.org/pages/demo-factcheck/feed.json" + }, + "history": { + "revision": 2, + "date": "2026-10-04T12:00:00Z", + "href": "/pages/demo-factcheck/history/", + "current": true + }, + "slides": { + "title": "Five claims, checked against what was said on air", + "closing": "Every citation opens the moment it quotes." + } +} diff --git a/export/fixtures/report-site/public/reports/demo-factcheck/stills/a01.png b/export/fixtures/report-site/public/pages/demo-factcheck/stills/a01.png Binary files differ. diff --git a/export/fixtures/report-site/public/reports/demo-factcheck/stills/poster.png b/export/fixtures/report-site/public/pages/demo-factcheck/stills/poster.png Binary files differ. diff --git a/export/fixtures/report-site/public/pages/index.json b/export/fixtures/report-site/public/pages/index.json @@ -0,0 +1,58 @@ +{ + "format": "archilyzer-report-index", + "version": 1, + "reports": [ + { + "id": "demo-factcheck", + "kind": "factcheck", + "series": "Demo Checks", + "title": "Checking an example article", + "subtitle": "Four claims about a demo channel, tested against what was said on air", + "published": "2026-10-01", + "updated": "2026-10-04", + "href": "/pages/demo-factcheck/", + "citationCount": 6, + "claimCount": 5, + "tally": [ + { + "verdict": "CORROBORATED", + "count": 1 + }, + { + "verdict": "PARTLY", + "count": 1 + }, + { + "verdict": "CONTRADICTED", + "count": 2 + }, + { + "verdict": "UNTESTABLE", + "count": 1 + } + ], + "verdicts": { + "CORROBORATED": { + "label": "Corroborated", + "color": "#3fbf7f" + }, + "PARTLY": { + "label": "Partly true", + "color": "#e3b23c" + }, + "CONTRADICTED": { + "label": "Contradicted", + "color": "#e5534b" + }, + "NOT_FOUND": { + "label": "Not found", + "color": "#8b93a7" + }, + "UNTESTABLE": { + "label": "Untestable", + "color": "#7d8fd6" + } + } + } + ] +} diff --git a/export/fixtures/report-site/public/reports/demo-factcheck/page.json b/export/fixtures/report-site/public/reports/demo-factcheck/page.json @@ -1,284 +0,0 @@ -{ - "format": "archilyzer-report-page", - "version": 1, - "id": "demo-factcheck", - "kind": "factcheck", - "series": "Demo Checks", - "title": "Checking an example article", - "subtitle": "Four claims about a demo channel, tested against what was said on air", - "summary": "The article makes four claims. The recordings support one, partly support another, and contradict a third; the fourth cannot be tested. The host said the opening date out loud [on stream](cite:c01), and later [repeated it](cite:au1).", - "method": "Each claim was searched for in the channel's transcripts and the guest's podcast, and checked against the city's public records.", - "published": "2026-10-01", - "updated": "2026-10-04", - "subject": "s0", - "sources": { - "s0": { - "id": "s0", - "kind": "article", - "title": "An example article about a demo channel", - "url": "https://example.org/articles/demo", - "publisher": "Example Gazette", - "author": "A. Writer", - "date": "2026-09-20", - "note": "Read in the edition published on the day; it has since been revised.", - "accent": "#8a6fb0", - "archives": [ - { - "label": "archive.org", - "url": "https://web.archive.org/web/2026/https://example.org/articles/demo", - "context": "as published on the day" - } - ] - } - }, - "verdicts": { - "CORROBORATED": { - "label": "Corroborated", - "color": "#3fbf7f" - }, - "PARTLY": { - "label": "Partly true", - "color": "#e3b23c" - }, - "CONTRADICTED": { - "label": "Contradicted", - "color": "#e5534b" - }, - "NOT_FOUND": { - "label": "Not found", - "color": "#8b93a7" - }, - "UNTESTABLE": { - "label": "Untestable", - "color": "#7d8fd6" - } - }, - "citations": { - "c01": { - "kind": "video", - "id": "c01", - "number": 1, - "quote": "The bridge opened in the spring of twenty nineteen, I was there for it.", - "verification": { - "quoteScore": 0.97, - "quoteCheckedAt": "2026-10-04T12:00:00Z", - "voiceChecked": true, - "method": "cue-window v1" - }, - "origin": "added", - "moment": "demo-channel/abc123/3126.00-3151.00", - "href": "/m/demo-channel/abc123/3126.00-3151.00/", - "start": 3126, - "end": 3151, - "record": { - "channel": "demo-channel", - "channelTitle": "Demo Channel", - "id": "abc123", - "title": "Demo stream: the bridge, the move, and the mail", - "date": "2026-01-10", - "platform": "youtube", - "originalUrl": "https://media.example.org/demo-channel/abc123?t=3126" - }, - "poster": "/reports/demo-factcheck/stills/poster.png" - }, - "au1": { - "kind": "audio", - "id": "au1", - "number": 2, - "quote": "Like I said before, spring twenty nineteen.", - "speaker": "The guest", - "verification": { - "quoteScore": 0.88, - "quoteCheckedAt": "2026-10-04T12:00:00Z" - }, - "moment": "demo-podcast/ep-042/610.50-628.00", - "href": "/m/demo-podcast/ep-042/610.50-628.00/", - "start": 610.5, - "end": 628, - "record": { - "channel": "demo-podcast", - "channelTitle": "Demo Podcast", - "id": "ep-042", - "title": "Episode 42: a guest looks back", - "date": "2026-02-02", - "originalUrl": "https://media.example.org/demo-podcast/ep-042?t=610" - } - }, - "a01": { - "kind": "source", - "id": "a01", - "number": 3, - "quote": "He opened the bridge himself in 2018.", - "sourceId": "s0", - "sourceTitle": "An example article about a demo channel", - "sourceAccent": "#8a6fb0", - "image": "/reports/demo-factcheck/stills/a01.png", - "href": "https://example.org/articles/demo" - }, - "w01": { - "kind": "page", - "id": "w01", - "number": 4, - "quote": "Opened to traffic: April 2019.", - "note": "The city's own record of the opening.", - "origin": "subject", - "href": "https://example.org/city/bridge-history", - "title": "Bridge history — city records", - "archiveUrl": "https://web.archive.org/web/2026/https://example.org/city/bridge-history" - }, - "a02": { - "kind": "source", - "id": "a02", - "number": 5, - "quote": "He has said many times that he would move away.", - "sourceId": "s0", - "sourceTitle": "An example article about a demo channel", - "sourceAccent": "#8a6fb0", - "href": "https://example.org/articles/demo" - }, - "p01": { - "kind": "post", - "id": "p01", - "number": 6, - "quote": "Never said I would move. Not once.", - "date": "2025-03-14", - "moment": "demo-social/1234567890", - "href": "/m/demo-social/1234567890/", - "record": { - "channel": "demo-social", - "channelTitle": "Demo Social", - "id": "1234567890", - "date": "2025-03-14", - "platform": "x", - "originalUrl": "https://media.example.org/demo-social/1234567890" - }, - "author": "@demo_account", - "text": "Never said I would move. Not once.\n\nPosted to settle it.", - "shot": "/media/posts/demo-social/1234567890/shot.png" - } - }, - "entries": [ - { - "id": "update-mail", - "date": "2026-10-04", - "title": "A reader asked about another year", - "body": "No other year turns up: every time he dates the opening it is the year he said [on stream](cite:c01)." - }, - { - "id": "update-opening", - "date": "2026-10-02", - "updated": "2026-10-04", - "title": "The opening date, said on air", - "body": "The host gave the year of the opening [on stream](cite:c01), the year the city's record names." - } - ], - "sections": [ - { - "id": "bridge", - "title": "The bridge", - "body": "The article's first chapter is about the bridge.", - "slide": { - "points": [ - "The article dates the opening to 2018", - "He says 2019 on stream, and [the city's record](cite:w01) agrees" - ], - "cite": "w01" - }, - "claims": [ - { - "id": "claim-1", - "title": "“He opened it himself”", - "text": "He opened the bridge himself in 2018.", - "verdict": "CONTRADICTED", - "gist": "It opened in 2019, as he says on stream and the city's record shows.", - "sourceQuote": "a01", - "findings": "He was there, but the bridge opened in 2019: he says so [on stream](cite:c01), and the [city's record](cite:w01) agrees.", - "citations": [ - "c01", - "w01", - "au1" - ] - }, - { - "id": "claim-2", - "text": "He went back to the bridge every year.", - "verdict": "PARTLY", - "gist": "Once is on record; every year is not.", - "findings": "He mentions going back [once](cite:au1); nothing in the recordings says every year.", - "citations": [ - "au1" - ], - "slide": { - "title": "Every year?", - "points": [ - "He mentions going back [once](cite:au1)", - "Nothing in the recordings says every year" - ] - } - } - ] - }, - { - "id": "moving", - "title": "Moving away", - "claims": [ - { - "id": "claim-3", - "text": "He has said many times that he would move away.", - "verdict": "CONTRADICTED", - "gist": "He denies ever saying it.", - "sourceQuote": "a02", - "findings": "The article [puts it as a habit](cite:a02); he [denies it outright](cite:p01).", - "citations": [ - "p01" - ], - "slide": { - "cite": "p01", - "layout": "quote" - } - }, - { - "id": "claim-4", - "text": "He privately regrets it.", - "verdict": "UNTESTABLE", - "flag": "No source given", - "findings": "Nothing public speaks to a private feeling.", - "citations": [] - }, - { - "id": "claim-5", - "text": "He was at the opening.", - "verdict": "CORROBORATED", - "findings": "He says [he was there](cite:c01).", - "citations": [ - "c01" - ] - } - ] - } - ], - "downloads": { - "html": "/reports/demo-factcheck/report.html", - "pdf": "/reports/demo-factcheck/report.pdf", - "md": "/reports/demo-factcheck/report.md", - "slides": "/reports/demo-factcheck/slides.html", - "slides-pdf": "/reports/demo-factcheck/slides.pdf", - "zip": "/reports/demo-factcheck/evidence-pack.zip", - "json": "/reports/demo-factcheck/citations.json", - "csv": "/reports/demo-factcheck/citations.csv" - }, - "feeds": { - "rss": "https://reports.example.org/reports/demo-factcheck/feed.xml", - "json": "https://reports.example.org/reports/demo-factcheck/feed.json" - }, - "history": { - "revision": 2, - "date": "2026-10-04T12:00:00Z", - "href": "/reports/demo-factcheck/history/", - "current": true - }, - "slides": { - "title": "Five claims, checked against what was said on air", - "closing": "Every citation opens the moment it quotes." - } -} diff --git a/export/fixtures/report-site/public/reports/index.json b/export/fixtures/report-site/public/reports/index.json @@ -1,58 +0,0 @@ -{ - "format": "archilyzer-report-index", - "version": 1, - "reports": [ - { - "id": "demo-factcheck", - "kind": "factcheck", - "series": "Demo Checks", - "title": "Checking an example article", - "subtitle": "Four claims about a demo channel, tested against what was said on air", - "published": "2026-10-01", - "updated": "2026-10-04", - "href": "/reports/demo-factcheck/", - "citationCount": 6, - "claimCount": 5, - "tally": [ - { - "verdict": "CORROBORATED", - "count": 1 - }, - { - "verdict": "PARTLY", - "count": 1 - }, - { - "verdict": "CONTRADICTED", - "count": 2 - }, - { - "verdict": "UNTESTABLE", - "count": 1 - } - ], - "verdicts": { - "CORROBORATED": { - "label": "Corroborated", - "color": "#3fbf7f" - }, - "PARTLY": { - "label": "Partly true", - "color": "#e3b23c" - }, - "CONTRADICTED": { - "label": "Contradicted", - "color": "#e5534b" - }, - "NOT_FOUND": { - "label": "Not found", - "color": "#8b93a7" - }, - "UNTESTABLE": { - "label": "Untestable", - "color": "#7d8fd6" - } - } - } - ] -} diff --git a/export/fixtures/report-site/write.ts b/export/fixtures/report-site/write.ts @@ -3,7 +3,7 @@ // // pnpm --filter export exec tsx fixtures/report-site/write.ts // -// The stills (public/reports/demo-factcheck/stills/*.png), the post's shot and +// The stills (public/pages/demo-factcheck/stills/*.png), the post's shot and // the two evidence clips (public/media/: a few seconds of lavfi test pattern // and tone, H.264/AAC) are committed files, not generated here. diff --git a/homepage/app/lib/articles.ts b/homepage/app/lib/articles.ts @@ -1,7 +1,7 @@ import fs from "node:fs"; import path from "node:path"; import { createReportReader, reportMetadata } from "yt-dlp-transcript-common/lib/report/reader-server"; -import { ARTICLES_BASE } from "yt-dlp-transcript-common/lib/report/routes"; +import { ARTICLES_REPORTS_BASE } from "yt-dlp-transcript-common/lib/report/routes"; // THE ARTICLES (release 26 A3): the reports the project homepage publishes, // read by the shared reader (common/lib/report/reader-server.ts) under @@ -24,7 +24,7 @@ export function articlesPublicDir( return publicDir; } -const reader = createReportReader({ publicDir: () => articlesPublicDir(), base: ARTICLES_BASE }); +const reader = createReportReader({ publicDir: () => articlesPublicDir(), base: ARTICLES_REPORTS_BASE }); export const ARTICLES_ROUTE_BASE = reader.base; export const readArticleIndex = () => reader.readReportIndex(); diff --git a/homepage/e2e/fixture-articles.ts b/homepage/e2e/fixture-articles.ts @@ -11,7 +11,7 @@ import path from "node:path"; // // Its data is export's report-site fixture (export/fixtures/report-site/ // public: the view JSON compose writes), as compose writes it for the homepage: -// under /articles/ rather than /reports/, and one moment opening in the listed +// under /articles/ rather than a site's /pages/, and one moment opening in the listed // public archive that publishes its channel (an absolute corpusUrl) — the // others in none. The binary media is not copied: nothing here is served. @@ -24,7 +24,7 @@ export const FIXTURE_LINKED_MOMENT = "demo-channel/abc123/3126.00-3151.00"; const SOURCE = path.resolve(process.cwd(), "..", "export", "fixtures", "report-site", "public"); function copyJson(from: string, to: string, edit?: (v: Record<string, unknown>) => void): void { - const text = fs.readFileSync(from, "utf8").replaceAll('"/reports/', '"/articles/'); + const text = fs.readFileSync(from, "utf8").replaceAll('"/pages/', '"/articles/'); const value = JSON.parse(text) as Record<string, unknown>; edit?.(value); fs.mkdirSync(path.dirname(to), { recursive: true }); @@ -43,8 +43,8 @@ function walk(dir: string, rel = ""): string[] { export function writeFixtureArticles(dest: string): void { clearFixtureArticles(dest); - for (const rel of walk(path.join(SOURCE, "reports"))) { - copyJson(path.join(SOURCE, "reports", rel), path.join(dest, "articles", rel)); + for (const rel of walk(path.join(SOURCE, "pages"))) { + copyJson(path.join(SOURCE, "pages", rel), path.join(dest, "articles", rel)); } for (const rel of walk(path.join(SOURCE, "m"))) { copyJson(path.join(SOURCE, "m", rel), path.join(dest, "m", rel), (v) => { diff --git a/mcp/src/reports.test.ts b/mcp/src/reports.test.ts @@ -90,12 +90,12 @@ async function writeSite(opts: { cited: boolean; reports: boolean }): Promise<st ...(opts.cited ? { scope: "cited", audience: "public" } : {}), }, channels: opts.cited ? [] : [{ slug: "demo-channel", name: "Demo Channel", videoCount: 1 }], - ...(opts.reports ? { reports: { index: `${ORIGIN}/reports/index.json`, count: 1 } } : {}), + ...(opts.reports ? { reports: { index: `${ORIGIN}/pages/index.json`, count: 1 } } : {}), }, }; if (opts.reports) { - files["reports/index.json"] = INDEX; - files["reports/demo-report/page.json"] = VIEW; + files["pages/index.json"] = INDEX; + files["pages/demo-report/page.json"] = VIEW; } for (const [rel, body] of Object.entries(files)) { const file = path.join(dir, rel); @@ -147,7 +147,7 @@ test("list_reports names each report with its counts, tally and page", async () assert.match(out, /- demo-report · A demo fact-check — Of an article/); assert.match(out, /factcheck · 1 claim\(s\) · 3 citation\(s\) · 2026-10-01/); assert.match(out, /verdicts: Contradicted 1/); - assert.match(out, new RegExp(`${ORIGIN}/reports/demo-report/`)); + assert.match(out, new RegExp(`${ORIGIN}/pages/demo-report/`)); } finally { await client.close(); await rm(dir, { recursive: true, force: true }); @@ -174,7 +174,7 @@ test("get_report: claims with their citations' quote, original and moment URLs", assert.match(text, new RegExp(`moment: ${ORIGIN}/m/demo-channel/abc123/61\\.00-75\\.50/`)); assert.match(text, /original: https:\/\/social\.example\/123/); assert.match(text, new RegExp(`moment: ${ORIGIN}/m/demo-social/123/`)); - assert.match(text, new RegExp(`page: ${ORIGIN}/reports/demo-report/`)); + assert.match(text, new RegExp(`page: ${ORIGIN}/pages/demo-report/`)); assert.match(text, /## Section two \(#two\)/); const one = (await call(client, "get_report", { report: "demo-report", section: "two" })).text; diff --git a/mcp/src/reports.ts b/mcp/src/reports.ts @@ -1,8 +1,9 @@ // Cited reports over MCP: list_reports / get_report, and the one sentence every // discovery tool says about a source's reports. // -// A site may publish reports (corpus spec 5): /reports/index.json lists them -// and /reports/<id>/page.json is one report with every citation resolved +// A site may publish reports (corpus spec 5) as its pages: /pages/index.json +// lists them and /pages/<id>/page.json is one report with every citation +// resolved (/reports/ before release 26) // (common/lib/report/views.ts — the export site's pages read the same files). // A CITED site publishes nothing else: no channels, no shards. Its empty // channel list is the site's shape, not a failure, and a tool that reported "no @@ -100,7 +101,7 @@ export function renderReportIndex( if (r.reports.length === 0) { return r.scope === "cited" ? `${label} is a cited-only site, but its report index lists no reports.` - : `${label} publishes no reports (no /reports/index.json — none published, or a site built before corpus spec 5).`; + : `${label} publishes no reports (no /pages/index.json — none published, or a site built before corpus spec 5).`; } const head = r.scope === "cited" diff --git a/plans/FACTS.md b/plans/FACTS.md @@ -173,7 +173,7 @@ A grep for either word finds all three; read the file before assuming which. | Which | Where | What it is | | --- | --- | --- | -| A cited (report-only) site | `common/lib/siteSchema.ts` — `isCitedSite` (`search: false`); corpus.json `site.scope: "cited"`; `isCitedBuild` / `citedBuildProblem` (`lib/builtExport.ts`) | A site that publishes only its reports and the moments they cite. | +| A cited (report-only) site | `common/lib/siteSchema.ts` — `isCitedSite` (`search: false`); corpus.json `site.scope: "cited"`; `isCitedBuild` / `citedBuildProblem` (`lib/builtExport.ts`) | A site that publishes only its pages (site.json `pages`, its reports at `/pages/<id>/` — release 26 A5; its home is the first) and the moments they cite. A save with no pages is refused (`siteSearchProblem`). | | A cited-only channel | `site.json` `citedChannels`; `siteCitableChannelSlugs`, `isCitedOnlyChannel` (`lib/siteSchema.ts`); `builtCitedOnlyProblem` (`lib/builtExport.ts`) | A channel a site's reports may cite without the site publishing it: its moments and clips publish, its corpus does not. `siteChannelSlugs` (and `publishedMemberSlugs`) stay pool-only. | | `citedMoments` | `common/publish/reportMedia.ts` | The moments a site's reports cite, one per span, with the citations that cite each. | | Compose's `citedSite` | `common/publish/composeReports.ts` `resolveSiteReports` | The local `isCitedSite(site)` (renamed from `cited` in release 23). | diff --git a/plans/report-sites.md b/plans/report-sites.md @@ -1,5 +1,11 @@ # Report sites — a site built around cited reports +**Release 26 A5 (plans/reports-on-homepage.md):** a site's published reports are its `pages` (site.json +`pages`; `reports` read as it for release 26 only), served at `/pages/<id>/` (the views under `public/pages/`), +linked from the header by title; the Reports index is gone, a search-off site's home is its first page, and a +search-off site with no pages is refused on save. The `/reports/` routes and the `reports` key below are the +model before it. + Status: BUILT — R0–R8 merged 2026-10-05 (plus R4b page size); first private report site built locally. RH (per-report revision history) built 2026-10-05, see "History". Report-only is derived from a per-site `search` switch (search off); export's `start` serves moment dirs (`scripts/serve-out.mjs`). Follow-ups: cited corpus.json still describes shards, voice checks recorded in citations, saveSiteAction onto patchSite. diff --git a/plans/reports-on-homepage.md b/plans/reports-on-homepage.md @@ -174,3 +174,83 @@ neither app's code changed. site's `/pages/` (A5) need the base decided there. A5's `reports` → `pages`: the move script reads `pages ?? reports` and writes `reports` with patchSite, and a search-off site emptied by the move would be refused by A5's validation — the merge adapts both. REPORT.md still names site.json `reports`. + +### A1, as shipped + +The report renderer shared (branch `r26/renderer`, Lane A): one renderer for a site's pages and the homepage's +articles. + +- **Components** — `export/app/components/reports/{ReportIndex,ReportArticle,MomentArticle,ReportHistory,parts}.tsx` + moved to `common/components/report/`. `ReportArticle` and `ReportHistory` take `base` (the view switch's + page.json, the history's links); `MomentArticle` takes `corpusHref` (the corpus link resolver; default the view's + `corpusUrl`); `ReportIndex` takes `empty` (an empty index's words). `NotOnCitedSite` stays in export + (`export/app/components/NotOnCitedSite.tsx`): it is a site's. +- **Reader** — `common/lib/report/reader-server.ts`: `createReportReader({publicDir, base})` (index, ids, page, + history, the only/first report, moments) and `reportMetadata`, shaped as Next's `Metadata` without importing + `next` (its globals would reach every package importing common/lib). `export/app/lib/reports.ts` binds it to the + site's public dir and base. +- **Base** — `common/lib/report/routes.ts`: `ReportBase` (`/<segments>/`), `SITE_REPORTS_BASE`, `isReportBase`, + `reportBaseDir`. Every path helper in `views.ts` and `revisions.ts` takes the base last, defaulting to a site's. +- **Export renders what it did** — the cited fixture built before and after: the same 17 HTML files; with build ids + and chunk names normalised, 15 byte-identical, the other two differing only in the RSC client-chunk list of the + view switch and the second revision's commit (the fixture's report.pdf carries a creation date, so that commit + differs run to run); the rendered markup (scripts stripped) 17/17 identical; CSS identical. + +| Commit | What | +|---|---| +| 8535c36d | common: the report renderer shared — components and reader in common, parameterised by base | + +**Gates.** tsc clean; common 3782/3782 (+10: reader-server.test.ts 7, renderer.test.ts 3; the architecture test +green); export unit 118/118; export `e2e:report` 46/46 (36.7 s, one run, foreground); the byte comparison above. + +### A5, as shipped + +A site's reports are its pages (branch `r26/renderer`, Lane A), and the base is a host's. + +- **`pages`** — site.json `pages` (ordered report ids) replaces `reports`; SITE.md regenerated. Four live site.json + files carried `reports` (key names counted offline, nothing written), so for release 26 only a file's `reports` + reads as `pages` when it has none, and is never written; a patch naming `reports` is refused + (`site.json "reports" is now "pages"`) so a generator outside the repo fails loudly instead of being dropped. + `citedChannels` unchanged. +- **Served at `/pages/<id>/`** — `SITE_REPORTS_BASE` is `/pages/`: the views under `public/pages/`, the routes + `export/app/pages/[reportId]` and `…/history`, the audits (`pages/` in the cited allowlist, the history-clone + audit, the hub's report-data check), the `_headers` feed types, corpus.json's `reports.index`, llms.txt, the + sitemap. Compose still clears a `public/reports/` an older compose left; a cited build holding one is refused. +- **Nav by title, no index** — the header links each page by its title after Ask AI (a search-off site: its pages + alone, none with one). The Reports index route is gone, and so is the search-off home-as-index: a search-off + site's home is its first page (with none, "No pages"). +- **D5** — `siteSearchProblem`: a save (writeSite, so the form, patchSite and every writer) with search off and no + pages is refused. The editor's site form lists **Pages**. +- **The host's base (the orchestrator's merge asks)** — `ReportHost.base`: `/pages/` for a site, `/articles/` + (`ARTICLES_REPORTS_BASE`) for the homepage, threaded through compose (every path written, index entries, cited-in + hrefs, stills, video, downloads, feeds, the history page, view and clone; `reportPublicEntries(base)` is what it + clears), the exports (the page link, the evidence pack's report files) and the history. `siteReportHost` + publishes `pages`; `reports check` and umtool's sites views read it. +- **A7's order hazard** — the move script writes `pages` and RETIRES a search-off site it empties: the patch that + drops its last page turns search on in the same write, so it saves as an empty site (no channels, no pages) + rather than being refused; the plan line reads `retire <site>: search off and no pages left — saved with search + on, as an empty site; delete it on /sites`. Nothing is deleted by the script. +- **Reserved site ids** — `articles` and `new` are refused by writeSite and the editor's save + (`reservedSiteIdProblem`): the editor's `/sites/articles` and `/sites/new` and umtool's `articles/<id>` would + hide them. No live site has either id. +- **ComposeReportsError** names its host: "the site's pages" or "the articles". + +| Commit | What | +|---|---| +| dad37ab9 | sites: reports become pages — site.json `pages`, served at /pages/<id>/, linked by title | +| 0a7ad151 | merge r26/integration; the host's base, A7's retire, reserved ids, the error's wording | + +**Gates.** tsc clean per commit. common 3806/3806; export unit 117/117 (the forward-to-home and index tests +replaced by first-page and nav-by-title ones); editor unit 264/264; mcp 306/306; homepage unit 23/23; test:scripts +836 (833 pass, 3 skipped). Builds: `pnpm --filter export exec next build` rc 0 (`/pages/[reportId]`, +`/pages/_none` placeholders; the one Turbopack NFT warning, via `common/lib/ttsApps.ts`, predates this branch); +umtool capped build with the corpus linked rc 0 (compiled 8.9 s); the editor's e2e production build (rebuilt by +the sites-crud run). e2e (single runs, foreground): export `e2e:report` 46/46 (32.3 s, fresh build after the +merge); export `header.spec.ts` 33/33 (3.7 min); editor `sites-crud.spec.ts` + `articles.spec.ts` 21/21 (20 + 1; +sites-crud gained "a site with search off and no pages is refused on save" and checks the legacy key saves as +`pages`). + +**Left.** umtool's e2e sites fixture (`umtool/e2e/fixtures/sites-fixture.mjs`) still writes `reports` — read as +`pages` this release; it should write `pages` before the legacy read is removed. The editor's Reports tab still +says "Reports" (the tab keeps site pages, A6). corpus.json's spec is not bumped for the `/pages/` paths: no report +was ever published, and readers follow `reports.index`. diff --git a/umtool/app/sites/[site]/[report]/page.tsx b/umtool/app/sites/[site]/[report]/page.tsx @@ -27,7 +27,7 @@ export default async function SiteArticlePage({ { href: "/sites", label: "articles" }, { href: `/sites/${site.siteId}`, label: site.siteId }, ]} - published={(site.reports ?? []).includes(reportId)} + published={(site.pages ?? []).includes(reportId)} /> ); } diff --git a/umtool/docs/sites.md b/umtool/docs/sites.md @@ -17,7 +17,7 @@ the one file it writes there is a report's `notes.json` (docs/notes.md). - **Site and reports**: common's `listSites`/`getSite` (site.json, the editor's defaults), `listReportDirs` (the enumerator the editor's Reports tab uses), each `report.json` through the report validator. **Published** = named in site.json - `reports`, in that order; every other report directory is a **draft**. + `pages`, in that order; every other report directory is a **draft**. - **Source** (`lib/articles/sources.mjs`): the draft under `~/reports/<ws>/polemics/drafts/` whose `id` or file name is the report id, `polemic-` allowed on either side, preferring a workspace whose generator names diff --git a/umtool/e2e/fixtures/sites-fixture.mjs b/umtool/e2e/fixtures/sites-fixture.mjs @@ -10,7 +10,7 @@ // polemic-alpha PUBLISHED: summary, two sections, cites sitechan/sv1 // (a clip window on disk: plays) and sitechan/sv2 (cues, // no media: the fetch_clip line); video.mp4 + poster.jpg -// polemic-beta a DRAFT (not in site.json's reports) +// polemic-beta a DRAFT (not in site.json's pages) // sites/pub public. Reports: // gamma PUBLISHED, one section, no citations // <dest>/sitews/ the WORKSPACE (a direct child of REPORTS_ROOT, which the @@ -103,8 +103,8 @@ export function makeSitesFixture({ dest, channels }) { clip(path.join(channels, "sitechan", "data", "sv1", "clips", "0.00-12.00.mp4"), 12, 523); // ---- the sites ------------------------------------------------------------ - put(path.join(sites, "priv", "site.json"), siteJson("priv", "Private Fixture", { audience: "private", search: false, reports: ["polemic-alpha"] })); - put(path.join(sites, "pub", "site.json"), siteJson("pub", "Public Fixture", { reports: ["gamma"] })); + put(path.join(sites, "priv", "site.json"), siteJson("priv", "Private Fixture", { audience: "private", search: false, pages: ["polemic-alpha"] })); + put(path.join(sites, "pub", "site.json"), siteJson("pub", "Public Fixture", { pages: ["gamma"] })); const alphaDir = path.join(sites, "priv", "reports", "polemic-alpha"); put(path.join(alphaDir, "report.json"), { diff --git a/umtool/lib/articles/sites.ts b/umtool/lib/articles/sites.ts @@ -19,7 +19,7 @@ import { linkedProjects, videoProjects } from "./links.mjs"; // (site.json through getSite, so a default is the editor's default), each // report directory through common's listReportDirs (the editor's report tab // uses the same enumerator), each report.json through the report document's -// own validator, and published-or-draft from the site's `reports` order. Plus +// own validator, and published-or-draft from the site's `pages` order. Plus // what only umtool knows: its notes, its source draft, its video project. // // READ-ONLY. The one thing umtool writes under SITES_DIR is a notes.json, and @@ -163,9 +163,9 @@ function siteFlags(site: Site) { /** One site with every article, published (in the site's order) then drafts (by id). */ export async function readSiteRow(site: Site, projects?: Awaited<ReturnType<typeof videoProjects>>): Promise<SiteRow> { const all = projects ?? (await videoProjects(REPORTS_ROOT)); - const published = new Set(site.reports ?? []); + const published = new Set(site.pages ?? []); const dirs = await listReportDirs(sitesPaths(), site.siteId); - const ids = [...(site.reports ?? []), ...dirs.filter((d) => !published.has(d))]; + const ids = [...(site.pages ?? []), ...dirs.filter((d) => !published.has(d))]; const articles = await Promise.all(ids.map((id) => articleRow(site.siteId, id, published, all))); return { siteId: site.siteId,