// A LOOKOUT'S PRIVATE FILES NEVER REACH THE MCP (lane/lookout slice 2, // acceptance 2b). The MCP reads a COMPOSED site (`--local`, TRANSCRIPT_LOCAL_DIR, // export/public) or a published one, never the corpus. So the corpus is made // for real — a video with a public cue, its `reading-notes.json` beside it and // a run, a trace and verdicts under `transcripts/.lookouts/`, each with a // marker — indexed and composed with the real build, and every read-only // corpus tool is asked over the composed dir: none answers with a marker or // the private files' names, and each does answer with the video's cue (the // control). common/bin/lookoutPrivacy.test.ts holds the index, compose, // archive and editor-reader halves. import { after, test } from "node:test"; import assert from "node:assert/strict"; import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import path from "node:path"; const ROOT = mkdtempSync(path.join(tmpdir(), "mcp-lookout-privacy-")); Object.assign(process.env, { TRANSCRIPTS_DIR: path.join(ROOT, "transcripts"), SAVED_VIDEOS_DIR: path.join(ROOT, "saved-videos"), SITES_DIR: path.join(ROOT, "transcripts", "sites"), SETTINGS_FILE: path.join(ROOT, "settings.json"), EXPORT_PUBLIC_DIR: path.join(ROOT, "public"), EXPORT_INDEX_DIR: path.join(ROOT, ".export-index"), EXPORT_BUILDS_DIR: path.join(ROOT, ".export-builds"), EDITOR_CHANGELOG_FILE: path.join(ROOT, "editor-CHANGELOG.md"), EXPORT_CHANGELOG_FILE: path.join(ROOT, "export-CHANGELOG.md"), CHARTS_CONFIG_FILE: path.join(ROOT, "chart-templates.json"), SEARCH_ALIASES_FILE: path.join(ROOT, "transcripts", "search-aliases.json"), CURATED_TAGS_FILE: path.join(ROOT, "transcripts", "tags.json"), ARCHILYZER_CONFIG_DIR: path.join(ROOT, "config"), ARCHILYZER_SOURCE_SCRATCH: path.join(ROOT, "source-scratch"), }); delete process.env.ARCHILYZER_INDEX_ALLOW_HELD; after(() => rmSync(ROOT, { recursive: true, force: true })); const { getPaths } = await import("yt-dlp-transcript-common/lib/paths"); const { buildIndex } = await import("yt-dlp-transcript-common/controller/buildIndex"); const { main: composeSite } = await import("yt-dlp-transcript-common/bin/compose-site"); const { READING_NOTES_FILENAME } = await import("yt-dlp-transcript-common/lib/readingNotes-server"); const { LOOKOUTS_DIRNAME } = await import("yt-dlp-transcript-common/lib/lookoutStore"); const { createCorpusTools } = await import("./callTool"); const paths = getPaths(); const CH = "alpha-news"; const VIDEO = "PublicVid01"; const PUBLIC_CUE = "an ordinary public cue about the weather"; const MARKS = ["notesmarkerq7x", "runmarkerz4k", "verdictmarkerw2p", "tracemarkerj9m"]; const writeJson = (file: string, value: unknown) => { mkdirSync(path.dirname(file), { recursive: true }); writeFileSync(file, JSON.stringify(value, null, 2)); }; writeJson(paths.settingsFile, {}); writeJson(path.join(paths.channelsDir, CH, "config.json"), { handling: "youtube", name: "Alpha News", url: "https://www.youtube.com/@alpha-news/videos" }); const video = path.join(paths.channelsDir, CH, "data", VIDEO); writeJson(path.join(video, "metadata.info.json"), { id: VIDEO, title: "A public video", upload_date: "20261103", timestamp: 1793750000, duration: 120, webpage_url: `https://www.youtube.com/watch?v=${VIDEO}`, extractor_key: "Youtube", }); writeFileSync(path.join(video, "transcript.en.vtt"), `WEBVTT\n\n00:00:01.000 --> 00:00:04.000\n${PUBLIC_CUE}\n`); writeJson(path.join(video, READING_NOTES_FILENAME), { version: 1, provenance: { model: "stub-local:1b", promptVersion: 1, chunkChars: 7000, cues: { size: 1, mtimeMs: 1 } }, chunkCount: 1, chunks: [{ index: 0, from: 1, to: 1, covers: `weather ${MARKS[0]}`, items: [{ kind: "claim", quote: `weather ${MARKS[0]}`, start: 1, end: 4, why: "why", voice: "own", people: [] }], dropped: 0 }], complete: true, updatedAt: "2026-11-11T12:00:00.000Z", }); const store = path.join(paths.transcriptsDir, LOOKOUTS_DIRNAME, "example-week"); writeJson(path.join(store, "runs", "20261111T120000Z-abcd.json"), { version: 1, lookoutId: "example-week", ideas: [{ workingTitle: `weather ${MARKS[1]}` }] }); writeFileSync(path.join(store, "runs", "20261111T120000Z-abcd.trace.jsonl"), `${JSON.stringify({ t: `weather ${MARKS[3]}` })}\n`); writeJson(path.join(store, "verdicts.json"), { version: 1, ideas: { "FAKE-TEST-VALUE": { verdict: "make", at: "x", note: `weather ${MARKS[2]}` } } }); writeJson(path.join(paths.sitesDir, "pub", "site.json"), { siteId: "pub", siteTitle: "pub", siteDescription: "fixture", headerTitle: "pub", homeTagline: "", socialLinks: [], groups: [{ id: "default", name: "All channels", selectedByDefault: true }], defaultGroupId: "default", channels: [{ slug: CH, groupId: "default" }], siteUrl: "https://pub.example.test", archives: false, }); test("every read-only corpus tool over the composed site: the cue, never a lookout's file", async () => { await buildIndex({ paths, onLog: () => {} }); const log = console.log; console.log = () => {}; try { await composeSite({ siteId: "pub", paths }); } finally { console.log = log; } const corpus = await createCorpusTools({ source: `local:${paths.exportPublicDir}` }); try { const answers: Record = { list_channels: await corpus.call("list_channels"), search_cue: await corpus.call("search_transcripts", { query: "weather" }), enumerate: await corpus.call("enumerate_matches", { query: "weather" }), get_transcript: await corpus.call("get_transcript", { video_id: VIDEO, channel: CH }), get_transcripts: await corpus.call("get_transcripts", { video_ids: [VIDEO] }), get_video_metadata: await corpus.call("get_video_metadata", { video_id: VIDEO }), }; // A search for each marker finds nothing to quote. for (const mark of MARKS) answers[`search ${mark}`] = await corpus.call("search_transcripts", { query: mark }).catch((e: Error) => e.message); assert.match(answers.get_transcript!, new RegExp(PUBLIC_CUE), "control: the video's cue is read"); assert.match(answers.search_cue!, new RegExp(VIDEO), "control: the cue is searchable"); for (const [tool, text] of Object.entries(answers)) { if (tool.startsWith("search ")) { // The search for a marker may echo its query; it finds no video. assert.ok(!text.includes(VIDEO), `${tool}: a hit`); } else { for (const mark of MARKS) assert.ok(!text.includes(mark), `${tool}: answers with ${mark}`); } for (const name of [READING_NOTES_FILENAME, LOOKOUTS_DIRNAME]) assert.ok(!text.includes(name), `${tool}: names ${name}`); } } finally { await corpus.close(); } });