FAILURE MAP
← Case archive

FA-97541 / Knitting and sewing pattern grading / Open access

Pattern size selector: dress range check · case 01

A dress for a bust beyond the chart prints "grade None to L".

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

ROOT CAUSE

Out of range is reported only when both zones are off the chart.

VERIFIED REPAIR

Report out of range when either zone has no size.

Unsuccessful approach: Checking only the bust misses hips beyond the chart.

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 = 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 and 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: dress range check', [110, 90, 109, 'dress', 'cm'], 'out of range'],
  ['repair check: dress range check', [84, 90, 116, 'dress', 'cm'], 'out of range'],
  ['generated control 1', [105, 69, 100, 'coat', 'cm'], 'error: garment'],
  ['generated control 2', [93, 87, 106, 'dress', 'cm'], 'grade M to L'],
  ['generated control 3', [79, 83, 108, 'top', 'cm'], 'XS']],
 [['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: dress range check', [95, 93, 118, 'dress', 'cm'], 'out of range'],
  ['repair check: dress range check', [90, 84, 116, 'dress', 'cm'], 'out of range'],
  ['generated control 1', [92, 77, 85, 'dress', 'cm'], 'grade M to XS'],
  ['generated control 2', [81, 83, 96, 'dress', 'cm'], 'grade XS to M'],
  ['generated control 3', [40, 27, 40, 'dress', 'in'], 'grade XL to 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: dress range check', [85, 85, 116, 'dress', 'cm'], 'out of range'],
  ['repair check: dress range check', [87, 74, 117, 'dress', 'cm'], 'out of range'],
  ['generated control 1', [42.5, 34, 43, 'dress', 'in'], 'XL'],
  ['generated control 2', [82, 62, 118, 'top', 'cm'], 'S'],
  ['generated control 3', [101, 67, 106, 'coat', 'cm'], 'error: garment']],
 [['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: dress range check', [95, 80, 117, 'dress', 'cm'], 'out of range'],
  ['repair check: dress range check', [98, 91, 116, 'dress', 'cm'], 'out of range'],
  ['generated control 1', [99, 89, 115, 'skirt', 'cm'], 'XL'],
  ['generated control 2', [32, 29, 36, 'dress', 'in'], 'S'],
  ['generated control 3', [97, 70, 99, 'dress', 'cm'], 'grade L to M']],
 [['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: dress range check', [86, 80, 117, 'dress', 'cm'], 'out of range'],
  ['repair check: dress range check', [85, 83, 117, 'dress', 'cm'], 'out of range'],
  ['generated control 1', [100, 86, 117, 'top', 'cm'], 'L'],
  ['generated control 2', [81, 79, 93, 'dress', 'cm'], 'grade XS to S'],
  ['generated control 3', [32, 25, 40, 'dress', 'in'], 'grade S to L']]]
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
top within toleranceMMPassed
skirt waist governsLLPassed
dress gradegrade S to Lgrade S to LPassed
regression: dress range checkgrade None to XLout of rangeFailed
repair check: dress range checkgrade S to Noneout of rangeFailed
generated control 1error: garmenterror: garmentPassed
generated control 2grade M to Lgrade M to LPassed
generated control 3XSXSPassed

