FAILURE MAP
← Case archive

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

Neckband pick-up counter: adjust direction · case 01

The band count is reduced below the picked-up total, leaving gaps.

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

ROOT CAUSE

The adjustment rounds down to the previous valid count.

VERIFIED REPAIR

Round up to the next valid count, keeping already valid totals.

Unsuccessful approach: Without the zero check an already valid count gains a full extra repeat.

Case contract

Edges [kind, count]: vertical picks up 3 per 4 rows, diagonal 9 per 10 rows, each rounded half-up per edge; horizontal picks 1 per stitch; other kinds -> "error: edge". The rib needs a count of multiple*k + plus; adjust the total up to the next such count (unchanged if already valid). Return [raw_total, adjusted].

Why this case matters

Neckbands and button bands pick up stitches at edge ratios and must fit the rib repeat.

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(edges, multiple, plus):
    total = 0
    for kind, n in edges:
        if kind == 'vertical':
            total += math.floor(Fraction(3 * n, 4) + Fraction(1, 2))
        elif kind == 'horizontal':
            total += n
        elif kind == 'diagonal':
            total += math.floor(Fraction(9 * n, 10) + Fraction(1, 2))
        else:
            return 'error: edge'
    r = (total - plus) % multiple
    adjusted = total - r
    return [total, adjusted]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['front neck', [[['vertical', 40], ['horizontal', 22], ['vertical', 40]], 4, 2], [82, 82]],
  ['already valid', [[['horizontal', 22]], 4, 2], [22, 22]],
  ['diagonal edge', [[['diagonal', 13]], 2, 0], [12, 12]],
  ['regression: adjust direction', [[['vertical', 18], ['diagonal', 41]], 4, 0], [51, 52]],
  ['repair check: adjust direction', [[['horizontal', 18], ['vertical', 10]], 2, 2], [26, 26]],
  ['generated control 1', [[['vertical', 7], ['horizontal', 7], ['horizontal', 41]], 2, 3], [53, 53]],
  ['generated control 2', [[['diagonal', 18], ['vertical', 18], ['vertical', 7]], 1, 0], [35, 35]],
  ['generated control 3', [[['vertical', 60]], 4, 2], [45, 46]]],
 [['already valid', [[['horizontal', 22]], 4, 2], [22, 22]],
  ['diagonal edge', [[['diagonal', 13]], 2, 0], [12, 12]],
  ['unknown edge', [[['curve', 10]], 2, 0], 'error: edge'],
  ['regression: adjust direction', [[['diagonal', 7], ['diagonal', 22], ['vertical', 7]], 4, 2], [31, 34]],
  ['repair check: adjust direction', [[['vertical', 41], ['diagonal', 41], ['vertical', 13]], 1, 2],
   [78, 78]],
  ['generated control 1', [[['horizontal', 20], ['vertical', 18], ['diagonal', 30], ['horizontal', 7]], 1, 3],
   [68, 68]],
  ['generated control 2', [[['vertical', 7], ['diagonal', 7], ['horizontal', 20], ['vertical', 30]], 1, 0],
   [54, 54]],
  ['generated control 3',
   [[['vertical', 60], ['horizontal', 20], ['horizontal', 20], ['vertical', 10], ['curve', 10]], 6, 0],
   'error: edge']],
 [['diagonal edge', [[['diagonal', 13]], 2, 0], [12, 12]],
  ['unknown edge', [[['curve', 10]], 2, 0], 'error: edge'],
  ['front neck', [[['vertical', 40], ['horizontal', 22], ['vertical', 40]], 4, 2], [82, 82]],
  ['regression: adjust direction',
   [[['diagonal', 13], ['vertical', 10], ['vertical', 18], ['diagonal', 7]], 4, 3], [40, 43]],
  ['repair check: adjust direction', [[['horizontal', 20], ['vertical', 30]], 1, 3], [43, 43]],
  ['generated control 1', [[['horizontal', 41], ['vertical', 18], ['vertical', 30]], 1, 3], [78, 78]],
  ['generated control 2', [[['vertical', 10]], 4, 3], [8, 11]],
  ['generated control 3', [[['vertical', 20], ['vertical', 60]], 1, 0], [60, 60]]],
 [['unknown edge', [[['curve', 10]], 2, 0], 'error: edge'],
  ['front neck', [[['vertical', 40], ['horizontal', 22], ['vertical', 40]], 4, 2], [82, 82]],
  ['already valid', [[['horizontal', 22]], 4, 2], [22, 22]],
  ['regression: adjust direction', [[['horizontal', 18]], 6, 2], [18, 20]],
  ['repair check: adjust direction',
   [[['horizontal', 13], ['horizontal', 60], ['diagonal', 7], ['vertical', 41]], 1, 2], [110, 110]],
  ['generated control 1', [[['vertical', 41], ['vertical', 60], ['horizontal', 18], ['diagonal', 7]], 6, 3],
   [100, 105]],
  ['generated control 2', [[['diagonal', 20], ['horizontal', 7]], 6, 3], [25, 27]],
  ['generated control 3', [[['vertical', 10], ['horizontal', 22], ['horizontal', 60]], 2, 1], [90, 91]]],
 [['front neck', [[['vertical', 40], ['horizontal', 22], ['vertical', 40]], 4, 2], [82, 82]],
  ['already valid', [[['horizontal', 22]], 4, 2], [22, 22]],
  ['diagonal edge', [[['diagonal', 13]], 2, 0], [12, 12]],
  ['regression: adjust direction',
   [[['vertical', 60], ['diagonal', 10], ['horizontal', 10], ['diagonal', 7]], 4, 3], [70, 71]],
  ['repair check: adjust direction', [[['diagonal', 60], ['horizontal', 10], ['diagonal', 30]], 1, 1],
   [91, 91]],
  ['generated control 1', [[['horizontal', 60], ['diagonal', 7]], 4, 3], [66, 67]],
  ['generated control 2', [[['vertical', 30], ['vertical', 41]], 4, 1], [54, 57]],
  ['generated control 3', [[['horizontal', 10]], 4, 1], [10, 13]]]]
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
front neck[82, 82][82, 82]Passed
already valid[22, 22][22, 22]Passed
diagonal edge[12, 12][12, 12]Passed
regression: adjust direction[51, 48][51, 52]Failed
repair check: adjust direction[26, 26][26, 26]Passed
generated control 1[53, 53][53, 53]Passed
generated control 2[35, 35][35, 35]Passed
generated control 3[45, 42][45, 46]Failed

