FAILURE MAP
← Case archive

FA-47551 / Delimited text / Open access

A section retains only its most recent data row · case 01

A structured table violates the declared record or column contract.

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

ROOT CAUSE

Assignment replaces previously parsed rows in a table section.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: else: current[2].append(line.split('\t'))

Unsuccessful approach: Prepending preserves rows but reverses their order.

Case contract

Read a bounded sectioned TSV stream: @name starts a new table, the next record is its header, subsequent records its data. Names are unique and nonempty. A blank line closes a section; body records outside sections and sections without headers reject. Return ordered [name, header, rows] sections.

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):
    sections, current, needs_header = [], None, False
    for line in data:
        if line.startswith('%'):
            if current is not None and needs_header: return None
            name = line[1:]
            if not name or any(s[0] == name for s in sections): return None
            current = [name, [], []]
            sections.append(current)
            needs_header = True
        elif line == '':
            if needs_header: return None
            current = None
        elif current is None: return None
        elif needs_header:
            current[1] = line.split('\t')
            needs_header = False
        else: current[2] = [line.split('\t')]
    if needs_header: return None
    return sections
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('two sections', solve(_vary(['%one', 'a\tb', '@\tz', '%two', 'x', 'q'])), _vary([['one', ['a', 'b'], [['@', 'z']]], ['two', ['x'], [['q']]]]))
check('section close', solve(_vary(['%one', 'a', 'x', '', 'orphan'])), _vary(None))
check('empty section', solve(_vary(['%one', '%two', 'a'])), _vary(None))
check('missing eof header', solve(_vary(['%one'])), _vary(None))
check('duplicate', solve(_vary(['%one', 'a', '%one', 'b'])), _vary(None))
check('empty name', solve(_vary(['%', 'a'])), _vary(None))
check('normal', solve(_vary(['%one', 'a', '%'])), _vary(None))
check('zero', solve(_vary([])), _vary([]))
check('body control', solve(_vary(['%one', 'a', 'cell', 'two'])), _vary([['one', ['a'], [['cell'], ['two']]]]))
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
two sections[['one', ['a', 'b'], [['cell', 'z']]], ['two', ['x'], [['q']]]][['one', ['a', 'b'], [['cell', 'z']]], ['two', ['x'], [['q']]]]Passed
section closeNoneNonePassed
empty sectionNoneNonePassed
missing eof headerNoneNonePassed
duplicateNoneNonePassed
empty nameNoneNonePassed
normalNoneNonePassed
zero[][]Passed
body control[['one', ['a'], [['two']]]][['one', ['a'], [['cell'], ['two']]]]Failed

SHA-256 / eab592e2ac1bbc1632a2dae1193c9c815dd9a31a35579dbba9a8880bbfa87741

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):
    sections, current, needs_header = [], None, False
    for line in data:
        if line.startswith('%'):
            if current is not None and needs_header: return None
            name = line[1:]
            if not name or any(s[0] == name for s in sections): return None
            current = [name, [], []]
            sections.append(current)
            needs_header = True
        elif line == '':
            if needs_header: return None
            current = None
        elif current is None: return None
        elif needs_header:
            current[1] = line.split('\t')
            needs_header = False
        else: current[2].insert(0, line.split('\t'))
    if needs_header: return None
    return sections
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('two sections', solve(_vary(['%one', 'a\tb', '@\tz', '%two', 'x', 'q'])), _vary([['one', ['a', 'b'], [['@', 'z']]], ['two', ['x'], [['q']]]]))
check('section close', solve(_vary(['%one', 'a', 'x', '', 'orphan'])), _vary(None))
check('empty section', solve(_vary(['%one', '%two', 'a'])), _vary(None))
check('missing eof header', solve(_vary(['%one'])), _vary(None))
check('duplicate', solve(_vary(['%one', 'a', '%one', 'b'])), _vary(None))
check('empty name', solve(_vary(['%', 'a'])), _vary(None))
check('normal', solve(_vary(['%one', 'a', '%'])), _vary(None))
check('zero', solve(_vary([])), _vary([]))
check('body control', solve(_vary(['%one', 'a', 'cell', 'two'])), _vary([['one', ['a'], [['cell'], ['two']]]]))
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
two sections[['one', ['a', 'b'], [['cell', 'z']]], ['two', ['x'], [['q']]]][['one', ['a', 'b'], [['cell', 'z']]], ['two', ['x'], [['q']]]]Passed
section closeNoneNonePassed
empty sectionNoneNonePassed
missing eof headerNoneNonePassed
duplicateNoneNonePassed
empty nameNoneNonePassed
normalNoneNonePassed
zero[][]Passed
body control[['one', ['a'], [['two'], ['cell']]]][['one', ['a'], [['cell'], ['two']]]]Failed

SHA-256 / 1bd278af1212a25cb99f4d0926df2e6b2758b4a4b53b582c837c6330ccb135dd

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):
    sections, current, needs_header = [], None, False
    for line in data:
        if line.startswith('%'):
            if current is not None and needs_header: return None
            name = line[1:]
            if not name or any(s[0] == name for s in sections): return None
            current = [name, [], []]
            sections.append(current)
            needs_header = True
        elif line == '':
            if needs_header: return None
            current = None
        elif current is None: return None
        elif needs_header:
            current[1] = line.split('\t')
            needs_header = False
        else: current[2].append(line.split('\t'))
    if needs_header: return None
    return sections
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('two sections', solve(_vary(['%one', 'a\tb', '@\tz', '%two', 'x', 'q'])), _vary([['one', ['a', 'b'], [['@', 'z']]], ['two', ['x'], [['q']]]]))
check('section close', solve(_vary(['%one', 'a', 'x', '', 'orphan'])), _vary(None))
check('empty section', solve(_vary(['%one', '%two', 'a'])), _vary(None))
check('missing eof header', solve(_vary(['%one'])), _vary(None))
check('duplicate', solve(_vary(['%one', 'a', '%one', 'b'])), _vary(None))
check('empty name', solve(_vary(['%', 'a'])), _vary(None))
check('normal', solve(_vary(['%one', 'a', '%'])), _vary(None))
check('zero', solve(_vary([])), _vary([]))
check('body control', solve(_vary(['%one', 'a', 'cell', 'two'])), _vary([['one', ['a'], [['cell'], ['two']]]]))
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
two sections[['one', ['a', 'b'], [['cell', 'z']]], ['two', ['x'], [['q']]]][['one', ['a', 'b'], [['cell', 'z']]], ['two', ['x'], [['q']]]]Passed
section closeNoneNonePassed
empty sectionNoneNonePassed
missing eof headerNoneNonePassed
duplicateNoneNonePassed
empty nameNoneNonePassed
normalNoneNonePassed
zero[][]Passed
body control[['one', ['a'], [['cell'], ['two']]]][['one', ['a'], [['cell'], ['two']]]]Passed

SHA-256 / 91c98c2c92c3b05585df3aef0b29296ddd37f20cba70ec5ea288fad98b73b730

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

Case digest / 7386b7d022bd8f653a85a48196f9ca9ad5cd2c161294e40909ee92d3510bb740