FA-47866 / Delimited text / Open access
A body tag is exposed as an additional data cell · case 01
A structured table violates the declared record or column contract.
ROOT CAUSE
The tag discriminator is included in the data column vector.
VERIFIED REPAIR
Preserve the named invariant at the faulty decision: rows.append(cells[1:])
Unsuccessful approach: Removing the final cell with the tag loses a real column.
Case contract
Read a comma table with header H,<column names>, body D,<values>, and final F,<body count>. Reject missing or misplaced footer, count mismatch, malformed tags, unequal body width, and missing header. Count only body records. Return body arrays.
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):
if not data or not data[0].startswith('H,'): return None
width = len(data[0].split(',')) - 1
rows, closed = [], False
for line in data[1:]:
if closed: return None
cells = line.split(',')
if cells[0] == 'D':
if len(cells) - 1 != width: return None
rows.append(cells)
elif cells[0] == 'F':
if len(cells) != 2 or not cells[1].isascii() or not cells[1].isdecimal(): return None
if int(cells[1]) != len(rows): return None
closed = True
else: return None
if not closed: return None
return rows
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('table', solve(_vary(['H,a,b', 'D,@,x', 'D,y,z', 'F,2'])), _vary([['@', 'x'], ['y', 'z']]))
check('count mismatch', solve(_vary(['H,a', 'D,@', 'F,2'])), _vary(None))
check('after footer', solve(_vary(['H,a', 'F,0', 'D,@'])), _vary(None))
check('missing footer', solve(_vary(['H,a', 'D,@'])), _vary(None))
check('empty body', solve(_vary(['H,a', 'F,0'])), _vary([]))
check('bad tag', solve(_vary(['H,a', 'X,@', 'F,1'])), _vary(None))
check('bad width', solve(_vary(['H,a,b', 'D,@', 'F,1'])), _vary(None))
check('missing header', solve(_vary(['D,@', 'F,1'])), _vary(None))
check('second footer', solve(_vary(['H,a', 'F,0', 'F,0'])), _vary(None))
check('bad count', solve(_vary(['H,a', 'F,-1'])), _vary(None))
check('unknown not counted', solve(_vary(['H,a', 'X,@', 'F,0'])), _vary(None))
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 |
|---|---|---|---|
| table | [['D', 'cell', 'x'], ['D', 'y', 'z']] | [['cell', 'x'], ['y', 'z']] | Failed |
| count mismatch | None | None | Passed |
| after footer | None | None | Passed |
| missing footer | None | None | Passed |
| empty body | [] | [] | Passed |
| bad tag | None | None | Passed |
| bad width | None | None | Passed |
| missing header | None | None | Passed |
| second footer | None | None | Passed |
| bad count | None | None | Passed |
| unknown not counted | None | None | Passed |
SHA-256 / 5d2abbdccfa74761b4925b8da815df2db8ee16edc781c5c2fe5b2706812687d9
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):
if not data or not data[0].startswith('H,'): return None
width = len(data[0].split(',')) - 1
rows, closed = [], False
for line in data[1:]:
if closed: return None
cells = line.split(',')
if cells[0] == 'D':
if len(cells) - 1 != width: return None
rows.append(cells[1:-1])
elif cells[0] == 'F':
if len(cells) != 2 or not cells[1].isascii() or not cells[1].isdecimal(): return None
if int(cells[1]) != len(rows): return None
closed = True
else: return None
if not closed: return None
return rows
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('table', solve(_vary(['H,a,b', 'D,@,x', 'D,y,z', 'F,2'])), _vary([['@', 'x'], ['y', 'z']]))
check('count mismatch', solve(_vary(['H,a', 'D,@', 'F,2'])), _vary(None))
check('after footer', solve(_vary(['H,a', 'F,0', 'D,@'])), _vary(None))
check('missing footer', solve(_vary(['H,a', 'D,@'])), _vary(None))
check('empty body', solve(_vary(['H,a', 'F,0'])), _vary([]))
check('bad tag', solve(_vary(['H,a', 'X,@', 'F,1'])), _vary(None))
check('bad width', solve(_vary(['H,a,b', 'D,@', 'F,1'])), _vary(None))
check('missing header', solve(_vary(['D,@', 'F,1'])), _vary(None))
check('second footer', solve(_vary(['H,a', 'F,0', 'F,0'])), _vary(None))
check('bad count', solve(_vary(['H,a', 'F,-1'])), _vary(None))
check('unknown not counted', solve(_vary(['H,a', 'X,@', 'F,0'])), _vary(None))
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 |
|---|---|---|---|
| table | [['cell'], ['y']] | [['cell', 'x'], ['y', 'z']] | Failed |
| count mismatch | None | None | Passed |
| after footer | None | None | Passed |
| missing footer | None | None | Passed |
| empty body | [] | [] | Passed |
| bad tag | None | None | Passed |
| bad width | None | None | Passed |
| missing header | None | None | Passed |
| second footer | None | None | Passed |
| bad count | None | None | Passed |
| unknown not counted | None | None | Passed |
SHA-256 / 45eb1a65224074b53c93f8c1c3aa552a2d3d90f35fe91c43802ab2f06f3ca28b
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):
if not data or not data[0].startswith('H,'): return None
width = len(data[0].split(',')) - 1
rows, closed = [], False
for line in data[1:]:
if closed: return None
cells = line.split(',')
if cells[0] == 'D':
if len(cells) - 1 != width: return None
rows.append(cells[1:])
elif cells[0] == 'F':
if len(cells) != 2 or not cells[1].isascii() or not cells[1].isdecimal(): return None
if int(cells[1]) != len(rows): return None
closed = True
else: return None
if not closed: return None
return rows
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('table', solve(_vary(['H,a,b', 'D,@,x', 'D,y,z', 'F,2'])), _vary([['@', 'x'], ['y', 'z']]))
check('count mismatch', solve(_vary(['H,a', 'D,@', 'F,2'])), _vary(None))
check('after footer', solve(_vary(['H,a', 'F,0', 'D,@'])), _vary(None))
check('missing footer', solve(_vary(['H,a', 'D,@'])), _vary(None))
check('empty body', solve(_vary(['H,a', 'F,0'])), _vary([]))
check('bad tag', solve(_vary(['H,a', 'X,@', 'F,1'])), _vary(None))
check('bad width', solve(_vary(['H,a,b', 'D,@', 'F,1'])), _vary(None))
check('missing header', solve(_vary(['D,@', 'F,1'])), _vary(None))
check('second footer', solve(_vary(['H,a', 'F,0', 'F,0'])), _vary(None))
check('bad count', solve(_vary(['H,a', 'F,-1'])), _vary(None))
check('unknown not counted', solve(_vary(['H,a', 'X,@', 'F,0'])), _vary(None))
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 |
|---|---|---|---|
| table | [['cell', 'x'], ['y', 'z']] | [['cell', 'x'], ['y', 'z']] | Passed |
| count mismatch | None | None | Passed |
| after footer | None | None | Passed |
| missing footer | None | None | Passed |
| empty body | [] | [] | Passed |
| bad tag | None | None | Passed |
| bad width | None | None | Passed |
| missing header | None | None | Passed |
| second footer | None | None | Passed |
| bad count | None | None | Passed |
| unknown not counted | None | None | Passed |
SHA-256 / eff4fab36227655b39d1b05e0a3920c4258817e46c396a4ac93252451db6c6e7
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:45.524811+00:00.
Case digest / 70a82756659bcd407029882d90e7398dcc7071d3e409c8a24738f78047807191