FAILURE MAP
← Case archive

FA-47536 / Delimited text / Open access

A new table directive abandons an unbound section · 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

Opening a section does not resolve the prior pending header requirement.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: if current is not None and needs_header: return None

Unsuccessful approach: Checking only after several sections misses the first abandoned header.

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 False: 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 section[['one', [], []], ['two', ['a'], []]]NoneFailed
missing eof headerNoneNonePassed
duplicateNoneNonePassed
empty nameNoneNonePassed
normalNoneNonePassed
zero[][]Passed
body control[['one', ['a'], [['cell'], ['two']]]][['one', ['a'], [['cell'], ['two']]]]Passed

SHA-256 / 17e01a27d8b1a6f04b9657ce498ace7b443ebbd3d43f56a9a7d632204cb1974a

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 and len(sections) > 1: 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 section[['one', [], []], ['two', ['a'], []]]NoneFailed
missing eof headerNoneNonePassed
duplicateNoneNonePassed
empty nameNoneNonePassed
normalNoneNonePassed
zero[][]Passed
body control[['one', ['a'], [['cell'], ['two']]]][['one', ['a'], [['cell'], ['two']]]]Passed

SHA-256 / 8003b908f9c10b20caaf38c60610d133fc21f3160c48fa1a0e390171a6ccafb3

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

Case digest / 8e22ce5ca8fab32ec5cf782a2db314e0daa1a177dd83e041f9349d5f026ae048