FAILURE MAP
← Case archive

FA-48071 / Delimited text / Open access

Byte-span advancement forgets the record separator · case 01

A structured table violates the declared record or column contract.

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

ROOT CAUSE

The next span begins at the previous payload end rather than after LF.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: start += size + 1

Unsuccessful approach: Assuming CRLF overcounts a one-byte delimiter.

Case contract

For UTF-8 text with LF-delimited physical records, report each record as [text,start_byte,end_byte,line_number]. LF is excluded from text and end offset; a final LF does not add a phantom record. Empty interior records remain. Leading BOM is ordinary text here.

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, start, line = [], 0, 1
    parts = data.split('\n')
    if parts[-1] == '': parts.pop()
    for text in parts:
        size = len(text.encode('utf-8'))
        out.append([text, start, start + size, line])
        start += size
        line += 1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unicode', solve(_vary('é\n@')), _vary([['é', 0, 2, 1], ['@', 3, '@END', 2]]))
check('empty middle', solve(_vary('a\n\nb')), _vary([['a', 0, 1, 1], ['', 2, 2, 2], ['b', 3, 4, 3]]))
check('final LF', solve(_vary('a\n')), _vary([['a', 0, 1, 1]]))
check('empty', solve(_vary('')), _vary([]))
check('only LF', solve(_vary('\n')), _vary([['', 0, 0, 1]]))
check('astral', solve(_vary('😀\nz')), _vary([['😀', 0, 4, 1], ['z', 5, 6, 2]]))
check('no LF', solve(_vary('x')), _vary([['x', 0, 1, 1]]))
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
unicode[['é', 0, 2, 1], ['cell', 2, 6, 2]][['é', 0, 2, 1], ['cell', 3, 7, 2]]Failed
empty middle[['a', 0, 1, 1], ['', 1, 1, 2], ['b', 1, 2, 3]][['a', 0, 1, 1], ['', 2, 2, 2], ['b', 3, 4, 3]]Failed
final LF[['a', 0, 1, 1]][['a', 0, 1, 1]]Passed
empty[][]Passed
only LF[['', 0, 0, 1]][['', 0, 0, 1]]Passed
astral[['😀', 0, 4, 1], ['z', 4, 5, 2]][['😀', 0, 4, 1], ['z', 5, 6, 2]]Failed
no LF[['x', 0, 1, 1]][['x', 0, 1, 1]]Passed

SHA-256 / b5a39d17f070b3942d648e6e3ba6d98da8667788c304533a37606c1af8b21e63

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, start, line = [], 0, 1
    parts = data.split('\n')
    if parts[-1] == '': parts.pop()
    for text in parts:
        size = len(text.encode('utf-8'))
        out.append([text, start, start + size, line])
        start += size + 2
        line += 1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unicode', solve(_vary('é\n@')), _vary([['é', 0, 2, 1], ['@', 3, '@END', 2]]))
check('empty middle', solve(_vary('a\n\nb')), _vary([['a', 0, 1, 1], ['', 2, 2, 2], ['b', 3, 4, 3]]))
check('final LF', solve(_vary('a\n')), _vary([['a', 0, 1, 1]]))
check('empty', solve(_vary('')), _vary([]))
check('only LF', solve(_vary('\n')), _vary([['', 0, 0, 1]]))
check('astral', solve(_vary('😀\nz')), _vary([['😀', 0, 4, 1], ['z', 5, 6, 2]]))
check('no LF', solve(_vary('x')), _vary([['x', 0, 1, 1]]))
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
unicode[['é', 0, 2, 1], ['cell', 4, 8, 2]][['é', 0, 2, 1], ['cell', 3, 7, 2]]Failed
empty middle[['a', 0, 1, 1], ['', 3, 3, 2], ['b', 5, 6, 3]][['a', 0, 1, 1], ['', 2, 2, 2], ['b', 3, 4, 3]]Failed
final LF[['a', 0, 1, 1]][['a', 0, 1, 1]]Passed
empty[][]Passed
only LF[['', 0, 0, 1]][['', 0, 0, 1]]Passed
astral[['😀', 0, 4, 1], ['z', 6, 7, 2]][['😀', 0, 4, 1], ['z', 5, 6, 2]]Failed
no LF[['x', 0, 1, 1]][['x', 0, 1, 1]]Passed

SHA-256 / 3b84822ccb7702a6ca29c9ad67023f2d42b0f7061d59c1ebb570f538d75cdbb5

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, start, line = [], 0, 1
    parts = data.split('\n')
    if parts[-1] == '': parts.pop()
    for text in parts:
        size = len(text.encode('utf-8'))
        out.append([text, start, start + size, line])
        start += size + 1
        line += 1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unicode', solve(_vary('é\n@')), _vary([['é', 0, 2, 1], ['@', 3, '@END', 2]]))
check('empty middle', solve(_vary('a\n\nb')), _vary([['a', 0, 1, 1], ['', 2, 2, 2], ['b', 3, 4, 3]]))
check('final LF', solve(_vary('a\n')), _vary([['a', 0, 1, 1]]))
check('empty', solve(_vary('')), _vary([]))
check('only LF', solve(_vary('\n')), _vary([['', 0, 0, 1]]))
check('astral', solve(_vary('😀\nz')), _vary([['😀', 0, 4, 1], ['z', 5, 6, 2]]))
check('no LF', solve(_vary('x')), _vary([['x', 0, 1, 1]]))
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
unicode[['é', 0, 2, 1], ['cell', 3, 7, 2]][['é', 0, 2, 1], ['cell', 3, 7, 2]]Passed
empty middle[['a', 0, 1, 1], ['', 2, 2, 2], ['b', 3, 4, 3]][['a', 0, 1, 1], ['', 2, 2, 2], ['b', 3, 4, 3]]Passed
final LF[['a', 0, 1, 1]][['a', 0, 1, 1]]Passed
empty[][]Passed
only LF[['', 0, 0, 1]][['', 0, 0, 1]]Passed
astral[['😀', 0, 4, 1], ['z', 5, 6, 2]][['😀', 0, 4, 1], ['z', 5, 6, 2]]Passed
no LF[['x', 0, 1, 1]][['x', 0, 1, 1]]Passed

SHA-256 / 5a6882ff32edfacc4f2d66200eb1f89df8b3f59bdc8b43ded53608af400d1d63

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

Case digest / 5ec270dfd9f98f8800e24f90798f572e5c3ac2b6c789902b606b09f884d67952