Archilyzer · Source

archilyzer

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

commit 9db5202544125de10c3595c35c5ef0c2aef99e8d
parent 0011db86ac2dafea3b1dfc3ffc44f5d66325f09d
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 14 Oct 2026 02:50:15 -0400

common: a teaser line past its role's row gets its end as the second tier, in code

Found in the release 28 live smoke: Sonnet wrote a 36-character middle line twice (a title row fits 34) and
the teaser was refused. fitTeaserLines() sets a long line's end as its `break` at the last word boundary
where the first tier fits the role and the end fits the second tier's row; the build's check and the write
both see the fitted lines. A line no split can fit is still refused.

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

Diffstat:
Mcommon/lib/report/draft/tasks/teaser.test.ts | 18+++++++++++++++---
Mcommon/lib/report/draft/tasks/teaser.ts | 33+++++++++++++++++++++++++++++++--
2 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/common/lib/report/draft/tasks/teaser.test.ts b/common/lib/report/draft/tasks/teaser.test.ts @@ -16,7 +16,7 @@ import { promisify } from "node:util"; import { jsonReply, startFakeOllama, type FakeOllama } from "../../../../testing/llm/fakeOllama.mjs"; import { createIteration, projectOf, updateIteration, writeIterationFile } from "../../iterations"; import { loadDeckChecks, type DeckChecks } from "./deckChecks"; -import { checkTeaser, claimGist, parseTeaser, teaser, teaserEvidence } from "./teaser"; +import { checkTeaser, claimGist, fitTeaserLines, parseTeaser, teaser, teaserEvidence } from "./teaser"; import type { DraftFile } from "./media"; import type { TaskDeps } from "./types"; @@ -107,8 +107,10 @@ test("teaser's checks, each alone; the build's validateTeaser is one of them", a assert.deepEqual(hard(["Synth Kitchen", "The baker's bakery", "The contest"]), [], "an apostrophe is not a quotation"); assert.match(hard(["Synth Kitchen", "The bakery", "In 2025"]).join(), /line 3: number 2025 is not in the report/); assert.match(hard(["Synth Kitchen", "The bakery", "Ask Marco"]).join(), /line 3: name “Marco” is not in the report/); - // A middle line is a title: past its row's fit the build refuses it. - assert.match(hard(["Synth Kitchen", "The bakery and the contest and the oven", "The contest"]).join(), /it would not build: .*lines\[1\]/); + // A middle line is a title: past its row's fit, code sets its end as the + // second tier; a line no split can fit (one long word) the build refuses. + assert.deepEqual(hard(["Synth Kitchen", "The bakery and the contest and the oven", "The contest"]), []); + assert.match(hard(["Synth Kitchen", "Thebakeryandthecontestandtheovenandmore", "The contest"]).join(), /it would not build: .*lines\[1\]/); // Without the build's check nothing is written. assert.match(hard(["Synth Kitchen", "The bakery", "The contest"], { ...u, deck: null as never }).join(), /not available, so the lines are not written/); assert.equal(claimGist('She says she would not sell: "I would never sell the bakery to a chain"'), "She says she would not sell"); @@ -141,3 +143,13 @@ test("teaser: the operator's lines kept (forced, the draft an alternative); a te assert.equal((await q.manifestNow()).timeline.some((e: { type: string }) => e.type === "teaser"), false, "no teaser added"); assert.equal(ol.remaining(), 0); }); + +test("teaser: a line past its role's row gets its end as the second tier; one that fits, or cannot be split, stays as written", () => { + const long = "Why can a glucose crash save a life?"; // 36: a title fits 34 + assert.deepEqual(fitTeaserLines(["Overline", long, "Kicker"]), ["Overline", { text: long, break: "life?" }, "Kicker"]); + assert.deepEqual(fitTeaserLines(["Overline", "Short title", "Kicker"]), ["Overline", "Short title", "Kicker"]); + // Roles follow position: one line is a title, two are an overline and a title. + assert.deepEqual(fitTeaserLines([long]), [{ text: long, break: "life?" }]); + assert.deepEqual(fitTeaserLines([long, long]), [long, { text: long, break: "life?" }]); + assert.deepEqual(fitTeaserLines(["Overline", "x".repeat(40), "Kicker"]), ["Overline", "x".repeat(40), "Kicker"]); +}); diff --git a/common/lib/report/draft/tasks/teaser.ts b/common/lib/report/draft/tasks/teaser.ts @@ -32,6 +32,35 @@ export const TEASER_QUOTE_RUN = 5; // The row each role fits (deck.mjs TEASER_LIMITS.fit): the prompt's rule; the // build's validator is the check. const ROLE_FIT = { overline: 64, title: 34, kicker: 56 }; +// A `break` (the line's end, drawn as the smaller second tier) fits this row. +const SUB_FIT = 66; + +export type TeaserLine = string | { text: string; break: string }; + +/** + * The lines as the card draws them: a line longer than its role's row (roles + * follow position: with three or more lines the first is the overline, the + * last the kicker, the rest titles; two are an overline and a title; one is a + * title) becomes `{ text, break }`, its end set as the second tier at the last + * word boundary where the first tier fits the role and the end fits the + * second tier's row. A line that cannot be split so stays as written, and the + * build's check refuses it. Code fits the rows; the model only writes words. + */ +export function fitTeaserLines(lines: string[]): TeaserLine[] { + const roleOf = (i: number): keyof typeof ROLE_FIT => + lines.length >= 3 ? (i === 0 ? "overline" : i === lines.length - 1 ? "kicker" : "title") : lines.length === 2 && i === 0 ? "overline" : "title"; + return lines.map((line, i) => { + const fit = ROLE_FIT[roleOf(i)]; + if (line.length <= fit) return line; + const words = line.split(/\s+/); + for (let k = words.length - 1; k >= 1; k--) { + const head = words.slice(0, k).join(" "); + const tail = words.slice(k).join(" "); + if (head.length <= fit && tail.length <= SUB_FIT) return { text: line, break: tail }; + } + return line; + }); +} export const NEW_TEASER_ID = "teaser"; export type TeaserInput = MediaTaskInput; @@ -96,7 +125,7 @@ export function quoteRunIn(line: string, quotes: readonly string[]): string | nu /** The teaser entry these lines would make. */ export const teaserEntryOf = (u: Pick<TeaserUnit, "entry" | "id">, lines: string[]): ManifestEntry => - ({ ...(u.entry ?? { type: "teaser", id: u.id }), lines }) as ManifestEntry; + ({ ...(u.entry ?? { type: "teaser", id: u.id }), lines: fitTeaserLines(lines) }) as ManifestEntry; /** Every code check of a teaser's lines: `hard` refuses them. */ export function checkTeaser(lines: string[], u: Pick<TeaserUnit, "entry" | "id" | "evidence" | "quotes" | "deck">): { hard: string[]; soft: string[] } { @@ -197,7 +226,7 @@ export const TEASER_SPEC: MediaTaskSpec<TeaserUnit, string[], TeaserInput> = { }); manifest.timeline.splice(at < 0 ? manifest.timeline.length : at + 1, 0, { type: "teaser", id: u.id } as ManifestEntry); } - return applyDraft(manifest, { entry: u.id, field: "lines", value, provenance, force }); + return applyDraft(manifest, { entry: u.id, field: "lines", value: fitTeaserLines(value as string[]), provenance, force }); }, describe: (lines) => lines.join(" / "), };