SHA-256 / 6fc077da471500bc878d5cae73f55dedccc01d6e22d11493a9bbf452ccf4ed0f

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(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:
            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: dress range check', [110, 90, 109, 'dress', 'cm'], 'out of range'],
  ['repair check: dress range check', [84, 90, 116, 'dress', 'cm'], 'out of range'],
  ['generated control 1', [105, 69, 100, 'coat', 'cm'], 'error: garment'],
  ['generated control 2', [93, 87, 106, 'dress', 'cm'], 'grade M to L'],
  ['generated control 3', [79, 83, 108, 'top', 'cm'], 'XS']],
 [['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: dress range check', [95, 93, 118, 'dress', 'cm'], 'out of range'],
  ['repair check: dress range check', [90, 84, 116, 'dress', 'cm'], 'out of range'],
  ['generated control 1', [92, 77, 85, 'dress', 'cm'], 'grade M to XS'],
  ['generated control 2', [81, 83, 96, 'dress', 'cm'], 'grade XS to M'],
  ['generated control 3', [40, 27, 40, 'dress', 'in'], 'grade XL to 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: dress range check', [85, 85, 116, 'dress', 'cm'], 'out of range'],
  ['repair check: dress range check', [87, 74, 117, 'dress', 'cm'], 'out of range'],
  ['generated control 1', [42.5, 34, 43, 'dress', 'in'], 'XL'],
  ['generated control 2', [82, 62, 118, 'top', 'cm'], 'S'],
  ['generated control 3', [101, 67, 106, 'coat', 'cm'], 'error: garment']],
 [['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: dress range check', [95, 80, 117, 'dress', 'cm'], 'out of range'],
  ['repair check: dress range check', [98, 91, 116, 'dress', 'cm'], 'out of range'],
  ['generated control 1', [99, 89, 115, 'skirt', 'cm'], 'XL'],
  ['generated control 2', [32, 29, 36, 'dress', 'in'], 'S'],
  ['generated control 3', [97, 70, 99, 'dress', 'cm'], 'grade L to M']],
 [['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: dress range check', [86, 80, 117, 'dress', 'cm'], 'out of range'],
  ['repair check: dress range check', [85, 83, 117, 'dress', 'cm'], 'out of range'],
  ['generated control 1', [100, 86, 117, 'top', 'cm'], 'L'],
  ['generated control 2', [81, 79, 93, 'dress', 'cm'], 'grade XS to S'],
  ['generated control 3', [32, 25, 40, 'dress', 'in'], 'grade S to L']]]
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
top within toleranceMMPassed
skirt waist governsLLPassed
dress gradegrade S to Lgrade S to LPassed
regression: dress range checkout of rangeout of rangePassed
repair check: dress range checkgrade S to Noneout of rangeFailed
generated control 1error: garmenterror: garmentPassed
generated control 2grade M to Lgrade M to LPassed
generated control 3XSXSPassed

SHA-256 / 5d46f3efea68cc1a30a63aa19b40004b41687bdbc7917e99d1504f4efb291f42

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: dress range check', [110, 90, 109, 'dress', 'cm'], 'out of range'],
  ['repair check: dress range check', [84, 90, 116, 'dress', 'cm'], 'out of range'],
  ['generated control 1', [105, 69, 100, 'coat', 'cm'], 'error: garment'],
  ['generated control 2', [93, 87, 106, 'dress', 'cm'], 'grade M to L'],
  ['generated control 3', [79, 83, 108, 'top', 'cm'], 'XS']],
 [['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: dress range check', [95, 93, 118, 'dress', 'cm'], 'out of range'],
  ['repair check: dress range check', [90, 84, 116, 'dress', 'cm'], 'out of range'],
  ['generated control 1', [92, 77, 85, 'dress', 'cm'], 'grade M to XS'],
  ['generated control 2', [81, 83, 96, 'dress', 'cm'], 'grade XS to M'],
  ['generated control 3', [40, 27, 40, 'dress', 'in'], 'grade XL to 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: dress range check', [85, 85, 116, 'dress', 'cm'], 'out of range'],
  ['repair check: dress range check', [87, 74, 117, 'dress', 'cm'], 'out of range'],
  ['generated control 1', [42.5, 34, 43, 'dress', 'in'], 'XL'],
  ['generated control 2', [82, 62, 118, 'top', 'cm'], 'S'],
  ['generated control 3', [101, 67, 106, 'coat', 'cm'], 'error: garment']],
 [['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: dress range check', [95, 80, 117, 'dress', 'cm'], 'out of range'],
  ['repair check: dress range check', [98, 91, 116, 'dress', 'cm'], 'out of range'],
  ['generated control 1', [99, 89, 115, 'skirt', 'cm'], 'XL'],
  ['generated control 2', [32, 29, 36, 'dress', 'in'], 'S'],
  ['generated control 3', [97, 70, 99, 'dress', 'cm'], 'grade L to M']],
 [['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: dress range check', [86, 80, 117, 'dress', 'cm'], 'out of range'],
  ['repair check: dress range check', [85, 83, 117, 'dress', 'cm'], 'out of range'],
  ['generated control 1', [100, 86, 117, 'top', 'cm'], 'L'],
  ['generated control 2', [81, 79, 93, 'dress', 'cm'], 'grade XS to S'],
  ['generated control 3', [32, 25, 40, 'dress', 'in'], 'grade S to L']]]
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
top within toleranceMMPassed
skirt waist governsLLPassed
dress gradegrade S to Lgrade S to LPassed
regression: dress range checkout of rangeout of rangePassed
repair check: dress range checkout of rangeout of rangePassed
generated control 1error: garmenterror: garmentPassed
generated control 2grade M to Lgrade M to LPassed
generated control 3XSXSPassed

SHA-256 / a40af80ecdb74551e719c229b39a566dd66d3e42e19874f4bfd5caa3a502b5d3

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

Case digest / 5526483147c4db79b30b8e08f5bc518b8f7b5e70b2290d524e806fc1ef0817f5