// The speaker-neutral claim form (demo epic D2, round b): the line is code's.
import { test } from "node:test";
import assert from "node:assert/strict";
import { attributes, cleanLabel, humanDate, isNeutralSweep, labelProblem, neutralHeading, neutralSentence, neutralTitle, NEUTRAL_LINES_NOTE, plainTitle, runTopicOf, topicLabel } from "./neutralClaim";
import { quotedIn } from "../../convertShared";
const ground = ["the acolyte now I think we finally hit rock bottom at a 15% audience score", "ratings numbers viewership numbers", "The Acolyte Hits ROCK BOTTOM", "What has Jeremy said about the Star Wars show The Acolyte?", "the acolyte"];
const label = (raw: unknown, hosts = ["jeremy", "quartering"]) => topicLabel(raw, { fallback: "the acolyte", hosts, ground });
test("the line: In
(), on : — no speaker, no verb of saying", () => {
const s = neutralSentence({ title: 'The Acolyte Hits "ROCK BOTTOM" [it\'s over] (finally)', date: "2024-06-17", topic: "the acolyte's audience score" });
assert.equal(s, "In The Acolyte Hits ROCK BOTTOM it's over finally (17 June 2024), on the acolyte's audience score:");
// The converter reads the quoted words before a link as the citation's quote:
// the line carries exactly one quoted run, the quote.
assert.equal(quotedIn(`${s} "we finally hit rock bottom at a 15% audience score"`), "we finally hit rock bottom at a 15% audience score");
assert.equal(neutralSentence({ title: "", date: "", topic: "the ban" }), "In a recording, on the ban:");
assert.equal(humanDate("20240605"), "5 June 2024");
assert.equal(humanDate("2024-13-05"), "2024-13-05");
assert.equal(humanDate("last week"), "last week");
assert.ok(plainTitle("x".repeat(40) + " " + "y".repeat(80)).endsWith("…"));
});
test("a topic label: the model's when it is a grounded noun phrase", () => {
assert.deepEqual(label("the acolyte's audience score"), { label: "the acolyte's audience score", from: "model" });
assert.deepEqual(label('On "The Acolyte ratings".'), { label: "The Acolyte ratings", from: "model" });
// Function words need no grounding.
assert.equal(label("the acolyte and its audience").from, "model");
// A plural or an inflection of a word that is there.
assert.equal(label("acolyte viewership number").from, "model");
});
test("a topic label that attributes, runs long, or uses words from nowhere is the run's topic", () => {
assert.deepEqual(label("Jeremy's view of the acolyte"), { label: "the acolyte", from: "fallback", why: "“view” is a word of saying, thinking or judging" });
assert.equal(label("the quartering on the acolyte").why, "it names quartering");
assert.equal(label("he says the acolyte hit rock bottom").why, "“he” is a pronoun: a label names what the words are about, not a person");
assert.equal(label("the acolyte's racist fan backlash").why, "“racist” is not in the quote, the transcript before it, the title or the question");
assert.equal(label("the acolyte audience score at rock bottom now finally here").why, "a label of 10 words (at most 8)");
assert.equal(label("").why, "no label");
assert.equal(label(42).why, "no label");
assert.equal(label("of the").why, "a label of no content words");
});
test("the title is code's; a heading is kept only when it is a grounded noun-phrase topic", () => {
assert.equal(neutralTitle("the acolyte", ["TheQuartering"]), "The acolyte: quotes from TheQuartering");
assert.equal(neutralTitle("", []), "Quotes: quotes from the archive");
const o = { labels: ["the acolyte's reviews", "The Acolyte's reviews", "the budget"], ground: ["the reviews and the budget of the acolyte", "The Acolyte Hits ROCK BOTTOM"], topic: "the acolyte", hosts: ["jeremy"] };
assert.deepEqual(neutralHeading("Reviews and budget", o), { heading: "Reviews and budget", from: "model" });
assert.deepEqual(neutralHeading("Jeremy's criticism of the show", o), { heading: "The acolyte's reviews", from: "code", why: "“criticism” is a word of saying, thinking or judging" });
// Not grounded: a word in none of its quotes, labels or titles, nor the question.
const racist = neutralHeading("Racist backlash to the acolyte", o);
assert.equal(racist.from, "code");
assert.match(racist.why!, /“racist” is in none of/);
assert.equal(neutralHeading("What he thinks of the lore", { ...o, labels: [] }).heading, "The acolyte");
// One quote's label is not a heading over others: the run's topic.
assert.equal(neutralHeading("Fan Reactions", { ...o, labels: ["spin-offs confirmed", "the acolyte budget"] }).heading, "The acolyte");
assert.equal(neutralHeading("Fan Reactions", { ...o, labels: ["spin-offs confirmed"] }).heading, "Spin-offs confirmed");
// A heading an earlier section has gets an ordinal; never two sections of one name.
const used = new Set();
assert.equal(neutralHeading("Reviews and budget", { ...o, used }).heading, "Reviews and budget");
assert.equal(neutralHeading("Main Actress's Comments", { ...o, used }).heading, "The acolyte's reviews");
assert.equal(neutralHeading("Fan Reactions", { ...o, used }).heading, "The acolyte's reviews (2)");
assert.equal(neutralHeading("reviews and budget", { ...o, used }).heading, "The acolyte's reviews (3)");
assert.equal(attributes("Reviews and ratings"), false);
assert.equal(attributes("Fans' reaction"), true);
});
// The review of round b (12 Nov 2026): headings and labels from the shipped
// runs, and constructed labels that passed when the quote had the word.
const REFUSED_HEADINGS = ["Main Actress's Comments", "Showrunner's Comments", "Wizards of the Coast's Response", "Public Statements and Accusations", "Fan Reactions"];
const REFUSED_LABELS = [
"acolyte writer blames filon",
"The Acolyte hates white people",
"DCI ban for defending free speech",
"his love of the show",
"he loves the show",
"why he hates disney",
"his hate for disney",
"his admission that the ban was a lie",
"she is guilty of fraud",
"the disney confession",
// and more of the same shapes
"Disney lying about promotional piece",
"the showrunner's budget",
"it's the acolyte",
"they're cancelling the acolyte",
"the acolyte isn't canceled",
"Disney's take on the acolyte",
"the acolyte was cancelled",
"fans' reaction to the acolyte",
"Jeremy's ban",
];
// A ground with every word of them: grounding does not save a label that attributes.
const everyWord = [...REFUSED_LABELS, ...REFUSED_HEADINGS].join(" ");
test("labels and headings that attribute, assert or name a person are refused, whatever the quote holds", () => {
for (const l of [...REFUSED_LABELS, ...REFUSED_HEADINGS]) {
assert.ok(labelProblem(cleanLabel(l), ["jeremy", "quartering"]), `refused: ${l}`);
const r = topicLabel(l, { fallback: "RUN", hosts: ["jeremy", "quartering"], ground: [everyWord] });
assert.equal(r.from, "fallback", `label refused: ${l}`);
assert.equal(r.label, "RUN");
}
for (const hd of REFUSED_HEADINGS) {
assert.equal(neutralHeading(hd, { labels: ["the acolyte ratings"], ground: [everyWord], topic: "the acolyte" }).from, "code", `heading replaced: ${hd}`);
}
// Curly apostrophes are the same apostrophe.
assert.ok(labelProblem("Jeremy’s ban", ["jeremy"]));
assert.ok(labelProblem("the actress’s comments"));
});
test("noun-phrase topics still pass", () => {
const ground = ["the acolyte ratings were the lowest", "disney star wars budget", "wizards of the coast changed its ban policy", "What has Jeremy said about being banned from Magic: The Gathering events and his dispute with Wizards of the Coast?"];
for (const l of ["the acolyte ratings", "disney star wars budget", "wizards of the coast ban policy", "the acolyte's audience score", "the ban from sanctioned events"]) {
assert.equal(labelProblem(l), null, l);
}
for (const l of ["the acolyte ratings", "disney star wars budget", "wizards of the coast ban policy"]) {
assert.deepEqual(topicLabel(l, { fallback: "RUN", hosts: ["jeremy"], ground }), { label: l, from: "model" }, l);
}
// "viewership" is not "view"; "statement" is refused, "states" alone is not in the list.
assert.equal(labelProblem("acolyte viewership numbers"), null);
assert.equal(labelProblem("united states release"), null);
});
test("the run's topic: the model's when it passes the label rules, never its raw words unchecked", () => {
const ground = ["What has Jeremy said about the Star Wars show The Acolyte?", "the acolyte", "leslye headland"];
assert.equal(runTopicOf(["star wars the acolyte"], { hosts: ["jeremy"], ground }).topic, "star wars the acolyte");
const r = runTopicOf(["Jeremy's hatred of the acolyte", "the acolyte"], { hosts: ["jeremy"], ground });
assert.equal(r.topic, "the acolyte");
assert.deepEqual(r.refused.map((x) => x.candidate), ["Jeremy's hatred of the acolyte"]);
assert.equal(runTopicOf(["he hates it", "", 7], { ground }).topic, "the question's subject");
});
test("a neutral sweep says so in its coverage line", () => {
assert.ok(isNeutralSweep(`## Coverage\n\nThe quotes were picked by m; ${NEUTRAL_LINES_NOTE}; every quote checked.`));
assert.equal(isNeutralSweep("## Coverage\n\nDrafted by m."), false);
});
// Every function over text a model or a transcript wrote runs in linear time
// (the review of round b found a pattern that never returned on 60 letters).
const slow = (f: () => unknown) => {
const t0 = performance.now();
f();
return performance.now() - t0;
};
const ADVERSARIAL = ["a".repeat(200), "x".repeat(150), "ha".repeat(75), "7".repeat(150)];
const big = (s: string) => s.repeat(Math.ceil(100_000 / s.length)).slice(0, 100_000);
const BIG = [".".repeat(100_000) + "x", big(" ."), big(".:"), big("a "), big("a'"), big("1,"), big("'s "), big("jeremy "), "a".repeat(100_000)];
test("the label, heading, title and date functions are linear on long and adversarial text", () => {
const ground = ["the acolyte", "a".repeat(200)];
for (const s of [...ADVERSARIAL, ...BIG]) {
const what = `${JSON.stringify(s.slice(0, 12))}×${s.length}`;
for (const [name, f] of [
["topicLabel", () => topicLabel(s, { fallback: "f", hosts: ["jeremy", "the quartering"], ground: [s, ...ground] })],
["labelProblem", () => labelProblem(s, ["jeremy"])],
["cleanLabel", () => cleanLabel(s)],
["neutralHeading", () => neutralHeading(s, { labels: [s.slice(0, 200)], ground: [s], topic: "t", hosts: ["jeremy"] })],
["runTopicOf", () => runTopicOf([s, s], { ground: [s] })],
["neutralSentence", () => neutralSentence({ title: s, date: s, topic: s.slice(0, 200) })],
["neutralTitle", () => neutralTitle(s, [s])],
["plainTitle", () => plainTitle(s)],
["humanDate", () => humanDate(s)],
] as const) {
const ms = slow(f);
assert.ok(ms < 50, `${name} on ${what}: ${ms.toFixed(1)} ms`);
}
}
});
test("a revision of a neutral report: the parent's claim flags are carried to the claims that cite the same words", async () => {
const { carryClaimFlags } = await import("./revise-report");
const cite = (id: string, quote: string) => ({ kind: "video" as const, channel: "c", id, start: 1, quote });
const parent = { sections: [{ id: "s", title: "S", claims: [{ id: "k1", text: "a", citations: ["c1"], flag: "check by ear: may be read aloud" }, { id: "k2", text: "b", citations: ["c2"] }] }], citations: { c1: cite("v1", "The judges were friends."), c2: cite("v1", "I did not enter") } };
const revised = { sections: [{ id: "t", title: "T", claims: [{ id: "k1", text: "b", citations: ["c1"] }, { id: "k2", text: "a", citations: ["c9"] }, { id: "k3", text: "x", citations: ["c3"] }] }], citations: { c1: cite("v1", "I did not enter"), c9: cite("v1", "the judges were friends"), c3: cite("v2", "the judges were friends") } };
assert.equal(carryClaimFlags(revised as never, [parent as never, null]), 1);
assert.deepEqual(revised.sections[0]!.claims.map((k) => (k as { flag?: string }).flag ?? null), [null, "check by ear: may be read aloud", null]);
});