{"abstract":"A structured table violates the declared record or column contract.","category":"Delimited text","checks":11,"contract":"Emit typed table cells as one comma row ending CRLF. None is bare NULL; strings equal NULL or empty must be quoted. Booleans are bare true/false, integers bare decimal. Other strings are quoted if they contain comma, quote, newline, CR, leading/trailing space, or begin # (comment protection). Double embedded quotes. Preserve Unicode and cell order.","evaluation_group":"s3-delimited-text-typed-csv-emitter","failed_approach":"Protecting only leading spaces misses a trailing-space value.","family":"s3-delimited-text-typed-csv-emitter-space-shield","id":"FA-47661","implementations":{"attempt":{"sha256":"53f9383f651e6b1f2c728acf5ddbed51a20d2f544fcc85de0392c752fc4bd268","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 value in data:\n        if value is None: field = 'NULL'\n        elif isinstance(value, bool): field = 'true' if value else 'false'\n        elif isinstance(value, int): field = str(value)\n        else:\n            quote = value in ('NULL', '') or any(c in value for c in ',\"\\r\\n') or value.startswith(' ') or value.startswith('#')\n            field = value.replace('\"', '\"\"')\n            if quote: field = '\"' + field + '\"'\n        out.append(field)\n    return ','.join(out) + '\\r\\n'\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('typed', solve(_vary(['@', None, True, False, 12])), _vary('@,NULL,true,false,12\\r\\n'))\ncheck('null string', solve(_vary(['NULL', ''])), _vary('\"NULL\",\"\"\\r\\n'))\ncheck('comment', solve(_vary(['#@'])), _vary('\"#@\"\\r\\n'))\ncheck('spaces', solve(_vary([' @ ', 'x'])), _vary('\" @ \",x\\r\\n'))\ncheck('escape', solve(_vary(['a\"b'])), _vary('\"a\"\"b\"\\r\\n'))\ncheck('crlf', solve(_vary(['x\\r\\ny'])), _vary('\"x\\r\\ny\"\\r\\n'))\ncheck('normal', solve(_vary(['@', 'β'])), _vary('@,β\\r\\n'))\ncheck('empty row', solve(_vary([])), _vary('\\r\\n'))\ncheck('negative', solve(_vary([-12])), _vary('-12\\r\\n'))\ncheck('single space', solve(_vary([' '])), _vary('\" \"\\r\\n'))\ncheck('trailing space', solve(_vary(['@ '])), _vary('\"@ \"\\r\\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":"08eb212695c6f2b3c1d1ba3d157255a2e9c3ce95abeffe9ebc345cee3af30c4b","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 value in data:\n        if value is None: field = 'NULL'\n        elif isinstance(value, bool): field = 'true' if value else 'false'\n        elif isinstance(value, int): field = str(value)\n        else:\n            quote = value in ('NULL', '') or any(c in value for c in ',\"\\r\\n')  or value.startswith('#')\n            field = value.replace('\"', '\"\"')\n            if quote: field = '\"' + field + '\"'\n        out.append(field)\n    return ','.join(out) + '\\r\\n'\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('typed', solve(_vary(['@', None, True, False, 12])), _vary('@,NULL,true,false,12\\r\\n'))\ncheck('null string', solve(_vary(['NULL', ''])), _vary('\"NULL\",\"\"\\r\\n'))\ncheck('comment', solve(_vary(['#@'])), _vary('\"#@\"\\r\\n'))\ncheck('spaces', solve(_vary([' @ ', 'x'])), _vary('\" @ \",x\\r\\n'))\ncheck('escape', solve(_vary(['a\"b'])), _vary('\"a\"\"b\"\\r\\n'))\ncheck('crlf', solve(_vary(['x\\r\\ny'])), _vary('\"x\\r\\ny\"\\r\\n'))\ncheck('normal', solve(_vary(['@', 'β'])), _vary('@,β\\r\\n'))\ncheck('empty row', solve(_vary([])), _vary('\\r\\n'))\ncheck('negative', solve(_vary([-12])), _vary('-12\\r\\n'))\ncheck('single space', solve(_vary([' '])), _vary('\" \"\\r\\n'))\ncheck('trailing space', solve(_vary(['@ '])), _vary('\"@ \"\\r\\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":"01dab3c6df4f14a2de881e543fd7f557862fb045b3894b8344acc59adc9432de","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 value in data:\n        if value is None: field = 'NULL'\n        elif isinstance(value, bool): field = 'true' if value else 'false'\n        elif isinstance(value, int): field = str(value)\n        else:\n            quote = value in ('NULL', '') or any(c in value for c in ',\"\\r\\n') or value != value.strip(' ') or value.startswith('#')\n            field = value.replace('\"', '\"\"')\n            if quote: field = '\"' + field + '\"'\n        out.append(field)\n    return ','.join(out) + '\\r\\n'\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('typed', solve(_vary(['@', None, True, False, 12])), _vary('@,NULL,true,false,12\\r\\n'))\ncheck('null string', solve(_vary(['NULL', ''])), _vary('\"NULL\",\"\"\\r\\n'))\ncheck('comment', solve(_vary(['#@'])), _vary('\"#@\"\\r\\n'))\ncheck('spaces', solve(_vary([' @ ', 'x'])), _vary('\" @ \",x\\r\\n'))\ncheck('escape', solve(_vary(['a\"b'])), _vary('\"a\"\"b\"\\r\\n'))\ncheck('crlf', solve(_vary(['x\\r\\ny'])), _vary('\"x\\r\\ny\"\\r\\n'))\ncheck('normal', solve(_vary(['@', 'β'])), _vary('@,β\\r\\n'))\ncheck('empty row', solve(_vary([])), _vary('\\r\\n'))\ncheck('negative', solve(_vary([-12])), _vary('-12\\r\\n'))\ncheck('single space', solve(_vary([' '])), _vary('\" \"\\r\\n'))\ncheck('trailing space', solve(_vary(['@ '])), _vary('\"@ \"\\r\\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-typed-csv-emitter-space-shield","generated_at":"2026-09-29T14:44:43.606759+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: or value != value.strip(' ')","root_cause":"Minimal quoting ignores the consumer contract that trims bare edge spaces.","sha256":"f3330032d9fd81a8ca8862624fa7d75a2ac54d4269ce87573d61ac8c9cdfc368","title":"The CSV writer leaves trim-sensitive edge spaces unquoted · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":40.264,"exit_code":1,"observations":[{"actual":"cell,NULL,true,false,12\r\n","check":"typed","expected":"cell,NULL,true,false,12\r\n","passed":true},{"actual":"\"NULL\",\"\"\r\n","check":"null string","expected":"\"NULL\",\"\"\r\n","passed":true},{"actual":"\"#cell\"\r\n","check":"comment","expected":"\"#cell\"\r\n","passed":true},{"actual":"\" cell \",x\r\n","check":"spaces","expected":"\" cell \",x\r\n","passed":true},{"actual":"\"a\"\"b\"\r\n","check":"escape","expected":"\"a\"\"b\"\r\n","passed":true},{"actual":"\"x\r\ny\"\r\n","check":"crlf","expected":"\"x\r\ny\"\r\n","passed":true},{"actual":"cell,β\r\n","check":"normal","expected":"cell,β\r\n","passed":true},{"actual":"\r\n","check":"empty row","expected":"\r\n","passed":true},{"actual":"-12\r\n","check":"negative","expected":"-12\r\n","passed":true},{"actual":"\" \"\r\n","check":"single space","expected":"\" \"\r\n","passed":true},{"actual":"cell \r\n","check":"trailing space","expected":"\"cell \"\r\n","passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"typed\", \"actual\": \"cell,NULL,true,false,12\\r\\n\", \"expected\": \"cell,NULL,true,false,12\\r\\n\", \"passed\": true}, {\"check\": \"null string\", \"actual\": \"\\\"NULL\\\",\\\"\\\"\\r\\n\", \"expected\": \"\\\"NULL\\\",\\\"\\\"\\r\\n\", \"passed\": true}, {\"check\": \"comment\", \"actual\": \"\\\"#cell\\\"\\r\\n\", \"expected\": \"\\\"#cell\\\"\\r\\n\", \"passed\": true}, {\"check\": \"spaces\", \"actual\": \"\\\" cell \\\",x\\r\\n\", \"expected\": \"\\\" cell \\\",x\\r\\n\", \"passed\": true}, {\"check\": \"escape\", \"actual\": \"\\\"a\\\"\\\"b\\\"\\r\\n\", \"expected\": \"\\\"a\\\"\\\"b\\\"\\r\\n\", \"passed\": true}, {\"check\": \"crlf\", \"actual\": \"\\\"x\\r\\ny\\\"\\r\\n\", \"expected\": \"\\\"x\\r\\ny\\\"\\r\\n\", \"passed\": true}, {\"check\": \"normal\", \"actual\": \"cell,β\\r\\n\", \"expected\": \"cell,β\\r\\n\", \"passed\": true}, {\"check\": \"empty row\", \"actual\": \"\\r\\n\", \"expected\": \"\\r\\n\", \"passed\": true}, {\"check\": \"negative\", \"actual\": \"-12\\r\\n\", \"expected\": \"-12\\r\\n\", \"passed\": true}, {\"check\": \"single space\", \"actual\": \"\\\" \\\"\\r\\n\", \"expected\": \"\\\" \\\"\\r\\n\", \"passed\": true}, {\"check\": \"trailing space\", \"actual\": \"cell \\r\\n\", \"expected\": \"\\\"cell \\\"\\r\\n\", \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":38.919,"exit_code":1,"observations":[{"actual":"cell,NULL,true,false,12\r\n","check":"typed","expected":"cell,NULL,true,false,12\r\n","passed":true},{"actual":"\"NULL\",\"\"\r\n","check":"null string","expected":"\"NULL\",\"\"\r\n","passed":true},{"actual":"\"#cell\"\r\n","check":"comment","expected":"\"#cell\"\r\n","passed":true},{"actual":" cell ,x\r\n","check":"spaces","expected":"\" cell \",x\r\n","passed":false},{"actual":"\"a\"\"b\"\r\n","check":"escape","expected":"\"a\"\"b\"\r\n","passed":true},{"actual":"\"x\r\ny\"\r\n","check":"crlf","expected":"\"x\r\ny\"\r\n","passed":true},{"actual":"cell,β\r\n","check":"normal","expected":"cell,β\r\n","passed":true},{"actual":"\r\n","check":"empty row","expected":"\r\n","passed":true},{"actual":"-12\r\n","check":"negative","expected":"-12\r\n","passed":true},{"actual":" \r\n","check":"single space","expected":"\" \"\r\n","passed":false},{"actual":"cell \r\n","check":"trailing space","expected":"\"cell \"\r\n","passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"typed\", \"actual\": \"cell,NULL,true,false,12\\r\\n\", \"expected\": \"cell,NULL,true,false,12\\r\\n\", \"passed\": true}, {\"check\": \"null string\", \"actual\": \"\\\"NULL\\\",\\\"\\\"\\r\\n\", \"expected\": \"\\\"NULL\\\",\\\"\\\"\\r\\n\", \"passed\": true}, {\"check\": \"comment\", \"actual\": \"\\\"#cell\\\"\\r\\n\", \"expected\": \"\\\"#cell\\\"\\r\\n\", \"passed\": true}, {\"check\": \"spaces\", \"actual\": \" cell ,x\\r\\n\", \"expected\": \"\\\" cell \\\",x\\r\\n\", \"passed\": false}, {\"check\": \"escape\", \"actual\": \"\\\"a\\\"\\\"b\\\"\\r\\n\", \"expected\": \"\\\"a\\\"\\\"b\\\"\\r\\n\", \"passed\": true}, {\"check\": \"crlf\", \"actual\": \"\\\"x\\r\\ny\\\"\\r\\n\", \"expected\": \"\\\"x\\r\\ny\\\"\\r\\n\", \"passed\": true}, {\"check\": \"normal\", \"actual\": \"cell,β\\r\\n\", \"expected\": \"cell,β\\r\\n\", \"passed\": true}, {\"check\": \"empty row\", \"actual\": \"\\r\\n\", \"expected\": \"\\r\\n\", \"passed\": true}, {\"check\": \"negative\", \"actual\": \"-12\\r\\n\", \"expected\": \"-12\\r\\n\", \"passed\": true}, {\"check\": \"single space\", \"actual\": \" \\r\\n\", \"expected\": \"\\\" \\\"\\r\\n\", \"passed\": false}, {\"check\": \"trailing space\", \"actual\": \"cell \\r\\n\", \"expected\": \"\\\"cell \\\"\\r\\n\", \"passed\": false}], \"passed\": false}\n"},"fixed":{"elapsed_ms":41.409,"exit_code":0,"observations":[{"actual":"cell,NULL,true,false,12\r\n","check":"typed","expected":"cell,NULL,true,false,12\r\n","passed":true},{"actual":"\"NULL\",\"\"\r\n","check":"null string","expected":"\"NULL\",\"\"\r\n","passed":true},{"actual":"\"#cell\"\r\n","check":"comment","expected":"\"#cell\"\r\n","passed":true},{"actual":"\" cell \",x\r\n","check":"spaces","expected":"\" cell \",x\r\n","passed":true},{"actual":"\"a\"\"b\"\r\n","check":"escape","expected":"\"a\"\"b\"\r\n","passed":true},{"actual":"\"x\r\ny\"\r\n","check":"crlf","expected":"\"x\r\ny\"\r\n","passed":true},{"actual":"cell,β\r\n","check":"normal","expected":"cell,β\r\n","passed":true},{"actual":"\r\n","check":"empty row","expected":"\r\n","passed":true},{"actual":"-12\r\n","check":"negative","expected":"-12\r\n","passed":true},{"actual":"\" \"\r\n","check":"single space","expected":"\" \"\r\n","passed":true},{"actual":"\"cell \"\r\n","check":"trailing space","expected":"\"cell \"\r\n","passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"typed\", \"actual\": \"cell,NULL,true,false,12\\r\\n\", \"expected\": \"cell,NULL,true,false,12\\r\\n\", \"passed\": true}, {\"check\": \"null string\", \"actual\": \"\\\"NULL\\\",\\\"\\\"\\r\\n\", \"expected\": \"\\\"NULL\\\",\\\"\\\"\\r\\n\", \"passed\": true}, {\"check\": \"comment\", \"actual\": \"\\\"#cell\\\"\\r\\n\", \"expected\": \"\\\"#cell\\\"\\r\\n\", \"passed\": true}, {\"check\": \"spaces\", \"actual\": \"\\\" cell \\\",x\\r\\n\", \"expected\": \"\\\" cell \\\",x\\r\\n\", \"passed\": true}, {\"check\": \"escape\", \"actual\": \"\\\"a\\\"\\\"b\\\"\\r\\n\", \"expected\": \"\\\"a\\\"\\\"b\\\"\\r\\n\", \"passed\": true}, {\"check\": \"crlf\", \"actual\": \"\\\"x\\r\\ny\\\"\\r\\n\", \"expected\": \"\\\"x\\r\\ny\\\"\\r\\n\", \"passed\": true}, {\"check\": \"normal\", \"actual\": \"cell,β\\r\\n\", \"expected\": \"cell,β\\r\\n\", \"passed\": true}, {\"check\": \"empty row\", \"actual\": \"\\r\\n\", \"expected\": \"\\r\\n\", \"passed\": true}, {\"check\": \"negative\", \"actual\": \"-12\\r\\n\", \"expected\": \"-12\\r\\n\", \"passed\": true}, {\"check\": \"single space\", \"actual\": \"\\\" \\\"\\r\\n\", \"expected\": \"\\\" \\\"\\r\\n\", \"passed\": true}, {\"check\": \"trailing space\", \"actual\": \"\\\"cell \\\"\\r\\n\", \"expected\": \"\\\"cell \\\"\\r\\n\", \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}