commit 66ce7a07d8e07641b1e12755e9d49293f95d29bc
parent fc248164c6ed1a5e089a0a836aa5846ed90ffcd6
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 13 Oct 2026 15:03:59 -0400
common: a two-line finding (the claim on the bullet, its quote and link under it) is a finding
The sweep.md model saw a bullet with no link on its first line as a plain line, so a sweep written
in that shape (the shape the sweep agent writes) had no findings for the ops: a revision's drops
and merges were refused ("the document has 0") and it added beside them, and a finding whose quote
failed the strict check could not be dropped. Found in the release 27 live smoke. evidenceOf()
gives a finding's quotes and links wherever they sit; the numbered view, quotesOf, the drop and the
quotes-in-claims lint read it; claim and merge add no separator to a claim with nothing after it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
7 files changed, 80 insertions(+), 12 deletions(-)
diff --git a/common/lib/report/draft/reportOps.test.ts b/common/lib/report/draft/reportOps.test.ts
@@ -179,3 +179,22 @@ test("section, title and summary", async () => {
assert.equal(report.title, "What the baker says");
assert.equal(report.summary, "Six findings from two recordings.");
});
+
+test("two-line findings (the claim on the bullet, its quote and link under it) are findings the ops can reach", async () => {
+ const md = await readSweep("two-line");
+ const doc = parseSweep(md);
+ assert.equal(renderSweep(doc), md, "round trip");
+ assert.equal(numberFindings(doc).length, 3, "three findings; the line with no link is not one");
+ const { doc: out, applied, refused } = await applyReportOps(doc, [
+ { op: "claim", n: 1, text: "She says she will not sell the bakery to a chain." },
+ { op: "merge", n: 2, into: 3 },
+ ], ctx);
+ assert.deepEqual(refused, []);
+ assert.equal(applied.length, 2);
+ const after = renderSweep(out);
+ assert.match(after, /^- She says she will not sell the bakery to a chain\.\n "I would never sell the bakery to a chain" — \[Bread day @ 0:15\]/m);
+ // The merged finding keeps every quote with its own link, still under its claim.
+ assert.match(after, /- She says she did not enter, and why\.\n "I did not enter the contest this year".*\n "the judges were friends.*\n "we never said that about the old oven"/);
+ const { problems } = await sweepToReport(after, { cuesOf });
+ assert.deepEqual(problems, []);
+});
diff --git a/common/lib/report/draft/reportOps.ts b/common/lib/report/draft/reportOps.ts
@@ -31,6 +31,7 @@ import { STRICT_QUOTE_WINDOW_SECONDS, strictQuoteCheck } from "../../citations/v
import {
LINK_RE,
QUOTE_MARK_RE,
+ evidenceOf,
findingsOf,
isCoverage,
numberFindings,
@@ -220,7 +221,7 @@ export async function applyReportOps(
const bad = claimProblem(t);
if (bad) refuse(bad);
f.claim = t;
- if (!f.sep) f.sep = " ";
+ if (!f.sep && f.rest) f.sep = " ";
break;
}
case "merge": {
@@ -235,10 +236,10 @@ export async function applyReportOps(
}
if (typeof op.text === "string" && op.text.trim()) {
dst.claim = op.text.trim();
- if (!dst.sep) dst.sep = " ";
}
// Every quote keeps its own link: the rest is appended verbatim.
- dst.rest = `${dst.rest.trimEnd()} ${src.rest.trim()}`;
+ dst.rest = [dst.rest.trimEnd(), src.rest.trim()].filter(Boolean).join(" ");
+ if (!dst.sep && dst.rest) dst.sep = " ";
dst.continued.push(...src.continued);
removeBlock(sectionOf(doc, src), src);
mergedInto.set(src, dst);
@@ -328,7 +329,7 @@ export function quotedClaimProblems(doc: SweepDoc): { n: number; why: string }[]
const JOINER = /^\s*(?:…|\.\.\.|,|;|—|-|and|and then|then|or)?\s*$/i;
for (const { n, finding } of numberFindings(doc)) {
// Each link's quoted run: the text from the previous link to it.
- const rest = finding.rest;
+ const rest = evidenceOf(finding);
let from = 0;
for (const link of rest.matchAll(new RegExp(LINK_RE.source, "g"))) {
const run = rest.slice(from, link.index);
diff --git a/common/lib/report/draft/sweepModel.ts b/common/lib/report/draft/sweepModel.ts
@@ -101,7 +101,8 @@ export function parseSweep(md: string): SweepDoc {
const doc: SweepDoc = { lead: [], title: "", hasTitle: false, preamble: [], sections: [] };
let section: SweepSection | null = null;
let last: Finding | null = null;
- for (const line of lines) {
+ for (let i = 0; i < lines.length; i++) {
+ const line = lines[i]!;
if (section === null && !doc.hasTitle && line.startsWith("# ")) {
doc.hasTitle = true;
doc.title = line.slice(2).trim();
@@ -129,12 +130,32 @@ export function parseSweep(md: string): SweepDoc {
section.body.push(last);
continue;
}
+ // A TWO-LINE finding: the claim on the bullet, its quote and link on the
+ // indented line(s) under it (the shape a sweep agent often writes, and
+ // convertSweep reads as one claim). The claim is the whole bullet line.
+ if (b) {
+ let j = i + 1;
+ while (j < lines.length && CONTINUED_RE.test(lines[j]!)) j++;
+ const cont = lines.slice(i + 1, j);
+ if (cont.some(hasLink)) {
+ last = { type: "finding", bullet: b[1]!, claim: b[2]!, sep: "", rest: "", continued: cont };
+ section.body.push(last);
+ i = j - 1;
+ continue;
+ }
+ }
last = null;
section.body.push({ type: "line", text: line });
}
return doc;
}
+// A finding's evidence — its quotes and links — wherever they sit: after the
+// claim on the bullet line, or on the indented lines under it.
+export function evidenceOf(f: Finding): string {
+ return [f.rest, ...f.continued.map((l) => l.trim())].filter((x) => x.trim()).join(" ");
+}
+
export function findingLines(f: Finding): string[] {
return [`${f.bullet}${f.claim}${f.sep}${f.rest}`, ...f.continued];
}
@@ -180,14 +201,14 @@ export function numberedView(doc: SweepDoc): string {
for (const s of doc.sections) {
lines.push(`## ${s.title}${isCoverage(s) ? " (coverage — keep)" : ""}`);
for (const b of s.body) {
- if (b.type === "finding") lines.push(`[${numbers.get(b)}] ${b.claim}${b.sep}${b.rest}`);
+ if (b.type === "finding") lines.push(`[${numbers.get(b)}] ${b.claim}${b.sep || " "}${evidenceOf(b)}`.trimEnd());
else if (b.text.trim()) lines.push(b.text);
}
}
return lines.join("\n");
}
-// The quoted spans of a finding's rest, in order (without their marks).
+// The quoted spans of a finding's evidence, in order (without their marks).
export function quotesOf(f: Finding): string[] {
- return [...f.rest.matchAll(new RegExp(QUOTED_RE.source, "g"))].map((m) => m[0].slice(1, -1));
+ return [...evidenceOf(f).matchAll(new RegExp(QUOTED_RE.source, "g"))].map((m) => m[0].slice(1, -1));
}
diff --git a/common/lib/report/draft/tasks/quotes.ts b/common/lib/report/draft/tasks/quotes.ts
@@ -12,7 +12,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 { findingsOf, parseSweep, quotesOf, renderSweep, LINK_RE, type SweepDoc } from "../sweepModel";
+import { evidenceOf, findingsOf, parseSweep, quotesOf, renderSweep, LINK_RE, type SweepDoc } from "../sweepModel";
import { parseCitationHref } from "../../convertShared";
import { mmss } from "../reportOps";
import type { TaskDeps } from "./types";
@@ -141,7 +141,7 @@ export function dropFailedFindings(md: string, problems: readonly QuoteProblem[]
const dropped: string[] = [];
for (const section of doc.sections) {
for (const f of findingsOf(section)) {
- const links = [...f.rest.matchAll(new RegExp(LINK_RE.source, "g"))]
+ const links = [...evidenceOf(f).matchAll(new RegExp(LINK_RE.source, "g"))]
.map((m) => /\]\((.*)\)$/.exec(m[0])?.[1] ?? "")
.map((href) => parseCitationHref(href))
.filter((x) => x !== null);
diff --git a/common/lib/report/draft/tasks/tasks.test.ts b/common/lib/report/draft/tasks/tasks.test.ts
@@ -3,7 +3,7 @@
import { test } from "node:test";
import assert from "node:assert/strict";
-import { mkdir, mkdtemp, rm, utimes, writeFile } from "node:fs/promises";
+import { mkdir, mkdtemp, readFile, rm, utimes, writeFile } from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { ORIGIN, POSTS, cuesOf } from "../../../../testing/draft/corpus.mjs";
@@ -212,3 +212,13 @@ test("corpus cues: get_transcript's timestamped lines as cues, each ending where
assert.equal(calls, 1, "read once per recording");
assert.equal(await corpusCuesOf({ call: async () => { throw new Error("no"); } })("c", "x"), null);
});
+
+test("a two-line finding whose quote failed the strict check is dropped (the claim on the bullet, the quote under it)", async () => {
+ const md = await readFile(new URL("../../../../testing/draft/sweeps/two-line.md", import.meta.url), "utf8");
+ const { md: out, dropped } = dropFailedFindings(md, [
+ { citation: "c1", channel: "synth-kitchen", id: "bread-day-01", second: 15, quote: "I would never sell the bakery to a chain", why: "not verbatim" },
+ ]);
+ assert.equal(dropped.length, 1);
+ assert.doesNotMatch(out, /would not sell the bakery|I would never sell/);
+ assert.match(out, /we never said that about the old oven/);
+});
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"] as const;
+export const SWEEPS = ["basic", "quotes-in-claims", "multi-quote", "posts-only", "paragraphs", "inexact", "two-line"] as const;
export type SweepName = (typeof SWEEPS)[number];
// The sweeps whose report and manifest are committed.
diff --git a/common/testing/draft/sweeps/two-line.md b/common/testing/draft/sweeps/two-line.md
@@ -0,0 +1,17 @@
+# Two-line findings
+
+The shape a sweep agent often writes: the claim on the bullet, the quote and its link on the line under it.
+
+## The bakery
+
+- She says she would not sell the bakery.
+ "I would never sell the bakery to a chain" — [Bread day @ 0:15](https://synth.example/?v=synth-kitchen%2Fbread-day-01&t=15)
+- She denies the oven story.
+ "we never said that about the old oven" — [Bread day @ 0:25](https://synth.example/?v=synth-kitchen%2Fbread-day-01&t=25)
+
+## The contest
+
+- She says she did not enter, and why.
+ "I did not enter the contest this year" — [Pie stream @ 0:10](https://synth.example/?v=synth-kitchen%2Fpie-stream-02&t=10)
+ "the judges were friends of mine so it felt wrong" — [Pie stream @ 0:15](https://synth.example/?v=synth-kitchen%2Fpie-stream-02&t=15)
+- Background with no citation, kept as a line.