Archilyzer · Source

archilyzer

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

commit 8e4a7e63d6e115845cf81d1cfeb64ce5cce76ab0
parent e9ea0e58cd3b1e65d46558ac90118247be810be3
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 14 Oct 2026 03:36:03 -0400

common: a flip topic or thread label past its limit is fitted in code, not refused

Found in the release 28 live smoke: qwen's thread label "Insulinoma: disease and treatment" was 33
characters against 32, twice. fitShortLine() keeps the part before a colon or dash when it fits, else drops
whole words (and a dangling small word) from the end; it runs when the answer is read, before the checks.

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

Diffstat:
Mcommon/lib/report/draft/tasks/clipEvidence.ts | 18++++++++++++++++++
Acommon/lib/report/draft/tasks/fitShortLine.test.ts | 11+++++++++++
Mcommon/lib/report/draft/tasks/flips.ts | 4++--
Mcommon/lib/report/draft/tasks/threads.ts | 4++--
4 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/common/lib/report/draft/tasks/clipEvidence.ts b/common/lib/report/draft/tasks/clipEvidence.ts @@ -141,6 +141,24 @@ export function fitLines(lines: string[], budget: number): { text: string; omitt return { text: kept.join("\n"), omitted: lines.length - kept.length }; } +const FIT_SMALL = new Set(["a", "an", "the", "and", "or", "of", "to", "in", "on", "for", "with", "at", "by", "from", "as", "but"]); + +/** + * A short line (a flip's topic, a thread's label) fitted to `max` characters + * in code, never by asking again: a line over it keeps the part before a colon + * or a dash when that part fits, else drops words from its end — and a small + * word left dangling — until it fits. A line that fits is returned as it is. + */ +export function fitShortLine(text: string, max: number): string { + const t = text.trim(); + if (t.length <= max) return t; + const head = t.split(/\s*[:—–]\s*|\s+-\s+/)[0]!.trim(); + if (head && head.length <= max && head !== t) return head; + const words = t.split(/\s+/); + while (words.length > 1 && (words.join(" ").length > max || FIT_SMALL.has(words.at(-1)!.toLowerCase()))) words.pop(); + return words.join(" ").replace(/[\s,;:.]+$/, ""); +} + const QUOTED = /“([^”]+)”|"([^"]+)"/g; /** diff --git a/common/lib/report/draft/tasks/fitShortLine.test.ts b/common/lib/report/draft/tasks/fitShortLine.test.ts @@ -0,0 +1,11 @@ +// fitShortLine (./clipEvidence.ts): a flip topic or a thread label fitted in code. +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { fitShortLine } from "./clipEvidence"; + +test("fitShortLine (release 28 smoke): a label past its limit is fitted in code — the part before a colon, else whole words off its end", () => { + assert.equal(fitShortLine("Insulinoma: Disease and Management", 32), "Insulinoma"); + assert.equal(fitShortLine("Rescue growth and staffing and the vets", 32), "Rescue growth and staffing"); + assert.equal(fitShortLine("The bakery", 32), "The bakery"); + assert.equal(fitShortLine("Supercalifragilisticexpialidociousnessness", 32).length > 32, true, "one word is left for the check to refuse"); +}); diff --git a/common/lib/report/draft/tasks/flips.ts b/common/lib/report/draft/tasks/flips.ts @@ -32,7 +32,7 @@ import { applyDraft, clearDrafted, entriesWithId, ownerOf } from "../../drafted. import { FLIPS_LIMITS, threadsOn, validateFlipEntries, validateFlips } from "../../panels.mjs"; import type { GroundingInput } from "../grounding"; import type { ManifestEntry, VideoManifest } from "../videoOps"; -import { checkLine, clipFacts, clipLine, fitLines, whenOf, type ClipFact } from "./clipEvidence"; +import { checkLine, clipFacts, clipLine, fitLines, fitShortLine, whenOf, type ClipFact } from "./clipEvidence"; import { runMediaTask, type MediaAttempt, type MediaContext, type MediaTaskInput, type MediaTaskSpec, type MediaUnit } from "./media"; import { TaskInputError } from "./run"; import type { TaskDeps, TaskResult } from "./types"; @@ -293,7 +293,7 @@ export const FLIPS_SPEC: MediaTaskSpec<FlipsUnit, FlipsValue, FlipsInput> = { pairs: list .filter((p): p is Record<string, unknown> => !!p && typeof p === "object") .map((p) => ({ - topic: oneLine(p.topic), + topic: fitShortLine(oneLine(p.topic), FLIPS_LIMITS.topic), then: oneLine(p.then), now: oneLine(p.now), ...(typeof p.thenWords === "string" && p.thenWords.trim() ? { thenWords: p.thenWords } : {}), diff --git a/common/lib/report/draft/tasks/threads.ts b/common/lib/report/draft/tasks/threads.ts @@ -31,7 +31,7 @@ import { THREADS_LIMITS, flipsOn, validateThreadEntries, validateThreads } from import { VERDICTS } from "../../verdicts.mjs"; import type { GroundingInput } from "../grounding"; import type { VideoManifest } from "../videoOps"; -import { checkLine, clipFacts, clipLine, fitLines, type ClipFact } from "./clipEvidence"; +import { checkLine, clipFacts, clipLine, fitLines, fitShortLine, type ClipFact } from "./clipEvidence"; import { runMediaTask, type MediaAttempt, type MediaContext, type MediaTaskInput, type MediaTaskSpec, type MediaUnit } from "./media"; import { TaskInputError } from "./run"; import type { TaskDeps, TaskResult } from "./types"; @@ -218,7 +218,7 @@ export const THREADS_SPEC: MediaTaskSpec<ThreadsUnit, ThreadsValue, ThreadsInput if (!Array.isArray(a?.threads)) throw new Error("no threads list in the answer"); const objs = (v: unknown) => (Array.isArray(v) ? v : []).filter((x): x is Record<string, unknown> => !!x && typeof x === "object"); return { - threads: objs(a.threads).map((t) => ({ id: oneLine(t.id), label: oneLine(t.label) })), + threads: objs(a.threads).map((t) => ({ id: oneLine(t.id), label: fitShortLine(oneLine(t.label), THREADS_LIMITS.label) })), assign: objs(a.clips).map((c) => ({ clip: oneLine(c.clip), thread: oneLine(c.thread) })), }; },