Archilyzer · Source

archilyzer

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

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

editor e2e: a watch learns a spelling over the fake model (proposed, counted in scope, confirmed quoting the line; the next tick's query carries it) — report-draft.spec; learn's plan, promote-alias plan then confirm through the alias writer, unlearn blocks — ops-api.spec (R6.3)

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

Diffstat:
Meditor/e2e/ops-api.spec.ts | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Meditor/e2e/report-draft.spec.ts | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 146 insertions(+), 0 deletions(-)

diff --git a/editor/e2e/ops-api.spec.ts b/editor/e2e/ops-api.spec.ts @@ -1050,3 +1050,66 @@ test("report-schedule: a watch — its plan names the triage; a tick with no bui expect(again.status).toBe(400); expect(again.body.error).toMatch(/has no triage state to discard/); }); + +// --- learned spellings (umtool R6.3) ---------------------------------------- +// +// Over HTTP: a create of a watch whose terms name someone starts the proposal +// pass (a report-draft job), which finds no composed build and says so in +// learned.json's pass; `learn` with dryRun is its plan (the names it asks +// about); over a learned spelling, promote-alias answers the plan (nothing +// written), then with confirm writes the alias through the editor's alias +// writer; unlearn removes it and blocks it. The pass over the fake model is +// report-draft.spec's. +test("report-schedule (R6.3): a create starts the proposal pass; learn's plan; promote-alias plan then confirm through the alias writer; unlearn blocks", async ({ request }) => { + test.setTimeout(120_000); + await resetData("empty"); + await settings(); + await writeChannelConfig("r63-chan", { name: "R63 channel" }); + await writeSite("r63site"); + const T = testPaths().transcriptsDir; + const LEARNED = `${T}/reports/.series/r63-ops/learned.json`; + const ALIASES = `${T}/search-aliases.json`; + type Learned = { learned: { spelling: string; promoted?: { to: string; alias: string } }[]; blocked: { spelling: string }[]; passes: { trigger: string; status: string; error?: string }[] }; + const made = await ops(request, "report-schedule", { action: "create", shape: "watch", topic: "R63 ops", id: "r63-ops", channels: ["r63-chan"], cadence: "daily 06:00", tz: "UTC", terms: "Pia Tartlet|co-host", regex: true }); + expect(made.status, made.body.error).toBe(200); + expect((made.body as { learn?: { jobId?: string; names?: string[] } }).learn).toMatchObject({ jobId: expect.any(String), names: ["Pia Tartlet"] }); + await expect.poll(async () => ((await pathExists(LEARNED)) ? (await readJson<Learned>(LEARNED)).passes.length : 0), { timeout: 60_000 }).toBe(1); + const pass = (await readJson<Learned>(LEARNED)).passes[0]!; + expect(pass).toMatchObject({ trigger: "create", status: "failed" }); + expect(pass.error).toMatch(/no composed build/); + const plan = await ops(request, "report-schedule", { action: "learn", id: "r63-ops", dryRun: true }); + expect(plan.status, plan.body.error).toBe(200); + expect((plan.body as { plan?: unknown }).plan).toMatchObject({ id: "r63-ops", names: ["Pia Tartlet"], provider: "local", due: "create", refused: null, learned: 0 }); + // Nothing learned yet: unlearn and promote refuse, saying so. + const none = await ops(request, "report-schedule", { action: "unlearn", id: "r63-ops", spelling: "pia tart lit" }); + expect(none.status).toBe(400); + expect(none.body.error).toMatch(/has not learned "pia tart lit"/); + // A spelling, as the pass would have kept it. + const cur = await readJson<Record<string, unknown>>(LEARNED); + await writeFile( + LEARNED, + JSON.stringify({ ...cur, learned: [{ spelling: "pia tart lit", means: "Pia Tartlet", quote: "tonight pia tart lit is judging the contest", recording: "pia-guest-06", channel: "r63-chan", start: 5, hits: 1, source: "proposed", at: "2026-10-14T00:00:00.000Z" }] }), + ); + const before = (await pathExists(ALIASES)) ? await readJson<{ aliases: unknown[] }>(ALIASES) : null; + const promote = await ops(request, "report-schedule", { action: "promote-alias", id: "r63-ops", spelling: "pia tart lit" }); + expect(promote.status, promote.body.error).toBe(200); + expect(promote.body).toMatchObject({ confirmed: false, plan: { action: "new", to: "global", alias: { id: "pia-tartlet", triggers: ["pia tartlet", "pia tart lit"], suggestion: "\\bPia Tartlet\\b|\\bpia tart lit\\b", note: "learned by watch r63-ops from r63-chan/pia-guest-06 at 0:05" } } }); + expect((promote.body as { plan: { sites: string[] } }).plan.sites).toContain("r63site"); + expect((await pathExists(ALIASES)) ? await readJson<{ aliases: unknown[] }>(ALIASES) : null).toEqual(before); + const done = await ops(request, "report-schedule", { action: "promote-alias", id: "r63-ops", spelling: "pia tart lit", confirm: true }); + expect(done.status, done.body.error).toBe(200); + const aliases = await readJson<{ aliases: { id: string; triggers: string[] }[] }>(ALIASES); + expect(aliases.aliases.at(-1)).toMatchObject({ id: "pia-tartlet", triggers: ["pia tartlet", "pia tart lit"] }); + expect((await readJson<Learned>(LEARNED)).learned[0]!.promoted).toMatchObject({ to: "global", alias: "pia-tartlet" }); + const bad = await ops(request, "report-schedule", { action: "promote-alias", id: "r63-ops", spelling: "pia tart lit", site: "nowhere" }); + expect(bad.status).toBe(400); + expect(bad.body.error).toMatch(/no site "nowhere"/); + const gone = await ops(request, "report-schedule", { action: "unlearn", id: "r63-ops", spelling: "pia tart lit" }); + expect(gone.status, gone.body.error).toBe(200); + const after = await readJson<Learned>(LEARNED); + expect(after.learned).toEqual([]); + expect(after.blocked.map((b) => b.spelling)).toEqual(["pia tart lit"]); + const again = await ops(request, "report-schedule", { action: "unlearn", id: "r63-ops", spelling: "pia tart lit" }); + expect(again.status).toBe(400); + expect(again.body.error).toMatch(/removed already/); +}); diff --git a/editor/e2e/report-draft.spec.ts b/editor/e2e/report-draft.spec.ts @@ -490,3 +490,86 @@ test("a watch ticks over the fake models: below the threshold (a mention only) await ol?.close(); } }); + +// ─── learned spellings (umtool R6.3) ─── +// +// A watch whose terms name someone ("Pia Tartlet": invented) over the fake +// ollama. Its create starts the proposal pass (a report-draft job on +// draft:local): the model proposes two spellings; the code counts each in +// scope over the build (one is there, one is not: dropped "no-hits"); the +// judge says the found one means her, quoting the line — checked verbatim in +// the window and the cues — and learned.json keeps it. The next tick's +// candidate query carries it ("terms + 1 learned"): a recording only the +// learned spelling matches is a candidate, named for it. + +test("a watch learns a spelling over the fake model: proposed, counted in scope, confirmed by the judge quoting the line; the next tick's query carries it", async ({ request }) => { + test.setTimeout(240_000); + let ol: FakeOllama | null = null; + try { + ol = await startFakeOllama(); + await setup(); + const settings = JSON.parse(await readFile(testPaths().settingsFile, "utf8")); + await writeSettings({ ...settings, generation: { ...settings.generation, ollamaUrl: ol.url } }); + await writeChannelConfig("synth-kitchen", { name: "Synth Kitchen" }); + const build = join(testPaths().transcriptsDir, ".export-builds", "draft-e2e", "out"); + const y = new Date(Date.now() - 86_400_000).toISOString().slice(0, 10); + const guest = { + ...LATE_RECORD, + id: "pia-guest-06", + slug: "synth-kitchen/pia-guest-06", + title: "Guest judge night", + uploadDate: y.replace(/-/g, ""), + cues: [ + { start: 0, end: 4.8, text: "welcome to the pie stream" }, + { start: 5, end: 9.8, text: "tonight pia tart lit is judging the contest" }, + { start: 10, end: 14.8, text: "she runs the bakery downtown" }, + ], + }; + await writeDraftCorpus(build, { channels: withRecords([guest]) }); + // 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" }); + return jsonReply({ relevant: false, items: [], heard: [] }); + }; + for (let i = 0; i < 12; i++) ol.push(route); + + const made = await schedule(request, { action: "create", shape: "watch", id: "r63-watch", topic: "Guest watch", question: "Who judged the contest?", channels: ["synth-kitchen"], terms: "Pia Tartlet", cadence: "daily 06:00", tz: "UTC" }); + expect(made.status, made.body.error).toBe(200); + const learn = made.body.learn as { jobId?: string; names?: string[]; refused?: string }; + expect(learn, JSON.stringify(made.body)).toMatchObject({ names: ["Pia Tartlet"] }); + const lj = await jobUntil(request, learn.jobId!, (s) => ["done", "failed", "cancelled"].includes(s), 150_000); + const ltail = (lj.tail ?? []).join("\n"); + expect(lj.job?.status ?? lj.status, ltail).toBe("done"); + expect(ltail).toMatch(/@@report-draft .*"task":"learn"/); + 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" }); + expect(learned.dropped).toMatchObject([{ spelling: "Pea Tartlet", reason: "no-hits" }]); + expect(ol.unloads.length).toBeGreaterThan(0); + + // The next tick: no pass due (proposed just now, the same terms); the learned spelling brings the candidate. + const t = await schedule(request, { action: "tick-now", id: "r63-watch" }); + expect(t.status, t.body.error).toBe(200); + const tj = await jobUntil(request, t.body.jobId!, (s) => ["done", "failed", "cancelled"].includes(s), 150_000); + const ttail = (tj.tail ?? []).join("\n"); + expect(tj.job?.status ?? tj.status, ttail).toBe("done"); + const s = await seriesJson("r63-watch"); + expect(s.ticks.at(-1), ttail).toMatchObject({ status: "no-change", usd: 0, triage: { k: 1, candidates: 1, learned: 1 } }); + expect(s.ticks.at(-1).learn).toBeUndefined(); + const f = JSON.parse(await readFile(join(reportsDir(), ".triage", "r63-watch", "1", "triage.json"), "utf8")); + expect(f).toMatchObject({ learned: { n: 1, spellings: ["pia tart lit"] }, tier0: { candidates: [{ id: "pia-guest-06", by: ["learned"], learned: ["pia tart lit"] }], learned: { spellings: ["pia tart lit"], matched: 1 } } }); + expect(f.summary).toMatch(/· terms \+ 1 learned —/); + // The judge was told which names to listen for. + const judged = ol.requests.find((b) => /The transcript may mishear these watched names: "Pia Tartlet"/.test(sys(b as never))); + expect(judged, "the window judge was asked for heard spans").toBeTruthy(); + // Its use is on the spelling (one candidate, none flagged). + const after = JSON.parse(await readFile(join(reportsDir(), ".series", "r63-watch", "learned.json"), "utf8")); + expect(after.learned[0].uses).toMatchObject([{ k: 1, candidates: 1, flagged: 0 }]); + } finally { + await ol?.close(); + } +});