FA-48476 / Delimited text / Open access
Repeated rows are prepended ahead of earlier data · case 01
A structured table violates the declared record or column contract.
ROOT CAUSE
Repeated rows are prepended ahead of earlier data.
VERIFIED REPAIR
Preserve the named invariant at the faulty decision: out.extend([list(previous) for _ in range(int(token))])
Unsuccessful approach: The alternate implementation still violates the same declared invariant: repeated rows are prepended ahead of earlier data.
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[0:0]=[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 | [['cell', 'z'], ['a', 'b'], ['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 | [[''], ['']] | [[''], ['']] | Passed |
| chained | [['cell'], ['cell'], ['cell']] | [['cell'], ['cell'], ['cell']] | Passed |
SHA-256 / eaf82a15206eb8318d7abd2a1a7dda1d6240a2d88d66ae5f337356ba50792948
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=[list(previous) for _ in range(int(token))]+out
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 | [['cell', 'z'], ['a', 'b'], ['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 | [[''], ['']] | [[''], ['']] | Passed |
| chained | [['cell'], ['cell'], ['cell']] | [['cell'], ['cell'], ['cell']] | Passed |
SHA-256 / 4e98dcc33469a5f83e5d5416e8af3de5248ee038b4eff4a66b17f64072a57efe
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:51.165246+00:00.
Case digest / afe02f545a85204ea7b5cb848ce9b88ae8f3ee9a306df01db24fc32717c06ec4