commit 76604d55bd6b45ff9bd5e32f5704d82ad2e64d83
parent a3cc8e5c5d6a7b5c9e1c0ce9ac58d502cedbe970
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 15 Oct 2026 17:25:44 -0400
common, mcp: a salvage transcript is marked downstream (release 30 lane Q) — the index derives `salvaged: {decodedSeconds, totalSeconds}` on a whisper record whose transcribe-outcome.json has a salvage (TranscriptSummary.salvaged, omitted otherwise so every other page stays byte-identical; never carried over a re-derivation), so the published transcript pages carry it; the export's video page (TranscriptModal) shows "Partial transcript: N of M min decoded" under the date line; MCP get_transcript and get_video_metadata carry the record's mark and say "⚠ PARTIAL TRANSCRIPT … do NOT conclude that something was never said" (lib/salvageMark.ts); real-buildIndex test over a temp corpus, MCP server test
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
9 files changed, 223 insertions(+), 3 deletions(-)
diff --git a/common/components/PlayerProvider.tsx b/common/components/PlayerProvider.tsx
@@ -93,6 +93,8 @@ export type TranscriptData = {
webpageUrl: string;
hlsUrl?: string;
mediaUrl?: string;
+ // A salvage transcript (release 30, lane Q): how much of the runtime decoded.
+ salvaged?: { decodedSeconds: number; totalSeconds: number };
// The cues of the track on show: the primary, or the alternate the viewer
// picked (`track`).
cues?: Cue[];
@@ -125,6 +127,8 @@ type Detail = {
webpageUrl: string;
hlsUrl?: string;
mediaUrl?: string;
+ // A salvage transcript (release 30, lane Q): how much of the runtime decoded.
+ salvaged?: { decodedSeconds: number; totalSeconds: number };
cues?: Cue[];
} & TrackFields;
@@ -462,6 +466,7 @@ export function PlayerProvider({
webpageUrl: detail.webpageUrl,
hlsUrl: detail.hlsUrl,
mediaUrl: detail.mediaUrl,
+ ...(detail.salvaged ? { salvaged: detail.salvaged } : {}),
// A `vt` the record does not hold reads as the primary.
cues: cuesOfTrack(detail, urlVt) ?? detail.cues,
tracks: recordTracks(detail),
diff --git a/common/components/TranscriptModal.tsx b/common/components/TranscriptModal.tsx
@@ -37,6 +37,7 @@ import { VirtualRow } from "./VirtualRow";
import { formatTimestamp } from "../lib/vtt";
import { formatDate } from "../lib/format";
import { trackLabels } from "../lib/captionTracks";
+import { partialTranscriptLine } from "../lib/salvageMark";
type DisplayCue = {
start: number;
@@ -320,6 +321,11 @@ export default function TranscriptModal() {
{data.ageRestricted && <AgeRestrictedBadge />}
</p>
)}
+ {data?.salvaged && (
+ <p role="status" className="text-xs text-amber-200 mt-0.5">
+ {partialTranscriptLine(data.salvaged)}
+ </p>
+ )}
</div>
<div className="px-3 sm:px-0 flex flex-wrap items-center gap-x-3 gap-y-1">
@@ -841,3 +847,4 @@ function TrackSwitcher({
</label>
);
}
+
diff --git a/common/controller/buildIndex.ts b/common/controller/buildIndex.ts
@@ -174,6 +174,7 @@ import {
} from "./curatedTagsIndex";
import { tagsForSite } from "../lib/curatedTags";
import { compileRecordedDateRule, deriveRecordedDate } from "../lib/recordedDate";
+import { loadTranscribeOutcome } from "../lib/transcribeOutcome-server";
// v10: multi-site build. Shared per-channel transcript/subs pages are written
// once; per-site summaries + subs manifests are filtered selections. Bumped to
@@ -1114,6 +1115,19 @@ export async function buildIndex({
const recorded = deriveRecordedDate(recordedRe, summary.title, summary.uploadDate);
if (recorded) summary.recordedDate = recorded;
}
+ // A SALVAGE transcript says so on its record (release 30, lane Q):
+ // only a whisper transcript can be one, and only one carrying the
+ // outcome sidecar pays the small read. Never carried over.
+ delete summary.salvaged;
+ if (s.transcriptKind === "whisper") {
+ const salvaged = (await loadTranscribeOutcome(videoFullDir).catch(() => null))?.salvaged;
+ if (salvaged) {
+ summary.salvaged = {
+ decodedSeconds: salvaged.decodedSeconds,
+ totalSeconds: salvaged.totalSeconds,
+ };
+ }
+ }
const indexKey: IndexKey = [
summary.uploadDate,
s.channelSlug,
diff --git a/common/controller/buildIndexSalvaged.test.ts b/common/controller/buildIndexSalvaged.test.ts
@@ -0,0 +1,117 @@
+// Integration: a SALVAGE transcript is marked on its index record and its
+// published page (release 30, lane Q) — `salvaged: {decodedSeconds,
+// totalSeconds}` from transcribe-outcome.json — and only there: every other
+// record's page bytes are what they were, and a clean re-transcription drops
+// the mark. Synthetic records through the REAL buildIndex over a temp corpus.
+//
+// Run with: node_modules/.bin/tsx --test common/controller/buildIndexSalvaged.test.ts
+
+import { after, test } from "node:test";
+import assert from "node:assert/strict";
+import { mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, utimesSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import path from "node:path";
+
+const ROOT = mkdtempSync(path.join(tmpdir(), "build-index-salvaged-"));
+const PINNED: Record<string, string> = {
+ 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"),
+};
+Object.assign(process.env, PINNED);
+delete process.env.ARCHILYZER_INDEX_ALLOW_HELD;
+after(() => rmSync(ROOT, { recursive: true, force: true }));
+
+const { getPaths } = await import("../lib/paths");
+const { buildIndex } = await import("./buildIndex");
+const { open } = await import("lmdb");
+
+const paths = getPaths();
+const SLUG = "example-salvage";
+const SITE = "testsite";
+
+const writeJson = (file: string, value: unknown) => {
+ mkdirSync(path.dirname(file), { recursive: true });
+ writeFileSync(file, JSON.stringify(value, null, 2));
+};
+const dirOf = (id: string) => path.join(paths.channelsDir, SLUG, "data", id);
+
+function video(id: string, salvaged?: { decodedSeconds: number; totalSeconds: number; gaps: number[][] }) {
+ const dir = dirOf(id);
+ writeJson(path.join(dir, "metadata.info.json"), {
+ id,
+ title: `Recording ${id}`,
+ upload_date: "20260105",
+ duration: 6000,
+ webpage_url: `https://odysee.com/@example:0/${id}:0`,
+ extractor_key: "LBRY",
+ });
+ writeJson(path.join(dir, "transcript.json"), {
+ chunk_data: [{ start_time: 1, end_time: 2, text: "a synthetic line" }],
+ });
+ writeJson(path.join(dir, "transcribe-outcome.json"), {
+ videoId: id,
+ transcribedAt: "2026-10-15T00:00:00.000Z",
+ ...(salvaged ? { salvaged: { source: "audio.mp4", ...salvaged } } : {}),
+ });
+}
+
+function pagesOf(slug: string): string {
+ const dir = path.join(paths.exportSharedTranscriptsDir, slug);
+ return readdirSync(dir)
+ .filter((f) => f.startsWith("page-"))
+ .map((f) => readFileSync(path.join(dir, f), "utf8"))
+ .join("\n");
+}
+
+function records(): Record<string, unknown> {
+ const out: Record<string, unknown> = {};
+ for (const page of pagesOf(SLUG).split("\n").filter(Boolean)) {
+ for (const r of JSON.parse(page) as Array<{ id: string; salvaged?: unknown }>) out[r.id] = r.salvaged;
+ }
+ return out;
+}
+
+test("a salvage transcript's record says how much decoded; a clean one says nothing", async () => {
+ writeFileSync(paths.settingsFile, "{}");
+ writeJson(path.join(paths.channelsDir, SLUG, "config.json"), { handling: "transcribe", name: SLUG });
+ writeJson(path.join(paths.sitesDir, SITE, "site.json"), {
+ siteId: SITE,
+ siteTitle: "Test Site",
+ siteDescription: "fixture",
+ headerTitle: "Test Site",
+ homeTagline: "",
+ socialLinks: [],
+ groups: [{ id: "default", name: "All channels", selectedByDefault: true }],
+ defaultGroupId: "default",
+ channels: [{ slug: SLUG, groupId: "default" }],
+ });
+ video("SalvagedRec1", { decodedSeconds: 2335, totalSeconds: 6000, gaps: [[2335, 6000]] });
+ video("CleanRec0001");
+ await buildIndex({ paths, onLog: () => {} });
+ assert.deepEqual(records(), {
+ SalvagedRec1: { decodedSeconds: 2335, totalSeconds: 6000 },
+ CleanRec0001: undefined,
+ });
+ // The gaps stay on disk; the record carries the two numbers.
+ assert.doesNotMatch(pagesOf(SLUG), /gaps/);
+
+ // Transcribed again from clean audio: the mark goes.
+ video("SalvagedRec1");
+ const later = new Date(Date.now() + 5000);
+ utimesSync(path.join(dirOf("SalvagedRec1"), "transcript.json"), later, later);
+ await buildIndex({ paths, onLog: () => {} });
+ assert.deepEqual(records(), { SalvagedRec1: undefined, CleanRec0001: undefined });
+ assert.doesNotMatch(pagesOf(SLUG), /salvaged/);
+});
diff --git a/common/lib/salvageMark.test.ts b/common/lib/salvageMark.test.ts
@@ -0,0 +1,11 @@
+import { test } from "node:test";
+import assert from "node:assert/strict";
+import { partialTranscriptLine, salvageCaveat } from "./salvageMark";
+
+// Release 30 lane Q: the salvage mark, as the export and the MCP say it.
+test("the status line and the caveat say how much decoded, in minutes", () => {
+ const mark = { decodedSeconds: 2335, totalSeconds: 6000 };
+ assert.equal(partialTranscriptLine(mark), "Partial transcript: 39 of 100 min decoded");
+ assert.match(salvageCaveat(mark), /^⚠ PARTIAL TRANSCRIPT — made from a damaged recording: 39 of 100 min decoded/);
+ assert.match(salvageCaveat(mark), /Do NOT conclude/);
+});
diff --git a/common/lib/salvageMark.ts b/common/lib/salvageMark.ts
@@ -0,0 +1,23 @@
+// A SALVAGE TRANSCRIPT, SAID IN ONE LINE (release 30, lane Q) — the record's
+// `salvaged` mark (TranscriptSummary.salvaged: made from a damaged recording,
+// no transcript where it would not decode) as the export's video page and the
+// MCP say it. Pure: no fs, client-safe.
+
+export type SalvageMark = { decodedSeconds: number; totalSeconds: number };
+
+const minutes = (sec: number) => Math.max(0, Math.round(sec / 60));
+
+// "Partial transcript: 39 of 100 min decoded"
+export function partialTranscriptLine(s: SalvageMark): string {
+ return `Partial transcript: ${minutes(s.decodedSeconds)} of ${minutes(s.totalSeconds)} min decoded`;
+}
+
+// The MCP's caveat, phrased like its coverage warning: a reader must not
+// conclude from this transcript that something was never said.
+export function salvageCaveat(s: SalvageMark): string {
+ return (
+ `⚠ PARTIAL TRANSCRIPT — made from a damaged recording: ${minutes(s.decodedSeconds)} of ` +
+ `${minutes(s.totalSeconds)} min decoded, and the rest has no transcript. Do NOT conclude ` +
+ `from this transcript that something was never said.`
+ );
+}
diff --git a/common/lib/transcripts.ts b/common/lib/transcripts.ts
@@ -1,6 +1,7 @@
import path from "node:path";
import type { Cue } from "./vtt";
import type { TrackFields } from "./captionTracks";
+import type { SalvageMark } from "./salvageMark";
import { readFile } from "fs-extra";
import { getPaths } from "./paths";
@@ -43,6 +44,11 @@ export type TranscriptSummary = {
// channel has no rule or the title gives no date, so every other channel's
// pages stay byte-identical. Coverage reads it first (`coverageDate`).
recordedDate?: string;
+ // The transcript is a SALVAGE (release 30, lane Q): made from a damaged
+ // recording, with no transcript where it would not decode — how much of the
+ // runtime decoded (transcribe-outcome.json `salvaged`, whose gaps stay on
+ // disk). OMITTED for every other record, so their pages stay byte-identical.
+ salvaged?: SalvageMark;
};
export type DisplaySummary = {
diff --git a/mcp/src/search.test.ts b/mcp/src/search.test.ts
@@ -1762,3 +1762,33 @@ test("server: get_transcript reads the primary by default and another track by `
assert.match(batch, /a zeppelin flew over/);
await client.close();
});
+
+// Release 30 lane Q: a salvage transcript's record carries `salvaged`; both
+// readers say it is partial, and a record without it says nothing.
+class SalvagedSource extends StubSource {
+ protected pages(ch: ChannelRef): TranscriptDetail[][] {
+ return super.pages(ch).map((p) =>
+ p.map((r) => (r.id === "a1" ? { ...r, salvaged: { decodedSeconds: 2335, totalSeconds: 6000 } } : r)),
+ );
+ }
+}
+
+test("server: a salvage transcript is marked partial by get_transcript and get_video_metadata", async () => {
+ const client = await connectClient(new SalvagedSource());
+ const transcript = firstText(
+ await client.callTool({ name: "get_transcript", arguments: { video_id: "a1" } }),
+ );
+ assert.match(transcript, /PARTIAL TRANSCRIPT — made from a damaged recording: 39 of 100 min decoded/);
+ assert.match(transcript, /i love coffee/);
+ const meta = firstText(
+ await client.callTool({ name: "get_video_metadata", arguments: { video_id: "a1" } }),
+ );
+ const parsed = JSON.parse(meta.slice(0, meta.indexOf("\n}") + 2));
+ assert.deepEqual(parsed.salvaged, { decodedSeconds: 2335, totalSeconds: 6000 });
+ assert.match(meta, /PARTIAL TRANSCRIPT/);
+ const other = firstText(
+ await client.callTool({ name: "get_transcript", arguments: { video_id: "b2" } }),
+ );
+ assert.doesNotMatch(other, /PARTIAL TRANSCRIPT/);
+ await client.close();
+});
diff --git a/mcp/src/server.ts b/mcp/src/server.ts
@@ -4,6 +4,7 @@ import {
type ServerOptions,
type Tool,
} from "@modelcontextprotocol/server";
+import { salvageCaveat } from "yt-dlp-transcript-common/lib/salvageMark";
import { transcriptToMarkdown } from "yt-dlp-transcript-common/lib/transcriptToMarkdown";
import { formatDate, formatDuration } from "yt-dlp-transcript-common/lib/format";
import { manifestHasDigest } from "yt-dlp-transcript-common/lib/digests";
@@ -2312,7 +2313,7 @@ async function handleGetTranscript(
);
}
const shown = asked || record.track;
- const extraMeta =
+ const trackMeta =
tracks.length > 1 && shown
? [
`track: ${shown} (${trackLabel(shown)})${shown === record.track ? " — the primary" : ""}`,
@@ -2321,14 +2322,17 @@ async function handleGetTranscript(
.map((t) => `${t} (${trackLabel(t)}${t === record.track ? ", the primary" : ""})`)
.join(", ")} — pass track to read one`,
]
- : undefined;
+ : [];
+ // A salvage transcript (release 30, lane Q) says so where a quote is read.
+ const salvageMeta = record.salvaged && (!asked || asked === record.track) ? [salvageCaveat(record.salvaged)] : [];
+ const extraMeta = [...trackMeta, ...salvageMeta];
const md = transcriptToMarkdown(
{ ...record, cues },
{
timestamps: args.timestamps !== false,
includeTags: true,
linkForCue: (seconds) => momentLinkFor(source, link, seconds),
- ...(extraMeta ? { extraMeta } : {}),
+ ...(extraMeta.length > 0 ? { extraMeta } : {}),
},
);
return text(md);
@@ -2400,6 +2404,9 @@ async function handleGetMetadata(
].filter(Boolean);
lines.push(statLines.join("\n"));
}
+ // A salvage transcript (release 30, lane Q): the record's own mark, stated
+ // as the caveat it is whatever the stats layer says.
+ if (found.record.salvaged) lines.push(`- ${salvageCaveat(found.record.salvaged)}`);
// ── duplicates.json ──
lines.push(await describeOtherCopies(source, slug));