FAILURE MAP
← Case archive

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

Pattern row locator: row within repeat · case 01

The last row of each repeat is shown as row 0.

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

ROOT CAUSE

Row-in-repeat uses a 0-based modulo on a 1-based offset.

VERIFIED REPAIR

Use (k-1)%length + 1.

Unsuccessful approach: Adding one to k%length shifts every row by one.

Case contract

Rows are 1-based. Rows 1..setup are ["setup", row]. The next length*repeats rows are ["repeat", repeat_number, row_in_repeat] (both 1-based). Later rows are ["finishing", k] counting from 1 after the last repeat. row < 1 -> "error: rows start at 1".

Why this case matters

Row counter apps must map an absolute row number onto setup, repeat and finishing sections.

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(row, setup, length, repeats):
    if row < 1:
        return 'error: rows start at 1'
    if row <= setup:
        return ['setup', row]
    k = row - setup
    if k <= length * repeats:
        return ['repeat', (k - 1) // length + 1, k % length]
    return ['finishing', k - length * repeats]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['last setup row', [4, 4, 8, 3], ['setup', 4]], ['first repeat row', [5, 4, 8, 3], ['repeat', 1, 1]],
  ['single setup row', [1, 1, 4, 2], ['setup', 1]],
  ['regression: row within repeat', [9, 6, 1, 5], ['repeat', 3, 1]],
  ['repair check: row within repeat', [57, 0, 12, 5], ['repeat', 5, 9]],
  ['generated control 1', [32, 0, 6, 1], ['finishing', 26]],
  ['generated control 2', [48, 0, 8, 3], ['finishing', 24]],
  ['generated control 3', [4, 2, 6, 2], ['repeat', 1, 2]]],
 [['first repeat row', [5, 4, 8, 3], ['repeat', 1, 1]], ['single setup row', [1, 1, 4, 2], ['setup', 1]],
  ['last row of repeat', [12, 4, 8, 3], ['repeat', 1, 8]],
  ['regression: row within repeat', [24, 0, 8, 3], ['repeat', 3, 8]],
  ['repair check: row within repeat', [4, 1, 6, 3], ['repeat', 1, 3]],
  ['generated control 1', [40, 0, 8, 3], ['finishing', 16]],
  ['generated control 2', [56, 2, 6, 1], ['finishing', 48]],
  ['generated control 3', [24, 0, 12, 2], ['repeat', 2, 12]]],
 [['single setup row', [1, 1, 4, 2], ['setup', 1]], ['last row of repeat', [12, 4, 8, 3], ['repeat', 1, 8]],
  ['first finishing row', [29, 4, 8, 3], ['finishing', 1]],
  ['regression: row within repeat', [42, 2, 8, 5], ['repeat', 5, 8]],
  ['repair check: row within repeat', [19, 1, 12, 3], ['repeat', 2, 6]],
  ['generated control 1', [49, 2, 6, 2], ['finishing', 35]],
  ['generated control 2', [21, 4, 4, 3], ['finishing', 5]],
  ['generated control 3', [44, 4, 12, 2], ['finishing', 16]]],
 [['last row of repeat', [12, 4, 8, 3], ['repeat', 1, 8]],
  ['first finishing row', [29, 4, 8, 3], ['finishing', 1]],
  ['row zero', [0, 2, 4, 2], 'error: rows start at 1'],
  ['regression: row within repeat', [14, 6, 8, 5], ['repeat', 1, 8]],
  ['repair check: row within repeat', [51, 4, 12, 5], ['repeat', 4, 11]],
  ['generated control 1', [57, 6, 1, 3], ['finishing', 48]],
  ['generated control 2', [50, 0, 6, 2], ['finishing', 38]],
  ['generated control 3', [3, 2, 8, 3], ['repeat', 1, 1]]],
 [['first finishing row', [29, 4, 8, 3], ['finishing', 1]],
  ['row zero', [0, 2, 4, 2], 'error: rows start at 1'], ['last setup row', [4, 4, 8, 3], ['setup', 4]],
  ['regression: row within repeat', [1, 0, 1, 3], ['repeat', 1, 1]],
  ['repair check: row within repeat', [25, 2, 12, 5], ['repeat', 2, 11]],
  ['generated control 1', [32, 1, 4, 1], ['finishing', 27]],
  ['generated control 2', [31, 2, 4, 2], ['finishing', 21]],
  ['generated control 3', [48, 6, 8, 2], ['finishing', 26]]]]
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
last setup row['setup', 4]['setup', 4]Passed
first repeat row['repeat', 1, 1]['repeat', 1, 1]Passed
single setup row['setup', 1]['setup', 1]Passed
regression: row within repeat['repeat', 3, 0]['repeat', 3, 1]Failed
repair check: row within repeat['repeat', 5, 9]['repeat', 5, 9]Passed
generated control 1['finishing', 26]['finishing', 26]Passed
generated control 2['finishing', 24]['finishing', 24]Passed
generated control 3['repeat', 1, 2]['repeat', 1, 2]Passed

