// What ingredient-rail.spec.ts reads (lane L5, the ingredient life-cycle rail): one recording of the // fixture corpus used by TWO projects, and a Rumble recording cited by its embed id. // // channels/railchan/ a YouTube channel of its own (fetch-windows serves it: editor-stub-fetch-windows.mjs) // data/railvid/ metadata.info.json (its webpage_url past a 64 KB formats array: the head reader never sees it), // transcript.cues.json (300 s, 50 cues), transcript.en.vtt, download-outcome.json, availability.json, // metadata.history.json, find-clips.json (the clip finder found it: rail-a), // clips/10.00-40.00.mp4 (+ sidecar: asked for rail-a's ra1), clips/200.00-230.00.mp4 (+ sidecar: // asked for a clip no project has now -- the orphan) // channels/railrumble/ platform rumble: data/v7rslug1/ is the URL slug, its metadata's id the // embed id v7rembd1, which rail-r cites // // reports/rail-a ra1 railvid 12-20 (quote; ok in quote-check.json), ra2 railvid 100-110 (quote; no window holds it) // takes/v1: a saved version (base.manifest.json) holding ra1, rendered (render.json done, preview.mp4) // reports/rail-b rb1 railvid 15-25, its QR link checked ok (out/links.json) // reports/rail-r rr1 railrumble/v7rembd1 30-40 // // The site the QRs link is http://127.0.0.1:9 (cut-integrity-fixture's placeholder): a link check there is // refused at once, on this machine. The spec WRITES (a link check rewrites rail-b's out/links.json; a quote // check may write rail-a's quote-check.json): these projects are its own. // // Synthetic, like every fixture. import { copyFileSync, mkdirSync, writeFileSync } from "node:fs"; import path from "node:path"; import { archiveMomentUrl } from "umtool-report-to-video/site-links"; export const RAIL_SITE = "http://127.0.0.1:9"; const write = (dir, name, doc) => { mkdirSync(dir, { recursive: true }); writeFileSync(path.join(dir, name), typeof doc === "string" ? doc : JSON.stringify(doc, null, 2) + "\n"); }; /** @param {{ reports: string, channels: string, manifest: Function, cachedWindow: string }} o */ export function makeIngredientRailFixture({ reports, channels, manifest, cachedWindow }) { // ── the corpus ── const ch = path.join(channels, "railchan"); write(ch, "config.json", { platform: "youtube" }); const v = path.join(ch, "data", "railvid"); const formats = Array.from({ length: 1500 }, (_, i) => ({ format_id: String(i), url: `https://media.example/${"x".repeat(40)}/${i}` })); write(v, "metadata.info.json", JSON.stringify({ id: "railvid", title: "The Rail Recording", formats, webpage_url: "https://www.youtube.com/watch?v=railvid", duration: 300 })); const cues = Array.from({ length: 50 }, (_, i) => ({ start: i * 6, end: i * 6 + 5.5, text: `the rail recording says line ${i}.` })); write(v, "transcript.cues.json", JSON.stringify({ version: 2, source: "vtt", vttFile: "transcript.en.vtt", transcriptFormat: "vtt", id: "railvid", channelSlug: "railchan", title: "The Rail Recording", uploadDate: "20261101", duration: 300, platform: "youtube", cues })); write(v, "transcript.en.vtt", "WEBVTT\n\n00:00:00.000 --> 00:00:05.500\nthe rail recording says line 0.\n"); write(v, "download-outcome.json", { videoId: "railvid", webpageUrl: "https://www.youtube.com/watch?v=railvid", status: "ok", startedAt: "2026-11-01T10:00:00.000Z", finishedAt: "2026-11-01T10:00:20.000Z", attempts: [{ n: 0, kind: "primary" }] }); write(v, "availability.json", { checkedAt: "2026-11-02T00:00:00.000Z", availability: "public", history: [] }); write(v, "metadata.history.json", { entries: [{ at: "2026-11-03T00:00:00.000Z", by: "refresh", from: { sha256: "a", bytes: 1 }, to: { sha256: "b", bytes: 2 }, changed: {}, added: {}, removed: {}, counters: {}, volatile: [] }] }); write(v, "find-clips.json", { version: 1, at: "2026-11-04T00:00:00.000Z", jobId: "job-1", project: "reports/rail-a", url: "/projects/reports/rail-a/clip-editor", created: true, segments: [{ id: "s1", from: 0, to: 120 }], steps: [] }); mkdirSync(path.join(v, "clips"), { recursive: true }); copyFileSync(cachedWindow, path.join(v, "clips", "10.00-40.00.mp4")); write(path.join(v, "clips"), "10.00-40.00.json", { requestedBy: "umtool:reports/rail-a", clipId: "ra1", reason: "The Rail A Fixture", fetchedAt: "2026-11-05T00:00:00.000Z", bytes: 1 }); copyFileSync(cachedWindow, path.join(v, "clips", "200.00-230.00.mp4")); write(path.join(v, "clips"), "200.00-230.00.json", { requestedBy: "umtool:reports/gone", clipId: "gone1", fetchedAt: "2026-11-05T00:00:00.000Z" }); const rch = path.join(channels, "railrumble"); write(rch, "config.json", { platform: "rumble" }); const rv = path.join(rch, "data", "v7rslug1"); write(rv, "metadata.info.json", JSON.stringify({ id: "v7rembd1", title: "The Rumble Rail Recording", webpage_url: "https://rumble.com/v7rslug1-the-rumble-rail-recording.html" })); write(rv, "transcript.cues.json", JSON.stringify({ version: 2, source: "whisper", id: "v7rembd1", title: "The Rumble Rail Recording", duration: 120, cues: [{ start: 0, end: 4, text: "rumble." }] })); // ── the projects ── // provenance.siteOrigin stays public-looking (a loopback origin is a BLOCKING decision, projects.spec), and each // clip's citeUrl names RAIL_SITE explicitly -- the moment URL the origin would have derived, on the placeholder. const PUBLIC = "https://archive.example"; const origin = { siteOrigin: PUBLIC, channelSlug: "railchan" }; const cited = (m) => { for (const e of m.timeline) e.citeUrl = archiveMomentUrl({ ...e, channel: e.channel ?? m.provenance.channelSlug }, m.provenance, e.start ?? 0, { origin: RAIL_SITE }); return m; }; const a = cited(manifest("rail-a", "The Rail A Fixture", origin, [ { type: "clip", id: "ra1", video: "railvid", start: 12, end: 20, cite: 12, section: 0, quote: "the rail recording says line 2." }, { type: "clip", id: "ra2", video: "railvid", start: 100, end: 110, cite: 100, section: 0, quote: "the rail recording says line 17." }, ])); const aDir = path.join(reports, "rail-a"); write(aDir, "video.manifest.json", a); const base = manifest("rail-a", "The Rail A Fixture", origin, [a.timeline[0]]); const take = path.join(aDir, "takes", "v1"); write(take, "base.manifest.json", base); write(take, "take.json", { id: "v1", group: "takes", order: 1, label: "Version 1", kind: "different", preview: "preview.mp4", window: "full", style: null, patch: null, version: true, draft: true, seconds: 8, builtAt: "2026-11-06T00:00:00.000Z" }); copyFileSync(cachedWindow, path.join(take, "preview.mp4")); write(take, "render.json", { version: 1, state: "done", project: "reports/rail-a", take: "v1", mp4: "preview.mp4", seconds: 8, startedAt: "2026-11-06T00:00:00.000Z", endedAt: "2026-11-06T00:01:00.000Z", exitCode: 0, stage: "done", percent: 100 }); write(aDir, "quote-check.json", { version: 1, checkedAt: "2026-11-06T12:00:00.000Z", clips: { ra1: { status: "ok", offset: 0.02, against: "cues", cut: { from: 12, to: 20 }, quote: "the rail recording says line 2." } } }); const bDir = path.join(reports, "rail-b"); write(bDir, "video.manifest.json", cited(manifest("rail-b", "The Rail B Fixture", origin, [{ type: "clip", id: "rb1", video: "railvid", start: 15, end: 25, cite: 15, section: 0 }]))); write(path.join(bDir, "out"), "links.json", { version: 1, checkedAt: "2026-11-07T00:00:00.000Z", fetched: 1, origins: {}, links: [{ clip: "rb1", url: `${RAIL_SITE}/?v=railchan%2Frailvid&t=15`, state: "ok", origin: RAIL_SITE }] }); const rDir = path.join(reports, "rail-r"); write(rDir, "video.manifest.json", cited(manifest("rail-r", "The Rail Rumble Fixture", { siteOrigin: PUBLIC, channelSlug: "railrumble" }, [{ type: "clip", id: "rr1", video: "v7rembd1", start: 30, end: 40, cite: 30, section: 0 }]))); return { aDir, bDir, rDir }; }