Archilyzer · Source

archilyzer

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

commit 1e287a181b5705c5a1be62c0374fa58b0a87280d
parent be043b961d9997af184d1b38b83a04b3439a0693
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Sat, 21 Nov 2026 19:08:02 -0500

common: the stored-text and do-not-clean gates read source, not build output or yt-dlp's option tables

Three gates went red on merged main; none of the hits was app code.

- do-not-clean writer gate: every hit was under homepage/out-private/, the
  homepage's private build (gitignored), which holds the published source
  tree, a copy of the one writer and its allow-list. The walk now skips
  out-private, as envVars.test.ts already does.
- caption-read gate: every hit was a compiled chunk in umtool's alternate
  dist dirs (.next-e2e-start, .next-prev, gitignored). The walk now skips
  every dot-directory, as the do-not-clean gate does; no tracked source lives
  under one in these roots.
- chat-argv gate: the hits were rows of lib/ytdlpOptions.ts and
  lib/ytdlpOptionClasses.ts (lane network-exits), yt-dlp's option table and
  each option's class: pure data, read only by lib/networkExits.ts to
  resolve a listing's argv, never built into one. Only a table row outside
  every function passes; the exemption fails when a table loses its rows or
  when anything but networkExits.ts imports either table.

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

Diffstat:
Mcommon/lib/doNotCleanGate.test.ts | 5++++-
Mcommon/lib/storedText.grep.test.ts | 43++++++++++++++++++++++++++++++++++++++++---
2 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/common/lib/doNotCleanGate.test.ts b/common/lib/doNotCleanGate.test.ts @@ -17,7 +17,10 @@ import { fileURLToPath } from "node:url"; const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", ".."); const ROOTS = ["common", "editor", "umtool", "mcp", "scripts", "export", "homepage", "plans"]; -const SKIP_DIRS = new Set(["node_modules", ".next", "out", "dist", "public", "e2e", ".e2e-song", "test-results", ".git", "coverage"]); +// Build and test output, never source. `out-private` is the homepage's private +// build (gitignored): it holds the published source tree — a copy of every +// file this gate reads, the one writer and its allow-list among them. +const SKIP_DIRS = new Set(["node_modules", ".next", "out", "out-private", "dist", "public", "e2e", ".e2e-song", "test-results", ".git", "coverage"]); const EXT = /\.(ts|tsx|mts|cts|js|mjs|cjs)$/; const TEST = /\.(test|spec)\.[cm]?[jt]sx?$|\.unit\.ts$/; diff --git a/common/lib/storedText.grep.test.ts b/common/lib/storedText.grep.test.ts @@ -34,7 +34,11 @@ const COMMON = path.dirname(path.dirname(fileURLToPath(import.meta.url))); const REPO = path.dirname(COMMON); const ROOTS = ["common", "editor/app", "editor/lib", "mcp/src", "umtool", "export/scripts", "export/lib", "export/app", "scripts", "docker"]; -const SKIP_DIRS = new Set(["node_modules", ".next", "out", "public", "e2e", "dist", ".turbo"]); +const SKIP_DIRS = new Set(["node_modules", ".next", "out", "out-private", "public", "e2e", "dist", ".turbo"]); +// Every dot-directory under these roots is build or test output, never source +// (umtool's alternate dist dirs `.next-*`, `.e2e-song`, …, all gitignored): a +// checkout that has run a build holds its compiled chunks, which name the same +// files as the source they were built from — and the source is what is gated. // The names of the raw chat in code: the two constants, the stored one, the // literal (but not its `.part`, its `.zst` spelled out in a comment, or the @@ -102,7 +106,9 @@ async function walk(dir: string, out: string[]): Promise<void> { for (const e of entries) { if (SKIP_DIRS.has(e.name)) continue; const p = path.join(dir, e.name); - if (e.isDirectory()) await walk(p, out); + if (e.isDirectory()) { + if (!e.name.startsWith(".")) await walk(p, out); + } else if (/\.(?:ts|tsx|mjs|js)$/.test(e.name) && !/\.(?:test|spec|unit)\.|\.d\.m?ts$/.test(e.name)) out.push(p); } } @@ -224,6 +230,26 @@ const CALLERS: Record<string, Record<string, number>> = { downloadSubsForUrl: { "common/ytdlp/runYtdlp.ts": 1 }, }; +// yt-dlp's OPTION TABLES (lane network-exits): every option the installed +// yt-dlp's parser accepts, and a person's class of each — pure data, outside +// any function, read only by lib/networkExits.ts to RESOLVE a listing's argv +// as yt-dlp would (resolveLongOption, argvOptions). Nothing builds an argv +// from them, so a row naming a subtitle flag writes nothing. Only a table ROW +// outside every function passes: an argv element in these files, or a row +// moved into a function, is a site like any other. +const OPTION_TABLES: { file: string; row: RegExp; why: string }[] = [ + { + file: "common/lib/ytdlpOptions.ts", + row: /^\s*\[(?:null|"[^"]+"), "--[a-z0-9-]+", (?:true|false)\],$/, + why: "YTDLP_OPTIONS: [short, long, takes a value], generated from yt-dlp's parser", + }, + { + file: "common/lib/ytdlpOptionClasses.ts", + row: /^\s*"--[a-z0-9-]+": "(?:cookie|login|header|config|proxy|none)",$/, + why: "YTDLP_OPTION_CLASSES: the network-exit class of each long name", + }, +]; + const BUILDER_RES = Object.keys(CHAT_WRITERS).map((name) => ({ name, call: new RegExp(`\\b${name}\\s*\\(`, "g"), @@ -243,13 +269,16 @@ function enclosingFunction(lines: string[], i: number): string | null { test("every yt-dlp argv that can write the raw chat is a pinned builder, and every caller of one is pinned", async () => { const sites: string[] = []; const calls: Record<string, Record<string, number>> = {}; + const tableRows = new Set<string>(); for (const { rel, lines } of await appFiles()) { for (let i = 0; i < lines.length; i++) { const code = codeOnly(lines[i]); if (SUB_FLAGS.test(code)) { const fn = enclosingFunction(lines, i); const pinned = fn ? CHAT_WRITERS[fn] : undefined; - if (!pinned || pinned.file !== rel) sites.push(`${rel}:${i + 1} (in ${fn ?? "no function"}): ${lines[i].trim()}`); + const table = fn === null ? OPTION_TABLES.find((t) => t.file === rel && t.row.test(code)) : undefined; + if (table) tableRows.add(table.file); + else if (!pinned || pinned.file !== rel) sites.push(`${rel}:${i + 1} (in ${fn ?? "no function"}): ${lines[i].trim()}`); } for (const { name, call, def } of BUILDER_RES) { if (!code.includes(name)) continue; @@ -265,6 +294,14 @@ test("every yt-dlp argv that can write the raw chat is a pinned builder, and eve "for the stored chat first (listingHas / storedFormsIn), have a test that the fake yt-dlp is not asked for it, " + "and be listed in CHAT_WRITERS", ); + // The table exemption cannot rot, and holds only while the tables are read + // by the one argv RESOLVER: a new importer of either could build from them. + for (const t of OPTION_TABLES) assert.ok(tableRows.has(t.file), `${t.file} has no subtitle-flag row any more: drop it from OPTION_TABLES`); + const importers = new Set<string>(); + for (const { rel, lines } of await appFiles()) { + if (lines.some((l) => /\bfrom\s+["'][^"']*\/ytdlpOption(?:s|Classes)(?:\.[jt]s)?["']/.test(codeOnly(l)))) importers.add(rel); + } + assert.deepEqual([...importers], ["common/lib/networkExits.ts"], "yt-dlp's option tables are read by lib/networkExits.ts alone"); assert.deepEqual( calls, CALLERS,