FA-47691 / Delimited text / Open access
A second metadata directive changes an established interpretation · case 01
A structured table violates the declared record or column contract.
ROOT CAUSE
Duplicate metadata overwrites the earlier schema context.
VERIFIED REPAIR
Preserve the named invariant at the faulty decision: if key in meta: return None
Unsuccessful approach: Silently keeping the first value still accepts an ambiguous document.
Case contract
Process already framed pipe records. Column-zero # starts a comment except ## encodes a literal leading # data record. A column-zero #!name=value directive sets a unique metadata name; malformed or duplicate directives reject. Other records, including leading-space # and empty records, are data. Return metadata and data rows.
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):
meta, rows = {}, []
for line in data:
if line.startswith('##'): rows.append(line[1:].split('|'))
elif line.startswith('#!'):
pair = line[2:].split('=', 1)
if len(pair) != 2 or not pair[0]: return None
key, value = pair
if False: return None
meta[key] = value
elif line.startswith('#'): continue
else: rows.append(line.split('|'))
return [meta, rows]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('comments', solve(_vary(['# comment', '@|x'])), _vary([{}, [['@', 'x']]]))
check('escaped marker', solve(_vary(['##literal|@'])), _vary([{}, [['#literal', '@']]]))
check('space prefix', solve(_vary([' # data|@'])), _vary([{}, [[' # data', '@']]]))
check('metadata', solve(_vary(['#!unit=a=b', '@|x'])), _vary([{'unit': 'a=b'}, [['@', 'x']]]))
check('duplicate', solve(_vary(['#!x=1', '#!x=2'])), _vary(None))
check('bad directive', solve(_vary(['#!x'])), _vary(None))
check('empty name', solve(_vary(['#!=value'])), _vary(None))
check('empty data', solve(_vary([''])), _vary([{}, [['']]]))
check('marker chain', solve(_vary(['###data'])), _vary([{}, [['##data']]]))
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 |
|---|---|---|---|
| comments | [{}, [['cell', 'x']]] | [{}, [['cell', 'x']]] | Passed |
| escaped marker | [{}, [['#literal', 'cell']]] | [{}, [['#literal', 'cell']]] | Passed |
| space prefix | [{}, [[' # data', 'cell']]] | [{}, [[' # data', 'cell']]] | Passed |
| metadata | [{'unit': 'a=b'}, [['cell', 'x']]] | [{'unit': 'a=b'}, [['cell', 'x']]] | Passed |
| duplicate | [{'x': '2'}, []] | None | Failed |
| bad directive | None | None | Passed |
| empty name | None | None | Passed |
| empty data | [{}, [['']]] | [{}, [['']]] | Passed |
| marker chain | [{}, [['##data']]] | [{}, [['##data']]] | Passed |
| zero | [{}, []] | [{}, []] | Passed |
SHA-256 / e6e23370b139e7f038f43e6f54a3bc464f8cb11a49d8b489555aba250b4aec00
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):
meta, rows = {}, []
for line in data:
if line.startswith('##'): rows.append(line[1:].split('|'))
elif line.startswith('#!'):
pair = line[2:].split('=', 1)
if len(pair) != 2 or not pair[0]: return None
key, value = pair
if key in meta: continue
meta[key] = value
elif line.startswith('#'): continue
else: rows.append(line.split('|'))
return [meta, rows]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('comments', solve(_vary(['# comment', '@|x'])), _vary([{}, [['@', 'x']]]))
check('escaped marker', solve(_vary(['##literal|@'])), _vary([{}, [['#literal', '@']]]))
check('space prefix', solve(_vary([' # data|@'])), _vary([{}, [[' # data', '@']]]))
check('metadata', solve(_vary(['#!unit=a=b', '@|x'])), _vary([{'unit': 'a=b'}, [['@', 'x']]]))
check('duplicate', solve(_vary(['#!x=1', '#!x=2'])), _vary(None))
check('bad directive', solve(_vary(['#!x'])), _vary(None))
check('empty name', solve(_vary(['#!=value'])), _vary(None))
check('empty data', solve(_vary([''])), _vary([{}, [['']]]))
check('marker chain', solve(_vary(['###data'])), _vary([{}, [['##data']]]))
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 |
|---|---|---|---|
| comments | [{}, [['cell', 'x']]] | [{}, [['cell', 'x']]] | Passed |
| escaped marker | [{}, [['#literal', 'cell']]] | [{}, [['#literal', 'cell']]] | Passed |
| space prefix | [{}, [[' # data', 'cell']]] | [{}, [[' # data', 'cell']]] | Passed |
| metadata | [{'unit': 'a=b'}, [['cell', 'x']]] | [{'unit': 'a=b'}, [['cell', 'x']]] | Passed |
| duplicate | [{'x': '1'}, []] | None | Failed |
| bad directive | None | None | Passed |
| empty name | None | None | Passed |
| empty data | [{}, [['']]] | [{}, [['']]] | Passed |
| marker chain | [{}, [['##data']]] | [{}, [['##data']]] | Passed |
| zero | [{}, []] | [{}, []] | Passed |
SHA-256 / fe9ad89adbdd53557fbcd565d35a7623c56dff2f275a61c60b8b7b98051b2ac1
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):
meta, rows = {}, []
for line in data:
if line.startswith('##'): rows.append(line[1:].split('|'))
elif line.startswith('#!'):
pair = line[2:].split('=', 1)
if len(pair) != 2 or not pair[0]: return None
key, value = pair
if key in meta: return None
meta[key] = value
elif line.startswith('#'): continue
else: rows.append(line.split('|'))
return [meta, rows]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('comments', solve(_vary(['# comment', '@|x'])), _vary([{}, [['@', 'x']]]))
check('escaped marker', solve(_vary(['##literal|@'])), _vary([{}, [['#literal', '@']]]))
check('space prefix', solve(_vary([' # data|@'])), _vary([{}, [[' # data', '@']]]))
check('metadata', solve(_vary(['#!unit=a=b', '@|x'])), _vary([{'unit': 'a=b'}, [['@', 'x']]]))
check('duplicate', solve(_vary(['#!x=1', '#!x=2'])), _vary(None))
check('bad directive', solve(_vary(['#!x'])), _vary(None))
check('empty name', solve(_vary(['#!=value'])), _vary(None))
check('empty data', solve(_vary([''])), _vary([{}, [['']]]))
check('marker chain', solve(_vary(['###data'])), _vary([{}, [['##data']]]))
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 |
|---|---|---|---|
| comments | [{}, [['cell', 'x']]] | [{}, [['cell', 'x']]] | Passed |
| escaped marker | [{}, [['#literal', 'cell']]] | [{}, [['#literal', 'cell']]] | Passed |
| space prefix | [{}, [[' # data', 'cell']]] | [{}, [[' # data', 'cell']]] | Passed |
| metadata | [{'unit': 'a=b'}, [['cell', 'x']]] | [{'unit': 'a=b'}, [['cell', 'x']]] | Passed |
| duplicate | None | None | Passed |
| bad directive | None | None | Passed |
| empty name | None | None | Passed |
| empty data | [{}, [['']]] | [{}, [['']]] | Passed |
| marker chain | [{}, [['##data']]] | [{}, [['##data']]] | Passed |
| zero | [{}, []] | [{}, []] | Passed |
SHA-256 / c949a9629cf94579fedf19126f589a3255cfeb34d192daea8ddd5ef4b54718b3
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:43.836842+00:00.
Case digest / b68a49763de243746a16be531068a883a1960d868268123103a253fa521fee52