commit 4c1aa9c5b2abb49d8c830e011983ef0843fdcb60
parent 6daaefcde8d3deef3323d7ffea79ad0b49e7cba9
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 14 Oct 2026 22:57:53 -0400
common, umtool: learned spellings by the review's rulings — kept when at least 2 of the windows read (up to 3) say it means the name, each quoting a verbatim line, or with a single window that yes and at least 3 recordings in scope (keptByWindows; "too-few" a new drop reason); every window's verdict kept on the spelling or its drop, logged, and listed on the series page; names are capitalised alternatives only; tests and the editor e2e (three windows of the spelling) to match
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
8 files changed, 166 insertions(+), 77 deletions(-)
diff --git a/common/controller/reportLearn.ts b/common/controller/reportLearn.ts
@@ -93,7 +93,7 @@ export async function planLearn(id: string, deps: { paths: ReportDraftDeps["path
const refused = !triagesFirst(s)
? `"${id}" does not triage: a learned spelling is a watch's (or a schedule with triage first)`
: !names.length
- ? `"${id}" has no name in its terms to learn spellings of (a literal alternative with a capital letter, or a phrase)`
+ ? `"${id}" has no name in its terms to learn spellings of (a literal alternative with a capital letter)`
: null;
return {
id,
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). 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"
+// transcript's cues near it (R2's word check). Kept when at least
+// 2 of the windows read say so (keptByWindows); with a single
+// window, that yes and at least 3 recordings in scope. Each
+// window's verdict is kept on the spelling (or its drop)
//
// proposeSpellings asks the model for mis-hearings of each name (parseProposals
// checks them); runLearnPass is the whole pass. Pure over the corpus tools, the
@@ -44,6 +44,7 @@ import {
type LearnedDropReason,
type LearnedSpelling,
type SpellingSource,
+ type SpellingWindow,
type TriageHeard,
} from "./learned";
@@ -161,8 +162,8 @@ export async function confirmSpellings(i: ConfirmInput, d: ConfirmDeps): Promise
return true;
});
if (!pending.length) return { kept, dropped, counted: null, judged: 0 };
- const drop = (p: PendingSpelling, reason: LearnedDropReason, why: string) => {
- dropped.push({ spelling: p.spelling, means: p.means, source: p.source, reason, why, at: i.at, ...(p.k ? { k: p.k } : {}) });
+ const drop = (p: PendingSpelling, reason: LearnedDropReason, why: string, windows?: SpellingWindow[]) => {
+ dropped.push({ spelling: p.spelling, means: p.means, source: p.source, reason, why, at: i.at, ...(p.k ? { k: p.k } : {}), ...(windows?.length ? { windows } : {}) });
log(` learn: "${p.spelling}" (${p.means}) dropped — ${why}`);
};
let counted: PhraseCounts;
@@ -190,7 +191,7 @@ export async function confirmSpellings(i: ConfirmInput, d: ConfirmDeps): Promise
if (ids.length >= maxWindows) break;
if (!ids.some((x) => x.id === ex.id)) ids.push({ id: ex.id, slug: ex.channelSlug, title: ex.title, date: ex.date });
}
- const verdicts: { means: boolean; reason: string; verbatim: boolean }[] = [];
+ const verdicts: SpellingWindow[] = [];
let proved: LearnedSpelling | null = null;
let parsed: Map<string, ParsedTranscript>;
try {
@@ -200,11 +201,9 @@ 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).
+ // Every window available (up to N) is read and its verdict kept; the
+ // decision is keptByWindows' (a majority of them).
for (const x of ids.slice(0, maxWindows)) {
- if (verdicts.some((v) => !v.means || !v.verbatim)) break;
const t = parsed.get(x.id);
if (!t) continue;
const wins = windowsOf(t.lines);
@@ -227,7 +226,8 @@ export async function confirmSpellings(i: ConfirmInput, d: ConfirmDeps): Promise
}
const reason = oneLine(ans.reason) || "(no reason given)";
if (ans.means !== true) {
- verdicts.push({ means: false, reason, verbatim: true });
+ verdicts.push({ recording: x.id, start: excerpt[0]![0], means: false, verbatim: true, reason });
+ log(` learn: "${p.spelling}" @ ${x.id}: not the name — ${reason}`);
continue;
}
const quote = clean(ans.quote);
@@ -246,7 +246,8 @@ export async function confirmSpellings(i: ConfirmInput, d: ConfirmDeps): Promise
}
}
}
- verdicts.push({ means: true, reason, verbatim: ok });
+ verdicts.push({ recording: x.id, start: at, means: true, verbatim: ok, reason, ...(quote ? { quote } : {}) });
+ log(` learn: "${p.spelling}" @ ${x.id} ${mmss(at)}: means ${p.means}${ok ? ` — “${quote}”` : " — but its line is not verbatim"}`);
if (!ok || proved) continue;
proved = {
spelling: normSpelling(p.spelling),
@@ -265,17 +266,42 @@ export async function confirmSpellings(i: ConfirmInput, d: ConfirmDeps): Promise
...(p.k ? { k: p.k } : {}),
};
}
- 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), confirmed in ${verdicts.length} window(s); “${proved.quote}” ${proved.recording} @ ${mmss(proved.start)})`);
- } else drop(p, "unread", "no window holding it could be read");
+ const decision = keptByWindows(verdicts, c.recordings);
+ if (decision.keep && proved) {
+ kept.push({ ...(proved as LearnedSpelling), windows: verdicts });
+ log(` learn: "${p.spelling}" means ${p.means} — kept (${decision.why}; ${c.recordings} recording(s); “${(proved as LearnedSpelling).quote}” ${(proved as LearnedSpelling).recording} @ ${mmss((proved as LearnedSpelling).start)})`);
+ } else drop(p, decision.reason ?? "unread", decision.why, verdicts);
}
return { kept, dropped, counted, judged };
}
+/** One window the judge read for a spelling: where, its verdict, and whether its quoted line was verbatim. */
+export type { SpellingWindow };
+
+// A spelling read in a single window needs this many recordings in scope.
+export const ONE_WINDOW_MIN_HITS = 3;
+
+/**
+ * The confirmation's rule (the operator's ruling, R6.3 review): kept when at
+ * least 2 of the windows read (up to 3) say it means the name, each with a
+ * verbatim quoted line; with only 1 window read, that one yes AND at least
+ * ONE_WINDOW_MIN_HITS recordings in scope. Else the reason: not verbatim (the
+ * judge agreed, its lines were not in the transcript), too few (one yes, too
+ * few recordings), not the name, or unread (no window).
+ */
+export function keptByWindows(ws: readonly SpellingWindow[], hits: number): { keep: boolean; why: string; reason?: LearnedDropReason } {
+ const read = ws.length;
+ const yes = ws.filter((w) => w.means && w.verbatim).length;
+ const means = ws.filter((w) => w.means).length;
+ if (!read) return { keep: false, reason: "unread", why: "no window holding it could be read" };
+ const said = `${yes} of ${read} window${read === 1 ? "" : "s"} read said it means the name, quoting a verbatim line`;
+ if (read >= 2 ? yes >= 2 : yes === 1 && hits >= ONE_WINDOW_MIN_HITS) return { keep: true, why: said };
+ if (read >= 2 ? means >= 2 : means === 1 && hits >= ONE_WINDOW_MIN_HITS) return { keep: false, reason: "not-verbatim", why: `${said}: the judge said so in ${means}, but its lines were not verbatim in the window or the cues` };
+ if (read === 1 && means === 1) return { keep: false, reason: "too-few", why: `${said}, but it occurs in only ${hits} recording${hits === 1 ? "" : "s"}: one window needs ${ONE_WINDOW_MIN_HITS}` };
+ const no = ws.find((w) => !w.means);
+ return { keep: false, reason: "not-the-name", why: `${said} (needs 2)${no ? `: ${no.reason}` : ""}` };
+}
+
// ─── the proposal pass ───
export type ProposeResult = { proposed: PendingSpelling[]; dropped: LearnedDrop[]; asked: number };
diff --git a/common/lib/report/draft/triage/learned.test.ts b/common/lib/report/draft/triage/learned.test.ts
@@ -16,7 +16,7 @@ import path from "node:path";
import type { EnumeratedAnswer, EnumerateFn, ListFn } from "../refresh/delta";
import type { CorpusToolsLike } from "../tasks/types";
import { EXTRACT_SYSTEM } from "../tasks/sweep-pipeline";
-import { confirmSpellings, countViaEnumerate, runLearnPass, type CountPhrasesFn } from "./confirm";
+import { confirmSpellings, countViaEnumerate, keptByWindows, runLearnPass, type CountPhrasesFn } from "./confirm";
import { checkHeard, judgeCandidates } from "./judge";
import {
CONFIRM_SYSTEM,
@@ -155,13 +155,12 @@ const learnedOf = (spelling: string, over: Partial<LearnedSpelling> = {}): Learn
// ─── names, proposals, the query ───
-test("namesOf: a watch's name-like alternatives — capitalised or several words; regex classes skipped; \\b anchors stripped", () => {
+test("namesOf: a watch's proper names — capitalised alternatives only; lowercase phrases and regex classes skipped; \\b anchors stripped", () => {
const terms = "co-?host|co host|guest host|\\bguests?\\b|Melonie|\\bMelanie\\b|Melanie Mac|Hannah Claire|[Gg]othix|Styx|joining the show";
- assert.deepEqual(namesOf(terms, true), ["Melonie", "Melanie", "Melanie Mac", "Hannah Claire", "Styx", "co host", "guest host", "joining the show"]);
+ assert.deepEqual(namesOf(terms, true), ["Melonie", "Melanie", "Melanie Mac", "Hannah Claire", "Styx"]);
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("co-host|guest-host|pia tartlet", 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);
@@ -250,27 +249,42 @@ test("judgeCandidates with names: the prompt asks for heard spans; a verbatim on
// ─── the confirmation ───
-test("confirmSpellings: no hits, judged not the name, a line not verbatim — dropped with their reasons; one kept with its proving line", async () => {
- const count = countViaEnumerate(listOver(RECS), enumerateOver(RECS));
+// A second corpus for the confirmation's rule: three windows of one spelling.
+const RECS2: Rec[] = [
+ { id: "w-01", date: "20260901", title: "Night one", lines: ["tonight pia tart lit is judging", "the pies were great", "we could not find the oven"] },
+ { id: "w-02", date: "20260910", title: "Night two", lines: ["pia tart lit joined us again", "she brought cherries", "we could not stop eating"] },
+ { id: "w-03", date: "20260920", title: "Night three", lines: ["thanks pia tart lit for coming", "see you soon", "goodbye"] },
+ { id: "w-04", date: "20260925", title: "Bakery day", lines: ["the downtown bakery opened", "lines around the block", "great day"] },
+];
+const spellingOf = (user: string) => /Spelling in the transcript: (.*)/.exec(user)?.[1] ?? "";
+const titleOf = (user: string) => /Video: (.*)/.exec(user)?.[1] ?? "";
+
+test("confirmSpellings: kept by a majority of the windows read (2 of up to 3), each verdict kept; one window needs 3 recordings; no hits, not the name, not verbatim, too few — dropped with why", async () => {
+ const base = countViaEnumerate(listOver(RECS2), enumerateOver(RECS2));
+ // "downtown bakery" is in one recording; this count says three (its other two unreadable), so one window decides.
+ const count: CountPhrasesFn = async (a) => {
+ const c = await base(a);
+ if (c.counts["downtown bakery"]) c.counts["downtown bakery"] = { ...c.counts["downtown bakery"], recordings: 3 };
+ return c;
+ };
const { ask } = askScript(({ system, user }) => {
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: lineHolding(user, "pia tart lit"), reason: "the guest, named" };
+ const sp = spellingOf(user);
+ const t = titleOf(user);
+ const line = lineHolding(user, sp);
+ if (sp === "pia tart lit") return t === "Night two" ? { means: false, quote: line, reason: "another Pia" } : { means: true, quote: line, reason: "the guest" };
+ if (sp === "tart lit") return t === "Night three" ? { means: true, quote: line, reason: "maybe" } : { means: false, quote: line, reason: "not her" };
+ if (sp === "could not") return { means: true, quote: "she could not ever make it", reason: "invented" };
+ return { means: true, quote: line, reason: "her bakery" };
});
const r = await confirmSpellings(
{
- pending: [
- { spelling: "Pea Tartlet", means: "Pia Tartlet", source: "proposed" },
- { spelling: "tart lit", means: "Pia Tartlet", source: "proposed" },
- { spelling: "could not", means: "Pia Tartlet", source: "proposed" },
- { spelling: "pia tart lit", means: "Pia Tartlet", source: "proposed" },
- ],
+ pending: ["Pea Tartlet", "pia tart lit", "tart lit", "could not", "downtown", "downtown bakery"].map((spelling) => ({ spelling, means: "Pia Tartlet", source: "proposed" as const })),
question: "Who joined the show?",
scope: { channels: [CHAN] },
at: "2026-10-14T00:00:00.000Z",
},
- { corpus: corpusOver(RECS), ask, count, cuesOf: cuesOver(RECS) },
+ { corpus: corpusOver(RECS2), ask, count, cuesOf: cuesOver(RECS2) },
);
assert.deepEqual(
r.dropped.map((d) => [d.spelling, d.reason]),
@@ -278,29 +292,32 @@ test("confirmSpellings: no hits, judged not the name, a line not verbatim — dr
["Pea Tartlet", "no-hits"],
["tart lit", "not-the-name"],
["could not", "not-verbatim"],
+ ["downtown", "too-few"],
],
);
- assert.match(r.dropped[1]!.why, /a tart that lit up/);
- assert.equal(r.kept.length, 1);
- assert.deepEqual(
- { spelling: r.kept[0]!.spelling, means: r.kept[0]!.means, quote: r.kept[0]!.quote, recording: r.kept[0]!.recording, start: r.kept[0]!.start, hits: r.kept[0]!.hits, source: r.kept[0]!.source },
- // The newest window first (d-04).
- { spelling: "pia tart lit", means: "Pia Tartlet", quote: "pia tart lit could not make it tonight", recording: "d-04", start: 0, hits: 2, source: "proposed" },
- );
- assert.equal(r.kept[0]!.url, "https://synth.example/?v=synth-kitchen%2Fd-04&t=0");
+ assert.equal(r.dropped[1]!.why, "1 of 3 windows read said it means the name, quoting a verbatim line (needs 2): not her");
+ assert.deepEqual(r.dropped[1]!.windows?.map((w) => [w.recording, w.means]), [["w-03", true], ["w-02", false], ["w-01", false]]);
+ assert.match(r.dropped[3]!.why, /occurs in only 1 recording: one window needs 3/);
+ assert.deepEqual(r.kept.map((k) => [k.spelling, k.recording, k.quote, k.hits]), [
+ // 2 of 3: the newest yes is its proving line.
+ ["pia tart lit", "w-03", "thanks pia tart lit for coming", 3],
+ // 1 window, 3 recordings.
+ ["downtown bakery", "w-04", "the downtown bakery opened", 3],
+ ]);
+ assert.deepEqual(r.kept[0]!.windows?.map((w) => [w.recording, w.means, w.verbatim]), [["w-03", true, true], ["w-02", false, true], ["w-01", true, true]]);
+ assert.equal(r.kept[0]!.url, "https://synth.example/?v=synth-kitchen%2Fw-03&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("keptByWindows: the rule on its own", () => {
+ const w = (means: boolean, verbatim = true) => ({ recording: "r", start: 0, means, verbatim, reason: means ? "yes" : "no" });
+ assert.equal(keptByWindows([w(true), w(true)], 2).keep, true);
+ assert.equal(keptByWindows([w(true), w(false), w(true)], 3).keep, true);
+ assert.equal(keptByWindows([w(true), w(false)], 2).reason, "not-the-name");
+ assert.equal(keptByWindows([w(true), w(true, false)], 2).reason, "not-verbatim");
+ assert.equal(keptByWindows([w(true)], 3).keep, true);
+ assert.equal(keptByWindows([w(true)], 2).reason, "too-few");
+ assert.equal(keptByWindows([w(false)], 9).reason, "not-the-name");
+ assert.equal(keptByWindows([], 9).reason, "unread");
});
test("confirmSpellings: a count that read part of the scope and found nothing is unread, never no-hits", async () => {
diff --git a/common/lib/report/draft/triage/learned.ts b/common/lib/report/draft/triage/learned.ts
@@ -40,7 +40,7 @@ export const CONFIRM_WINDOWS = 3;
export const SUGGEST_REMOVE_AFTER = 4;
// A tick proposes again when the last pass is at least this old.
export const PROPOSE_EVERY_DAYS = 7;
-// The most names one proposal pass asks about (capitalised first).
+// The most names one proposal pass asks about.
export const NAMES_PER_PASS = 16;
// What the file keeps of its history.
export const USES_KEPT = 8;
@@ -80,12 +80,17 @@ export type LearnedSpelling = {
uses?: LearnedUse[];
// Promoted to a search alias (the operator's act): where, and the alias id.
promoted?: { to: string; alias: string; at: string };
+ // Each window the judge read to confirm it, with its verdict.
+ windows?: SpellingWindow[];
};
-export type LearnedDropReason = "no-hits" | "not-the-name" | "not-verbatim" | "known" | "blocked" | "cap" | "invalid" | "unread";
+export type LearnedDropReason = "no-hits" | "not-the-name" | "not-verbatim" | "too-few" | "known" | "blocked" | "cap" | "invalid" | "unread";
-/** A spelling that was not learned, and why. */
-export type LearnedDrop = { spelling: string; means: string; source: SpellingSource; reason: LearnedDropReason; why: string; at: string; k?: number };
+/** One window the judge read to confirm a spelling: where, its verdict, its quoted line and whether that was verbatim. */
+export type SpellingWindow = { recording: string; start: number; means: boolean; verbatim: boolean; reason: string; quote?: string };
+
+/** A spelling that was not learned, and why (with each window's verdict, when the judge read any). */
+export type LearnedDrop = { spelling: string; means: string; source: SpellingSource; reason: LearnedDropReason; why: string; at: string; k?: number; windows?: SpellingWindow[] };
/** One proposal pass. */
export type LearnedPass = {
@@ -196,10 +201,10 @@ export function literalOf(alt: string): string | null {
}
/**
- * The name-like alternatives of a watch's terms: a literal alternative (its
- * `\b` anchors aside) with a capital letter, or a phrase of several words —
- * the ones a transcript can mishear. A regex class, a quantifier or a group
- * is skipped. Capitalised first, then the order given; no repeats.
+ * The names a watch's terms watch: each literal alternative (its `\b` and
+ * line anchors aside) with a capital letter — a proper name, the kind a
+ * transcript mishears. A lowercase word or phrase, a regex class, a quantifier
+ * or a group is skipped. In the order given; no repeats.
*/
export function namesOf(terms: string | null | undefined, regex: boolean): string[] {
const t = (terms ?? "").trim();
@@ -207,19 +212,15 @@ export function namesOf(terms: string | null | undefined, regex: boolean): strin
const alts = regex ? splitAlternatives(t).map(literalOf) : [t.replace(/\s+/g, " ")];
const seen = new Set<string>();
const caps: string[] = [];
- const phrases: string[] = [];
for (const a of alts) {
if (!a) continue;
const key = spellingKey(a);
if (!key || seen.has(key)) continue;
- const capital = /\p{Lu}/u.test(a);
- // Several words: spaces in the alternative itself (a hyphenated word is one).
- const multi = /\s/.test(a);
- if (!capital && !multi) continue;
+ if (!/\p{Lu}/u.test(a)) continue;
seen.add(key);
- (capital ? caps : phrases).push(a);
+ caps.push(a);
}
- return [...caps, ...phrases];
+ return caps;
}
/** The names a schedule's terms watch, split into one pass's (NAMES_PER_PASS) and the rest. */
diff --git a/common/testing/schedule/opsStub.ts b/common/testing/schedule/opsStub.ts
@@ -264,7 +264,11 @@ const enqueueLearn: EnqueueLearnFn = async (id, trigger) => {
const at = (nowIso ? new Date(nowIso) : new Date()).toISOString();
const name = plan.names[0]!;
const kept: LearnedSpelling[] = [
- { spelling: "Vote Rigg", means: name, quote: "The vote was rigged and everybody knew.", recording: "sv1", channel: "sitechan", title: "Site video one", start: 3, url: `${ORIGIN}/?v=sitechan%2Fsv1&t=3`, hits: 2, lines: 3, source: "proposed", at },
+ { spelling: "Vote Rigg", means: name, quote: "The vote was rigged and everybody knew.", recording: "sv1", channel: "sitechan", title: "Site video one", start: 3, url: `${ORIGIN}/?v=sitechan%2Fsv1&t=3`, hits: 2, lines: 3, source: "proposed", at, windows: [
+ { recording: "sv1", start: 3, means: true, verbatim: true, reason: "the watched name (stub)", quote: "The vote was rigged and everybody knew." },
+ { recording: "sv2", start: 8, means: false, verbatim: true, reason: "another person (stub)" },
+ { recording: "sv3", start: 5, means: true, verbatim: true, reason: "the watched name (stub)", quote: "Vote Rigg was on the panel." },
+ ] },
{
spelling: "Vote Rick",
means: name,
diff --git a/editor/e2e/report-draft.spec.ts b/editor/e2e/report-draft.spec.ts
@@ -525,13 +525,30 @@ test("a watch learns a spelling over the fake model: proposed, counted in scope,
{ start: 10, end: 14.8, text: "she runs the bakery downtown" },
],
};
- await writeDraftCorpus(build, { channels: withRecords([guest]) });
+ // Two older streams name her the same way (not new to the tick: before its window).
+ const older = (id: string, date: string, line: string) => ({
+ ...LATE_RECORD,
+ id,
+ slug: `synth-kitchen/${id}`,
+ title: `Older stream ${id}`,
+ uploadDate: date,
+ cues: [
+ { start: 0, end: 4.8, text: "good evening chat" },
+ { start: 5, end: 9.8, text: line },
+ ],
+ });
+ await writeDraftCorpus(build, { channels: withRecords([guest, older("pia-old-07", "20260301", "last time pia tart lit brought cherry pies"), older("pia-old-08", "20260401", "pia tart lit says hello to everyone")]) });
// The model, by what it is asked: proposals, the confirmation, the window judge.
const sys = (b: { messages?: { role: string; content: string }[] }) => b.messages?.find((m) => m.role === "system")?.content ?? "";
const route = (b: { messages?: { role: string; content: string }[] }) => {
const s = sys(b);
if (/mishears names\. Given a name/.test(s)) return jsonReply({ spellings: ["pia tart lit", "Pea Tartlet", "Pia Tartlet"] });
- if (/whether the given spelling/.test(s)) return jsonReply({ means: true, quote: "tonight pia tart lit is judging the contest", reason: "the guest judge, named" });
+ if (/whether the given spelling/.test(s)) {
+ // The excerpt's line holding the spelling, as an honest judge quotes it.
+ const user = b.messages?.find((m) => m.role === "user")?.content ?? "";
+ const line = user.split("\n").map((l) => l.replace(/^\[[\d:]+\]\s*/, "")).find((l) => /pia tart lit/.test(l) && !l.includes(":") && !l.includes("?")) ?? "";
+ return jsonReply({ means: true, quote: line, reason: "the guest judge, named" });
+ }
return jsonReply({ relevant: false, items: [], heard: [] });
};
for (let i = 0; i < 12; i++) ol.push(route);
@@ -547,7 +564,13 @@ test("a watch learns a spelling over the fake model: proposed, counted in scope,
const learned = JSON.parse(await readFile(join(reportsDir(), ".series", "r63-watch", "learned.json"), "utf8"));
expect(learned, ltail).toMatchObject({ owner: "r63-watch", termsKey: "lit:Pia Tartlet", passes: [{ trigger: "create", status: "done", names: ["Pia Tartlet"], proposed: 2, kept: 1 }] });
expect(learned.learned).toHaveLength(1);
- expect(learned.learned[0]).toMatchObject({ spelling: "pia tart lit", means: "Pia Tartlet", quote: "tonight pia tart lit is judging the contest", recording: "pia-guest-06", channel: "synth-kitchen", start: 5, hits: 1, source: "proposed" });
+ // Confirmed in all three windows (at least 2 needed); the newest is its proving line.
+ expect(learned.learned[0]).toMatchObject({ spelling: "pia tart lit", means: "Pia Tartlet", quote: "tonight pia tart lit is judging the contest", recording: "pia-guest-06", channel: "synth-kitchen", start: 5, hits: 3, source: "proposed" });
+ expect(learned.learned[0].windows.map((w: { recording: string; means: boolean; verbatim: boolean }) => [w.recording, w.means, w.verbatim])).toEqual([
+ ["pia-guest-06", true, true],
+ ["pia-old-08", true, true],
+ ["pia-old-07", true, true],
+ ]);
expect(learned.dropped).toMatchObject([{ spelling: "Pea Tartlet", reason: "no-hits" }]);
expect(ol.unloads.length).toBeGreaterThan(0);
diff --git a/umtool/components/series/LearnedSpellings.tsx b/umtool/components/series/LearnedSpellings.tsx
@@ -56,6 +56,7 @@ const DROP_WORDS: Record<string, string> = {
"no-hits": "no hits",
"not-the-name": "not the name",
"not-verbatim": "not verbatim",
+ "too-few": "too few",
known: "known",
blocked: "removed",
cap: "past the cap",
@@ -112,7 +113,7 @@ export default function LearnedSpellings({ view }: { view: LearnedView }) {
<p className="m-0 text-[12.5px] text-muted" data-learned-empty="">
{view.names.length
? `Nothing learned yet. ${view.lastPass ? `The last proposal pass (${day(view.lastPass.at)}) kept nothing.` : "No proposal pass has run."} It asks about ${view.names.slice(0, 6).join(", ")}${view.names.length > 6 ? ` and ${view.names.length - 6} more` : ""}.`
- : "No name in the terms to learn spellings of: a literal alternative with a capital letter, or a phrase."}
+ : "No name in the terms to learn spellings of: a literal alternative with a capital letter."}
</p>
) : (
<div className="grid grid-cols-[minmax(260px,380px)_minmax(0,1fr)] gap-x-5">
@@ -168,6 +169,17 @@ export default function LearnedSpellings({ view }: { view: LearnedView }) {
{lit.idle ? " · idle: its name is no longer in the terms" : ""}
{lit.promoted ? ` · promoted to ${lit.promoted.to === "global" ? "the global aliases" : `${lit.promoted.to}'s aliases`} (${lit.promoted.alias})` : ""}
</p>
+ {lit.windows?.length ? (
+ <ul className="m-0 grid list-none gap-0.5 p-0 text-[11.5px] text-text-2" aria-label="windows the judge read" data-learned-windows={lit.windows.length}>
+ {lit.windows.map((w) => (
+ <li key={`${w.recording}-${w.start}`} className="flex min-w-0 items-baseline gap-2">
+ <span className={badgeVariants({ variant: w.means && w.verbatim ? "on" : "info", size: "sm" })}>{w.means ? (w.verbatim ? "the name" : "not verbatim") : "not the name"}</span>
+ <span className="shrink-0 font-mono text-[11px] text-muted-2">{w.recording}</span>
+ <span className="truncate">{w.means && w.quote ? `“${w.quote}”` : w.reason}</span>
+ </li>
+ ))}
+ </ul>
+ ) : null}
{lit.suggestRemoving && (
<p className="m-0 text-[12px] text-text-2" data-learned-suggestion="">
Its candidates were dismissed in each of its last runs with none flagged: suggested for removal.
diff --git a/umtool/e2e/learned-spellings.spec.ts b/umtool/e2e/learned-spellings.spec.ts
@@ -95,6 +95,12 @@ test("a watch's Learned spellings: made by its first proposal pass; the lit list
await expect(detail.locator("[data-learned-quote]")).toHaveText("“The vote was rigged and everybody knew.”");
await expect(detail.locator("[data-learned-cite]")).toHaveAttribute("data-learned-cite", "sitechan/sv1 at 0:03");
await expect(detail.getByRole("link", { name: "sitechan/sv1 at 0:03" })).toHaveAttribute("href", "https://priv.example/?v=sitechan%2Fsv1&t=3");
+ // Each window the judge read, with its verdict.
+ const windows = detail.getByRole("list", { name: "windows the judge read" });
+ await expect(windows.locator("li")).toHaveCount(3);
+ await expect(windows.locator("li").nth(0)).toContainText("the name");
+ await expect(windows.locator("li").nth(1)).toContainText("not the name");
+ await expect(windows.locator("li").nth(1)).toContainText("another person (stub)");
// j moves the light (focus in the list): the heard one, with why it is suggested for removal.
await rigg.focus();
await page.keyboard.press("j");