Archilyzer · Source

archilyzer

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

commit 5b01655d2f5ff843665152029619b0f53c8a0032
parent 442926c9db15d745ff1e0942bb08605019e39267
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 13 Oct 2026 21:12:04 -0400

common: the narrator is third person — a first-person narration sentence is a hard grounding failure (r28 Q1)

checkNarration refuses a sentence with I, me, my, we, us, our, … outside
quotation marks ("the narrator is third person"); when the sentence restates a
cited quote the reason names whose line it is and its citation
(groundingInputOf now carries each quote's speaker and citation). narrate
refuses it through its existing grounding call; the taste states the rule
once, and revise-video's narration op names it.

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

Diffstat:
Mcommon/lib/report/draft/authoringRules.ts | 3++-
Mcommon/lib/report/draft/grounding.test.ts | 34+++++++++++++++++++++++++++++++++-
Mcommon/lib/report/draft/grounding.ts | 88++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Mcommon/lib/report/draft/tasks/revise-video.ts | 2+-
4 files changed, 121 insertions(+), 6 deletions(-)

diff --git a/common/lib/report/draft/authoringRules.ts b/common/lib/report/draft/authoringRules.ts @@ -32,7 +32,8 @@ export const NARRATION_TASTE = [ "No expressive tags or stage directions of any kind, nothing in angle brackets.", "No stock phrases or filler openers; start with the point.", "Every number and every name you use must already be in the evidence below; add no facts.", - "Do not read quotes out; the clips that follow say them. Do not put a speaker's words in your own mouth.", + "Do not read quotes out; the clips that follow say them.", + "The narrator is third person: never I, me, my, we, us or our, and never a speaker's words as your own.", "Keep every negation and hedge the evidence has; say what was said, not why.", ] as const; diff --git a/common/lib/report/draft/grounding.test.ts b/common/lib/report/draft/grounding.test.ts @@ -5,7 +5,7 @@ import assert from "node:assert/strict"; import { readFile } from "node:fs/promises"; import path from "node:path"; import { fileURLToPath } from "node:url"; -import { checkNarration, groundingInputOf, lintNarration, reportText, QUOTE_RUN_MESSAGE } from "./grounding"; +import { checkNarration, firstPersonWords, groundingInputOf, lintNarration, reportText, QUOTE_RUN_MESSAGE, THIRD_PERSON_MESSAGE } from "./grounding"; const REPORTS = path.join(path.dirname(fileURLToPath(import.meta.url)), "../../../testing/draft/reports"); const basic = JSON.parse(await readFile(path.join(REPORTS, "basic.report.json"), "utf8")); @@ -75,3 +75,35 @@ test("checkNarration carries the lints as soft warnings", () => { assert.equal(r.soft.length, 1); assert.match(r.soft[0]!, /negation mismatch/); }); + +test("hard (Q1): the narrator is third person — a first-person sentence is refused", () => { + // The live smoke's line: no cited quote it restates. + const r = checkNarration("She talks about the contest. I've already finished mine.", input); + assert.equal(r.hard.length, 1, r.hard.join("|")); + assert.ok(r.hard[0]!.startsWith(`${THIRD_PERSON_MESSAGE} (“I've”, “mine”)`), r.hard[0]); + for (const line of ["We tried the bakery.", "That's my oven.", "The oven is ours.", "Let me be clear: the bakery stays.", "So we're done.", "It was us all along."]) { + assert.ok(checkNarration(line, input).hard.some((h) => h.startsWith(THIRD_PERSON_MESSAGE)), line); + } +}); + +test("hard (Q1): a first-person sentence that restates a cited quote names whose line it is and where", () => { + const r = checkNarration("I paid for the mixer myself.", input); + assert.equal(r.hard.length, 1, r.hard.join("|")); + assert.match(r.hard[0]!, /^the narrator is third person \(“I”, “myself”\): this is the speaker's line from c03 \(Bread day @ 0:45\), “I paid for the new mixer myself”/); + // A named speaker is named. + const named = groundingInputOf({ ...basic, citations: { ...basic.citations, c03: { ...basic.citations.c03, speaker: "the baker" } } }); + assert.match(checkNarration("I paid for the mixer myself.", named).hard[0]!, /this is the baker's line from c03/); +}); + +test("Q1: first person inside quotation marks is not the narrator's; word boundaries, not substrings", () => { + assert.deepEqual(firstPersonWords('She said "I quit" and “we are done” twice.'), []); + const quoted = checkNarration('She said "I quit" twice.', input).hard; + assert.ok(!quoted.some((h) => h.startsWith(THIRD_PERSON_MESSAGE)), quoted.join("|")); + assert.ok(quoted.includes("text in quotation marks: no quotes in narration"), "the quote itself is still refused"); + // Not first person: names and words that only contain the letters. + assert.deepEqual(firstPersonWords("Iowa's myth of the mineral museum in the US is idle."), []); + // Accepted collateral: "mine" the noun. + assert.deepEqual(firstPersonWords("The old mine shaft."), ["mine"]); + // Curly apostrophes read as straight ones. + assert.deepEqual(firstPersonWords("I’m sure."), ["I’m".replace("’", "'")]); +}); diff --git a/common/lib/report/draft/grounding.ts b/common/lib/report/draft/grounding.ts @@ -9,7 +9,11 @@ // - a capitalised name the report does not have (the first word of a // sentence and the COMMON_CAPS words aside); // - text in quotation marks: a narrator does not read quotes out; -// - six or more consecutive words of a cited quote: the clip says it. +// - six or more consecutive words of a cited quote: the clip says it; +// - a first-person word (I, me, my, we, us, our, … — FIRST_PERSON_WORDS) +// outside quotation marks: the narrator is third person (release 28 Q1). +// When the sentence restates a cited quote, the reason names whose line it +// is and where it was cited. // // SOFT (a warning; the line may be used, flagged for review) — the Q0 lints, // for what the hard checks cannot see (plans/local-llm-report-media.md, Q0): @@ -80,15 +84,25 @@ export type GroundingInput = { // The evidence lines (claims and quotes) the Q0 lints compare against; // default: the quotes. evidence?: readonly string[]; + // Every cited quote with who said it and where it is cited, for the + // first-person reason (default: none — the reason names no line). + sources?: readonly QuoteSource[]; }; +export type QuoteSource = { quote: string; speaker?: string; citation?: string }; + export type GroundingResult = { hard: string[]; soft: string[] }; type ReportLike = { title?: string; summary?: string | null; sections?: readonly { title?: string; body?: string | null; claims?: readonly { text?: string; title?: string }[] | null }[]; - citations?: Record<string, { quote?: string; label?: string; date?: string } | undefined> | null; + citations?: + | Record< + string, + { quote?: string; label?: string; date?: string; speaker?: string; channel?: string; id?: string; start?: number } | undefined + > + | null; }; // Every text of a report a narration may draw on: title, summary, section @@ -120,8 +134,75 @@ export function reportEvidence(report: ReportLike): string[] { return [...out, ...reportQuotes(report)]; } +const mmssOf = (s: number) => `${Math.floor(s / 60)}:${String(Math.floor(s % 60)).padStart(2, "0")}`; + +// Each cited quote with its speaker and its citation, as the first-person +// reason names them: `c03 (Pie stream @ 0:30)`. +export function reportQuoteSources(report: ReportLike): QuoteSource[] { + const out: QuoteSource[] = []; + for (const [cid, c] of Object.entries(report.citations ?? {})) { + if (!c?.quote) continue; + const where = c.label ?? (c.channel && c.id ? `${c.channel}/${c.id}` : ""); + const at = typeof c.start === "number" ? ` @ ${mmssOf(c.start)}` : ""; + out.push({ quote: c.quote, ...(c.speaker ? { speaker: c.speaker } : {}), citation: where ? `${cid} (${where}${at})` : cid }); + } + return out; +} + export function groundingInputOf(report: ReportLike): GroundingInput { - return { reference: reportText(report), quotes: reportQuotes(report), evidence: reportEvidence(report) }; + return { + reference: reportText(report), + quotes: reportQuotes(report), + evidence: reportEvidence(report), + sources: reportQuoteSources(report), + }; +} + +// ─── the narrator is third person (release 28 Q1) ─── + +// Word-bounded and case-insensitive: "Iowa", "myth" and "mineral" are not +// hits. Two kinds of collateral are accepted: "mine" the noun (a gold mine) +// and a roman numeral I; the all-caps "US" (the country) is not a hit. +export const FIRST_PERSON_WORDS = [ + "i", "i'm", "i've", "i'd", "i'll", "me", "my", "mine", "myself", + "we", "we're", "we've", "we'd", "we'll", "us", "our", "ours", "ourselves", +] as const; + +export const THIRD_PERSON_MESSAGE = "the narrator is third person"; + +const FIRST_PERSON = new Set<string>(FIRST_PERSON_WORDS); + +// A sentence's first-person words outside quotation marks, as written. +export function firstPersonWords(sentence: string): string[] { + const outside = sentence + .replace(/[’‘ʼ]/g, "'") + .replace(/"[^"]*"|“[^”]*”/g, " "); + const out: string[] = []; + for (const m of outside.matchAll(/[A-Za-z]+(?:'[A-Za-z]+)?/g)) { + const w = m[0]; + if (w === "US") continue; + if (FIRST_PERSON.has(w.toLowerCase())) out.push(w); + } + return out; +} + +// The hard problem for each first-person sentence: the rule, and — when the +// sentence restates a cited quote — whose line it is and where it is cited. +export function firstPersonProblems(text: string, sources: readonly QuoteSource[] = []): string[] { + const out: string[] = []; + for (const sent of sentencesOf(text)) { + const words = firstPersonWords(sent); + if (!words.length) continue; + const said = [...new Set(words)].map((w) => `“${w}”`).join(", "); + const line = sources.length ? closest(strictNormalize(sent), sources.map((s) => s.quote)) : null; + const src = line === null ? undefined : sources.find((s) => s.quote === line); + out.push( + src + ? `${THIRD_PERSON_MESSAGE} (${said}): this is ${src.speaker ? `${src.speaker}'s` : "the speaker's"} line from ${src.citation ?? "a citation"}, “${src.quote.slice(0, 80)}”` + : `${THIRD_PERSON_MESSAGE} (${said}): say what the speaker said, not as the speaker`, + ); + } + return out; } const SENTENCE_SPLIT = /(?<=[.!?…])\s+/; @@ -172,6 +253,7 @@ export function checkNarration(text: string, input: GroundingInput): GroundingRe } } } + for (const p of firstPersonProblems(text, input.sources)) hard.add(p); for (const w of lintNarration(text, input.evidence ?? input.quotes)) soft.add(w); return { hard: [...hard].sort(), soft: [...soft].sort() }; } diff --git a/common/lib/report/draft/tasks/revise-video.ts b/common/lib/report/draft/tasks/revise-video.ts @@ -23,7 +23,7 @@ export const VIDEO_OPS_TEXT = [ '- {"op":"drop","id":"<entry id>"} remove an entry', '- {"op":"move","id":"<entry id>","after":"<entry id, or \'start\'>"} reorder', '- {"op":"heading","id":"<card id>","text":"..."} a card\'s on-screen heading', - '- {"op":"narration","id":"<card id>","text":"..."} a card\'s spoken narration (for the ear: short, casual, contractions; no quotes read out; no numbers or names the report lacks; no tags); "text":"" removes it', + '- {"op":"narration","id":"<card id>","text":"..."} a card\'s spoken narration (for the ear: short, casual, contractions; third person — never I, me, my, we, us or our; no quotes read out; no numbers or names the report lacks; no tags); "text":"" removes it', '- {"op":"trim","id":"<clip id>","start":S,"end":E} a clip\'s in/out seconds, within 3 s of its current ones', '- {"op":"add_clip","citation":"<citation id from the report>","after":"<entry id>"} a clip for a cited moment not in the cut', '- {"op":"title","text":"..."} / {"op":"subtitle","text":"..."}',