{"abstract":"A structured table violates the declared record or column contract.","category":"Delimited text","checks":8,"contract":"Split a comma record with trailing comments. A # outside double quotes ends the record; inside quotes it is data. Quotes toggle quoted state and are removed; doubled quotes inside quotes emit one quote. Whitespace before a trailing comment is data. Unterminated quoting rejects.","evaluation_group":"s3-delimited-text-trailing-comments","failed_approach":"The alternate implementation still violates the same declared invariant: whitespace before a comment is removed from the final field.","family":"s3-delimited-text-trailing-comments-comment-whitespace","id":"FA-48151","implementations":{"attempt":{"sha256":"005c67f39002fe725eb91cdcfce6c4705953c19e82ee8f1000a9d4a812d44e36","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, buf, quoted, i = [], [], False, 0\n    while i < len(data):\n        ch=data[i]\n        if ch == '\"':\n            if quoted and i+1 < len(data) and data[i+1] == '\"':\n                buf.append('\"'); i += 2; continue\n            quoted = not quoted\n        elif ch == '#' and not quoted: break\n        elif ch == ',' and not quoted:\n            out.append(''.join(buf)); buf=[]\n        else: buf.append(ch)\n        i += 1\n    if quoted: return None\n    out.append(''.join(buf).strip())\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('comment', solve(_vary('@,x#note')), _vary(['@', 'x']))\ncheck('quoted marker', solve(_vary('\"#@\",x')), _vary(['#@', 'x']))\ncheck('escaped quote', solve(_vary('\"a\"\"#b\",z')), _vary(['a\"#b', 'z']))\ncheck('spaces', solve(_vary('@  #x')), _vary(['@  ']))\ncheck('only comment', solve(_vary('#note')), _vary(['']))\ncheck('unclosed', solve(_vary('\"@#note')), _vary(None))\ncheck('normal', solve(_vary('@,x')), _vary(['@', 'x']))\ncheck('comment commas', solve(_vary('@#x,y')), _vary(['@']))\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":"7fbd3d6f30431607b35f3ae2e5c7295ed3e6edd1b369b1b5b11e77cf5cfd5773","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, buf, quoted, i = [], [], False, 0\n    while i < len(data):\n        ch=data[i]\n        if ch == '\"':\n            if quoted and i+1 < len(data) and data[i+1] == '\"':\n                buf.append('\"'); i += 2; continue\n            quoted = not quoted\n        elif ch == '#' and not quoted: break\n        elif ch == ',' and not quoted:\n            out.append(''.join(buf)); buf=[]\n        else: buf.append(ch)\n        i += 1\n    if quoted: return None\n    out.append(''.join(buf).rstrip())\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('comment', solve(_vary('@,x#note')), _vary(['@', 'x']))\ncheck('quoted marker', solve(_vary('\"#@\",x')), _vary(['#@', 'x']))\ncheck('escaped quote', solve(_vary('\"a\"\"#b\",z')), _vary(['a\"#b', 'z']))\ncheck('spaces', solve(_vary('@  #x')), _vary(['@  ']))\ncheck('only comment', solve(_vary('#note')), _vary(['']))\ncheck('unclosed', solve(_vary('\"@#note')), _vary(None))\ncheck('normal', solve(_vary('@,x')), _vary(['@', 'x']))\ncheck('comment commas', solve(_vary('@#x,y')), _vary(['@']))\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":"015bbb11965f644930fe00f62300281bc9d252e6724a34460de3f6edbc924bcb","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, buf, quoted, i = [], [], False, 0\n    while i < len(data):\n        ch=data[i]\n        if ch == '\"':\n            if quoted and i+1 < len(data) and data[i+1] == '\"':\n                buf.append('\"'); i += 2; continue\n            quoted = not quoted\n        elif ch == '#' and not quoted: break\n        elif ch == ',' and not quoted:\n            out.append(''.join(buf)); buf=[]\n        else: buf.append(ch)\n        i += 1\n    if quoted: return None\n    out.append(''.join(buf))\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('comment', solve(_vary('@,x#note')), _vary(['@', 'x']))\ncheck('quoted marker', solve(_vary('\"#@\",x')), _vary(['#@', 'x']))\ncheck('escaped quote', solve(_vary('\"a\"\"#b\",z')), _vary(['a\"#b', 'z']))\ncheck('spaces', solve(_vary('@  #x')), _vary(['@  ']))\ncheck('only comment', solve(_vary('#note')), _vary(['']))\ncheck('unclosed', solve(_vary('\"@#note')), _vary(None))\ncheck('normal', solve(_vary('@,x')), _vary(['@', 'x']))\ncheck('comment commas', solve(_vary('@#x,y')), _vary(['@']))\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-trailing-comments-comment-whitespace","generated_at":"2026-09-29T14:44:48.157370+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: out.append(''.join(buf))\nreturn out","root_cause":"Whitespace before a comment is removed from the final field.","sha256":"978f2f0416748d0cc7befbb295265835ecc5ae1d2d2bc325def31d1595a747f9","title":"Whitespace before a comment is removed from the final field · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":41.317,"exit_code":1,"observations":[{"actual":["cell","x"],"check":"comment","expected":["cell","x"],"passed":true},{"actual":["#cell","x"],"check":"quoted marker","expected":["#cell","x"],"passed":true},{"actual":["a\"#b","z"],"check":"escaped quote","expected":["a\"#b","z"],"passed":true},{"actual":["cell"],"check":"spaces","expected":["cell  "],"passed":false},{"actual":[""],"check":"only comment","expected":[""],"passed":true},{"actual":null,"check":"unclosed","expected":null,"passed":true},{"actual":["cell","x"],"check":"normal","expected":["cell","x"],"passed":true},{"actual":["cell"],"check":"comment commas","expected":["cell"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"comment\", \"actual\": [\"cell\", \"x\"], \"expected\": [\"cell\", \"x\"], \"passed\": true}, {\"check\": \"quoted marker\", \"actual\": [\"#cell\", \"x\"], \"expected\": [\"#cell\", \"x\"], \"passed\": true}, {\"check\": \"escaped quote\", \"actual\": [\"a\\\"#b\", \"z\"], \"expected\": [\"a\\\"#b\", \"z\"], \"passed\": true}, {\"check\": \"spaces\", \"actual\": [\"cell\"], \"expected\": [\"cell  \"], \"passed\": false}, {\"check\": \"only comment\", \"actual\": [\"\"], \"expected\": [\"\"], \"passed\": true}, {\"check\": \"unclosed\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"normal\", \"actual\": [\"cell\", \"x\"], \"expected\": [\"cell\", \"x\"], \"passed\": true}, {\"check\": \"comment commas\", \"actual\": [\"cell\"], \"expected\": [\"cell\"], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":38.983,"exit_code":1,"observations":[{"actual":["cell","x"],"check":"comment","expected":["cell","x"],"passed":true},{"actual":["#cell","x"],"check":"quoted marker","expected":["#cell","x"],"passed":true},{"actual":["a\"#b","z"],"check":"escaped quote","expected":["a\"#b","z"],"passed":true},{"actual":["cell"],"check":"spaces","expected":["cell  "],"passed":false},{"actual":[""],"check":"only comment","expected":[""],"passed":true},{"actual":null,"check":"unclosed","expected":null,"passed":true},{"actual":["cell","x"],"check":"normal","expected":["cell","x"],"passed":true},{"actual":["cell"],"check":"comment commas","expected":["cell"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"comment\", \"actual\": [\"cell\", \"x\"], \"expected\": [\"cell\", \"x\"], \"passed\": true}, {\"check\": \"quoted marker\", \"actual\": [\"#cell\", \"x\"], \"expected\": [\"#cell\", \"x\"], \"passed\": true}, {\"check\": \"escaped quote\", \"actual\": [\"a\\\"#b\", \"z\"], \"expected\": [\"a\\\"#b\", \"z\"], \"passed\": true}, {\"check\": \"spaces\", \"actual\": [\"cell\"], \"expected\": [\"cell  \"], \"passed\": false}, {\"check\": \"only comment\", \"actual\": [\"\"], \"expected\": [\"\"], \"passed\": true}, {\"check\": \"unclosed\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"normal\", \"actual\": [\"cell\", \"x\"], \"expected\": [\"cell\", \"x\"], \"passed\": true}, {\"check\": \"comment commas\", \"actual\": [\"cell\"], \"expected\": [\"cell\"], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":41.483,"exit_code":0,"observations":[{"actual":["cell","x"],"check":"comment","expected":["cell","x"],"passed":true},{"actual":["#cell","x"],"check":"quoted marker","expected":["#cell","x"],"passed":true},{"actual":["a\"#b","z"],"check":"escaped quote","expected":["a\"#b","z"],"passed":true},{"actual":["cell  "],"check":"spaces","expected":["cell  "],"passed":true},{"actual":[""],"check":"only comment","expected":[""],"passed":true},{"actual":null,"check":"unclosed","expected":null,"passed":true},{"actual":["cell","x"],"check":"normal","expected":["cell","x"],"passed":true},{"actual":["cell"],"check":"comment commas","expected":["cell"],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"comment\", \"actual\": [\"cell\", \"x\"], \"expected\": [\"cell\", \"x\"], \"passed\": true}, {\"check\": \"quoted marker\", \"actual\": [\"#cell\", \"x\"], \"expected\": [\"#cell\", \"x\"], \"passed\": true}, {\"check\": \"escaped quote\", \"actual\": [\"a\\\"#b\", \"z\"], \"expected\": [\"a\\\"#b\", \"z\"], \"passed\": true}, {\"check\": \"spaces\", \"actual\": [\"cell  \"], \"expected\": [\"cell  \"], \"passed\": true}, {\"check\": \"only comment\", \"actual\": [\"\"], \"expected\": [\"\"], \"passed\": true}, {\"check\": \"unclosed\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"normal\", \"actual\": [\"cell\", \"x\"], \"expected\": [\"cell\", \"x\"], \"passed\": true}, {\"check\": \"comment commas\", \"actual\": [\"cell\"], \"expected\": [\"cell\"], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}