FA-48341 / Delimited text / Open access
Dictionary-coded row references are sorted before expansion · case 01
A structured table violates the declared record or column contract.
ROOT CAUSE
Dictionary-coded row references are sorted before expansion.
VERIFIED REPAIR
Preserve the named invariant at the faulty decision: rows.append([dictionary[key] for key in ids])
Unsuccessful approach: The alternate implementation still violates the same declared invariant: dictionary-coded row references are sorted before expansion.
Case contract
Read pipe records DEF|id|literal and ROW|comma-separated IDs. Definitions are immutable; rows may reference only preceding IDs, and preserve repeated references. Literal definition payloads may contain pipes. Return expanded text rows. An empty ROW payload is a zero-cell row.
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):
dictionary,rows={},[]
for line in data:
parts=line.split('|',2)
if parts[0]=='DEF' and len(parts)==3:
if parts[1] in dictionary: return None
dictionary[parts[1]]=parts[2]
elif parts[0]=='ROW' and len(parts)==2:
ids=parts[1].split(',') if parts[1] else []
if any(key not in dictionary for key in ids): return None
rows.append([dictionary[key] for key in sorted(ids)])
else: return None
return rows
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeat refs', solve(_vary(['DEF|a|@', 'DEF|b|z', 'ROW|a,b,a'])), _vary([['@', 'z', '@']]))
check('ordered refs', solve(_vary(['DEF|a|@', 'DEF|b|z', 'ROW|a,b'])), _vary([['@', 'z']]))
check('literal pipes', solve(_vary(['DEF|a|x|y', 'ROW|a'])), _vary([['x|y']]))
check('unknown', solve(_vary(['ROW|a', 'DEF|a|x'])), _vary(None))
check('redefine', solve(_vary(['DEF|a|x', 'DEF|a|y'])), _vary(None))
check('empty row', solve(_vary(['ROW|'])), _vary([[]]))
check('empty literal', solve(_vary(['DEF|a|', 'ROW|a'])), _vary([['']]))
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 |
|---|---|---|---|
| repeat refs | [['cell', 'cell', 'z']] | [['cell', 'z', 'cell']] | Failed |
| ordered refs | [['cell', 'z']] | [['cell', 'z']] | Passed |
| literal pipes | [['x|y']] | [['x|y']] | Passed |
| unknown | None | None | Passed |
| redefine | None | None | Passed |
| empty row | [[]] | [[]] | Passed |
| empty literal | [['']] | [['']] | Passed |
| zero | [] | [] | Passed |
SHA-256 / 44da55ac1e7869b451d421b5783c2af49447f391e59c17b0d24b38fdd21fe3d8
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):
dictionary,rows={},[]
for line in data:
parts=line.split('|',2)
if parts[0]=='DEF' and len(parts)==3:
if parts[1] in dictionary: return None
dictionary[parts[1]]=parts[2]
elif parts[0]=='ROW' and len(parts)==2:
ids=parts[1].split(',') if parts[1] else []
if any(key not in dictionary for key in ids): return None
rows.append([dictionary[key] for key in reversed(ids)])
else: return None
return rows
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeat refs', solve(_vary(['DEF|a|@', 'DEF|b|z', 'ROW|a,b,a'])), _vary([['@', 'z', '@']]))
check('ordered refs', solve(_vary(['DEF|a|@', 'DEF|b|z', 'ROW|a,b'])), _vary([['@', 'z']]))
check('literal pipes', solve(_vary(['DEF|a|x|y', 'ROW|a'])), _vary([['x|y']]))
check('unknown', solve(_vary(['ROW|a', 'DEF|a|x'])), _vary(None))
check('redefine', solve(_vary(['DEF|a|x', 'DEF|a|y'])), _vary(None))
check('empty row', solve(_vary(['ROW|'])), _vary([[]]))
check('empty literal', solve(_vary(['DEF|a|', 'ROW|a'])), _vary([['']]))
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 |
|---|---|---|---|
| repeat refs | [['cell', 'z', 'cell']] | [['cell', 'z', 'cell']] | Passed |
| ordered refs | [['z', 'cell']] | [['cell', 'z']] | Failed |
| literal pipes | [['x|y']] | [['x|y']] | Passed |
| unknown | None | None | Passed |
| redefine | None | None | Passed |
| empty row | [[]] | [[]] | Passed |
| empty literal | [['']] | [['']] | Passed |
| zero | [] | [] | Passed |
SHA-256 / a245feefc1bf37c9c9e9556220d91bbcca2a8bae01253ea32cca13f61d367697
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):
dictionary,rows={},[]
for line in data:
parts=line.split('|',2)
if parts[0]=='DEF' and len(parts)==3:
if parts[1] in dictionary: return None
dictionary[parts[1]]=parts[2]
elif parts[0]=='ROW' and len(parts)==2:
ids=parts[1].split(',') if parts[1] else []
if any(key not in dictionary for key in ids): return None
rows.append([dictionary[key] for key in ids])
else: return None
return rows
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeat refs', solve(_vary(['DEF|a|@', 'DEF|b|z', 'ROW|a,b,a'])), _vary([['@', 'z', '@']]))
check('ordered refs', solve(_vary(['DEF|a|@', 'DEF|b|z', 'ROW|a,b'])), _vary([['@', 'z']]))
check('literal pipes', solve(_vary(['DEF|a|x|y', 'ROW|a'])), _vary([['x|y']]))
check('unknown', solve(_vary(['ROW|a', 'DEF|a|x'])), _vary(None))
check('redefine', solve(_vary(['DEF|a|x', 'DEF|a|y'])), _vary(None))
check('empty row', solve(_vary(['ROW|'])), _vary([[]]))
check('empty literal', solve(_vary(['DEF|a|', 'ROW|a'])), _vary([['']]))
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 |
|---|---|---|---|
| repeat refs | [['cell', 'z', 'cell']] | [['cell', 'z', 'cell']] | Passed |
| ordered refs | [['cell', 'z']] | [['cell', 'z']] | Passed |
| literal pipes | [['x|y']] | [['x|y']] | Passed |
| unknown | None | None | Passed |
| redefine | None | None | Passed |
| empty row | [[]] | [[]] | Passed |
| empty literal | [['']] | [['']] | Passed |
| zero | [] | [] | Passed |
SHA-256 / 72515b60f3c4e11bbf7561051385163a19a02b94ca3739cc371eef9dcf98a085
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:49.890206+00:00.
Case digest / c090761b5c83b281eb8e26fb509c6217458742244533e34de122dc9570af62c4