FAILURE MAP
← Case archive

FA-48336 / Delimited text / Open access

EOF commits still-open interleaved tables · case 01

A structured table violates the declared record or column contract.

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

ROOT CAUSE

EOF commits still-open interleaved tables.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: if active: return None

Unsuccessful approach: The alternate implementation still violates the same declared invariant: eof commits still-open interleaved tables.

Case contract

Read pipe messages OPEN|id|header, ROW|id|comma-values, CLOSE|id|empty. Multiple table IDs may be open concurrently. IDs cannot reopen after close; rows require an active ID and matching width. Close emits [id, rows] in close order; EOF with open tables rejects.

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):
    active, closed, out = {},set(),[]
    for line in data:
        parts=line.split('|',2)
        if len(parts)!=3: return None
        tag,key,payload=parts
        if tag=='OPEN':
            if key in active or key in closed: return None
            active[key]=[payload.split(','),[]]
        elif tag=='ROW':
            if key not in active: return None
            row=payload.split(',')
            if len(row)!=len(active[key][0]): return None
            active[key][1].append(row)
        elif tag=='CLOSE':
            if key not in active or payload!='': return None
            out.append([key,active.pop(key)[1]]); closed.add(key)
        else: return None
    if active: active.clear()
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('interleaved', solve(_vary(['OPEN|a|x', 'OPEN|b|y', 'ROW|a|@', 'ROW|b|z', 'CLOSE|b|', 'CLOSE|a|'])), _vary([['b', [['z']]], ['a', [['@']]]]))
check('unclosed', solve(_vary(['OPEN|a|x'])), _vary(None))
check('unknown', solve(_vary(['ROW|a|@'])), _vary(None))
check('reopen', solve(_vary(['OPEN|a|x', 'CLOSE|a|', 'OPEN|a|x', 'CLOSE|a|'])), _vary(None))
check('close payload', solve(_vary(['OPEN|a|x', 'CLOSE|a|bad'])), _vary(None))
check('width', solve(_vary(['OPEN|a|x,y', 'ROW|a|@', 'CLOSE|a|'])), _vary(None))
check('normal', solve(_vary(['OPEN|@|x', 'CLOSE|@|'])), _vary([['@', []]]))
check('zero', solve(_vary([])), _vary([]))
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
interleaved[['b', [['z']]], ['a', [['cell']]]][['b', [['z']]], ['a', [['cell']]]]Passed
unclosed[]NoneFailed
unknownNoneNonePassed
reopenNoneNonePassed
close payloadNoneNonePassed
widthNoneNonePassed
normal[['cell', []]][['cell', []]]Passed
zero[][]Passed

SHA-256 / d9dd93ceaa538701dd6f1db761113cc4e68cb2dadd5116a84b34ebee500e3a8f

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):
    active, closed, out = {},set(),[]
    for line in data:
        parts=line.split('|',2)
        if len(parts)!=3: return None
        tag,key,payload=parts
        if tag=='OPEN':
            if key in active or key in closed: return None
            active[key]=[payload.split(','),[]]
        elif tag=='ROW':
            if key not in active: return None
            row=payload.split(',')
            if len(row)!=len(active[key][0]): return None
            active[key][1].append(row)
        elif tag=='CLOSE':
            if key not in active or payload!='': return None
            out.append([key,active.pop(key)[1]]); closed.add(key)
        else: return None
    if active: out.extend([key,value[1]] for key,value in active.items())
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('interleaved', solve(_vary(['OPEN|a|x', 'OPEN|b|y', 'ROW|a|@', 'ROW|b|z', 'CLOSE|b|', 'CLOSE|a|'])), _vary([['b', [['z']]], ['a', [['@']]]]))
check('unclosed', solve(_vary(['OPEN|a|x'])), _vary(None))
check('unknown', solve(_vary(['ROW|a|@'])), _vary(None))
check('reopen', solve(_vary(['OPEN|a|x', 'CLOSE|a|', 'OPEN|a|x', 'CLOSE|a|'])), _vary(None))
check('close payload', solve(_vary(['OPEN|a|x', 'CLOSE|a|bad'])), _vary(None))
check('width', solve(_vary(['OPEN|a|x,y', 'ROW|a|@', 'CLOSE|a|'])), _vary(None))
check('normal', solve(_vary(['OPEN|@|x', 'CLOSE|@|'])), _vary([['@', []]]))
check('zero', solve(_vary([])), _vary([]))
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
interleaved[['b', [['z']]], ['a', [['cell']]]][['b', [['z']]], ['a', [['cell']]]]Passed
unclosed[['a', []]]NoneFailed
unknownNoneNonePassed
reopenNoneNonePassed
close payloadNoneNonePassed
widthNoneNonePassed
normal[['cell', []]][['cell', []]]Passed
zero[][]Passed

SHA-256 / 53678998db0ffd9477ac04f22d631e7fc35061d0b671c47f1fa6675f47f69f2e

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):
    active, closed, out = {},set(),[]
    for line in data:
        parts=line.split('|',2)
        if len(parts)!=3: return None
        tag,key,payload=parts
        if tag=='OPEN':
            if key in active or key in closed: return None
            active[key]=[payload.split(','),[]]
        elif tag=='ROW':
            if key not in active: return None
            row=payload.split(',')
            if len(row)!=len(active[key][0]): return None
            active[key][1].append(row)
        elif tag=='CLOSE':
            if key not in active or payload!='': return None
            out.append([key,active.pop(key)[1]]); closed.add(key)
        else: return None
    if active: return None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('interleaved', solve(_vary(['OPEN|a|x', 'OPEN|b|y', 'ROW|a|@', 'ROW|b|z', 'CLOSE|b|', 'CLOSE|a|'])), _vary([['b', [['z']]], ['a', [['@']]]]))
check('unclosed', solve(_vary(['OPEN|a|x'])), _vary(None))
check('unknown', solve(_vary(['ROW|a|@'])), _vary(None))
check('reopen', solve(_vary(['OPEN|a|x', 'CLOSE|a|', 'OPEN|a|x', 'CLOSE|a|'])), _vary(None))
check('close payload', solve(_vary(['OPEN|a|x', 'CLOSE|a|bad'])), _vary(None))
check('width', solve(_vary(['OPEN|a|x,y', 'ROW|a|@', 'CLOSE|a|'])), _vary(None))
check('normal', solve(_vary(['OPEN|@|x', 'CLOSE|@|'])), _vary([['@', []]]))
check('zero', solve(_vary([])), _vary([]))
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
interleaved[['b', [['z']]], ['a', [['cell']]]][['b', [['z']]], ['a', [['cell']]]]Passed
unclosedNoneNonePassed
unknownNoneNonePassed
reopenNoneNonePassed
close payloadNoneNonePassed
widthNoneNonePassed
normal[['cell', []]][['cell', []]]Passed
zero[][]Passed

SHA-256 / 750180ba36107cbeb96429312234571c3144603ae1616f63252b60db76bd764c

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

Case digest / 28686447d007d8d1084a9dfc4a31838ada160d38472675513cd86c1fbe9e0481