Archilyzer · Source

archilyzer

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

commit fd01705f5d0cde7f83cc12d164892ca0e75b946b
parent 701e9754cb1ce78f8b1b0b9ebc4a3a5756167a49
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 14 Oct 2026 21:49:54 -0400

common: learned spellings, calibrated on the jeralyzer proof — every window the judge reads must say it means the name (one "no" drops it: the 8B judge had kept "melony steelers" and "dr. Robert meloney" on a single yes); a spelling the terms' own query already finds is dropped as known ("Melanie Mack" under "Melanie Mac"), a heard span too; the confirm prompt names what is not the name (another person, an ordinary word); a hyphenated word is not a phrase

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

Diffstat:
Mcommon/controller/reportLearn.ts | 3++-
Mcommon/lib/report/draft/triage/confirm.ts | 34+++++++++++++++++++---------------
Mcommon/lib/report/draft/triage/judge.ts | 7+++++--
Mcommon/lib/report/draft/triage/learned.test.ts | 39+++++++++++++++++++++++++++++++++++----
Mcommon/lib/report/draft/triage/learned.ts | 42++++++++++++++++++++++++++++++++++--------
Mcommon/lib/report/draft/triage/task.ts | 3++-
6 files changed, 97 insertions(+), 31 deletions(-)

