FA-47701 / Delimited text / Open access
Metadata parsing retains its control introducer · case 01
A structured table violates the declared record or column contract.
ROOT CAUSE
The directive prefix is only partly removed before key extraction.
VERIFIED REPAIR
Preserve the named invariant at the faulty decision: pair = line[2:].split('=', 1)
Unsuccessful approach: Keeping the whole prefix further pollutes the metadata key.
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[1:].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']]] | Failed |
| duplicate | None | None | Passed |
| bad directive | None | None | Passed |
| empty name | [{'!': 'value'}, []] | None | Failed |
| empty data | [{}, [['']]] | [{}, [['']]] | Passed |
| marker chain | [{}, [['##data']]] | [{}, [['##data']]] | Passed |
| zero | [{}, []] | [{}, []] | Passed |
SHA-256 / d9cd48ef68028f29f6c762ecd3ac8ccf5a7323802a00ae098ad7cd8d332e4b12
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.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']]] | Failed |
| duplicate | None | None | Passed |
| bad directive | None | None | Passed |
| empty name | [{'#!': 'value'}, []] | None | Failed |
| empty data | [{}, [['']]] | [{}, [['']]] | Passed |
| marker chain | [{}, [['##data']]] | [{}, [['##data']]] | Passed |
| zero | [{}, []] | [{}, []] | Passed |
SHA-256 / dac444e7a0a0c78b47260413ea88c536468fb3428ddb0ee766e9e82811e6f70d
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:44.043441+00:00.
Case digest / 394b4752a1a751a2ed83dc03ad44abe719eae96d8f21abfa59670035be9fdba1