{"abstract":"Short pieces open rows that tall pieces then extend, wasting fabric.","category":"Knitting and sewing pattern grading","checks":8,"contract":"Pieces [w, h, qty] (cm; w across the fabric). A piece wider than the fabric is rotated if the fabric is not directional and its height fits, else \"error: piece too wide\". Expand qty, sort by (height, width) descending, then shelf-pack: start a new row when the row width plus the piece would exceed the fabric width; each row is as tall as its tallest piece. Return [length_cm, eighths_of_a_yard] with eighths = ceiling(length/91.44*8).","contract_signature":"pieces, width, directional","evaluation_group":"w2-knitting_and_sewing_pattern_grading-layout-length","failed_approach":"Sorting by width ignores row height.","family":"w2-knitting_and_sewing_pattern_grading-layout-length-layout-sort-order","id":"FA-97576","implementations":{"attempt":{"sha256":"8ea0ad3c2d2c8fe1e6f6974ab6d69eae2c6c569d47ffc344a5dc409ec42209bf","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(pieces, width, directional):\n    items = []\n    for w, h, qty in pieces:\n        for _ in range(qty):\n            if w > width:\n                if directional or h > width:\n                    return 'error: piece too wide'\n                w, h = h, w\n            items.append((h, w))\n    items.sort(key=lambda t: -t[1])\n    length = 0\n    row_w = 0\n    row_h = 0\n    for h, w in items:\n        if row_w + w > width:\n            length += row_h\n            row_w, row_h = 0, 0\n        row_w += w\n        row_h = max(row_h, h)\n    length += row_h\n    return [length, math.ceil(Fraction(length) / Fraction(9144, 100) * 8)]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['two pieces one row', [[[70, 60, 2]], 140, False], [60, 6]],\n  ['rotate wide piece', [[[150, 60, 1]], 140, False], [150, 14]],\n  ['directional wide piece', [[[150, 60, 1]], 140, True], 'error: piece too wide'],\n  ['regression: layout sort order', [[[20, 80, 2], [20, 60, 1], [40, 30, 2]], 110, True], [110, 10]],\n  ['repair check: layout sort order', [[[150, 45, 1], [35, 30, 1], [40, 60, 2], [35, 100, 3]], 140, False],\n   [280, 25]],\n  ['generated control 1', [[[70, 100, 3], [150, 45, 1], [40, 100, 1]], 110, False], [450, 40]],\n  ['generated control 2', [[[35, 45, 2], [55, 45, 1]], 150, True], [45, 4]],\n  ['generated control 3', [[[70, 45, 1]], 110, True], [45, 4]]],\n [['rotate wide piece', [[[150, 60, 1]], 140, False], [150, 14]],\n  ['directional wide piece', [[[150, 60, 1]], 140, True], 'error: piece too wide'],\n  ['exact fit row', [[[55, 80, 2], [40, 45, 1]], 150, False], [80, 7]],\n  ['regression: layout sort order', [[[150, 45, 2], [55, 45, 1]], 140, False], [195, 18]],\n  ['repair check: layout sort order', [[[20, 100, 2], [70, 30, 1], [110, 80, 3]], 110, True], [370, 33]],\n  ['generated control 1', [[[70, 100, 2], [40, 60, 2], [150, 60, 2]], 140, True], 'error: piece too wide'],\n  ['generated control 2', [[[70, 30, 2], [40, 30, 2], [110, 45, 1], [110, 45, 3]], 150, True], [240, 21]],\n  ['generated control 3', [[[110, 30, 1], [150, 100, 1]], 140, True], 'error: piece too wide']],\n [['directional wide piece', [[[150, 60, 1]], 140, True], 'error: piece too wide'],\n  ['exact fit row', [[[55, 80, 2], [40, 45, 1]], 150, False], [80, 7]],\n  ['two pieces one row', [[[70, 60, 2]], 140, False], [60, 6]],\n  ['regression: layout sort order', [[[20, 60, 1], [150, 30, 2], [40, 45, 1]], 110, False], [195, 18]],\n  ['repair check: layout sort order', [[[55, 45, 3], [110, 45, 2], [40, 80, 2]], 150, False], [260, 23]],\n  ['generated control 1', [[[70, 30, 1], [150, 30, 1]], 140, False], [150, 14]],\n  ['generated control 2', [[[20, 45, 1]], 150, False], [45, 4]],\n  ['generated control 3', [[[20, 80, 1]], 110, True], [80, 7]]],\n [['exact fit row', [[[55, 80, 2], [40, 45, 1]], 150, False], [80, 7]],\n  ['two pieces one row', [[[70, 60, 2]], 140, False], [60, 6]],\n  ['rotate wide piece', [[[150, 60, 1]], 140, False], [150, 14]],\n  ['regression: layout sort order', [[[110, 30, 1], [150, 60, 1], [20, 45, 1]], 140, False], [180, 16]],\n  ['repair check: layout sort order', [[[110, 45, 3], [70, 80, 2], [20, 60, 1], [35, 100, 3]], 140, False],\n   [330, 29]],\n  ['generated control 1', [[[35, 30, 3], [55, 80, 3]], 150, True], [190, 17]],\n  ['generated control 2', [[[55, 100, 2]], 110, False], [100, 9]],\n  ['generated control 3', [[[40, 45, 1], [110, 45, 1], [40, 30, 1], [40, 100, 1]], 150, True], [145, 13]]],\n [['two pieces one row', [[[70, 60, 2]], 140, False], [60, 6]],\n  ['rotate wide piece', [[[150, 60, 1]], 140, False], [150, 14]],\n  ['directional wide piece', [[[150, 60, 1]], 140, True], 'error: piece too wide'],\n  ['regression: layout sort order', [[[40, 60, 1], [40, 45, 3], [70, 80, 2]], 110, False], [250, 22]],\n  ['repair check: layout sort order', [[[55, 30, 3], [110, 30, 3], [70, 45, 1]], 150, False], [195, 18]],\n  ['generated control 1', [[[150, 30, 3], [70, 45, 1], [40, 45, 1], [150, 100, 3]], 110, True],\n   'error: piece too wide'],\n  ['generated control 2', [[[55, 80, 2], [110, 45, 2], [20, 80, 2], [40, 45, 1]], 140, True], [250, 22]],\n  ['generated control 3', [[[35, 60, 3], [150, 100, 2], [110, 60, 1], [150, 30, 2]], 150, False], [380, 34]]]]\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":"67389b7b48715c7ba82cf2a9f9f3706d4e3fe25b52856e97a296c44807c2fa16","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(pieces, width, directional):\n    items = []\n    for w, h, qty in pieces:\n        for _ in range(qty):\n            if w > width:\n                if directional or h > width:\n                    return 'error: piece too wide'\n                w, h = h, w\n            items.append((h, w))\n    items.sort()\n    length = 0\n    row_w = 0\n    row_h = 0\n    for h, w in items:\n        if row_w + w > width:\n            length += row_h\n            row_w, row_h = 0, 0\n        row_w += w\n        row_h = max(row_h, h)\n    length += row_h\n    return [length, math.ceil(Fraction(length) / Fraction(9144, 100) * 8)]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['two pieces one row', [[[70, 60, 2]], 140, False], [60, 6]],\n  ['rotate wide piece', [[[150, 60, 1]], 140, False], [150, 14]],\n  ['directional wide piece', [[[150, 60, 1]], 140, True], 'error: piece too wide'],\n  ['regression: layout sort order', [[[20, 80, 2], [20, 60, 1], [40, 30, 2]], 110, True], [110, 10]],\n  ['repair check: layout sort order', [[[150, 45, 1], [35, 30, 1], [40, 60, 2], [35, 100, 3]], 140, False],\n   [280, 25]],\n  ['generated control 1', [[[70, 100, 3], [150, 45, 1], [40, 100, 1]], 110, False], [450, 40]],\n  ['generated control 2', [[[35, 45, 2], [55, 45, 1]], 150, True], [45, 4]],\n  ['generated control 3', [[[70, 45, 1]], 110, True], [45, 4]]],\n [['rotate wide piece', [[[150, 60, 1]], 140, False], [150, 14]],\n  ['directional wide piece', [[[150, 60, 1]], 140, True], 'error: piece too wide'],\n  ['exact fit row', [[[55, 80, 2], [40, 45, 1]], 150, False], [80, 7]],\n  ['regression: layout sort order', [[[150, 45, 2], [55, 45, 1]], 140, False], [195, 18]],\n  ['repair check: layout sort order', [[[20, 100, 2], [70, 30, 1], [110, 80, 3]], 110, True], [370, 33]],\n  ['generated control 1', [[[70, 100, 2], [40, 60, 2], [150, 60, 2]], 140, True], 'error: piece too wide'],\n  ['generated control 2', [[[70, 30, 2], [40, 30, 2], [110, 45, 1], [110, 45, 3]], 150, True], [240, 21]],\n  ['generated control 3', [[[110, 30, 1], [150, 100, 1]], 140, True], 'error: piece too wide']],\n [['directional wide piece', [[[150, 60, 1]], 140, True], 'error: piece too wide'],\n  ['exact fit row', [[[55, 80, 2], [40, 45, 1]], 150, False], [80, 7]],\n  ['two pieces one row', [[[70, 60, 2]], 140, False], [60, 6]],\n  ['regression: layout sort order', [[[20, 60, 1], [150, 30, 2], [40, 45, 1]], 110, False], [195, 18]],\n  ['repair check: layout sort order', [[[55, 45, 3], [110, 45, 2], [40, 80, 2]], 150, False], [260, 23]],\n  ['generated control 1', [[[70, 30, 1], [150, 30, 1]], 140, False], [150, 14]],\n  ['generated control 2', [[[20, 45, 1]], 150, False], [45, 4]],\n  ['generated control 3', [[[20, 80, 1]], 110, True], [80, 7]]],\n [['exact fit row', [[[55, 80, 2], [40, 45, 1]], 150, False], [80, 7]],\n  ['two pieces one row', [[[70, 60, 2]], 140, False], [60, 6]],\n  ['rotate wide piece', [[[150, 60, 1]], 140, False], [150, 14]],\n  ['regression: layout sort order', [[[110, 30, 1], [150, 60, 1], [20, 45, 1]], 140, False], [180, 16]],\n  ['repair check: layout sort order', [[[110, 45, 3], [70, 80, 2], [20, 60, 1], [35, 100, 3]], 140, False],\n   [330, 29]],\n  ['generated control 1', [[[35, 30, 3], [55, 80, 3]], 150, True], [190, 17]],\n  ['generated control 2', [[[55, 100, 2]], 110, False], [100, 9]],\n  ['generated control 3', [[[40, 45, 1], [110, 45, 1], [40, 30, 1], [40, 100, 1]], 150, True], [145, 13]]],\n [['two pieces one row', [[[70, 60, 2]], 140, False], [60, 6]],\n  ['rotate wide piece', [[[150, 60, 1]], 140, False], [150, 14]],\n  ['directional wide piece', [[[150, 60, 1]], 140, True], 'error: piece too wide'],\n  ['regression: layout sort order', [[[40, 60, 1], [40, 45, 3], [70, 80, 2]], 110, False], [250, 22]],\n  ['repair check: layout sort order', [[[55, 30, 3], [110, 30, 3], [70, 45, 1]], 150, False], [195, 18]],\n  ['generated control 1', [[[150, 30, 3], [70, 45, 1], [40, 45, 1], [150, 100, 3]], 110, True],\n   'error: piece too wide'],\n  ['generated control 2', [[[55, 80, 2], [110, 45, 2], [20, 80, 2], [40, 45, 1]], 140, True], [250, 22]],\n  ['generated control 3', [[[35, 60, 3], [150, 100, 2], [110, 60, 1], [150, 30, 2]], 150, False], [380, 34]]]]\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 contract stated in full here; it is a bounded teaching model, not an authoritative reference or standards implementation. 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-knitting_and_sewing_pattern_grading-layout-length-layout-sort-order","generated_at":"2026-09-29T14:52:33.505976+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Pattern envelopes and cutting planners estimate yardage from piece layouts and nap direction.","root_cause":"Pieces are packed shortest first.","sha256":"65c1e428bf6c729d7fb13b1bea1a06813881841a13e4f2d6bb36451fa4072236","title":"Cutting layout fabric length: layout sort order · 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.058,"exit_code":1,"observations":[{"actual":[60,6],"check":"two pieces one row","expected":[60,6],"passed":true},{"actual":[150,14],"check":"rotate wide piece","expected":[150,14],"passed":true},{"actual":"error: piece too wide","check":"directional wide piece","expected":"error: piece too wide","passed":true},{"actual":[160,14],"check":"regression: layout sort order","expected":[110,10],"passed":false},{"actual":[250,22],"check":"repair check: layout sort order","expected":[280,25],"passed":false},{"actual":[450,40],"check":"generated control 1","expected":[450,40],"passed":true},{"actual":[45,4],"check":"generated control 2","expected":[45,4],"passed":true},{"actual":[45,4],"check":"generated control 3","expected":[45,4],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"two pieces one row\", \"actual\": [60, 6], \"expected\": [60, 6], \"passed\": true}, {\"check\": \"rotate wide piece\", \"actual\": [150, 14], \"expected\": [150, 14], \"passed\": true}, {\"check\": \"directional wide piece\", \"actual\": \"error: piece too wide\", \"expected\": \"error: piece too wide\", \"passed\": true}, {\"check\": \"regression: layout sort order\", \"actual\": [160, 14], \"expected\": [110, 10], \"passed\": false}, {\"check\": \"repair check: layout sort order\", \"actual\": [250, 22], \"expected\": [280, 25], \"passed\": false}, {\"check\": \"generated control 1\", \"actual\": [450, 40], \"expected\": [450, 40], \"passed\": true}, {\"check\": \"generated control 2\", \"actual\": [45, 4], \"expected\": [45, 4], \"passed\": true}, {\"check\": \"generated control 3\", \"actual\": [45, 4], \"expected\": [45, 4], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":44.795,"exit_code":1,"observations":[{"actual":[60,6],"check":"two pieces one row","expected":[60,6],"passed":true},{"actual":[150,14],"check":"rotate wide piece","expected":[150,14],"passed":true},{"actual":"error: piece too wide","check":"directional wide piece","expected":"error: piece too wide","passed":true},{"actual":[140,13],"check":"regression: layout sort order","expected":[110,10],"passed":false},{"actual":[310,28],"check":"repair check: layout sort order","expected":[280,25],"passed":false},{"actual":[450,40],"check":"generated control 1","expected":[450,40],"passed":true},{"actual":[45,4],"check":"generated control 2","expected":[45,4],"passed":true},{"actual":[45,4],"check":"generated control 3","expected":[45,4],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"two pieces one row\", \"actual\": [60, 6], \"expected\": [60, 6], \"passed\": true}, {\"check\": \"rotate wide piece\", \"actual\": [150, 14], \"expected\": [150, 14], \"passed\": true}, {\"check\": \"directional wide piece\", \"actual\": \"error: piece too wide\", \"expected\": \"error: piece too wide\", \"passed\": true}, {\"check\": \"regression: layout sort order\", \"actual\": [140, 13], \"expected\": [110, 10], \"passed\": false}, {\"check\": \"repair check: layout sort order\", \"actual\": [310, 28], \"expected\": [280, 25], \"passed\": false}, {\"check\": \"generated control 1\", \"actual\": [450, 40], \"expected\": [450, 40], \"passed\": true}, {\"check\": \"generated control 2\", \"actual\": [45, 4], \"expected\": [45, 4], \"passed\": true}, {\"check\": \"generated control 3\", \"actual\": [45, 4], \"expected\": [45, 4], \"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."}}