FA-48031 / Delimited text / Open access
Closing a grouped record leaves it open for later fields · case 01
A structured table violates the declared record or column contract.
ROOT CAUSE
The end transition does not release the active object.
VERIFIED REPAIR
Preserve the named invariant at the faulty decision: active = None
Unsuccessful approach: Replacing the ID with empty text still leaves a non-null active scope.
Case contract
Read pipe rows: B|id opens an object, V|key|value adds a unique field, E|id closes and emits it. Nested begins, values outside an object, mismatched closes and EOF-open objects reject. Closed objects may reuse field keys. Preserve object order and text including empty values.
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, active, fields = [], None, {}
for line in data:
cells = line.split('|')
tag = cells[0]
if tag == 'B' and len(cells) == 2:
if active is not None: return None
active, fields = cells[1], {}
elif tag == 'V' and len(cells) == 3:
if active is None or cells[1] in fields: return None
fields[cells[1]] = cells[2]
elif tag == 'E' and len(cells) == 2:
if active is None or cells[1] != active: return None
out.append([active, fields])
active = active
else: return None
if active is not None: return None
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('groups', solve(_vary(['B|@', 'V|a|x', 'E|@', 'B|other', 'V|a|y', 'E|other'])), _vary([['@', {'a': 'x'}], ['other', {'a': 'y'}]]))
check('nested', solve(_vary(['B|a', 'B|b', 'E|b'])), _vary(None))
check('orphan', solve(_vary(['V|a|x'])), _vary(None))
check('mismatch', solve(_vary(['B|a', 'E|b'])), _vary(None))
check('unclosed', solve(_vary(['B|@', 'V|a|x'])), _vary(None))
check('duplicate', solve(_vary(['B|a', 'V|x|1', 'V|x|2', 'E|a'])), _vary(None))
check('empty object', solve(_vary(['B|a', 'E|a'])), _vary([['a', {}]]))
check('empty value', solve(_vary(['B|a', 'V|x|', 'E|a'])), _vary([['a', {'x': ''}]]))
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 |
|---|---|---|---|
| groups | None | [['cell', {'a': 'x'}], ['other', {'a': 'y'}]] | Failed |
| nested | None | None | Passed |
| orphan | None | None | Passed |
| mismatch | None | None | Passed |
| unclosed | None | None | Passed |
| duplicate | None | None | Passed |
| empty object | None | [['a', {}]] | Failed |
| empty value | None | [['a', {'x': ''}]] | Failed |
| zero | [] | [] | Passed |
SHA-256 / 740226e8b218327e81ddc318d9199e22e555215843d4b85178f5b890d245cb8f
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, active, fields = [], None, {}
for line in data:
cells = line.split('|')
tag = cells[0]
if tag == 'B' and len(cells) == 2:
if active is not None: return None
active, fields = cells[1], {}
elif tag == 'V' and len(cells) == 3:
if active is None or cells[1] in fields: return None
fields[cells[1]] = cells[2]
elif tag == 'E' and len(cells) == 2:
if active is None or cells[1] != active: return None
out.append([active, fields])
active = ''
else: return None
if active is not None: return None
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('groups', solve(_vary(['B|@', 'V|a|x', 'E|@', 'B|other', 'V|a|y', 'E|other'])), _vary([['@', {'a': 'x'}], ['other', {'a': 'y'}]]))
check('nested', solve(_vary(['B|a', 'B|b', 'E|b'])), _vary(None))
check('orphan', solve(_vary(['V|a|x'])), _vary(None))
check('mismatch', solve(_vary(['B|a', 'E|b'])), _vary(None))
check('unclosed', solve(_vary(['B|@', 'V|a|x'])), _vary(None))
check('duplicate', solve(_vary(['B|a', 'V|x|1', 'V|x|2', 'E|a'])), _vary(None))
check('empty object', solve(_vary(['B|a', 'E|a'])), _vary([['a', {}]]))
check('empty value', solve(_vary(['B|a', 'V|x|', 'E|a'])), _vary([['a', {'x': ''}]]))
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 |
|---|---|---|---|
| groups | None | [['cell', {'a': 'x'}], ['other', {'a': 'y'}]] | Failed |
| nested | None | None | Passed |
| orphan | None | None | Passed |
| mismatch | None | None | Passed |
| unclosed | None | None | Passed |
| duplicate | None | None | Passed |
| empty object | None | [['a', {}]] | Failed |
| empty value | None | [['a', {'x': ''}]] | Failed |
| zero | [] | [] | Passed |
SHA-256 / 66c37c565111882b22e6958f1e4de4c7526c16353b17e1a9a2a1043b42a0d63d
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, active, fields = [], None, {}
for line in data:
cells = line.split('|')
tag = cells[0]
if tag == 'B' and len(cells) == 2:
if active is not None: return None
active, fields = cells[1], {}
elif tag == 'V' and len(cells) == 3:
if active is None or cells[1] in fields: return None
fields[cells[1]] = cells[2]
elif tag == 'E' and len(cells) == 2:
if active is None or cells[1] != active: return None
out.append([active, fields])
active = None
else: return None
if active is not None: return None
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('groups', solve(_vary(['B|@', 'V|a|x', 'E|@', 'B|other', 'V|a|y', 'E|other'])), _vary([['@', {'a': 'x'}], ['other', {'a': 'y'}]]))
check('nested', solve(_vary(['B|a', 'B|b', 'E|b'])), _vary(None))
check('orphan', solve(_vary(['V|a|x'])), _vary(None))
check('mismatch', solve(_vary(['B|a', 'E|b'])), _vary(None))
check('unclosed', solve(_vary(['B|@', 'V|a|x'])), _vary(None))
check('duplicate', solve(_vary(['B|a', 'V|x|1', 'V|x|2', 'E|a'])), _vary(None))
check('empty object', solve(_vary(['B|a', 'E|a'])), _vary([['a', {}]]))
check('empty value', solve(_vary(['B|a', 'V|x|', 'E|a'])), _vary([['a', {'x': ''}]]))
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 |
|---|---|---|---|
| groups | [['cell', {'a': 'x'}], ['other', {'a': 'y'}]] | [['cell', {'a': 'x'}], ['other', {'a': 'y'}]] | Passed |
| nested | None | None | Passed |
| orphan | None | None | Passed |
| mismatch | None | None | Passed |
| unclosed | None | None | Passed |
| duplicate | None | None | Passed |
| empty object | [['a', {}]] | [['a', {}]] | Passed |
| empty value | [['a', {'x': ''}]] | [['a', {'x': ''}]] | Passed |
| zero | [] | [] | Passed |
SHA-256 / a26c300d3511e4328896ad8713a0f7f784094aea0505e32417fcdcdb5a3d92e3
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.044540+00:00.
Case digest / 499f625329fcc0cb56c39d1238d3080ca0c47ad02b58bfdc62bfd465b59040ca