FAILURE MAP
← Case archive

FA-80141 / Typography line breaking / Open access

Runt last-line prevention: runt measure unit · case 01

Short last lines with several short words are left as runts.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The runt test counts words instead of characters.

VERIFIED REPAIR

Measure the last line in characters including spaces.

Unsuccessful approach: Ignoring spaces undercounts multi-word lines.

Case contract

Input [words, width, minimum last-line length]. Greedy fill (unit spaces; overwide word alone). Then while there are at least two lines and the last line string is shorter than the minimum, move the last word of the previous line down if that line keeps at least one word and the new last line fits. Return lines.

Why this case matters

Line breaking decides where paragraphs wrap on screen and in print; a wrong decision point shifts every following line.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    words, width, min_last = x
    lines = []
    cur = ''
    for w in words:
        cand = w if not cur else cur + ' ' + w
        if len(cand) <= width or not cur:
            cur = cand
        else:
            lines.append(cur)
            cur = w
    lines.append(cur)
    while len(lines) >= 2 and len(lines[-1].split(' ')) < min_last:
        prev = lines[-2].split(' ')
        if len(prev) < 2:
            break
        moved = prev[-1] + ' ' + lines[-1]
        if len(moved) > width:
            break
        lines[-2] = ' '.join(prev[:-1])
        lines[-1] = moved
    return lines
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: runt measure unit', [['grid', 'the', 'grid', 'baseline', 'serif'], 20, 8], ['grid the grid', 'baseline serif']), ('regression: runt measure unit', [['type', 'the', 'baseline', 'a', 'grid', 'x', 'ink', 'of'], 20, 9], ['type the baseline a', 'grid x ink of']), ('regression: runt measure unit', [['kerning', 'grid', 'of', 'is', 'serif', 'the', 'serif', 'ink', 'serif', 'type', 'a', 'the'], 17, 9], ['kerning grid of', 'is serif the', 'serif ink serif', 'type a the']), ('regression: runt measure unit', [['baseline', 'type', 'is', 'of', 'serif', 'x', 'grid', 'on', 'x'], 14, 8], ['baseline type', 'is of serif x', 'grid on x']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('control layout', [['ink', 'on', 'kerning', 'ink', 'is', 'measure'], 14, 7], ['ink on kerning', 'ink is measure']), ('control layout', [['kerning', 'grid', 'a', 'kerning', 'serif', 'is', 'the', 'kerning', 'baseline', 'serif'], 7, 4], ['kerning', 'grid a', 'kerning', 'serif', 'is the', 'kerning', 'baseline', 'serif'])], [('regression: runt measure unit', [['baseline', 'x', 'at', 'the', 'measure', 'serif', 'ink', 'grid', 'a', 'the', 'on', 'kerning'], 13, 3], ['baseline x at', 'the measure', 'serif ink', 'grid a the on', 'kerning']), ('regression: runt measure unit', [['x', 'x', 'measure', 'baseline', 'of', 'on', 'on', 'serif', 'serif', 'type', 'type'], 15, 9], ['x x measure', 'baseline of on', 'on serif serif', 'type type']), ('regression: runt measure unit', [['serif', 'baseline', 'x', 'ink', 'at', 'on', 'on', 'a', 'at'], 16, 4], ['serif baseline x', 'ink at on on', 'a at']), ('regression: runt measure unit', [['kerning', 'at', 'at', 'is', 'is'], 15, 8], ['kerning at', 'at is is']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('control layout', [['serif', 'of', 'ink', 'grid', 'the', 'kerning', 'is', 'type', 'x', 'is'], 5, 9], ['serif', 'of', 'ink', 'grid', 'the', 'kerning', 'is', 'type', 'x is']), ('control layout', [['x', 'a', 'baseline', 'is', 'measure'], 10, 8], ['x a', 'baseline', 'is measure'])], [('regression: runt measure unit', [['is', 'the', 'serif', 'grid', 'serif', 'of', 'serif'], 13, 3], ['is the serif', 'grid serif of', 'serif']), ('regression: runt measure unit', [['measure', 'x', 'x', 'the', 'a', 'the', 'at', 'baseline', 'ink', 'is', 'grid', 'measure'], 20, 9], ['measure x x the a', 'the at baseline ink', 'is grid measure']), ('regression: runt measure unit', [['at', 'measure', 'grid', 'serif', 'on', 'is', 'measure', 'at', 'at', 'at', 'the'], 15, 9], ['at measure grid', 'serif on is', 'measure at', 'at at the']), ('regression: runt measure unit', [['the', 'a', 'ink', 'on', 'at'], 11, 5], ['the a ink', 'on at']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('control layout', [['on', 'is', 'type', 'grid', 'ink', 'at', 'the', 'is', 'type'], 6, 6], ['on is', 'type', 'grid', 'ink at', 'the is', 'type']), ('control layout', [['a', 'the', 'of', 'measure', 'at', 'type', 'kerning', 'the', 'ink'], 15, 7], ['a the of', 'measure at type', 'kerning the ink'])], [('regression: runt measure unit', [['at', 'measure', 'kerning', 'of', 'is', 'type'], 17, 3], ['at measure', 'kerning of is', 'type']), ('regression: runt measure unit', [['at', 'of', 'measure', 'x', 'of', 'on', 'grid', 'of', 'x', 'is', 'serif'], 10, 8], ['at of', 'measure x', 'of on grid', 'of x', 'is serif']), ('regression: runt measure unit', [['the', 'is', 'grid', 'at', 'at', 'a', 'is'], 18, 7], ['the is grid at', 'at a is']), ('regression: runt measure unit', [['a', 'kerning', 'serif', 'is', 'a'], 16, 4], ['a kerning serif', 'is a']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('control layout', [['baseline', 'serif', 'is', 'baseline', 'x', 'x', 'at', 'is', 'serif', 'at', 'at'], 6, 9], ['baseline', 'serif', 'is', 'baseline', 'x x at', 'is', 'serif', 'at at']), ('control layout', [['of', 'the', 'kerning'], 6, 4], ['of the', 'kerning'])], [('regression: runt measure unit', [['grid', 'kerning', 'ink', 'baseline', 'at', 'type', 'grid', 'of', 'baseline', 'type', 'ink'], 18, 7], ['grid kerning ink', 'baseline at type', 'grid of baseline', 'type ink']), ('regression: runt measure unit', [['ink', 'the', 'kerning', 'x', 'kerning'], 18, 7], ['ink the kerning x', 'kerning']), ('regression: runt measure unit', [['a', 'serif', 'grid', 'ink', 'measure', 'the', 'type', 'type', 'at', 'a', 'of'], 13, 7], ['a serif grid', 'ink measure', 'the type type', 'at a of']), ('regression: runt measure unit', [['at', 'measure', 'grid', 'serif', 'on', 'is', 'measure', 'at', 'at', 'at', 'the'], 15, 9], ['at measure grid', 'serif on is', 'measure at', 'at at the']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('control layout', [['the', 'on', 'is', 'at', 'baseline', 'the', 'a', 'at', 'ink', 'type'], 9, 5], ['the on is', 'at', 'baseline', 'the a at', 'ink type']), ('control layout', [['on', 'serif', 'on'], 7, 6], ['on', 'serif', 'on'])]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: runt measure unit['grid the', 'grid baseline serif']['grid the grid', 'baseline serif']Failed
regression: runt measure unit['type the baseline', 'a grid x ink of']['type the baseline a', 'grid x ink of']Failed
regression: runt measure unit['kerning grid of', 'is serif the', 'serif ink', 'serif type a the']['kerning grid of', 'is serif the', 'serif ink serif', 'type a the']Failed
regression: runt measure unit['baseline type', 'is of serif', 'x grid on x']['baseline type', 'is of serif x', 'grid on x']Failed
runt limited by width['kerning', 'baseline x']['kerning', 'baseline x']Passed
one-word runt pulled down['the type', 'grid is a']['the type', 'grid is a']Passed
control layout['ink on kerning', 'ink is measure']['ink on kerning', 'ink is measure']Passed
control layout['kerning', 'grid a', 'kerning', 'serif', 'is the', 'kerning', 'baseline', 'serif']['kerning', 'grid a', 'kerning', 'serif', 'is the', 'kerning', 'baseline', 'serif']Passed

