Archilyzer · Source

archilyzer

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

commit 97a9ac02ac6d65bc1411c56deb351e5079602246
parent e25b68a7e7dc0a21e7d012b11c05daf3de47f0b4
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 11 Nov 2026 06:36:30 -0500

local media: a local recording's date is its recording date; undated is safe (review B2)

The patch let a source-less recording into the index with uploadDate "".
Audited every consumer (recency index, index pages, stats, search filters,
export UI, MCP, umtool): nothing crashed, but four things were wrong.

- The stated date: a local recording was never published, so the recording
  date the operator gave (`recorded_date`) is its date. uploadDate takes it
  (it sorts, filters and shows by it) and `recordedDate` keeps saying what it
  is. With none it is undated ("").
- buildStats dropped an undated record (`if (!base.uploadDate) return`), so
  it had no stats row, counted as "added" on EVERY run, and every site's stats
  bundle was rewritten every time. It now keeps a row; charts already put an
  empty date in no time bucket.
- The date filters (search evaluator, the viewer's filter, chart filters)
  dropped "" under a from-bound but kept it under a to-bound alone. Undated is
  now outside every bounded range.
- MCP listings printed "uploaded: " with nothing after it; they say
  "undated". umtool's attribution line left an empty field between dots; it
  drops the date.

Tests through the index: an undated local record pages last in the site's
summaries, a second stats run adds nothing and short-circuits (fails without
the buildStats fix), the recency index reads "" as unknown; plus the filter,
MCP and attribution cases.

Left as found on main: an undated PROVIDER record (skipped by the index) is
re-"added" by every stats run too, and so rewrites every bundle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Diffstat:
Mcommon/components/SearchSessionContext.tsx | 2++
Mcommon/controller/buildIndexLocalRecording.test.ts | 43++++++++++++++++++++++++++++++++++++++++++-
Mcommon/controller/buildStats.ts | 6+++++-
Mcommon/lib/chartAggregate.ts | 1+
Mcommon/lib/localRecordingIntegration.test.ts | 8++++++--
Mcommon/lib/search/evalTree.test.ts | 11+++++++++++
Mcommon/lib/search/evalTree.ts | 5++++-
Mcommon/lib/transcripts-server.ts | 7++++++-
Mmcp/src/server.ts | 17++++++++++++-----
Amcp/src/undatedRecord.test.ts | 11+++++++++++
Mumtool/report-to-video/attribution.mjs | 4+++-
Mumtool/report-to-video/attribution.test.mjs | 10++++++++++
12 files changed, 113 insertions(+), 12 deletions(-)

diff --git a/common/components/SearchSessionContext.tsx b/common/components/SearchSessionContext.tsx @@ -835,6 +835,8 @@ function useSearchSessionState() { const passesFilter = useMemo(() => { return (t: Summary) => { if (committedChannels.has(channelKeyOf(t))) return false; + // Undated is outside any bounded range (lib/search/evalTree.ts). + if ((committedDateFrom || committedDateTo) && !t.uploadDate) return false; if (committedDateFrom && t.uploadDate < committedDateFrom) return false; if (committedDateTo && t.uploadDate > committedDateTo) return false; if (t.isLivestream ? committedNol : committedNov) return false; diff --git a/common/controller/buildIndexLocalRecording.test.ts b/common/controller/buildIndexLocalRecording.test.ts @@ -89,7 +89,8 @@ test("source-less commits reach real search pages; retries and title rules retai await buildIndex({paths, onLog: () => {}}); for (const summary of summaries()) { assert.equal(summary.platform,"local"); - assert.equal(summary.uploadDate, ""); + // The recording date is a local recording's date (review B2); none, undated. + assert.equal(summary.uploadDate, summary.id === second ? "20240229" : ""); assert.equal(summary.webpageUrl, ""); assert.equal(summary.recordedDate, summary.id === second ? "20240229" : undefined); } @@ -117,3 +118,43 @@ test("a malformed local_recording written past the importer is skipped with a lo assert.ok(!logs.some(line => line.includes("Failed to process")), logs.join("\n")); rmSync(dir, {recursive: true, force: true}); }); + +// Review B2: an undated local record (uploadDate "") through the index, the +// summaries page order, the stats run and the recency index the lanes read. +test("an undated local record pages last, keeps a stats row, and reads as unknown to the recency index", async () => { + const { siteSummariesDir } = await import("../lib/site"); + const { buildStats } = await import("./buildStats"); + const { openUploadDateIndex } = await import("./recencyIndex"); + // The first test's undated ONLINE record is skipped by the index, and so, + // on main, re-"added" by every stats run: out of this one's count. + rmSync(path.join(dataDirectory, "online-no-date"), {recursive: true, force: true}); + const online = path.join(dataDirectory, "onlinedated"); + writeJson(path.join(online, "metadata.info.json"), {id: "onlinedated", title: "Dated online", + extractor_key: "Youtube", upload_date: "20250101", webpage_url: "https://www.youtube.com/watch?v=onlinedated"}); + writeFileSync(path.join(online, "transcript.en.vtt"), transcript); + await buildIndex({paths, onLog: () => {}}); + const dir = siteSummariesDir(paths, "localtest"); + const listed: Array<{id: string; date: string}> = readdirSync(dir).filter(f => /^page-\d+\.json$/.test(f)).sort() + .flatMap(f => JSON.parse(readFileSync(path.join(dir, f), "utf8"))); + // Newest first: the dated online record, the dated local one, then the undated one last. + assert.deepEqual(listed.map(r => r.id), ["onlinedated", second, first]); + assert.deepEqual(listed.map(r => r.date), ["2025-01-01", "2024-02-29", ""]); + + const logs: string[] = []; + const once = await buildStats({paths, onLog: line => logs.push(line)}); + assert.ok(once.added >= 3, JSON.stringify(once)); + const twice = await buildStats({paths, onLog: () => {}}); + // Without a row for the undated record it was "added" every run, and every + // site's stats bundle rewritten. + assert.equal(twice.added, 0, JSON.stringify(twice)); + assert.equal(twice.shortCircuited, true, JSON.stringify(twice)); + + const recency = openUploadDateIndex(paths, [channel]); + try { + const dates = recency.datesBySlug.get(channel)!; + assert.equal(dates.get(first), ""); + assert.equal(dates.get(second), "20240229"); + assert.equal(dates.get("onlinedated"), "20250101"); + } finally { await recency.close(); } + rmSync(online, {recursive: true, force: true}); +}); diff --git a/common/controller/buildStats.ts b/common/controller/buildStats.ts @@ -549,7 +549,11 @@ export async function buildStats({ parsedMeta, e.configName, ); - if (!base.uploadDate) return; + // An undated LOCAL recording is indexed (lib/transcripts-server.ts, + // summarize), so it has a stats row too — without one it would count + // as "added" on every run and rewrite every site's bundle. Its row + // falls in no time bucket (chartAggregate.xLabelsForStat). + if (!base.uploadDate && base.platform !== "local") return; // The key buildIndex stored this video's cues under, when it has a // record: its uploadDate comes from transcript.cues.json when that // is fresh, which the metadata's can differ from. The computed key diff --git a/common/lib/chartAggregate.ts b/common/lib/chartAggregate.ts @@ -79,6 +79,7 @@ export function applyFilters( const platformSet = f.platforms && f.platforms.length ? new Set(f.platforms) : null; return stats.filter((s) => { + if ((f.dateFrom || f.dateTo) && !s.uploadDate) return false; if (f.dateFrom && s.uploadDate < f.dateFrom) return false; if (f.dateTo && s.uploadDate > f.dateTo) return false; if (channelSet && !channelSet.has(s.channelSlug)) return false; diff --git a/common/lib/localRecordingIntegration.test.ts b/common/lib/localRecordingIntegration.test.ts @@ -22,13 +22,17 @@ test("source-less summaries keep unknown dates and duration without a fabricated assert.ok(PLATFORM_VALUES.includes("local")); }); -test("an explicit recording date stays distinct from publication date", () => { +// Review B2: a local recording was never published, so its recording date is +// its one date — the record sorts and filters by it — and it stays marked as a +// recording date (recordedDate), never claimed from a provider. +test("an explicit recording date is the record's date, and stays a recording date", () => { const value = prepareLocalRecordingMetadata({id, filename: "Lesson.mp4", recordedDate: "2024-02-29", probe: {format: {duration: "10.5"}, streams: [{codec_type: "video"}]}}); requireLocalRecordingMetadata(value); const summary = summarize("classroom", id, value); assert.equal(summary.recordedDate, "20240229"); - assert.equal(summary.uploadDate, ""); + assert.equal(summary.uploadDate, "20240229"); + assert.equal(summary.webpageUrl, ""); assert.equal(summary.duration, 10.5); }); diff --git a/common/lib/search/evalTree.test.ts b/common/lib/search/evalTree.test.ts @@ -393,3 +393,14 @@ test("a transcripts leaf reads the record's alternate tracks; a hit only one hol ], ); }); + +// lane/local-media (review B2): an undated record — a local recording with no +// recording date, uploadDate "" — is outside every bounded date range, from- +// only and to-only alike, and inside an unbounded one. +test("passesFilters: an undated record is outside any bounded date range", () => { + const rec = { uploadDate: "", isLivestream: false, ageRestricted: false }; + assert.equal(passesFilters(rec, openFilters(), undefined), true); + assert.equal(passesFilters(rec, openFilters({ dateFrom: "20250101" }), undefined), false); + assert.equal(passesFilters(rec, openFilters({ dateTo: "20251231" }), undefined), false); + assert.equal(passesFilters(rec, openFilters({ dateFrom: "20250101", dateTo: "20251231" }), undefined), false); +}); diff --git a/common/lib/search/evalTree.ts b/common/lib/search/evalTree.ts @@ -364,7 +364,10 @@ export function passesFilters( if (rec.ageRestricted ? !f.restricted : !f.allAges) return false; // fav — presence on the source platform if (!f.states.has(avail?.state ?? "available")) return false; - // fdf / fdt — upload-date range (lexicographic on YYYYMMDD) + // fdf / fdt — upload-date range (lexicographic on YYYYMMDD). An undated + // record (an undated local recording, "") is outside ANY bounded range — not + // only a from-bounded one, which "" < from alone would make it. + if ((f.dateFrom || f.dateTo) && !rec.uploadDate) return false; if (f.dateFrom && rec.uploadDate < f.dateFrom) return false; if (f.dateTo && rec.uploadDate > f.dateTo) return false; // tg — curated tags. OR across the selection (a video tagged either diff --git a/common/lib/transcripts-server.ts b/common/lib/transcripts-server.ts @@ -179,7 +179,12 @@ export function summarize( id, channelSlug, title: meta.title ?? id, - uploadDate: platform === "local" ? "" : meta.upload_date ?? dateFromDir ?? "", + // A LOCAL RECORDING was never published: its one date is the recording + // date the operator gave (`recorded_date`), and that is the date it sorts, + // filters and shows by (lane/local-media slice 1, review B2). It keeps + // `recordedDate` too. With none it is UNDATED (""): indexed all the same, + // last in newest-first, outside any date-bounded filter. + uploadDate: platform === "local" ? meta.recorded_date ?? "" : meta.upload_date ?? dateFromDir ?? "", ...(platform === "local" && meta.recorded_date ? { recordedDate: meta.recorded_date } : {}), duration: meta.duration ?? 0, channel: configName ?? meta.channel ?? meta.uploader ?? "", diff --git a/mcp/src/server.ts b/mcp/src/server.ts @@ -9,6 +9,13 @@ import { salvageCaveat } from "yt-dlp-transcript-common/lib/salvageMark"; import { COPIES_NOT_AVAILABLE, describeCopies, loadMirrorScans, onlyHereIds } from "./mirrorCopies"; import { transcriptToMarkdown } from "yt-dlp-transcript-common/lib/transcriptToMarkdown"; import { formatDate, formatDuration } from "yt-dlp-transcript-common/lib/format"; + +// A record's date as these listings print it. An undated record (a local +// recording with no recording date has uploadDate "") says so, rather than +// leaving an empty field a reader takes for a parse error. +export function dateOrUndated(uploadDate: string): string { + return uploadDate ? formatDate(uploadDate) : "undated"; +} import { manifestHasDigest } from "yt-dlp-transcript-common/lib/digests"; import type { VideoStat } from "yt-dlp-transcript-common/lib/stats"; import { momentUrl, momentBaseUrl, viewerPostUrl } from "yt-dlp-transcript-common/lib/momentUrl"; @@ -1717,7 +1724,7 @@ async function handleSearch( `### ${h.title}\n` + `- video_id: ${h.videoId} | channel: ${h.channelName}` + (h.siteTitle ? ` | site: ${h.siteTitle}` : "") + - ` | uploaded: ${formatDate(h.uploadDate)} | matches: ${h.matches}` + + ` | uploaded: ${dateOrUndated(h.uploadDate)} | matches: ${h.matches}` + (includeSnippets && h.webpageUrl ? `\n- source: ${h.webpageUrl}` : "") + (baseUrl ? `\n- moment_base: ${baseUrl}` : "") + (h.mirrors && h.mirrors.length > 0 @@ -1861,7 +1868,7 @@ async function handleEnumerateMatches( : ""; return ( `- ${h.videoId} | ${kind} | ${h.channelName} | ` + - `${formatDate(h.uploadDate)} | ${h.matches} match(es) | ${h.title}${mirrors}` + `${dateOrUndated(h.uploadDate)} | ${h.matches} match(es) | ${h.title}${mirrors}` ); }); @@ -2129,7 +2136,7 @@ async function handleGetTranscripts( `## ${record.title || id}\n` + `- video_id: ${id} | channel: ${ch.name}` + (ch.siteTitle ? ` | site: ${ch.siteTitle}` : "") + - ` | uploaded: ${formatDate(record.uploadDate)}` + + ` | uploaded: ${dateOrUndated(record.uploadDate)}` + (record.webpageUrl ? `\n- source: ${record.webpageUrl}` : "") + (baseUrl ? `\n- moment_base: ${baseUrl}` : "") + // A salvage transcript (release 30, lane Q) is marked here too (release 32 R8). @@ -2560,7 +2567,7 @@ async function describeOtherCopies( `open it at 0:00 and locate the moment again`; return ( `- ${s.id} (${s.channel}, ${s.platform}, ${formatDuration(s.duration)}, ` + - `uploaded ${formatDate(s.uploadDate)}` + + `uploaded ${dateOrUndated(s.uploadDate)}` + `${s.hasTranscript ? "" : ", NO transcript"}) — ${timing}` ); }); @@ -2987,7 +2994,7 @@ function renderSpecResults(source: ShardSource, hits: SpecHit[]): string { `### ${h.title}\n` + `- video_id: ${h.videoId} | channel: ${h.channelName}` + (h.siteTitle ? ` | site: ${h.siteTitle}` : "") + - ` | uploaded: ${formatDate(h.uploadDate)} | matches: ${h.matches}` + + ` | uploaded: ${dateOrUndated(h.uploadDate)} | matches: ${h.matches}` + (h.webpageUrl ? `\n- source: ${h.webpageUrl}` : ""); const snips = h.snippets .map((s) => renderScopedSnippet(source, h, s)) diff --git a/mcp/src/undatedRecord.test.ts b/mcp/src/undatedRecord.test.ts @@ -0,0 +1,11 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { dateOrUndated } from "./server"; + +// lane/local-media (review B2): a local recording with no recording date has +// uploadDate "", and the listings say "undated" rather than print an empty +// field; a dated record prints exactly as before. +test("dateOrUndated: an empty date is named, a real one formatted as before", () => { + assert.equal(dateOrUndated(""), "undated"); + assert.equal(dateOrUndated("20240229"), "2024-02-29"); +}); diff --git a/umtool/report-to-video/attribution.mjs b/umtool/report-to-video/attribution.mjs @@ -119,7 +119,9 @@ export function attributionLine(entry, meta, provenance = {}) { // A cut with no channel to name anywhere reproduces the old line exactly, // rather than opening on a stray separator. const head = [channel, title].filter((s) => String(s ?? "").length > 0).join(" · "); - return `${head} · ${date} @ ${hms(at)}`; + // An undated recording (a local recording with no recording date: its + // uploadDate is "") drops the date, not leaves an empty field between dots. + return String(date ?? "").length > 0 ? `${head} · ${date} @ ${hms(at)}` : `${head} @ ${hms(at)}`; } /** diff --git a/umtool/report-to-video/attribution.test.mjs b/umtool/report-to-video/attribution.test.mjs @@ -10,6 +10,7 @@ import test from "node:test"; import { attributionLine, + attributionParts, channelName, cleanTitle, hms, @@ -131,3 +132,12 @@ test("isCalendarDate / uploadDateToIso", () => { assert.equal(uploadDateToIso("20250101"), "2025-01-01"); assert.equal(uploadDateToIso("2025-01-01"), "2025-01-01"); }); + +// lane/local-media: an undated local recording's uploadDate is "". +test("attributionLine: an undated recording drops the date, not leaves an empty field", () => { + assert.equal( + attributionLine({ start: 62 }, { title: "Lesson one", uploadDate: "", channel: "Classroom" }), + "Classroom · Lesson one @ 1:02", + ); + assert.equal(attributionParts({ start: 62 }, { title: "Lesson one", uploadDate: "" }).date, ""); +});