Script-aware terminator + ellipsis-scrub helpers extracted
from resolve-helpers.ts so that module stays below the 600-line
drift-guard cap (see test/unit/source-file-size.test.js). Pure leaf
module — depends only on the script-family classifier from
seo-budgets.ts.
Background. Two SEO-extraction regressions repeatedly hit this code
path and motivated extracting it as its own module:
clampForBudget (and truncateDescription) emit a trailing …
when they have to hard-cut mid-clause — the
executive-brief-seo-extraction.test.js description-ellipsis gate
(and title-rejection.ts::looksLikeEllipsisCut) flag those as
truncation cuts. We scrub the ellipsis here and either back-scan to
the most recent real terminator within the trailing ~35 chars, or
append a script-appropriate sentence terminator (. for Latin /
RTL, 。 for CJK).
The second clamp in the HTML shell can knock the terminator off
when the description sits exactly at the per-script budget. The
maxLength reservation in ensureDescriptionTerminator fixes
a live 2026-05-26 regression where news/2026-05-26-breaking-fr.html
shipped a mid-word cut after the terminator was dropped.
Description
Script-aware terminator + ellipsis-scrub helpers extracted from
resolve-helpers.tsso that module stays below the 600-line drift-guard cap (seetest/unit/source-file-size.test.js). Pure leaf module — depends only on the script-family classifier fromseo-budgets.ts.Background. Two SEO-extraction regressions repeatedly hit this code path and motivated extracting it as its own module:
clampForBudget(andtruncateDescription) emit a trailing…when they have to hard-cut mid-clause — theexecutive-brief-seo-extraction.test.jsdescription-ellipsis gate (andtitle-rejection.ts::looksLikeEllipsisCut) flag those as truncation cuts. We scrub the ellipsis here and either back-scan to the most recent real terminator within the trailing ~35 chars, or append a script-appropriate sentence terminator (.for Latin / RTL,。for CJK).maxLengthreservation in ensureDescriptionTerminator fixes a live 2026-05-26 regression wherenews/2026-05-26-breaking-fr.htmlshipped a mid-word cut after the terminator was dropped.