FA-97536 / Knitting and sewing pattern grading / Open access
Pattern size selector: skirt governing zone · case 01
A skirt for a larger waist is cut at the hip size and will not close.
ROOT CAUSE
Skirts are sized by hip only.
VERIFIED REPAIR
Use the larger of the waist and hip sizes.
Unsuccessful approach: min() picks the smaller size, which is too tight at the other zone.
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 c
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: skirt governing zone', [34, 31, 34, 'skirt', 'in'], 'L'],
['repair check: skirt governing zone', [95, 79, 95, 'skirt', 'cm'], 'L'],
['generated control 1', [32, 29, 40, 'coat', 'in'], 'error: garment'],
['generated control 2', [89, 88, 117, 'coat', 'cm'], 'error: garment'],
['generated control 3', [98, 93, 91, 'skirt', 'cm'], 'out of range']],
[['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: skirt governing zone', [109, 91, 86, 'skirt', 'cm'], 'XL'],
['repair check: skirt governing zone', [85, 67, 107, 'skirt', 'cm'], 'L'],
['generated control 1', [84, 76, 87, 'top', 'cm'], 'S'],
['generated control 2', [103, 79, 111, 'skirt', 'cm'], 'XL'],
['generated control 3', [91, 71, 105, 'skirt', '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: skirt governing zone', [100, 72, 93, 'skirt', 'cm'], 'M'],
['repair check: skirt governing zone', [84, 77, 108, 'skirt', 'cm'], 'XL'],
['generated control 1', [111, 62, 95, 'coat', 'cm'], 'error: garment'],
['generated control 2', [105, 79, 114, 'top', 'cm'], 'XL'],
['generated control 3', [109, 63, 118, '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: skirt governing zone', [93, 85, 91, 'skirt', 'cm'], 'XL'],
['repair check: skirt governing zone', [78, 61, 109, 'skirt', 'cm'], 'XL'],
['generated control 1', [42.5, 34, 36, 'dress', 'in'], 'grade XL to S'],
['generated control 2', [79, 73, 116, 'coat', 'cm'], 'error: garment'],
['generated control 3', [80, 67, 118, 'skirt', '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: skirt governing zone', [38, 31, 38, 'skirt', 'in'], 'L'],
['repair check: skirt governing zone', [34, 31, 43, 'skirt', 'in'], 'XL'],
['generated control 1', [87, 94, 94, 'top', 'cm'], 'S'],
['generated control 2', [110, 65, 112, 'coat', 'cm'], 'error: garment'],
['generated control 3', [85, 71, 101, '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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| top within tolerance | M | M | Passed |
| skirt waist governs | M | L | Failed |
| dress grade | grade S to L | grade S to L | Passed |
| regression: skirt governing zone | XS | L | Failed |
| repair check: skirt governing zone | M | L | Failed |
| generated control 1 | error: garment | error: garment | Passed |
| generated control 2 | error: garment | error: garment | Passed |
| generated control 3 | out of range | out of range | Passed |
SHA-256 / 07ad9da32807d8a9f40c52538ee7fa8f8554cafe67f4752cb09e30ac02aeda3c
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 min(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: skirt governing zone', [34, 31, 34, 'skirt', 'in'], 'L'],
['repair check: skirt governing zone', [95, 79, 95, 'skirt', 'cm'], 'L'],
['generated control 1', [32, 29, 40, 'coat', 'in'], 'error: garment'],
['generated control 2', [89, 88, 117, 'coat', 'cm'], 'error: garment'],
['generated control 3', [98, 93, 91, 'skirt', 'cm'], 'out of range']],
[['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: skirt governing zone', [109, 91, 86, 'skirt', 'cm'], 'XL'],
['repair check: skirt governing zone', [85, 67, 107, 'skirt', 'cm'], 'L'],
['generated control 1', [84, 76, 87, 'top', 'cm'], 'S'],
['generated control 2', [103, 79, 111, 'skirt', 'cm'], 'XL'],
['generated control 3', [91, 71, 105, 'skirt', '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: skirt governing zone', [100, 72, 93, 'skirt', 'cm'], 'M'],
['repair check: skirt governing zone', [84, 77, 108, 'skirt', 'cm'], 'XL'],
['generated control 1', [111, 62, 95, 'coat', 'cm'], 'error: garment'],
['generated control 2', [105, 79, 114, 'top', 'cm'], 'XL'],
['generated control 3', [109, 63, 118, '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: skirt governing zone', [93, 85, 91, 'skirt', 'cm'], 'XL'],
['repair check: skirt governing zone', [78, 61, 109, 'skirt', 'cm'], 'XL'],
['generated control 1', [42.5, 34, 36, 'dress', 'in'], 'grade XL to S'],
['generated control 2', [79, 73, 116, 'coat', 'cm'], 'error: garment'],
['generated control 3', [80, 67, 118, 'skirt', '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: skirt governing zone', [38, 31, 38, 'skirt', 'in'], 'L'],
['repair check: skirt governing zone', [34, 31, 43, 'skirt', 'in'], 'XL'],
['generated control 1', [87, 94, 94, 'top', 'cm'], 'S'],
['generated control 2', [110, 65, 112, 'coat', 'cm'], 'error: garment'],
['generated control 3', [85, 71, 101, '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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| top within tolerance | M | M | Passed |
| skirt waist governs | M | L | Failed |
| dress grade | grade S to L | grade S to L | Passed |
| regression: skirt governing zone | XS | L | Failed |
| repair check: skirt governing zone | M | L | Failed |
| generated control 1 | error: garment | error: garment | Passed |
| generated control 2 | error: garment | error: garment | Passed |
| generated control 3 | out of range | out of range | Passed |
SHA-256 / 1b9cb9f936e376bce50b5536101013c48bcbe4f9737d1559c45f037f56b5957d
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: skirt governing zone', [34, 31, 34, 'skirt', 'in'], 'L'],
['repair check: skirt governing zone', [95, 79, 95, 'skirt', 'cm'], 'L'],
['generated control 1', [32, 29, 40, 'coat', 'in'], 'error: garment'],
['generated control 2', [89, 88, 117, 'coat', 'cm'], 'error: garment'],
['generated control 3', [98, 93, 91, 'skirt', 'cm'], 'out of range']],
[['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: skirt governing zone', [109, 91, 86, 'skirt', 'cm'], 'XL'],
['repair check: skirt governing zone', [85, 67, 107, 'skirt', 'cm'], 'L'],
['generated control 1', [84, 76, 87, 'top', 'cm'], 'S'],
['generated control 2', [103, 79, 111, 'skirt', 'cm'], 'XL'],
['generated control 3', [91, 71, 105, 'skirt', '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: skirt governing zone', [100, 72, 93, 'skirt', 'cm'], 'M'],
['repair check: skirt governing zone', [84, 77, 108, 'skirt', 'cm'], 'XL'],
['generated control 1', [111, 62, 95, 'coat', 'cm'], 'error: garment'],
['generated control 2', [105, 79, 114, 'top', 'cm'], 'XL'],
['generated control 3', [109, 63, 118, '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: skirt governing zone', [93, 85, 91, 'skirt', 'cm'], 'XL'],
['repair check: skirt governing zone', [78, 61, 109, 'skirt', 'cm'], 'XL'],
['generated control 1', [42.5, 34, 36, 'dress', 'in'], 'grade XL to S'],
['generated control 2', [79, 73, 116, 'coat', 'cm'], 'error: garment'],
['generated control 3', [80, 67, 118, 'skirt', '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: skirt governing zone', [38, 31, 38, 'skirt', 'in'], 'L'],
['repair check: skirt governing zone', [34, 31, 43, 'skirt', 'in'], 'XL'],
['generated control 1', [87, 94, 94, 'top', 'cm'], 'S'],
['generated control 2', [110, 65, 112, 'coat', 'cm'], 'error: garment'],
['generated control 3', [85, 71, 101, '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 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: skirt governing zone | L | L | Passed |
| repair check: skirt governing zone | L | L | Passed |
| generated control 1 | error: garment | error: garment | Passed |
| generated control 2 | error: garment | error: garment | Passed |
| generated control 3 | out of range | out of range | Passed |
SHA-256 / daa581e5c04513d5a2ebf9a8bb186530e30f239318edaec137d726b4b5ab0393
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.097075+00:00.
Case digest / 77cf81bc1047afb85ba295356723eae93de05c5b40f8f3a0e45423d3461830b1