FA-48761 / Delimited text / Open access
Repeated edits to the same physical cell are accepted · case 01
A structured table violates the declared record or column contract.
ROOT CAUSE
Repeated edits to the same physical cell are accepted.
VERIFIED REPAIR
Preserve the named invariant at the faulty decision: or index in seen
Unsuccessful approach: The alternate implementation still violates the same declared invariant: repeated edits to the same physical cell are accepted.
Case contract
Apply cell text edits to an unquoted comma row without changing unedited spelling. Edits are [zero-based cell index,replacement text], unique indexes only; replacements cannot contain comma or newline. Compute all source spans before editing and apply from right to left. Out-of-range indexes reject.
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):
text=data['row']; starts=[0]+[i+1 for i,ch in enumerate(text) if ch==',']
ends=[i for i,ch in enumerate(text) if ch==',']+[len(text)]
seen=set(); patches=[]
for index,value in data['edits']:
if not 0<=index<len(starts) : return None
if any(ch in value for ch in ',\r\n'): return None
seen.add(index); patches.append((starts[index],ends[index],value))
for start,end,value in sorted(patches,reverse=True):
text=text[:start]+value+text[end:]
return text
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('vary lengths', solve(_vary({'row': 'a,bbb,c', 'edits': [[0, '@long'], [2, 'z']]})), _vary('@long,bbb,z'))
check('empty field', solve(_vary({'row': 'a,,b', 'edits': [[1, '@']]})), _vary('a,@,b'))
check('empty replacement', solve(_vary({'row': 'a,b,c', 'edits': [[1, '']]})), _vary('a,,c'))
check('duplicate index', solve(_vary({'row': 'a,b', 'edits': [[0, 'x'], [0, 'y']]})), _vary(None))
check('invalid replacement', solve(_vary({'row': 'a,b', 'edits': [[1, 'x,y']]})), _vary(None))
check('out of range', solve(_vary({'row': 'a,b', 'edits': [[2, 'x']]})), _vary(None))
check('preserve spaces', solve(_vary({'row': ' a , b ', 'edits': [[1, '@']]})), _vary(' a ,@'))
check('unicode', solve(_vary({'row': 'é,😀,x', 'edits': [[1, '@']]})), _vary('é,@,x'))
check('no edits', solve(_vary({'row': '@,x', 'edits': []})), _vary('@,x'))
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 |
|---|---|---|---|
| vary lengths | celllong,bbb,z | celllong,bbb,z | Passed |
| empty field | a,cell,b | a,cell,b | Passed |
| empty replacement | a,,c | a,,c | Passed |
| duplicate index | x,b | None | Failed |
| invalid replacement | None | None | Passed |
| out of range | None | None | Passed |
| preserve spaces | a ,cell | a ,cell | Passed |
| unicode | é,cell,x | é,cell,x | Passed |
| no edits | cell,x | cell,x | Passed |
SHA-256 / 58db9d857e14b41f5846dc3bb168eeff8a91b4666791ce69666858a54cc7ab49
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):
text=data['row']; starts=[0]+[i+1 for i,ch in enumerate(text) if ch==',']
ends=[i for i,ch in enumerate(text) if ch==',']+[len(text)]
seen=set(); patches=[]
for index,value in data['edits']:
if not 0<=index<len(starts) or (index in seen and value==''): return None
if any(ch in value for ch in ',\r\n'): return None
seen.add(index); patches.append((starts[index],ends[index],value))
for start,end,value in sorted(patches,reverse=True):
text=text[:start]+value+text[end:]
return text
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('vary lengths', solve(_vary({'row': 'a,bbb,c', 'edits': [[0, '@long'], [2, 'z']]})), _vary('@long,bbb,z'))
check('empty field', solve(_vary({'row': 'a,,b', 'edits': [[1, '@']]})), _vary('a,@,b'))
check('empty replacement', solve(_vary({'row': 'a,b,c', 'edits': [[1, '']]})), _vary('a,,c'))
check('duplicate index', solve(_vary({'row': 'a,b', 'edits': [[0, 'x'], [0, 'y']]})), _vary(None))
check('invalid replacement', solve(_vary({'row': 'a,b', 'edits': [[1, 'x,y']]})), _vary(None))
check('out of range', solve(_vary({'row': 'a,b', 'edits': [[2, 'x']]})), _vary(None))
check('preserve spaces', solve(_vary({'row': ' a , b ', 'edits': [[1, '@']]})), _vary(' a ,@'))
check('unicode', solve(_vary({'row': 'é,😀,x', 'edits': [[1, '@']]})), _vary('é,@,x'))
check('no edits', solve(_vary({'row': '@,x', 'edits': []})), _vary('@,x'))
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 |
|---|---|---|---|
| vary lengths | celllong,bbb,z | celllong,bbb,z | Passed |
| empty field | a,cell,b | a,cell,b | Passed |
| empty replacement | a,,c | a,,c | Passed |
| duplicate index | x,b | None | Failed |
| invalid replacement | None | None | Passed |
| out of range | None | None | Passed |
| preserve spaces | a ,cell | a ,cell | Passed |
| unicode | é,cell,x | é,cell,x | Passed |
| no edits | cell,x | cell,x | Passed |
SHA-256 / 53ac18634d8456d8ce22c35cd3805f30397fcdbb29b8ff5fa35a51eb15e09a39
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):
text=data['row']; starts=[0]+[i+1 for i,ch in enumerate(text) if ch==',']
ends=[i for i,ch in enumerate(text) if ch==',']+[len(text)]
seen=set(); patches=[]
for index,value in data['edits']:
if not 0<=index<len(starts) or index in seen: return None
if any(ch in value for ch in ',\r\n'): return None
seen.add(index); patches.append((starts[index],ends[index],value))
for start,end,value in sorted(patches,reverse=True):
text=text[:start]+value+text[end:]
return text
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('vary lengths', solve(_vary({'row': 'a,bbb,c', 'edits': [[0, '@long'], [2, 'z']]})), _vary('@long,bbb,z'))
check('empty field', solve(_vary({'row': 'a,,b', 'edits': [[1, '@']]})), _vary('a,@,b'))
check('empty replacement', solve(_vary({'row': 'a,b,c', 'edits': [[1, '']]})), _vary('a,,c'))
check('duplicate index', solve(_vary({'row': 'a,b', 'edits': [[0, 'x'], [0, 'y']]})), _vary(None))
check('invalid replacement', solve(_vary({'row': 'a,b', 'edits': [[1, 'x,y']]})), _vary(None))
check('out of range', solve(_vary({'row': 'a,b', 'edits': [[2, 'x']]})), _vary(None))
check('preserve spaces', solve(_vary({'row': ' a , b ', 'edits': [[1, '@']]})), _vary(' a ,@'))
check('unicode', solve(_vary({'row': 'é,😀,x', 'edits': [[1, '@']]})), _vary('é,@,x'))
check('no edits', solve(_vary({'row': '@,x', 'edits': []})), _vary('@,x'))
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 |
|---|---|---|---|
| vary lengths | celllong,bbb,z | celllong,bbb,z | Passed |
| empty field | a,cell,b | a,cell,b | Passed |
| empty replacement | a,,c | a,,c | Passed |
| duplicate index | None | None | Passed |
| invalid replacement | None | None | Passed |
| out of range | None | None | Passed |
| preserve spaces | a ,cell | a ,cell | Passed |
| unicode | é,cell,x | é,cell,x | Passed |
| no edits | cell,x | cell,x | Passed |
SHA-256 / e23f84ea66fae053bc4c869e52195c78fb7a7d544cd7a5a8ba18dd18fc67f595
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.730529+00:00.
Case digest / eabb534eb641d5ff2dd817310838f5e00921de58ce6e0f99054b2ed27f42cd50