FA-47506 / Delimited text / Open access
A TSV framer clears a CR carry at chunk boundaries · case 01
A structured table violates the declared record or column contract.
ROOT CAUSE
A delimiter prefix is stored as chunk-local state.
THE FAILURE
A delimiter prefix is stored as chunk-local state.
Unsuccessful approach: Ignoring empty chunks still loses a CR before the next nonempty chunk.
Case contract
Frame raw TSV records from arbitrary string chunks using CRLF only. Bare CR and bare LF are invalid. A trailing nonterminated record is allowed; a final CR is invalid. Return records without terminators, retaining empty records.
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, buf, pending = [], [], False
for chunk in data:
pending = False
for ch in chunk:
if pending:
if ch != '\n': return None
rows.append(''.join(buf))
buf, pending = [], False
elif ch == '\r': pending = True
elif ch == '\n': return None
else: buf.append(ch)
if pending: return None
if buf: rows.append(''.join(buf))
return rows
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split terminator', solve(_vary(['@\r', '\nZ\r', '\n'])), _vary(['@', 'Z']))
check('whole', solve(_vary(['@\tA\r\nB'])), _vary(['@\tA', 'B']))
check('empty records', solve(_vary(['\r\n\r\n'])), _vary(['', '']))
check('empty chunks', solve(_vary(['', '@', '', '\r', '', '\n', ''])), _vary(['@']))
check('trailing CR', solve(_vary(['@\r'])), _vary(None))
check('bare LF', solve(_vary(['@\n'])), _vary(None))
check('bad CR', solve(_vary(['@\rZ'])), _vary(None))
check('no data', solve(_vary([])), _vary([]))
check('trailing unframed', solve(_vary(['@'])), _vary(['@']))
check('three chunks', solve(_vary(['@\r', '\n', 'X'])), _vary(['@', 'X']))
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 terminator | None | ['cell', 'Z'] | Failed |
| whole | ['cell\tA', 'B'] | ['cell\tA', 'B'] | Passed |
| empty records | ['', ''] | ['', ''] | Passed |
| empty chunks | None | ['cell'] | Failed |
| trailing CR | None | None | Passed |
| bare LF | None | None | Passed |
| bad CR | None | None | Passed |
| no data | [] | [] | Passed |
| trailing unframed | ['cell'] | ['cell'] | Passed |
| three chunks | None | ['cell', 'X'] | Failed |
SHA-256 / 5eabe723ee5bb9cb3eeaae5d71edfd4d34b19a4fc842cc5eb873b080bb09e8de
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, buf, pending = [], [], False
for chunk in data:
if chunk: pending = False
for ch in chunk:
if pending:
if ch != '\n': return None
rows.append(''.join(buf))
buf, pending = [], False
elif ch == '\r': pending = True
elif ch == '\n': return None
else: buf.append(ch)
if pending: return None
if buf: rows.append(''.join(buf))
return rows
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split terminator', solve(_vary(['@\r', '\nZ\r', '\n'])), _vary(['@', 'Z']))
check('whole', solve(_vary(['@\tA\r\nB'])), _vary(['@\tA', 'B']))
check('empty records', solve(_vary(['\r\n\r\n'])), _vary(['', '']))
check('empty chunks', solve(_vary(['', '@', '', '\r', '', '\n', ''])), _vary(['@']))
check('trailing CR', solve(_vary(['@\r'])), _vary(None))
check('bare LF', solve(_vary(['@\n'])), _vary(None))
check('bad CR', solve(_vary(['@\rZ'])), _vary(None))
check('no data', solve(_vary([])), _vary([]))
check('trailing unframed', solve(_vary(['@'])), _vary(['@']))
check('three chunks', solve(_vary(['@\r', '\n', 'X'])), _vary(['@', 'X']))
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 terminator | None | ['cell', 'Z'] | Failed |
| whole | ['cell\tA', 'B'] | ['cell\tA', 'B'] | Passed |
| empty records | ['', ''] | ['', ''] | Passed |
| empty chunks | None | ['cell'] | Failed |
| trailing CR | None | None | Passed |
| bare LF | None | None | Passed |
| bad CR | None | None | Passed |
| no data | [] | [] | Passed |
| trailing unframed | ['cell'] | ['cell'] | Passed |
| three chunks | None | ['cell', 'X'] | Failed |
SHA-256 / 04e14f9f4b6ca5b1a96fc27a8e67872f07e00dfb17548beea068d8a4b84cc88b
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 10 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗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:42.448314+00:00.
Case digest / 992cd04e0227994ca865e2c9861008ff8c78c3c17a66168893dd02a79a10d4b3