FAILURE MAP
← Case archive

FA-48066 / Delimited text / Open access

Record span offsets count characters instead of UTF-8 bytes · 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

Offset measurement uses text code points despite a byte-indexed contract.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: size = len(text.encode('utf-8'))

Unsuccessful approach: UTF-16 byte counts are a different coordinate system from the emitted UTF-8 stream.

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)
        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, 1, 1], ['cell', 2, 6, 2]][['é', 0, 2, 1], ['cell', 3, 7, 2]]Failed
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, 1, 1], ['z', 2, 3, 2]][['😀', 0, 4, 1], ['z', 5, 6, 2]]Failed
no LF[['x', 0, 1, 1]][['x', 0, 1, 1]]Passed

SHA-256 / deb9e81414acedaeacf5cad536f5426616ccbbe61c29fb39a0b658786f50f909

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-16-le'))
        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, 11, 2]][['é', 0, 2, 1], ['cell', 3, 7, 2]]Failed
empty middle[['a', 0, 2, 1], ['', 3, 3, 2], ['b', 4, 6, 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, 0, 1]][['', 0, 0, 1]]Passed
astral[['😀', 0, 4, 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 / fb9bd8ff8473b8c63e6a53547c30878331a0c68a20151647358fd875d0024161

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

Case digest / d5cc0b81f2cd6ebb7bed984bbf695a9a323e747bedc45f8d650d81ef885989f1