commit bad168820c5e4011d050c006b931e51d8a7ac9d9
parent 6dee892f51804a7d0a2fa621c364fed2a2344504
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 12 Nov 2026 11:12:13 -0500
lookouts: a lookout's private files never leave -- reading notes and transcripts/.lookouts held off every consumer that enumerates the corpus, by test
Each test plants a video's reading-notes.json and a run, its trace and
verdicts under transcripts/.lookouts/, a marker in each, runs the real
consumer, and searches its whole output -- file names and contents --
with a control that the video's public cue did get through:
- the index build: every export index file and every record of every
LMDB sub-database (common/bin/lookoutPrivacy.test.ts);
- the site compose: the whole public dir;
- the archive bundles: a channel's ZIP, with and without metadata;
- the editor's transcript reader (readVideoCues: `get transcript`, the
MCP's editor-side ask);
- the MCP's read-only corpus tools over the composed site
(mcp/src/lookoutPrivacy.test.ts): list, search, enumerate, get
transcript(s), metadata; a search for a marker finds no video;
- the source mirror: the files in the checkout's working tree beside a
committed /transcripts ignore -- no published object, tree page,
tarball entry or clone holds them (publish/source.test.ts).
No consumer needed a fix: each reads a video's files by name (the cues,
the metadata, transcript.<x>.<y> tracks) and none lists the corpus root.
compose-homepage and compose-hub read no corpus file at all.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
3 files changed, 362 insertions(+), 0 deletions(-)
diff --git a/common/bin/lookoutPrivacy.test.ts b/common/bin/lookoutPrivacy.test.ts
@@ -0,0 +1,196 @@
+// A LOOKOUT'S PRIVATE FILES NEVER LEAVE (lane/lookout slice 2, acceptance 2b):
+// a video's `reading-notes.json` (what the model found reading it) and
+// everything under `transcripts/.lookouts/` (runs, ideas, verdicts, traces)
+// are planted in a temp corpus with a marker in every one, then each consumer
+// that enumerates the corpus's files runs FOR REAL and its whole output is
+// searched — file names and contents — for the names and the markers. A
+// positive control in each (the video's own public cue) proves the consumer
+// did read the video.
+//
+// the index build (controller/buildIndex.ts: export index files + LMDB)
+// the site compose (bin/compose-site.ts: the public dir)
+// the archive bundles (controller/archiveTranscripts.ts: the ZIP)
+// the editor's reader (controller/videoCues.ts readVideoCues — what
+// `pnpm ops get transcript` and the MCP's editor-side
+// transcript ask read)
+// The MCP's own readers are mcp/src/lookoutPrivacy.test.ts (over this same
+// kind of composed dir), the source mirror publish/source.test.ts.
+//
+// Run with: node_modules/.bin/tsx --test common/bin/lookoutPrivacy.test.ts
+
+import { after, test } from "node:test";
+import assert from "node:assert/strict";
+import { mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import { execa } from "execa";
+
+const ROOT = mkdtempSync(path.join(tmpdir(), "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("../lib/paths");
+const { buildIndex } = await import("../controller/buildIndex");
+const { main: composeSite } = await import("./compose-site");
+const { archiveTranscripts } = await import("../controller/archiveTranscripts");
+const { readVideoCues } = await import("../controller/videoCues");
+const { READING_NOTES_FILENAME } = await import("../lib/readingNotes-server");
+const { LOOKOUTS_DIRNAME } = await import("../lib/lookoutStore");
+const { open } = await import("lmdb");
+
+const paths = getPaths();
+const CH = "alpha-news";
+const VIDEO = "PublicVid01";
+const PUBLIC_CUE = "an ordinary public cue about the weather";
+// One marker per private file, so a leak names its source.
+const NOTES_MARK = "notesmarkerq7x";
+const RUN_MARK = "runmarkerz4k";
+const VERDICT_MARK = "verdictmarkerw2p";
+const TRACE_MARK = "tracemarkerj9m";
+const MARKS = [NOTES_MARK, RUN_MARK, VERDICT_MARK, TRACE_MARK];
+const NAMES = [READING_NOTES_FILENAME, LOOKOUTS_DIRNAME, "verdicts.json", "trace.jsonl"];
+const quiet = () => {};
+
+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, "transcript.cues.json"), {
+ version: 2, id: VIDEO, title: "A public video", uploadDate: "20261103", duration: 120, platform: "youtube",
+ webpageUrl: `https://www.youtube.com/watch?v=${VIDEO}`, cues: [{ start: 1, end: 4, text: PUBLIC_CUE }],
+});
+// The private files, as a lookout run writes them.
+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: `covers ${NOTES_MARK}`, items: [{ kind: "claim", quote: `a quote ${NOTES_MARK}`, 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", runId: "20261111T120000Z-abcd", ideas: [{ workingTitle: RUN_MARK }] });
+writeFileSync(path.join(store, "runs", "20261111T120000Z-abcd.trace.jsonl"), `${JSON.stringify({ t: TRACE_MARK })}\n`);
+writeJson(path.join(store, "verdicts.json"), { version: 1, ideas: { "FAKE-TEST-VALUE": { verdict: "make", at: "x", note: VERDICT_MARK } } });
+
+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,
+});
+
+/** Every file under `dir`: its path relative to `dir`, and its bytes as text. */
+function filesUnder(dir: string): { rel: string; text: string }[] {
+ const out: { rel: string; text: string }[] = [];
+ const walk = (d: string) => {
+ for (const e of readdirSync(d, { withFileTypes: true })) {
+ const p = path.join(d, e.name);
+ if (e.isDirectory()) walk(p);
+ else if (e.isFile() || (e.isSymbolicLink() && statSync(p).isFile())) out.push({ rel: path.relative(dir, p), text: readFileSync(p).toString("latin1") });
+ }
+ };
+ walk(dir);
+ return out;
+}
+
+function assertNoLeak(files: { rel: string; text: string }[], where: string) {
+ for (const f of files) {
+ for (const name of NAMES) assert.ok(!f.rel.split(path.sep).includes(name) && !f.rel.endsWith(name), `${where}: a file named ${f.rel}`);
+ for (const mark of MARKS) assert.ok(!f.text.includes(mark), `${where}: ${f.rel} holds ${mark}`);
+ for (const name of [READING_NOTES_FILENAME, LOOKOUTS_DIRNAME]) assert.ok(!f.text.includes(name), `${where}: ${f.rel} names ${name}`);
+ }
+}
+
+const hasPublicCue = (files: { text: string }[]) => files.some((f) => f.text.includes(PUBLIC_CUE));
+
+test("the index build: neither the export index files nor any LMDB record carries a lookout's file", async () => {
+ await buildIndex({ paths, onLog: quiet });
+ const files = filesUnder(paths.exportIndexDir);
+ assert.ok(hasPublicCue(files), "control: the video's cue is in the index");
+ assertNoLeak(files, "export index");
+ // Every record of every sub-database, keys and values (LMDB compresses, so
+ // the bytes on disk are not searched; the records are).
+ const root = open({ path: paths.lmdbPath, maxDbs: 18, compression: true });
+ try {
+ let seenCue = false;
+ for (const name of ["sums", "cues", "subs", "alts", "mtimes", "byChannel", "pageHashes", "subPageHashes", "channelStats", "posts", "postPageHashes", "channelPostsStats", "digests", "digestPageHashes", "channelDigestStats", "videoState", "meta"]) {
+ const db = root.openDB<unknown, unknown>({ name, encoding: "msgpack" });
+ for (const { key, value } of db.getRange()) {
+ const text = JSON.stringify([key, value]);
+ if (text.includes(PUBLIC_CUE)) seenCue = true;
+ for (const mark of MARKS) assert.ok(!text.includes(mark), `LMDB ${name}: a record holds ${mark}`);
+ for (const n of [READING_NOTES_FILENAME, LOOKOUTS_DIRNAME]) assert.ok(!text.includes(n), `LMDB ${name}: a record names ${n}`);
+ }
+ }
+ assert.ok(seenCue, "control: the cue is in LMDB");
+ } finally {
+ await root.close();
+ }
+});
+
+test("the site compose: nothing in the public dir carries a lookout's file", async () => {
+ await buildIndex({ paths, onLog: quiet });
+ const log = console.log;
+ console.log = quiet;
+ try {
+ await composeSite({ siteId: "pub", paths });
+ } finally {
+ console.log = log;
+ }
+ const files = filesUnder(paths.exportPublicDir);
+ assert.ok(hasPublicCue(files), "control: the video's cue is composed");
+ assertNoLeak(files, "public dir");
+});
+
+test("the archive bundles: a channel's ZIP, with metadata, holds the cues and the channel and nothing of a lookout's", async () => {
+ for (const includeMetadata of [true, false]) {
+ const result = await archiveTranscripts({ paths, channelSlugs: [CH], build: { format: "zip", includeMetadata }, onLog: quiet });
+ assert.equal(result.archives.length, 1);
+ const archive = result.archives[0]!.archivePath;
+ const names = (await execa("unzip", ["-Z1", archive])).stdout.split(/\r?\n/).filter((n) => n && !n.endsWith("/"));
+ const files = await Promise.all(names.map(async (rel) => ({ rel, text: (await execa("unzip", ["-p", archive, rel])).stdout })));
+ assert.ok(hasPublicCue(files), "control: the cue is in the ZIP");
+ assertNoLeak(files, `ZIP (metadata=${includeMetadata})`);
+ }
+});
+
+test("the editor's transcript reader: a video's cues, never its reading notes", async () => {
+ const out = await readVideoCues(paths, { slug: CH, id: VIDEO });
+ const text = JSON.stringify(out);
+ assert.ok(text.includes(PUBLIC_CUE), text.slice(0, 400));
+ for (const mark of MARKS) assert.ok(!text.includes(mark), mark);
+ assert.ok(!text.includes(READING_NOTES_FILENAME));
+});
+
+test("the search itself catches a leak: a planted name or marker fails it", () => {
+ assert.throws(() => assertNoLeak([{ rel: path.join("transcripts", CH, READING_NOTES_FILENAME), text: "" }], "x"));
+ assert.throws(() => assertNoLeak([{ rel: path.join(LOOKOUTS_DIRNAME, "a"), text: "" }], "x"));
+ for (const mark of MARKS) assert.throws(() => assertNoLeak([{ rel: "page-0001.json", text: `{"q":"${mark}"}` }], "x"));
+ assert.doesNotThrow(() => assertNoLeak([{ rel: "page-0001.json", text: PUBLIC_CUE }], "x"));
+});
diff --git a/common/publish/source.test.ts b/common/publish/source.test.ts
@@ -612,6 +612,54 @@ test("session links never ship: the trailer goes from every message and file, a
assert.equal(readFileSync(path.join(clone, "rules.md"), "utf8"), "End every commit with:\n\n\nor see [session link removed] for the run.\n");
});
+// A LOOKOUT'S PRIVATE FILES (lane/lookout slice 2, acceptance 2b): a video's
+// reading-notes.json and transcripts/.lookouts/ live in the corpus, which the
+// workspace ignores (`/transcripts`). Planted in the checkout's working tree
+// beside a committed .gitignore saying so, with a marker in each: no
+// published object, tree page, tarball entry or clone carries either.
+test("a lookout's files in the working tree never ship: no object, tree page, tarball entry or clone holds them", async (t) => {
+ if (filterRepoProblem) return t.skip(`git-filter-repo unavailable: ${filterRepoProblem}`);
+ const repo = sourceRepo({ ".gitignore": "/transcripts\n" });
+ const NOTES = "notesmarkerq7x";
+ const RUN = "runmarkerz4k";
+ const plant = (rel: string, text: string) => {
+ mkdirSync(path.dirname(path.join(repo, rel)), { recursive: true });
+ writeFileSync(path.join(repo, rel), text);
+ };
+ plant("transcripts/channels/alpha-news/data/PublicVid01/reading-notes.json", JSON.stringify({ covers: NOTES }));
+ plant("transcripts/.lookouts/example-week/runs/20261111T120000Z-abcd.json", JSON.stringify({ ideas: [{ workingTitle: RUN }] }));
+ plant("transcripts/.lookouts/example-week/verdicts.json", JSON.stringify({ note: RUN }));
+ assert.equal(gitIn(repo, "status", "--porcelain"), "", "the corpus is ignored: nothing to commit");
+ const logs: string[] = [];
+ const o = opts(repo, operatorFiles("", ""), logs);
+ assert.equal(await publishSource(o), 0, logs.join("\n"));
+ const pub = o.publicDir!;
+
+ const mirror = path.join(pub, "source", MIRROR_DIR);
+ const copy = path.join(dir("copy"), "m.git");
+ cpSync(mirror, copy, { recursive: true });
+ const all = execFileSync("git", ["--git-dir", copy, "cat-file", "--batch-all-objects", "--batch"], { maxBuffer: 1 << 26 }).toString("latin1");
+ for (const s of [NOTES, RUN, "reading-notes.json", ".lookouts"]) assert.equal(all.indexOf(s), -1, `an object holds ${s}`);
+ assert.ok(all.includes("/transcripts"), "control: the .gitignore was published");
+
+ // Every published file: the tree pages, the mirror, the downloads.
+ const walk = (d: string): string[] => readdirSync(d, { withFileTypes: true }).flatMap((e) => (e.isDirectory() ? walk(path.join(d, e.name)) : [path.join(d, e.name)]));
+ for (const f of walk(pub)) {
+ assert.ok(!/reading-notes\.json|\.lookouts/.test(path.relative(pub, f)), `published: ${f}`);
+ const text = readFileSync(f).toString("latin1");
+ for (const s of [NOTES, RUN]) assert.ok(!text.includes(s), `${path.relative(pub, f)} holds ${s}`);
+ }
+ // The tarball's entries, by name.
+ const tarball = path.join(pub, "downloads", path.basename(TARBALL_HREF));
+ const entries = execFileSync("tar", ["-tzf", tarball]).toString();
+ assert.match(entries, /\.gitignore/, "control: the tarball lists the tree");
+ assert.doesNotMatch(entries, /transcripts|reading-notes|\.lookouts/);
+
+ const clone = path.join(dir("clone"), "c");
+ execFileSync("git", ["clone", "-q", `file://${mirror}`, clone], { stdio: "pipe" });
+ assert.ok(!existsSync(path.join(clone, "transcripts")), "the clone has no corpus");
+});
+
test("a denied literal no rule removes: refused, nothing written, the report never prints it", async (t) => {
if (filterRepoProblem) return t.skip(`git-filter-repo unavailable: ${filterRepoProblem}`);
const repo = sourceRepo({ "keys.txt": `the ${SECRET} is here\n` });
diff --git a/mcp/src/lookoutPrivacy.test.ts b/mcp/src/lookoutPrivacy.test.ts
@@ -0,0 +1,118 @@
+// 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<string, string> = {
+ 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();
+ }
+});