SHA-256 / 6dd284329a6acd99c4ae3cc2e229c325c68d8dca2440f10269f296e41a992376

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    words, width, min_last = x
    lines = []
    cur = ''
    for w in words:
        cand = w if not cur else cur + ' ' + w
        if len(cand) <= width or not cur:
            cur = cand
        else:
            lines.append(cur)
            cur = w
    lines.append(cur)
    while len(lines) >= 2 and len(lines[-1].replace(' ', '')) < min_last:
        prev = lines[-2].split(' ')
        if len(prev) < 2:
            break
        moved = prev[-1] + ' ' + lines[-1]
        if len(moved) > width:
            break
        lines[-2] = ' '.join(prev[:-1])
        lines[-1] = moved
    return lines
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: runt measure unit', [['grid', 'the', 'grid', 'baseline', 'serif'], 20, 8], ['grid the grid', 'baseline serif']), ('regression: runt measure unit', [['type', 'the', 'baseline', 'a', 'grid', 'x', 'ink', 'of'], 20, 9], ['type the baseline a', 'grid x ink of']), ('regression: runt measure unit', [['kerning', 'grid', 'of', 'is', 'serif', 'the', 'serif', 'ink', 'serif', 'type', 'a', 'the'], 17, 9], ['kerning grid of', 'is serif the', 'serif ink serif', 'type a the']), ('regression: runt measure unit', [['baseline', 'type', 'is', 'of', 'serif', 'x', 'grid', 'on', 'x'], 14, 8], ['baseline type', 'is of serif x', 'grid on x']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('control layout', [['ink', 'on', 'kerning', 'ink', 'is', 'measure'], 14, 7], ['ink on kerning', 'ink is measure']), ('control layout', [['kerning', 'grid', 'a', 'kerning', 'serif', 'is', 'the', 'kerning', 'baseline', 'serif'], 7, 4], ['kerning', 'grid a', 'kerning', 'serif', 'is the', 'kerning', 'baseline', 'serif'])], [('regression: runt measure unit', [['baseline', 'x', 'at', 'the', 'measure', 'serif', 'ink', 'grid', 'a', 'the', 'on', 'kerning'], 13, 3], ['baseline x at', 'the measure', 'serif ink', 'grid a the on', 'kerning']), ('regression: runt measure unit', [['x', 'x', 'measure', 'baseline', 'of', 'on', 'on', 'serif', 'serif', 'type', 'type'], 15, 9], ['x x measure', 'baseline of on', 'on serif serif', 'type type']), ('regression: runt measure unit', [['serif', 'baseline', 'x', 'ink', 'at', 'on', 'on', 'a', 'at'], 16, 4], ['serif baseline x', 'ink at on on', 'a at']), ('regression: runt measure unit', [['kerning', 'at', 'at', 'is', 'is'], 15, 8], ['kerning at', 'at is is']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('control layout', [['serif', 'of', 'ink', 'grid', 'the', 'kerning', 'is', 'type', 'x', 'is'], 5, 9], ['serif', 'of', 'ink', 'grid', 'the', 'kerning', 'is', 'type', 'x is']), ('control layout', [['x', 'a', 'baseline', 'is', 'measure'], 10, 8], ['x a', 'baseline', 'is measure'])], [('regression: runt measure unit', [['is', 'the', 'serif', 'grid', 'serif', 'of', 'serif'], 13, 3], ['is the serif', 'grid serif of', 'serif']), ('regression: runt measure unit', [['measure', 'x', 'x', 'the', 'a', 'the', 'at', 'baseline', 'ink', 'is', 'grid', 'measure'], 20, 9], ['measure x x the a', 'the at baseline ink', 'is grid measure']), ('regression: runt measure unit', [['at', 'measure', 'grid', 'serif', 'on', 'is', 'measure', 'at', 'at', 'at', 'the'], 15, 9], ['at measure grid', 'serif on is', 'measure at', 'at at the']), ('regression: runt measure unit', [['the', 'a', 'ink', 'on', 'at'], 11, 5], ['the a ink', 'on at']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('control layout', [['on', 'is', 'type', 'grid', 'ink', 'at', 'the', 'is', 'type'], 6, 6], ['on is', 'type', 'grid', 'ink at', 'the is', 'type']), ('control layout', [['a', 'the', 'of', 'measure', 'at', 'type', 'kerning', 'the', 'ink'], 15, 7], ['a the of', 'measure at type', 'kerning the ink'])], [('regression: runt measure unit', [['at', 'measure', 'kerning', 'of', 'is', 'type'], 17, 3], ['at measure', 'kerning of is', 'type']), ('regression: runt measure unit', [['at', 'of', 'measure', 'x', 'of', 'on', 'grid', 'of', 'x', 'is', 'serif'], 10, 8], ['at of', 'measure x', 'of on grid', 'of x', 'is serif']), ('regression: runt measure unit', [['the', 'is', 'grid', 'at', 'at', 'a', 'is'], 18, 7], ['the is grid at', 'at a is']), ('regression: runt measure unit', [['a', 'kerning', 'serif', 'is', 'a'], 16, 4], ['a kerning serif', 'is a']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('control layout', [['baseline', 'serif', 'is', 'baseline', 'x', 'x', 'at', 'is', 'serif', 'at', 'at'], 6, 9], ['baseline', 'serif', 'is', 'baseline', 'x x at', 'is', 'serif', 'at at']), ('control layout', [['of', 'the', 'kerning'], 6, 4], ['of the', 'kerning'])], [('regression: runt measure unit', [['grid', 'kerning', 'ink', 'baseline', 'at', 'type', 'grid', 'of', 'baseline', 'type', 'ink'], 18, 7], ['grid kerning ink', 'baseline at type', 'grid of baseline', 'type ink']), ('regression: runt measure unit', [['ink', 'the', 'kerning', 'x', 'kerning'], 18, 7], ['ink the kerning x', 'kerning']), ('regression: runt measure unit', [['a', 'serif', 'grid', 'ink', 'measure', 'the', 'type', 'type', 'at', 'a', 'of'], 13, 7], ['a serif grid', 'ink measure', 'the type type', 'at a of']), ('regression: runt measure unit', [['at', 'measure', 'grid', 'serif', 'on', 'is', 'measure', 'at', 'at', 'at', 'the'], 15, 9], ['at measure grid', 'serif on is', 'measure at', 'at at the']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('control layout', [['the', 'on', 'is', 'at', 'baseline', 'the', 'a', 'at', 'ink', 'type'], 9, 5], ['the on is', 'at', 'baseline', 'the a at', 'ink type']), ('control layout', [['on', 'serif', 'on'], 7, 6], ['on', 'serif', 'on'])]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: runt measure unit['grid the grid', 'baseline serif']['grid the grid', 'baseline serif']Passed
regression: runt measure unit['type the baseline a', 'grid x ink of']['type the baseline a', 'grid x ink of']Passed
regression: runt measure unit['kerning grid of', 'is serif the', 'serif ink', 'serif type a the']['kerning grid of', 'is serif the', 'serif ink serif', 'type a the']Failed
regression: runt measure unit['baseline type', 'is of serif', 'x grid on x']['baseline type', 'is of serif x', 'grid on x']Failed
runt limited by width['kerning', 'baseline x']['kerning', 'baseline x']Passed
one-word runt pulled down['the type', 'grid is a']['the type', 'grid is a']Passed
control layout['ink on kerning', 'ink is measure']['ink on kerning', 'ink is measure']Passed
control layout['kerning', 'grid a', 'kerning', 'serif', 'is the', 'kerning', 'baseline', 'serif']['kerning', 'grid a', 'kerning', 'serif', 'is the', 'kerning', 'baseline', 'serif']Passed

