Archilyzer · Source

archilyzer

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

commit f8636d72257540c85a1f46e4f9b06389decc7627
parent 639ebb07b989e51987f2856dca4be86f85acad05
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 14 Oct 2026 20:20:06 -0400

common, mcp: seen means judge-able — listRecordings says which recordings have transcript text (the stats index, or a page-read record's cues); tier 0 keeps an untranscribed one out of new and seen, so it is new once transcribed; "N listed · M without a transcript yet"; "1 recording waits" (R6.2)

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

Diffstat:
Mcommon/lib/report/draft/refresh/delta.ts | 6+++++-
Mcommon/lib/report/draft/refresh/fetch.ts | 2+-
Mcommon/lib/report/draft/refresh/refresh.test.ts | 7+++++--
Mcommon/lib/report/draft/triage/tier0.ts | 37+++++++++++++++++++++++++++++--------
Mcommon/lib/report/draft/triage/triage.test.ts | 87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcommon/lib/report/draft/triage/types.ts | 13++++++++++++-
Mcommon/testing/schedule/opsStub.ts | 5++++-
Mmcp/src/enumerate.ts | 26++++++++++++++++++++++++--
Mmcp/src/listRecordings.test.ts | 35++++++++++++++++++++++++++++++++++-
9 files changed, 201 insertions(+), 17 deletions(-)

diff --git a/common/lib/report/draft/refresh/delta.ts b/common/lib/report/draft/refresh/delta.ts @@ -52,7 +52,11 @@ export type EnumerateFn = (args: Record<string, unknown>) => Promise<EnumeratedA // stops at its cap and calls what it read "the scope" is a silent zero. // `complete` false: some channel was not listed in full (`unreached`, with // why in `problems`), so what is missing is NOT "nothing new". -export type ListedRecording = { id: string; channel: string | null; channelSlug: string | null; date: string | null; title: string | null }; +// R6.2: `hasTranscript` — does the build carry transcript text for it (the +// stats index's `hasTranscript`, or the record's own cues when its page was +// read)? false: listed but not judge-able yet; null/absent: the build does +// not say (read as judge-able, as before R6.2). +export type ListedRecording = { id: string; channel: string | null; channelSlug: string | null; date: string | null; title: string | null; hasTranscript?: boolean | null }; export type RecordingListing = { rows: ListedRecording[]; complete: boolean; unreached: string[]; problems: string[] }; export type ListArgs = { channels?: string[]; date_from?: string; date_to?: string }; export type ListFn = (args: ListArgs) => Promise<RecordingListing>; diff --git a/common/lib/report/draft/refresh/fetch.ts b/common/lib/report/draft/refresh/fetch.ts @@ -197,7 +197,7 @@ export async function fetchAndBuild( const held = hooks.transcriptionHeld ? await hooks.transcriptionHeld().catch(() => null) : null; if (held) { steps.push({ - ...skip(slug, "transcribe-bucket", `transcription is paused (${held}) — ${landed.length} recording${landed.length === 1 ? "" : "s"} wait; a later run reads them once transcribed`), + ...skip(slug, "transcribe-bucket", `transcription is paused (${held}) — ${landed.length} recording${landed.length === 1 ? " waits; a later run reads it" : "s wait; a later run reads them"} once transcribed`), ids: landed, }); return steps; diff --git a/common/lib/report/draft/refresh/refresh.test.ts b/common/lib/report/draft/refresh/refresh.test.ts @@ -500,12 +500,13 @@ test("refresh, a capped search again with nothing new: partial (naming what it d test("R4.1 fetch: transcription held — transcribe-bucket is skipped and said (a warning to the caller), never waited on; nothing to transcribe is a routine skip; a cancelled job is a warning", async () => { const calls: Call[] = []; - const buckets: Record<string, string[]> = { held: ["old"], quiet: ["old"], gone: [] }; + const buckets: Record<string, string[]> = { held: ["old"], one: ["old"], quiet: ["old"], gone: [] }; const hooks = { editor: { async run(action: string, args: Record<string, unknown>) { calls.push({ action, args }); if (action === "sync" && args.slug === "held") buckets.held = ["old", "n1", "n2"]; + if (action === "sync" && args.slug === "one") buckets.one = ["old", "m1"]; if (action === "sync" && args.slug === "gone") return { ok: true, jobId: "cancel-me" }; return { ok: true, jobId: `job-${calls.length}` }; }, @@ -518,7 +519,7 @@ test("R4.1 fetch: transcription held — transcribe-bucket is skipped and said ( pollMs: 1, sleep: async () => {}, }; - const r = await fetchAndBuild({ channels: ["held", "quiet", "gone"] }, hooks); + const r = await fetchAndBuild({ channels: ["held", "one", "quiet", "gone"] }, hooks); assert.ok(!calls.some((c) => c.action === "transcribe-bucket"), "nothing queued for a held transcription"); const tb = r.fetch.find((s) => s.channel === "held" && s.action === "transcribe-bucket")!; assert.deepEqual(tb, { @@ -528,6 +529,8 @@ test("R4.1 fetch: transcription held — transcribe-bucket is skipped and said ( reason: "transcription is paused (no transcription worker is enabled) — 2 recordings wait; a later run reads them once transcribed", ids: ["n1", "n2"], }); + // R6.2: one recording "waits" (not "wait"), and a later run reads "it". + assert.equal(r.fetch.find((s) => s.channel === "one" && s.action === "transcribe-bucket")!.reason, "transcription is paused (no transcription worker is enabled) — 1 recording waits; a later run reads it once transcribed"); const routine = r.fetch.find((s) => s.channel === "quiet" && s.action === "transcribe-bucket")!; assert.deepEqual(routine, { channel: "quiet", action: "transcribe-bucket", status: "skipped", reason: "nothing new to transcribe", routine: true }); assert.ok(r.warnings.some((w) => /^gone: sync cancelled — the job ended cancelled$/.test(w)), JSON.stringify(r.warnings)); diff --git a/common/lib/report/draft/triage/tier0.ts b/common/lib/report/draft/triage/tier0.ts @@ -22,10 +22,22 @@ // less the candidates past the cap, which stay new. Posts are not candidates // (a triage reads transcript windows). // +// R6.2 — SEEN MEANS JUDGE-ABLE. A build's manifests list a recording before +// its transcript lands (metadata only). Such a recording (the listing's +// `hasTranscript: false`) is neither new nor seen this run: it stays out of +// seen.json, so the run after its transcript lands counts it new by id — the +// late transcript R6's by-id rule exists to catch. An id an earlier run +// stored as seen while it had no text (before R6.2) is dropped from the set +// this run stores, so it heals the same way. Unknown (`null`, the enumerate +// fallback): judge-able, as before. +// // Pure over the list and enumerate functions and the topic reader it is handed. import { type EnumerateFn, type ListFn, type RecordingListing } from "../refresh/delta"; -import type { TriageCandidate, TriageTier0 } from "./types"; +import { listedWords, type TriageCandidate, type TriageTier0 } from "./types"; + +// The untranscribed ids triage.json names (the count is whole). +const UNTRANSCRIBED_IDS_KEPT = 50; export type Tier0Input = { scope: { channels: string[]; from?: string; to?: string }; @@ -101,9 +113,15 @@ export async function triageCandidates(i: Tier0Input, d: Tier0Deps): Promise<Tie d.signal?.throwIfAborted(); const rows = listing.rows; const perQuery: TriageTier0["perQuery"] = [{ query: listing.by === "manifests" ? "(every recording, listed)" : "(any recording)", n: rows.length, partial: !listing.complete }]; + // R6.2: listed with no transcript text yet — not judge-able, so not new and + // not seen (new on the run after its transcript lands). + const waiting = rows.filter((r) => r.hasTranscript === false); + const waitingIds = new Set(waiting.map((r) => r.id)); + const judgeable = waiting.length ? rows.filter((r) => !waitingIds.has(r.id)) : rows; const isNew = (id: string, date: string | null) => (i.known ? !i.known.has(id) : since ? !!date && date >= since : true); - const fresh = rows.filter((r) => isNew(r.id, ymdOf(r.date))); + const fresh = judgeable.filter((r) => isNew(r.id, ymdOf(r.date))); const byId = new Map(fresh.map((r) => [r.id, r])); + log(`tier 0: ${listedWords({ scanned: rows.length, untranscribed: waiting.length })}`); log( `tier 0: ${rows.length} recording(s) in scope (${listing.by === "manifests" ? "listed from the build's manifests" : "enumerated per channel"}), ${fresh.length} new ${i.known ? `since the last run (by id; ${i.known.size} known)` : since ? `uploaded on or after ${since}` : "(no last run, no since: all)"}${listing.complete ? "" : ` — PARTIAL: ${listing.problems.join("; ")}`}`, ); @@ -185,17 +203,20 @@ export async function triageCandidates(i: Tier0Input, d: Tier0Deps): Promise<Tie const cut = ranked.slice(i.max).map((c) => c.id); const cutSet = new Set(cut); const scannedIds = rows.map((r) => r.id); - // Seen: everything known, everything listed, less what was cut (it stays - // new). A PARTIAL run stores nothing: what it did not reach must not become - // known, so the next run falls back to the last complete run's set (or to - // its `since`). - const seen = partial ? null : [...new Set([...(i.known ?? []), ...scannedIds])].filter((id) => !cutSet.has(id)); + // Seen: everything known, everything listed WITH TEXT, less what was cut + // (it stays new) and less what is listed without a transcript (R6.2: it is + // new once transcribed — a known id among them, stored before R6.2, is + // dropped too). A PARTIAL run stores nothing: what it did not reach must + // not become known, so the next run falls back to the last complete run's + // set (or to its `since`). + const seen = partial ? null : [...new Set([...(i.known ?? []), ...judgeable.map((r) => r.id)])].filter((id) => !cutSet.has(id) && !waitingIds.has(id)); if (partial) log(`tier 0: PARTIAL${unreached.size ? ` — not reached: ${[...unreached].join(", ")}` : ""}: this run's seen set is not kept`); return { tier0: { candidates, scanned: rows.length, newCount: fresh.length, + ...(waiting.length ? { untranscribed: waiting.length, untranscribedIds: waiting.slice(0, UNTRANSCRIBED_IDS_KEPT).map((r) => r.id) } : {}), cut, partial, unreached: [...unreached].sort(), @@ -209,7 +230,7 @@ export async function triageCandidates(i: Tier0Input, d: Tier0Deps): Promise<Tie }; } -type ScopeRow = { id: string; channel: string | null; channelSlug?: string | null; date: string | null; title: string | null }; +type ScopeRow = { id: string; channel: string | null; channelSlug?: string | null; date: string | null; title: string | null; hasTranscript?: boolean | null }; /** * Every recording in scope: the corpus's uncapped listing when it has one, diff --git a/common/lib/report/draft/triage/triage.test.ts b/common/lib/report/draft/triage/triage.test.ts @@ -432,3 +432,90 @@ test("R6.1 tier 0: the corpus tools' listRecordings is the default listing", asy assert.deepEqual(listed, [{ channels: [CHAN] }]); assert.equal((await readTriageSeen("watch-l", paths))?.ids.length, BIG.length); }); + +// ─── R6.2: seen means judge-able — an untranscribed recording stays new ─── + +import { listedWords } from "./types"; + +test("R6.2 tier 0: a recording listed with no transcript yet is neither new nor seen; on the run after its transcript lands it is new (by id) and a candidate; the counts are said", async () => { + // late-03 is listed by the build's manifests before its transcript lands. + const untranscribed = new Set(["late-03"]); + const listWith = (waiting: Set<string>): ListFn => async () => ({ + rows: BIG.map((r) => ({ id: r.id, channel: NAME, channelSlug: CHAN, date: ymd(r.date), title: r.title, hasTranscript: !waiting.has(r.id) })), + complete: true, + unreached: [], + problems: [], + }); + const lines: string[] = []; + // First run (by date): late-03 is old AND untranscribed — not a candidate, not seen. + const first = await triageCandidates({ scope: { channels: [CHAN] }, terms: "contest", topics: [], known: null, since: "2026-10-01", max: 40 }, { enumerate: cappedEnumerate(BIG), list: listWith(untranscribed), log: (l) => lines.push(l) }); + assert.equal(first.tier0.partial, false); + assert.equal(first.tier0.scanned, BIG.length); + assert.equal(first.tier0.untranscribed, 1); + assert.deepEqual(first.tier0.untranscribedIds, ["late-03"]); + assert.ok(first.seen && !first.seen.includes("late-03"), "an untranscribed recording is not stored as seen"); + assert.equal(first.seen!.length, BIG.length - 1); + assert.ok(lines.includes(`tier 0: ${BIG.length} listed · 1 without a transcript yet (not seen; new once transcribed)`), JSON.stringify(lines)); + + // By id, an untranscribed recording that is not known is not new either (nothing to judge yet). + const waitingNew = new Set(["late-03", "new-04"]); + const stillWaiting = await triageCandidates({ scope: { channels: [CHAN] }, terms: "contest", topics: [], known: new Set(first.seen), since: null, max: 40 }, { enumerate: cappedEnumerate(BIG), list: listWith(waitingNew) }); + assert.equal(stillWaiting.tier0.newCount, 0, "new-04 has no text yet: not new"); + assert.deepEqual(stillWaiting.tier0.candidates, []); + assert.equal(stillWaiting.tier0.untranscribed, 2); + assert.ok(!stillWaiting.seen!.includes("late-03") && !stillWaiting.seen!.includes("new-04")); + + // The next run: late-03's transcript has landed — new by id, and it matches the terms. + const enumerate = cappedEnumerate(BIG); + const next = await triageCandidates({ scope: { channels: [CHAN] }, terms: "contest", topics: [], known: new Set(first.seen), since: null, max: 40 }, { enumerate, list: listWith(new Set()) }); + assert.equal(next.tier0.newCount, 1); + assert.deepEqual(next.tier0.candidates.map((c) => c.id), ["late-03"]); + assert.deepEqual(enumerate.calls.find((c) => c.query === "contest")!.ids, ["late-03"]); + assert.equal(next.tier0.untranscribed, undefined); + assert.equal(next.seen!.length, BIG.length); + + // A known id stored as seen while it had no text (before R6.2) is dropped from the set this run stores — it heals. + const healed = await triageCandidates({ scope: { channels: [CHAN] }, terms: "contest", topics: [], known: new Set(BIG.map((r) => r.id)), since: null, max: 40 }, { enumerate: cappedEnumerate(BIG), list: listWith(untranscribed) }); + assert.deepEqual(healed.tier0.candidates, []); + assert.ok(!healed.seen!.includes("late-03")); + + // Unknown transcript state (no `hasTranscript`): judge-able, as before. + const unknown = await triageCandidates({ scope: { channels: [CHAN] }, terms: "contest", topics: [], known: null, since: "2026-10-01", max: 40 }, { enumerate: cappedEnumerate(BIG), list: listOver(BIG) }); + assert.equal(unknown.tier0.untranscribed, undefined); + assert.equal(unknown.seen!.length, BIG.length); +}); + +test("R6.2 a run: seen.json leaves the untranscribed id out; the next run, its transcript landed, judges it", async () => { + const paths = store(); + let waiting = new Set(["late-03"]); + const corpus = { + ...corpusOver(BIG), + listRecordings: async () => ({ rows: BIG.map((r) => ({ id: r.id, channel: NAME, channelSlug: CHAN, date: ymd(r.date), title: r.title, hasTranscript: !waiting.has(r.id) })), complete: true, unreached: [], problems: [] }), + }; + const judged: string[] = []; + const ask = async <T,>(_s: string, user: string): Promise<T> => { + judged.push(user); + return (/judged the contest that year/.test(user) ? { relevant: true, items: [{ quote: "I judged the contest that year myself", claim: "She judged it.", on_topic: true, strength: 3 }] } : { relevant: false, items: [] }) as T; + }; + await createTriageRun(queued("watch-t"), paths, "watch-t"); + const one = await runTriage({ owner: "watch-t", k: 1 }, { llm: {} as never, corpus, enumerate: cappedEnumerate(BIG), paths, cuesOf: cuesOver(BIG), ask }); + assert.equal(one.file.status, "done", one.file.error); + assert.equal(one.file.tier0!.untranscribed, 1); + const seen = await readTriageSeen("watch-t", paths); + assert.equal(seen?.ids.length, BIG.length - 1); + assert.ok(!seen!.ids.includes("late-03")); + // The transcript lands. + waiting = new Set(); + await createTriageRun(queued("watch-t"), paths, "watch-t"); + const two = await runTriage({ owner: "watch-t", k: 2 }, { llm: {} as never, corpus, enumerate: cappedEnumerate(BIG), paths, cuesOf: cuesOver(BIG), ask }); + assert.equal(two.file.status, "done", two.file.error); + assert.equal(two.file.tier0!.newBy, "id"); + assert.deepEqual(two.file.tier0!.candidates.map((c) => c.id), ["late-03"]); + assert.deepEqual(two.file.tier1!.flags.map((f) => f.id), ["late-03"]); + assert.equal((await readTriageSeen("watch-t", paths))?.ids.length, BIG.length); +}); + +test("R6.2 listedWords", () => { + assert.equal(listedWords({ scanned: 23290, untranscribed: 8 }), "23,290 listed · 8 without a transcript yet (not seen; new once transcribed)"); + assert.equal(listedWords({ scanned: 12 }), "12 listed"); +}); diff --git a/common/lib/report/draft/triage/types.ts b/common/lib/report/draft/triage/types.ts @@ -130,6 +130,11 @@ export type TriageTier0 = { listedBy?: "manifests" | "enumerate"; // Why the listing or a query is partial, in words. problems?: string[]; + // R6.2: listed, but with no transcript text in the build yet — not new and + // not seen (new on the run after the transcript lands). The count is whole; + // the ids are the first few. Absent: none. + untranscribed?: number; + untranscribedIds?: string[]; }; export type TriageTier1 = { @@ -210,7 +215,12 @@ export function escalationOf(flags: readonly Pick<TriageFlag, "strength">[], thr return { escalate, why: `${counted} (threshold: ${thresholdWords(threshold)})`, strong, weak, threshold }; } -/** "8 candidates · 2 flagged · 6 dismissed". */ +/** R6.2: "23,290 listed · 8 without a transcript yet (not seen; new once transcribed)". */ +export function listedWords(t: Pick<TriageTier0, "scanned" | "untranscribed">): string { + const n = t.untranscribed ?? 0; + return `${t.scanned.toLocaleString("en-US")} listed${n ? ` · ${n.toLocaleString("en-US")} without a transcript yet (not seen; new once transcribed)` : ""}`; +} + /** R6.1: why a tier 0 is partial, in words ("not reached: A, B (stopped at page 3 of 29)"); null: complete. */ export function partialWords(t: Pick<TriageTier0, "partial" | "unreached" | "problems"> | null | undefined): string | null { if (!t?.partial) return null; @@ -218,6 +228,7 @@ export function partialWords(t: Pick<TriageTier0, "partial" | "unreached" | "pro return (t.problems ?? []).join("; ") || "a cap was hit"; } +/** "8 candidates · 2 flagged · 6 dismissed". */ export function triageLine(f: Pick<TriageFile, "tier0" | "tier1">): string { const c = f.tier0?.candidates.length ?? 0; const flagged = f.tier1?.flags.length ?? 0; diff --git a/common/testing/schedule/opsStub.ts b/common/testing/schedule/opsStub.ts @@ -23,7 +23,8 @@ // "quiet" in the terms or question → candidates, no flag // (below the threshold); "partial" → the same, tier 0 // partial (a channel not reached: the tick is partial, -// R6.1); else a strong flag and a weak one +// R6.1); a quiet run also lists two recordings without +// a transcript yet (R6.2); else a strong flag and a weak one // on sitechan/sv1 and sv2, an invented line dismissed as // not verbatim, a window not relevant; $0 (local) @@ -190,6 +191,8 @@ const steps: TickSteps = { perQuery: [{ query: "(every recording, listed)", n: 16, partial }], newBy: "id", listedBy: "manifests", + // R6.2: a quiet run lists two recordings whose transcripts have not landed (not seen). + ...(quiet && !partial ? { untranscribed: 2, untranscribedIds: ["sv5", "sv6"] } : {}), }, tier1: { model: generation.models.local, diff --git a/mcp/src/enumerate.ts b/mcp/src/enumerate.ts @@ -266,6 +266,12 @@ const ymd = (d: unknown): string | null => { * a channel whose manifest does not read, a scope token no channel matches, * or a record no page dates is said in `problems` and makes the listing * incomplete — never "nothing there". + * + * R6.2: each row says whether the build carries transcript text for it + * (`hasTranscript`): the stats index's flag, or — for a record whose page was + * read anyway — its own cues. A manifest lists a record with no transcript + * yet (metadata only); a triage must not count it as seen. null: the build + * does not say (no stats shipped, or none for this record). */ export async function listRecordings(source: ShardSource, args: ListArgs): Promise<RecordingListing> { const from = args.date_from ? ymd(args.date_from) : null; @@ -285,6 +291,21 @@ export async function listRecordings(source: ShardSource, args: ListArgs): Promi index = null; } } + // R6.2: transcript presence, from the stats index (one read, cached per + // source). Absent or unreadable: unknown, never "untranscribed". + let stats: Awaited<ReturnType<NonNullable<ShardSource["statsIndex"]>>> | null = null; + if (typeof source.statsIndex === "function") { + try { + stats = await source.statsIndex(); + if (stats.size === 0) stats = null; + } catch { + stats = null; + } + } + const textOf = (slug: string): boolean | null => { + const s = stats?.get(slug); + return s && typeof s.hasTranscript === "boolean" ? s.hasTranscript : null; + }; const rows: ListedRecording[] = []; const inRange = (d: string | null) => (!from || (d !== null && d >= from)) && (!to || (d !== null && d <= to)); for (const ch of sel.channels) { @@ -310,7 +331,7 @@ export async function listRecordings(source: ShardSource, args: ListArgs): Promi continue; } const date = ymd(rec.uploadDate); - if (inRange(date)) rows.push({ id, channel: ch.name, channelSlug: ch.slug, date, title: rec.title ?? null }); + if (inRange(date)) rows.push({ id, channel: ch.name, channelSlug: ch.slug, date, title: rec.title ?? null, hasTranscript: textOf(`${ch.slug}/${id}`) }); } let lost = 0; for (const [page, ids] of undated) { @@ -328,7 +349,8 @@ export async function listRecordings(source: ShardSource, args: ListArgs): Promi continue; } const date = ymd(r.uploadDate); - if (inRange(date)) rows.push({ id, channel: ch.name, channelSlug: ch.slug, date, title: r.title ?? null }); + // The record is in hand: its own cues say, whatever the stats say. + if (inRange(date)) rows.push({ id, channel: ch.name, channelSlug: ch.slug, date, title: r.title ?? null, hasTranscript: Array.isArray(r.cues) && r.cues.length > 0 }); } } if (lost) { diff --git a/mcp/src/listRecordings.test.ts b/mcp/src/listRecordings.test.ts @@ -79,7 +79,9 @@ test("listRecordings lists every recording, uncapped, dated (the index, else the const all = await listRecordings(src, { channels: ["big"] }); assert.equal(all.complete, true, all.problems.join("; ")); assert.deepEqual(all.rows.map((r) => r.id).sort(), PAGES.flat().map((r) => r.id).sort()); - assert.deepEqual(all.rows.find((r) => r.id === "new-2"), { id: "new-2", channel: "Big Channel (Mirror)", channelSlug: "big", date: "2026-10-13", title: "Title new-2" }); + // new-2 is dated from its own page, whose cues say it has text; with no stats shipped the rest do not say (null). + assert.deepEqual(all.rows.find((r) => r.id === "new-2"), { id: "new-2", channel: "Big Channel (Mirror)", channelSlug: "big", date: "2026-10-13", title: "Title new-2", hasTranscript: true }); + assert.equal(all.rows.find((r) => r.id === "old-1")?.hasTranscript, null); const recent = await listRecordings(src, { channels: ["big"], date_from: "2026-10-07" }); assert.deepEqual(recent.rows.map((r) => r.id).sort(), ["new-1", "new-2"]); const unknown = await listRecordings(src, { channels: ["big", "nowhere"] }); @@ -103,3 +105,34 @@ test("enumerate with `ids` reads only the pages holding them — bounded, so a s assert.match(text, /restricted to 1 recording id\(s\): 1 held by a channel in scope/); assert.deepEqual(enumerateOf(text).ids, ["new-2"]); }); + +test("R6.2 listRecordings says which recordings have transcript text: the stats index's flag, or a page-read record's own cues", async () => { + const d = await mkdtemp(path.join(os.tmpdir(), "mcp-list-text-")); + try { + await writeFile(path.join(d, "corpus.json"), JSON.stringify({ channels: [{ slug: "big", name: "Big", videoCount: 4 }] })); + const ch = path.join(d, "transcripts", "big"); + await mkdir(ch, { recursive: true }); + const recs = [ + rec("has-1", "20261001", ["words"]), + { ...rec("bare-1", "20261002", []), cues: undefined }, // listed before its transcript lands + rec("has-2", "20261003", ["more words"]), // not in the index: read from its page + { ...rec("bare-2", "20261004", []), cues: undefined }, // not in the index, no cues on its page + ]; + await writeFile(path.join(ch, "manifest.json"), JSON.stringify({ version: 1, channelSlug: "big", pageCount: 1, maxPageBytes: 1e6, generatedAt: "2026-10-14", slugToPage: Object.fromEntries(recs.map((r) => [r.id, 0])) })); + await writeFile(path.join(ch, "page-0000.json"), JSON.stringify(recs)); + const sum = path.join(d, "summaries"); + await mkdir(sum, { recursive: true }); + const indexed = recs.filter((r) => r.id === "has-1" || r.id === "bare-1"); + await writeFile(path.join(sum, "manifest.json"), JSON.stringify({ version: 3, totalCount: 2, pageSize: 1000, pageCount: 1, generatedAt: "2026-10-14", channels: [{ slug: "big", name: "Big", count: 2 }] })); + await writeFile(path.join(sum, "page-0000.json"), JSON.stringify(indexed.map((r) => ({ slug: r.slug, id: r.id, channelSlug: "big", title: r.title, uploadDate: r.uploadDate })))); + const stats = path.join(d, "stats"); + await mkdir(stats, { recursive: true }); + await writeFile(path.join(stats, "manifest.json"), JSON.stringify({ version: 6, generatedAt: "2026-10-14", totalCount: 2, pageCount: 1, maxPageBytes: 1e6, channels: [{ slug: "big", name: "Big", count: 2 }] })); + await writeFile(path.join(stats, "page-0000.json"), JSON.stringify(indexed.map((r) => ({ slug: r.slug, id: r.id, channelSlug: "big", hasTranscript: r.id === "has-1", cueCount: r.id === "has-1" ? 1 : null })))); + const l = await listRecordings(new LocalSource(d), { channels: ["big"] }); + assert.equal(l.complete, true, l.problems.join("; ")); + assert.deepEqual(Object.fromEntries(l.rows.map((r) => [r.id, r.hasTranscript])), { "has-1": true, "bare-1": false, "has-2": true, "bare-2": false }); + } finally { + await rm(d, { recursive: true, force: true }); + } +});