SHA-256 / 3545848d477d10ff7ec099fec1c0c0c0a3bec65011fc4156629eea59c360aca5

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(row, setup, length, repeats):
    if row < 1:
        return 'error: rows start at 1'
    if row <= setup:
        return ['setup', row]
    k = row - setup
    if k <= length * repeats:
        return ['repeat', (k - 1) // length + 1, k % length + 1]
    return ['finishing', k - length * repeats]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['last setup row', [4, 4, 8, 3], ['setup', 4]], ['first repeat row', [5, 4, 8, 3], ['repeat', 1, 1]],
  ['single setup row', [1, 1, 4, 2], ['setup', 1]],
  ['regression: row within repeat', [9, 6, 1, 5], ['repeat', 3, 1]],
  ['repair check: row within repeat', [57, 0, 12, 5], ['repeat', 5, 9]],
  ['generated control 1', [32, 0, 6, 1], ['finishing', 26]],
  ['generated control 2', [48, 0, 8, 3], ['finishing', 24]],
  ['generated control 3', [4, 2, 6, 2], ['repeat', 1, 2]]],
 [['first repeat row', [5, 4, 8, 3], ['repeat', 1, 1]], ['single setup row', [1, 1, 4, 2], ['setup', 1]],
  ['last row of repeat', [12, 4, 8, 3], ['repeat', 1, 8]],
  ['regression: row within repeat', [24, 0, 8, 3], ['repeat', 3, 8]],
  ['repair check: row within repeat', [4, 1, 6, 3], ['repeat', 1, 3]],
  ['generated control 1', [40, 0, 8, 3], ['finishing', 16]],
  ['generated control 2', [56, 2, 6, 1], ['finishing', 48]],
  ['generated control 3', [24, 0, 12, 2], ['repeat', 2, 12]]],
 [['single setup row', [1, 1, 4, 2], ['setup', 1]], ['last row of repeat', [12, 4, 8, 3], ['repeat', 1, 8]],
  ['first finishing row', [29, 4, 8, 3], ['finishing', 1]],
  ['regression: row within repeat', [42, 2, 8, 5], ['repeat', 5, 8]],
  ['repair check: row within repeat', [19, 1, 12, 3], ['repeat', 2, 6]],
  ['generated control 1', [49, 2, 6, 2], ['finishing', 35]],
  ['generated control 2', [21, 4, 4, 3], ['finishing', 5]],
  ['generated control 3', [44, 4, 12, 2], ['finishing', 16]]],
 [['last row of repeat', [12, 4, 8, 3], ['repeat', 1, 8]],
  ['first finishing row', [29, 4, 8, 3], ['finishing', 1]],
  ['row zero', [0, 2, 4, 2], 'error: rows start at 1'],
  ['regression: row within repeat', [14, 6, 8, 5], ['repeat', 1, 8]],
  ['repair check: row within repeat', [51, 4, 12, 5], ['repeat', 4, 11]],
  ['generated control 1', [57, 6, 1, 3], ['finishing', 48]],
  ['generated control 2', [50, 0, 6, 2], ['finishing', 38]],
  ['generated control 3', [3, 2, 8, 3], ['repeat', 1, 1]]],
 [['first finishing row', [29, 4, 8, 3], ['finishing', 1]],
  ['row zero', [0, 2, 4, 2], 'error: rows start at 1'], ['last setup row', [4, 4, 8, 3], ['setup', 4]],
  ['regression: row within repeat', [1, 0, 1, 3], ['repeat', 1, 1]],
  ['repair check: row within repeat', [25, 2, 12, 5], ['repeat', 2, 11]],
  ['generated control 1', [32, 1, 4, 1], ['finishing', 27]],
  ['generated control 2', [31, 2, 4, 2], ['finishing', 21]],
  ['generated control 3', [48, 6, 8, 2], ['finishing', 26]]]]
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
last setup row['setup', 4]['setup', 4]Passed
first repeat row['repeat', 1, 2]['repeat', 1, 1]Failed
single setup row['setup', 1]['setup', 1]Passed
regression: row within repeat['repeat', 3, 1]['repeat', 3, 1]Passed
repair check: row within repeat['repeat', 5, 10]['repeat', 5, 9]Failed
generated control 1['finishing', 26]['finishing', 26]Passed
generated control 2['finishing', 24]['finishing', 24]Passed
generated control 3['repeat', 1, 3]['repeat', 1, 2]Failed

