FA-48781 / Delimited text / Open access
A buffered unterminated final record is omitted · case 01
A structured table violates the declared record or column contract.
ROOT CAUSE
A buffered unterminated final record is omitted.
VERIFIED REPAIR
Preserve the named invariant at the faulty decision: if carry: rows.append(carry.split(','))
Unsuccessful approach: The alternate implementation still violates the same declared invariant: a buffered unterminated final record is omitted.
Case contract
Consume arbitrary text chunks of an unquoted LF-delimited table. Complete records emit immediately into an output list; carry partial records across chunks. EOF emits a nonempty remaining fragment, but not a phantom row after final LF. Empty complete physical records are retained. Return comma-split rows.
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):
rows=[]; carry=''
for chunk in data:
carry+=chunk
while '\n' in carry:
record,carry=carry.split('\n',1)
rows.append(record.split(','))
if False: rows.append(carry.split(','))
return rows
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split cell', solve(_vary(['a,', '@', '\nx,y\n'])), _vary([['a', '@'], ['x', 'y']]))
check('several per chunk', solve(_vary(['a,b\n@,z\n'])), _vary([['a', 'b'], ['@', 'z']]))
check('empty chunks', solve(_vary(['', '@', '', '\n', ''])), _vary([['@']]))
check('partial final', solve(_vary(['a,b\n@'])), _vary([['a', 'b'], ['@']]))
check('empty rows', solve(_vary(['\n\n'])), _vary([[''], ['']]))
check('empty input', solve(_vary([])), _vary([]))
check('no newline', solve(_vary(['@'])), _vary([['@']]))
check('split delimiter', solve(_vary(['a', '\n', 'b'])), _vary([['a'], ['b']]))
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 |
|---|---|---|---|
| split cell | [['a', 'cell'], ['x', 'y']] | [['a', 'cell'], ['x', 'y']] | Passed |
| several per chunk | [['a', 'b'], ['cell', 'z']] | [['a', 'b'], ['cell', 'z']] | Passed |
| empty chunks | [['cell']] | [['cell']] | Passed |
| partial final | [['a', 'b']] | [['a', 'b'], ['cell']] | Failed |
| empty rows | [[''], ['']] | [[''], ['']] | Passed |
| empty input | [] | [] | Passed |
| no newline | [] | [['cell']] | Failed |
| split delimiter | [['a']] | [['a'], ['b']] | Failed |
SHA-256 / 75c4cede41609e942df09c3c6dfcc68cb5da7767d878c8007332654f1373f3c1
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):
rows=[]; carry=''
for chunk in data:
carry+=chunk
while '\n' in carry:
record,carry=carry.split('\n',1)
rows.append(record.split(','))
if carry.endswith('\n'): rows.append(carry.split(','))
return rows
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split cell', solve(_vary(['a,', '@', '\nx,y\n'])), _vary([['a', '@'], ['x', 'y']]))
check('several per chunk', solve(_vary(['a,b\n@,z\n'])), _vary([['a', 'b'], ['@', 'z']]))
check('empty chunks', solve(_vary(['', '@', '', '\n', ''])), _vary([['@']]))
check('partial final', solve(_vary(['a,b\n@'])), _vary([['a', 'b'], ['@']]))
check('empty rows', solve(_vary(['\n\n'])), _vary([[''], ['']]))
check('empty input', solve(_vary([])), _vary([]))
check('no newline', solve(_vary(['@'])), _vary([['@']]))
check('split delimiter', solve(_vary(['a', '\n', 'b'])), _vary([['a'], ['b']]))
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 |
|---|---|---|---|
| split cell | [['a', 'cell'], ['x', 'y']] | [['a', 'cell'], ['x', 'y']] | Passed |
| several per chunk | [['a', 'b'], ['cell', 'z']] | [['a', 'b'], ['cell', 'z']] | Passed |
| empty chunks | [['cell']] | [['cell']] | Passed |
| partial final | [['a', 'b']] | [['a', 'b'], ['cell']] | Failed |
| empty rows | [[''], ['']] | [[''], ['']] | Passed |
| empty input | [] | [] | Passed |
| no newline | [] | [['cell']] | Failed |
| split delimiter | [['a']] | [['a'], ['b']] | Failed |
SHA-256 / 39b7b6cf59547b99087cbef3dfe7672496ce04318f3aa69277cc1e38bbdaf124
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):
rows=[]; carry=''
for chunk in data:
carry+=chunk
while '\n' in carry:
record,carry=carry.split('\n',1)
rows.append(record.split(','))
if carry: rows.append(carry.split(','))
return rows
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split cell', solve(_vary(['a,', '@', '\nx,y\n'])), _vary([['a', '@'], ['x', 'y']]))
check('several per chunk', solve(_vary(['a,b\n@,z\n'])), _vary([['a', 'b'], ['@', 'z']]))
check('empty chunks', solve(_vary(['', '@', '', '\n', ''])), _vary([['@']]))
check('partial final', solve(_vary(['a,b\n@'])), _vary([['a', 'b'], ['@']]))
check('empty rows', solve(_vary(['\n\n'])), _vary([[''], ['']]))
check('empty input', solve(_vary([])), _vary([]))
check('no newline', solve(_vary(['@'])), _vary([['@']]))
check('split delimiter', solve(_vary(['a', '\n', 'b'])), _vary([['a'], ['b']]))
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 |
|---|---|---|---|
| split cell | [['a', 'cell'], ['x', 'y']] | [['a', 'cell'], ['x', 'y']] | Passed |
| several per chunk | [['a', 'b'], ['cell', 'z']] | [['a', 'b'], ['cell', 'z']] | Passed |
| empty chunks | [['cell']] | [['cell']] | Passed |
| partial final | [['a', 'b'], ['cell']] | [['a', 'b'], ['cell']] | Passed |
| empty rows | [[''], ['']] | [[''], ['']] | Passed |
| empty input | [] | [] | Passed |
| no newline | [['cell']] | [['cell']] | Passed |
| split delimiter | [['a'], ['b']] | [['a'], ['b']] | Passed |
SHA-256 / 85410585cfb2fad32494d3b27709ac40176364ac6f648ab54678ed08bd179c6b
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:53.854214+00:00.
Case digest / 38cbe137d74841160c0bd761077f110ab67523f74cfdfd34dfa4213516ba78ba