{"abstract":"Badness of lines with fractional ratios drifts by several points.","category":"Typography line breaking","checks":8,"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].","contract_signature":"x","evaluation_group":"w2-typography-line-breaking-glue-badness","failed_approach":"Using Python's round on the scaled value applies banker's rounding and drops 12.5 to 12.","family":"w2-typography-line-breaking-glue-badness-badness-rounding-stage","id":"FA-79856","implementations":{"attempt":{"sha256":"0abfe0dedd574be2e60619572acbe890d99248c0ab6df48a45c2de602882e794","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(x):\n    natural, stretch, shrink, width, tolerance = x\n    shortfall = width - natural\n    if shortfall > 0:\n        if stretch == 0:\n            return ['underfull', 10000, 'very_loose']\n        r = Fraction(shortfall, stretch)\n    elif shortfall < 0:\n        if -shortfall > shrink:\n            return ['overfull', 1000000, 'tight']\n        r = Fraction(shortfall, shrink)\n    else:\n        r = Fraction(0)\n    badness = min(10000, round(100 * abs(r) ** 3))\n    if r < Fraction(-1, 2):\n        fitness = 'tight'\n    elif r <= Fraction(1, 2):\n        fitness = 'decent'\n    elif r <= 1:\n        fitness = 'loose'\n    else:\n        fitness = 'very_loose'\n    status = 'ok' if badness <= tolerance else 'underfull'\n    return [status, badness, fitness]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('regression: badness rounding stage', [84, 20, 2, 101, 500], ['ok', 61, 'loose']), ('regression: badness rounding stage', [82, 6, 5, 98, 200], ['underfull', 1896, 'very_loose']), ('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('partial-repair probe', [111, 8, 7, 131, 150], ['underfull', 1563, 'very_loose']), ('very loose over tolerance', [100, 4, 0, 110, 200], ['underfull', 1563, 'very_loose']), ('exact natural width', [100, 10, 5, 100, 200], ['ok', 0, 'decent']), ('control layout', [83, 0, 3, 97, 100], ['underfull', 10000, 'very_loose']), ('control layout', [94, 20, 0, 108, 100], ['ok', 34, 'loose'])], [('regression: badness rounding stage', [102, 16, 2, 113, 150], ['ok', 32, 'loose']), ('regression: badness rounding stage', [64, 8, 7, 77, 500], ['ok', 429, 'very_loose']), ('partial-repair probe', [88, 8, 8, 84, 150], ['ok', 13, 'decent']), ('partial-repair probe', [117, 2, 12, 111, 100], ['ok', 13, 'decent']), ('very loose over tolerance', [100, 4, 0, 110, 200], ['underfull', 1563, 'very_loose']), ('full shrink is still acceptable', [100, 10, 5, 95, 200], ['ok', 100, 'tight']), ('control layout', [106, 16, 11, 95, 200], ['ok', 100, 'tight']), ('control layout', [80, 1, 6, 84, 1000], ['underfull', 6400, 'very_loose'])], [('regression: badness rounding stage', [89, 4, 12, 80, 150], ['ok', 42, 'tight']), ('regression: badness rounding stage', [119, 4, 10, 134, 100], ['underfull', 5273, 'very_loose']), ('partial-repair probe', [120, 12, 3, 126, 1000], ['ok', 13, 'decent']), ('partial-repair probe', [86, 6, 3, 89, 200], ['ok', 13, 'decent']), ('exact natural width', [100, 10, 5, 100, 200], ['ok', 0, 'decent']), ('full shrink is still acceptable', [100, 10, 5, 95, 200], ['ok', 100, 'tight']), ('control layout', [66, 4, 5, 60, 200], ['overfull', 1000000, 'tight']), ('control layout', [94, 20, 0, 108, 100], ['ok', 34, 'loose'])], [('regression: badness rounding stage', [88, 3, 12, 79, 1000], ['ok', 42, 'tight']), ('regression: badness rounding stage', [107, 16, 10, 111, 1000], ['ok', 2, 'decent']), ('partial-repair probe', [66, 2, 3, 75, 150], ['underfull', 9113, 'very_loose']), ('partial-repair probe', [120, 12, 3, 126, 1000], ['ok', 13, 'decent']), ('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', [64, 0, 3, 50, 1000], ['overfull', 1000000, 'tight']), ('control layout', [64, 4, 9, 52, 100], ['overfull', 1000000, 'tight'])], [('regression: badness rounding stage', [80, 12, 5, 88, 500], ['ok', 30, 'loose']), ('regression: badness rounding stage', [65, 16, 4, 69, 1000], ['ok', 2, 'decent']), ('partial-repair probe', [117, 2, 12, 111, 100], ['ok', 13, 'decent']), ('partial-repair probe', [109, 8, 11, 129, 100], ['underfull', 1563, 'very_loose']), ('badness cap at 10000', [100, 2, 0, 150, 200], ['underfull', 10000, 'very_loose']), ('exact natural width', [100, 10, 5, 100, 200], ['ok', 0, 'decent']), ('control layout', [81, 4, 5, 72, 100], ['overfull', 1000000, 'tight']), ('control layout', [76, 20, 1, 72, 200], ['overfull', 1000000, 'tight'])]]\nfor label, args, expected in fixtures[N - 1]:\n    check(label, solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"c4954c9dacdb85940c9e81532eff6c26cf99ebc8b8b1a2610d19ba45ae9cce04","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(x):\n    natural, stretch, shrink, width, tolerance = x\n    shortfall = width - natural\n    if shortfall > 0:\n        if stretch == 0:\n            return ['underfull', 10000, 'very_loose']\n        r = Fraction(shortfall, stretch)\n    elif shortfall < 0:\n        if -shortfall > shrink:\n            return ['overfull', 1000000, 'tight']\n        r = Fraction(shortfall, shrink)\n    else:\n        r = Fraction(0)\n    badness = min(10000, math.floor(100 * round(abs(r), 1) ** 3 + Fraction(1, 2)))\n    if r < Fraction(-1, 2):\n        fitness = 'tight'\n    elif r <= Fraction(1, 2):\n        fitness = 'decent'\n    elif r <= 1:\n        fitness = 'loose'\n    else:\n        fitness = 'very_loose'\n    status = 'ok' if badness <= tolerance else 'underfull'\n    return [status, badness, fitness]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('regression: badness rounding stage', [84, 20, 2, 101, 500], ['ok', 61, 'loose']), ('regression: badness rounding stage', [82, 6, 5, 98, 200], ['underfull', 1896, 'very_loose']), ('half stretch ratio rounds 12.5 up', [100, 10, 5, 105, 200], ['ok', 13, 'decent']), ('partial-repair probe', [111, 8, 7, 131, 150], ['underfull', 1563, 'very_loose']), ('very loose over tolerance', [100, 4, 0, 110, 200], ['underfull', 1563, 'very_loose']), ('exact natural width', [100, 10, 5, 100, 200], ['ok', 0, 'decent']), ('control layout', [83, 0, 3, 97, 100], ['underfull', 10000, 'very_loose']), ('control layout', [94, 20, 0, 108, 100], ['ok', 34, 'loose'])], [('regression: badness rounding stage', [102, 16, 2, 113, 150], ['ok', 32, 'loose']), ('regression: badness rounding stage', [64, 8, 7, 77, 500], ['ok', 429, 'very_loose']), ('partial-repair probe', [88, 8, 8, 84, 150], ['ok', 13, 'decent']), ('partial-repair probe', [117, 2, 12, 111, 100], ['ok', 13, 'decent']), ('very loose over tolerance', [100, 4, 0, 110, 200], ['underfull', 1563, 'very_loose']), ('full shrink is still acceptable', [100, 10, 5, 95, 200], ['ok', 100, 'tight']), ('control layout', [106, 16, 11, 95, 200], ['ok', 100, 'tight']), ('control layout', [80, 1, 6, 84, 1000], ['underfull', 6400, 'very_loose'])], [('regression: badness rounding stage', [89, 4, 12, 80, 150], ['ok', 42, 'tight']), ('regression: badness rounding stage', [119, 4, 10, 134, 100], ['underfull', 5273, 'very_loose']), ('partial-repair probe', [120, 12, 3, 126, 1000], ['ok', 13, 'decent']), ('partial-repair probe', [86, 6, 3, 89, 200], ['ok', 13, 'decent']), ('exact natural width', [100, 10, 5, 100, 200], ['ok', 0, 'decent']), ('full shrink is still acceptable', [100, 10, 5, 95, 200], ['ok', 100, 'tight']), ('control layout', [66, 4, 5, 60, 200], ['overfull', 1000000, 'tight']), ('control layout', [94, 20, 0, 108, 100], ['ok', 34, 'loose'])], [('regression: badness rounding stage', [88, 3, 12, 79, 1000], ['ok', 42, 'tight']), ('regression: badness rounding stage', [107, 16, 10, 111, 1000], ['ok', 2, 'decent']), ('partial-repair probe', [66, 2, 3, 75, 150], ['underfull', 9113, 'very_loose']), ('partial-repair probe', [120, 12, 3, 126, 1000], ['ok', 13, 'decent']), ('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', [64, 0, 3, 50, 1000], ['overfull', 1000000, 'tight']), ('control layout', [64, 4, 9, 52, 100], ['overfull', 1000000, 'tight'])], [('regression: badness rounding stage', [80, 12, 5, 88, 500], ['ok', 30, 'loose']), ('regression: badness rounding stage', [65, 16, 4, 69, 1000], ['ok', 2, 'decent']), ('partial-repair probe', [117, 2, 12, 111, 100], ['ok', 13, 'decent']), ('partial-repair probe', [109, 8, 11, 129, 100], ['underfull', 1563, 'very_loose']), ('badness cap at 10000', [100, 2, 0, 150, 200], ['underfull', 10000, 'very_loose']), ('exact natural width', [100, 10, 5, 100, 200], ['ok', 0, 'decent']), ('control layout', [81, 4, 5, 72, 100], ['overfull', 1000000, 'tight']), ('control layout', [76, 20, 1, 72, 200], ['overfull', 1000000, 'tight'])]]\nfor label, args, expected in fixtures[N - 1]:\n    check(label, solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-typography-line-breaking-glue-badness-badness-rounding-stage","generated_at":"2026-09-29T14:49:48.293310+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Line breaking decides where paragraphs wrap on screen and in print; a wrong decision point shifts every following line.","root_cause":"The ratio is rounded to one decimal before it is cubed, rounding at the wrong stage.","sha256":"d4c4a6fcb8db02978711734c40d4815945eee32f8fa4350002a8d970a21c52ed","title":"Glue-set badness rating: badness rounding stage · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":43.316,"exit_code":1,"observations":[{"actual":["ok",61,"loose"],"check":"regression: badness rounding stage","expected":["ok",61,"loose"],"passed":true},{"actual":["underfull",1896,"very_loose"],"check":"regression: badness rounding stage","expected":["underfull",1896,"very_loose"],"passed":true},{"actual":["ok",12,"decent"],"check":"half stretch ratio rounds 12.5 up","expected":["ok",13,"decent"],"passed":false},{"actual":["underfull",1562,"very_loose"],"check":"partial-repair probe","expected":["underfull",1563,"very_loose"],"passed":false},{"actual":["underfull",1562,"very_loose"],"check":"very loose over tolerance","expected":["underfull",1563,"very_loose"],"passed":false},{"actual":["ok",0,"decent"],"check":"exact natural width","expected":["ok",0,"decent"],"passed":true},{"actual":["underfull",10000,"very_loose"],"check":"control layout","expected":["underfull",10000,"very_loose"],"passed":true},{"actual":["ok",34,"loose"],"check":"control layout","expected":["ok",34,"loose"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: badness rounding stage\", \"actual\": [\"ok\", 61, \"loose\"], \"expected\": [\"ok\", 61, \"loose\"], \"passed\": true}, {\"check\": \"regression: badness rounding stage\", \"actual\": [\"underfull\", 1896, \"very_loose\"], \"expected\": [\"underfull\", 1896, \"very_loose\"], \"passed\": true}, {\"check\": \"half stretch ratio rounds 12.5 up\", \"actual\": [\"ok\", 12, \"decent\"], \"expected\": [\"ok\", 13, \"decent\"], \"passed\": false}, {\"check\": \"partial-repair probe\", \"actual\": [\"underfull\", 1562, \"very_loose\"], \"expected\": [\"underfull\", 1563, \"very_loose\"], \"passed\": false}, {\"check\": \"very loose over tolerance\", \"actual\": [\"underfull\", 1562, \"very_loose\"], \"expected\": [\"underfull\", 1563, \"very_loose\"], \"passed\": false}, {\"check\": \"exact natural width\", \"actual\": [\"ok\", 0, \"decent\"], \"expected\": [\"ok\", 0, \"decent\"], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [\"underfull\", 10000, \"very_loose\"], \"expected\": [\"underfull\", 10000, \"very_loose\"], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [\"ok\", 34, \"loose\"], \"expected\": [\"ok\", 34, \"loose\"], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":43.476,"exit_code":1,"observations":[{"actual":["ok",51,"loose"],"check":"regression: badness rounding stage","expected":["ok",61,"loose"],"passed":false},{"actual":["underfull",1968,"very_loose"],"check":"regression: badness rounding stage","expected":["underfull",1896,"very_loose"],"passed":false},{"actual":["ok",13,"decent"],"check":"half stretch ratio rounds 12.5 up","expected":["ok",13,"decent"],"passed":true},{"actual":["underfull",1563,"very_loose"],"check":"partial-repair probe","expected":["underfull",1563,"very_loose"],"passed":true},{"actual":["underfull",1563,"very_loose"],"check":"very loose over tolerance","expected":["underfull",1563,"very_loose"],"passed":true},{"actual":["ok",0,"decent"],"check":"exact natural width","expected":["ok",0,"decent"],"passed":true},{"actual":["underfull",10000,"very_loose"],"check":"control layout","expected":["underfull",10000,"very_loose"],"passed":true},{"actual":["ok",34,"loose"],"check":"control layout","expected":["ok",34,"loose"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: badness rounding stage\", \"actual\": [\"ok\", 51, \"loose\"], \"expected\": [\"ok\", 61, \"loose\"], \"passed\": false}, {\"check\": \"regression: badness rounding stage\", \"actual\": [\"underfull\", 1968, \"very_loose\"], \"expected\": [\"underfull\", 1896, \"very_loose\"], \"passed\": false}, {\"check\": \"half stretch ratio rounds 12.5 up\", \"actual\": [\"ok\", 13, \"decent\"], \"expected\": [\"ok\", 13, \"decent\"], \"passed\": true}, {\"check\": \"partial-repair probe\", \"actual\": [\"underfull\", 1563, \"very_loose\"], \"expected\": [\"underfull\", 1563, \"very_loose\"], \"passed\": true}, {\"check\": \"very loose over tolerance\", \"actual\": [\"underfull\", 1563, \"very_loose\"], \"expected\": [\"underfull\", 1563, \"very_loose\"], \"passed\": true}, {\"check\": \"exact natural width\", \"actual\": [\"ok\", 0, \"decent\"], \"expected\": [\"ok\", 0, \"decent\"], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [\"underfull\", 10000, \"very_loose\"], \"expected\": [\"underfull\", 10000, \"very_loose\"], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [\"ok\", 34, \"loose\"], \"expected\": [\"ok\", 34, \"loose\"], \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}