FA-48326 / Delimited text / Open access
Tables are emitted in ID order instead of close order · case 01
A structured table violates the declared record or column contract.
ROOT CAUSE
Tables are emitted in ID order instead of close order.
VERIFIED REPAIR
Preserve the named invariant at the faulty decision: return out
Unsuccessful approach: The alternate implementation still violates the same declared invariant: tables are emitted in id order instead of close order.
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: return None
return sorted(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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| interleaved | [['a', [['cell']]], ['b', [['z']]]] | [['b', [['z']]], ['a', [['cell']]]] | Failed |
| unclosed | None | None | Passed |
| unknown | None | None | Passed |
| reopen | None | None | Passed |
| close payload | None | None | Passed |
| width | None | None | Passed |
| normal | [['cell', []]] | [['cell', []]] | Passed |
| zero | [] | [] | Passed |
SHA-256 / 0e2e7dda77db062ab49f9f76f9bcc25e93063b8c3a545750b0280bee3e766b5c
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: return None
return list(reversed(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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| interleaved | [['a', [['cell']]], ['b', [['z']]]] | [['b', [['z']]], ['a', [['cell']]]] | Failed |
| unclosed | None | None | Passed |
| unknown | None | None | Passed |
| reopen | None | None | Passed |
| close payload | None | None | Passed |
| width | None | None | Passed |
| normal | [['cell', []]] | [['cell', []]] | Passed |
| zero | [] | [] | Passed |
SHA-256 / 0fdfa9213469ef1857f6adbb95872f1d6bd17f5ac7c6c70c0b04c11791527a8a
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| interleaved | [['b', [['z']]], ['a', [['cell']]]] | [['b', [['z']]], ['a', [['cell']]]] | Passed |
| unclosed | None | None | Passed |
| unknown | None | None | Passed |
| reopen | None | None | Passed |
| close payload | None | None | Passed |
| width | None | None | Passed |
| 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.698188+00:00.
Case digest / 3de6e167028460db5f5d1958e30c7755d87be841253f3210f0592d28b0ace6b9