FAILURE MAP
← Case archive

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

Pattern row locator: finishing boundary · case 01

The last row of the last repeat is reported as finishing row 0.

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

ROOT CAUSE

The repeat section excludes its final row.

VERIFIED REPAIR

Rows up to length*repeats past setup are repeat rows.

Unsuccessful approach: Extending one row further swallows the first finishing row.

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 - 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: finishing boundary', [12, 4, 4, 2], ['repeat', 2, 4]],
  ['repair check: finishing boundary', [6, 4, 1, 1], ['finishing', 1]],
  ['generated control 1', [48, 2, 12, 5], ['repeat', 4, 10]],
  ['generated control 2', [43, 2, 4, 1], ['finishing', 37]],
  ['generated control 3', [17, 6, 6, 2], ['repeat', 2, 5]]],
 [['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: finishing boundary', [4, 2, 1, 2], ['repeat', 2, 1]],
  ['repair check: finishing boundary', [27, 2, 12, 2], ['finishing', 1]],
  ['generated control 1', [46, 6, 4, 3], ['finishing', 28]],
  ['generated control 2', [58, 1, 1, 1], ['finishing', 56]],
  ['generated control 3', [35, 1, 8, 1], ['finishing', 26]]],
 [['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: finishing boundary', [30, 6, 12, 2], ['repeat', 2, 12]],
  ['repair check: finishing boundary', [25, 4, 4, 5], ['finishing', 1]],
  ['generated control 1', [15, 4, 1, 5], ['finishing', 6]],
  ['generated control 2', [24, 2, 6, 5], ['repeat', 4, 4]],
  ['generated control 3', [52, 1, 12, 1], ['finishing', 39]]],
 [['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: finishing boundary', [26, 2, 8, 3], ['repeat', 3, 8]],
  ['repair check: finishing boundary', [5, 0, 4, 1], ['finishing', 1]],
  ['generated control 1', [40, 4, 4, 2], ['finishing', 28]],
  ['generated control 2', [25, 1, 4, 1], ['finishing', 20]],
  ['generated control 3', [5, 2, 8, 2], ['repeat', 1, 3]]],
 [['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: finishing boundary', [30, 6, 8, 3], ['repeat', 3, 8]],
  ['repair check: finishing boundary', [13, 0, 4, 3], ['finishing', 1]],
  ['generated control 1', [42, 1, 6, 3], ['finishing', 23]],
  ['generated control 2', [45, 4, 12, 5], ['repeat', 4, 5]],
  ['generated control 3', [51, 0, 4, 2], ['finishing', 43]]]]
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: finishing boundary['finishing', 0]['repeat', 2, 4]Failed
repair check: finishing boundary['finishing', 1]['finishing', 1]Passed
generated control 1['repeat', 4, 10]['repeat', 4, 10]Passed
generated control 2['finishing', 37]['finishing', 37]Passed
generated control 3['repeat', 2, 5]['repeat', 2, 5]Passed

SHA-256 / 4aaebe0635695c14e4df79227790015932186b01dd8422070c9061104129875f

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 + 1:
        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: finishing boundary', [12, 4, 4, 2], ['repeat', 2, 4]],
  ['repair check: finishing boundary', [6, 4, 1, 1], ['finishing', 1]],
  ['generated control 1', [48, 2, 12, 5], ['repeat', 4, 10]],
  ['generated control 2', [43, 2, 4, 1], ['finishing', 37]],
  ['generated control 3', [17, 6, 6, 2], ['repeat', 2, 5]]],
 [['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: finishing boundary', [4, 2, 1, 2], ['repeat', 2, 1]],
  ['repair check: finishing boundary', [27, 2, 12, 2], ['finishing', 1]],
  ['generated control 1', [46, 6, 4, 3], ['finishing', 28]],
  ['generated control 2', [58, 1, 1, 1], ['finishing', 56]],
  ['generated control 3', [35, 1, 8, 1], ['finishing', 26]]],
 [['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: finishing boundary', [30, 6, 12, 2], ['repeat', 2, 12]],
  ['repair check: finishing boundary', [25, 4, 4, 5], ['finishing', 1]],
  ['generated control 1', [15, 4, 1, 5], ['finishing', 6]],
  ['generated control 2', [24, 2, 6, 5], ['repeat', 4, 4]],
  ['generated control 3', [52, 1, 12, 1], ['finishing', 39]]],
 [['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: finishing boundary', [26, 2, 8, 3], ['repeat', 3, 8]],
  ['repair check: finishing boundary', [5, 0, 4, 1], ['finishing', 1]],
  ['generated control 1', [40, 4, 4, 2], ['finishing', 28]],
  ['generated control 2', [25, 1, 4, 1], ['finishing', 20]],
  ['generated control 3', [5, 2, 8, 2], ['repeat', 1, 3]]],
 [['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: finishing boundary', [30, 6, 8, 3], ['repeat', 3, 8]],
  ['repair check: finishing boundary', [13, 0, 4, 3], ['finishing', 1]],
  ['generated control 1', [42, 1, 6, 3], ['finishing', 23]],
  ['generated control 2', [45, 4, 12, 5], ['repeat', 4, 5]],
  ['generated control 3', [51, 0, 4, 2], ['finishing', 43]]]]
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: finishing boundary['repeat', 2, 4]['repeat', 2, 4]Passed
repair check: finishing boundary['repeat', 2, 1]['finishing', 1]Failed
generated control 1['repeat', 4, 10]['repeat', 4, 10]Passed
generated control 2['finishing', 37]['finishing', 37]Passed
generated control 3['repeat', 2, 5]['repeat', 2, 5]Passed

