FAILURE MAP
← Case archive

FA-48411 / Delimited text / Open access

Each rearranged row retains an extra slot for the order directive · case 01

A structured table violates the declared record or column contract.

Verified by executionVariant 1 · 7 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Each rearranged row retains an extra slot for the order directive.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: row=[None]*width

Unsuccessful approach: The alternate implementation still violates the same declared invariant: each rearranged row retains an extra slot for the order directive.

Case contract

Process an initial comma header plus ORDER|comma-indexes and DATA|comma-values records. ORDER is a zero-based permutation describing each incoming position original column index. Each new order replaces the previous order. DATA is rearranged into original header order. Reject invalid permutations and row widths.

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):
    width=len(data[0].split(',')); order=list(range(width)); rows=[]
    for line in data[1:]:
        tag,payload=(line.split('|',1)+[''])[:2]
        fields=payload.split(',')
        if tag=='ORDER':
            if any(not x.isascii() or not x.isdecimal() for x in fields): return None
            proposal=[int(x) for x in fields]
            if sorted(proposal)!=list(range(width)): return None
            order=proposal
        elif tag=='DATA':
            if len(fields)!=width: return None
            row=[None]*(width+1)
            for position,original in enumerate(order): row[original]=fields[position]
            rows.append(row)
        else: return None
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cyclic', solve(_vary(['a,b,c', 'ORDER|2,0,1', 'DATA|z,@,y'])), _vary([['@', 'y', 'z']]))
check('replace', solve(_vary(['a,b,c', 'ORDER|2,0,1', 'ORDER|1,2,0', 'DATA|y,z,@'])), _vary([['@', 'y', 'z']]))
check('duplicate order', solve(_vary(['a,b', 'ORDER|0,0'])), _vary(None))
check('out of range', solve(_vary(['a,b', 'ORDER|0,2'])), _vary(None))
check('wrong width', solve(_vary(['a,b', 'DATA|@'])), _vary(None))
check('identity', solve(_vary(['a,b', 'DATA|@,z'])), _vary([['@', 'z']]))
check('reset', solve(_vary(['a,b', 'ORDER|1,0', 'DATA|x,@', 'ORDER|0,1', 'DATA|@,y'])), _vary([['@', 'x'], ['@', 'y']]))
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 fixtureActualExpectedOutcome
cyclic[['cell', 'y', 'z', None]][['cell', 'y', 'z']]Failed
replace[['cell', 'y', 'z', None]][['cell', 'y', 'z']]Failed
duplicate orderNoneNonePassed
out of rangeNoneNonePassed
wrong widthNoneNonePassed
identity[['cell', 'z', None]][['cell', 'z']]Failed
reset[['cell', 'x', None], ['cell', 'y', None]][['cell', 'x'], ['cell', 'y']]Failed

SHA-256 / 9bb4e0edd827bcdd8b8c70e24f683694339ba4dff538c4f2262b5b09a7330e98

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):
    width=len(data[0].split(',')); order=list(range(width)); rows=[]
    for line in data[1:]:
        tag,payload=(line.split('|',1)+[''])[:2]
        fields=payload.split(',')
        if tag=='ORDER':
            if any(not x.isascii() or not x.isdecimal() for x in fields): return None
            proposal=[int(x) for x in fields]
            if sorted(proposal)!=list(range(width)): return None
            order=proposal
        elif tag=='DATA':
            if len(fields)!=width: return None
            row=[None]*(width*2)
            for position,original in enumerate(order): row[original]=fields[position]
            rows.append(row)
        else: return None
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cyclic', solve(_vary(['a,b,c', 'ORDER|2,0,1', 'DATA|z,@,y'])), _vary([['@', 'y', 'z']]))
check('replace', solve(_vary(['a,b,c', 'ORDER|2,0,1', 'ORDER|1,2,0', 'DATA|y,z,@'])), _vary([['@', 'y', 'z']]))
check('duplicate order', solve(_vary(['a,b', 'ORDER|0,0'])), _vary(None))
check('out of range', solve(_vary(['a,b', 'ORDER|0,2'])), _vary(None))
check('wrong width', solve(_vary(['a,b', 'DATA|@'])), _vary(None))
check('identity', solve(_vary(['a,b', 'DATA|@,z'])), _vary([['@', 'z']]))
check('reset', solve(_vary(['a,b', 'ORDER|1,0', 'DATA|x,@', 'ORDER|0,1', 'DATA|@,y'])), _vary([['@', 'x'], ['@', 'y']]))
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 fixtureActualExpectedOutcome
cyclic[['cell', 'y', 'z', None, None, None]][['cell', 'y', 'z']]Failed
replace[['cell', 'y', 'z', None, None, None]][['cell', 'y', 'z']]Failed
duplicate orderNoneNonePassed
out of rangeNoneNonePassed
wrong widthNoneNonePassed
identity[['cell', 'z', None, None]][['cell', 'z']]Failed
reset[['cell', 'x', None, None], ['cell', 'y', None, None]][['cell', 'x'], ['cell', 'y']]Failed

SHA-256 / 0461245f643311e9c012d9a6da95eefa0d4d6e55dc5bc957f187f847fecb6884

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):
    width=len(data[0].split(',')); order=list(range(width)); rows=[]
    for line in data[1:]:
        tag,payload=(line.split('|',1)+[''])[:2]
        fields=payload.split(',')
        if tag=='ORDER':
            if any(not x.isascii() or not x.isdecimal() for x in fields): return None
            proposal=[int(x) for x in fields]
            if sorted(proposal)!=list(range(width)): return None
            order=proposal
        elif tag=='DATA':
            if len(fields)!=width: return None
            row=[None]*width
            for position,original in enumerate(order): row[original]=fields[position]
            rows.append(row)
        else: return None
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cyclic', solve(_vary(['a,b,c', 'ORDER|2,0,1', 'DATA|z,@,y'])), _vary([['@', 'y', 'z']]))
check('replace', solve(_vary(['a,b,c', 'ORDER|2,0,1', 'ORDER|1,2,0', 'DATA|y,z,@'])), _vary([['@', 'y', 'z']]))
check('duplicate order', solve(_vary(['a,b', 'ORDER|0,0'])), _vary(None))
check('out of range', solve(_vary(['a,b', 'ORDER|0,2'])), _vary(None))
check('wrong width', solve(_vary(['a,b', 'DATA|@'])), _vary(None))
check('identity', solve(_vary(['a,b', 'DATA|@,z'])), _vary([['@', 'z']]))
check('reset', solve(_vary(['a,b', 'ORDER|1,0', 'DATA|x,@', 'ORDER|0,1', 'DATA|@,y'])), _vary([['@', 'x'], ['@', 'y']]))
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 fixtureActualExpectedOutcome
cyclic[['cell', 'y', 'z']][['cell', 'y', 'z']]Passed
replace[['cell', 'y', 'z']][['cell', 'y', 'z']]Passed
duplicate orderNoneNonePassed
out of rangeNoneNonePassed
wrong widthNoneNonePassed
identity[['cell', 'z']][['cell', 'z']]Passed
reset[['cell', 'x'], ['cell', 'y']][['cell', 'x'], ['cell', 'y']]Passed

SHA-256 / 5c76e57712bb68f17e8aa38ae7a2e03b9248b2b0214b458169b8d131ecd72d4d

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:50.539296+00:00.

Case digest / d9ae8812480e5353dc536cb497f6af15ab56d514e4dbb71be2ac7a698a4b9391