FAILURE MAP
← Case archive

FA-79986 / Typography line breaking / Open access

Widow and orphan page breaking: empty page waiver · case 01

Pages that start mid-paragraph are left short or stall the flow.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The widow/orphan adjustments also run on an empty page, where nothing can be moved.

VERIFIED REPAIR

Waive the adjustments when the page holds no lines yet.

Unsuccessful approach: Waiving only pages with one line still adjusts nearly empty pages wrongly.

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 = [[('regression: empty page waiver', [[9, 9, 3, 9, 2, 9, 2, 8], 4, 2, 3], [4, 4, 4, 4, 2, 3, 4, 4, 3, 4, 4, 3, 4, 4]), ('regression: empty page waiver', [[4, 5, 5, 1, 6, 1], 4, 3, 2], [4, 4, 4, 3, 4, 3]), ('regression: empty page waiver', [[2, 2, 4, 4, 4, 5, 4, 4], 4, 2, 3], [4, 4, 4, 4, 4, 1, 4, 4]), ('regression: empty page waiver', [[5, 2, 5, 9, 2, 6, 9, 8], 8, 3, 2], [7, 8, 8, 6, 8, 7, 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', [[5, 6, 6], 11, 1, 3], [11, 6]), ('control layout', [[1, 9, 4, 2, 1, 1, 1, 1], 7, 1, 3], [7, 7, 6])], [('regression: empty page waiver', [[9, 9, 9], 4, 3, 3], [4, 4, 4, 4, 2, 4, 4, 1]), ('regression: empty page waiver', [[9, 1, 2, 9, 1, 1, 5], 4, 1, 2], [4, 4, 4, 4, 4, 4, 4]), ('regression: empty page waiver', [[7, 1, 1, 6, 3, 6, 4], 4, 1, 3], [4, 4, 4, 3, 4, 4, 2, 3]), ('regression: empty page waiver', [[5, 5, 9, 6, 5], 5, 3, 3], [5, 5, 5, 4, 5, 1, 5]), ('orphan pushed forward', [[5, 3], 6, 2, 2], [5, 3]), ('paragraph exactly fills page', [[2, 4, 3], 6, 2, 2], [6, 3]), ('control layout', [[9, 9, 3, 5, 6, 1], 12, 2, 3], [12, 11, 10]), ('control layout', [[8, 4, 3, 2, 3], 9, 3, 1], [8, 9, 3])], [('regression: empty page waiver', [[9, 8, 5, 2, 1, 8], 8, 2, 2], [8, 7, 7, 8, 3]), ('regression: empty page waiver', [[9, 9, 3, 9, 2, 9, 2, 8], 4, 2, 3], [4, 4, 4, 4, 2, 3, 4, 4, 3, 4, 4, 3, 4, 4]), ('regression: empty page waiver', [[4, 6, 5, 8, 9], 5, 2, 2], [4, 5, 4, 5, 5, 5, 4]), ('regression: empty page waiver', [[9, 5, 1, 9, 8, 5], 8, 2, 3], [8, 7, 8, 6, 8]), ('paragraph exactly fills page', [[2, 4, 3], 6, 2, 2], [6, 3]), ('single widow pulled back', [[3, 4], 6, 2, 2], [5, 2]), ('control layout', [[5, 4, 1, 5, 7], 4, 1, 1], [4, 4, 4, 4, 4, 2]), ('control layout', [[5, 6, 1, 3, 1], 12, 3, 1], [12, 4])], [('regression: empty page waiver', [[8, 4, 9, 6, 1], 7, 3, 2], [7, 5, 7, 6, 3]), ('regression: empty page waiver', [[6, 8, 9, 2], 4, 1, 3], [4, 4, 4, 4, 4, 3, 2]), ('regression: empty page waiver', [[5, 2, 5, 9, 2, 6, 9, 8], 8, 3, 2], [7, 8, 8, 6, 8, 7, 2]), ('regression: empty page waiver', [[3, 3, 8, 5, 7, 7], 5, 1, 3], [3, 5, 5, 3, 5, 5, 5, 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', [[3, 4, 1], 6, 3, 3], [3, 5]), ('control layout', [[3, 8, 3, 4], 9, 3, 1], [9, 9])], [('regression: empty page waiver', [[6, 7, 1], 5, 1, 3], [5, 5, 4]), ('regression: empty page waiver', [[8, 8, 4, 7, 9, 1, 4], 7, 2, 2], [7, 7, 6, 7, 7, 7]), ('partial-repair probe', [[9, 7, 5, 9, 3, 9, 1, 7], 6, 1, 3], [6, 6, 6, 6, 6, 6, 6, 5, 3]), ('partial-repair probe', [[1, 7, 1, 3, 3, 9, 6, 9], 6, 1, 3], [5, 4, 6, 6, 6, 6, 6]), ('long paragraph continuation', [[2, 14], 6, 2, 2], [6, 6, 4]), ('orphan pushed forward', [[5, 3], 6, 2, 2], [5, 3]), ('control layout', [[4, 4, 6, 1], 12, 3, 1], [12, 3]), ('control layout', [[2, 9, 3, 5, 4, 7, 8], 9, 1, 1], [9, 9, 9, 9, 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 fixtureActualExpectedOutcome
regression: empty page waiver[4, 2, 3, 4, 2, 3, 3, 4, 2, 3, 4, 4, 3, 4, 3, 3][4, 4, 4, 4, 2, 3, 4, 4, 3, 4, 4, 3, 4, 4]Failed
regression: empty page waiver[4, 3, 2, 3, 3, 4, 3][4, 4, 4, 3, 4, 3]Failed
regression: empty page waiver[4, 4, 4, 4, 2, 3, 4, 4][4, 4, 4, 4, 4, 1, 4, 4]Failed
regression: empty page waiver[7, 8, 8, 6, 7, 8, 2][7, 8, 8, 6, 8, 7, 2]Failed
long paragraph continuation[6, 6, 4][6, 6, 4]Passed
single widow pulled back[5, 2][5, 2]Passed
control layout[11, 6][11, 6]Passed
control layout[7, 7, 6][7, 7, 6]Passed

SHA-256 / 0dabe237da01a3302cf12093b2ae5dba2296fe641d70504e8f081d4b1afc9d6d

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 > 1:
                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: empty page waiver', [[9, 9, 3, 9, 2, 9, 2, 8], 4, 2, 3], [4, 4, 4, 4, 2, 3, 4, 4, 3, 4, 4, 3, 4, 4]), ('regression: empty page waiver', [[4, 5, 5, 1, 6, 1], 4, 3, 2], [4, 4, 4, 3, 4, 3]), ('regression: empty page waiver', [[2, 2, 4, 4, 4, 5, 4, 4], 4, 2, 3], [4, 4, 4, 4, 4, 1, 4, 4]), ('regression: empty page waiver', [[5, 2, 5, 9, 2, 6, 9, 8], 8, 3, 2], [7, 8, 8, 6, 8, 7, 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', [[5, 6, 6], 11, 1, 3], [11, 6]), ('control layout', [[1, 9, 4, 2, 1, 1, 1, 1], 7, 1, 3], [7, 7, 6])], [('regression: empty page waiver', [[9, 9, 9], 4, 3, 3], [4, 4, 4, 4, 2, 4, 4, 1]), ('regression: empty page waiver', [[9, 1, 2, 9, 1, 1, 5], 4, 1, 2], [4, 4, 4, 4, 4, 4, 4]), ('regression: empty page waiver', [[7, 1, 1, 6, 3, 6, 4], 4, 1, 3], [4, 4, 4, 3, 4, 4, 2, 3]), ('regression: empty page waiver', [[5, 5, 9, 6, 5], 5, 3, 3], [5, 5, 5, 4, 5, 1, 5]), ('orphan pushed forward', [[5, 3], 6, 2, 2], [5, 3]), ('paragraph exactly fills page', [[2, 4, 3], 6, 2, 2], [6, 3]), ('control layout', [[9, 9, 3, 5, 6, 1], 12, 2, 3], [12, 11, 10]), ('control layout', [[8, 4, 3, 2, 3], 9, 3, 1], [8, 9, 3])], [('regression: empty page waiver', [[9, 8, 5, 2, 1, 8], 8, 2, 2], [8, 7, 7, 8, 3]), ('regression: empty page waiver', [[9, 9, 3, 9, 2, 9, 2, 8], 4, 2, 3], [4, 4, 4, 4, 2, 3, 4, 4, 3, 4, 4, 3, 4, 4]), ('regression: empty page waiver', [[4, 6, 5, 8, 9], 5, 2, 2], [4, 5, 4, 5, 5, 5, 4]), ('regression: empty page waiver', [[9, 5, 1, 9, 8, 5], 8, 2, 3], [8, 7, 8, 6, 8]), ('paragraph exactly fills page', [[2, 4, 3], 6, 2, 2], [6, 3]), ('single widow pulled back', [[3, 4], 6, 2, 2], [5, 2]), ('control layout', [[5, 4, 1, 5, 7], 4, 1, 1], [4, 4, 4, 4, 4, 2]), ('control layout', [[5, 6, 1, 3, 1], 12, 3, 1], [12, 4])], [('regression: empty page waiver', [[8, 4, 9, 6, 1], 7, 3, 2], [7, 5, 7, 6, 3]), ('regression: empty page waiver', [[6, 8, 9, 2], 4, 1, 3], [4, 4, 4, 4, 4, 3, 2]), ('regression: empty page waiver', [[5, 2, 5, 9, 2, 6, 9, 8], 8, 3, 2], [7, 8, 8, 6, 8, 7, 2]), ('regression: empty page waiver', [[3, 3, 8, 5, 7, 7], 5, 1, 3], [3, 5, 5, 3, 5, 5, 5, 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', [[3, 4, 1], 6, 3, 3], [3, 5]), ('control layout', [[3, 8, 3, 4], 9, 3, 1], [9, 9])], [('regression: empty page waiver', [[6, 7, 1], 5, 1, 3], [5, 5, 4]), ('regression: empty page waiver', [[8, 8, 4, 7, 9, 1, 4], 7, 2, 2], [7, 7, 6, 7, 7, 7]), ('partial-repair probe', [[9, 7, 5, 9, 3, 9, 1, 7], 6, 1, 3], [6, 6, 6, 6, 6, 6, 6, 5, 3]), ('partial-repair probe', [[1, 7, 1, 3, 3, 9, 6, 9], 6, 1, 3], [5, 4, 6, 6, 6, 6, 6]), ('long paragraph continuation', [[2, 14], 6, 2, 2], [6, 6, 4]), ('orphan pushed forward', [[5, 3], 6, 2, 2], [5, 3]), ('control layout', [[4, 4, 6, 1], 12, 3, 1], [12, 3]), ('control layout', [[2, 9, 3, 5, 4, 7, 8], 9, 1, 1], [9, 9, 9, 9, 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 fixtureActualExpectedOutcome
regression: empty page waiver[4, 4, 4, 4, 2, 3, 4, 4, 3, 4, 4, 3, 4, 4][4, 4, 4, 4, 2, 3, 4, 4, 3, 4, 4, 3, 4, 4]Passed
regression: empty page waiver[4, 4, 4, 3, 4, 3][4, 4, 4, 3, 4, 3]Passed
regression: empty page waiver[4, 4, 4, 4, 4, 4, 4, 1][4, 4, 4, 4, 4, 1, 4, 4]Failed
regression: empty page waiver[7, 8, 8, 6, 8, 8, 1][7, 8, 8, 6, 8, 7, 2]Failed
long paragraph continuation[6, 6, 4][6, 6, 4]Passed
single widow pulled back[5, 2][5, 2]Passed
control layout[11, 6][11, 6]Passed
control layout[7, 7, 6][7, 7, 6]Passed

SHA-256 / ae79e393ed66c1c571aaf9d49a65d118178e0f802f92ad1704550cfb480d81f6

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: empty page waiver', [[9, 9, 3, 9, 2, 9, 2, 8], 4, 2, 3], [4, 4, 4, 4, 2, 3, 4, 4, 3, 4, 4, 3, 4, 4]), ('regression: empty page waiver', [[4, 5, 5, 1, 6, 1], 4, 3, 2], [4, 4, 4, 3, 4, 3]), ('regression: empty page waiver', [[2, 2, 4, 4, 4, 5, 4, 4], 4, 2, 3], [4, 4, 4, 4, 4, 1, 4, 4]), ('regression: empty page waiver', [[5, 2, 5, 9, 2, 6, 9, 8], 8, 3, 2], [7, 8, 8, 6, 8, 7, 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', [[5, 6, 6], 11, 1, 3], [11, 6]), ('control layout', [[1, 9, 4, 2, 1, 1, 1, 1], 7, 1, 3], [7, 7, 6])], [('regression: empty page waiver', [[9, 9, 9], 4, 3, 3], [4, 4, 4, 4, 2, 4, 4, 1]), ('regression: empty page waiver', [[9, 1, 2, 9, 1, 1, 5], 4, 1, 2], [4, 4, 4, 4, 4, 4, 4]), ('regression: empty page waiver', [[7, 1, 1, 6, 3, 6, 4], 4, 1, 3], [4, 4, 4, 3, 4, 4, 2, 3]), ('regression: empty page waiver', [[5, 5, 9, 6, 5], 5, 3, 3], [5, 5, 5, 4, 5, 1, 5]), ('orphan pushed forward', [[5, 3], 6, 2, 2], [5, 3]), ('paragraph exactly fills page', [[2, 4, 3], 6, 2, 2], [6, 3]), ('control layout', [[9, 9, 3, 5, 6, 1], 12, 2, 3], [12, 11, 10]), ('control layout', [[8, 4, 3, 2, 3], 9, 3, 1], [8, 9, 3])], [('regression: empty page waiver', [[9, 8, 5, 2, 1, 8], 8, 2, 2], [8, 7, 7, 8, 3]), ('regression: empty page waiver', [[9, 9, 3, 9, 2, 9, 2, 8], 4, 2, 3], [4, 4, 4, 4, 2, 3, 4, 4, 3, 4, 4, 3, 4, 4]), ('regression: empty page waiver', [[4, 6, 5, 8, 9], 5, 2, 2], [4, 5, 4, 5, 5, 5, 4]), ('regression: empty page waiver', [[9, 5, 1, 9, 8, 5], 8, 2, 3], [8, 7, 8, 6, 8]), ('paragraph exactly fills page', [[2, 4, 3], 6, 2, 2], [6, 3]), ('single widow pulled back', [[3, 4], 6, 2, 2], [5, 2]), ('control layout', [[5, 4, 1, 5, 7], 4, 1, 1], [4, 4, 4, 4, 4, 2]), ('control layout', [[5, 6, 1, 3, 1], 12, 3, 1], [12, 4])], [('regression: empty page waiver', [[8, 4, 9, 6, 1], 7, 3, 2], [7, 5, 7, 6, 3]), ('regression: empty page waiver', [[6, 8, 9, 2], 4, 1, 3], [4, 4, 4, 4, 4, 3, 2]), ('regression: empty page waiver', [[5, 2, 5, 9, 2, 6, 9, 8], 8, 3, 2], [7, 8, 8, 6, 8, 7, 2]), ('regression: empty page waiver', [[3, 3, 8, 5, 7, 7], 5, 1, 3], [3, 5, 5, 3, 5, 5, 5, 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', [[3, 4, 1], 6, 3, 3], [3, 5]), ('control layout', [[3, 8, 3, 4], 9, 3, 1], [9, 9])], [('regression: empty page waiver', [[6, 7, 1], 5, 1, 3], [5, 5, 4]), ('regression: empty page waiver', [[8, 8, 4, 7, 9, 1, 4], 7, 2, 2], [7, 7, 6, 7, 7, 7]), ('partial-repair probe', [[9, 7, 5, 9, 3, 9, 1, 7], 6, 1, 3], [6, 6, 6, 6, 6, 6, 6, 5, 3]), ('partial-repair probe', [[1, 7, 1, 3, 3, 9, 6, 9], 6, 1, 3], [5, 4, 6, 6, 6, 6, 6]), ('long paragraph continuation', [[2, 14], 6, 2, 2], [6, 6, 4]), ('orphan pushed forward', [[5, 3], 6, 2, 2], [5, 3]), ('control layout', [[4, 4, 6, 1], 12, 3, 1], [12, 3]), ('control layout', [[2, 9, 3, 5, 4, 7, 8], 9, 1, 1], [9, 9, 9, 9, 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 fixtureActualExpectedOutcome
regression: empty page waiver[4, 4, 4, 4, 2, 3, 4, 4, 3, 4, 4, 3, 4, 4][4, 4, 4, 4, 2, 3, 4, 4, 3, 4, 4, 3, 4, 4]Passed
regression: empty page waiver[4, 4, 4, 3, 4, 3][4, 4, 4, 3, 4, 3]Passed
regression: empty page waiver[4, 4, 4, 4, 4, 1, 4, 4][4, 4, 4, 4, 4, 1, 4, 4]Passed
regression: empty page waiver[7, 8, 8, 6, 8, 7, 2][7, 8, 8, 6, 8, 7, 2]Passed
long paragraph continuation[6, 6, 4][6, 6, 4]Passed
single widow pulled back[5, 2][5, 2]Passed
control layout[11, 6][11, 6]Passed
control layout[7, 7, 6][7, 7, 6]Passed

SHA-256 / 86bf4db20e11d4b842a18dfcf24f8906b145a3eab89a12be214a735979fbdc8e

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.644771+00:00.

Case digest / 796ce4b19906ceb3fdca53b6c8290cf8ba31be399942b169ee52723fbd83c975