FA-48831 / Delimited text / Open access
An empty header component introduces an extra hierarchy separator · case 01
A structured table violates the declared record or column contract.
ROOT CAUSE
An empty header component introduces an extra hierarchy separator.
VERIFIED REPAIR
Preserve the named invariant at the faulty decision: '/'.join(level[i] for level in levels if level[i])
Unsuccessful approach: The alternate implementation still violates the same declared invariant: an empty header component introduces an extra hierarchy separator.
Case contract
Decode a table with an integer preamble giving the number of following physical header rows. Each header row is comma cells; combine corresponding column labels with /, omitting empty components. At least one header row is required, widths must agree, final names must be nonempty and unique. Remaining rows are body and must match width. Return header and body.
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].isascii() or not data[0].isdecimal(): return None
count=int(data[0])
if count<1 or len(data)<count+1: return None
levels=[line.split(',') for line in data[1:count+1]]
width=len(levels[0])
if any(len(level)!=width for level in levels): return None
header=['/'.join(level[i] for level in levels) for i in range(width)]
if any(not name for name in header) or len(set(header))!=width: return None
rows=[line.split(',') for line in data[count+1:]]
if any(len(row)!=width for row in rows): return None
return {'header':header,'rows':rows}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('levels', solve(_vary(['2', 'group,group', 'a,b', '@,z'])), _vary({'header': ['group/a', 'group/b'], 'rows': [['@', 'z']]}))
check('empty components', solve(_vary(['2', 'group,', 'a,b', '@,z'])), _vary({'header': ['group/a', 'b'], 'rows': [['@', 'z']]}))
check('header only', solve(_vary(['1', '@'])), _vary({'header': ['@'], 'rows': []}))
check('bad count', solve(_vary(['0', 'a'])), _vary(None))
check('too few headers', solve(_vary(['2', 'a'])), _vary(None))
check('width mismatch', solve(_vary(['2', 'a,b', 'c'])), _vary(None))
check('duplicate', solve(_vary(['1', 'a,a'])), _vary(None))
check('empty final name', solve(_vary(['2', ',a', ',b'])), _vary(None))
check('body width', solve(_vary(['1', 'a,b', '@'])), _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 |
|---|---|---|---|
| levels | {'header': ['group/a', 'group/b'], 'rows': [['cell', 'z']]} | {'header': ['group/a', 'group/b'], 'rows': [['cell', 'z']]} | Passed |
| empty components | {'header': ['group/a', '/b'], 'rows': [['cell', 'z']]} | {'header': ['group/a', 'b'], 'rows': [['cell', 'z']]} | Failed |
| header only | {'header': ['cell'], 'rows': []} | {'header': ['cell'], 'rows': []} | Passed |
| bad count | None | None | Passed |
| too few headers | None | None | Passed |
| width mismatch | None | None | Passed |
| duplicate | None | None | Passed |
| empty final name | {'header': ['/', 'a/b'], 'rows': []} | None | Failed |
| body width | None | None | Passed |
SHA-256 / e0f14e3b9e171799a542d75424f7bafb9e393f2f2a64be7f01c88ecc0762ac80
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].isascii() or not data[0].isdecimal(): return None
count=int(data[0])
if count<1 or len(data)<count+1: return None
levels=[line.split(',') for line in data[1:count+1]]
width=len(levels[0])
if any(len(level)!=width for level in levels): return None
header=['/'.join(level[i] if level[i] else '_' for level in levels) for i in range(width)]
if any(not name for name in header) or len(set(header))!=width: return None
rows=[line.split(',') for line in data[count+1:]]
if any(len(row)!=width for row in rows): return None
return {'header':header,'rows':rows}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('levels', solve(_vary(['2', 'group,group', 'a,b', '@,z'])), _vary({'header': ['group/a', 'group/b'], 'rows': [['@', 'z']]}))
check('empty components', solve(_vary(['2', 'group,', 'a,b', '@,z'])), _vary({'header': ['group/a', 'b'], 'rows': [['@', 'z']]}))
check('header only', solve(_vary(['1', '@'])), _vary({'header': ['@'], 'rows': []}))
check('bad count', solve(_vary(['0', 'a'])), _vary(None))
check('too few headers', solve(_vary(['2', 'a'])), _vary(None))
check('width mismatch', solve(_vary(['2', 'a,b', 'c'])), _vary(None))
check('duplicate', solve(_vary(['1', 'a,a'])), _vary(None))
check('empty final name', solve(_vary(['2', ',a', ',b'])), _vary(None))
check('body width', solve(_vary(['1', 'a,b', '@'])), _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 |
|---|---|---|---|
| levels | {'header': ['group/a', 'group/b'], 'rows': [['cell', 'z']]} | {'header': ['group/a', 'group/b'], 'rows': [['cell', 'z']]} | Passed |
| empty components | {'header': ['group/a', '_/b'], 'rows': [['cell', 'z']]} | {'header': ['group/a', 'b'], 'rows': [['cell', 'z']]} | Failed |
| header only | {'header': ['cell'], 'rows': []} | {'header': ['cell'], 'rows': []} | Passed |
| bad count | None | None | Passed |
| too few headers | None | None | Passed |
| width mismatch | None | None | Passed |
| duplicate | None | None | Passed |
| empty final name | {'header': ['_/_', 'a/b'], 'rows': []} | None | Failed |
| body width | None | None | Passed |
SHA-256 / 3bae5969b2fe5b272fabb99b6a75a62d7e78380ae4c7293ef24055defff0ecec
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].isascii() or not data[0].isdecimal(): return None
count=int(data[0])
if count<1 or len(data)<count+1: return None
levels=[line.split(',') for line in data[1:count+1]]
width=len(levels[0])
if any(len(level)!=width for level in levels): return None
header=['/'.join(level[i] for level in levels if level[i]) for i in range(width)]
if any(not name for name in header) or len(set(header))!=width: return None
rows=[line.split(',') for line in data[count+1:]]
if any(len(row)!=width for row in rows): return None
return {'header':header,'rows':rows}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('levels', solve(_vary(['2', 'group,group', 'a,b', '@,z'])), _vary({'header': ['group/a', 'group/b'], 'rows': [['@', 'z']]}))
check('empty components', solve(_vary(['2', 'group,', 'a,b', '@,z'])), _vary({'header': ['group/a', 'b'], 'rows': [['@', 'z']]}))
check('header only', solve(_vary(['1', '@'])), _vary({'header': ['@'], 'rows': []}))
check('bad count', solve(_vary(['0', 'a'])), _vary(None))
check('too few headers', solve(_vary(['2', 'a'])), _vary(None))
check('width mismatch', solve(_vary(['2', 'a,b', 'c'])), _vary(None))
check('duplicate', solve(_vary(['1', 'a,a'])), _vary(None))
check('empty final name', solve(_vary(['2', ',a', ',b'])), _vary(None))
check('body width', solve(_vary(['1', 'a,b', '@'])), _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 |
|---|---|---|---|
| levels | {'header': ['group/a', 'group/b'], 'rows': [['cell', 'z']]} | {'header': ['group/a', 'group/b'], 'rows': [['cell', 'z']]} | Passed |
| empty components | {'header': ['group/a', 'b'], 'rows': [['cell', 'z']]} | {'header': ['group/a', 'b'], 'rows': [['cell', 'z']]} | Passed |
| header only | {'header': ['cell'], 'rows': []} | {'header': ['cell'], 'rows': []} | Passed |
| bad count | None | None | Passed |
| too few headers | None | None | Passed |
| width mismatch | None | None | Passed |
| duplicate | None | None | Passed |
| empty final name | None | None | Passed |
| body width | None | None | Passed |
SHA-256 / f721d3361c09056295254294e2c13be31b3d9cbb04627a75e3fc27a1ad41db41
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:54.360917+00:00.
Case digest / fd0b95cbc3d454510d1c249f3af01b96c6e1bae2f1096f6bf66f319c6bdd3c77