FA-97546 / Knitting and sewing pattern grading / Open access
Pattern size selector: inch conversion · case 01
A 36 inch bust is sized XS.
ROOT CAUSE
Inches are divided by 2.54 instead of multiplied.
VERIFIED REPAIR
Multiply inches by 2.54.
Unsuccessful approach: Rounding to 2.5 cm per inch shifts sizes near the tolerance edge.
Case contract
Chart (cm) XS 80/62/86, S 86/68/92, M 92/74/98, L 100/82/106, XL 108/90/114 (bust/waist/hip). Inches convert at 2.54. A size fits a measurement when chart + 1 cm >= body; pick the smallest fitting size. top: by bust; skirt: the larger of waist size and hip size; dress: bust size and hip size, same -> that size, else "grade A to B" (bust size to hip size). No fitting size -> "out of range"; other garments -> "error: garment".
Why this case matters
Sewists choose a pattern size per body zone and grade between sizes.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(bust, waist, hip, garment, units):
CHART = [['XS', 80, 62, 86], ['S', 86, 68, 92], ['M', 92, 74, 98], ['L', 100, 82, 106], ['XL', 108, 90, 114]]
ORDER = [row[0] for row in CHART]
k = 1 / Fraction(254, 100) if units == 'in' else Fraction(1)
b, w, h = (Fraction(str(v)) * k for v in (bust, waist, hip))
def pick(col, v):
for row in CHART:
if row[col] + 1 >= v:
return row[0]
return None
if garment == 'top':
s = pick(1, b)
return s if s else 'out of range'
if garment == 'skirt':
a, c = pick(2, w), pick(3, h)
if not a or not c:
return 'out of range'
return max(a, c, key=ORDER.index)
if garment == 'dress':
a, c = pick(1, b), pick(3, h)
if not a or not c:
return 'out of range'
return a if a == c else 'grade %s to %s' % (a, c)
return 'error: garment'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['top within tolerance', [93, 70, 95, 'top', 'cm'], 'M'],
['skirt waist governs', [90, 80, 95, 'skirt', 'cm'], 'L'],
['dress grade', [86, 70, 104, 'dress', 'cm'], 'grade S to L'],
['regression: inch conversion', [34, 27, 38, 'skirt', 'in'], 'M'],
['repair check: inch conversion', [40, 25, 40, 'dress', 'in'], 'grade XL to L'],
['generated control 1', [80, 89, 93, 'skirt', 'cm'], 'XL'],
['generated control 2', [108, 74, 94, 'coat', 'cm'], 'error: garment'],
['generated control 3', [106, 70, 94, 'dress', 'cm'], 'grade XL to M']],
[['skirt waist governs', [90, 80, 95, 'skirt', 'cm'], 'L'],
['dress grade', [86, 70, 104, 'dress', 'cm'], 'grade S to L'],
['inches top', [36, 28, 38, 'top', 'in'], 'M'],
['regression: inch conversion', [42.5, 25, 34, 'dress', 'in'], 'grade XL to XS'],
['repair check: inch conversion', [40, 25, 36, 'top', 'in'], 'XL'],
['generated control 1', [34, 27, 36, 'coat', 'in'], 'error: garment'],
['generated control 2', [42.5, 31, 43, 'dress', 'in'], 'XL'],
['generated control 3', [34, 31, 40, 'skirt', 'in'], 'L']],
[['dress grade', [86, 70, 104, 'dress', 'cm'], 'grade S to L'],
['inches top', [36, 28, 38, 'top', 'in'], 'M'],
['out of range dress', [120, 90, 100, 'dress', 'cm'], 'out of range'],
['regression: inch conversion', [34, 34, 36, 'top', 'in'], 'S'],
['repair check: inch conversion', [40, 31, 40, 'dress', 'in'], 'grade XL to L'],
['generated control 1', [93, 61, 88, 'coat', 'cm'], 'error: garment'],
['generated control 2', [91, 85, 118, 'skirt', 'cm'], 'out of range'],
['generated control 3', [79, 78, 106, 'skirt', 'cm'], 'L']],
[['inches top', [36, 28, 38, 'top', 'in'], 'M'],
['out of range dress', [120, 90, 100, 'dress', 'cm'], 'out of range'],
['top within tolerance', [93, 70, 95, 'top', 'cm'], 'M'],
['regression: inch conversion', [40, 27, 38, 'dress', 'in'], 'grade XL to M'],
['repair check: inch conversion', [32, 25, 34, 'skirt', 'in'], 'S'],
['generated control 1', [96, 93, 95, 'skirt', 'cm'], 'out of range'],
['generated control 2', [95, 78, 107, 'dress', 'cm'], 'L'],
['generated control 3', [110, 94, 112, 'dress', 'cm'], 'out of range']],
[['out of range dress', [120, 90, 100, 'dress', 'cm'], 'out of range'],
['top within tolerance', [93, 70, 95, 'top', 'cm'], 'M'],
['skirt waist governs', [90, 80, 95, 'skirt', 'cm'], 'L'],
['regression: inch conversion', [34, 34, 38, 'dress', 'in'], 'grade S to M'],
['repair check: inch conversion', [40, 25, 38, 'top', 'in'], 'XL'],
['generated control 1', [107, 89, 114, 'skirt', 'cm'], 'XL'],
['generated control 2', [111, 89, 90, 'coat', 'cm'], 'error: garment'],
['generated control 3', [82, 85, 85, 'top', 'cm'], 'S']]]
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 |
|---|---|---|---|
| top within tolerance | M | M | Passed |
| skirt waist governs | L | L | Passed |
| dress grade | grade S to L | grade S to L | Passed |
| regression: inch conversion | XS | M | Failed |
| repair check: inch conversion | XS | grade XL to L | Failed |
| generated control 1 | XL | XL | Passed |
| generated control 2 | error: garment | error: garment | Passed |
| generated control 3 | grade XL to M | grade XL to M | Passed |
SHA-256 / c967d25dfbc951e5a20443a20a64eda5bbb50adba692cea3bc7897371c5ae66e
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(bust, waist, hip, garment, units):
CHART = [['XS', 80, 62, 86], ['S', 86, 68, 92], ['M', 92, 74, 98], ['L', 100, 82, 106], ['XL', 108, 90, 114]]
ORDER = [row[0] for row in CHART]
k = Fraction(5, 2) if units == 'in' else Fraction(1)
b, w, h = (Fraction(str(v)) * k for v in (bust, waist, hip))
def pick(col, v):
for row in CHART:
if row[col] + 1 >= v:
return row[0]
return None
if garment == 'top':
s = pick(1, b)
return s if s else 'out of range'
if garment == 'skirt':
a, c = pick(2, w), pick(3, h)
if not a or not c:
return 'out of range'
return max(a, c, key=ORDER.index)
if garment == 'dress':
a, c = pick(1, b), pick(3, h)
if not a or not c:
return 'out of range'
return a if a == c else 'grade %s to %s' % (a, c)
return 'error: garment'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['top within tolerance', [93, 70, 95, 'top', 'cm'], 'M'],
['skirt waist governs', [90, 80, 95, 'skirt', 'cm'], 'L'],
['dress grade', [86, 70, 104, 'dress', 'cm'], 'grade S to L'],
['regression: inch conversion', [34, 27, 38, 'skirt', 'in'], 'M'],
['repair check: inch conversion', [40, 25, 40, 'dress', 'in'], 'grade XL to L'],
['generated control 1', [80, 89, 93, 'skirt', 'cm'], 'XL'],
['generated control 2', [108, 74, 94, 'coat', 'cm'], 'error: garment'],
['generated control 3', [106, 70, 94, 'dress', 'cm'], 'grade XL to M']],
[['skirt waist governs', [90, 80, 95, 'skirt', 'cm'], 'L'],
['dress grade', [86, 70, 104, 'dress', 'cm'], 'grade S to L'],
['inches top', [36, 28, 38, 'top', 'in'], 'M'],
['regression: inch conversion', [42.5, 25, 34, 'dress', 'in'], 'grade XL to XS'],
['repair check: inch conversion', [40, 25, 36, 'top', 'in'], 'XL'],
['generated control 1', [34, 27, 36, 'coat', 'in'], 'error: garment'],
['generated control 2', [42.5, 31, 43, 'dress', 'in'], 'XL'],
['generated control 3', [34, 31, 40, 'skirt', 'in'], 'L']],
[['dress grade', [86, 70, 104, 'dress', 'cm'], 'grade S to L'],
['inches top', [36, 28, 38, 'top', 'in'], 'M'],
['out of range dress', [120, 90, 100, 'dress', 'cm'], 'out of range'],
['regression: inch conversion', [34, 34, 36, 'top', 'in'], 'S'],
['repair check: inch conversion', [40, 31, 40, 'dress', 'in'], 'grade XL to L'],
['generated control 1', [93, 61, 88, 'coat', 'cm'], 'error: garment'],
['generated control 2', [91, 85, 118, 'skirt', 'cm'], 'out of range'],
['generated control 3', [79, 78, 106, 'skirt', 'cm'], 'L']],
[['inches top', [36, 28, 38, 'top', 'in'], 'M'],
['out of range dress', [120, 90, 100, 'dress', 'cm'], 'out of range'],
['top within tolerance', [93, 70, 95, 'top', 'cm'], 'M'],
['regression: inch conversion', [40, 27, 38, 'dress', 'in'], 'grade XL to M'],
['repair check: inch conversion', [32, 25, 34, 'skirt', 'in'], 'S'],
['generated control 1', [96, 93, 95, 'skirt', 'cm'], 'out of range'],
['generated control 2', [95, 78, 107, 'dress', 'cm'], 'L'],
['generated control 3', [110, 94, 112, 'dress', 'cm'], 'out of range']],
[['out of range dress', [120, 90, 100, 'dress', 'cm'], 'out of range'],
['top within tolerance', [93, 70, 95, 'top', 'cm'], 'M'],
['skirt waist governs', [90, 80, 95, 'skirt', 'cm'], 'L'],
['regression: inch conversion', [34, 34, 38, 'dress', 'in'], 'grade S to M'],
['repair check: inch conversion', [40, 25, 38, 'top', 'in'], 'XL'],
['generated control 1', [107, 89, 114, 'skirt', 'cm'], 'XL'],
['generated control 2', [111, 89, 90, 'coat', 'cm'], 'error: garment'],
['generated control 3', [82, 85, 85, 'top', 'cm'], 'S']]]
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 |
|---|---|---|---|
| top within tolerance | M | M | Passed |
| skirt waist governs | L | L | Passed |
| dress grade | grade S to L | grade S to L | Passed |
| regression: inch conversion | M | M | Passed |
| repair check: inch conversion | L | grade XL to L | Failed |
| generated control 1 | XL | XL | Passed |
| generated control 2 | error: garment | error: garment | Passed |
| generated control 3 | grade XL to M | grade XL to M | Passed |
SHA-256 / a39c3a31907695a671bc33e8e3bfc0385f9c628a5951030805db749e55cd1a0c
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(bust, waist, hip, garment, units):
CHART = [['XS', 80, 62, 86], ['S', 86, 68, 92], ['M', 92, 74, 98], ['L', 100, 82, 106], ['XL', 108, 90, 114]]
ORDER = [row[0] for row in CHART]
k = Fraction(254, 100) if units == 'in' else Fraction(1)
b, w, h = (Fraction(str(v)) * k for v in (bust, waist, hip))
def pick(col, v):
for row in CHART:
if row[col] + 1 >= v:
return row[0]
return None
if garment == 'top':
s = pick(1, b)
return s if s else 'out of range'
if garment == 'skirt':
a, c = pick(2, w), pick(3, h)
if not a or not c:
return 'out of range'
return max(a, c, key=ORDER.index)
if garment == 'dress':
a, c = pick(1, b), pick(3, h)
if not a or not c:
return 'out of range'
return a if a == c else 'grade %s to %s' % (a, c)
return 'error: garment'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['top within tolerance', [93, 70, 95, 'top', 'cm'], 'M'],
['skirt waist governs', [90, 80, 95, 'skirt', 'cm'], 'L'],
['dress grade', [86, 70, 104, 'dress', 'cm'], 'grade S to L'],
['regression: inch conversion', [34, 27, 38, 'skirt', 'in'], 'M'],
['repair check: inch conversion', [40, 25, 40, 'dress', 'in'], 'grade XL to L'],
['generated control 1', [80, 89, 93, 'skirt', 'cm'], 'XL'],
['generated control 2', [108, 74, 94, 'coat', 'cm'], 'error: garment'],
['generated control 3', [106, 70, 94, 'dress', 'cm'], 'grade XL to M']],
[['skirt waist governs', [90, 80, 95, 'skirt', 'cm'], 'L'],
['dress grade', [86, 70, 104, 'dress', 'cm'], 'grade S to L'],
['inches top', [36, 28, 38, 'top', 'in'], 'M'],
['regression: inch conversion', [42.5, 25, 34, 'dress', 'in'], 'grade XL to XS'],
['repair check: inch conversion', [40, 25, 36, 'top', 'in'], 'XL'],
['generated control 1', [34, 27, 36, 'coat', 'in'], 'error: garment'],
['generated control 2', [42.5, 31, 43, 'dress', 'in'], 'XL'],
['generated control 3', [34, 31, 40, 'skirt', 'in'], 'L']],
[['dress grade', [86, 70, 104, 'dress', 'cm'], 'grade S to L'],
['inches top', [36, 28, 38, 'top', 'in'], 'M'],
['out of range dress', [120, 90, 100, 'dress', 'cm'], 'out of range'],
['regression: inch conversion', [34, 34, 36, 'top', 'in'], 'S'],
['repair check: inch conversion', [40, 31, 40, 'dress', 'in'], 'grade XL to L'],
['generated control 1', [93, 61, 88, 'coat', 'cm'], 'error: garment'],
['generated control 2', [91, 85, 118, 'skirt', 'cm'], 'out of range'],
['generated control 3', [79, 78, 106, 'skirt', 'cm'], 'L']],
[['inches top', [36, 28, 38, 'top', 'in'], 'M'],
['out of range dress', [120, 90, 100, 'dress', 'cm'], 'out of range'],
['top within tolerance', [93, 70, 95, 'top', 'cm'], 'M'],
['regression: inch conversion', [40, 27, 38, 'dress', 'in'], 'grade XL to M'],
['repair check: inch conversion', [32, 25, 34, 'skirt', 'in'], 'S'],
['generated control 1', [96, 93, 95, 'skirt', 'cm'], 'out of range'],
['generated control 2', [95, 78, 107, 'dress', 'cm'], 'L'],
['generated control 3', [110, 94, 112, 'dress', 'cm'], 'out of range']],
[['out of range dress', [120, 90, 100, 'dress', 'cm'], 'out of range'],
['top within tolerance', [93, 70, 95, 'top', 'cm'], 'M'],
['skirt waist governs', [90, 80, 95, 'skirt', 'cm'], 'L'],
['regression: inch conversion', [34, 34, 38, 'dress', 'in'], 'grade S to M'],
['repair check: inch conversion', [40, 25, 38, 'top', 'in'], 'XL'],
['generated control 1', [107, 89, 114, 'skirt', 'cm'], 'XL'],
['generated control 2', [111, 89, 90, 'coat', 'cm'], 'error: garment'],
['generated control 3', [82, 85, 85, 'top', 'cm'], 'S']]]
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 |
|---|---|---|---|
| top within tolerance | M | M | Passed |
| skirt waist governs | L | L | Passed |
| dress grade | grade S to L | grade S to L | Passed |
| regression: inch conversion | M | M | Passed |
| repair check: inch conversion | grade XL to L | grade XL to L | Passed |
| generated control 1 | XL | XL | Passed |
| generated control 2 | error: garment | error: garment | Passed |
| generated control 3 | grade XL to M | grade XL to M | Passed |
SHA-256 / ff71bbe2452de364a717b647880b59d0d3de9d1e7426980971605d5ca4991018
Verification & scope
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.
Observations recorded using Python 3.12.14 at 2026-09-29T14:52:33.240452+00:00.
Case digest / d9342a64752ba0211a96df7564ba7e77c62480accef4b813f7fc34507c6279e4