FA-48466 / Delimited text / Open access
A row-repeat count is treated as including the original row · case 01
A structured table violates the declared record or column contract.
ROOT CAUSE
A row-repeat count is treated as including the original row.
VERIFIED REPAIR
Preserve the named invariant at the faulty decision: range(int(token))
Unsuccessful approach: The alternate implementation still violates the same declared invariant: a row-repeat count is treated as including the original row.
Case contract
Read comma rows, with an R|count control line repeating the most recent data row count additional times. Count must be positive ASCII decimal; controls cannot precede data. Repeated rows do not become a distinct source row. Return independent row values in order; ordinary payloads contain no pipe.
Why this case matters
Delimited interchange needs explicit framing, schema and field semantics at ingestion and emission boundaries.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
if value == '@END': return 3 + 4*N
if isinstance(value, str): return value.replace('@', 'cell' * N)
if isinstance(value, list): return [_vary(x) for x in value]
if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
return value
N = 1
observations = []
def solve(data):
out=[]; previous=None
for line in data:
if line.startswith('R|'):
token=line[2:]
if previous is None or not token.isascii() or not token.isdecimal() or int(token)<1: return None
out.extend([list(previous) for _ in range(int(token)-1)])
else:
if '|' in line: return None
previous=line.split(',')
out.append(previous)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeat', solve(_vary(['@,x', 'R|2'])), _vary([['@', 'x'], ['@', 'x'], ['@', 'x']]))
check('new source', solve(_vary(['a,b', 'R|1', '@,z', 'R|1'])), _vary([['a', 'b'], ['a', 'b'], ['@', 'z'], ['@', 'z']]))
check('orphan', solve(_vary(['R|2'])), _vary(None))
check('zero', solve(_vary(['a', 'R|0'])), _vary(None))
check('negative', solve(_vary(['a', 'R|-1'])), _vary(None))
check('empty row', solve(_vary(['', 'R|1'])), _vary([[''], ['']]))
check('chained', solve(_vary(['@', 'R|1', 'R|1'])), _vary([['@'], ['@'], ['@']]))
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 |
|---|---|---|---|
| repeat | [['cell', 'x'], ['cell', 'x']] | [['cell', 'x'], ['cell', 'x'], ['cell', 'x']] | Failed |
| new source | [['a', 'b'], ['cell', 'z']] | [['a', 'b'], ['a', 'b'], ['cell', 'z'], ['cell', 'z']] | Failed |
| orphan | None | None | Passed |
| zero | None | None | Passed |
| negative | None | None | Passed |
| empty row | [['']] | [[''], ['']] | Failed |
| chained | [['cell']] | [['cell'], ['cell'], ['cell']] | Failed |
SHA-256 / 5329ce67de59a4c6cbd116817148890d7d7053e0b91143263518f470b32b8347
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
if value == '@END': return 3 + 4*N
if isinstance(value, str): return value.replace('@', 'cell' * N)
if isinstance(value, list): return [_vary(x) for x in value]
if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
return value
N = 1
observations = []
def solve(data):
out=[]; previous=None
for line in data:
if line.startswith('R|'):
token=line[2:]
if previous is None or not token.isascii() or not token.isdecimal() or int(token)<1: return None
out.extend([list(previous) for _ in range(int(token)+1)])
else:
if '|' in line: return None
previous=line.split(',')
out.append(previous)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeat', solve(_vary(['@,x', 'R|2'])), _vary([['@', 'x'], ['@', 'x'], ['@', 'x']]))
check('new source', solve(_vary(['a,b', 'R|1', '@,z', 'R|1'])), _vary([['a', 'b'], ['a', 'b'], ['@', 'z'], ['@', 'z']]))
check('orphan', solve(_vary(['R|2'])), _vary(None))
check('zero', solve(_vary(['a', 'R|0'])), _vary(None))
check('negative', solve(_vary(['a', 'R|-1'])), _vary(None))
check('empty row', solve(_vary(['', 'R|1'])), _vary([[''], ['']]))
check('chained', solve(_vary(['@', 'R|1', 'R|1'])), _vary([['@'], ['@'], ['@']]))
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 |
|---|---|---|---|
| repeat | [['cell', 'x'], ['cell', 'x'], ['cell', 'x'], ['cell', 'x']] | [['cell', 'x'], ['cell', 'x'], ['cell', 'x']] | Failed |
| new source | [['a', 'b'], ['a', 'b'], ['a', 'b'], ['cell', 'z'], ['cell', 'z'], ['cell', 'z']] | [['a', 'b'], ['a', 'b'], ['cell', 'z'], ['cell', 'z']] | Failed |
| orphan | None | None | Passed |
| zero | None | None | Passed |
| negative | None | None | Passed |
| empty row | [[''], [''], ['']] | [[''], ['']] | Failed |
| chained | [['cell'], ['cell'], ['cell'], ['cell'], ['cell']] | [['cell'], ['cell'], ['cell']] | Failed |
SHA-256 / 709926843aa45c3c4d74f0ee42457a4107ce73f1d7e40aa7097c6838516f7c9e
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
if value == '@END': return 3 + 4*N
if isinstance(value, str): return value.replace('@', 'cell' * N)
if isinstance(value, list): return [_vary(x) for x in value]
if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
return value
N = 1
observations = []
def solve(data):
out=[]; previous=None
for line in data:
if line.startswith('R|'):
token=line[2:]
if previous is None or not token.isascii() or not token.isdecimal() or int(token)<1: return None
out.extend([list(previous) for _ in range(int(token))])
else:
if '|' in line: return None
previous=line.split(',')
out.append(previous)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeat', solve(_vary(['@,x', 'R|2'])), _vary([['@', 'x'], ['@', 'x'], ['@', 'x']]))
check('new source', solve(_vary(['a,b', 'R|1', '@,z', 'R|1'])), _vary([['a', 'b'], ['a', 'b'], ['@', 'z'], ['@', 'z']]))
check('orphan', solve(_vary(['R|2'])), _vary(None))
check('zero', solve(_vary(['a', 'R|0'])), _vary(None))
check('negative', solve(_vary(['a', 'R|-1'])), _vary(None))
check('empty row', solve(_vary(['', 'R|1'])), _vary([[''], ['']]))
check('chained', solve(_vary(['@', 'R|1', 'R|1'])), _vary([['@'], ['@'], ['@']]))
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 |
|---|---|---|---|
| repeat | [['cell', 'x'], ['cell', 'x'], ['cell', 'x']] | [['cell', 'x'], ['cell', 'x'], ['cell', 'x']] | Passed |
| new source | [['a', 'b'], ['a', 'b'], ['cell', 'z'], ['cell', 'z']] | [['a', 'b'], ['a', 'b'], ['cell', 'z'], ['cell', 'z']] | Passed |
| orphan | None | None | Passed |
| zero | None | None | Passed |
| negative | None | None | Passed |
| empty row | [[''], ['']] | [[''], ['']] | Passed |
| chained | [['cell'], ['cell'], ['cell']] | [['cell'], ['cell'], ['cell']] | Passed |
SHA-256 / 0404f6f8095c5adfbca880b90dfe3b84c3c8f87c21e7d0bc82d0f215d4412c9b
Verification & scope
Deterministic bounded in-memory model. No claim of complete CSV or external format conformance. 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:44:50.948796+00:00.
Case digest / c6f8ff6d4632b5431d528d084b9769d0962747cdc7c5b694f1aceccc17cd3179