FA-79996 / Typography line breaking / Open access
Widow and orphan page breaking: exact fit acceptance · case 01
A paragraph that exactly fills the page is split needlessly.
ROOT CAUSE
The fit test uses rem < room so an exact fit takes the breaking path.
THE FAILURE
The fit test uses rem < room so an exact fit takes the breaking path.
Unsuccessful approach: Allowing rem <= room + 1 overfills the page.
Case contract
Input [paragraph line counts, page height, min orphan lines, min widow lines]. Lines flow onto pages. When a paragraph must break on a page that already holds lines, at least min widow lines must carry to the next page (move lines forward) and, if the paragraph starts on this page, at least min orphan lines must stay (else move it all). A paragraph that exactly fits stays. Constraints are waived on an empty page. Return lines per page.
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):
paras, H, orphan, widow = x
pages = []
used = 0
for p in paras:
rem = p
started = True
while rem > 0:
room = H - used
if rem < room:
used += rem
rem = 0
continue
a = room
if used > 0:
if rem - a < widow:
a = max(rem - widow, 0)
if started and a < orphan:
a = 0
used += a
rem -= a
if a > 0:
started = False
pages.append(used)
used = 0
if used > 0:
pages.append(used)
return pages
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('paragraph exactly fills page', [[2, 4, 3], 6, 2, 2], [6, 3]), ('regression: exact fit acceptance', [[7, 6, 7, 1], 4, 3, 1], [4, 3, 4, 2, 4, 4]), ('regression: exact fit acceptance', [[6, 3, 5, 3, 1, 6, 5, 7], 10, 2, 3], [9, 9, 8, 10]), ('regression: exact fit acceptance', [[2, 2, 5, 5, 7, 6, 4, 2], 8, 2, 3], [6, 8, 7, 6, 6]), ('long paragraph continuation', [[2, 14], 6, 2, 2], [6, 6, 4]), ('single widow pulled back', [[3, 4], 6, 2, 2], [5, 2]), ('control layout', [[6, 3, 4, 2], 11, 1, 2], [11, 4]), ('control layout', [[9, 6, 2, 9, 7], 12, 3, 2], [12, 12, 9])], [('regression: exact fit acceptance', [[2, 8, 2, 7], 12, 1, 1], [12, 7]), ('regression: exact fit acceptance', [[3, 5, 5, 1, 7, 7, 3, 1], 4, 3, 3], [3, 4, 1, 4, 2, 4, 3, 4, 3, 4]), ('partial-repair probe', [[6, 7, 1, 1], 12, 3, 2], [11, 4]), ('regression: exact fit acceptance', [[2, 2, 5, 5, 7, 6, 4, 2], 8, 2, 3], [6, 8, 7, 6, 6]), ('single widow pulled back', [[3, 4], 6, 2, 2], [5, 2]), ('orphan pushed forward', [[5, 3], 6, 2, 2], [5, 3]), ('control layout', [[5, 1, 2, 7, 6], 9, 1, 2], [9, 9, 3]), ('control layout', [[9, 7, 4], 11, 2, 1], [11, 9])], [('regression: exact fit acceptance', [[6, 9, 1, 5, 1, 8], 11, 2, 1], [11, 11, 8]), ('regression: exact fit acceptance', [[6, 6, 2, 6, 9, 7, 2, 8], 7, 1, 1], [7, 7, 7, 7, 7, 7, 4]), ('partial-repair probe', [[8, 8, 2, 6, 7, 7, 9], 7, 3, 3], [7, 6, 5, 6, 7, 7, 7, 2]), ('partial-repair probe', [[1, 9, 7, 4, 6, 9], 5, 2, 1], [5, 5, 5, 5, 5, 5, 5, 1]), ('single widow pulled back', [[3, 4], 6, 2, 2], [5, 2]), ('paragraph exactly fills page', [[2, 4, 3], 6, 2, 2], [6, 3]), ('control layout', [[5, 9, 5, 1], 12, 1, 1], [12, 8]), ('control layout', [[5, 2, 2, 6, 3, 3, 3, 3], 10, 2, 3], [9, 9, 9])], [('regression: exact fit acceptance', [[8, 1, 5, 2, 5, 5], 8, 1, 3], [8, 8, 7, 3]), ('regression: exact fit acceptance', [[4, 5, 5, 3, 2, 6], 9, 2, 2], [9, 8, 8]), ('partial-repair probe', [[3, 7, 3, 2], 6, 1, 2], [6, 5, 4]), ('regression: exact fit acceptance', [[7, 4, 1, 1, 2, 6], 6, 3, 2], [6, 6, 6, 3]), ('paragraph exactly fills page', [[2, 4, 3], 6, 2, 2], [6, 3]), ('long paragraph continuation', [[2, 14], 6, 2, 2], [6, 6, 4]), ('control layout', [[2, 5, 2], 11, 3, 1], [9]), ('control layout', [[3, 5, 4, 4, 2, 7], 10, 1, 1], [10, 10, 5])], [('regression: exact fit acceptance', [[1, 7, 1, 3, 3, 9, 6, 9], 6, 1, 3], [5, 4, 6, 6, 6, 6, 6]), ('regression: exact fit acceptance', [[9, 3, 5, 4], 6, 3, 3], [6, 6, 5, 4]), ('regression: exact fit acceptance', [[6, 4, 9, 9, 4], 5, 2, 3], [5, 5, 5, 4, 5, 4, 4]), ('partial-repair probe', [[6, 8, 9, 3, 2, 5, 9, 6], 4, 1, 3], [4, 4, 4, 4, 4, 3, 3, 4, 4, 4, 4, 4, 2]), ('long paragraph continuation', [[2, 14], 6, 2, 2], [6, 6, 4]), ('single widow pulled back', [[3, 4], 6, 2, 2], [5, 2]), ('control layout', [[7, 4, 6, 6], 4, 3, 1], [4, 3, 4, 4, 2, 4, 2]), ('control layout', [[8, 7, 8], 8, 1, 3], [8, 8, 7])]]
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 |
|---|---|---|---|
| paragraph exactly fills page | [4, 5] | [6, 3] | Failed |
| regression: exact fit acceptance | [4, 3, 4, 2, 4, 3, 1] | [4, 3, 4, 2, 4, 4] | Failed |
| regression: exact fit acceptance | [9, 9, 8, 7, 3] | [9, 9, 8, 10] | Failed |
| regression: exact fit acceptance | [6, 5, 7, 6, 7, 2] | [6, 8, 7, 6, 6] | Failed |
| long paragraph continuation | [6, 6, 4] | [6, 6, 4] | Passed |
| single widow pulled back | [5, 2] | [5, 2] | Passed |
| control layout | [11, 4] | [11, 4] | Passed |
| control layout | [12, 12, 9] | [12, 12, 9] | Passed |
SHA-256 / 085f83febfb35a3d269dbdc446a9b3ae83698b625c267099223b721da4dc16c6
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
paras, H, orphan, widow = x
pages = []
used = 0
for p in paras:
rem = p
started = True
while rem > 0:
room = H - used
if rem <= room + 1:
used += rem
rem = 0
continue
a = room
if used > 0:
if rem - a < widow:
a = max(rem - widow, 0)
if started and a < orphan:
a = 0
used += a
rem -= a
if a > 0:
started = False
pages.append(used)
used = 0
if used > 0:
pages.append(used)
return pages
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('paragraph exactly fills page', [[2, 4, 3], 6, 2, 2], [6, 3]), ('regression: exact fit acceptance', [[7, 6, 7, 1], 4, 3, 1], [4, 3, 4, 2, 4, 4]), ('regression: exact fit acceptance', [[6, 3, 5, 3, 1, 6, 5, 7], 10, 2, 3], [9, 9, 8, 10]), ('regression: exact fit acceptance', [[2, 2, 5, 5, 7, 6, 4, 2], 8, 2, 3], [6, 8, 7, 6, 6]), ('long paragraph continuation', [[2, 14], 6, 2, 2], [6, 6, 4]), ('single widow pulled back', [[3, 4], 6, 2, 2], [5, 2]), ('control layout', [[6, 3, 4, 2], 11, 1, 2], [11, 4]), ('control layout', [[9, 6, 2, 9, 7], 12, 3, 2], [12, 12, 9])], [('regression: exact fit acceptance', [[2, 8, 2, 7], 12, 1, 1], [12, 7]), ('regression: exact fit acceptance', [[3, 5, 5, 1, 7, 7, 3, 1], 4, 3, 3], [3, 4, 1, 4, 2, 4, 3, 4, 3, 4]), ('partial-repair probe', [[6, 7, 1, 1], 12, 3, 2], [11, 4]), ('regression: exact fit acceptance', [[2, 2, 5, 5, 7, 6, 4, 2], 8, 2, 3], [6, 8, 7, 6, 6]), ('single widow pulled back', [[3, 4], 6, 2, 2], [5, 2]), ('orphan pushed forward', [[5, 3], 6, 2, 2], [5, 3]), ('control layout', [[5, 1, 2, 7, 6], 9, 1, 2], [9, 9, 3]), ('control layout', [[9, 7, 4], 11, 2, 1], [11, 9])], [('regression: exact fit acceptance', [[6, 9, 1, 5, 1, 8], 11, 2, 1], [11, 11, 8]), ('regression: exact fit acceptance', [[6, 6, 2, 6, 9, 7, 2, 8], 7, 1, 1], [7, 7, 7, 7, 7, 7, 4]), ('partial-repair probe', [[8, 8, 2, 6, 7, 7, 9], 7, 3, 3], [7, 6, 5, 6, 7, 7, 7, 2]), ('partial-repair probe', [[1, 9, 7, 4, 6, 9], 5, 2, 1], [5, 5, 5, 5, 5, 5, 5, 1]), ('single widow pulled back', [[3, 4], 6, 2, 2], [5, 2]), ('paragraph exactly fills page', [[2, 4, 3], 6, 2, 2], [6, 3]), ('control layout', [[5, 9, 5, 1], 12, 1, 1], [12, 8]), ('control layout', [[5, 2, 2, 6, 3, 3, 3, 3], 10, 2, 3], [9, 9, 9])], [('regression: exact fit acceptance', [[8, 1, 5, 2, 5, 5], 8, 1, 3], [8, 8, 7, 3]), ('regression: exact fit acceptance', [[4, 5, 5, 3, 2, 6], 9, 2, 2], [9, 8, 8]), ('partial-repair probe', [[3, 7, 3, 2], 6, 1, 2], [6, 5, 4]), ('regression: exact fit acceptance', [[7, 4, 1, 1, 2, 6], 6, 3, 2], [6, 6, 6, 3]), ('paragraph exactly fills page', [[2, 4, 3], 6, 2, 2], [6, 3]), ('long paragraph continuation', [[2, 14], 6, 2, 2], [6, 6, 4]), ('control layout', [[2, 5, 2], 11, 3, 1], [9]), ('control layout', [[3, 5, 4, 4, 2, 7], 10, 1, 1], [10, 10, 5])], [('regression: exact fit acceptance', [[1, 7, 1, 3, 3, 9, 6, 9], 6, 1, 3], [5, 4, 6, 6, 6, 6, 6]), ('regression: exact fit acceptance', [[9, 3, 5, 4], 6, 3, 3], [6, 6, 5, 4]), ('regression: exact fit acceptance', [[6, 4, 9, 9, 4], 5, 2, 3], [5, 5, 5, 4, 5, 4, 4]), ('partial-repair probe', [[6, 8, 9, 3, 2, 5, 9, 6], 4, 1, 3], [4, 4, 4, 4, 4, 3, 3, 4, 4, 4, 4, 4, 2]), ('long paragraph continuation', [[2, 14], 6, 2, 2], [6, 6, 4]), ('single widow pulled back', [[3, 4], 6, 2, 2], [5, 2]), ('control layout', [[7, 4, 6, 6], 4, 3, 1], [4, 3, 4, 4, 2, 4, 2]), ('control layout', [[8, 7, 8], 8, 1, 3], [8, 8, 7])]]
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 |
|---|---|---|---|
| paragraph exactly fills page | [6, 3] | [6, 3] | Passed |
| regression: exact fit acceptance | [4, 3, 4, 2, 4, 4] | [4, 3, 4, 2, 4, 4] | Passed |
| regression: exact fit acceptance | [9, 9, 11, 7] | [9, 9, 8, 10] | Failed |
| regression: exact fit acceptance | [9, 8, 7, 9] | [6, 8, 7, 6, 6] | Failed |
| long paragraph continuation | [6, 6, 4] | [6, 6, 4] | Passed |
| single widow pulled back | [7] | [5, 2] | Failed |
| control layout | [11, 4] | [11, 4] | Passed |
| control layout | [12, 12, 9] | [12, 12, 9] | Passed |
SHA-256 / 70f9a54a9115218701bb3e122872835aa192b44d9e5f6ed168d20ddff57ab0d7
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗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:49.688651+00:00.
Case digest / 16bbd779f307a3804e1b7f04aaec7922decd30046d731a1163767dcfc63edb9b