FA-80001 / Typography line breaking / Open access
Widow and orphan page breaking: orphan parameter binding · case 01
Orphan decisions follow the widow minimum.
ROOT CAUSE
The orphan check compares against the widow parameter.
VERIFIED REPAIR
Compare the kept opening lines with the orphan minimum.
Unsuccessful approach: Using the smaller of the two minimums still ignores the configured orphan limit.
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 < widow:
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 = [[('regression: orphan parameter binding', [[3, 7, 8, 6, 7, 4, 2, 6], 6, 3, 1], [6, 4, 6, 6, 6, 6, 6, 3]), ('regression: orphan parameter binding', [[8, 4, 7, 9, 2], 7, 3, 1], [7, 5, 7, 7, 4]), ('regression: orphan parameter binding', [[1, 5, 3], 7, 2, 1], [6, 3]), ('regression: orphan parameter binding', [[2, 9, 7], 12, 2, 1], [11, 7]), ('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', [[1, 7, 1, 2, 1, 8], 8, 3, 2], [8, 8, 4]), ('control layout', [[1, 2, 8, 5, 8, 6, 7, 9], 7, 3, 3], [7, 4, 5, 7, 7, 7, 7, 2])], [('regression: orphan parameter binding', [[6, 8, 9, 2], 4, 1, 3], [4, 4, 4, 4, 4, 3, 2]), ('regression: orphan parameter binding', [[6, 8, 1, 3, 8, 9], 4, 1, 3], [4, 4, 4, 3, 4, 4, 4, 4, 4]), ('regression: orphan parameter binding', [[6, 6, 3, 3, 5, 7, 8], 11, 3, 2], [10, 11, 9, 8]), ('regression: orphan parameter binding', [[5, 4, 2, 8, 5], 5, 2, 1], [5, 4, 5, 5, 5]), ('orphan pushed forward', [[5, 3], 6, 2, 2], [5, 3]), ('long paragraph continuation', [[2, 14], 6, 2, 2], [6, 6, 4]), ('control layout', [[6, 2, 9, 7, 8, 9, 7], 8, 1, 3], [8, 8, 8, 8, 8, 8]), ('control layout', [[6, 9, 1, 5, 1, 8], 11, 2, 1], [11, 11, 8])], [('regression: orphan parameter binding', [[7, 8, 6, 2, 2, 9, 5, 6], 7, 1, 2], [7, 7, 7, 7, 7, 7, 3]), ('regression: orphan parameter binding', [[5, 3, 1, 2, 2, 9, 4, 4], 8, 3, 1], [8, 8, 6, 8]), ('regression: orphan parameter binding', [[6, 4, 6, 7, 5, 3], 8, 3, 2], [6, 8, 7, 7, 3]), ('regression: orphan parameter binding', [[6, 3, 8], 4, 3, 1], [4, 2, 3, 4, 4]), ('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, 6, 7], 5, 1, 1], [5, 5, 5, 5, 2]), ('control layout', [[7, 2, 8, 7, 3, 2], 9, 2, 3], [9, 8, 7, 5])], [('regression: orphan parameter binding', [[5, 1, 5, 6, 7, 7, 5, 1], 10, 2, 3], [8, 9, 10, 10]), ('regression: orphan parameter binding', [[7, 6, 7, 1], 4, 3, 1], [4, 3, 4, 2, 4, 4]), ('regression: orphan parameter binding', [[9, 8, 9, 1, 6, 3, 2, 5], 5, 2, 1], [5, 4, 5, 5, 5, 5, 4, 5, 5]), ('regression: orphan parameter binding', [[5, 3, 7], 7, 3, 1], [5, 7, 3]), ('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, 1, 5], 9, 1, 1], [9, 9, 2]), ('control layout', [[3, 4, 6, 6], 11, 1, 3], [10, 9])], [('regression: orphan parameter binding', [[1, 5, 6, 3], 7, 1, 2], [7, 6, 2]), ('regression: orphan parameter binding', [[5, 6, 5, 6, 7], 6, 3, 1], [5, 6, 5, 6, 6, 1]), ('regression: orphan parameter binding', [[7, 3, 1, 1, 8, 4, 9, 2], 5, 2, 1], [5, 5, 5, 5, 4, 5, 4, 2]), ('regression: orphan parameter binding', [[1, 7, 9, 4, 5, 8, 4], 10, 3, 2], [8, 9, 9, 8, 4]), ('single widow pulled back', [[3, 4], 6, 2, 2], [5, 2]), ('long paragraph continuation', [[2, 14], 6, 2, 2], [6, 6, 4]), ('control layout', [[7, 5, 3], 9, 3, 3], [7, 8]), ('control layout', [[5, 4, 4, 7, 8, 1, 5, 8], 6, 3, 3], [5, 4, 4, 6, 6, 4, 5, 6, 2])]]
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: orphan parameter binding | [6, 6, 6, 6, 6, 6, 6, 1] | [6, 4, 6, 6, 6, 6, 6, 3] | Failed |
| regression: orphan parameter binding | [7, 7, 7, 7, 2] | [7, 5, 7, 7, 4] | Failed |
| regression: orphan parameter binding | [7, 2] | [6, 3] | Failed |
| regression: orphan parameter binding | [12, 6] | [11, 7] | Failed |
| paragraph exactly fills page | [6, 3] | [6, 3] | Passed |
| long paragraph continuation | [6, 6, 4] | [6, 6, 4] | Passed |
| control layout | [8, 8, 4] | [8, 8, 4] | Passed |
| control layout | [7, 4, 5, 7, 7, 7, 7, 2] | [7, 4, 5, 7, 7, 7, 7, 2] | Passed |
SHA-256 / e167fafb948d70451a99b53f6b5924123499ef96824ffca121e5ebe5da9cfee3
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:
used += rem
rem = 0
continue
a = room
if used > 0:
if rem - a < widow:
a = max(rem - widow, 0)
if started and a < min(orphan, widow):
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 = [[('regression: orphan parameter binding', [[3, 7, 8, 6, 7, 4, 2, 6], 6, 3, 1], [6, 4, 6, 6, 6, 6, 6, 3]), ('regression: orphan parameter binding', [[8, 4, 7, 9, 2], 7, 3, 1], [7, 5, 7, 7, 4]), ('regression: orphan parameter binding', [[1, 5, 3], 7, 2, 1], [6, 3]), ('regression: orphan parameter binding', [[2, 9, 7], 12, 2, 1], [11, 7]), ('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', [[1, 7, 1, 2, 1, 8], 8, 3, 2], [8, 8, 4]), ('control layout', [[1, 2, 8, 5, 8, 6, 7, 9], 7, 3, 3], [7, 4, 5, 7, 7, 7, 7, 2])], [('regression: orphan parameter binding', [[6, 8, 9, 2], 4, 1, 3], [4, 4, 4, 4, 4, 3, 2]), ('regression: orphan parameter binding', [[6, 8, 1, 3, 8, 9], 4, 1, 3], [4, 4, 4, 3, 4, 4, 4, 4, 4]), ('regression: orphan parameter binding', [[6, 6, 3, 3, 5, 7, 8], 11, 3, 2], [10, 11, 9, 8]), ('regression: orphan parameter binding', [[5, 4, 2, 8, 5], 5, 2, 1], [5, 4, 5, 5, 5]), ('orphan pushed forward', [[5, 3], 6, 2, 2], [5, 3]), ('long paragraph continuation', [[2, 14], 6, 2, 2], [6, 6, 4]), ('control layout', [[6, 2, 9, 7, 8, 9, 7], 8, 1, 3], [8, 8, 8, 8, 8, 8]), ('control layout', [[6, 9, 1, 5, 1, 8], 11, 2, 1], [11, 11, 8])], [('regression: orphan parameter binding', [[7, 8, 6, 2, 2, 9, 5, 6], 7, 1, 2], [7, 7, 7, 7, 7, 7, 3]), ('regression: orphan parameter binding', [[5, 3, 1, 2, 2, 9, 4, 4], 8, 3, 1], [8, 8, 6, 8]), ('regression: orphan parameter binding', [[6, 4, 6, 7, 5, 3], 8, 3, 2], [6, 8, 7, 7, 3]), ('regression: orphan parameter binding', [[6, 3, 8], 4, 3, 1], [4, 2, 3, 4, 4]), ('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, 6, 7], 5, 1, 1], [5, 5, 5, 5, 2]), ('control layout', [[7, 2, 8, 7, 3, 2], 9, 2, 3], [9, 8, 7, 5])], [('regression: orphan parameter binding', [[5, 1, 5, 6, 7, 7, 5, 1], 10, 2, 3], [8, 9, 10, 10]), ('regression: orphan parameter binding', [[7, 6, 7, 1], 4, 3, 1], [4, 3, 4, 2, 4, 4]), ('regression: orphan parameter binding', [[9, 8, 9, 1, 6, 3, 2, 5], 5, 2, 1], [5, 4, 5, 5, 5, 5, 4, 5, 5]), ('regression: orphan parameter binding', [[5, 3, 7], 7, 3, 1], [5, 7, 3]), ('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, 1, 5], 9, 1, 1], [9, 9, 2]), ('control layout', [[3, 4, 6, 6], 11, 1, 3], [10, 9])], [('regression: orphan parameter binding', [[1, 5, 6, 3], 7, 1, 2], [7, 6, 2]), ('regression: orphan parameter binding', [[5, 6, 5, 6, 7], 6, 3, 1], [5, 6, 5, 6, 6, 1]), ('regression: orphan parameter binding', [[7, 3, 1, 1, 8, 4, 9, 2], 5, 2, 1], [5, 5, 5, 5, 4, 5, 4, 2]), ('regression: orphan parameter binding', [[1, 7, 9, 4, 5, 8, 4], 10, 3, 2], [8, 9, 9, 8, 4]), ('single widow pulled back', [[3, 4], 6, 2, 2], [5, 2]), ('long paragraph continuation', [[2, 14], 6, 2, 2], [6, 6, 4]), ('control layout', [[7, 5, 3], 9, 3, 3], [7, 8]), ('control layout', [[5, 4, 4, 7, 8, 1, 5, 8], 6, 3, 3], [5, 4, 4, 6, 6, 4, 5, 6, 2])]]
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: orphan parameter binding | [6, 6, 6, 6, 6, 6, 6, 1] | [6, 4, 6, 6, 6, 6, 6, 3] | Failed |
| regression: orphan parameter binding | [7, 7, 7, 7, 2] | [7, 5, 7, 7, 4] | Failed |
| regression: orphan parameter binding | [7, 2] | [6, 3] | Failed |
| regression: orphan parameter binding | [12, 6] | [11, 7] | Failed |
| paragraph exactly fills page | [6, 3] | [6, 3] | Passed |
| long paragraph continuation | [6, 6, 4] | [6, 6, 4] | Passed |
| control layout | [8, 8, 4] | [8, 8, 4] | Passed |
| control layout | [7, 4, 5, 7, 7, 7, 7, 2] | [7, 4, 5, 7, 7, 7, 7, 2] | Passed |
SHA-256 / af07e5d682610e270f171255cfc6654026f14d423e2ba08c39a492393d7864c0
3 / The verified repair
Exit 0"""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 = [[('regression: orphan parameter binding', [[3, 7, 8, 6, 7, 4, 2, 6], 6, 3, 1], [6, 4, 6, 6, 6, 6, 6, 3]), ('regression: orphan parameter binding', [[8, 4, 7, 9, 2], 7, 3, 1], [7, 5, 7, 7, 4]), ('regression: orphan parameter binding', [[1, 5, 3], 7, 2, 1], [6, 3]), ('regression: orphan parameter binding', [[2, 9, 7], 12, 2, 1], [11, 7]), ('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', [[1, 7, 1, 2, 1, 8], 8, 3, 2], [8, 8, 4]), ('control layout', [[1, 2, 8, 5, 8, 6, 7, 9], 7, 3, 3], [7, 4, 5, 7, 7, 7, 7, 2])], [('regression: orphan parameter binding', [[6, 8, 9, 2], 4, 1, 3], [4, 4, 4, 4, 4, 3, 2]), ('regression: orphan parameter binding', [[6, 8, 1, 3, 8, 9], 4, 1, 3], [4, 4, 4, 3, 4, 4, 4, 4, 4]), ('regression: orphan parameter binding', [[6, 6, 3, 3, 5, 7, 8], 11, 3, 2], [10, 11, 9, 8]), ('regression: orphan parameter binding', [[5, 4, 2, 8, 5], 5, 2, 1], [5, 4, 5, 5, 5]), ('orphan pushed forward', [[5, 3], 6, 2, 2], [5, 3]), ('long paragraph continuation', [[2, 14], 6, 2, 2], [6, 6, 4]), ('control layout', [[6, 2, 9, 7, 8, 9, 7], 8, 1, 3], [8, 8, 8, 8, 8, 8]), ('control layout', [[6, 9, 1, 5, 1, 8], 11, 2, 1], [11, 11, 8])], [('regression: orphan parameter binding', [[7, 8, 6, 2, 2, 9, 5, 6], 7, 1, 2], [7, 7, 7, 7, 7, 7, 3]), ('regression: orphan parameter binding', [[5, 3, 1, 2, 2, 9, 4, 4], 8, 3, 1], [8, 8, 6, 8]), ('regression: orphan parameter binding', [[6, 4, 6, 7, 5, 3], 8, 3, 2], [6, 8, 7, 7, 3]), ('regression: orphan parameter binding', [[6, 3, 8], 4, 3, 1], [4, 2, 3, 4, 4]), ('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, 6, 7], 5, 1, 1], [5, 5, 5, 5, 2]), ('control layout', [[7, 2, 8, 7, 3, 2], 9, 2, 3], [9, 8, 7, 5])], [('regression: orphan parameter binding', [[5, 1, 5, 6, 7, 7, 5, 1], 10, 2, 3], [8, 9, 10, 10]), ('regression: orphan parameter binding', [[7, 6, 7, 1], 4, 3, 1], [4, 3, 4, 2, 4, 4]), ('regression: orphan parameter binding', [[9, 8, 9, 1, 6, 3, 2, 5], 5, 2, 1], [5, 4, 5, 5, 5, 5, 4, 5, 5]), ('regression: orphan parameter binding', [[5, 3, 7], 7, 3, 1], [5, 7, 3]), ('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, 1, 5], 9, 1, 1], [9, 9, 2]), ('control layout', [[3, 4, 6, 6], 11, 1, 3], [10, 9])], [('regression: orphan parameter binding', [[1, 5, 6, 3], 7, 1, 2], [7, 6, 2]), ('regression: orphan parameter binding', [[5, 6, 5, 6, 7], 6, 3, 1], [5, 6, 5, 6, 6, 1]), ('regression: orphan parameter binding', [[7, 3, 1, 1, 8, 4, 9, 2], 5, 2, 1], [5, 5, 5, 5, 4, 5, 4, 2]), ('regression: orphan parameter binding', [[1, 7, 9, 4, 5, 8, 4], 10, 3, 2], [8, 9, 9, 8, 4]), ('single widow pulled back', [[3, 4], 6, 2, 2], [5, 2]), ('long paragraph continuation', [[2, 14], 6, 2, 2], [6, 6, 4]), ('control layout', [[7, 5, 3], 9, 3, 3], [7, 8]), ('control layout', [[5, 4, 4, 7, 8, 1, 5, 8], 6, 3, 3], [5, 4, 4, 6, 6, 4, 5, 6, 2])]]
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: orphan parameter binding | [6, 4, 6, 6, 6, 6, 6, 3] | [6, 4, 6, 6, 6, 6, 6, 3] | Passed |
| regression: orphan parameter binding | [7, 5, 7, 7, 4] | [7, 5, 7, 7, 4] | Passed |
| regression: orphan parameter binding | [6, 3] | [6, 3] | Passed |
| regression: orphan parameter binding | [11, 7] | [11, 7] | Passed |
| paragraph exactly fills page | [6, 3] | [6, 3] | Passed |
| long paragraph continuation | [6, 6, 4] | [6, 6, 4] | Passed |
| control layout | [8, 8, 4] | [8, 8, 4] | Passed |
| control layout | [7, 4, 5, 7, 7, 7, 7, 2] | [7, 4, 5, 7, 7, 7, 7, 2] | Passed |
SHA-256 / 84126b3260c43f07a1e49c1111cb9f02361b82c0719ab4df55b6eb511340d1d1
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.688982+00:00.
Case digest / e9e8a58c34f712886d652bfdbf3e14c93a150a42f343e9edede47d64670b3f90