SHA-256 / 279716a02faf25519569a61814fb089ca97812eae400fc997e54f572bb30d96f

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(row, setup, length, repeats):
    if row < 1:
        return 'error: rows start at 1'
    if row <= setup:
        return ['setup', row]
    k = row - setup
    if k <= length * repeats:
        return ['repeat', (k - 1) // length + 1, (k - 1) % length + 1]
    return ['finishing', k - length * repeats]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['last setup row', [4, 4, 8, 3], ['setup', 4]], ['first repeat row', [5, 4, 8, 3], ['repeat', 1, 1]],
  ['single setup row', [1, 1, 4, 2], ['setup', 1]],
  ['regression: row within repeat', [9, 6, 1, 5], ['repeat', 3, 1]],
  ['repair check: row within repeat', [57, 0, 12, 5], ['repeat', 5, 9]],
  ['generated control 1', [32, 0, 6, 1], ['finishing', 26]],
  ['generated control 2', [48, 0, 8, 3], ['finishing', 24]],
  ['generated control 3', [4, 2, 6, 2], ['repeat', 1, 2]]],
 [['first repeat row', [5, 4, 8, 3], ['repeat', 1, 1]], ['single setup row', [1, 1, 4, 2], ['setup', 1]],
  ['last row of repeat', [12, 4, 8, 3], ['repeat', 1, 8]],
  ['regression: row within repeat', [24, 0, 8, 3], ['repeat', 3, 8]],
  ['repair check: row within repeat', [4, 1, 6, 3], ['repeat', 1, 3]],
  ['generated control 1', [40, 0, 8, 3], ['finishing', 16]],
  ['generated control 2', [56, 2, 6, 1], ['finishing', 48]],
  ['generated control 3', [24, 0, 12, 2], ['repeat', 2, 12]]],
 [['single setup row', [1, 1, 4, 2], ['setup', 1]], ['last row of repeat', [12, 4, 8, 3], ['repeat', 1, 8]],
  ['first finishing row', [29, 4, 8, 3], ['finishing', 1]],
  ['regression: row within repeat', [42, 2, 8, 5], ['repeat', 5, 8]],
  ['repair check: row within repeat', [19, 1, 12, 3], ['repeat', 2, 6]],
  ['generated control 1', [49, 2, 6, 2], ['finishing', 35]],
  ['generated control 2', [21, 4, 4, 3], ['finishing', 5]],
  ['generated control 3', [44, 4, 12, 2], ['finishing', 16]]],
 [['last row of repeat', [12, 4, 8, 3], ['repeat', 1, 8]],
  ['first finishing row', [29, 4, 8, 3], ['finishing', 1]],
  ['row zero', [0, 2, 4, 2], 'error: rows start at 1'],
  ['regression: row within repeat', [14, 6, 8, 5], ['repeat', 1, 8]],
  ['repair check: row within repeat', [51, 4, 12, 5], ['repeat', 4, 11]],
  ['generated control 1', [57, 6, 1, 3], ['finishing', 48]],
  ['generated control 2', [50, 0, 6, 2], ['finishing', 38]],
  ['generated control 3', [3, 2, 8, 3], ['repeat', 1, 1]]],
 [['first finishing row', [29, 4, 8, 3], ['finishing', 1]],
  ['row zero', [0, 2, 4, 2], 'error: rows start at 1'], ['last setup row', [4, 4, 8, 3], ['setup', 4]],
  ['regression: row within repeat', [1, 0, 1, 3], ['repeat', 1, 1]],
  ['repair check: row within repeat', [25, 2, 12, 5], ['repeat', 2, 11]],
  ['generated control 1', [32, 1, 4, 1], ['finishing', 27]],
  ['generated control 2', [31, 2, 4, 2], ['finishing', 21]],
  ['generated control 3', [48, 6, 8, 2], ['finishing', 26]]]]
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
last setup row['setup', 4]['setup', 4]Passed
first repeat row['repeat', 1, 1]['repeat', 1, 1]Passed
single setup row['setup', 1]['setup', 1]Passed
regression: row within repeat['repeat', 3, 1]['repeat', 3, 1]Passed
repair check: row within repeat['repeat', 5, 9]['repeat', 5, 9]Passed
generated control 1['finishing', 26]['finishing', 26]Passed
generated control 2['finishing', 24]['finishing', 24]Passed
generated control 3['repeat', 1, 2]['repeat', 1, 2]Passed

SHA-256 / cb93200f6cf8848e1c1741265058a31ea28ec431199626ed12d9f44e7f74012d

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

Case digest / 057655caacb34a3f290b7322bb7607fe76be93b9eb911425478e4eb1abe29777