{"abstract":"A 22-stitch need in a 4-stitch rib casts on 20 instead of 24 whenever the raw count is past half a repeat.","category":"Knitting and sewing pattern grading","checks":8,"contract":"Target width = width + ease (ease may be negative). Raw stitches = target * gauge / 10 (gauge per 10 cm). Body stitches = nearest multiple of repeat, half-up in repeat units, at least one repeat. Cast on = body + 2*edge (selvedge each side). Actual body width = body*10/gauge, half-up to 0.1 cm. Non-positive target, gauge or repeat returns an error string.","evaluation_group":"w2-knitting_and_sewing_pattern_grading-gauge-cast-on","failed_approach":"Rounding to the nearest stitch ignores the repeat, so the rib does not close.","family":"w2-knitting_and_sewing_pattern_grading-gauge-cast-on-repeat-rounding","id":"FA-97351","implementations":{"attempt":{"sha256":"946b6f2ca2834c2d714d49c52666c222a8be4a729f6d187cc2e71577c79e5502","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(width_cm, sts_per_10cm, repeat, edge, ease_cm):\n    w = Fraction(str(width_cm)) + Fraction(str(ease_cm))\n    g = Fraction(str(sts_per_10cm))\n    if w <= 0 or g <= 0 or repeat < 1:\n        return 'error: bad measurements'\n    raw = w * g / 10\n    body = math.floor(raw + Fraction(1, 2))\n    body = max(repeat, body)\n    total = body + 2 * edge\n    actual = body * 10 / g\n    return [total, math.floor(actual * 10 + Fraction(1, 2)) / 10]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['plain stockinette', [50, '20', 1, 0, 0], [100, 50.0]],\n  ['rib with selvedges', [45, '22', 4, 1, 5], [114, 50.9]],\n  ['narrow strap one repeat', [3, '16', 8, 2, 0], [12, 5.0]],\n  ['regression: repeat rounding', [50, '24', 8, 0, 5], [136, 56.7]],\n  ['repair check: repeat rounding', [10, '22', 12, 2, 7.5], [40, 16.4]],\n  ['generated control 1', [10, '18', 8, 2, -5], [12, 4.4]],\n  ['generated control 2', [40, '18', 2, 3, 10], [96, 50.0]],\n  ['generated control 3', [40, '20', 4, 2, 5], [96, 46.0]]],\n [['rib with selvedges', [45, '22', 4, 1, 5], [114, 50.9]],\n  ['narrow strap one repeat', [3, '16', 8, 2, 0], [12, 5.0]],\n  ['negative ease', [40, '24', 2, 1, -5], [86, 35.0]],\n  ['regression: repeat rounding', [52.5, '18', 1, 0, 5], [104, 57.8]],\n  ['repair check: repeat rounding', [10, '22', 12, 2, 5], [40, 16.4]],\n  ['generated control 1', [45, '24', 4, 2, 10], [136, 55.0]],\n  ['generated control 2', [50, '27.5', 2, 1, 7.5], [160, 57.5]],\n  ['generated control 3', [3, '27.5', 1, 2, 5], [26, 8.0]]],\n [['narrow strap one repeat', [3, '16', 8, 2, 0], [12, 5.0]],\n  ['negative ease', [40, '24', 2, 1, -5], [86, 35.0]],\n  ['invalid width', [3, '20', 2, 0, -5], 'error: bad measurements'],\n  ['regression: repeat rounding', [3, '22', 6, 0, 10], [30, 13.6]],\n  ['repair check: repeat rounding', [50, '18', 4, 0, 0], [92, 51.1]],\n  ['generated control 1', [40, '20', 2, 3, -5], [76, 35.0]],\n  ['generated control 2', [40, '24', 6, 0, 7.5], [114, 47.5]],\n  ['generated control 3', [50, '20', 8, 2, -2], [100, 48.0]]],\n [['negative ease', [40, '24', 2, 1, -5], [86, 35.0]],\n  ['invalid width', [3, '20', 2, 0, -5], 'error: bad measurements'],\n  ['plain stockinette', [50, '20', 1, 0, 0], [100, 50.0]],\n  ['regression: repeat rounding', [3, '18', 1, 1, -2], [4, 1.1]],\n  ['repair check: repeat rounding', [52.5, '27.5', 6, 2, 10], [178, 63.3]],\n  ['generated control 1', [45, '27.5', 4, 0, -2], [120, 43.6]],\n  ['generated control 2', [45, '20', 12, 0, 10], [108, 54.0]],\n  ['generated control 3', [3, '18', 6, 0, -2], [6, 3.3]]],\n [['invalid width', [3, '20', 2, 0, -5], 'error: bad measurements'],\n  ['plain stockinette', [50, '20', 1, 0, 0], [100, 50.0]],\n  ['rib with selvedges', [45, '22', 4, 1, 5], [114, 50.9]],\n  ['regression: repeat rounding', [30, '20', 4, 1, -5], [54, 26.0]],\n  ['repair check: repeat rounding', [3, '27.5', 8, 2, 10], [36, 11.6]],\n  ['generated control 1', [50, '16', 2, 3, 0], [86, 50.0]],\n  ['generated control 2', [50, '20', 2, 1, 5], [112, 55.0]],\n  ['generated control 3', [45, '24', 12, 2, 0], [112, 45.0]]]]\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":"f4f1fc999fbe9600fbcfafe2672a43b2dc1722fbf11e30989fe94c5ad97a8953","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(width_cm, sts_per_10cm, repeat, edge, ease_cm):\n    w = Fraction(str(width_cm)) + Fraction(str(ease_cm))\n    g = Fraction(str(sts_per_10cm))\n    if w <= 0 or g <= 0 or repeat < 1:\n        return 'error: bad measurements'\n    raw = w * g / 10\n    body = repeat * math.floor(raw / repeat)\n    body = max(repeat, body)\n    total = body + 2 * edge\n    actual = body * 10 / g\n    return [total, math.floor(actual * 10 + Fraction(1, 2)) / 10]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['plain stockinette', [50, '20', 1, 0, 0], [100, 50.0]],\n  ['rib with selvedges', [45, '22', 4, 1, 5], [114, 50.9]],\n  ['narrow strap one repeat', [3, '16', 8, 2, 0], [12, 5.0]],\n  ['regression: repeat rounding', [50, '24', 8, 0, 5], [136, 56.7]],\n  ['repair check: repeat rounding', [10, '22', 12, 2, 7.5], [40, 16.4]],\n  ['generated control 1', [10, '18', 8, 2, -5], [12, 4.4]],\n  ['generated control 2', [40, '18', 2, 3, 10], [96, 50.0]],\n  ['generated control 3', [40, '20', 4, 2, 5], [96, 46.0]]],\n [['rib with selvedges', [45, '22', 4, 1, 5], [114, 50.9]],\n  ['narrow strap one repeat', [3, '16', 8, 2, 0], [12, 5.0]],\n  ['negative ease', [40, '24', 2, 1, -5], [86, 35.0]],\n  ['regression: repeat rounding', [52.5, '18', 1, 0, 5], [104, 57.8]],\n  ['repair check: repeat rounding', [10, '22', 12, 2, 5], [40, 16.4]],\n  ['generated control 1', [45, '24', 4, 2, 10], [136, 55.0]],\n  ['generated control 2', [50, '27.5', 2, 1, 7.5], [160, 57.5]],\n  ['generated control 3', [3, '27.5', 1, 2, 5], [26, 8.0]]],\n [['narrow strap one repeat', [3, '16', 8, 2, 0], [12, 5.0]],\n  ['negative ease', [40, '24', 2, 1, -5], [86, 35.0]],\n  ['invalid width', [3, '20', 2, 0, -5], 'error: bad measurements'],\n  ['regression: repeat rounding', [3, '22', 6, 0, 10], [30, 13.6]],\n  ['repair check: repeat rounding', [50, '18', 4, 0, 0], [92, 51.1]],\n  ['generated control 1', [40, '20', 2, 3, -5], [76, 35.0]],\n  ['generated control 2', [40, '24', 6, 0, 7.5], [114, 47.5]],\n  ['generated control 3', [50, '20', 8, 2, -2], [100, 48.0]]],\n [['negative ease', [40, '24', 2, 1, -5], [86, 35.0]],\n  ['invalid width', [3, '20', 2, 0, -5], 'error: bad measurements'],\n  ['plain stockinette', [50, '20', 1, 0, 0], [100, 50.0]],\n  ['regression: repeat rounding', [3, '18', 1, 1, -2], [4, 1.1]],\n  ['repair check: repeat rounding', [52.5, '27.5', 6, 2, 10], [178, 63.3]],\n  ['generated control 1', [45, '27.5', 4, 0, -2], [120, 43.6]],\n  ['generated control 2', [45, '20', 12, 0, 10], [108, 54.0]],\n  ['generated control 3', [3, '18', 6, 0, -2], [6, 3.3]]],\n [['invalid width', [3, '20', 2, 0, -5], 'error: bad measurements'],\n  ['plain stockinette', [50, '20', 1, 0, 0], [100, 50.0]],\n  ['rib with selvedges', [45, '22', 4, 1, 5], [114, 50.9]],\n  ['regression: repeat rounding', [30, '20', 4, 1, -5], [54, 26.0]],\n  ['repair check: repeat rounding', [3, '27.5', 8, 2, 10], [36, 11.6]],\n  ['generated control 1', [50, '16', 2, 3, 0], [86, 50.0]],\n  ['generated control 2', [50, '20', 2, 1, 5], [112, 55.0]],\n  ['generated control 3', [45, '24', 12, 2, 0], [112, 45.0]]]]\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"},"fixed":{"sha256":"bdff7c2f3972582c72bd35ed8fa24512ce6008586da24c0776345e688b4b02e4","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(width_cm, sts_per_10cm, repeat, edge, ease_cm):\n    w = Fraction(str(width_cm)) + Fraction(str(ease_cm))\n    g = Fraction(str(sts_per_10cm))\n    if w <= 0 or g <= 0 or repeat < 1:\n        return 'error: bad measurements'\n    raw = w * g / 10\n    body = repeat * math.floor(raw / repeat + Fraction(1, 2))\n    body = max(repeat, body)\n    total = body + 2 * edge\n    actual = body * 10 / g\n    return [total, math.floor(actual * 10 + Fraction(1, 2)) / 10]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['plain stockinette', [50, '20', 1, 0, 0], [100, 50.0]],\n  ['rib with selvedges', [45, '22', 4, 1, 5], [114, 50.9]],\n  ['narrow strap one repeat', [3, '16', 8, 2, 0], [12, 5.0]],\n  ['regression: repeat rounding', [50, '24', 8, 0, 5], [136, 56.7]],\n  ['repair check: repeat rounding', [10, '22', 12, 2, 7.5], [40, 16.4]],\n  ['generated control 1', [10, '18', 8, 2, -5], [12, 4.4]],\n  ['generated control 2', [40, '18', 2, 3, 10], [96, 50.0]],\n  ['generated control 3', [40, '20', 4, 2, 5], [96, 46.0]]],\n [['rib with selvedges', [45, '22', 4, 1, 5], [114, 50.9]],\n  ['narrow strap one repeat', [3, '16', 8, 2, 0], [12, 5.0]],\n  ['negative ease', [40, '24', 2, 1, -5], [86, 35.0]],\n  ['regression: repeat rounding', [52.5, '18', 1, 0, 5], [104, 57.8]],\n  ['repair check: repeat rounding', [10, '22', 12, 2, 5], [40, 16.4]],\n  ['generated control 1', [45, '24', 4, 2, 10], [136, 55.0]],\n  ['generated control 2', [50, '27.5', 2, 1, 7.5], [160, 57.5]],\n  ['generated control 3', [3, '27.5', 1, 2, 5], [26, 8.0]]],\n [['narrow strap one repeat', [3, '16', 8, 2, 0], [12, 5.0]],\n  ['negative ease', [40, '24', 2, 1, -5], [86, 35.0]],\n  ['invalid width', [3, '20', 2, 0, -5], 'error: bad measurements'],\n  ['regression: repeat rounding', [3, '22', 6, 0, 10], [30, 13.6]],\n  ['repair check: repeat rounding', [50, '18', 4, 0, 0], [92, 51.1]],\n  ['generated control 1', [40, '20', 2, 3, -5], [76, 35.0]],\n  ['generated control 2', [40, '24', 6, 0, 7.5], [114, 47.5]],\n  ['generated control 3', [50, '20', 8, 2, -2], [100, 48.0]]],\n [['negative ease', [40, '24', 2, 1, -5], [86, 35.0]],\n  ['invalid width', [3, '20', 2, 0, -5], 'error: bad measurements'],\n  ['plain stockinette', [50, '20', 1, 0, 0], [100, 50.0]],\n  ['regression: repeat rounding', [3, '18', 1, 1, -2], [4, 1.1]],\n  ['repair check: repeat rounding', [52.5, '27.5', 6, 2, 10], [178, 63.3]],\n  ['generated control 1', [45, '27.5', 4, 0, -2], [120, 43.6]],\n  ['generated control 2', [45, '20', 12, 0, 10], [108, 54.0]],\n  ['generated control 3', [3, '18', 6, 0, -2], [6, 3.3]]],\n [['invalid width', [3, '20', 2, 0, -5], 'error: bad measurements'],\n  ['plain stockinette', [50, '20', 1, 0, 0], [100, 50.0]],\n  ['rib with selvedges', [45, '22', 4, 1, 5], [114, 50.9]],\n  ['regression: repeat rounding', [30, '20', 4, 1, -5], [54, 26.0]],\n  ['repair check: repeat rounding', [3, '27.5', 8, 2, 10], [36, 11.6]],\n  ['generated control 1', [50, '16', 2, 3, 0], [86, 50.0]],\n  ['generated control 2', [50, '20', 2, 1, 5], [112, 55.0]],\n  ['generated control 3', [45, '24', 12, 2, 0], [112, 45.0]]]]\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-gauge-cast-on-repeat-rounding","generated_at":"2026-09-29T14:52:31.369694+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Knitting patterns and calculators convert a finished measurement and gauge into a stitch count that fits the stitch pattern repeat.","repair":"Round raw stitches to the nearest multiple of the repeat.","root_cause":"Stitches are floored to a whole repeat instead of rounded to the nearest repeat.","sha256":"f6fe607b42787ef15bfbaf1797a336dff2204b434723b90b9d0700200578cb3c","title":"Gauge-based cast-on calculator: repeat rounding · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":44.651,"exit_code":1,"observations":[{"actual":[100,50.0],"check":"plain stockinette","expected":[100,50.0],"passed":true},{"actual":[112,50.0],"check":"rib with selvedges","expected":[114,50.9],"passed":false},{"actual":[12,5.0],"check":"narrow strap one repeat","expected":[12,5.0],"passed":true},{"actual":[132,55.0],"check":"regression: repeat rounding","expected":[136,56.7],"passed":false},{"actual":[43,17.7],"check":"repair check: repeat rounding","expected":[40,16.4],"passed":false},{"actual":[13,5.0],"check":"generated control 1","expected":[12,4.4],"passed":false},{"actual":[96,50.0],"check":"generated control 2","expected":[96,50.0],"passed":true},{"actual":[94,45.0],"check":"generated control 3","expected":[96,46.0],"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"plain stockinette\", \"actual\": [100, 50.0], \"expected\": [100, 50.0], \"passed\": true}, {\"check\": \"rib with selvedges\", \"actual\": [112, 50.0], \"expected\": [114, 50.9], \"passed\": false}, {\"check\": \"narrow strap one repeat\", \"actual\": [12, 5.0], \"expected\": [12, 5.0], \"passed\": true}, {\"check\": \"regression: repeat rounding\", \"actual\": [132, 55.0], \"expected\": [136, 56.7], \"passed\": false}, {\"check\": \"repair check: repeat rounding\", \"actual\": [43, 17.7], \"expected\": [40, 16.4], \"passed\": false}, {\"check\": \"generated control 1\", \"actual\": [13, 5.0], \"expected\": [12, 4.4], \"passed\": false}, {\"check\": \"generated control 2\", \"actual\": [96, 50.0], \"expected\": [96, 50.0], \"passed\": true}, {\"check\": \"generated control 3\", \"actual\": [94, 45.0], \"expected\": [96, 46.0], \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":46.013,"exit_code":1,"observations":[{"actual":[100,50.0],"check":"plain stockinette","expected":[100,50.0],"passed":true},{"actual":[110,49.1],"check":"rib with selvedges","expected":[114,50.9],"passed":false},{"actual":[12,5.0],"check":"narrow strap one repeat","expected":[12,5.0],"passed":true},{"actual":[128,53.3],"check":"regression: repeat rounding","expected":[136,56.7],"passed":false},{"actual":[40,16.4],"check":"repair check: repeat rounding","expected":[40,16.4],"passed":true},{"actual":[12,4.4],"check":"generated control 1","expected":[12,4.4],"passed":true},{"actual":[96,50.0],"check":"generated control 2","expected":[96,50.0],"passed":true},{"actual":[92,44.0],"check":"generated control 3","expected":[96,46.0],"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"plain stockinette\", \"actual\": [100, 50.0], \"expected\": [100, 50.0], \"passed\": true}, {\"check\": \"rib with selvedges\", \"actual\": [110, 49.1], \"expected\": [114, 50.9], \"passed\": false}, {\"check\": \"narrow strap one repeat\", \"actual\": [12, 5.0], \"expected\": [12, 5.0], \"passed\": true}, {\"check\": \"regression: repeat rounding\", \"actual\": [128, 53.3], \"expected\": [136, 56.7], \"passed\": false}, {\"check\": \"repair check: repeat rounding\", \"actual\": [40, 16.4], \"expected\": [40, 16.4], \"passed\": true}, {\"check\": \"generated control 1\", \"actual\": [12, 4.4], \"expected\": [12, 4.4], \"passed\": true}, {\"check\": \"generated control 2\", \"actual\": [96, 50.0], \"expected\": [96, 50.0], \"passed\": true}, {\"check\": \"generated control 3\", \"actual\": [92, 44.0], \"expected\": [96, 46.0], \"passed\": false}], \"passed\": false}\n"},"fixed":{"elapsed_ms":47.938,"exit_code":0,"observations":[{"actual":[100,50.0],"check":"plain stockinette","expected":[100,50.0],"passed":true},{"actual":[114,50.9],"check":"rib with selvedges","expected":[114,50.9],"passed":true},{"actual":[12,5.0],"check":"narrow strap one repeat","expected":[12,5.0],"passed":true},{"actual":[136,56.7],"check":"regression: repeat rounding","expected":[136,56.7],"passed":true},{"actual":[40,16.4],"check":"repair check: repeat rounding","expected":[40,16.4],"passed":true},{"actual":[12,4.4],"check":"generated control 1","expected":[12,4.4],"passed":true},{"actual":[96,50.0],"check":"generated control 2","expected":[96,50.0],"passed":true},{"actual":[96,46.0],"check":"generated control 3","expected":[96,46.0],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"plain stockinette\", \"actual\": [100, 50.0], \"expected\": [100, 50.0], \"passed\": true}, {\"check\": \"rib with selvedges\", \"actual\": [114, 50.9], \"expected\": [114, 50.9], \"passed\": true}, {\"check\": \"narrow strap one repeat\", \"actual\": [12, 5.0], \"expected\": [12, 5.0], \"passed\": true}, {\"check\": \"regression: repeat rounding\", \"actual\": [136, 56.7], \"expected\": [136, 56.7], \"passed\": true}, {\"check\": \"repair check: repeat rounding\", \"actual\": [40, 16.4], \"expected\": [40, 16.4], \"passed\": true}, {\"check\": \"generated control 1\", \"actual\": [12, 4.4], \"expected\": [12, 4.4], \"passed\": true}, {\"check\": \"generated control 2\", \"actual\": [96, 50.0], \"expected\": [96, 50.0], \"passed\": true}, {\"check\": \"generated control 3\", \"actual\": [96, 46.0], \"expected\": [96, 46.0], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}