SHA-256 / c1e58cd8f769bc5d075f33ab3dc64f98bc0caf54e8f448f7930d1c9a52993b38

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    words, width, min_last = x
    lines = []
    cur = ''
    for w in words:
        cand = w if not cur else cur + ' ' + w
        if len(cand) <= width or not cur:
            cur = cand
        else:
            lines.append(cur)
            cur = w
    lines.append(cur)
    while len(lines) >= 2 and len(lines[-1]) < min_last:
        prev = lines[-2].split(' ')
        if len(prev) < 2:
            break
        moved = prev[-1] + ' ' + lines[-1]
        if len(moved) > width:
            break
        lines[-2] = ' '.join(prev[:-1])
        lines[-1] = moved
    return lines
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: runt measure unit', [['grid', 'the', 'grid', 'baseline', 'serif'], 20, 8], ['grid the grid', 'baseline serif']), ('regression: runt measure unit', [['type', 'the', 'baseline', 'a', 'grid', 'x', 'ink', 'of'], 20, 9], ['type the baseline a', 'grid x ink of']), ('regression: runt measure unit', [['kerning', 'grid', 'of', 'is', 'serif', 'the', 'serif', 'ink', 'serif', 'type', 'a', 'the'], 17, 9], ['kerning grid of', 'is serif the', 'serif ink serif', 'type a the']), ('regression: runt measure unit', [['baseline', 'type', 'is', 'of', 'serif', 'x', 'grid', 'on', 'x'], 14, 8], ['baseline type', 'is of serif x', 'grid on x']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('control layout', [['ink', 'on', 'kerning', 'ink', 'is', 'measure'], 14, 7], ['ink on kerning', 'ink is measure']), ('control layout', [['kerning', 'grid', 'a', 'kerning', 'serif', 'is', 'the', 'kerning', 'baseline', 'serif'], 7, 4], ['kerning', 'grid a', 'kerning', 'serif', 'is the', 'kerning', 'baseline', 'serif'])], [('regression: runt measure unit', [['baseline', 'x', 'at', 'the', 'measure', 'serif', 'ink', 'grid', 'a', 'the', 'on', 'kerning'], 13, 3], ['baseline x at', 'the measure', 'serif ink', 'grid a the on', 'kerning']), ('regression: runt measure unit', [['x', 'x', 'measure', 'baseline', 'of', 'on', 'on', 'serif', 'serif', 'type', 'type'], 15, 9], ['x x measure', 'baseline of on', 'on serif serif', 'type type']), ('regression: runt measure unit', [['serif', 'baseline', 'x', 'ink', 'at', 'on', 'on', 'a', 'at'], 16, 4], ['serif baseline x', 'ink at on on', 'a at']), ('regression: runt measure unit', [['kerning', 'at', 'at', 'is', 'is'], 15, 8], ['kerning at', 'at is is']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('control layout', [['serif', 'of', 'ink', 'grid', 'the', 'kerning', 'is', 'type', 'x', 'is'], 5, 9], ['serif', 'of', 'ink', 'grid', 'the', 'kerning', 'is', 'type', 'x is']), ('control layout', [['x', 'a', 'baseline', 'is', 'measure'], 10, 8], ['x a', 'baseline', 'is measure'])], [('regression: runt measure unit', [['is', 'the', 'serif', 'grid', 'serif', 'of', 'serif'], 13, 3], ['is the serif', 'grid serif of', 'serif']), ('regression: runt measure unit', [['measure', 'x', 'x', 'the', 'a', 'the', 'at', 'baseline', 'ink', 'is', 'grid', 'measure'], 20, 9], ['measure x x the a', 'the at baseline ink', 'is grid measure']), ('regression: runt measure unit', [['at', 'measure', 'grid', 'serif', 'on', 'is', 'measure', 'at', 'at', 'at', 'the'], 15, 9], ['at measure grid', 'serif on is', 'measure at', 'at at the']), ('regression: runt measure unit', [['the', 'a', 'ink', 'on', 'at'], 11, 5], ['the a ink', 'on at']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('control layout', [['on', 'is', 'type', 'grid', 'ink', 'at', 'the', 'is', 'type'], 6, 6], ['on is', 'type', 'grid', 'ink at', 'the is', 'type']), ('control layout', [['a', 'the', 'of', 'measure', 'at', 'type', 'kerning', 'the', 'ink'], 15, 7], ['a the of', 'measure at type', 'kerning the ink'])], [('regression: runt measure unit', [['at', 'measure', 'kerning', 'of', 'is', 'type'], 17, 3], ['at measure', 'kerning of is', 'type']), ('regression: runt measure unit', [['at', 'of', 'measure', 'x', 'of', 'on', 'grid', 'of', 'x', 'is', 'serif'], 10, 8], ['at of', 'measure x', 'of on grid', 'of x', 'is serif']), ('regression: runt measure unit', [['the', 'is', 'grid', 'at', 'at', 'a', 'is'], 18, 7], ['the is grid at', 'at a is']), ('regression: runt measure unit', [['a', 'kerning', 'serif', 'is', 'a'], 16, 4], ['a kerning serif', 'is a']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('control layout', [['baseline', 'serif', 'is', 'baseline', 'x', 'x', 'at', 'is', 'serif', 'at', 'at'], 6, 9], ['baseline', 'serif', 'is', 'baseline', 'x x at', 'is', 'serif', 'at at']), ('control layout', [['of', 'the', 'kerning'], 6, 4], ['of the', 'kerning'])], [('regression: runt measure unit', [['grid', 'kerning', 'ink', 'baseline', 'at', 'type', 'grid', 'of', 'baseline', 'type', 'ink'], 18, 7], ['grid kerning ink', 'baseline at type', 'grid of baseline', 'type ink']), ('regression: runt measure unit', [['ink', 'the', 'kerning', 'x', 'kerning'], 18, 7], ['ink the kerning x', 'kerning']), ('regression: runt measure unit', [['a', 'serif', 'grid', 'ink', 'measure', 'the', 'type', 'type', 'at', 'a', 'of'], 13, 7], ['a serif grid', 'ink measure', 'the type type', 'at a of']), ('regression: runt measure unit', [['at', 'measure', 'grid', 'serif', 'on', 'is', 'measure', 'at', 'at', 'at', 'the'], 15, 9], ['at measure grid', 'serif on is', 'measure at', 'at at the']), ('runt limited by width', [['kerning', 'baseline', 'x'], 10, 4], ['kerning', 'baseline x']), ('one-word runt pulled down', [['the', 'type', 'grid', 'is', 'a'], 12, 5], ['the type', 'grid is a']), ('control layout', [['the', 'on', 'is', 'at', 'baseline', 'the', 'a', 'at', 'ink', 'type'], 9, 5], ['the on is', 'at', 'baseline', 'the a at', 'ink type']), ('control layout', [['on', 'serif', 'on'], 7, 6], ['on', 'serif', 'on'])]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: runt measure unit['grid the grid', 'baseline serif']['grid the grid', 'baseline serif']Passed
regression: runt measure unit['type the baseline a', 'grid x ink of']['type the baseline a', 'grid x ink of']Passed
regression: runt measure unit['kerning grid of', 'is serif the', 'serif ink serif', 'type a the']['kerning grid of', 'is serif the', 'serif ink serif', 'type a the']Passed
regression: runt measure unit['baseline type', 'is of serif x', 'grid on x']['baseline type', 'is of serif x', 'grid on x']Passed
runt limited by width['kerning', 'baseline x']['kerning', 'baseline x']Passed
one-word runt pulled down['the type', 'grid is a']['the type', 'grid is a']Passed
control layout['ink on kerning', 'ink is measure']['ink on kerning', 'ink is measure']Passed
control layout['kerning', 'grid a', 'kerning', 'serif', 'is the', 'kerning', 'baseline', 'serif']['kerning', 'grid a', 'kerning', 'serif', 'is the', 'kerning', 'baseline', 'serif']Passed

SHA-256 / 4bdfa2e83c4ff9d5e9072ca847623f27045bb86f2ad1b1366530e871d61f4c35

Verification & scope

A deterministic toy typesetting model with integer widths and a stipulated rule set; it does not claim conformance to any engine. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:49:50.979619+00:00.

Case digest / 075490bec347a375276d7911d785fc9923dcca59b0211c8f496ee6d59eb0fe4d