FA-48591 / Delimited text / Open access
Table union sorts column names instead of retaining discovery order · case 01
A structured table violates the declared record or column contract.
ROOT CAUSE
Table union sorts column names instead of retaining discovery order.
THE FAILURE
Table union sorts column names instead of retaining discovery order.
Unsuccessful approach: The alternate implementation still violates the same declared invariant: table union sorts column names instead of retaining discovery order.
Case contract
Combine a list of tables, each {header:[names], rows:[[cells]]}. Output header is the first-seen union of names, preserving first-seen order. Duplicate names within one input header and row-width mismatches reject. Missing columns in a table become null; explicit empty values remain empty. Return {header,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):
header=[]
for table in data:
if len(set(table['header']))!=len(table['header']): return None
for name in table['header']:
if name not in header: header.append(name)
out=[]
for table in data:
for row in table['rows']:
if len(row)!=len(table['header']): return None
mapping=dict(zip(table['header'],row))
out.append([mapping.get(name) for name in header])
return {'header':sorted(header),'rows':out}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('union', solve(_vary([{'header': ['b', 'a'], 'rows': [['@', 'x']]}, {'header': ['a', 'c'], 'rows': [['y', 'z']]}])), _vary({'header': ['b', 'a', 'c'], 'rows': [['@', 'x', None], [None, 'y', 'z']]}))
check('reordered', solve(_vary([{'header': ['a', 'b'], 'rows': [['@', 'x']]}, {'header': ['b', 'a'], 'rows': [['z', 'y']]}])), _vary({'header': ['a', 'b'], 'rows': [['@', 'x'], ['y', 'z']]}))
check('duplicate', solve(_vary([{'header': ['a', 'a'], 'rows': []}])), _vary(None))
check('ragged', solve(_vary([{'header': ['a', 'b'], 'rows': [['@']]}])), _vary(None))
check('explicit empty', solve(_vary([{'header': ['a'], 'rows': [['']]}, {'header': ['b'], 'rows': [['@']]}])), _vary({'header': ['a', 'b'], 'rows': [['', None], [None, '@']]}))
check('empty', solve(_vary([])), _vary({'header': [], 'rows': []}))
check('header only', solve(_vary([{'header': ['@'], 'rows': []}])), _vary({'header': ['@'], 'rows': []}))
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 |
|---|---|---|---|
| union | {'header': ['a', 'b', 'c'], 'rows': [['cell', 'x', None], [None, 'y', 'z']]} | {'header': ['b', 'a', 'c'], 'rows': [['cell', 'x', None], [None, 'y', 'z']]} | Failed |
| reordered | {'header': ['a', 'b'], 'rows': [['cell', 'x'], ['y', 'z']]} | {'header': ['a', 'b'], 'rows': [['cell', 'x'], ['y', 'z']]} | Passed |
| duplicate | None | None | Passed |
| ragged | None | None | Passed |
| explicit empty | {'header': ['a', 'b'], 'rows': [['', None], [None, 'cell']]} | {'header': ['a', 'b'], 'rows': [['', None], [None, 'cell']]} | Passed |
| empty | {'header': [], 'rows': []} | {'header': [], 'rows': []} | Passed |
| header only | {'header': ['cell'], 'rows': []} | {'header': ['cell'], 'rows': []} | Passed |
SHA-256 / 334c8370b51fa71cb8808fec9e032a9f41dece62a3dcbdd4f54e4e61a2dd78ec
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):
header=[]
for table in data:
if len(set(table['header']))!=len(table['header']): return None
for name in table['header']:
if name not in header: header.append(name)
out=[]
for table in data:
for row in table['rows']:
if len(row)!=len(table['header']): return None
mapping=dict(zip(table['header'],row))
out.append([mapping.get(name) for name in header])
return {'header':list(reversed(header)),'rows':out}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('union', solve(_vary([{'header': ['b', 'a'], 'rows': [['@', 'x']]}, {'header': ['a', 'c'], 'rows': [['y', 'z']]}])), _vary({'header': ['b', 'a', 'c'], 'rows': [['@', 'x', None], [None, 'y', 'z']]}))
check('reordered', solve(_vary([{'header': ['a', 'b'], 'rows': [['@', 'x']]}, {'header': ['b', 'a'], 'rows': [['z', 'y']]}])), _vary({'header': ['a', 'b'], 'rows': [['@', 'x'], ['y', 'z']]}))
check('duplicate', solve(_vary([{'header': ['a', 'a'], 'rows': []}])), _vary(None))
check('ragged', solve(_vary([{'header': ['a', 'b'], 'rows': [['@']]}])), _vary(None))
check('explicit empty', solve(_vary([{'header': ['a'], 'rows': [['']]}, {'header': ['b'], 'rows': [['@']]}])), _vary({'header': ['a', 'b'], 'rows': [['', None], [None, '@']]}))
check('empty', solve(_vary([])), _vary({'header': [], 'rows': []}))
check('header only', solve(_vary([{'header': ['@'], 'rows': []}])), _vary({'header': ['@'], 'rows': []}))
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 |
|---|---|---|---|
| union | {'header': ['c', 'a', 'b'], 'rows': [['cell', 'x', None], [None, 'y', 'z']]} | {'header': ['b', 'a', 'c'], 'rows': [['cell', 'x', None], [None, 'y', 'z']]} | Failed |
| reordered | {'header': ['b', 'a'], 'rows': [['cell', 'x'], ['y', 'z']]} | {'header': ['a', 'b'], 'rows': [['cell', 'x'], ['y', 'z']]} | Failed |
| duplicate | None | None | Passed |
| ragged | None | None | Passed |
| explicit empty | {'header': ['b', 'a'], 'rows': [['', None], [None, 'cell']]} | {'header': ['a', 'b'], 'rows': [['', None], [None, 'cell']]} | Failed |
| empty | {'header': [], 'rows': []} | {'header': [], 'rows': []} | Passed |
| header only | {'header': ['cell'], 'rows': []} | {'header': ['cell'], 'rows': []} | Passed |
SHA-256 / a1d298ac6c55f17d5465a4dee7e38cdfac2ecfa07015c73a6569c14c2b077e9f
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 7 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗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:52.393584+00:00.
Case digest / 89e221a0ccb7325150399ed6939edbbfedc72473cab21854ac2329c110c67383