SHA-256 / 8dca0c89336443b4a2881baeb64f17f9559b8ccc3210b4282b464749a28ef08f

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: finishing boundary', [12, 4, 4, 2], ['repeat', 2, 4]],
  ['repair check: finishing boundary', [6, 4, 1, 1], ['finishing', 1]],
  ['generated control 1', [48, 2, 12, 5], ['repeat', 4, 10]],
  ['generated control 2', [43, 2, 4, 1], ['finishing', 37]],
  ['generated control 3', [17, 6, 6, 2], ['repeat', 2, 5]]],
 [['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: finishing boundary', [4, 2, 1, 2], ['repeat', 2, 1]],
  ['repair check: finishing boundary', [27, 2, 12, 2], ['finishing', 1]],
  ['generated control 1', [46, 6, 4, 3], ['finishing', 28]],
  ['generated control 2', [58, 1, 1, 1], ['finishing', 56]],
  ['generated control 3', [35, 1, 8, 1], ['finishing', 26]]],
 [['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: finishing boundary', [30, 6, 12, 2], ['repeat', 2, 12]],
  ['repair check: finishing boundary', [25, 4, 4, 5], ['finishing', 1]],
  ['generated control 1', [15, 4, 1, 5], ['finishing', 6]],
  ['generated control 2', [24, 2, 6, 5], ['repeat', 4, 4]],
  ['generated control 3', [52, 1, 12, 1], ['finishing', 39]]],
 [['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: finishing boundary', [26, 2, 8, 3], ['repeat', 3, 8]],
  ['repair check: finishing boundary', [5, 0, 4, 1], ['finishing', 1]],
  ['generated control 1', [40, 4, 4, 2], ['finishing', 28]],
  ['generated control 2', [25, 1, 4, 1], ['finishing', 20]],
  ['generated control 3', [5, 2, 8, 2], ['repeat', 1, 3]]],
 [['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: finishing boundary', [30, 6, 8, 3], ['repeat', 3, 8]],
  ['repair check: finishing boundary', [13, 0, 4, 3], ['finishing', 1]],
  ['generated control 1', [42, 1, 6, 3], ['finishing', 23]],
  ['generated control 2', [45, 4, 12, 5], ['repeat', 4, 5]],
  ['generated control 3', [51, 0, 4, 2], ['finishing', 43]]]]
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: finishing boundary['repeat', 2, 4]['repeat', 2, 4]Passed
repair check: finishing boundary['finishing', 1]['finishing', 1]Passed
generated control 1['repeat', 4, 10]['repeat', 4, 10]Passed
generated control 2['finishing', 37]['finishing', 37]Passed
generated control 3['repeat', 2, 5]['repeat', 2, 5]Passed

SHA-256 / d48c01db7fe98c5b637e5bc21dbd6fb1a6055d16e8d6dc04be8d164eb27a4622

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

Case digest / 2e7e47b9143aa57c1d89ccfd7e1426888d18603e7f74f7ece8a543cdf786efbc