FAILURE MAP
← Case archive

FA-48696 / Delimited text / Open access

Message row decoding swaps sender and recipient · case 01

A structured table violates the declared record or column contract.

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

ROOT CAUSE

Message row decoding swaps sender and recipient.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: 'from':cells[1],'to':cells[2]

Unsuccessful approach: The alternate implementation still violates the same declared invariant: message row decoding swaps sender and recipient.

Case contract

Decode tagged comma rows. P,name,age represents a person with canonical unsigned ASCII integer age; M,from,to,text represents a message with text that may be empty. Unknown tags and wrong arities reject. Return tagged dictionaries in source order.

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):
    out=[]
    for line in data:
        cells=line.split(',')
        if cells[0]=='P':
            if len(cells)!=3: return None
            if not cells[2].isascii() or not cells[2].isdecimal() or str(int(cells[2]))!=cells[2]: return None
            out.append({'kind':'person','name':cells[1],'age':int(cells[2])})
        elif cells[0]=='M':
            if len(cells)!=4: return None
            out.append({'kind':'message','from':cells[2],'to':cells[1],'text':cells[3]})
        else: return None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mixed', solve(_vary(['P,@,12', 'M,a,b,hello'])), _vary([{'kind': 'person', 'name': '@', 'age': 12}, {'kind': 'message', 'from': 'a', 'to': 'b', 'text': 'hello'}]))
check('empty text', solve(_vary(['M,a,b,'])), _vary([{'kind': 'message', 'from': 'a', 'to': 'b', 'text': ''}]))
check('zero age', solve(_vary(['P,@,0'])), _vary([{'kind': 'person', 'name': '@', 'age': 0}]))
check('bad tag', solve(_vary(['X,a,b'])), _vary(None))
check('wrong person', solve(_vary(['P,a,12,x'])), _vary(None))
check('wrong message', solve(_vary(['M,a,b'])), _vary(None))
check('leading zero', solve(_vary(['P,@,01'])), _vary(None))
check('empty', 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 fixtureActualExpectedOutcome
mixed[{'age': 12, 'kind': 'person', 'name': 'cell'}, {'from': 'b', 'kind': 'message', 'text': 'hello', 'to': 'a'}][{'age': 12, 'kind': 'person', 'name': 'cell'}, {'from': 'a', 'kind': 'message', 'text': 'hello', 'to': 'b'}]Failed
empty text[{'from': 'b', 'kind': 'message', 'text': '', 'to': 'a'}][{'from': 'a', 'kind': 'message', 'text': '', 'to': 'b'}]Failed
zero age[{'age': 0, 'kind': 'person', 'name': 'cell'}][{'age': 0, 'kind': 'person', 'name': 'cell'}]Passed
bad tagNoneNonePassed
wrong personNoneNonePassed
wrong messageNoneNonePassed
leading zeroNoneNonePassed
empty[][]Passed

SHA-256 / 0d15d1b07212d4000b302e1457a7e072204765d1334d5298b59e16dd894a299e

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):
    out=[]
    for line in data:
        cells=line.split(',')
        if cells[0]=='P':
            if len(cells)!=3: return None
            if not cells[2].isascii() or not cells[2].isdecimal() or str(int(cells[2]))!=cells[2]: return None
            out.append({'kind':'person','name':cells[1],'age':int(cells[2])})
        elif cells[0]=='M':
            if len(cells)!=4: return None
            out.append({'kind':'message','from':cells[1],'to':cells[1],'text':cells[3]})
        else: return None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mixed', solve(_vary(['P,@,12', 'M,a,b,hello'])), _vary([{'kind': 'person', 'name': '@', 'age': 12}, {'kind': 'message', 'from': 'a', 'to': 'b', 'text': 'hello'}]))
