FAILURE MAP
← Case archive

FA-48076 / Delimited text / Open access

Record spans include the LF terminator in their payload extent · 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 end offset includes framing bytes excluded from the cell text.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: start + size, line

Unsuccessful approach: Subtracting one instead loses a payload byte.

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 + 1, 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, 3, 1], ['cell', 3, 8, 2]][['é', 0, 2, 1], ['cell', 3, 7, 2]]Failed
empty middle[['a', 0, 2, 1], ['', 2, 3, 2], ['b', 3, 5, 3]][['a', 0, 1, 1], ['', 2, 2, 2], ['b', 3, 4, 3]]Failed
final LF[['a', 0, 2, 1]][['a', 0, 1, 1]]Failed
empty[][]Passed
only LF[['', 0, 1, 1]][['', 0, 0, 1]]Failed
astral[['😀', 0, 5, 1], ['z', 5, 7, 2]][['😀', 0, 4, 1], ['z', 5, 6, 2]]Failed
no LF[['x', 0, 2, 1]][['x', 0, 1, 1]]Failed

SHA-256 / d5d439696806ee45faef04a3bb428b94faa60917986a24d6541c2a0afd7e4b48

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 + max(size - 1, 0), 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, 1, 1], ['cell', 3, 6, 2]][['é', 0, 2, 1], ['cell', 3, 7, 2]]Failed
empty middle[['a', 0, 0, 1], ['', 2, 2, 2], ['b', 3, 3, 3]][['a', 0, 1, 1], ['', 2, 2, 2], ['b', 3, 4, 3]]Failed
final LF[['a', 0, 0, 1]][['a', 0, 1, 1]]Failed
empty[][]Passed
only LF[['', 0, 0, 1]][['', 0, 0, 1]]Passed
astral[['😀', 0, 3, 1], ['z', 5, 5, 2]][['😀', 0, 4, 1], ['z', 5, 6, 2]]Failed
no LF[['x', 0, 0, 1]][['x', 0, 1, 1]]Failed

SHA-256 / cfd166ad0ff3ad3d0412ff47132d23d10cf3347329ed26dae3e587b23638cc37

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

Case digest / f987b632b173de3d06fa4ca3b26ffd2d2749e738f2a378069b6702e3c1690417