Archilyzer · Source

archilyzer

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

commit 78c692779b23166c41f237e496a58559a7b78d78
parent 5b01655d2f5ff843665152029619b0f53c8a0032
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 13 Oct 2026 21:18:41 -0400

common: fragment quotes — refused when generated, the full sentence offered; a warning in verify-quotes (r28 Q2)

lib/citations/fragment.ts: a quote under four words, or a part ending on a
function word (FRAGMENT_END_WORDS), is a fragment (fragmentOf); fullSentenceFor
offers the smallest run of cue text from the quote to sentence punctuation or
a new cue's sentence, else the quote's cue and one more, capped at ~30 words.
The generation checks (checkQuotes, the add op's strictCheckerOver) refuse a
fragment with that sentence as the repair hint; the sweep pipeline extends a
fragment to its sentence in code; a revision's parent fragments are a warning.
verify-quotes reports `fragment` as a warning (drift > inexact > fragment).
authoringRules: WHOLE_SENTENCE_QUOTE_RULE. The kit gains sweeps/fragment.md.

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

Diffstat:
MREPORT.md | 2+-
Mcommon/bin/reports-check.test.ts | 32++++++++++++++++++++++++++++++++
Mcommon/bin/reports-check.ts | 53++++++++++++++++++++++++++++++++++++++++++++++++-----
Acommon/lib/citations/fragment.test.ts | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acommon/lib/citations/fragment.ts | 155+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcommon/lib/report/docs.ts | 8++++++--
Mcommon/lib/report/draft/authoringRules.ts | 6++++++
Mcommon/lib/report/draft/reportOps.test.ts | 19+++++++++++++++++++
Mcommon/lib/report/draft/reportOps.ts | 13++++++++++---
Mcommon/lib/report/draft/tasks/quotes.ts | 25+++++++++++++++++++++++--
Mcommon/lib/report/draft/tasks/revise-report.ts | 14+++++++++++---
Mcommon/lib/report/draft/tasks/sweep-agent.ts | 7+++++--
Mcommon/lib/report/draft/tasks/sweep-pipeline.ts | 20+++++++++++++++++---
Mcommon/lib/report/draft/tasks/tasks.test.ts | 23+++++++++++++++++++++++
Mcommon/testing/README.md | 2+-
Mcommon/testing/draft/derive.ts | 2+-
Acommon/testing/draft/sweeps/fragment.md | 11+++++++++++
Mmcp/src/draftTasks.test.ts | 24++++++++++++++++++++++++
18 files changed, 451 insertions(+), 23 deletions(-)

diff --git a/REPORT.md b/REPORT.md @@ -146,7 +146,7 @@ An article made or revised by a model keeps each generation as an **iteration**, ## Checking quotes -`archilyzer reports verify-quotes <report.json> | --article <id>` checks every quote against its record as compose does (token recall, on every track) and names a quote that matches a served `en` rewrite but not `en-orig` (`en-orig-drift`). A quote that passes recall but is not verbatim (case, punctuation and curly quotes aside) within ±90 s of its cited second is **`inexact`**: a warning, printed and counted, that does not change the exit code; compose and publish do not use it. A GENERATED quote must pass that strict check: a finding whose quote fails it is dropped. The statuses: `ok`, `drift`, `en-orig-drift`, `inexact`, `missing-record`, `no-cues`, `missing-post`, `unreadable`. +`archilyzer reports verify-quotes <report.json> | --article <id>` checks every quote against its record as compose does (token recall, on every track) and names a quote that matches a served `en` rewrite but not `en-orig` (`en-orig-drift`). A quote that passes recall but is not verbatim (case, punctuation and curly quotes aside) within ±90 s of its cited second is **`inexact`**: a warning, printed and counted, that does not change the exit code; compose and publish do not use it. A GENERATED quote must pass that strict check: a finding whose quote fails it is dropped. A quote under four words, or one that stops on a function word (`as`, `to`, `the`, …), is a **`fragment`**: a warning too, with the full sentence to quote when the record has one; a GENERATED fragment fails, and the repair round is handed that sentence. `drift` and `en-orig-drift` come before `inexact`, and `inexact` before `fragment`. The statuses: `ok`, `drift`, `en-orig-drift`, `inexact`, `fragment`, `missing-record`, `no-cues`, `missing-post`, `unreadable`. ## Making a report from what exists diff --git a/common/bin/reports-check.test.ts b/common/bin/reports-check.test.ts @@ -249,6 +249,38 @@ test("verify-quotes: `inexact` — recall passes, the strict check does not — assert.match(w.text(), /2 quote\(s\): 1 inexact, 1 ok \(inexact is a warning\)/); }); +test("verify-quotes: `fragment` — verbatim, but stopping mid-thought — is a warning with the full sentence (testing/draft/sweeps/fragment.md)", async () => { + // The kitchen channel's records are on disk from the test above. + const { report } = await convertFixture("fragment"); + const file = path.join(ROOT, "fragment.report.json"); + writeJson(file, report); + const c = capture(); + const code = await verifyQuotesMain({ file, json: true, paths }, c.out); + const { results } = JSON.parse(c.text()) as { results: { citation: string; status: string; sentence?: string; message?: string }[] }; + const by = Object.fromEntries(results.map((r) => [r.citation, r])); + assert.equal(by.c01.status, "fragment"); + assert.equal(by.c01.sentence, "I paid for the new mixer myself"); + assert.match(by.c01.message!, /ends on “the”/); + assert.equal(by.c02.status, "fragment"); + assert.equal(by.c02.sentence, "my lawyer told me not to talk about the lease"); + assert.equal(by.c03.status, "fragment"); + assert.match(by.c03.message!, /under 4 words/); + assert.equal(by.c03.sentence, "I did not enter the contest this year"); + assert.equal(by.c04.status, "ok"); + assert.equal(code, 0, "a fragment is a warning"); + const w = capture(); + assert.equal(await verifyQuotesMain({ file, paths }, w.out), 0); + assert.match(w.text(), /FRAGMENT \(warning\) c01/); + assert.match(w.text(), /4 quote\(s\): 3 fragment, 1 ok \(fragment is a warning\)/); + // Precedence: a quote that is not verbatim is `inexact`, never `fragment`. + const reversed = { ...report, citations: { ...report.citations, c01: { ...report.citations!.c01!, quote: "I paid for a" } } }; + writeJson(file, reversed); + const r = capture(); + await verifyQuotesMain({ file, json: true, paths }, r.out); + const rc01 = (JSON.parse(r.text()) as { results: { citation: string; status: string }[] }).results.find((x) => x.citation === "c01")!; + assert.notEqual(rc01.status, "fragment"); +}); + // ─── attach-video ─── test("encodePlan: remux an H.264 mp4 under the limit; encode the rest to fit; refuse what cannot", () => { diff --git a/common/bin/reports-check.ts b/common/bin/reports-check.ts @@ -25,6 +25,11 @@ // and counted, and does not change the exit code; compose and publish do not // use it. // +// A quote that is a FRAGMENT — under four words, or stopping on a function +// word (lib/citations/fragment.ts, release 28 Q2) — is `fragment`: a WARNING +// too, with the full sentence to quote when the record has one. Precedence: +// `drift` / `en-orig-drift` > `inexact` > `fragment` > `ok`. +// // `--article <id>` checks one ARTICLE (release 26: transcripts/reports/<id>/, // published or a draft) as the homepage's compose would — any channel of the // corpus citable, the articles' prepared media. @@ -51,6 +56,7 @@ import { strictTextCheck, type StrictQuoteResult, } from "../lib/citations/verify"; +import { fragmentOf, fullSentenceFor, type FragmentFinding } from "../lib/citations/fragment"; import { ComposeReportsError, checkSpanQuote, @@ -142,6 +148,9 @@ export type QuoteStatus = | "en-orig-drift" // Recall passes, the strict check does not: a warning (release 27 D3). | "inexact" + // Verbatim, but under four words or stopping on a function word: a + // warning (release 28 Q2). + | "fragment" | "missing-record" | "no-cues" | "missing-post" @@ -165,11 +174,13 @@ export type QuoteResult = { // The strict check (verbatim within ±90 s): whether it passed, and the // first fragment it did not find. Absent where recall already failed. strict?: { ok: boolean; failed?: string }; + // A fragment's full sentence, from the record, when one fits. + sentence?: string; message?: string; }; // Statuses that are warnings: printed and counted, never a failure. -export const QUOTE_WARNING_STATUSES: ReadonlySet<QuoteStatus> = new Set<QuoteStatus>(["inexact"]); +export const QUOTE_WARNING_STATUSES: ReadonlySet<QuoteStatus> = new Set<QuoteStatus>(["inexact", "fragment"]); const strictOf = (r: StrictQuoteResult): NonNullable<QuoteResult["strict"]> => r.ok ? { ok: true } : { ok: false, ...(r.failed !== undefined ? { failed: r.failed } : {}) }; @@ -181,6 +192,14 @@ export function inexactMessage(failed: string | undefined): string { ); } +export function fragmentMessage(f: FragmentFinding, sentence: string | null): string { + return ( + `"${f.part.slice(0, 120)}" is a fragment (${f.why}): quote the whole sentence` + + (sentence ? ` — "${sentence}"` : " or clause") + + " — a warning; compose is unchanged" + ); +} + export const EN_ORIG_TRACK = "transcript.en-orig.vtt"; // Every video, audio and post citation of a report, checked against the @@ -233,18 +252,23 @@ export async function verifyReportQuotes( } const v = quoteVerification(c.quote, postText, now); const strict = quoteDrifted(v) ? null : strictTextCheck(c.quote, postText); - const status: QuoteStatus = quoteDrifted(v) ? "drift" : strict && !strict.ok ? "inexact" : "ok"; + const frag = fragmentOf(c.quote); + const status: QuoteStatus = quoteDrifted(v) ? "drift" : strict && !strict.ok ? "inexact" : frag ? "fragment" : "ok"; + const sentence = status === "fragment" ? fullSentenceFor(frag!.part, [{ start: 0, end: 1, text: postText }], 0) : null; results.push({ ...base, score: v.quoteScore, track: "post", status, ...(strict ? { strict: strictOf(strict) } : {}), + ...(sentence ? { sentence } : {}), ...(status === "drift" ? { message: quoteDriftMessage(v.quoteScore) } : status === "inexact" ? { message: inexactMessage(strict?.failed) } - : {}), + : status === "fragment" + ? { message: fragmentMessage(frag!, sentence) } + : {}), }); continue; } @@ -269,14 +293,19 @@ export async function verifyReportQuotes( // The strict check passes when any track has the quote verbatim near // the cited second (as recall takes the best track). let strict: StrictQuoteResult | null = null; + let strictCues = record.cues; if (!quoteDrifted(checked.verification)) { const tracks = record.tracks.length ? record.tracks.map((t) => t.cues) : [record.cues]; for (const cues of tracks) { const r = strictQuoteCheck(c.quote, cues, c.start); if (!strict || r.ok) strict = r; - if (r.ok) break; + if (r.ok) { + strictCues = cues; + break; + } } } + let sentence: string | null = null; if (quoteDrifted(checked.verification)) { status = "drift"; message = quoteDriftMessage(score); @@ -288,6 +317,13 @@ export async function verifyReportQuotes( } else if (strict && !strict.ok) { status = "inexact"; message = inexactMessage(strict.failed); + } else { + const frag = fragmentOf(c.quote); + if (frag) { + status = "fragment"; + sentence = fullSentenceFor(frag.part, strictCues, c.start); + message = fragmentMessage(frag, sentence); + } } results.push({ ...base, @@ -296,6 +332,7 @@ export async function verifyReportQuotes( tracks: checked.tracks, ...(enOrig !== undefined ? { enOrig } : {}), ...(strict ? { strict: strictOf(strict) } : {}), + ...(sentence ? { sentence } : {}), status, ...(message ? { message } : {}), }); @@ -343,8 +380,14 @@ export async function verifyQuotesMain( `reports verify-quotes: ${results.length} quote(s): ` + [...counts].map(([s, n]) => `${n} ${s}`).join(", ") + (parsed.problems.length ? `; ${parsed.problems.length} validation problem(s)` : "") + - (results.some((r) => QUOTE_WARNING_STATUSES.has(r.status)) ? " (inexact is a warning)" : ""), + warningsNote(results), ); } return bad.length > 0 || parsed.problems.length > 0 ? 1 : 0; } + +// " (inexact is a warning)", " (inexact and fragment are warnings)", or "". +function warningsNote(results: readonly QuoteResult[]): string { + const seen = [...QUOTE_WARNING_STATUSES].filter((w) => results.some((r) => r.status === w)); + return seen.length ? ` (${seen.join(" and ")} ${seen.length > 1 ? "are warnings" : "is a warning"})` : ""; +} diff --git a/common/lib/citations/fragment.test.ts b/common/lib/citations/fragment.test.ts @@ -0,0 +1,58 @@ +// Fragment quotes (release 28 Q2): what is one, and the full sentence code offers. + +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { FRAGMENT_END_WORDS, fragmentOf, fullSentenceFor, isFragmentQuote } from "./fragment"; +import { strictQuoteCheck } from "./verify"; +import { cuesOf } from "../../testing/draft/corpus.mjs"; + +const cue = (start: number, text: string) => ({ start, end: start + 4.8, text }); + +test("a fragment: under four words, or a part ending on a function word", () => { + assert.deepEqual(fragmentOf("I priced it as"), { why: "ends on “as”", part: "I priced it as" }); + assert.equal(fragmentOf("never again")?.why, "under 4 words"); + assert.equal(fragmentOf("my lawyer told me not to")?.why, "ends on “to”"); + // Case and punctuation aside; an ellipsis part is judged on its own. + assert.equal(fragmentOf("I paid for THE")?.why, "ends on “the”"); + assert.equal(fragmentOf("I would never sell the bakery … to a chain and")?.part, "to a chain and"); + // Whole sentences and clauses pass. + assert.equal(fragmentOf("I would never sell the bakery to a chain"), null); + assert.equal(fragmentOf("What are you even looking at?"), null, "sentence punctuation ends a sentence whatever its last word"); + assert.equal(isFragmentQuote("the judges were friends of mine so it felt wrong"), false); + assert.equal(fragmentOf(""), null); + assert.ok(FRAGMENT_END_WORDS.includes("as") && FRAGMENT_END_WORDS.includes("her")); +}); + +test("the full sentence: unpunctuated captions extend to the end of the quote's cue", async () => { + const cues = (await cuesOf("synth-kitchen", "bread-day-01"))!; + assert.equal(fullSentenceFor("I paid for the", cues, 45), "I paid for the new mixer myself"); + const pie = (await cuesOf("synth-kitchen", "pie-stream-02"))!; + assert.equal(fullSentenceFor("my lawyer told me not to", pie, 40), "my lawyer told me not to talk about the lease"); + // Under four words: the cue's run holds it. + assert.equal(fullSentenceFor("I did not", pie, 10), "I did not enter the contest this year"); + // Not there verbatim: nothing to offer. + assert.equal(fullSentenceFor("I sold the bakery as", cues, 15), null); +}); + +test("the full sentence: punctuation, a new cue's capital, one more cue, and the cap", () => { + const punct = [cue(0, "So the price. I priced it as a loss, and"), cue(5, "then I moved on. Next")]; + assert.equal(fullSentenceFor("I priced it as", punct, 0), "I priced it as a loss, and then I moved on."); + // A cue boundary where the next cue starts a sentence ends it (the pronoun I does not). + const caps = [cue(0, "we said that the oven ran hot"), cue(5, "Then we left"), cue(10, "I think")]; + assert.equal(fullSentenceFor("the oven ran", caps, 0), "the oven ran hot"); + // Still under four words: back to the sentence's start. + assert.equal(fullSentenceFor("ran hot", caps, 0), "we said that the oven ran hot"); + // The quote's cue ends on a function word: one more cue. + const more = [cue(0, "she told me that the shop is"), cue(5, "closing in the spring"), cue(10, "and nobody knew")]; + assert.equal(fullSentenceFor("the shop is", more, 0), "the shop is closing in the spring"); + // Too long to be offered. + const long = [cue(0, `the ${"very ".repeat(40)}long one of`), cue(5, "and of")]; + assert.equal(fullSentenceFor("the very very", long, 0, { maxWords: 10 }), null); +}); + +test("the full sentence passes the strict check wherever the quote did", async () => { + const cues = (await cuesOf("synth-kitchen", "bread-day-01"))!; + const s = fullSentenceFor("I paid for the", cues, 45)!; + assert.equal(strictQuoteCheck(s, cues, 45).ok, true); + assert.equal(fragmentOf(s), null); +}); diff --git a/common/lib/citations/fragment.ts b/common/lib/citations/fragment.ts @@ -0,0 +1,155 @@ +// FRAGMENT QUOTES — a quote that stops mid-thought (release 28, Q2). +// +// A quote is a FRAGMENT when it has fewer than FRAGMENT_MIN_WORDS words, or +// one of its parts (the runs convertSweep joins with an ellipsis) ends on a +// function word — "I priced it as", "my lawyer told me not to". A part that +// ends on sentence punctuation (. ! ? …) is a whole sentence whatever its last +// word ("What are you looking at?"). Accepted collateral of the end-word rule: +// a sentence that really ends on an object pronoun ("I told her") when its +// transcript is unpunctuated. +// +// `fullSentenceFor` is what code offers instead: the smallest run of the +// record's text, from the quote's first word, that ends at sentence +// punctuation or at a cue boundary where the next cue starts a new sentence; +// with unpunctuated captions, the end of the cue the quote ends in, then one +// more cue while it is still a fragment. Capped at FULL_SENTENCE_MAX_WORDS +// (or the quote's own length and a margin, when the quote is longer). A +// result still under the minimum is widened back to the sentence's start. +// The words are the cues' own, joined with single spaces, so the sentence +// passes the strict check wherever the quote did. +// +// Pure, no imports but ./verify (also pure). + +import { STRICT_QUOTE_WINDOW_SECONDS, quoteFragments, strictNormalize } from "./verify"; + +export const FRAGMENT_MIN_WORDS = 4; + +// The words a quote may not end on (lowercase; compared normalised). +export const FRAGMENT_END_WORDS = [ + "as", "to", "the", "and", "of", "a", "an", "in", "on", "for", "with", "at", "by", "from", "that", "which", + "but", "or", "if", "is", "was", "be", "i", "my", "your", "their", "our", "his", "her", +] as const; + +export const FULL_SENTENCE_MAX_WORDS = 30; + +const END_WORDS = new Set<string>(FRAGMENT_END_WORDS); + +// A word that ends a sentence: its last letter is followed by . ! ? or … +// (closing quotes and brackets allowed after). +const SENTENCE_END_RE = /[.!?…]["'”’)\]]*$/; + +const wordsOf = (text: string) => strictNormalize(text).split(" ").filter(Boolean); + +export type FragmentFinding = { + // Why it is a fragment: "under 4 words", or "ends on “as”". + why: string; + // The part (an ellipsis-joined run, or the whole quote) that is one. + part: string; +}; + +// Whether a quote is a fragment, and which part; null when it is not. +export function fragmentOf(quote: string): FragmentFinding | null { + const total = wordsOf(quote).length; + if (total === 0) return null; + const parts = quoteFragments(quote); + if (total < FRAGMENT_MIN_WORDS) return { why: `under ${FRAGMENT_MIN_WORDS} words`, part: parts.at(-1) ?? quote.trim() }; + for (const part of parts) { + if (SENTENCE_END_RE.test(part.trim())) continue; + const last = wordsOf(part).at(-1); + if (last && END_WORDS.has(last)) return { why: `ends on “${last}”`, part }; + } + return null; +} + +export const isFragmentQuote = (quote: string) => fragmentOf(quote) !== null; + +type TimedText = { start: number; end: number; text: string }; + +type Word = { raw: string; cue: number; norms: string[] }; + +// A cue's first word starts a new sentence when it is capitalised and is not +// the pronoun I (or a contraction of it). +const startsSentence = (raw: string) => /^["'“‘(]?[A-Z]/.test(raw) && !/^["'“‘(]?I(['’][a-z]+)?$/.test(raw); + +// The full sentence a quote (or one part of it) stops short of, from the cues +// overlapping ±windowSeconds of `second`; null when the quote is not found +// there verbatim, or no whole sentence fits the cap. +export function fullSentenceFor( + quote: string, + cues: readonly TimedText[], + second: number, + opts: { windowSeconds?: number; maxWords?: number } = {}, +): string | null { + const win = opts.windowSeconds ?? STRICT_QUOTE_WINDOW_SECONDS; + const window = cues.filter((c) => c.end > second - win && c.start < second + win); + const words: Word[] = []; + window.forEach((c, k) => { + for (const raw of c.text.split(/\s+/).filter(Boolean)) words.push({ raw, cue: k, norms: wordsOf(raw) }); + }); + const flat: { tok: string; w: number }[] = []; + words.forEach((w, i) => w.norms.forEach((tok) => flat.push({ tok, w: i }))); + const q = wordsOf(quote); + if (!q.length) return null; + // Every place the quote occurs; the one nearest the cited second wins. + let best: { from: number; to: number; dist: number } | null = null; + for (let i = 0; i + q.length <= flat.length; i++) { + let ok = true; + for (let k = 0; k < q.length && ok; k++) ok = flat[i + k]!.tok === q[k]; + if (!ok) continue; + const from = flat[i]!.w; + const to = flat[i + q.length - 1]!.w; + const dist = Math.abs(window[words[from]!.cue]!.start - second); + if (!best || dist < best.dist) best = { from, to, dist }; + } + if (!best) return null; + const cap = Math.max(opts.maxWords ?? FULL_SENTENCE_MAX_WORDS, q.length + 15); + const text = (a: number, b: number) => words.slice(a, b + 1).map((w) => w.raw).join(" "); + const span = (a: number, b: number) => wordsOf(text(a, b)).length; + const lastOfCue = (cue: number) => { + let j = -1; + words.forEach((w, i) => { + if (w.cue === cue) j = i; + }); + return j; + }; + + let start = best.from; + let end = -1; + // 1. Forward to sentence punctuation, or to a cue boundary before a new sentence. + for (let j = best.to; j < words.length && span(start, j) <= cap; j++) { + if (SENTENCE_END_RE.test(words[j]!.raw)) { + end = j; + break; + } + const next = words[j + 1]; + if (next && next.cue !== words[j]!.cue && startsSentence(next.raw)) { + end = j; + break; + } + } + // 2. Unpunctuated: the end of the quote's last cue, then one more cue. + if (end < 0) { + end = lastOfCue(words[best.to]!.cue); + if (fragmentOf(text(start, end)) && end + 1 < words.length) end = lastOfCue(words[end + 1]!.cue); + if (span(start, end) > cap) return null; + } + // 3. Still too short: back to the sentence's start (the previous sentence + // punctuation, else the start of the quote's first cue). + if (wordsOf(text(start, end)).length < FRAGMENT_MIN_WORDS) { + let i = start; + while (i > 0 && !SENTENCE_END_RE.test(words[i - 1]!.raw) && words[i - 1]!.cue === words[start]!.cue) i--; + while (i > 0 && !SENTENCE_END_RE.test(words[i - 1]!.raw) && span(i - 1, end) <= cap && !startsSentence(words[i]!.raw)) i--; + start = i; + } + const out = text(start, end); + return fragmentOf(out) ? null : out; +} + +// The words a check hands back for a fragment: what it is, and the sentence +// to quote instead when there is one — the repair hint. +export function fragmentHint(f: FragmentFinding, sentence: string | null): string { + return ( + `a fragment (${f.why}): "${f.part.slice(0, 120)}" — quote the whole sentence` + + (sentence ? `: "${sentence}"` : " or clause") + ); +} diff --git a/common/lib/report/docs.ts b/common/lib/report/docs.ts @@ -238,8 +238,12 @@ export function renderReportMarkdown(): string { "recall but is not verbatim (case, punctuation and curly quotes aside) within ±90 s of its " + "cited second is **`inexact`**: a warning, printed and counted, that does not change the " + "exit code; compose and publish do not use it. A GENERATED quote must pass that strict " + - "check: a finding whose quote fails it is dropped. The statuses: `ok`, `drift`, " + - "`en-orig-drift`, `inexact`, `missing-record`, `no-cues`, `missing-post`, `unreadable`.", + "check: a finding whose quote fails it is dropped. A quote under four words, or one that " + + "stops on a function word (`as`, `to`, `the`, …), is a **`fragment`**: a warning too, with the " + + "full sentence to quote when the record has one; a GENERATED fragment fails, and the repair " + + "round is handed that sentence. `drift` and `en-orig-drift` come before `inexact`, and " + + "`inexact` before `fragment`. The statuses: `ok`, `drift`, `en-orig-drift`, `inexact`, " + + "`fragment`, `missing-record`, `no-cues`, `missing-post`, `unreadable`.", ); out.push(""); out.push("## Making a report from what exists"); diff --git a/common/lib/report/draft/authoringRules.ts b/common/lib/report/draft/authoringRules.ts @@ -69,6 +69,12 @@ export const VERBATIM_QUOTES_RULE = "never fix a transcript's spelling, grammar or names inside quotes, never join words from two moments " + "into one quote. A quote that is not word for word what was said within 90 seconds of its link is refused."; +// A quote that stops mid-thought (release 28 Q2, lib/citations/fragment.ts) +// is refused in code; the refusal carries the sentence to quote. +export const WHOLE_SENTENCE_QUOTE_RULE = + "Quote a whole sentence or clause: a quote under four words, or one that stops on a function word (an " + + "article, a preposition, a conjunction, a possessive), is refused as a fragment."; + export const ONE_QUOTE_PER_FINDING_RULE = "Each finding is a list item under a `## section`: the claim in plain words, the quoted words in double " + "quotes, then the citation link. One quote, one link per item."; diff --git a/common/lib/report/draft/reportOps.test.ts b/common/lib/report/draft/reportOps.test.ts @@ -198,3 +198,22 @@ test("two-line findings (the claim on the bullet, its quote and link under it) a const { problems } = await sweepToReport(after, { cuesOf }); assert.deepEqual(problems, []); }); + +test("add: a fragment quote is refused, and the refusal carries the full sentence (release 28 Q2)", async () => { + const doc = parseSweep(await readSweep("basic")); + const link = momentHref("synth-kitchen", "pie-stream-02", 40); + const r = await applyReportOps( + doc, + [ + { op: "add", section: "The lease", text: "She will not discuss the lease", quote: "my lawyer told me not to", link }, + { op: "add", section: "The lease", text: "She will not discuss the lease", quote: "my lawyer told me not to talk about the lease", link }, + ], + { checkQuote: strictCheckerOver(cuesOf), origin: "https://synth.example" }, + ); + assert.equal(r.refused.length, 1); + assert.match(r.refused[0]!.why, /a fragment \(ends on “to”\).*"my lawyer told me not to talk about the lease"/); + assert.equal(r.applied.length, 1); + // The words-only checker lets it through. + const words = await strictCheckerOver(cuesOf, { fragments: false })({ channel: "synth-kitchen", id: "pie-stream-02", second: 40, quote: "my lawyer told me not to" }); + assert.deepEqual(words, { ok: true }); +}); diff --git a/common/lib/report/draft/reportOps.ts b/common/lib/report/draft/reportOps.ts @@ -28,6 +28,7 @@ // add). import { STRICT_QUOTE_WINDOW_SECONDS, strictQuoteCheck } from "../../citations/verify"; +import { fragmentHint, fragmentOf, fullSentenceFor } from "../../citations/fragment"; import { LINK_RE, QUOTE_MARK_RE, @@ -64,17 +65,23 @@ export type ReportOpsContext = { }; // The strict checker over a cue reader (testing/draft/corpus.mjs cuesOf, or -// the MCP's transcript read): every fragment verbatim within ±90 s. +// the MCP's transcript read): every fragment verbatim within ±90 s, and the +// quote not a FRAGMENT (release 28 Q2: under four words, or stopping on a +// function word) — the refusal then carries the full sentence to quote. +// `fragments: false` checks the words only. export function strictCheckerOver( cuesOf: (channel: string, id: string) => Promise<readonly { start: number; end: number; text: string }[] | null>, - opts: { windowSeconds?: number } = {}, + opts: { windowSeconds?: number; fragments?: boolean } = {}, ): (q: QuoteCheckRequest) => Promise<QuoteCheckAnswer> { const windowSeconds = opts.windowSeconds ?? STRICT_QUOTE_WINDOW_SECONDS; return async ({ channel, id, second, quote }) => { const cues = await cuesOf(channel, id); if (!cues || cues.length === 0) return { ok: false, why: `no transcript cues for ${channel}/${id}` }; const r = strictQuoteCheck(quote, cues, second, { windowSeconds }); - return r.ok ? { ok: true } : { ok: false, why: `"${r.failed}" is not there` }; + if (!r.ok) return { ok: false, why: `"${r.failed}" is not there` }; + const frag = opts.fragments === false ? null : fragmentOf(quote); + if (frag) return { ok: false, why: fragmentHint(frag, fullSentenceFor(frag.part, cues, second, { windowSeconds })) }; + return { ok: true }; }; } diff --git a/common/lib/report/draft/tasks/quotes.ts b/common/lib/report/draft/tasks/quotes.ts @@ -3,7 +3,9 @@ // // The check a GENERATED quote must pass is the strict one (D3): every quoted // fragment verbatim (normalised) in the record's cues within ±90 s of its -// cited second; a post's quote in the post's text. An outside verifier (the +// cited second; a post's quote in the post's text. And it may not be a +// FRAGMENT (release 28 Q2, lib/citations/fragment.ts): the problem then +// carries the full sentence, the repair round's hint. An outside verifier (the // editor's verify-quotes over the corpus on disk, which also reads the en-orig // track) may add problems. A finding whose quote fails after the one repair // round is DROPPED, never repaired by code. @@ -12,6 +14,7 @@ import { sweepToReport } from "../../convertSweep"; import type { CuesOf, PostChannelOf } from "../../convertShared"; import type { Report } from "../../schema"; import { strictNormalize, strictQuoteCheck, strictTextCheck, quoteFragments } from "../../../citations/verify"; +import { fragmentHint, fragmentOf, fullSentenceFor } from "../../../citations/fragment"; import { evidenceOf, findingsOf, parseSweep, quotesOf, renderSweep, LINK_RE, type SweepDoc } from "../sweepModel"; import { parseCitationHref } from "../../convertShared"; import { mmss } from "../reportOps"; @@ -26,6 +29,10 @@ export type QuoteProblem = { why: string; // The transcript ±45 s around the cited second, for a repair. near?: string; + // A FRAGMENT (release 28 Q2): the words are there, but the quote stops + // mid-thought. `sentence` is the full sentence to quote instead (the repair + // hint), null when none fits. + fragment?: { why: string; part: string; sentence: string | null }; }; export type ConvertOutcome = @@ -78,6 +85,12 @@ export async function checkQuotes( const r = strictTextCheck(quote, text); if (!r.ok) { problems.push({ citation: cid, channel: c.channel, id: c.id, quote, why: `"${r.failed}" is not the post's words`, near: text }); + continue; + } + const frag = fragmentOf(quote); + if (frag) { + const sentence = fullSentenceFor(frag.part, [{ start: 0, end: 1, text }], 0); + problems.push({ citation: cid, channel: c.channel, id: c.id, quote, why: fragmentHint(frag, sentence), fragment: { ...frag, sentence } }); } continue; } @@ -101,12 +114,20 @@ export async function checkQuotes( why: `not verbatim within 90 s of ${Math.floor(c.start)} s: "${r.failed}"`, near, }); + continue; + } + const frag = fragmentOf(quote); + if (frag) { + const sentence = fullSentenceFor(frag.part, cues, c.start); + problems.push({ citation: cid, channel: c.channel, id: c.id, second: c.start, quote, why: fragmentHint(frag, sentence), fragment: { ...frag, sentence } }); } } if (deps.verifyReport) { const seen = new Set(problems.map((p) => p.citation)); for (const p of await deps.verifyReport(report)) { - if (seen.has(p.citation) || p.status === "ok" || p.status === "inexact") continue; + // A warning (inexact, fragment) is not a problem: the strict and + // fragment checks above are this run's own. + if (seen.has(p.citation) || p.status === "ok" || p.status === "inexact" || p.status === "fragment") continue; const c = report.citations?.[p.citation] as { channel?: string; id?: string; start?: number; quote?: string } | undefined; problems.push({ citation: p.citation, diff --git a/common/lib/report/draft/tasks/revise-report.ts b/common/lib/report/draft/tasks/revise-report.ts @@ -11,7 +11,7 @@ import { providerOf, runAgent, structuredAnswer, type AgentTool } from "../../../llm"; import { lineage, readIterationFile, writeIterationFile } from "../../iterations"; -import { CLAIM_QUOTES_RULE, UNATTENDED_RULE, VERBATIM_QUOTES_RULE, momentLinkRule } from "../authoringRules"; +import { CLAIM_QUOTES_RULE, UNATTENDED_RULE, VERBATIM_QUOTES_RULE, WHOLE_SENTENCE_QUOTE_RULE, momentLinkRule } from "../authoringRules"; import { applyReportOps, strictCheckerOver, type AppliedOp, type RefusedOp } from "../reportOps"; import { numberedView, parseSweep, renderSweep, type SweepDoc } from "../sweepModel"; import { extractJsonObject } from "../../../parseStdoutJson"; @@ -43,6 +43,7 @@ export const REPORT_OPS_TEXT = (origin: string) => '- {"op":"title","text":"..."} / {"op":"summary","text":"..."}', CLAIM_QUOTES_RULE, VERBATIM_QUOTES_RULE, + WHOLE_SENTENCE_QUOTE_RULE, momentLinkRule(origin), ].join("\n"); @@ -241,10 +242,17 @@ async function reviseReportBody(h: TaskHandle, input: ReviseReportInput): Promis } await writeIterationFile(h.article, h.n, "sweep.md", md, h.paths); h.check({ name: "convert", ok: true }); + // A fragment the parent already quoted is a warning, as verify-quotes says + // of an existing report (release 28 Q2); what fails the words is a failure. + const failing = problems.filter((p) => !p.fragment); + const fragments = problems.filter((p) => p.fragment); + const warn = fragments.length ? `; ${fragments.length} fragment quote(s) from the iteration revised (a warning)` : ""; h.check({ name: "quotes", - ok: problems.length === 0, - detail: problems.length ? `${problems.length} quote(s) fail the strict check (from the iteration revised): ${problems.map((p) => p.why).slice(0, 3).join("; ")}` : "every quote verbatim (strict)", + ok: failing.length === 0, + detail: failing.length + ? `${failing.length} quote(s) fail the strict check (from the iteration revised): ${failing.map((p) => p.why).slice(0, 3).join("; ")}${warn}` + : `every quote verbatim (strict)${warn}`, }); await writeIterationFile(h.article, h.n, "report.json", c.report, h.paths); return { diff --git a/common/lib/report/draft/tasks/sweep-agent.ts b/common/lib/report/draft/tasks/sweep-agent.ts @@ -21,6 +21,7 @@ import { REPORT_STYLE_RULE, UNATTENDED_RULE, VERBATIM_QUOTES_RULE, + WHOLE_SENTENCE_QUOTE_RULE, momentLinkRule, } from "../authoringRules"; import { plainAnswer, userCharsFor } from "./llmText"; @@ -93,6 +94,7 @@ function runPreamble(o: { origin: string; maxUsd: number; terms?: string[]; from `- ${ONE_QUOTE_PER_FINDING_RULE}`, `- ${CLAIM_QUOTES_RULE}`, `- ${VERBATIM_QUOTES_RULE}`, + `- ${WHOLE_SENTENCE_QUOTE_RULE}`, `- ${momentLinkRule(o.origin)}`, `- ${POST_CITATION_RULE}`, `- ${COVERAGE_RULE}`, @@ -109,7 +111,8 @@ const REPAIR_SYSTEM = [ "You repair a sweep report whose quote checks failed. You have the report tools only (read_report, edit_report, write_report); the transcript each fix needs is in the message.", `- ${VERBATIM_QUOTES_RULE}`, `- ${CLAIM_QUOTES_RULE}`, - "For each problem: correct the quote to the transcript's exact words shown with it (and the second in the link to that line's second), or remove the finding. Never invent words. Edit the report only, then stop.", + `- ${WHOLE_SENTENCE_QUOTE_RULE}`, + "For each problem: correct the quote to the transcript's exact words shown with it (and the second in the link to that line's second); a fragment's fix is the whole sentence given with it; or remove the finding. Never invent words. Edit the report only, then stop.", ].join("\n"); function extractTool(h: TaskHandle, input: SweepAgentInput, rewrite: (t: string) => Promise<string>, count: { n: number }): AgentTool { @@ -238,7 +241,7 @@ async function sweepAgentBody(h: TaskHandle, input: SweepAgentInput): Promise<Ta system: REPAIR_SYSTEM, user: "The quote checks refused these citations — the quoted words are not, word for word, what the transcript says " + - `at that moment:\n${describeProblems(problems)}\n\nThe report now:\n\n${file.text()}`, + `at that moment, or the quote is a fragment:\n${describeProblems(problems)}\n\nThe report now:\n\n${file.text()}`, tools: file.tools, meter: h.meter, maxUsd: h.meter.usd + allowance, diff --git a/common/lib/report/draft/tasks/sweep-pipeline.ts b/common/lib/report/draft/tasks/sweep-pipeline.ts @@ -15,6 +15,7 @@ import { structuredAnswer, type LlmConfig, type Meter } from "../../../llm"; import { writeIterationFile } from "../../iterations"; import { mmss } from "../reportOps"; import { strictNormalize } from "../../../citations/verify"; +import { fragmentOf, fullSentenceFor } from "../../../citations/fragment"; import { momentHref } from "./links"; import { checkQuotes, convertSweepText, dropFailedFindings } from "./quotes"; import { TaskInputError, runOnIteration, type TaskHandle, type TaskOutcome } from "./run"; @@ -53,7 +54,7 @@ export const TERMS_SCHEMA = { export const EXTRACT_SYSTEM = "You read excerpts of an automatic transcript and pick out evidence for a research question. Rules: (1) Only use the " + "excerpt; never add facts. (2) Each quote is copied EXACTLY, character for character, from consecutive transcript " + - "lines, without the bracketed timestamps; at least 8 and at most 40 words; do not fix grammar, spelling or names. " + + "lines, without the bracketed timestamps; at least 8 and at most 40 words, a whole sentence or clause; do not fix grammar, spelling or names. " + "(3) Each claim is one plain sentence saying what the speaker says in that quote, attributed to the speaker; keep " + "every negation (not, never, no) and every hedge (maybe, I think, allegedly, if) the quote has; do not state motives " + "or feelings; do not exaggerate; paraphrase in the third person in at most 20 words, do not repeat the quote. Set " + @@ -419,16 +420,29 @@ async function pipelineBody(h: TaskHandle, input: SweepPipelineInput): Promise<T nRelevant++; const items = Array.isArray(ans.items) ? ans.items.slice(0, MAX_ITEMS_PER_CHUNK) : []; for (const raw of items as { quote?: unknown; claim?: unknown; on_topic?: unknown; strength?: unknown }[]) { - const quote = String(raw.quote ?? "") + let quote = String(raw.quote ?? "") .replace(/["“”]/g, "") .replace(/\s+/g, " ") .trim() .replace(/^\[[\d:]+\]\s*/, ""); const claim = String(raw.claim ?? "").replace(/\s+/g, " ").trim().replace(/"/g, "'").replace(/[“”]/g, "'"); - const wc = quote.split(" ").filter(Boolean).length; const sec = locate(quote, ch); + // A quote that stops mid-thought (Q2) becomes its whole sentence + // when the window has one: code copies the words, still verbatim. + const frag = sec === null ? null : fragmentOf(quote); + if (frag) { + const lines = win.map(([s, t], i) => ({ start: s, end: win[i + 1]?.[0] ?? s + 1, text: t })); + const whole = fullSentenceFor(quote, lines, sec!, { windowSeconds: Number.MAX_SAFE_INTEGER }); + if (whole && whole.split(" ").length <= MAX_QUOTE_WORDS) { + event({ kind: "extended", video: v.id, quote, to: whole }); + quote = whole; + } + } + const wc = quote.split(" ").filter(Boolean).length; + const stillFragment = sec === null ? null : fragmentOf(quote); let why: string | null = null; if (sec === null) why = "not verbatim in its window"; + else if (stillFragment) why = `a fragment (${stillFragment.why})`; else if (wc < MIN_QUOTE_WORDS) why = `too short (${wc} words)`; else if (wc > MAX_QUOTE_WORDS) why = `too long (${wc} words)`; else if (!claim) why = "no claim"; diff --git a/common/lib/report/draft/tasks/tasks.test.ts b/common/lib/report/draft/tasks/tasks.test.ts @@ -15,6 +15,8 @@ import { checkQuotes, convertSweepText, dropFailedFindings } from "./quotes"; import { cardContext, chooseDraft } from "./narrate"; import { groundingInputOf } from "../grounding"; +const DRAFT_SWEEPS = path.join(path.dirname(new URL(import.meta.url).pathname), "../../../../testing/draft/sweeps"); + const stubCorpus = (slugs: Record<string, string>) => ({ calls: [] as unknown[], async call(name: string, args: Record<string, unknown> = {}) { @@ -173,6 +175,27 @@ test("quotes: the strict check over cues and posts; the failing finding dropped, assert.ok(more.length > problems.length); }); +test("quotes: a generated fragment is a failing quote whose repair hint is the full sentence (testing/draft/sweeps/fragment.md)", async () => { + const md = await readFile(path.join(DRAFT_SWEEPS, "fragment.md"), "utf8"); + const c = await convertSweepText(md, { id: "frag", cuesOf }); + assert.ok(c.ok); + if (!c.ok) return; + const problems = await checkQuotes(c.report, { cuesOf }); + assert.equal(problems.length, 3); + const by = Object.fromEntries(problems.map((p) => [p.quote, p])); + assert.equal(by["I paid for the"]!.fragment!.sentence, "I paid for the new mixer myself"); + assert.match(by["I paid for the"]!.why, /a fragment \(ends on “the”\).*quote the whole sentence: "I paid for the new mixer myself"/); + assert.equal(by["my lawyer told me not to"]!.fragment!.sentence, "my lawyer told me not to talk about the lease"); + assert.match(by["I did not"]!.why, /under 4 words.*"I did not enter the contest this year"/); + // Still a fragment after the repair round: the finding goes, the whole one stays. + const d = dropFailedFindings(md, problems); + assert.equal(d.dropped.length, 3); + assert.ok(d.md.includes('"I have never met the other finalist"')); + // A verify-quotes `fragment` is a warning, not one more problem. + const more = await checkQuotes(c.report, { cuesOf, verifyReport: async () => [{ citation: "c04", status: "fragment" }] }); + assert.equal(more.length, 3); +}); + test("narrate: a card's evidence; the better draft kept, failing sentences removed, never rewritten", async () => { const report = { title: "The baker", diff --git a/common/testing/README.md b/common/testing/README.md @@ -14,7 +14,7 @@ transcript, channel or person goes in these fixtures, ever. | `llm/fakeAnthropic.mjs` | A fake Messages API: scripted turns (`textTurn`, `toolTurn`, `pauseTurn`, `webSearchBlocks`, `thinkingBlock`, `errorTurn`, or a function of the request). It enforces the Sonnet 5.5 400s (temperature, forced `tool_choice`, `thinking: disabled`), signs thinking blocks so an edited history is refused, needs `x-api-key` = `FAKE_KEY`, and estimates usage, cache reads included. | | `llm/fakeOllama.mjs` | A fake ollama: `/api/chat` with `format` or tools, the 8k prompt cap and the 12k `num_ctx` cap as 400s, `stream: true` refused, `faultReply()` (`done: false`), the `keep_alive: 0` unload, `/api/tags`, `/api/ps`. | | `draft/corpus.mjs` | Two channels of recordings with cues (`CHANNELS`), posts (`POSTS`), `ORIGIN`, `momentHref`, `postHref`, `cuesOf`, `recordOf`, and `writeDraftCorpus(dir)` — a composed public dir for the MCP's `--local`. | -| `draft/sweeps/*.md` | sweep.md variants: `basic` (the canonical shape), `quotes-in-claims` (claims that carry quoted words — the rule they break), `multi-quote` (several quotes per link, several links per item), `posts-only`, `paragraphs` (paragraphs and a sub-heading between findings, a trailing Coverage section), `inexact` (a reversed quote fuzzy recall passes, a quote 200 s from its link, an exact one). | +| `draft/sweeps/*.md` | sweep.md variants: `basic` (the canonical shape), `quotes-in-claims` (claims that carry quoted words — the rule they break), `multi-quote` (several quotes per link, several links per item), `posts-only`, `paragraphs` (paragraphs and a sub-heading between findings, a trailing Coverage section), `inexact` (a reversed quote fuzzy recall passes, a quote 200 s from its link, an exact one), `two-line` (a finding's quote and link on the lines under its claim), `fragment` (verbatim quotes that stop mid-thought — on a function word, or under four words — and one whole sentence). | | `draft/reports/`, `draft/manifests/` | `basic`, `posts-only`, `paragraphs` converted (`report.json`) and taken to a video manifest, as the converters make them today. | | `web/fakeWeb.mjs` | A fake web on loopback: a DuckDuckGo-shaped HTML search (`POST /html/`, links in the `uddg` redirect, an ad), pages, plain text, a long page, redirects and a redirect loop, a PDF, a 429 that clears (`busyTimes`), a 503 that does not. `web.searchUrl` is what `webSearch` takes. | | `archiveOrg/fakeArchiveOrg.mjs` | A fake archive.org on loopback: `/advancedsearch.php` (every word of `q` in an item's identifier, title or subject; `*` all) and `/metadata/<id>` over invented items (`ITEMS`: a show's episodes with an original, a derivative and a JSON file, a restricted item, an audio tape). `ia.fetch` sends `https://archive.org/…` to it, for `new ArchiveOrgClient({ fetch: ia.fetch })`; `busyTimes` answers 429 first. | diff --git a/common/testing/draft/derive.ts b/common/testing/draft/derive.ts @@ -10,7 +10,7 @@ import { cuesOf, ORIGIN, POSTS } from "./corpus.mjs"; const HERE = path.dirname(/* turbopackIgnore: true */ fileURLToPath(import.meta.url)); -export const SWEEPS = ["basic", "quotes-in-claims", "multi-quote", "posts-only", "paragraphs", "inexact", "two-line"] as const; +export const SWEEPS = ["basic", "quotes-in-claims", "multi-quote", "posts-only", "paragraphs", "inexact", "two-line", "fragment"] as const; export type SweepName = (typeof SWEEPS)[number]; // The sweeps whose report and manifest are committed. diff --git a/common/testing/draft/sweeps/fragment.md b/common/testing/draft/sweeps/fragment.md @@ -0,0 +1,11 @@ +# Fragment quotes + +Four quotes, every one verbatim: three stop mid-thought — two on a function word, one under four words — and one is a +whole sentence. + +## Findings + +- The mixer: "I paid for the" [Bread day @ 0:45](https://synth.example/?v=synth-kitchen%2Fbread-day-01&t=45) +- The lease: "my lawyer told me not to" [Pie stream @ 0:40](https://synth.example/?v=synth-kitchen%2Fpie-stream-02&t=40) +- The contest: "I did not" [Pie stream @ 0:10](https://synth.example/?v=synth-kitchen%2Fpie-stream-02&t=10) +- The finalist: "I have never met the other finalist" [Pie stream @ 0:30](https://synth.example/?v=synth-kitchen%2Fpie-stream-02&t=30) diff --git a/mcp/src/draftTasks.test.ts b/mcp/src/draftTasks.test.ts @@ -162,6 +162,30 @@ test("sweep-agent: a quote the repair round does not fix is dropped, and the ite assert.match(after.checks!.find((c) => c.name === "quotes")!.detail!, /1 finding\(s\) dropped/); }); +test("sweep-agent: a fragment quote goes to the repair round with its full sentence, and the fix is kept (release 28 Q2)", async () => { + const r = await run("sweep-agent"); + const turns = structuredClone(r.turns); + const write = turns[3].content[0].input; + write.markdown = write.markdown.replace("the judges were friends of mine so it felt right", "the judges were friends of"); + turns[5] = { + content: [{ type: "tool_use", id: "toolu_f04", name: "edit_report", input: { old_text: 'friends of"', new_text: 'friends of mine so it felt wrong"' } }], + stop_reason: "tool_use", + }; + api.push(...turns); + const it = await createIteration("synth-frag", { kind: "sweep", model: r.model, question: r.question, scope: { channels: r.channels } }, paths); + const d = deps(); + const out = await runTask({ task: "sweep-agent", article: "synth-frag", n: it.n, extractorModel: r.extractorModel, origin: ORIGIN, maxUsd: 5 }, d); + assert.equal(out.status, "done", `${out.summary}\n${d.lines.join("\n")}`); + const first = api.requests.at(-7); + assert.match(first.system[0].text, /Quote a whole sentence or clause/); + const repair = api.requests.at(-2); + assert.match(repair.messages[0].content, /a fragment \(ends on “of”\): "the judges were friends of" — quote the whole sentence: "the judges were friends of mine so it felt wrong"/); + const md = (await readIterationFile("synth-frag", it.n, "sweep.md", paths))!; + assert.ok(md.includes('"the judges were friends of mine so it felt wrong"')); + const after = (await readIteration("synth-frag", it.n, paths))!; + assert.deepEqual(after.checks?.map((c) => [c.name, c.ok]), [["convert", true], ["quotes", true]]); +}); + test("sweep-agent: the repair round has its own small allowance", async () => { const r = await run("sweep-agent"); // The repair round's first turn costs more than the allowance: it stops there.