check('empty text', solve(_vary(['M,a,b,'])), _vary([{'kind': 'message', 'from': 'a', 'to': 'b', 'text': ''}]))
check('zero age', solve(_vary(['P,@,0'])), _vary([{'kind': 'person', 'name': '@', 'age': 0}]))
check('bad tag', solve(_vary(['X,a,b'])), _vary(None))
check('wrong person', solve(_vary(['P,a,12,x'])), _vary(None))
check('wrong message', solve(_vary(['M,a,b'])), _vary(None))
check('leading zero', solve(_vary(['P,@,01'])), _vary(None))
check('empty', 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 fixtureActualExpectedOutcome
mixed[{'age': 12, 'kind': 'person', 'name': 'cell'}, {'from': 'a', 'kind': 'message', 'text': 'hello', 'to': 'a'}][{'age': 12, 'kind': 'person', 'name': 'cell'}, {'from': 'a', 'kind': 'message', 'text': 'hello', 'to': 'b'}]Failed
empty text[{'from': 'a', 'kind': 'message', 'text': '', 'to': 'a'}][{'from': 'a', 'kind': 'message', 'text': '', 'to': 'b'}]Failed
zero age[{'age': 0, 'kind': 'person', 'name': 'cell'}][{'age': 0, 'kind': 'person', 'name': 'cell'}]Passed
bad tagNoneNonePassed
wrong personNoneNonePassed
wrong messageNoneNonePassed
leading zeroNoneNonePassed
empty[][]Passed

SHA-256 / d4a8e1b0d78388b490379e327bb6b58c647bcd09d3b33e5b02b40dded240adda

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):
    out=[]
    for line in data:
        cells=line.split(',')
        if cells[0]=='P':
            if len(cells)!=3: return None
            if not cells[2].isascii() or not cells[2].isdecimal() or str(int(cells[2]))!=cells[2]: return None
            out.append({'kind':'person','name':cells[1],'age':int(cells[2])})
        elif cells[0]=='M':
            if len(cells)!=4: return None
            out.append({'kind':'message','from':cells[1],'to':cells[2],'text':cells[3]})
        else: return None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mixed', solve(_vary(['P,@,12', 'M,a,b,hello'])), _vary([{'kind': 'person', 'name': '@', 'age': 12}, {'kind': 'message', 'from': 'a', 'to': 'b', 'text': 'hello'}]))
check('empty text', solve(_vary(['M,a,b,'])), _vary([{'kind': 'message', 'from': 'a', 'to': 'b', 'text': ''}]))
check('zero age', solve(_vary(['P,@,0'])), _vary([{'kind': 'person', 'name': '@', 'age': 0}]))
check('bad tag', solve(_vary(['X,a,b'])), _vary(None))
check('wrong person', solve(_vary(['P,a,12,x'])), _vary(None))
check('wrong message', solve(_vary(['M,a,b'])), _vary(None))
check('leading zero', solve(_vary(['P,@,01'])), _vary(None))
check('empty', 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 fixtureActualExpectedOutcome
mixed[{'age': 12, 'kind': 'person', 'name': 'cell'}, {'from': 'a', 'kind': 'message', 'text': 'hello', 'to': 'b'}][{'age': 12, 'kind': 'person', 'name': 'cell'}, {'from': 'a', 'kind': 'message', 'text': 'hello', 'to': 'b'}]Passed
empty text[{'from': 'a', 'kind': 'message', 'text': '', 'to': 'b'}][{'from': 'a', 'kind': 'message', 'text': '', 'to': 'b'}]Passed
zero age[{'age': 0, 'kind': 'person', 'name': 'cell'}][{'age': 0, 'kind': 'person', 'name': 'cell'}]Passed
bad tagNoneNonePassed
wrong personNoneNonePassed
wrong messageNoneNonePassed
leading zeroNoneNonePassed
empty[][]Passed

SHA-256 / d62b2209ed5e60b6b25b7ee1edd34e1ddd582a9ddbe5ee76b17a91ffdae93fe8

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

Case digest / 73f9fd431a26030e5484ea504d409e86b39349b7bc5cf411e692a4c7892862cf