{"abstract":"A structured table violates the declared record or column contract.","category":"Delimited text","checks":9,"contract":"Encode already textual comma cells for a spreadsheet-facing export. Prefix a single apostrophe if the first non-space/non-tab character is =,+,-, or @. An existing leading apostrophe is preserved without duplication. Then double embedded quotes and quote every cell. Return LF-terminated row. This is a stipulated conservative transport policy, not a universal spreadsheet security guarantee.","evaluation_group":"s3-delimited-text-spreadsheet-safe-export","failed_approach":"The alternate implementation still violates the same declared invariant: csv quote escaping drops the formula-neutralization marker.","family":"s3-delimited-text-spreadsheet-safe-export-prefix-escaping","id":"FA-48136","implementations":{"attempt":{"sha256":"d790c3d41031017e247b41f7837a8d88acd96a360991c987cc51d980409292bb","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    out=[]\n    for cell in data:\n        probe = cell.lstrip(' \\t')\n        if not cell.startswith(\"'\") and probe[:1] in ('=', '+', '-', '@'):\n            cell = \"'\" + cell\n        cell = cell.replace(\"'\", '').replace('\"', '\"\"')\n        out.append('\"' + cell + '\"')\n    return ','.join(out) + '\\n'\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('formula', solve(_vary(['=1+1'])), _vary('\"\\'=1+1\"\\n'))\ncheck('leading space', solve(_vary([' \\t+2'])), _vary('\"\\' \\t+2\"\\n'))\ncheck('existing prefix', solve(_vary([\"'=3\"])), _vary('\"\\'=3\"\\n'))\ncheck('minus', solve(_vary(['-12'])), _vary('\"\\'-12\"\\n'))\ncheck('ordinary', solve(_vary(['text', 'a\"b'])), _vary('\"text\",\"a\"\"b\"\\n'))\ncheck('empty', solve(_vary([''])), _vary('\"\"\\n'))\ncheck('interior', solve(_vary(['x=1'])), _vary('\"x=1\"\\n'))\ncheck('no cells', solve(_vary([])), _vary('\\n'))\ncheck('variant formula width', solve(['='+str(N)+'+1']), '\"\\'='+str(N)+'+1\"\\n')\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":"4518d11f71ab67b29fe18d835309d6acedac1a36be60524e182e67f7d7b641ef","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    out=[]\n    for cell in data:\n        probe = cell.lstrip(' \\t')\n        if not cell.startswith(\"'\") and probe[:1] in ('=', '+', '-', '@'):\n            cell = \"'\" + cell\n        cell = cell.lstrip(\"'\").replace('\"', '\"\"')\n        out.append('\"' + cell + '\"')\n    return ','.join(out) + '\\n'\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('formula', solve(_vary(['=1+1'])), _vary('\"\\'=1+1\"\\n'))\ncheck('leading space', solve(_vary([' \\t+2'])), _vary('\"\\' \\t+2\"\\n'))\ncheck('existing prefix', solve(_vary([\"'=3\"])), _vary('\"\\'=3\"\\n'))\ncheck('minus', solve(_vary(['-12'])), _vary('\"\\'-12\"\\n'))\ncheck('ordinary', solve(_vary(['text', 'a\"b'])), _vary('\"text\",\"a\"\"b\"\\n'))\ncheck('empty', solve(_vary([''])), _vary('\"\"\\n'))\ncheck('interior', solve(_vary(['x=1'])), _vary('\"x=1\"\\n'))\ncheck('no cells', solve(_vary([])), _vary('\\n'))\ncheck('variant formula width', solve(['='+str(N)+'+1']), '\"\\'='+str(N)+'+1\"\\n')\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":"8348ff28c929a532c9792033b193a797fe6e2e3c5e5cd5409b1465525f8e21b4","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    out=[]\n    for cell in data:\n        probe = cell.lstrip(' \\t')\n        if not cell.startswith(\"'\") and probe[:1] in ('=', '+', '-', '@'):\n            cell = \"'\" + cell\n        cell = cell.replace('\"', '\"\"')\n        out.append('\"' + cell + '\"')\n    return ','.join(out) + '\\n'\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('formula', solve(_vary(['=1+1'])), _vary('\"\\'=1+1\"\\n'))\ncheck('leading space', solve(_vary([' \\t+2'])), _vary('\"\\' \\t+2\"\\n'))\ncheck('existing prefix', solve(_vary([\"'=3\"])), _vary('\"\\'=3\"\\n'))\ncheck('minus', solve(_vary(['-12'])), _vary('\"\\'-12\"\\n'))\ncheck('ordinary', solve(_vary(['text', 'a\"b'])), _vary('\"text\",\"a\"\"b\"\\n'))\ncheck('empty', solve(_vary([''])), _vary('\"\"\\n'))\ncheck('interior', solve(_vary(['x=1'])), _vary('\"x=1\"\\n'))\ncheck('no cells', solve(_vary([])), _vary('\\n'))\ncheck('variant formula width', solve(['='+str(N)+'+1']), '\"\\'='+str(N)+'+1\"\\n')\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-spreadsheet-safe-export-prefix-escaping","generated_at":"2026-09-29T14:44:48.065069+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: cell = cell.replace('\"', '\"\"')","root_cause":"CSV quote escaping drops the formula-neutralization marker.","sha256":"569e19e2cf39925b40294be6b6a61a88f76895ab7b798587dca57fc4afad9284","title":"CSV quote escaping drops the formula-neutralization marker · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":40.039,"exit_code":1,"observations":[{"actual":"\"=1+1\"\n","check":"formula","expected":"\"'=1+1\"\n","passed":false},{"actual":"\" \t+2\"\n","check":"leading space","expected":"\"' \t+2\"\n","passed":false},{"actual":"\"=3\"\n","check":"existing prefix","expected":"\"'=3\"\n","passed":false},{"actual":"\"-12\"\n","check":"minus","expected":"\"'-12\"\n","passed":false},{"actual":"\"text\",\"a\"\"b\"\n","check":"ordinary","expected":"\"text\",\"a\"\"b\"\n","passed":true},{"actual":"\"\"\n","check":"empty","expected":"\"\"\n","passed":true},{"actual":"\"x=1\"\n","check":"interior","expected":"\"x=1\"\n","passed":true},{"actual":"\n","check":"no cells","expected":"\n","passed":true},{"actual":"\"=1+1\"\n","check":"variant formula width","expected":"\"'=1+1\"\n","passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"formula\", \"actual\": \"\\\"=1+1\\\"\\n\", \"expected\": \"\\\"'=1+1\\\"\\n\", \"passed\": false}, {\"check\": \"leading space\", \"actual\": \"\\\" \\t+2\\\"\\n\", \"expected\": \"\\\"' \\t+2\\\"\\n\", \"passed\": false}, {\"check\": \"existing prefix\", \"actual\": \"\\\"=3\\\"\\n\", \"expected\": \"\\\"'=3\\\"\\n\", \"passed\": false}, {\"check\": \"minus\", \"actual\": \"\\\"-12\\\"\\n\", \"expected\": \"\\\"'-12\\\"\\n\", \"passed\": false}, {\"check\": \"ordinary\", \"actual\": \"\\\"text\\\",\\\"a\\\"\\\"b\\\"\\n\", \"expected\": \"\\\"text\\\",\\\"a\\\"\\\"b\\\"\\n\", \"passed\": true}, {\"check\": \"empty\", \"actual\": \"\\\"\\\"\\n\", \"expected\": \"\\\"\\\"\\n\", \"passed\": true}, {\"check\": \"interior\", \"actual\": \"\\\"x=1\\\"\\n\", \"expected\": \"\\\"x=1\\\"\\n\", \"passed\": true}, {\"check\": \"no cells\", \"actual\": \"\\n\", \"expected\": \"\\n\", \"passed\": true}, {\"check\": \"variant formula width\", \"actual\": \"\\\"=1+1\\\"\\n\", \"expected\": \"\\\"'=1+1\\\"\\n\", \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.489,"exit_code":1,"observations":[{"actual":"\"=1+1\"\n","check":"formula","expected":"\"'=1+1\"\n","passed":false},{"actual":"\" \t+2\"\n","check":"leading space","expected":"\"' \t+2\"\n","passed":false},{"actual":"\"=3\"\n","check":"existing prefix","expected":"\"'=3\"\n","passed":false},{"actual":"\"-12\"\n","check":"minus","expected":"\"'-12\"\n","passed":false},{"actual":"\"text\",\"a\"\"b\"\n","check":"ordinary","expected":"\"text\",\"a\"\"b\"\n","passed":true},{"actual":"\"\"\n","check":"empty","expected":"\"\"\n","passed":true},{"actual":"\"x=1\"\n","check":"interior","expected":"\"x=1\"\n","passed":true},{"actual":"\n","check":"no cells","expected":"\n","passed":true},{"actual":"\"=1+1\"\n","check":"variant formula width","expected":"\"'=1+1\"\n","passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"formula\", \"actual\": \"\\\"=1+1\\\"\\n\", \"expected\": \"\\\"'=1+1\\\"\\n\", \"passed\": false}, {\"check\": \"leading space\", \"actual\": \"\\\" \\t+2\\\"\\n\", \"expected\": \"\\\"' \\t+2\\\"\\n\", \"passed\": false}, {\"check\": \"existing prefix\", \"actual\": \"\\\"=3\\\"\\n\", \"expected\": \"\\\"'=3\\\"\\n\", \"passed\": false}, {\"check\": \"minus\", \"actual\": \"\\\"-12\\\"\\n\", \"expected\": \"\\\"'-12\\\"\\n\", \"passed\": false}, {\"check\": \"ordinary\", \"actual\": \"\\\"text\\\",\\\"a\\\"\\\"b\\\"\\n\", \"expected\": \"\\\"text\\\",\\\"a\\\"\\\"b\\\"\\n\", \"passed\": true}, {\"check\": \"empty\", \"actual\": \"\\\"\\\"\\n\", \"expected\": \"\\\"\\\"\\n\", \"passed\": true}, {\"check\": \"interior\", \"actual\": \"\\\"x=1\\\"\\n\", \"expected\": \"\\\"x=1\\\"\\n\", \"passed\": true}, {\"check\": \"no cells\", \"actual\": \"\\n\", \"expected\": \"\\n\", \"passed\": true}, {\"check\": \"variant formula width\", \"actual\": \"\\\"=1+1\\\"\\n\", \"expected\": \"\\\"'=1+1\\\"\\n\", \"passed\": false}], \"passed\": false}\n"},"fixed":{"elapsed_ms":41.567,"exit_code":0,"observations":[{"actual":"\"'=1+1\"\n","check":"formula","expected":"\"'=1+1\"\n","passed":true},{"actual":"\"' \t+2\"\n","check":"leading space","expected":"\"' \t+2\"\n","passed":true},{"actual":"\"'=3\"\n","check":"existing prefix","expected":"\"'=3\"\n","passed":true},{"actual":"\"'-12\"\n","check":"minus","expected":"\"'-12\"\n","passed":true},{"actual":"\"text\",\"a\"\"b\"\n","check":"ordinary","expected":"\"text\",\"a\"\"b\"\n","passed":true},{"actual":"\"\"\n","check":"empty","expected":"\"\"\n","passed":true},{"actual":"\"x=1\"\n","check":"interior","expected":"\"x=1\"\n","passed":true},{"actual":"\n","check":"no cells","expected":"\n","passed":true},{"actual":"\"'=1+1\"\n","check":"variant formula width","expected":"\"'=1+1\"\n","passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"formula\", \"actual\": \"\\\"'=1+1\\\"\\n\", \"expected\": \"\\\"'=1+1\\\"\\n\", \"passed\": true}, {\"check\": \"leading space\", \"actual\": \"\\\"' \\t+2\\\"\\n\", \"expected\": \"\\\"' \\t+2\\\"\\n\", \"passed\": true}, {\"check\": \"existing prefix\", \"actual\": \"\\\"'=3\\\"\\n\", \"expected\": \"\\\"'=3\\\"\\n\", \"passed\": true}, {\"check\": \"minus\", \"actual\": \"\\\"'-12\\\"\\n\", \"expected\": \"\\\"'-12\\\"\\n\", \"passed\": true}, {\"check\": \"ordinary\", \"actual\": \"\\\"text\\\",\\\"a\\\"\\\"b\\\"\\n\", \"expected\": \"\\\"text\\\",\\\"a\\\"\\\"b\\\"\\n\", \"passed\": true}, {\"check\": \"empty\", \"actual\": \"\\\"\\\"\\n\", \"expected\": \"\\\"\\\"\\n\", \"passed\": true}, {\"check\": \"interior\", \"actual\": \"\\\"x=1\\\"\\n\", \"expected\": \"\\\"x=1\\\"\\n\", \"passed\": true}, {\"check\": \"no cells\", \"actual\": \"\\n\", \"expected\": \"\\n\", \"passed\": true}, {\"check\": \"variant formula width\", \"actual\": \"\\\"'=1+1\\\"\\n\", \"expected\": \"\\\"'=1+1\\\"\\n\", \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}