FA-79871 / Typography line breaking / Open access
Glue-set badness rating: decent fitness upper bound · case 01
Lines stretched by exactly half their stretch are classed loose.
ROOT CAUSE
The decent class uses a strict < 1/2 bound, excluding the boundary ratio.
VERIFIED REPAIR
Keep ratio 1/2 inside the decent class (r <= 1/2).
Unsuccessful approach: Widening decent to r <= 1 removes the loose class entirely.
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 = [[('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('regression: decent fitness upper bound', [120, 12, 3, 126, 1000], ['ok', 13, 'decent']), ('partial-repair probe', [94, 20, 0, 108, 100], ['ok', 34, 'loose']), ('partial-repair probe', [67, 6, 10, 71, 100], ['ok', 30, 'loose']), ('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', [63, 8, 8, 61, 200], ['ok', 2, 'decent']), ('control layout', [64, 4, 11, 65, 500], ['ok', 2, 'decent'])], [('regression: decent fitness upper bound', [101, 10, 11, 106, 150], ['ok', 13, 'decent']), ('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('partial-repair probe', [80, 20, 1, 99, 150], ['ok', 86, 'loose']), ('partial-repair probe', [117, 10, 10, 127, 150], ['ok', 100, 'loose']), ('exact natural width', [100, 10, 5, 100, 200], ['ok', 0, 'decent']), ('one unit past total shrink', [100, 10, 5, 94, 200], ['overfull', 1000000, 'tight']), ('control layout', [92, 3, 7, 100, 500], ['underfull', 1896, 'very_loose']), ('control layout', [86, 3, 10, 109, 100], ['underfull', 10000, 'very_loose'])], [('regression: decent fitness upper bound', [60, 2, 9, 61, 1000], ['ok', 13, 'decent']), ('regression: decent fitness upper bound', [105, 12, 8, 111, 100], ['ok', 13, 'decent']), ('partial-repair probe', [61, 12, 9, 70, 100], ['ok', 42, 'loose']), ('partial-repair probe', [82, 20, 4, 95, 500], ['ok', 27, 'loose']), ('very loose over tolerance', [100, 4, 0, 110, 200], ['underfull', 1563, 'very_loose']), ('negative half ratio is decent', [100, 10, 6, 97, 200], ['ok', 13, 'decent']), ('control layout', [98, 2, 2, 102, 100], ['underfull', 800, 'very_loose']), ('control layout', [73, 3, 0, 67, 200], ['overfull', 1000000, 'tight'])], [('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('regression: decent fitness upper bound', [120, 12, 3, 126, 1000], ['ok', 13, 'decent']), ('partial-repair probe', [112, 8, 6, 120, 500], ['ok', 100, 'loose']), ('partial-repair probe', [71, 10, 5, 77, 200], ['ok', 22, 'loose']), ('negative half ratio is decent', [100, 10, 6, 97, 200], ['ok', 13, 'decent']), ('very loose over tolerance', [100, 4, 0, 110, 200], ['underfull', 1563, 'very_loose']), ('control layout', [90, 0, 6, 102, 1000], ['underfull', 10000, 'very_loose']), ('control layout', [65, 10, 12, 82, 150], ['underfull', 491, 'very_loose'])], [('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('regression: decent fitness upper bound', [105, 12, 8, 111, 100], ['ok', 13, 'decent']), ('partial-repair probe', [114, 8, 8, 119, 150], ['ok', 24, 'loose']), ('partial-repair probe', [82, 20, 4, 95, 500], ['ok', 27, 'loose']), ('badness cap at 10000', [100, 2, 0, 150, 200], ['underfull', 10000, 'very_loose']), ('very loose over tolerance', [100, 4, 0, 110, 200], ['underfull', 1563, 'very_loose']), ('control layout', [104, 8, 7, 113, 500], ['ok', 142, 'very_loose']), ('control layout', [90, 12, 4, 95, 150], ['ok', 7, 'decent'])]]
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 |
|---|---|---|---|
| half stretch ratio rounds 12.5 up | ['ok', 13, 'loose'] | ['ok', 13, 'decent'] | Failed |
| regression: decent fitness upper bound | ['ok', 13, 'loose'] | ['ok', 13, 'decent'] | Failed |
| partial-repair probe | ['ok', 34, 'loose'] | ['ok', 34, 'loose'] | Passed |
| partial-repair probe | ['ok', 30, 'loose'] | ['ok', 30, 'loose'] | Passed |
| rigid line with slack | ['underfull', 10000, 'very_loose'] | ['underfull', 10000, 'very_loose'] | Passed |
| very loose over tolerance | ['underfull', 1563, 'very_loose'] | ['underfull', 1563, 'very_loose'] | Passed |
| control layout | ['ok', 2, 'decent'] | ['ok', 2, 'decent'] | Passed |
| control layout | ['ok', 2, 'decent'] | ['ok', 2, 'decent'] | Passed |
SHA-256 / 05bbcaac335c33656a5ee735ac86e3722cc88f90a154b985d81f9f3b3c1cc5b3
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 > 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 <= 1:
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 = [[('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('regression: decent fitness upper bound', [120, 12, 3, 126, 1000], ['ok', 13, 'decent']), ('partial-repair probe', [94, 20, 0, 108, 100], ['ok', 34, 'loose']), ('partial-repair probe', [67, 6, 10, 71, 100], ['ok', 30, 'loose']), ('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', [63, 8, 8, 61, 200], ['ok', 2, 'decent']), ('control layout', [64, 4, 11, 65, 500], ['ok', 2, 'decent'])], [('regression: decent fitness upper bound', [101, 10, 11, 106, 150], ['ok', 13, 'decent']), ('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('partial-repair probe', [80, 20, 1, 99, 150], ['ok', 86, 'loose']), ('partial-repair probe', [117, 10, 10, 127, 150], ['ok', 100, 'loose']), ('exact natural width', [100, 10, 5, 100, 200], ['ok', 0, 'decent']), ('one unit past total shrink', [100, 10, 5, 94, 200], ['overfull', 1000000, 'tight']), ('control layout', [92, 3, 7, 100, 500], ['underfull', 1896, 'very_loose']), ('control layout', [86, 3, 10, 109, 100], ['underfull', 10000, 'very_loose'])], [('regression: decent fitness upper bound', [60, 2, 9, 61, 1000], ['ok', 13, 'decent']), ('regression: decent fitness upper bound', [105, 12, 8, 111, 100], ['ok', 13, 'decent']), ('partial-repair probe', [61, 12, 9, 70, 100], ['ok', 42, 'loose']), ('partial-repair probe', [82, 20, 4, 95, 500], ['ok', 27, 'loose']), ('very loose over tolerance', [100, 4, 0, 110, 200], ['underfull', 1563, 'very_loose']), ('negative half ratio is decent', [100, 10, 6, 97, 200], ['ok', 13, 'decent']), ('control layout', [98, 2, 2, 102, 100], ['underfull', 800, 'very_loose']), ('control layout', [73, 3, 0, 67, 200], ['overfull', 1000000, 'tight'])], [('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('regression: decent fitness upper bound', [120, 12, 3, 126, 1000], ['ok', 13, 'decent']), ('partial-repair probe', [112, 8, 6, 120, 500], ['ok', 100, 'loose']), ('partial-repair probe', [71, 10, 5, 77, 200], ['ok', 22, 'loose']), ('negative half ratio is decent', [100, 10, 6, 97, 200], ['ok', 13, 'decent']), ('very loose over tolerance', [100, 4, 0, 110, 200], ['underfull', 1563, 'very_loose']), ('control layout', [90, 0, 6, 102, 1000], ['underfull', 10000, 'very_loose']), ('control layout', [65, 10, 12, 82, 150], ['underfull', 491, 'very_loose'])], [('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('regression: decent fitness upper bound', [105, 12, 8, 111, 100], ['ok', 13, 'decent']), ('partial-repair probe', [114, 8, 8, 119, 150], ['ok', 24, 'loose']), ('partial-repair probe', [82, 20, 4, 95, 500], ['ok', 27, 'loose']), ('badness cap at 10000', [100, 2, 0, 150, 200], ['underfull', 10000, 'very_loose']), ('very loose over tolerance', [100, 4, 0, 110, 200], ['underfull', 1563, 'very_loose']), ('control layout', [104, 8, 7, 113, 500], ['ok', 142, 'very_loose']), ('control layout', [90, 12, 4, 95, 150], ['ok', 7, 'decent'])]]
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 |
|---|---|---|---|
| half stretch ratio rounds 12.5 up | ['ok', 13, 'decent'] | ['ok', 13, 'decent'] | Passed |
| regression: decent fitness upper bound | ['ok', 13, 'decent'] | ['ok', 13, 'decent'] | Passed |
| partial-repair probe | ['ok', 34, 'decent'] | ['ok', 34, 'loose'] | Failed |
| partial-repair probe | ['ok', 30, 'decent'] | ['ok', 30, 'loose'] | Failed |
| rigid line with slack | ['underfull', 10000, 'very_loose'] | ['underfull', 10000, 'very_loose'] | Passed |
| very loose over tolerance | ['underfull', 1563, 'very_loose'] | ['underfull', 1563, 'very_loose'] | Passed |
| control layout | ['ok', 2, 'decent'] | ['ok', 2, 'decent'] | Passed |
| control layout | ['ok', 2, 'decent'] | ['ok', 2, 'decent'] | Passed |
SHA-256 / ec213d1d30f6af376eddf5847e18a90b2eb57246a3af7d6e5deec5921b45aab3
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 = [[('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('regression: decent fitness upper bound', [120, 12, 3, 126, 1000], ['ok', 13, 'decent']), ('partial-repair probe', [94, 20, 0, 108, 100], ['ok', 34, 'loose']), ('partial-repair probe', [67, 6, 10, 71, 100], ['ok', 30, 'loose']), ('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', [63, 8, 8, 61, 200], ['ok', 2, 'decent']), ('control layout', [64, 4, 11, 65, 500], ['ok', 2, 'decent'])], [('regression: decent fitness upper bound', [101, 10, 11, 106, 150], ['ok', 13, 'decent']), ('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('partial-repair probe', [80, 20, 1, 99, 150], ['ok', 86, 'loose']), ('partial-repair probe', [117, 10, 10, 127, 150], ['ok', 100, 'loose']), ('exact natural width', [100, 10, 5, 100, 200], ['ok', 0, 'decent']), ('one unit past total shrink', [100, 10, 5, 94, 200], ['overfull', 1000000, 'tight']), ('control layout', [92, 3, 7, 100, 500], ['underfull', 1896, 'very_loose']), ('control layout', [86, 3, 10, 109, 100], ['underfull', 10000, 'very_loose'])], [('regression: decent fitness upper bound', [60, 2, 9, 61, 1000], ['ok', 13, 'decent']), ('regression: decent fitness upper bound', [105, 12, 8, 111, 100], ['ok', 13, 'decent']), ('partial-repair probe', [61, 12, 9, 70, 100], ['ok', 42, 'loose']), ('partial-repair probe', [82, 20, 4, 95, 500], ['ok', 27, 'loose']), ('very loose over tolerance', [100, 4, 0, 110, 200], ['underfull', 1563, 'very_loose']), ('negative half ratio is decent', [100, 10, 6, 97, 200], ['ok', 13, 'decent']), ('control layout', [98, 2, 2, 102, 100], ['underfull', 800, 'very_loose']), ('control layout', [73, 3, 0, 67, 200], ['overfull', 1000000, 'tight'])], [('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('regression: decent fitness upper bound', [120, 12, 3, 126, 1000], ['ok', 13, 'decent']), ('partial-repair probe', [112, 8, 6, 120, 500], ['ok', 100, 'loose']), ('partial-repair probe', [71, 10, 5, 77, 200], ['ok', 22, 'loose']), ('negative half ratio is decent', [100, 10, 6, 97, 200], ['ok', 13, 'decent']), ('very loose over tolerance', [100, 4, 0, 110, 200], ['underfull', 1563, 'very_loose']), ('control layout', [90, 0, 6, 102, 1000], ['underfull', 10000, 'very_loose']), ('control layout', [65, 10, 12, 82, 150], ['underfull', 491, 'very_loose'])], [('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('regression: decent fitness upper bound', [105, 12, 8, 111, 100], ['ok', 13, 'decent']), ('partial-repair probe', [114, 8, 8, 119, 150], ['ok', 24, 'loose']), ('partial-repair probe', [82, 20, 4, 95, 500], ['ok', 27, 'loose']), ('badness cap at 10000', [100, 2, 0, 150, 200], ['underfull', 10000, 'very_loose']), ('very loose over tolerance', [100, 4, 0, 110, 200], ['underfull', 1563, 'very_loose']), ('control layout', [104, 8, 7, 113, 500], ['ok', 142, 'very_loose']), ('control layout', [90, 12, 4, 95, 150], ['ok', 7, 'decent'])]]
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 |
|---|---|---|---|
| half stretch ratio rounds 12.5 up | ['ok', 13, 'decent'] | ['ok', 13, 'decent'] | Passed |
| regression: decent fitness upper bound | ['ok', 13, 'decent'] | ['ok', 13, 'decent'] | Passed |
| partial-repair probe | ['ok', 34, 'loose'] | ['ok', 34, 'loose'] | Passed |
| partial-repair probe | ['ok', 30, 'loose'] | ['ok', 30, 'loose'] | Passed |
| rigid line with slack | ['underfull', 10000, 'very_loose'] | ['underfull', 10000, 'very_loose'] | Passed |
| very loose over tolerance | ['underfull', 1563, 'very_loose'] | ['underfull', 1563, 'very_loose'] | Passed |
| control layout | ['ok', 2, 'decent'] | ['ok', 2, 'decent'] | Passed |
| control layout | ['ok', 2, 'decent'] | ['ok', 2, 'decent'] | Passed |
SHA-256 / cf986c0def1e6f9afe71f6d660e39b81430cb7c29e825e434454c2020a74a311
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.474331+00:00.
Case digest / 668d0192c58f3fe039f8c4ee69f95af5dc3b6869e8e5979a5f9d07e153159331