{"abstract":"A structured table violates the declared record or column contract.","category":"Delimited text","checks":9,"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.","evaluation_group":"s3-delimited-text-raw-cell-patches","failed_approach":"The alternate implementation still violates the same declared invariant: earlier cell edits invalidate offsets used by later edits.","family":"s3-delimited-text-raw-cell-patches-patch-order","id":"FA-48741","implementations":{"attempt":{"sha256":"b6beb18aeacf54339f12fb565e38740563cc16eb5faeb9f82fbc50f22869ce77","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\ndef _vary(value):\n    if value == '@END': return 3 + 4*N\n    if isinstance(value, str): return value.replace('@', 'cell' * N)\n    if isinstance(value, list): return [_vary(x) for x in value]\n    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}\n    return value\nN = 1\nobservations = []\ndef solve(data):\n    text=data['row']; starts=[0]+[i+1 for i,ch in enumerate(text) if ch==',']\n    ends=[i for i,ch in enumerate(text) if ch==',']+[len(text)]\n    seen=set(); patches=[]\n    for index,value in data['edits']:\n        if not 0<=index<len(starts) or index in seen: return None\n        if any(ch in value for ch in ',\\r\\n'): return None\n        seen.add(index); patches.append((starts[index],ends[index],value))\n    for start,end,value in patches:\n        text=text[:start]+value+text[end:]\n    return text\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('vary lengths', solve(_vary({'row': 'a,bbb,c', 'edits': [[0, '@long'], [2, 'z']]})), _vary('@long,bbb,z'))\ncheck('empty field', solve(_vary({'row': 'a,,b', 'edits': [[1, '@']]})), _vary('a,@,b'))\ncheck('empty replacement', solve(_vary({'row': 'a,b,c', 'edits': [[1, '']]})), _vary('a,,c'))\ncheck('duplicate index', solve(_vary({'row': 'a,b', 'edits': [[0, 'x'], [0, 'y']]})), _vary(None))\ncheck('invalid replacement', solve(_vary({'row': 'a,b', 'edits': [[1, 'x,y']]})), _vary(None))\ncheck('out of range', solve(_vary({'row': 'a,b', 'edits': [[2, 'x']]})), _vary(None))\ncheck('preserve spaces', solve(_vary({'row': ' a , b ', 'edits': [[1, '@']]})), _vary(' a ,@'))\ncheck('unicode', solve(_vary({'row': 'é,😀,x', 'edits': [[1, '@']]})), _vary('é,@,x'))\ncheck('no edits', solve(_vary({'row': '@,x', 'edits': []})), _vary('@,x'))\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"918c7440d30552585ec60bfafc767db0cd10690b12d5a4325ff044d7d6cbe036","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\ndef _vary(value):\n    if value == '@END': return 3 + 4*N\n    if isinstance(value, str): return value.replace('@', 'cell' * N)\n    if isinstance(value, list): return [_vary(x) for x in value]\n    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}\n    return value\nN = 1\nobservations = []\ndef solve(data):\n    text=data['row']; starts=[0]+[i+1 for i,ch in enumerate(text) if ch==',']\n    ends=[i for i,ch in enumerate(text) if ch==',']+[len(text)]\n    seen=set(); patches=[]\n    for index,value in data['edits']:\n        if not 0<=index<len(starts) or index in seen: return None\n        if any(ch in value for ch in ',\\r\\n'): return None\n        seen.add(index); patches.append((starts[index],ends[index],value))\n    for start,end,value in sorted(patches):\n        text=text[:start]+value+text[end:]\n    return text\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('vary lengths', solve(_vary({'row': 'a,bbb,c', 'edits': [[0, '@long'], [2, 'z']]})), _vary('@long,bbb,z'))\ncheck('empty field', solve(_vary({'row': 'a,,b', 'edits': [[1, '@']]})), _vary('a,@,b'))\ncheck('empty replacement', solve(_vary({'row': 'a,b,c', 'edits': [[1, '']]})), _vary('a,,c'))\ncheck('duplicate index', solve(_vary({'row': 'a,b', 'edits': [[0, 'x'], [0, 'y']]})), _vary(None))\ncheck('invalid replacement', solve(_vary({'row': 'a,b', 'edits': [[1, 'x,y']]})), _vary(None))\ncheck('out of range', solve(_vary({'row': 'a,b', 'edits': [[2, 'x']]})), _vary(None))\ncheck('preserve spaces', solve(_vary({'row': ' a , b ', 'edits': [[1, '@']]})), _vary(' a ,@'))\ncheck('unicode', solve(_vary({'row': 'é,😀,x', 'edits': [[1, '@']]})), _vary('é,@,x'))\ncheck('no edits', solve(_vary({'row': '@,x', 'edits': []})), _vary('@,x'))\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"fixed":{"sha256":"e23f84ea66fae053bc4c869e52195c78fb7a7d544cd7a5a8ba18dd18fc67f595","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\ndef _vary(value):\n    if value == '@END': return 3 + 4*N\n    if isinstance(value, str): return value.replace('@', 'cell' * N)\n    if isinstance(value, list): return [_vary(x) for x in value]\n    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}\n    return value\nN = 1\nobservations = []\ndef solve(data):\n    text=data['row']; starts=[0]+[i+1 for i,ch in enumerate(text) if ch==',']\n    ends=[i for i,ch in enumerate(text) if ch==',']+[len(text)]\n    seen=set(); patches=[]\n    for index,value in data['edits']:\n        if not 0<=index<len(starts) or index in seen: return None\n        if any(ch in value for ch in ',\\r\\n'): return None\n        seen.add(index); patches.append((starts[index],ends[index],value))\n    for start,end,value in sorted(patches,reverse=True):\n        text=text[:start]+value+text[end:]\n    return text\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('vary lengths', solve(_vary({'row': 'a,bbb,c', 'edits': [[0, '@long'], [2, 'z']]})), _vary('@long,bbb,z'))\ncheck('empty field', solve(_vary({'row': 'a,,b', 'edits': [[1, '@']]})), _vary('a,@,b'))\ncheck('empty replacement', solve(_vary({'row': 'a,b,c', 'edits': [[1, '']]})), _vary('a,,c'))\ncheck('duplicate index', solve(_vary({'row': 'a,b', 'edits': [[0, 'x'], [0, 'y']]})), _vary(None))\ncheck('invalid replacement', solve(_vary({'row': 'a,b', 'edits': [[1, 'x,y']]})), _vary(None))\ncheck('out of range', solve(_vary({'row': 'a,b', 'edits': [[2, 'x']]})), _vary(None))\ncheck('preserve spaces', solve(_vary({'row': ' a , b ', 'edits': [[1, '@']]})), _vary(' a ,@'))\ncheck('unicode', solve(_vary({'row': 'é,😀,x', 'edits': [[1, '@']]})), _vary('é,@,x'))\ncheck('no edits', solve(_vary({'row': '@,x', 'edits': []})), _vary('@,x'))\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"s3-delimited-text-raw-cell-patches-patch-order","generated_at":"2026-09-29T14:44:53.432500+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Delimited interchange needs explicit framing, schema and field semantics at ingestion and emission boundaries.","repair":"Preserve the named invariant at the faulty decision: sorted(patches,reverse=True)","root_cause":"Earlier cell edits invalidate offsets used by later edits.","sha256":"aa10be273e90c67c3ab48cc62e35a5d25846cd81d02b691fd8f3a7d1b26c72c3","title":"Earlier cell edits invalidate offsets used by later edits · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":39.981,"exit_code":1,"observations":[{"actual":"celllozg,bbb,c","check":"vary lengths","expected":"celllong,bbb,z","passed":false},{"actual":"a,cell,b","check":"empty field","expected":"a,cell,b","passed":true},{"actual":"a,,c","check":"empty replacement","expected":"a,,c","passed":true},{"actual":null,"check":"duplicate index","expected":null,"passed":true},{"actual":null,"check":"invalid replacement","expected":null,"passed":true},{"actual":null,"check":"out of range","expected":null,"passed":true},{"actual":" a ,cell","check":"preserve spaces","expected":" a ,cell","passed":true},{"actual":"é,cell,x","check":"unicode","expected":"é,cell,x","passed":true},{"actual":"cell,x","check":"no edits","expected":"cell,x","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"vary lengths\", \"actual\": \"celllozg,bbb,c\", \"expected\": \"celllong,bbb,z\", \"passed\": false}, {\"check\": \"empty field\", \"actual\": \"a,cell,b\", \"expected\": \"a,cell,b\", \"passed\": true}, {\"check\": \"empty replacement\", \"actual\": \"a,,c\", \"expected\": \"a,,c\", \"passed\": true}, {\"check\": \"duplicate index\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"invalid replacement\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"out of range\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"preserve spaces\", \"actual\": \" a ,cell\", \"expected\": \" a ,cell\", \"passed\": true}, {\"check\": \"unicode\", \"actual\": \"é,cell,x\", \"expected\": \"é,cell,x\", \"passed\": true}, {\"check\": \"no edits\", \"actual\": \"cell,x\", \"expected\": \"cell,x\", \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":39.181,"exit_code":1,"observations":[{"actual":"celllozg,bbb,c","check":"vary lengths","expected":"celllong,bbb,z","passed":false},{"actual":"a,cell,b","check":"empty field","expected":"a,cell,b","passed":true},{"actual":"a,,c","check":"empty replacement","expected":"a,,c","passed":true},{"actual":null,"check":"duplicate index","expected":null,"passed":true},{"actual":null,"check":"invalid replacement","expected":null,"passed":true},{"actual":null,"check":"out of range","expected":null,"passed":true},{"actual":" a ,cell","check":"preserve spaces","expected":" a ,cell","passed":true},{"actual":"é,cell,x","check":"unicode","expected":"é,cell,x","passed":true},{"actual":"cell,x","check":"no edits","expected":"cell,x","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"vary lengths\", \"actual\": \"celllozg,bbb,c\", \"expected\": \"celllong,bbb,z\", \"passed\": false}, {\"check\": \"empty field\", \"actual\": \"a,cell,b\", \"expected\": \"a,cell,b\", \"passed\": true}, {\"check\": \"empty replacement\", \"actual\": \"a,,c\", \"expected\": \"a,,c\", \"passed\": true}, {\"check\": \"duplicate index\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"invalid replacement\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"out of range\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"preserve spaces\", \"actual\": \" a ,cell\", \"expected\": \" a ,cell\", \"passed\": true}, {\"check\": \"unicode\", \"actual\": \"é,cell,x\", \"expected\": \"é,cell,x\", \"passed\": true}, {\"check\": \"no edits\", \"actual\": \"cell,x\", \"expected\": \"cell,x\", \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":38.841,"exit_code":0,"observations":[{"actual":"celllong,bbb,z","check":"vary lengths","expected":"celllong,bbb,z","passed":true},{"actual":"a,cell,b","check":"empty field","expected":"a,cell,b","passed":true},{"actual":"a,,c","check":"empty replacement","expected":"a,,c","passed":true},{"actual":null,"check":"duplicate index","expected":null,"passed":true},{"actual":null,"check":"invalid replacement","expected":null,"passed":true},{"actual":null,"check":"out of range","expected":null,"passed":true},{"actual":" a ,cell","check":"preserve spaces","expected":" a ,cell","passed":true},{"actual":"é,cell,x","check":"unicode","expected":"é,cell,x","passed":true},{"actual":"cell,x","check":"no edits","expected":"cell,x","passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"vary lengths\", \"actual\": \"celllong,bbb,z\", \"expected\": \"celllong,bbb,z\", \"passed\": true}, {\"check\": \"empty field\", \"actual\": \"a,cell,b\", \"expected\": \"a,cell,b\", \"passed\": true}, {\"check\": \"empty replacement\", \"actual\": \"a,,c\", \"expected\": \"a,,c\", \"passed\": true}, {\"check\": \"duplicate index\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"invalid replacement\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"out of range\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"preserve spaces\", \"actual\": \" a ,cell\", \"expected\": \" a ,cell\", \"passed\": true}, {\"check\": \"unicode\", \"actual\": \"é,cell,x\", \"expected\": \"é,cell,x\", \"passed\": true}, {\"check\": \"no edits\", \"actual\": \"cell,x\", \"expected\": \"cell,x\", \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}