FA-79841 / Typography line breaking / Open access
Glue-set badness rating: shrink exhaustion limit · case 01
A line compressed by exactly its total shrink is reported overfull.
ROOT CAUSE
The overfull test uses >= against the total shrink, so the legal limit itself is rejected.
VERIFIED REPAIR
Only declare overfull when the needed compression strictly exceeds the available shrink.
Unsuccessful approach: Comparing the compression with the stretch total instead of the shrink total still misclassifies lines.
Case contract
Input [natural, stretch, shrink, width, tolerance] (ints). shortfall=width-natural. Positive shortfall with zero stretch is underfull 10000 very_loose; shrinking past total shrink is overfull 1000000 tight. r=shortfall/stretch (or /shrink when negative); badness=min(10000, floor(100*|r|^3+1/2)); fitness tight r<-1/2, decent r<=1/2, loose r<=1, else very_loose; status ok iff badness<=tolerance. Return [status, badness, fitness].
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
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
natural, stretch, shrink, width, tolerance = x
shortfall = width - natural
if shortfall > 0:
if stretch == 0:
return ['underfull', 10000, 'very_loose']
r = Fraction(shortfall, stretch)
elif shortfall < 0:
if -shortfall >= shrink:
return ['overfull', 1000000, 'tight']
r = Fraction(shortfall, shrink)
else:
r = Fraction(0)
badness = min(10000, math.floor(100 * abs(r) ** 3 + Fraction(1, 2)))
if r < Fraction(-1, 2):
fitness = 'tight'
elif r <= Fraction(1, 2):
fitness = 'decent'
elif r <= 1:
fitness = 'loose'
else:
fitness = 'very_loose'
status = 'ok' if badness <= tolerance else 'underfull'
return [status, badness, fitness]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('full shrink is still acceptable', [100, 10, 5, 95, 200], ['ok', 100, 'tight']), ('regression: shrink exhaustion limit', [92, 6, 12, 80, 100], ['ok', 100, 'tight']), ('partial-repair probe', [82, 3, 10, 77, 100], ['ok', 13, 'decent']), ('partial-repair probe', [108, 0, 6, 105, 1000], ['ok', 13, 'decent']), ('very loose over tolerance', [100, 4, 0, 110, 200], ['underfull', 1563, 'very_loose']), ('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('control layout', [107, 16, 10, 115, 150], ['ok', 13, 'decent']), ('control layout', [66, 4, 5, 60, 200], ['overfull', 1000000, 'tight'])], [('regression: shrink exhaustion limit', [108, 1, 10, 98, 1000], ['ok', 100, 'tight']), ('regression: shrink exhaustion limit', [106, 16, 11, 95, 200], ['ok', 100, 'tight']), ('regression: shrink exhaustion limit', [85, 3, 7, 78, 150], ['ok', 100, 'tight']), ('partial-repair probe', [74, 16, 4, 67, 500], ['overfull', 1000000, 'tight']), ('rigid line with slack', [100, 0, 5, 110, 200], ['underfull', 10000, 'very_loose']), ('very loose over tolerance', [100, 4, 0, 110, 200], ['underfull', 1563, 'very_loose']), ('control layout', [116, 0, 11, 126, 100], ['underfull', 10000, 'very_loose']), ('control layout', [104, 0, 1, 124, 100], ['underfull', 10000, 'very_loose'])], [('regression: shrink exhaustion limit', [92, 6, 12, 80, 100], ['ok', 100, 'tight']), ('regression: shrink exhaustion limit', [92, 10, 6, 86, 500], ['ok', 100, 'tight']), ('partial-repair probe', [76, 1, 11, 74, 1000], ['ok', 1, 'decent']), ('partial-repair probe', [118, 20, 4, 106, 1000], ['overfull', 1000000, 'tight']), ('one unit past total shrink', [100, 10, 5, 94, 200], ['overfull', 1000000, 'tight']), ('rigid line with slack', [100, 0, 5, 110, 200], ['underfull', 10000, 'very_loose']), ('control layout', [64, 20, 12, 59, 100], ['ok', 7, 'decent']), ('control layout', [74, 6, 6, 67, 100], ['overfull', 1000000, 'tight'])], [('regression: shrink exhaustion limit', [90, 12, 2, 88, 150], ['ok', 100, 'tight']), ('regression: shrink exhaustion limit', [62, 4, 4, 58, 200], ['ok', 100, 'tight']), ('partial-repair probe', [61, 8, 1, 56, 100], ['overfull', 1000000, 'tight']), ('partial-repair probe', [86, 10, 5, 77, 500], ['overfull', 1000000, 'tight']), ('negative half ratio is decent', [100, 10, 6, 97, 200], ['ok', 13, 'decent']), ('rigid line with slack', [100, 0, 5, 110, 200], ['underfull', 10000, 'very_loose']), ('control layout', [63, 6, 7, 53, 150], ['overfull', 1000000, 'tight']), ('control layout', [73, 0, 12, 81, 500], ['underfull', 10000, 'very_loose'])], [('regression: shrink exhaustion limit', [92, 10, 6, 86, 500], ['ok', 100, 'tight']), ('regression: shrink exhaustion limit', [106, 16, 11, 95, 200], ['ok', 100, 'tight']), ('partial-repair probe', [104, 8, 3, 98, 500], ['overfull', 1000000, 'tight']), ('regression: shrink exhaustion limit', [108, 1, 10, 98, 1000], ['ok', 100, 'tight']), ('badness cap at 10000', [100, 2, 0, 150, 200], ['underfull', 10000, 'very_loose']), ('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('control layout', [80, 20, 11, 82, 150], ['ok', 0, 'decent']), ('control layout', [111, 8, 4, 130, 150], ['underfull', 1340, 'very_loose'])]]
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 |
|---|---|---|---|
| full shrink is still acceptable | ['overfull', 1000000, 'tight'] | ['ok', 100, 'tight'] | Failed |
| regression: shrink exhaustion limit | ['overfull', 1000000, 'tight'] | ['ok', 100, 'tight'] | Failed |
| partial-repair probe | ['ok', 13, 'decent'] | ['ok', 13, 'decent'] | Passed |
| partial-repair probe | ['ok', 13, 'decent'] | ['ok', 13, 'decent'] | Passed |
| very loose over tolerance | ['underfull', 1563, 'very_loose'] | ['underfull', 1563, 'very_loose'] | Passed |
| half stretch ratio rounds 12.5 up | ['ok', 13, 'decent'] | ['ok', 13, 'decent'] | Passed |
| control layout | ['ok', 13, 'decent'] | ['ok', 13, 'decent'] | Passed |
| control layout | ['overfull', 1000000, 'tight'] | ['overfull', 1000000, 'tight'] | Passed |
SHA-256 / 24415e070290606541357a02e26c85c1ed420d278cf3f640f6250a027a4b4c2d
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
natural, stretch, shrink, width, tolerance = x
shortfall = width - natural
if shortfall > 0:
if stretch == 0:
return ['underfull', 10000, 'very_loose']
r = Fraction(shortfall, stretch)
elif shortfall < 0:
if -shortfall > stretch:
return ['overfull', 1000000, 'tight']
r = Fraction(shortfall, shrink)
else:
r = Fraction(0)
badness = min(10000, math.floor(100 * abs(r) ** 3 + Fraction(1, 2)))
if r < Fraction(-1, 2):
fitness = 'tight'
elif r <= Fraction(1, 2):
fitness = 'decent'
elif r <= 1:
fitness = 'loose'
else:
fitness = 'very_loose'
status = 'ok' if badness <= tolerance else 'underfull'
return [status, badness, fitness]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('full shrink is still acceptable', [100, 10, 5, 95, 200], ['ok', 100, 'tight']), ('regression: shrink exhaustion limit', [92, 6, 12, 80, 100], ['ok', 100, 'tight']), ('partial-repair probe', [82, 3, 10, 77, 100], ['ok', 13, 'decent']), ('partial-repair probe', [108, 0, 6, 105, 1000], ['ok', 13, 'decent']), ('very loose over tolerance', [100, 4, 0, 110, 200], ['underfull', 1563, 'very_loose']), ('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('control layout', [107, 16, 10, 115, 150], ['ok', 13, 'decent']), ('control layout', [66, 4, 5, 60, 200], ['overfull', 1000000, 'tight'])], [('regression: shrink exhaustion limit', [108, 1, 10, 98, 1000], ['ok', 100, 'tight']), ('regression: shrink exhaustion limit', [106, 16, 11, 95, 200], ['ok', 100, 'tight']), ('regression: shrink exhaustion limit', [85, 3, 7, 78, 150], ['ok', 100, 'tight']), ('partial-repair probe', [74, 16, 4, 67, 500], ['overfull', 1000000, 'tight']), ('rigid line with slack', [100, 0, 5, 110, 200], ['underfull', 10000, 'very_loose']), ('very loose over tolerance', [100, 4, 0, 110, 200], ['underfull', 1563, 'very_loose']), ('control layout', [116, 0, 11, 126, 100], ['underfull', 10000, 'very_loose']), ('control layout', [104, 0, 1, 124, 100], ['underfull', 10000, 'very_loose'])], [('regression: shrink exhaustion limit', [92, 6, 12, 80, 100], ['ok', 100, 'tight']), ('regression: shrink exhaustion limit', [92, 10, 6, 86, 500], ['ok', 100, 'tight']), ('partial-repair probe', [76, 1, 11, 74, 1000], ['ok', 1, 'decent']), ('partial-repair probe', [118, 20, 4, 106, 1000], ['overfull', 1000000, 'tight']), ('one unit past total shrink', [100, 10, 5, 94, 200], ['overfull', 1000000, 'tight']), ('rigid line with slack', [100, 0, 5, 110, 200], ['underfull', 10000, 'very_loose']), ('control layout', [64, 20, 12, 59, 100], ['ok', 7, 'decent']), ('control layout', [74, 6, 6, 67, 100], ['overfull', 1000000, 'tight'])], [('regression: shrink exhaustion limit', [90, 12, 2, 88, 150], ['ok', 100, 'tight']), ('regression: shrink exhaustion limit', [62, 4, 4, 58, 200], ['ok', 100, 'tight']), ('partial-repair probe', [61, 8, 1, 56, 100], ['overfull', 1000000, 'tight']), ('partial-repair probe', [86, 10, 5, 77, 500], ['overfull', 1000000, 'tight']), ('negative half ratio is decent', [100, 10, 6, 97, 200], ['ok', 13, 'decent']), ('rigid line with slack', [100, 0, 5, 110, 200], ['underfull', 10000, 'very_loose']), ('control layout', [63, 6, 7, 53, 150], ['overfull', 1000000, 'tight']), ('control layout', [73, 0, 12, 81, 500], ['underfull', 10000, 'very_loose'])], [('regression: shrink exhaustion limit', [92, 10, 6, 86, 500], ['ok', 100, 'tight']), ('regression: shrink exhaustion limit', [106, 16, 11, 95, 200], ['ok', 100, 'tight']), ('partial-repair probe', [104, 8, 3, 98, 500], ['overfull', 1000000, 'tight']), ('regression: shrink exhaustion limit', [108, 1, 10, 98, 1000], ['ok', 100, 'tight']), ('badness cap at 10000', [100, 2, 0, 150, 200], ['underfull', 10000, 'very_loose']), ('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('control layout', [80, 20, 11, 82, 150], ['ok', 0, 'decent']), ('control layout', [111, 8, 4, 130, 150], ['underfull', 1340, 'very_loose'])]]
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 |
|---|---|---|---|
| full shrink is still acceptable | ['ok', 100, 'tight'] | ['ok', 100, 'tight'] | Passed |
| regression: shrink exhaustion limit | ['overfull', 1000000, 'tight'] | ['ok', 100, 'tight'] | Failed |
| partial-repair probe | ['overfull', 1000000, 'tight'] | ['ok', 13, 'decent'] | Failed |
| partial-repair probe | ['overfull', 1000000, 'tight'] | ['ok', 13, 'decent'] | Failed |
| very loose over tolerance | ['underfull', 1563, 'very_loose'] | ['underfull', 1563, 'very_loose'] | Passed |
| half stretch ratio rounds 12.5 up | ['ok', 13, 'decent'] | ['ok', 13, 'decent'] | Passed |
| control layout | ['ok', 13, 'decent'] | ['ok', 13, 'decent'] | Passed |
| control layout | ['overfull', 1000000, 'tight'] | ['overfull', 1000000, 'tight'] | Passed |
SHA-256 / b7b4ae5594cc2ff37c86a39989ad7c5f0d9625f7ec1d20a72cd13a1f12ab0219
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
natural, stretch, shrink, width, tolerance = x
shortfall = width - natural
if shortfall > 0:
if stretch == 0:
return ['underfull', 10000, 'very_loose']
r = Fraction(shortfall, stretch)
elif shortfall < 0:
if -shortfall > shrink:
return ['overfull', 1000000, 'tight']
r = Fraction(shortfall, shrink)
else:
r = Fraction(0)
badness = min(10000, math.floor(100 * abs(r) ** 3 + Fraction(1, 2)))
if r < Fraction(-1, 2):
fitness = 'tight'
elif r <= Fraction(1, 2):
fitness = 'decent'
elif r <= 1:
fitness = 'loose'
else:
fitness = 'very_loose'
status = 'ok' if badness <= tolerance else 'underfull'
return [status, badness, fitness]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('full shrink is still acceptable', [100, 10, 5, 95, 200], ['ok', 100, 'tight']), ('regression: shrink exhaustion limit', [92, 6, 12, 80, 100], ['ok', 100, 'tight']), ('partial-repair probe', [82, 3, 10, 77, 100], ['ok', 13, 'decent']), ('partial-repair probe', [108, 0, 6, 105, 1000], ['ok', 13, 'decent']), ('very loose over tolerance', [100, 4, 0, 110, 200], ['underfull', 1563, 'very_loose']), ('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('control layout', [107, 16, 10, 115, 150], ['ok', 13, 'decent']), ('control layout', [66, 4, 5, 60, 200], ['overfull', 1000000, 'tight'])], [('regression: shrink exhaustion limit', [108, 1, 10, 98, 1000], ['ok', 100, 'tight']), ('regression: shrink exhaustion limit', [106, 16, 11, 95, 200], ['ok', 100, 'tight']), ('regression: shrink exhaustion limit', [85, 3, 7, 78, 150], ['ok', 100, 'tight']), ('partial-repair probe', [74, 16, 4, 67, 500], ['overfull', 1000000, 'tight']), ('rigid line with slack', [100, 0, 5, 110, 200], ['underfull', 10000, 'very_loose']), ('very loose over tolerance', [100, 4, 0, 110, 200], ['underfull', 1563, 'very_loose']), ('control layout', [116, 0, 11, 126, 100], ['underfull', 10000, 'very_loose']), ('control layout', [104, 0, 1, 124, 100], ['underfull', 10000, 'very_loose'])], [('regression: shrink exhaustion limit', [92, 6, 12, 80, 100], ['ok', 100, 'tight']), ('regression: shrink exhaustion limit', [92, 10, 6, 86, 500], ['ok', 100, 'tight']), ('partial-repair probe', [76, 1, 11, 74, 1000], ['ok', 1, 'decent']), ('partial-repair probe', [118, 20, 4, 106, 1000], ['overfull', 1000000, 'tight']), ('one unit past total shrink', [100, 10, 5, 94, 200], ['overfull', 1000000, 'tight']), ('rigid line with slack', [100, 0, 5, 110, 200], ['underfull', 10000, 'very_loose']), ('control layout', [64, 20, 12, 59, 100], ['ok', 7, 'decent']), ('control layout', [74, 6, 6, 67, 100], ['overfull', 1000000, 'tight'])], [('regression: shrink exhaustion limit', [90, 12, 2, 88, 150], ['ok', 100, 'tight']), ('regression: shrink exhaustion limit', [62, 4, 4, 58, 200], ['ok', 100, 'tight']), ('partial-repair probe', [61, 8, 1, 56, 100], ['overfull', 1000000, 'tight']), ('partial-repair probe', [86, 10, 5, 77, 500], ['overfull', 1000000, 'tight']), ('negative half ratio is decent', [100, 10, 6, 97, 200], ['ok', 13, 'decent']), ('rigid line with slack', [100, 0, 5, 110, 200], ['underfull', 10000, 'very_loose']), ('control layout', [63, 6, 7, 53, 150], ['overfull', 1000000, 'tight']), ('control layout', [73, 0, 12, 81, 500], ['underfull', 10000, 'very_loose'])], [('regression: shrink exhaustion limit', [92, 10, 6, 86, 500], ['ok', 100, 'tight']), ('regression: shrink exhaustion limit', [106, 16, 11, 95, 200], ['ok', 100, 'tight']), ('partial-repair probe', [104, 8, 3, 98, 500], ['overfull', 1000000, 'tight']), ('regression: shrink exhaustion limit', [108, 1, 10, 98, 1000], ['ok', 100, 'tight']), ('badness cap at 10000', [100, 2, 0, 150, 200], ['underfull', 10000, 'very_loose']), ('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('control layout', [80, 20, 11, 82, 150], ['ok', 0, 'decent']), ('control layout', [111, 8, 4, 130, 150], ['underfull', 1340, 'very_loose'])]]
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 |
|---|---|---|---|
| full shrink is still acceptable | ['ok', 100, 'tight'] | ['ok', 100, 'tight'] | Passed |
| regression: shrink exhaustion limit | ['ok', 100, 'tight'] | ['ok', 100, 'tight'] | Passed |
| partial-repair probe | ['ok', 13, 'decent'] | ['ok', 13, 'decent'] | Passed |
| partial-repair probe | ['ok', 13, 'decent'] | ['ok', 13, 'decent'] | Passed |
| very loose over tolerance | ['underfull', 1563, 'very_loose'] | ['underfull', 1563, 'very_loose'] | Passed |
| half stretch ratio rounds 12.5 up | ['ok', 13, 'decent'] | ['ok', 13, 'decent'] | Passed |
| control layout | ['ok', 13, 'decent'] | ['ok', 13, 'decent'] | Passed |
| control layout | ['overfull', 1000000, 'tight'] | ['overfull', 1000000, 'tight'] | Passed |
SHA-256 / 8358349adc1274771baafa11cd2cc6d83ba047d64cad0eaf7986601eb53ac9c5
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:48.250833+00:00.
Case digest / a1d55c2faf9b7d2e4001e01992473aa09e194988f963834dbc951b3df5b5df11