FAILURE MAP
← Case archive

FA-47516 / Delimited text / Open access

Framed records retain the preceding record payload · case 01

A structured table violates the declared record or column contract.

Verified by executionVariant 1 · 10 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Record emission resets terminator state but not content state.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: buf, pending = [], False

Unsuccessful approach: Retaining only the last character still contaminates the successor.

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:
        for ch in chunk:
            if pending:
                if ch != '\n': return None
                rows.append(''.join(buf))
                buf, pending = buf, 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 fixtureActualExpectedOutcome
split terminator['cell', 'cellZ', 'cellZ']['cell', 'Z']Failed
whole['cell\tA', 'cell\tAB']['cell\tA', 'B']Failed
empty records['', '']['', '']Passed
empty chunks['cell', 'cell']['cell']Failed
trailing CRNoneNonePassed
bare LFNoneNonePassed
bad CRNoneNonePassed
no data[][]Passed
trailing unframed['cell']['cell']Passed
three chunks['cell', 'cellX']['cell', 'X']Failed

SHA-256 / 48490cb50c733ecf1da6933041b7241e28bd5d5097d6d0ec7460b5508690d398

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:
        for ch in chunk:
            if pending:
                if ch != '\n': return None
                rows.append(''.join(buf))
                buf, pending = buf[-1:], 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 fixtureActualExpectedOutcome
split terminator['cell', 'lZ', 'Z']['cell', 'Z']Failed
whole['cell\tA', 'AB']['cell\tA', 'B']Failed
empty records['', '']['', '']Passed
empty chunks['cell', 'l']['cell']Failed
trailing CRNoneNonePassed
bare LFNoneNonePassed
bad CRNoneNonePassed
no data[][]Passed
trailing unframed['cell']['cell']Passed
three chunks['cell', 'lX']['cell', 'X']Failed

SHA-256 / c6cbbfca0c7fb7fe342844fe767bd03b355ccf3bd0a05f5f9c23143408157638

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, buf, pending = [], [], False
    for chunk in data:
        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 fixtureActualExpectedOutcome
split terminator['cell', 'Z']['cell', 'Z']Passed
whole['cell\tA', 'B']['cell\tA', 'B']Passed
empty records['', '']['', '']Passed
empty chunks['cell']['cell']Passed
trailing CRNoneNonePassed
bare LFNoneNonePassed
bad CRNoneNonePassed
no data[][]Passed
trailing unframed['cell']['cell']Passed
three chunks['cell', 'X']['cell', 'X']Passed

SHA-256 / f495bf941e395e1a4d39a9c3aa637de71fe7a5e1e9f5955fd1bc41eb65d05334

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.254829+00:00.

Case digest / 7860ce9b9f74952d07912269f34148182f39b55a32393bfd33ca3b339b9c563e