diff --git a/common/controller/reportLearn.ts b/common/controller/reportLearn.ts @@ -34,6 +34,7 @@ import { LEARNED_CAP, NAMES_PER_PASS, PROPOSALS_PER_NAME, + coveredByTerms, knownKeys, learnDue, namesForPass, @@ -176,7 +177,7 @@ async function runLearnJob( const count = c.countPhrases ? (a: Parameters<NonNullable<typeof c.countPhrases>>[0]) => c.countPhrases!(a) : c.listRecordings ? countViaEnumerate((a) => c.listRecordings!(a), enumerateViaTools(c)) : null; if (!count) throw new Error("this corpus cannot count a spelling in scope (no listing)"); const r = await runLearnPass( - { names: plan.names, question: s.question, scope: { channels: s.scope.channels, ...(s.scope.from ? { from: s.scope.from } : {}) }, known, at }, + { names: plan.names, question: s.question, scope: { channels: s.scope.channels, ...(s.scope.from ? { from: s.scope.from } : {}) }, known, at, covered: coveredByTerms(s.scope.terms, s.scope.regex === true) }, { corpus: c, ask, count, cuesOf: corpusCuesOf(c), log: onLog, signal }, ); kept = r.kept; diff --git a/common/lib/report/draft/triage/confirm.ts b/common/lib/report/draft/triage/confirm.ts @@ -12,10 +12,10 @@ // (newest first; a heard span's own window first) and must say it // means the watched name, quoting the line. The quote must be // VERBATIM in that window and hold the spelling, and be in the -// transcript's cues near it (R2's word check). One window that -// passes keeps the spelling with its proving line; else dropped — -// "not-the-name" (the judge said so, its reason kept) or -// "not-verbatim" (it said yes but its line is not in the window) +// transcript's cues near it (R2's word check). EVERY window read +// must pass: the spelling is kept with the first one's line; one +// "no" drops it as "not-the-name" (its reason kept), one yes whose +// line is not in the window as "not-verbatim" // // proposeSpellings asks the model for mis-hearings of each name (parseProposals // checks them); runLearnPass is the whole pass. Pure over the corpus tools, the @@ -200,8 +200,11 @@ export async function confirmSpellings(i: ConfirmInput, d: ConfirmDeps): Promise drop(p, "unread", `its windows could not be read: ${oneLine((e as Error).message)}`); continue; } + // EVERY window read must agree: one "not the name", or one line that is + // not verbatim, and the spelling is not learned (a common word heard as a + // name in one window is not the name in the next). for (const x of ids.slice(0, maxWindows)) { - if (proved) break; + if (verdicts.some((v) => !v.means || !v.verbatim)) break; const t = parsed.get(x.id); if (!t) continue; const wins = windowsOf(t.lines); @@ -244,7 +247,7 @@ export async function confirmSpellings(i: ConfirmInput, d: ConfirmDeps): Promise } } verdicts.push({ means: true, reason, verbatim: ok }); - if (!ok) continue; + if (!ok || proved) continue; proved = { spelling: normSpelling(p.spelling), means: p.means, @@ -262,12 +265,13 @@ export async function confirmSpellings(i: ConfirmInput, d: ConfirmDeps): Promise ...(p.k ? { k: p.k } : {}), }; } - if (proved) { + const no = verdicts.filter((v) => !v.means); + if (no.length) drop(p, "not-the-name", `judged not the name in ${no.length} of ${verdicts.length} window(s) read: ${no[0]!.reason}`); + else if (verdicts.some((v) => !v.verbatim)) drop(p, "not-verbatim", "the judge said it means the name, but its line is not verbatim in the window or the cues"); + else if (proved) { kept.push(proved); - log(` learn: "${p.spelling}" means ${p.means} — kept (${c.recordings} recording(s); “${proved.quote}” ${proved.recording} @ ${mmss(proved.start)})`); - } else if (verdicts.some((v) => v.means && !v.verbatim)) drop(p, "not-verbatim", "the judge said it means the name, but its line is not verbatim in the window or the cues"); - else if (verdicts.length) drop(p, "not-the-name", `judged not the name in ${verdicts.length} window(s): ${verdicts[0]!.reason}`); - else drop(p, "unread", "no window holding it could be read"); + log(` learn: "${p.spelling}" means ${p.means} — kept (${c.recordings} recording(s), confirmed in ${verdicts.length} window(s); “${proved.quote}” ${proved.recording} @ ${mmss(proved.start)})`); + } else drop(p, "unread", "no window holding it could be read"); } return { kept, dropped, counted, judged }; } @@ -278,7 +282,7 @@ export type ProposeResult = { proposed: PendingSpelling[]; dropped: LearnedDrop[ /** Ask the model for each name's likely mis-hearings (checked by parseProposals). */ export async function proposeSpellings( - i: { names: string[]; question: string; known: ReadonlySet<string>; at: string; k?: number }, + i: { names: string[]; question: string; known: ReadonlySet<string>; at: string; k?: number; covered?: (spelling: string) => boolean }, d: { ask: Ask; log?: (line: string) => void; signal?: AbortSignal }, ): Promise<ProposeResult> { const k = i.k ?? PROPOSALS_PER_NAME; @@ -297,7 +301,7 @@ export async function proposeSpellings( d.log?.(`learn: proposals for "${name}" failed — ${oneLine((e as Error).message, 160)}`); continue; } - const r = parseProposals(name, ans, { k, known }); + const r = parseProposals(name, ans, { k, known, ...(i.covered ? { covered: i.covered } : {}) }); for (const s of r.spellings) { known.add(spellingKey(s)); proposed.push({ spelling: s, means: name, source: "proposed" }); @@ -312,10 +316,10 @@ export type LearnPassResult = { proposed: PendingSpelling[]; kept: LearnedSpelli /** The whole pass: propose for each name, then confirm every proposal. */ export async function runLearnPass( - i: { names: string[]; question: string; scope: ConfirmInput["scope"]; known: ReadonlySet<string>; at: string; k?: number; windows?: number }, + i: { names: string[]; question: string; scope: ConfirmInput["scope"]; known: ReadonlySet<string>; at: string; k?: number; windows?: number; covered?: (spelling: string) => boolean }, d: ConfirmDeps, ): Promise<LearnPassResult> { - const p = await proposeSpellings({ names: i.names, question: i.question, known: i.known, at: i.at, ...(i.k ? { k: i.k } : {}) }, d); + const p = await proposeSpellings({ names: i.names, question: i.question, known: i.known, at: i.at, ...(i.k ? { k: i.k } : {}), ...(i.covered ? { covered: i.covered } : {}) }, d); const c = await confirmSpellings({ pending: p.proposed, question: i.question, scope: i.scope, at: i.at, ...(i.windows ? { windows: i.windows } : {}) }, d); return { proposed: p.proposed, kept: c.kept, dropped: [...p.dropped, ...c.dropped], counted: c.counted, judged: c.judged }; } diff --git a/common/lib/report/draft/triage/judge.ts b/common/lib/report/draft/triage/judge.ts @@ -47,6 +47,8 @@ export type JudgeInput = { // keys: the names, the learned and removed spellings) are not reported. names?: string[]; known?: ReadonlySet<string>; + // A span the terms' own query already finds is not reported (coveredByTerms). + covered?: (span: string) => boolean; }; export type JudgeTrace = (e: { t: "batch"; k: number; of: number; ids: string[]; lines: string[]; model: string; usd: number } | { t: "check"; quote: string; cite: { channel?: string; video?: string; start?: number; url?: string }; ok: boolean; reason: string; stage: "triage"; dropped?: boolean; claim?: string }) => void; @@ -207,7 +209,7 @@ export async function judgeCandidates(i: JudgeInput, d: JudgeDeps): Promise<Judg continue; } if (names.length && Array.isArray(ans.heard)) { - for (const h of await checkHeard(ans.heard, { id: c.id, title, slug, chunk: ch, names, known: i.known, cues, already: heard })) { + for (const h of await checkHeard(ans.heard, { id: c.id, title, slug, chunk: ch, names, known: i.known, ...(i.covered ? { covered: i.covered } : {}), cues, already: heard })) { if ("reason" in h) { heardDropped.push(h); lines.push(`${c.id}: heard “${h.span}” as ${h.means} [put aside: ${h.reason}]`); @@ -306,6 +308,7 @@ export async function checkHeard( chunk: readonly Line[]; names: readonly string[]; known?: ReadonlySet<string>; + covered?: (span: string) => boolean; cues: (slug: string, id: string) => Promise<readonly WordCue[] | null>; already?: readonly TriageHeard[]; }, @@ -323,7 +326,7 @@ export async function checkHeard( out.push({ span, means: meansRaw, id: o.id, reason: "not a watched name" }); continue; } - if (byKey.has(key) || o.known?.has(key) || done.has(key)) continue; + if (byKey.has(key) || o.known?.has(key) || done.has(key) || o.covered?.(span)) continue; if (key.split(" ").length > 4) { out.push({ span, means, id: o.id, reason: "too long (at most 4 words)" }); continue; diff --git a/common/lib/report/draft/triage/learned.test.ts b/common/lib/report/draft/triage/learned.test.ts @@ -21,6 +21,7 @@ import { checkHeard, judgeCandidates } from "./judge"; import { CONFIRM_SYSTEM, LEARNED_CAP, + coveredByTerms, PROPOSE_SYSTEM, SUGGEST_REMOVE_AFTER, activeLearned, @@ -124,6 +125,12 @@ const cuesOver = (recs: Rec[]) => async (_c: string, id: string) => { }; type Asked = { system: string; user: string }; +// The excerpt line holding a spelling (what an honest judge quotes). +const lineHolding = (user: string, spelling: string) => + user + .split("\n") + .map((l) => l.replace(/^\[[\d:]+\]\s*/, "")) + .find((l) => !l.includes(":") && l.toLowerCase().includes(spelling.toLowerCase())) ?? ""; function askScript(answer: (a: Asked) => unknown) { const asked: Asked[] = []; const ask = async <T,>(system: string, user: string): Promise<T> => { @@ -153,6 +160,8 @@ test("namesOf: a watch's name-like alternatives — capitalised or several words assert.deepEqual(namesOf(terms, true), ["Melonie", "Melanie", "Melanie Mac", "Hannah Claire", "Styx", "co host", "guest host", "joining the show"]); assert.deepEqual(namesOf("Pia Tartlet", false), ["Pia Tartlet"]); assert.deepEqual(namesOf("contest", false), []); + // A hyphenated word is one word, not a phrase. + assert.deepEqual(namesOf("co-host|guest-host", true), []); assert.deepEqual(namesOf("(Pia|Pea) Tartlet|Pia Tartlet", true), ["Pia Tartlet"]); assert.equal(termsKey("Pia Tartlet", false), "lit:Pia Tartlet"); assert.equal(termsKey("", true), null); @@ -247,7 +256,7 @@ test("confirmSpellings: no hits, judged not the name, a line not verbatim — dr assert.equal(system, CONFIRM_SYSTEM); if (/Spelling in the transcript: tart lit/.test(user)) return { means: false, quote: "the tart lit up the whole room", reason: "a tart that lit up, not her" }; if (/Spelling in the transcript: could not/.test(user)) return { means: true, quote: "she could not ever make it", reason: "invented" }; - return { means: true, quote: "pia tart lit could not make it tonight", reason: "the guest who could not come" }; + return { means: true, quote: lineHolding(user, "pia tart lit"), reason: "the guest, named" }; }); const r = await confirmSpellings( { @@ -281,6 +290,19 @@ test("confirmSpellings: no hits, judged not the name, a line not verbatim — dr assert.equal(r.kept[0]!.url, "https://synth.example/?v=synth-kitchen%2Fd-04&t=0"); }); +test("confirmSpellings: EVERY window read must agree — a yes in one and a no in the next drops it as not the name", async () => { + const count = countViaEnumerate(listOver(RECS), enumerateOver(RECS)); + // The newest window (d-04) says yes; the next (b-02) says it is someone else. + const { ask, asked } = askScript(({ user }) => + /Late stream/.test(user) ? { means: true, quote: lineHolding(user, "pia tart lit"), reason: "her" } : { means: false, quote: lineHolding(user, "pia tart lit"), reason: "a pie stall, not her" }, + ); + const r = await confirmSpellings({ pending: [{ spelling: "pia tart lit", means: "Pia Tartlet", source: "proposed" }], question: "Q?", scope: { channels: [CHAN] }, at: "t" }, { corpus: corpusOver(RECS), ask, count, cuesOf: cuesOver(RECS) }); + assert.equal(asked.length, 2); + assert.deepEqual(r.kept, []); + assert.equal(r.dropped[0]!.reason, "not-the-name"); + assert.equal(r.dropped[0]!.why, "judged not the name in 1 of 2 window(s) read: a pie stall, not her"); +}); + test("confirmSpellings: a count that read part of the scope and found nothing is unread, never no-hits", async () => { const count: CountPhrasesFn = async (a) => ({ counts: Object.fromEntries(a.phrases.map((p) => [p, { recordings: 0, lines: 0, examples: [] }])), complete: false, problems: ["Other (stopped at page 2 of 5)"], listed: 10 }); const r = await confirmSpellings({ pending: [{ spelling: "x y", means: "X Y", source: "proposed" }], question: "Q?", scope: { channels: [CHAN] }, at: "t" }, { corpus: corpusOver(RECS), ask: askScript(() => ({})).ask, count }); @@ -290,12 +312,21 @@ test("confirmSpellings: a count that read part of the scope and found nothing is test("runLearnPass: proposals asked per name, checked, then confirmed", async () => { const count = countViaEnumerate(listOver(RECS), enumerateOver(RECS)); const { ask, asked } = askScript(({ system }) => - system === PROPOSE_SYSTEM ? { spellings: ["pia tart lit", "Pia Tartlet", "Pea Tartlet"] } : { means: true, quote: "pia tart lit could not make it tonight", reason: "her" }, + system === PROPOSE_SYSTEM ? { spellings: ["pia tart lit", "Pia Tartlet", "Pea Tartlet", "Pia Tartlet tonight"] } : { means: true, quote: lineHolding(asked.at(-1)!.user, "pia tart lit"), reason: "her" }, + ); + // A spelling the terms' own query already finds adds nothing ("Pia Tartlet tonight" under "Pia Tartlet"). + const r = await runLearnPass( + { names: ["Pia Tartlet"], question: "Who joined?", scope: { channels: [CHAN] }, known: new Set(), at: "t", covered: coveredByTerms("Pia Tartlet|guest", true) }, + { corpus: corpusOver(RECS), ask, count, cuesOf: cuesOver(RECS) }, ); - const r = await runLearnPass({ names: ["Pia Tartlet"], question: "Who joined?", scope: { channels: [CHAN] }, known: new Set(), at: "t" }, { corpus: corpusOver(RECS), ask, count, cuesOf: cuesOver(RECS) }); assert.deepEqual(r.proposed.map((p) => p.spelling), ["pia tart lit", "Pea Tartlet"]); assert.deepEqual(r.kept.map((k) => k.spelling), ["pia tart lit"]); - assert.deepEqual(r.dropped.map((d) => [d.spelling, d.reason]), [["Pea Tartlet", "no-hits"]]); + assert.deepEqual(r.dropped.map((d) => [d.spelling, d.reason, d.why]), [ + ["Pia Tartlet tonight", "known", "the terms already match it"], + ["Pea Tartlet", "no-hits", "does not occur in scope (4 recordings counted)"], + ]); + assert.equal(coveredByTerms("Melanie Mac", false)("Melanie Mack"), true); + assert.equal(coveredByTerms("Gothix", false)("Gothics"), false); assert.match(asked[0]!.user, /Name: Pia Tartlet/); }); diff --git a/common/lib/report/draft/triage/learned.ts b/common/lib/report/draft/triage/learned.ts @@ -213,7 +213,8 @@ export function namesOf(terms: string | null | undefined, regex: boolean): strin const key = spellingKey(a); if (!key || seen.has(key)) continue; const capital = /\p{Lu}/u.test(a); - const multi = key.includes(" "); + // Several words: spaces in the alternative itself (a hyphenated word is one). + const multi = /\s/.test(a); if (!capital && !multi) continue; seen.add(key); (capital ? caps : phrases).push(a); @@ -293,6 +294,24 @@ export function holdsSpelling(text: string, spelling: string): boolean { } } +/** + * Does the terms' own query already find this spelling (the literal terms as + * a substring, a regex as it is, case aside — as enumerate matches them)? A + * spelling it finds adds nothing ("Melanie Mack" under "Melanie Mac"). + */ +export function coveredByTerms(terms: string | null | undefined, regex: boolean): (spelling: string) => boolean { + const t = (terms ?? "").trim(); + if (!t) return () => false; + if (!regex) return (s) => s.toLowerCase().includes(t.toLowerCase()); + let re: RegExp; + try { + re = new RegExp(t, "i"); + } catch { + return () => false; + } + return (s) => re.test(s); +} + /** "terms + 3 learned" (the tick log's and triage.json's words). */ export const learnedWords = (n: number, terms = true): string => (n ? `${terms ? "terms + " : ""}${n} learned` : terms ? "terms" : "no learned spelling"); @@ -318,7 +337,11 @@ export const proposeUser = (name: string, question: string, k = PROPOSALS_PER_NA * itself, already known (in the terms, learned or blocked), repeated, too * long, or not words is put aside with its reason; at most `k` kept. */ -export function parseProposals(name: string, answer: unknown, o: { k?: number; known?: ReadonlySet<string> } = {}): { spellings: string[]; dropped: { spelling: string; reason: LearnedDropReason; why: string }[] } { +export function parseProposals( + name: string, + answer: unknown, + o: { k?: number; known?: ReadonlySet<string>; covered?: (spelling: string) => boolean } = {}, +): { spellings: string[]; dropped: { spelling: string; reason: LearnedDropReason; why: string }[] } { const k = o.k ?? PROPOSALS_PER_NAME; const raw = Array.isArray((answer as { spellings?: unknown })?.spellings) ? ((answer as { spellings: unknown[] }).spellings) : []; const spellings: string[] = []; @@ -334,6 +357,7 @@ export function parseProposals(name: string, answer: unknown, o: { k?: number; k else if (key === spellingKey(name)) continue; else if (seen.has(key)) continue; else if (o.known?.has(key)) dropped.push({ spelling: s, reason: "known", why: "already in the terms, learned or removed" }); + else if (o.covered?.(s)) dropped.push({ spelling: s, reason: "known", why: "the terms already match it" }); else if (spellings.length >= k) continue; else { seen.add(key); @@ -346,11 +370,13 @@ export function parseProposals(name: string, answer: unknown, o: { k?: number; k // ─── the confirmation (the judge) ─── export const CONFIRM_SYSTEM = - "You read an excerpt of an automatic transcript, which often mishears names. Say whether the given spelling, " + - "where it occurs in the excerpt, is the transcript's mis-hearing of the given name (the same person or thing), " + - "or something else (another word, another person). Copy the line holding the spelling EXACTLY, character for " + - "character, without the bracketed timestamp. Answer means = true only when the excerpt makes it clear; give one " + - "short reason."; + "An automatic transcript often misspells names: a name is heard as a sound-alike, split or joined, or with a " + + "letter dropped or added. You are given a NAME, a SPELLING and a transcript excerpt where the spelling occurs. " + + "Decide whether the given spelling, there, is the transcript's misspelling of the name: the speaker means that " + + "person or thing. Answer means = false when it plainly means something else there: an ordinary word, or another " + + "person (a different first name, surname or title beside it). Answer means = true when the speaker is most likely " + + "talking about the name. Copy the line holding the spelling EXACTLY, character for character, without the " + + "bracketed timestamp, and give one short reason."; export const CONFIRM_SCHEMA = { type: "object", @@ -359,7 +385,7 @@ export const CONFIRM_SCHEMA = { }; export const confirmUser = (o: { spelling: string; means: string; question: string; title: string; excerpt: string }) => - `Name: ${o.means}\nSpelling in the transcript: ${o.spelling}\nThe transcripts are searched for: ${o.question}\n\nVideo: ${o.title}\n\nTranscript excerpt:\n${o.excerpt}`; + `Name: ${o.means}\nSpelling in the transcript: ${o.spelling}\nThe transcripts are searched for: ${o.question}\n\nVideo: ${o.title}\n\nTranscript excerpt:\n${o.excerpt}\n\nIs "${o.spelling}" here the transcript's misspelling of "${o.means}"?`; // ─── heard spans (the triage judge's extra field) ─── diff --git a/common/lib/report/draft/triage/task.ts b/common/lib/report/draft/triage/task.ts @@ -26,7 +26,7 @@ import { openTrace, NO_TRACE, type RunTracer } from "../tasks/trace"; import type { CorpusToolsLike } from "../tasks/types"; import { judgeCandidates } from "./judge"; import { confirmSpellings, countViaEnumerate, type CountPhrasesFn } from "./confirm"; -import { joinedQuery, learnedWords, type LearnedSpelling } from "./learned"; +import { coveredByTerms, joinedQuery, learnedWords, type LearnedSpelling } from "./learned"; import { readTriageFile, readTriageSeen, triageTracePath, writeTriageFile, writeTriageSeen, type TriagePaths } from "./store"; import { triageCandidates } from "./tier0"; import { TRIAGE_SEEN_FORMAT, escalationOf, partialWords, triageLine, type TriageFile, type TriageWindow } from "./types"; @@ -210,6 +210,7 @@ export async function runTriage(input: TriageRunInput, deps: TriageRunDeps): Pro origin: input.origin ?? null, ...(input.names?.length ? { names: input.names } : {}), ...(input.known ? { known: input.known } : {}), + ...(input.names?.length ? { covered: coveredByTerms(file.terms, file.regex) } : {}), }, { corpus: deps.corpus,