FAILURE MAP
← Case archive

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

Pattern size selector: fit tolerance · case 01

A 93 cm bust is sized up to L although M (92 cm) is within the 1 cm tolerance.

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

ROOT CAUSE

The 1 cm tolerance is not applied.

VERIFIED REPAIR

Accept a size when chart + 1 cm >= body.

Unsuccessful approach: A strict comparison rejects bodies exactly 1 cm over 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] >= 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: fit tolerance', [34, 27, 43, 'top', 'in'], 'S'],
  ['repair check: fit tolerance', [109, 74, 117, 'top', 'cm'], 'XL'],
  ['generated control 1', [107, 83, 90, 'dress', 'cm'], 'grade XL to S'],
  ['generated control 2', [40, 29, 40, 'top', 'in'], 'XL'],
  ['generated control 3', [42.5, 29, 40, 'top', 'in'], 'XL']],
 [['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: fit tolerance', [93, 65, 90, 'top', 'cm'], 'M'],
  ['repair check: fit tolerance', [81, 91, 110, 'dress', 'cm'], 'grade XS to XL'],
  ['generated control 1', [92, 69, 116, 'dress', 'cm'], 'out of range'],
  ['generated control 2', [40, 27, 36, 'coat', 'in'], 'error: garment'],
  ['generated control 3', [97, 64, 110, 'top', 'cm'], '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: fit tolerance', [106, 91, 103, 'skirt', 'cm'], 'XL'],
  ['repair check: fit tolerance', [96, 94, 93, 'dress', 'cm'], 'grade L to S'],
  ['generated control 1', [103, 62, 84, 'coat', 'cm'], 'error: garment'],
  ['generated control 2', [103, 73, 108, 'top', 'cm'], 'XL'],
  ['generated control 3', [38, 25, 43, 'skirt', 'in'], 'XL']],
 [['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: fit tolerance', [93, 69, 107, 'dress', 'cm'], 'grade M to L'],
  ['repair check: fit tolerance', [81, 85, 95, 'dress', 'cm'], 'grade XS to M'],
  ['generated control 1', [92, 61, 95, 'top', 'cm'], 'M'],
  ['generated control 2', [83, 73, 111, 'coat', 'cm'], 'error: garment'],
  ['generated control 3', [36, 25, 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'],
  ['skirt waist governs', [90, 80, 95, 'skirt', 'cm'], 'L'],
  ['regression: fit tolerance', [109, 61, 104, 'dress', 'cm'], 'grade XL to L'],
  ['repair check: fit tolerance', [81, 78, 113, 'top', 'cm'], 'XS'],
  ['generated control 1', [87, 63, 99, 'coat', 'cm'], 'error: garment'],
  ['generated control 2', [84, 88, 118, 'skirt', 'cm'], 'out of range'],
  ['generated control 3', [86, 73, 102, 'dress', 'cm'], '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 toleranceLMFailed
skirt waist governsLLPassed
dress gradegrade S to Lgrade S to LPassed
regression: fit toleranceMSFailed
repair check: fit toleranceout of rangeXLFailed
generated control 1grade XL to Sgrade XL to SPassed
generated control 2XLXLPassed
generated control 3XLXLPassed

SHA-256 / 6d745f66e43413e84c153416e73bb1c089945ddc4f943f31bc385a0fd37b7e8b

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 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: fit tolerance', [34, 27, 43, 'top', 'in'], 'S'],
  ['repair check: fit tolerance', [109, 74, 117, 'top', 'cm'], 'XL'],
  ['generated control 1', [107, 83, 90, 'dress', 'cm'], 'grade XL to S'],
  ['generated control 2', [40, 29, 40, 'top', 'in'], 'XL'],
  ['generated control 3', [42.5, 29, 40, 'top', 'in'], 'XL']],
 [['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: fit tolerance', [93, 65, 90, 'top', 'cm'], 'M'],
  ['repair check: fit tolerance', [81, 91, 110, 'dress', 'cm'], 'grade XS to XL'],
  ['generated control 1', [92, 69, 116, 'dress', 'cm'], 'out of range'],
  ['generated control 2', [40, 27, 36, 'coat', 'in'], 'error: garment'],
  ['generated control 3', [97, 64, 110, 'top', 'cm'], '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: fit tolerance', [106, 91, 103, 'skirt', 'cm'], 'XL'],
  ['repair check: fit tolerance', [96, 94, 93, 'dress', 'cm'], 'grade L to S'],
  ['generated control 1', [103, 62, 84, 'coat', 'cm'], 'error: garment'],
  ['generated control 2', [103, 73, 108, 'top', 'cm'], 'XL'],
  ['generated control 3', [38, 25, 43, 'skirt', 'in'], 'XL']],
 [['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: fit tolerance', [93, 69, 107, 'dress', 'cm'], 'grade M to L'],
  ['repair check: fit tolerance', [81, 85, 95, 'dress', 'cm'], 'grade XS to M'],
  ['generated control 1', [92, 61, 95, 'top', 'cm'], 'M'],
  ['generated control 2', [83, 73, 111, 'coat', 'cm'], 'error: garment'],
  ['generated control 3', [36, 25, 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'],
  ['skirt waist governs', [90, 80, 95, 'skirt', 'cm'], 'L'],
  ['regression: fit tolerance', [109, 61, 104, 'dress', 'cm'], 'grade XL to L'],
  ['repair check: fit tolerance', [81, 78, 113, 'top', 'cm'], 'XS'],
  ['generated control 1', [87, 63, 99, 'coat', 'cm'], 'error: garment'],
  ['generated control 2', [84, 88, 118, 'skirt', 'cm'], 'out of range'],
  ['generated control 3', [86, 73, 102, 'dress', 'cm'], '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 toleranceLMFailed
skirt waist governsLLPassed
dress gradegrade S to Lgrade S to LPassed
regression: fit toleranceSSPassed
repair check: fit toleranceout of rangeXLFailed
generated control 1grade XL to Sgrade XL to SPassed
generated control 2XLXLPassed
generated control 3XLXLPassed

SHA-256 / 0911bed1af43906aaa463376ddd8f9a1e339e337b9d3c8721706c016bf9943bf

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: fit tolerance', [34, 27, 43, 'top', 'in'], 'S'],
  ['repair check: fit tolerance', [109, 74, 117, 'top', 'cm'], 'XL'],
  ['generated control 1', [107, 83, 90, 'dress', 'cm'], 'grade XL to S'],
  ['generated control 2', [40, 29, 40, 'top', 'in'], 'XL'],
  ['generated control 3', [42.5, 29, 40, 'top', 'in'], 'XL']],
 [['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: fit tolerance', [93, 65, 90, 'top', 'cm'], 'M'],
  ['repair check: fit tolerance', [81, 91, 110, 'dress', 'cm'], 'grade XS to XL'],
  ['generated control 1', [92, 69, 116, 'dress', 'cm'], 'out of range'],
  ['generated control 2', [40, 27, 36, 'coat', 'in'], 'error: garment'],
  ['generated control 3', [97, 64, 110, 'top', 'cm'], '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: fit tolerance', [106, 91, 103, 'skirt', 'cm'], 'XL'],
  ['repair check: fit tolerance', [96, 94, 93, 'dress', 'cm'], 'grade L to S'],
  ['generated control 1', [103, 62, 84, 'coat', 'cm'], 'error: garment'],
  ['generated control 2', [103, 73, 108, 'top', 'cm'], 'XL'],
  ['generated control 3', [38, 25, 43, 'skirt', 'in'], 'XL']],
 [['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: fit tolerance', [93, 69, 107, 'dress', 'cm'], 'grade M to L'],
  ['repair check: fit tolerance', [81, 85, 95, 'dress', 'cm'], 'grade XS to M'],
  ['generated control 1', [92, 61, 95, 'top', 'cm'], 'M'],
  ['generated control 2', [83, 73, 111, 'coat', 'cm'], 'error: garment'],
  ['generated control 3', [36, 25, 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'],
  ['skirt waist governs', [90, 80, 95, 'skirt', 'cm'], 'L'],
  ['regression: fit tolerance', [109, 61, 104, 'dress', 'cm'], 'grade XL to L'],
  ['repair check: fit tolerance', [81, 78, 113, 'top', 'cm'], 'XS'],
  ['generated control 1', [87, 63, 99, 'coat', 'cm'], 'error: garment'],
  ['generated control 2', [84, 88, 118, 'skirt', 'cm'], 'out of range'],
  ['generated control 3', [86, 73, 102, 'dress', 'cm'], '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: fit toleranceSSPassed
repair check: fit toleranceXLXLPassed
generated control 1grade XL to Sgrade XL to SPassed
generated control 2XLXLPassed
generated control 3XLXLPassed

SHA-256 / 45b7577d819a36fe449e067ea2ee4c77f7ab737678b6016650e87fd8b5ffce7e

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

Case digest / 09325fdba3d94e689ba60ad9b68e54246f64701bf6b49ce3210aee732cc83edf