FA-97436 / Knitting and sewing pattern grading / Open access
Pattern row locator: setup boundary · case 01
The last setup row is reported as repeat 0.
ROOT CAUSE
The setup test excludes its final row.
VERIFIED REPAIR
Rows up to and including setup are setup rows.
Unsuccessful approach: Excluding single-row setups still misplaces row 1.
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: setup boundary', [4, 4, 1, 1], ['setup', 4]],
['generated control 1', [19, 6, 8, 3], ['repeat', 2, 5]],
['generated control 2', [11, 6, 8, 3], ['repeat', 1, 5]],
['generated control 3', [0, 4, 1, 5], 'error: rows start at 1'],
['generated control 4', [8, 4, 4, 2], ['repeat', 1, 4]]],
[['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: setup boundary', [2, 2, 4, 2], ['setup', 2]],
['repair check: setup boundary', [1, 1, 4, 1], ['setup', 1]],
['generated control 1', [56, 0, 8, 3], ['finishing', 32]],
['generated control 2', [28, 2, 1, 5], ['finishing', 21]],
['generated control 3', [49, 4, 12, 5], ['repeat', 4, 9]]],
[['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: setup boundary', [4, 4, 6, 1], ['setup', 4]],
['repair check: setup boundary', [1, 1, 6, 5], ['setup', 1]],
['generated control 1', [56, 1, 12, 3], ['finishing', 19]],
['generated control 2', [57, 6, 1, 1], ['finishing', 50]],
['generated control 3', [10, 0, 8, 3], ['repeat', 2, 2]]],
[['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: setup boundary', [6, 6, 8, 1], ['setup', 6]],
['repair check: setup boundary', [1, 1, 4, 3], ['setup', 1]],
['generated control 1', [16, 1, 1, 5], ['finishing', 10]],
['generated control 2', [15, 4, 1, 3], ['finishing', 8]],
['generated control 3', [30, 0, 8, 5], ['repeat', 4, 6]]],
[['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: setup boundary', [4, 4, 1, 3], ['setup', 4]],
['repair check: setup boundary', [1, 1, 1, 1], ['setup', 1]],
['generated control 1', [36, 6, 12, 2], ['finishing', 6]],
['generated control 2', [11, 1, 8, 2], ['repeat', 2, 2]],
['generated control 3', [55, 1, 12, 5], ['repeat', 5, 6]]]]
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 |
|---|---|---|---|
| last setup row | ['repeat', 0, 8] | ['setup', 4] | Failed |
| first repeat row | ['repeat', 1, 1] | ['repeat', 1, 1] | Passed |
| single setup row | ['repeat', 0, 4] | ['setup', 1] | Failed |
| regression: setup boundary | ['repeat', 0, 1] | ['setup', 4] | Failed |
| generated control 1 | ['repeat', 2, 5] | ['repeat', 2, 5] | Passed |
| generated control 2 | ['repeat', 1, 5] | ['repeat', 1, 5] | Passed |
| generated control 3 | error: rows start at 1 | error: rows start at 1 | Passed |
| generated control 4 | ['repeat', 1, 4] | ['repeat', 1, 4] | Passed |
SHA-256 / ad502e7498482635ce86360df9aa22a6e63d7cd596720dfe5754f20ff86a6d1e
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 and setup > 1:
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: setup boundary', [4, 4, 1, 1], ['setup', 4]],
['generated control 1', [19, 6, 8, 3], ['repeat', 2, 5]],
['generated control 2', [11, 6, 8, 3], ['repeat', 1, 5]],
['generated control 3', [0, 4, 1, 5], 'error: rows start at 1'],
['generated control 4', [8, 4, 4, 2], ['repeat', 1, 4]]],
[['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: setup boundary', [2, 2, 4, 2], ['setup', 2]],
['repair check: setup boundary', [1, 1, 4, 1], ['setup', 1]],
['generated control 1', [56, 0, 8, 3], ['finishing', 32]],
['generated control 2', [28, 2, 1, 5], ['finishing', 21]],
['generated control 3', [49, 4, 12, 5], ['repeat', 4, 9]]],
[['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: setup boundary', [4, 4, 6, 1], ['setup', 4]],
['repair check: setup boundary', [1, 1, 6, 5], ['setup', 1]],
['generated control 1', [56, 1, 12, 3], ['finishing', 19]],
['generated control 2', [57, 6, 1, 1], ['finishing', 50]],
['generated control 3', [10, 0, 8, 3], ['repeat', 2, 2]]],
[['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: setup boundary', [6, 6, 8, 1], ['setup', 6]],
['repair check: setup boundary', [1, 1, 4, 3], ['setup', 1]],
['generated control 1', [16, 1, 1, 5], ['finishing', 10]],
['generated control 2', [15, 4, 1, 3], ['finishing', 8]],
['generated control 3', [30, 0, 8, 5], ['repeat', 4, 6]]],
[['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: setup boundary', [4, 4, 1, 3], ['setup', 4]],
['repair check: setup boundary', [1, 1, 1, 1], ['setup', 1]],
['generated control 1', [36, 6, 12, 2], ['finishing', 6]],
['generated control 2', [11, 1, 8, 2], ['repeat', 2, 2]],
['generated control 3', [55, 1, 12, 5], ['repeat', 5, 6]]]]
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 |
|---|---|---|---|
| last setup row | ['setup', 4] | ['setup', 4] | Passed |
| first repeat row | ['repeat', 1, 1] | ['repeat', 1, 1] | Passed |
| single setup row | ['repeat', 0, 4] | ['setup', 1] | Failed |
| regression: setup boundary | ['setup', 4] | ['setup', 4] | Passed |
| generated control 1 | ['repeat', 2, 5] | ['repeat', 2, 5] | Passed |
| generated control 2 | ['repeat', 1, 5] | ['repeat', 1, 5] | Passed |
| generated control 3 | error: rows start at 1 | error: rows start at 1 | Passed |
| generated control 4 | ['repeat', 1, 4] | ['repeat', 1, 4] | Passed |
SHA-256 / 775ff13fbc7ade16a6fb1ff051835042d98e28250965c8a597f95e95a6d82bf9
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: setup boundary', [4, 4, 1, 1], ['setup', 4]],
['generated control 1', [19, 6, 8, 3], ['repeat', 2, 5]],
['generated control 2', [11, 6, 8, 3], ['repeat', 1, 5]],
['generated control 3', [0, 4, 1, 5], 'error: rows start at 1'],
['generated control 4', [8, 4, 4, 2], ['repeat', 1, 4]]],
[['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: setup boundary', [2, 2, 4, 2], ['setup', 2]],
['repair check: setup boundary', [1, 1, 4, 1], ['setup', 1]],
['generated control 1', [56, 0, 8, 3], ['finishing', 32]],
['generated control 2', [28, 2, 1, 5], ['finishing', 21]],
['generated control 3', [49, 4, 12, 5], ['repeat', 4, 9]]],
[['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: setup boundary', [4, 4, 6, 1], ['setup', 4]],
['repair check: setup boundary', [1, 1, 6, 5], ['setup', 1]],
['generated control 1', [56, 1, 12, 3], ['finishing', 19]],
['generated control 2', [57, 6, 1, 1], ['finishing', 50]],
['generated control 3', [10, 0, 8, 3], ['repeat', 2, 2]]],
[['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: setup boundary', [6, 6, 8, 1], ['setup', 6]],
['repair check: setup boundary', [1, 1, 4, 3], ['setup', 1]],
['generated control 1', [16, 1, 1, 5], ['finishing', 10]],
['generated control 2', [15, 4, 1, 3], ['finishing', 8]],
['generated control 3', [30, 0, 8, 5], ['repeat', 4, 6]]],
[['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: setup boundary', [4, 4, 1, 3], ['setup', 4]],
['repair check: setup boundary', [1, 1, 1, 1], ['setup', 1]],
['generated control 1', [36, 6, 12, 2], ['finishing', 6]],
['generated control 2', [11, 1, 8, 2], ['repeat', 2, 2]],
['generated control 3', [55, 1, 12, 5], ['repeat', 5, 6]]]]
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 |
|---|---|---|---|
| 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: setup boundary | ['setup', 4] | ['setup', 4] | Passed |
| generated control 1 | ['repeat', 2, 5] | ['repeat', 2, 5] | Passed |
| generated control 2 | ['repeat', 1, 5] | ['repeat', 1, 5] | Passed |
| generated control 3 | error: rows start at 1 | error: rows start at 1 | Passed |
| generated control 4 | ['repeat', 1, 4] | ['repeat', 1, 4] | Passed |
SHA-256 / a437231f0b35f1b1156a2529993970c86be8a90405a7b0c2098bc80e619abd9f
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.152775+00:00.
Case digest / 80a132abc3b48905ac4db71ba54bb6cd02e9334e20956bdc3f3170fdf35a2e3b