SHA-256 / 4586cea6fa6af4e5c03bb8049c274c4b3f9c0b031ab0b3e851448b6c3777b0fc

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(edges, multiple, plus):
    total = 0
    for kind, n in edges:
        if kind == 'vertical':
            total += math.floor(Fraction(3 * n, 4) + Fraction(1, 2))
        elif kind == 'horizontal':
            total += n
        elif kind == 'diagonal':
            total += math.floor(Fraction(9 * n, 10) + Fraction(1, 2))
        else:
            return 'error: edge'
    r = (total - plus) % multiple
    adjusted = total + (multiple - r)
    return [total, adjusted]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['front neck', [[['vertical', 40], ['horizontal', 22], ['vertical', 40]], 4, 2], [82, 82]],
  ['already valid', [[['horizontal', 22]], 4, 2], [22, 22]],
  ['diagonal edge', [[['diagonal', 13]], 2, 0], [12, 12]],
  ['regression: adjust direction', [[['vertical', 18], ['diagonal', 41]], 4, 0], [51, 52]],
  ['repair check: adjust direction', [[['horizontal', 18], ['vertical', 10]], 2, 2], [26, 26]],
  ['generated control 1', [[['vertical', 7], ['horizontal', 7], ['horizontal', 41]], 2, 3], [53, 53]],
  ['generated control 2', [[['diagonal', 18], ['vertical', 18], ['vertical', 7]], 1, 0], [35, 35]],
  ['generated control 3', [[['vertical', 60]], 4, 2], [45, 46]]],
 [['already valid', [[['horizontal', 22]], 4, 2], [22, 22]],
  ['diagonal edge', [[['diagonal', 13]], 2, 0], [12, 12]],
  ['unknown edge', [[['curve', 10]], 2, 0], 'error: edge'],
  ['regression: adjust direction', [[['diagonal', 7], ['diagonal', 22], ['vertical', 7]], 4, 2], [31, 34]],
  ['repair check: adjust direction', [[['vertical', 41], ['diagonal', 41], ['vertical', 13]], 1, 2],
   [78, 78]],
  ['generated control 1', [[['horizontal', 20], ['vertical', 18], ['diagonal', 30], ['horizontal', 7]], 1, 3],
   [68, 68]],
  ['generated control 2', [[['vertical', 7], ['diagonal', 7], ['horizontal', 20], ['vertical', 30]], 1, 0],
   [54, 54]],
  ['generated control 3',
   [[['vertical', 60], ['horizontal', 20], ['horizontal', 20], ['vertical', 10], ['curve', 10]], 6, 0],
   'error: edge']],
 [['diagonal edge', [[['diagonal', 13]], 2, 0], [12, 12]],
  ['unknown edge', [[['curve', 10]], 2, 0], 'error: edge'],
  ['front neck', [[['vertical', 40], ['horizontal', 22], ['vertical', 40]], 4, 2], [82, 82]],
  ['regression: adjust direction',
   [[['diagonal', 13], ['vertical', 10], ['vertical', 18], ['diagonal', 7]], 4, 3], [40, 43]],
  ['repair check: adjust direction', [[['horizontal', 20], ['vertical', 30]], 1, 3], [43, 43]],
  ['generated control 1', [[['horizontal', 41], ['vertical', 18], ['vertical', 30]], 1, 3], [78, 78]],
  ['generated control 2', [[['vertical', 10]], 4, 3], [8, 11]],
  ['generated control 3', [[['vertical', 20], ['vertical', 60]], 1, 0], [60, 60]]],
 [['unknown edge', [[['curve', 10]], 2, 0], 'error: edge'],
  ['front neck', [[['vertical', 40], ['horizontal', 22], ['vertical', 40]], 4, 2], [82, 82]],
  ['already valid', [[['horizontal', 22]], 4, 2], [22, 22]],
  ['regression: adjust direction', [[['horizontal', 18]], 6, 2], [18, 20]],
  ['repair check: adjust direction',
   [[['horizontal', 13], ['horizontal', 60], ['diagonal', 7], ['vertical', 41]], 1, 2], [110, 110]],
  ['generated control 1', [[['vertical', 41], ['vertical', 60], ['horizontal', 18], ['diagonal', 7]], 6, 3],
   [100, 105]],
  ['generated control 2', [[['diagonal', 20], ['horizontal', 7]], 6, 3], [25, 27]],
  ['generated control 3', [[['vertical', 10], ['horizontal', 22], ['horizontal', 60]], 2, 1], [90, 91]]],
 [['front neck', [[['vertical', 40], ['horizontal', 22], ['vertical', 40]], 4, 2], [82, 82]],
  ['already valid', [[['horizontal', 22]], 4, 2], [22, 22]],
  ['diagonal edge', [[['diagonal', 13]], 2, 0], [12, 12]],
  ['regression: adjust direction',
   [[['vertical', 60], ['diagonal', 10], ['horizontal', 10], ['diagonal', 7]], 4, 3], [70, 71]],
  ['repair check: adjust direction', [[['diagonal', 60], ['horizontal', 10], ['diagonal', 30]], 1, 1],
   [91, 91]],
  ['generated control 1', [[['horizontal', 60], ['diagonal', 7]], 4, 3], [66, 67]],
  ['generated control 2', [[['vertical', 30], ['vertical', 41]], 4, 1], [54, 57]],
  ['generated control 3', [[['horizontal', 10]], 4, 1], [10, 13]]]]
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
front neck[82, 86][82, 82]Failed
already valid[22, 26][22, 22]Failed
diagonal edge[12, 14][12, 12]Failed
regression: adjust direction[51, 52][51, 52]Passed
repair check: adjust direction[26, 28][26, 26]Failed
generated control 1[53, 55][53, 53]Failed
generated control 2[35, 36][35, 35]Failed
generated control 3[45, 46][45, 46]Passed

