FA-80131 / Typography line breaking / Open access
Runt last-line prevention: repeated rebalancing · case 01
A runt is only partly fixed when one moved word is not enough.
ROOT CAUSE
The rebalancing loop exits after moving a single word.
VERIFIED REPAIR
Keep moving words while the last line is still a runt.
Unsuccessful approach: Stopping once the donor line has fewer than three words still leaves runts.
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]) < 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
break
return lines
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: repeated rebalancing', [['the', 'the', 'is', 'ink', 'serif', 'on', 'on', 'ink'], 14, 8], ['the the is ink', 'serif', 'on on ink']), ('regression: repeated rebalancing', [['the', 'measure', 'a', 'x'], 14, 6], ['the', 'measure a x']), ('regression: repeated rebalancing', [['measure', 'is', 'on', 'grid', 'is', 'measure', 'ink', 'ink', 'serif', 'x', 'on'], 13, 9], ['measure is on', 'grid is', 'measure ink', 'ink', 'serif x on']), ('regression: repeated rebalancing', [['ink', 'the', 'of', 'of', 'of', 'on', 'at'], 10, 9], ['ink the of', 'of', 'of on at']), ('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', [['on', 'ink', 'type', 'a'], 12, 4], ['on ink', 'type a']), ('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: repeated rebalancing', [['x', 'on', 'is', 'the', 'is', 'is', 'ink'], 18, 7], ['x on is the', 'is is ink']), ('regression: repeated rebalancing', [['is', 'serif', 'on', 'a', 'type'], 14, 7], ['is serif', 'on a type']), ('regression: repeated rebalancing', [['grid', 'the', 'the', 'kerning', 'kerning', 'x', 'a'], 17, 7], ['grid the the', 'kerning', 'kerning x a']), ('regression: repeated rebalancing', [['is', 'baseline', 'measure', 'the', 'baseline', 'a', 'the', 'x'], 15, 8], ['is baseline', 'measure the', 'baseline', 'a the 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', [['serif', 'measure', 'type'], 11, 5], ['serif', 'measure', 'type']), ('control layout', [['of', 'at', 'x', 'on', 'measure', 'type', 'a', 'measure'], 19, 4], ['of at x on measure', 'type a measure'])], [('regression: repeated rebalancing', [['serif', 'the', 'is', 'is', 'of', 'grid', 'at', 'is', 'a'], 10, 7], ['serif the', 'is is of', 'grid', 'at is a']), ('regression: repeated rebalancing', [['measure', 'is', 'on', 'grid', 'is', 'measure', 'ink', 'ink', 'serif', 'x', 'on'], 13, 9], ['measure is on', 'grid is', 'measure ink', 'ink', 'serif x on']), ('regression: repeated rebalancing', [['ink', 'the', 'of', 'of', 'of', 'on', 'at'], 10, 9], ['ink the of', 'of', 'of on at']), ('regression: repeated rebalancing', [['measure', 'type', 'is', 'serif', 'at', 'the'], 13, 8], ['measure type', 'is', 'serif 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', [['serif', 'is', 'a', 'x', 'kerning', 'kerning'], 7, 4], ['serif', 'is a x', 'kerning', 'kerning']), ('control layout', [['grid', 'kerning', 'is', 'serif', 'ink'], 17, 7], ['grid kerning is', 'serif ink'])], [('regression: repeated rebalancing', [['the', 'on', 'a', 'a', 'of'], 10, 8], ['the', 'on a a of']), ('regression: repeated rebalancing', [['grid', 'the', 'the', 'kerning', 'kerning', 'x', 'a'], 17, 7], ['grid the the', 'kerning', 'kerning x a']), ('regression: repeated rebalancing', [['the', 'measure', 'a', 'x'], 14, 6], ['the', 'measure a x']), ('regression: repeated rebalancing', [['ink', 'the', 'of', 'of', 'of', 'on', 'at'], 10, 9], ['ink the of', 'of', 'of on at']), ('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', [['on', 'of', 'at', 'ink', 'measure'], 12, 5], ['on of at ink', 'measure']), ('control layout', [['kerning', 'is', 'type', 'of', 'type', 'of', 'baseline', 'a', 'baseline'], 14, 8], ['kerning is', 'type of type', 'of baseline a', 'baseline'])], [('regression: repeated rebalancing', [['the', 'on', 'a', 'a', 'of'], 10, 8], ['the', 'on a a of']), ('regression: repeated rebalancing', [['the', 'the', 'is', 'ink', 'serif', 'on', 'on', 'ink'], 14, 8], ['the the is ink', 'serif', 'on on ink']), ('regression: repeated rebalancing', [['is', 'baseline', 'measure', 'the', 'baseline', 'a', 'the', 'x'], 15, 8], ['is baseline', 'measure the', 'baseline', 'a the x']), ('regression: repeated rebalancing', [['grid', 'the', 'the', 'kerning', 'kerning', 'x', 'a'], 17, 7], ['grid the the', 'kerning', 'kerning x 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', [['type', 'ink', 'the', 'ink', 'the', 'of', 'kerning', 'a', 'of'], 13, 9], ['type ink the', 'ink the of', 'kerning a of']), ('control layout', [['x', 'baseline', 'grid', 'is', 'baseline', 'on', 'on', 'at', 'on', 'grid', 'grid'], 20, 3], ['x baseline grid is', 'baseline on on at on', 'grid grid'])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: repeated rebalancing | ['the the is ink', 'serif on', 'on ink'] | ['the the is ink', 'serif', 'on on ink'] | Failed |
| regression: repeated rebalancing | ['the measure', 'a x'] | ['the', 'measure a x'] | Failed |
| regression: repeated rebalancing | ['measure is on', 'grid is', 'measure ink', 'ink serif', 'x on'] | ['measure is on', 'grid is', 'measure ink', 'ink', 'serif x on'] | Failed |
| regression: repeated rebalancing | ['ink the of', 'of of', 'on at'] | ['ink the of', 'of', 'of on at'] | 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 | ['on ink', 'type a'] | ['on ink', 'type a'] | 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 / 3b25c0fe5a669ccd598fa0cb4d669afc984640972409a3abfbfe1ffa246b48d5
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]) < 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
if len(prev) < 4:
break
return lines
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: repeated rebalancing', [['the', 'the', 'is', 'ink', 'serif', 'on', 'on', 'ink'], 14, 8], ['the the is ink', 'serif', 'on on ink']), ('regression: repeated rebalancing', [['the', 'measure', 'a', 'x'], 14, 6], ['the', 'measure a x']), ('regression: repeated rebalancing', [['measure', 'is', 'on', 'grid', 'is', 'measure', 'ink', 'ink', 'serif', 'x', 'on'], 13, 9], ['measure is on', 'grid is', 'measure ink', 'ink', 'serif x on']), ('regression: repeated rebalancing', [['ink', 'the', 'of', 'of', 'of', 'on', 'at'], 10, 9], ['ink the of', 'of', 'of on at']), ('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', [['on', 'ink', 'type', 'a'], 12, 4], ['on ink', 'type a']), ('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: repeated rebalancing', [['x', 'on', 'is', 'the', 'is', 'is', 'ink'], 18, 7], ['x on is the', 'is is ink']), ('regression: repeated rebalancing', [['is', 'serif', 'on', 'a', 'type'], 14, 7], ['is serif', 'on a type']), ('regression: repeated rebalancing', [['grid', 'the', 'the', 'kerning', 'kerning', 'x', 'a'], 17, 7], ['grid the the', 'kerning', 'kerning x a']), ('regression: repeated rebalancing', [['is', 'baseline', 'measure', 'the', 'baseline', 'a', 'the', 'x'], 15, 8], ['is baseline', 'measure the', 'baseline', 'a the 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', [['serif', 'measure', 'type'], 11, 5], ['serif', 'measure', 'type']), ('control layout', [['of', 'at', 'x', 'on', 'measure', 'type', 'a', 'measure'], 19, 4], ['of at x on measure', 'type a measure'])], [('regression: repeated rebalancing', [['serif', 'the', 'is', 'is', 'of', 'grid', 'at', 'is', 'a'], 10, 7], ['serif the', 'is is of', 'grid', 'at is a']), ('regression: repeated rebalancing', [['measure', 'is', 'on', 'grid', 'is', 'measure', 'ink', 'ink', 'serif', 'x', 'on'], 13, 9], ['measure is on', 'grid is', 'measure ink', 'ink', 'serif x on']), ('regression: repeated rebalancing', [['ink', 'the', 'of', 'of', 'of', 'on', 'at'], 10, 9], ['ink the of', 'of', 'of on at']), ('regression: repeated rebalancing', [['measure', 'type', 'is', 'serif', 'at', 'the'], 13, 8], ['measure type', 'is', 'serif 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', [['serif', 'is', 'a', 'x', 'kerning', 'kerning'], 7, 4], ['serif', 'is a x', 'kerning', 'kerning']), ('control layout', [['grid', 'kerning', 'is', 'serif', 'ink'], 17, 7], ['grid kerning is', 'serif ink'])], [('regression: repeated rebalancing', [['the', 'on', 'a', 'a', 'of'], 10, 8], ['the', 'on a a of']), ('regression: repeated rebalancing', [['grid', 'the', 'the', 'kerning', 'kerning', 'x', 'a'], 17, 7], ['grid the the', 'kerning', 'kerning x a']), ('regression: repeated rebalancing', [['the', 'measure', 'a', 'x'], 14, 6], ['the', 'measure a x']), ('regression: repeated rebalancing', [['ink', 'the', 'of', 'of', 'of', 'on', 'at'], 10, 9], ['ink the of', 'of', 'of on at']), ('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', [['on', 'of', 'at', 'ink', 'measure'], 12, 5], ['on of at ink', 'measure']), ('control layout', [['kerning', 'is', 'type', 'of', 'type', 'of', 'baseline', 'a', 'baseline'], 14, 8], ['kerning is', 'type of type', 'of baseline a', 'baseline'])], [('regression: repeated rebalancing', [['the', 'on', 'a', 'a', 'of'], 10, 8], ['the', 'on a a of']), ('regression: repeated rebalancing', [['the', 'the', 'is', 'ink', 'serif', 'on', 'on', 'ink'], 14, 8], ['the the is ink', 'serif', 'on on ink']), ('regression: repeated rebalancing', [['is', 'baseline', 'measure', 'the', 'baseline', 'a', 'the', 'x'], 15, 8], ['is baseline', 'measure the', 'baseline', 'a the x']), ('regression: repeated rebalancing', [['grid', 'the', 'the', 'kerning', 'kerning', 'x', 'a'], 17, 7], ['grid the the', 'kerning', 'kerning x 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', [['type', 'ink', 'the', 'ink', 'the', 'of', 'kerning', 'a', 'of'], 13, 9], ['type ink the', 'ink the of', 'kerning a of']), ('control layout', [['x', 'baseline', 'grid', 'is', 'baseline', 'on', 'on', 'at', 'on', 'grid', 'grid'], 20, 3], ['x baseline grid is', 'baseline on on at on', 'grid grid'])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: repeated rebalancing | ['the the is ink', 'serif on', 'on ink'] | ['the the is ink', 'serif', 'on on ink'] | Failed |
| regression: repeated rebalancing | ['the measure', 'a x'] | ['the', 'measure a x'] | Failed |
| regression: repeated rebalancing | ['measure is on', 'grid is', 'measure ink', 'ink serif', 'x on'] | ['measure is on', 'grid is', 'measure ink', 'ink', 'serif x on'] | Failed |
| regression: repeated rebalancing | ['ink the of', 'of of', 'on at'] | ['ink the of', 'of', 'of on at'] | 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 | ['on ink', 'type a'] | ['on ink', 'type a'] | 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 / 3bfed405395df87b0fb8183ad7165a19b84e601e2bd3c03b9f237b6940c55246
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: repeated rebalancing', [['the', 'the', 'is', 'ink', 'serif', 'on', 'on', 'ink'], 14, 8], ['the the is ink', 'serif', 'on on ink']), ('regression: repeated rebalancing', [['the', 'measure', 'a', 'x'], 14, 6], ['the', 'measure a x']), ('regression: repeated rebalancing', [['measure', 'is', 'on', 'grid', 'is', 'measure', 'ink', 'ink', 'serif', 'x', 'on'], 13, 9], ['measure is on', 'grid is', 'measure ink', 'ink', 'serif x on']), ('regression: repeated rebalancing', [['ink', 'the', 'of', 'of', 'of', 'on', 'at'], 10, 9], ['ink the of', 'of', 'of on at']), ('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', [['on', 'ink', 'type', 'a'], 12, 4], ['on ink', 'type a']), ('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: repeated rebalancing', [['x', 'on', 'is', 'the', 'is', 'is', 'ink'], 18, 7], ['x on is the', 'is is ink']), ('regression: repeated rebalancing', [['is', 'serif', 'on', 'a', 'type'], 14, 7], ['is serif', 'on a type']), ('regression: repeated rebalancing', [['grid', 'the', 'the', 'kerning', 'kerning', 'x', 'a'], 17, 7], ['grid the the', 'kerning', 'kerning x a']), ('regression: repeated rebalancing', [['is', 'baseline', 'measure', 'the', 'baseline', 'a', 'the', 'x'], 15, 8], ['is baseline', 'measure the', 'baseline', 'a the 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', [['serif', 'measure', 'type'], 11, 5], ['serif', 'measure', 'type']), ('control layout', [['of', 'at', 'x', 'on', 'measure', 'type', 'a', 'measure'], 19, 4], ['of at x on measure', 'type a measure'])], [('regression: repeated rebalancing', [['serif', 'the', 'is', 'is', 'of', 'grid', 'at', 'is', 'a'], 10, 7], ['serif the', 'is is of', 'grid', 'at is a']), ('regression: repeated rebalancing', [['measure', 'is', 'on', 'grid', 'is', 'measure', 'ink', 'ink', 'serif', 'x', 'on'], 13, 9], ['measure is on', 'grid is', 'measure ink', 'ink', 'serif x on']), ('regression: repeated rebalancing', [['ink', 'the', 'of', 'of', 'of', 'on', 'at'], 10, 9], ['ink the of', 'of', 'of on at']), ('regression: repeated rebalancing', [['measure', 'type', 'is', 'serif', 'at', 'the'], 13, 8], ['measure type', 'is', 'serif 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', [['serif', 'is', 'a', 'x', 'kerning', 'kerning'], 7, 4], ['serif', 'is a x', 'kerning', 'kerning']), ('control layout', [['grid', 'kerning', 'is', 'serif', 'ink'], 17, 7], ['grid kerning is', 'serif ink'])], [('regression: repeated rebalancing', [['the', 'on', 'a', 'a', 'of'], 10, 8], ['the', 'on a a of']), ('regression: repeated rebalancing', [['grid', 'the', 'the', 'kerning', 'kerning', 'x', 'a'], 17, 7], ['grid the the', 'kerning', 'kerning x a']), ('regression: repeated rebalancing', [['the', 'measure', 'a', 'x'], 14, 6], ['the', 'measure a x']), ('regression: repeated rebalancing', [['ink', 'the', 'of', 'of', 'of', 'on', 'at'], 10, 9], ['ink the of', 'of', 'of on at']), ('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', [['on', 'of', 'at', 'ink', 'measure'], 12, 5], ['on of at ink', 'measure']), ('control layout', [['kerning', 'is', 'type', 'of', 'type', 'of', 'baseline', 'a', 'baseline'], 14, 8], ['kerning is', 'type of type', 'of baseline a', 'baseline'])], [('regression: repeated rebalancing', [['the', 'on', 'a', 'a', 'of'], 10, 8], ['the', 'on a a of']), ('regression: repeated rebalancing', [['the', 'the', 'is', 'ink', 'serif', 'on', 'on', 'ink'], 14, 8], ['the the is ink', 'serif', 'on on ink']), ('regression: repeated rebalancing', [['is', 'baseline', 'measure', 'the', 'baseline', 'a', 'the', 'x'], 15, 8], ['is baseline', 'measure the', 'baseline', 'a the x']), ('regression: repeated rebalancing', [['grid', 'the', 'the', 'kerning', 'kerning', 'x', 'a'], 17, 7], ['grid the the', 'kerning', 'kerning x 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', [['type', 'ink', 'the', 'ink', 'the', 'of', 'kerning', 'a', 'of'], 13, 9], ['type ink the', 'ink the of', 'kerning a of']), ('control layout', [['x', 'baseline', 'grid', 'is', 'baseline', 'on', 'on', 'at', 'on', 'grid', 'grid'], 20, 3], ['x baseline grid is', 'baseline on on at on', 'grid grid'])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: repeated rebalancing | ['the the is ink', 'serif', 'on on ink'] | ['the the is ink', 'serif', 'on on ink'] | Passed |
| regression: repeated rebalancing | ['the', 'measure a x'] | ['the', 'measure a x'] | Passed |
| regression: repeated rebalancing | ['measure is on', 'grid is', 'measure ink', 'ink', 'serif x on'] | ['measure is on', 'grid is', 'measure ink', 'ink', 'serif x on'] | Passed |
| regression: repeated rebalancing | ['ink the of', 'of', 'of on at'] | ['ink the of', 'of', 'of on at'] | 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 | ['on ink', 'type a'] | ['on ink', 'type a'] | 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 / 1c223ca8eaa09ad4095cb5333edbbe63151b72f6a203285c0ab94c7f35cc5423
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.962282+00:00.
Case digest / 611e15401ce3408340b50bc6fa9359ae8b385000cf1497cd639be0e365df459e