SHA-256 / 8c5e673a04f25146ab8a2cb2fbc37255dbd19da03846f837797dacc36df10f28

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(edges, multiple, plus):
    total = 0
    for kind, n in edges:
        if kind == 'vertical':
            total += math.floor(Fraction(3 * n, 4) + Fraction(1, 2))
        elif kind == 'horizontal':
            total += n
        elif kind == 'diagonal':
            total += math.floor(Fraction(9 * n, 10) + Fraction(1, 2))
        else:
            return 'error: edge'
    r = (total - plus) % multiple
    adjusted = total if r == 0 else total + (multiple - r)
    return [total, adjusted]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['front neck', [[['vertical', 40], ['horizontal', 22], ['vertical', 40]], 4, 2], [82, 82]],
  ['already valid', [[['horizontal', 22]], 4, 2], [22, 22]],
  ['diagonal edge', [[['diagonal', 13]], 2, 0], [12, 12]],
  ['regression: adjust direction', [[['vertical', 18], ['diagonal', 41]], 4, 0], [51, 52]],
  ['repair check: adjust direction', [[['horizontal', 18], ['vertical', 10]], 2, 2], [26, 26]],
  ['generated control 1', [[['vertical', 7], ['horizontal', 7], ['horizontal', 41]], 2, 3], [53, 53]],
  ['generated control 2', [[['diagonal', 18], ['vertical', 18], ['vertical', 7]], 1, 0], [35, 35]],
  ['generated control 3', [[['vertical', 60]], 4, 2], [45, 46]]],
 [['already valid', [[['horizontal', 22]], 4, 2], [22, 22]],
  ['diagonal edge', [[['diagonal', 13]], 2, 0], [12, 12]],
  ['unknown edge', [[['curve', 10]], 2, 0], 'error: edge'],
  ['regression: adjust direction', [[['diagonal', 7], ['diagonal', 22], ['vertical', 7]], 4, 2], [31, 34]],
  ['repair check: adjust direction', [[['vertical', 41], ['diagonal', 41], ['vertical', 13]], 1, 2],
   [78, 78]],
  ['generated control 1', [[['horizontal', 20], ['vertical', 18], ['diagonal', 30], ['horizontal', 7]], 1, 3],
   [68, 68]],
  ['generated control 2', [[['vertical', 7], ['diagonal', 7], ['horizontal', 20], ['vertical', 30]], 1, 0],
   [54, 54]],
  ['generated control 3',
   [[['vertical', 60], ['horizontal', 20], ['horizontal', 20], ['vertical', 10], ['curve', 10]], 6, 0],
   'error: edge']],
 [['diagonal edge', [[['diagonal', 13]], 2, 0], [12, 12]],
  ['unknown edge', [[['curve', 10]], 2, 0], 'error: edge'],
  ['front neck', [[['vertical', 40], ['horizontal', 22], ['vertical', 40]], 4, 2], [82, 82]],
  ['regression: adjust direction',
   [[['diagonal', 13], ['vertical', 10], ['vertical', 18], ['diagonal', 7]], 4, 3], [40, 43]],
  ['repair check: adjust direction', [[['horizontal', 20], ['vertical', 30]], 1, 3], [43, 43]],
  ['generated control 1', [[['horizontal', 41], ['vertical', 18], ['vertical', 30]], 1, 3], [78, 78]],
  ['generated control 2', [[['vertical', 10]], 4, 3], [8, 11]],
  ['generated control 3', [[['vertical', 20], ['vertical', 60]], 1, 0], [60, 60]]],
 [['unknown edge', [[['curve', 10]], 2, 0], 'error: edge'],
  ['front neck', [[['vertical', 40], ['horizontal', 22], ['vertical', 40]], 4, 2], [82, 82]],
  ['already valid', [[['horizontal', 22]], 4, 2], [22, 22]],
  ['regression: adjust direction', [[['horizontal', 18]], 6, 2], [18, 20]],
  ['repair check: adjust direction',
   [[['horizontal', 13], ['horizontal', 60], ['diagonal', 7], ['vertical', 41]], 1, 2], [110, 110]],
  ['generated control 1', [[['vertical', 41], ['vertical', 60], ['horizontal', 18], ['diagonal', 7]], 6, 3],
   [100, 105]],
  ['generated control 2', [[['diagonal', 20], ['horizontal', 7]], 6, 3], [25, 27]],
  ['generated control 3', [[['vertical', 10], ['horizontal', 22], ['horizontal', 60]], 2, 1], [90, 91]]],
 [['front neck', [[['vertical', 40], ['horizontal', 22], ['vertical', 40]], 4, 2], [82, 82]],
  ['already valid', [[['horizontal', 22]], 4, 2], [22, 22]],
  ['diagonal edge', [[['diagonal', 13]], 2, 0], [12, 12]],
  ['regression: adjust direction',
   [[['vertical', 60], ['diagonal', 10], ['horizontal', 10], ['diagonal', 7]], 4, 3], [70, 71]],
  ['repair check: adjust direction', [[['diagonal', 60], ['horizontal', 10], ['diagonal', 30]], 1, 1],
   [91, 91]],
  ['generated control 1', [[['horizontal', 60], ['diagonal', 7]], 4, 3], [66, 67]],
  ['generated control 2', [[['vertical', 30], ['vertical', 41]], 4, 1], [54, 57]],
  ['generated control 3', [[['horizontal', 10]], 4, 1], [10, 13]]]]
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
front neck[82, 82][82, 82]Passed
already valid[22, 22][22, 22]Passed
diagonal edge[12, 12][12, 12]Passed
regression: adjust direction[51, 52][51, 52]Passed
repair check: adjust direction[26, 26][26, 26]Passed
generated control 1[53, 53][53, 53]Passed
generated control 2[35, 35][35, 35]Passed
generated control 3[45, 46][45, 46]Passed

SHA-256 / 67c49538bd5e5ba95ee7bc489e78ffc9320f24de617d427672e194d52a742703

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

Case digest / 586a4f0b1d4ca97ff39db04bceac93cf0fccf091051979768a3cccce344f5ccb