{"abstract":"Four digits in a pairs pattern render \"55 50 \" with a trailing space.","category":"Phone number formatting","checks":9,"contract":"Input [digits, pattern]. Each X consumes the next digit; \"\\\" makes the next pattern character a literal; other characters are literals. Literals are buffered and written only in front of the next digit, so a partial input never ends in a literal; when the whole pattern was consumed the trailing literals are written too. More digits than X slots returns None.","evaluation_group":"w2-phone-number-formatting-pattern-mask","failed_approach":"Never flushing trailing literals drops the closing bracket of a completed pattern.","family":"w2-phone-number-formatting-pattern-mask-trailing-literal","id":"FA-96766","implementations":{"attempt":{"sha256":"d58ef13a69fad83b625b24458ecd13163673dd3160f0e69ce1635b55a8bf95a6","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    digits, pattern = x\n    out, i, k, pend = [], 0, 0, ''\n    while k < len(pattern):\n        ch = pattern[k]\n        if ch == '\\\\' and k + 1 < len(pattern):\n            pend += pattern[k + 1]\n            k += 2\n            continue\n        if ch == 'X':\n            if i >= len(digits):\n                break\n            out.append(pend + digits[i])\n            pend = ''\n            i += 1\n        else:\n            pend += ch\n        k += 1\n    if i < len(digits):\n        return None\n    return ''.join(out)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['complete ten digits', ['5550113456', '(XXX) XXX-XXXX'], '(555) 011-3456'], ['three digits keep the bracket pending', ['555', '(XXX) XXX-XXXX'], '(555'], ['six digits', ['555011', '(XXX) XXX-XXXX'], '(555) 011'], ['nothing typed', ['', '(XXX) XXX-XXXX'], ''], ['pattern ending in a literal', ['555', '(XXX)'], '(555)'], ['escaped letter X', ['5550', 'E\\\\XT XXXX'], 'EXT 5550'], ['one digit too many', ['55501134561', '(XXX) XXX-XXXX'], None], ['pairs pattern complete', ['5550113456', 'XX XX XX XX XX'], '55 50 11 34 56'], ['pairs pattern partial', ['5550', 'XX XX XX XX XX'], '55 50']], [['complete ten digits', ['6550123456', '(XXX) XXX-XXXX'], '(655) 012-3456'], ['three digits keep the bracket pending', ['655', '(XXX) XXX-XXXX'], '(655'], ['six digits', ['655012', '(XXX) XXX-XXXX'], '(655) 012'], ['nothing typed', ['', '(XXX) XXX-XXXX'], ''], ['pattern ending in a literal', ['655', '(XXX)'], '(655)'], ['escaped letter X', ['6550', 'E\\\\XT XXXX'], 'EXT 6550'], ['one digit too many', ['65501234562', '(XXX) XXX-XXXX'], None], ['pairs pattern complete', ['6550123456', 'XX XX XX XX XX'], '65 50 12 34 56'], ['pairs pattern partial', ['6550', 'XX XX XX XX XX'], '65 50']], [['complete ten digits', ['7550133456', '(XXX) XXX-XXXX'], '(755) 013-3456'], ['three digits keep the bracket pending', ['755', '(XXX) XXX-XXXX'], '(755'], ['six digits', ['755013', '(XXX) XXX-XXXX'], '(755) 013'], ['nothing typed', ['', '(XXX) XXX-XXXX'], ''], ['pattern ending in a literal', ['755', '(XXX)'], '(755)'], ['escaped letter X', ['7550', 'E\\\\XT XXXX'], 'EXT 7550'], ['one digit too many', ['75501334563', '(XXX) XXX-XXXX'], None], ['pairs pattern complete', ['7550133456', 'XX XX XX XX XX'], '75 50 13 34 56'], ['pairs pattern partial', ['7550', 'XX XX XX XX XX'], '75 50']], [['complete ten digits', ['8550143456', '(XXX) XXX-XXXX'], '(855) 014-3456'], ['three digits keep the bracket pending', ['855', '(XXX) XXX-XXXX'], '(855'], ['six digits', ['855014', '(XXX) XXX-XXXX'], '(855) 014'], ['nothing typed', ['', '(XXX) XXX-XXXX'], ''], ['pattern ending in a literal', ['855', '(XXX)'], '(855)'], ['escaped letter X', ['8550', 'E\\\\XT XXXX'], 'EXT 8550'], ['one digit too many', ['85501434564', '(XXX) XXX-XXXX'], None], ['pairs pattern complete', ['8550143456', 'XX XX XX XX XX'], '85 50 14 34 56'], ['pairs pattern partial', ['8550', 'XX XX XX XX XX'], '85 50']], [['complete ten digits', ['9550153456', '(XXX) XXX-XXXX'], '(955) 015-3456'], ['three digits keep the bracket pending', ['955', '(XXX) XXX-XXXX'], '(955'], ['six digits', ['955015', '(XXX) XXX-XXXX'], '(955) 015'], ['nothing typed', ['', '(XXX) XXX-XXXX'], ''], ['pattern ending in a literal', ['955', '(XXX)'], '(955)'], ['escaped letter X', ['9550', 'E\\\\XT XXXX'], 'EXT 9550'], ['one digit too many', ['95501534565', '(XXX) XXX-XXXX'], None], ['pairs pattern complete', ['9550153456', 'XX XX XX XX XX'], '95 50 15 34 56'], ['pairs pattern partial', ['9550', 'XX XX XX XX XX'], '95 50']]]\nfor label, arg, expected in fixtures[N - 1]:\n    check(label, solve(arg), expected)\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":"2b8bf669d4dac7c3c1e5df8d68b79760ccdcc4c4858f1e151da1f90f8d1e5c0f","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    digits, pattern = x\n    out, i, k, pend = [], 0, 0, ''\n    while k < len(pattern):\n        ch = pattern[k]\n        if ch == '\\\\' and k + 1 < len(pattern):\n            pend += pattern[k + 1]\n            k += 2\n            continue\n        if ch == 'X':\n            if i >= len(digits):\n                break\n            out.append(pend + digits[i])\n            pend = ''\n            i += 1\n        else:\n            pend += ch\n        k += 1\n    if i < len(digits):\n        return None\n    out.append(pend)\n    return ''.join(out)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['complete ten digits', ['5550113456', '(XXX) XXX-XXXX'], '(555) 011-3456'], ['three digits keep the bracket pending', ['555', '(XXX) XXX-XXXX'], '(555'], ['six digits', ['555011', '(XXX) XXX-XXXX'], '(555) 011'], ['nothing typed', ['', '(XXX) XXX-XXXX'], ''], ['pattern ending in a literal', ['555', '(XXX)'], '(555)'], ['escaped letter X', ['5550', 'E\\\\XT XXXX'], 'EXT 5550'], ['one digit too many', ['55501134561', '(XXX) XXX-XXXX'], None], ['pairs pattern complete', ['5550113456', 'XX XX XX XX XX'], '55 50 11 34 56'], ['pairs pattern partial', ['5550', 'XX XX XX XX XX'], '55 50']], [['complete ten digits', ['6550123456', '(XXX) XXX-XXXX'], '(655) 012-3456'], ['three digits keep the bracket pending', ['655', '(XXX) XXX-XXXX'], '(655'], ['six digits', ['655012', '(XXX) XXX-XXXX'], '(655) 012'], ['nothing typed', ['', '(XXX) XXX-XXXX'], ''], ['pattern ending in a literal', ['655', '(XXX)'], '(655)'], ['escaped letter X', ['6550', 'E\\\\XT XXXX'], 'EXT 6550'], ['one digit too many', ['65501234562', '(XXX) XXX-XXXX'], None], ['pairs pattern complete', ['6550123456', 'XX XX XX XX XX'], '65 50 12 34 56'], ['pairs pattern partial', ['6550', 'XX XX XX XX XX'], '65 50']], [['complete ten digits', ['7550133456', '(XXX) XXX-XXXX'], '(755) 013-3456'], ['three digits keep the bracket pending', ['755', '(XXX) XXX-XXXX'], '(755'], ['six digits', ['755013', '(XXX) XXX-XXXX'], '(755) 013'], ['nothing typed', ['', '(XXX) XXX-XXXX'], ''], ['pattern ending in a literal', ['755', '(XXX)'], '(755)'], ['escaped letter X', ['7550', 'E\\\\XT XXXX'], 'EXT 7550'], ['one digit too many', ['75501334563', '(XXX) XXX-XXXX'], None], ['pairs pattern complete', ['7550133456', 'XX XX XX XX XX'], '75 50 13 34 56'], ['pairs pattern partial', ['7550', 'XX XX XX XX XX'], '75 50']], [['complete ten digits', ['8550143456', '(XXX) XXX-XXXX'], '(855) 014-3456'], ['three digits keep the bracket pending', ['855', '(XXX) XXX-XXXX'], '(855'], ['six digits', ['855014', '(XXX) XXX-XXXX'], '(855) 014'], ['nothing typed', ['', '(XXX) XXX-XXXX'], ''], ['pattern ending in a literal', ['855', '(XXX)'], '(855)'], ['escaped letter X', ['8550', 'E\\\\XT XXXX'], 'EXT 8550'], ['one digit too many', ['85501434564', '(XXX) XXX-XXXX'], None], ['pairs pattern complete', ['8550143456', 'XX XX XX XX XX'], '85 50 14 34 56'], ['pairs pattern partial', ['8550', 'XX XX XX XX XX'], '85 50']], [['complete ten digits', ['9550153456', '(XXX) XXX-XXXX'], '(955) 015-3456'], ['three digits keep the bracket pending', ['955', '(XXX) XXX-XXXX'], '(955'], ['six digits', ['955015', '(XXX) XXX-XXXX'], '(955) 015'], ['nothing typed', ['', '(XXX) XXX-XXXX'], ''], ['pattern ending in a literal', ['955', '(XXX)'], '(955)'], ['escaped letter X', ['9550', 'E\\\\XT XXXX'], 'EXT 9550'], ['one digit too many', ['95501534565', '(XXX) XXX-XXXX'], None], ['pairs pattern complete', ['9550153456', 'XX XX XX XX XX'], '95 50 15 34 56'], ['pairs pattern partial', ['9550', 'XX XX XX XX XX'], '95 50']]]\nfor label, arg, expected in fixtures[N - 1]:\n    check(label, solve(arg), expected)\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":"f8306aef227a4142d80f6d1a1338405bd8b2b733653b7a052c0afca57c97078d","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    digits, pattern = x\n    out, i, k, pend = [], 0, 0, ''\n    while k < len(pattern):\n        ch = pattern[k]\n        if ch == '\\\\' and k + 1 < len(pattern):\n            pend += pattern[k + 1]\n            k += 2\n            continue\n        if ch == 'X':\n            if i >= len(digits):\n                break\n            out.append(pend + digits[i])\n            pend = ''\n            i += 1\n        else:\n            pend += ch\n        k += 1\n    if i < len(digits):\n        return None\n    if k >= len(pattern):\n        out.append(pend)\n    return ''.join(out)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['complete ten digits', ['5550113456', '(XXX) XXX-XXXX'], '(555) 011-3456'], ['three digits keep the bracket pending', ['555', '(XXX) XXX-XXXX'], '(555'], ['six digits', ['555011', '(XXX) XXX-XXXX'], '(555) 011'], ['nothing typed', ['', '(XXX) XXX-XXXX'], ''], ['pattern ending in a literal', ['555', '(XXX)'], '(555)'], ['escaped letter X', ['5550', 'E\\\\XT XXXX'], 'EXT 5550'], ['one digit too many', ['55501134561', '(XXX) XXX-XXXX'], None], ['pairs pattern complete', ['5550113456', 'XX XX XX XX XX'], '55 50 11 34 56'], ['pairs pattern partial', ['5550', 'XX XX XX XX XX'], '55 50']], [['complete ten digits', ['6550123456', '(XXX) XXX-XXXX'], '(655) 012-3456'], ['three digits keep the bracket pending', ['655', '(XXX) XXX-XXXX'], '(655'], ['six digits', ['655012', '(XXX) XXX-XXXX'], '(655) 012'], ['nothing typed', ['', '(XXX) XXX-XXXX'], ''], ['pattern ending in a literal', ['655', '(XXX)'], '(655)'], ['escaped letter X', ['6550', 'E\\\\XT XXXX'], 'EXT 6550'], ['one digit too many', ['65501234562', '(XXX) XXX-XXXX'], None], ['pairs pattern complete', ['6550123456', 'XX XX XX XX XX'], '65 50 12 34 56'], ['pairs pattern partial', ['6550', 'XX XX XX XX XX'], '65 50']], [['complete ten digits', ['7550133456', '(XXX) XXX-XXXX'], '(755) 013-3456'], ['three digits keep the bracket pending', ['755', '(XXX) XXX-XXXX'], '(755'], ['six digits', ['755013', '(XXX) XXX-XXXX'], '(755) 013'], ['nothing typed', ['', '(XXX) XXX-XXXX'], ''], ['pattern ending in a literal', ['755', '(XXX)'], '(755)'], ['escaped letter X', ['7550', 'E\\\\XT XXXX'], 'EXT 7550'], ['one digit too many', ['75501334563', '(XXX) XXX-XXXX'], None], ['pairs pattern complete', ['7550133456', 'XX XX XX XX XX'], '75 50 13 34 56'], ['pairs pattern partial', ['7550', 'XX XX XX XX XX'], '75 50']], [['complete ten digits', ['8550143456', '(XXX) XXX-XXXX'], '(855) 014-3456'], ['three digits keep the bracket pending', ['855', '(XXX) XXX-XXXX'], '(855'], ['six digits', ['855014', '(XXX) XXX-XXXX'], '(855) 014'], ['nothing typed', ['', '(XXX) XXX-XXXX'], ''], ['pattern ending in a literal', ['855', '(XXX)'], '(855)'], ['escaped letter X', ['8550', 'E\\\\XT XXXX'], 'EXT 8550'], ['one digit too many', ['85501434564', '(XXX) XXX-XXXX'], None], ['pairs pattern complete', ['8550143456', 'XX XX XX XX XX'], '85 50 14 34 56'], ['pairs pattern partial', ['8550', 'XX XX XX XX XX'], '85 50']], [['complete ten digits', ['9550153456', '(XXX) XXX-XXXX'], '(955) 015-3456'], ['three digits keep the bracket pending', ['955', '(XXX) XXX-XXXX'], '(955'], ['six digits', ['955015', '(XXX) XXX-XXXX'], '(955) 015'], ['nothing typed', ['', '(XXX) XXX-XXXX'], ''], ['pattern ending in a literal', ['955', '(XXX)'], '(955)'], ['escaped letter X', ['9550', 'E\\\\XT XXXX'], 'EXT 9550'], ['one digit too many', ['95501534565', '(XXX) XXX-XXXX'], None], ['pairs pattern complete', ['9550153456', 'XX XX XX XX XX'], '95 50 15 34 56'], ['pairs pattern partial', ['9550', 'XX XX XX XX XX'], '95 50']]]\nfor label, arg, expected in fixtures[N - 1]:\n    check(label, solve(arg), expected)\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":"A deterministic toy contract over synthetic, obviously fictitious telephone numbers and toy country tables. The rules are stipulated for this model only and make no claim of conformance with any numbering plan or telecommunications standard. 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":"w2-phone-number-formatting-pattern-mask-trailing-literal","generated_at":"2026-09-29T14:52:25.696361+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Input masks drive what users see while typing; stray punctuation, lost literals or silently dropped digits produce numbers that differ from what was typed.","repair":"Flush trailing literals only when the whole pattern was consumed.","root_cause":"Buffered literals are flushed even when the pattern stopped early for lack of digits.","sha256":"45dd706eceec549f930b8250653b4658456124e71d46a20e2104f92597ae4819","title":"Pattern-driven phone input mask: pending literals are written for partial input · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":40.474,"exit_code":1,"observations":[{"actual":"(555) 011-3456","check":"complete ten digits","expected":"(555) 011-3456","passed":true},{"actual":"(555","check":"three digits keep the bracket pending","expected":"(555","passed":true},{"actual":"(555) 011","check":"six digits","expected":"(555) 011","passed":true},{"actual":"","check":"nothing typed","expected":"","passed":true},{"actual":"(555","check":"pattern ending in a literal","expected":"(555)","passed":false},{"actual":"EXT 5550","check":"escaped letter X","expected":"EXT 5550","passed":true},{"actual":null,"check":"one digit too many","expected":null,"passed":true},{"actual":"55 50 11 34 56","check":"pairs pattern complete","expected":"55 50 11 34 56","passed":true},{"actual":"55 50","check":"pairs pattern partial","expected":"55 50","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"complete ten digits\", \"actual\": \"(555) 011-3456\", \"expected\": \"(555) 011-3456\", \"passed\": true}, {\"check\": \"three digits keep the bracket pending\", \"actual\": \"(555\", \"expected\": \"(555\", \"passed\": true}, {\"check\": \"six digits\", \"actual\": \"(555) 011\", \"expected\": \"(555) 011\", \"passed\": true}, {\"check\": \"nothing typed\", \"actual\": \"\", \"expected\": \"\", \"passed\": true}, {\"check\": \"pattern ending in a literal\", \"actual\": \"(555\", \"expected\": \"(555)\", \"passed\": false}, {\"check\": \"escaped letter X\", \"actual\": \"EXT 5550\", \"expected\": \"EXT 5550\", \"passed\": true}, {\"check\": \"one digit too many\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"pairs pattern complete\", \"actual\": \"55 50 11 34 56\", \"expected\": \"55 50 11 34 56\", \"passed\": true}, {\"check\": \"pairs pattern partial\", \"actual\": \"55 50\", \"expected\": \"55 50\", \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":38.016,"exit_code":1,"observations":[{"actual":"(555) 011-3456","check":"complete ten digits","expected":"(555) 011-3456","passed":true},{"actual":"(555) ","check":"three digits keep the bracket pending","expected":"(555","passed":false},{"actual":"(555) 011-","check":"six digits","expected":"(555) 011","passed":false},{"actual":"(","check":"nothing typed","expected":"","passed":false},{"actual":"(555)","check":"pattern ending in a literal","expected":"(555)","passed":true},{"actual":"EXT 5550","check":"escaped letter X","expected":"EXT 5550","passed":true},{"actual":null,"check":"one digit too many","expected":null,"passed":true},{"actual":"55 50 11 34 56","check":"pairs pattern complete","expected":"55 50 11 34 56","passed":true},{"actual":"55 50 ","check":"pairs pattern partial","expected":"55 50","passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"complete ten digits\", \"actual\": \"(555) 011-3456\", \"expected\": \"(555) 011-3456\", \"passed\": true}, {\"check\": \"three digits keep the bracket pending\", \"actual\": \"(555) \", \"expected\": \"(555\", \"passed\": false}, {\"check\": \"six digits\", \"actual\": \"(555) 011-\", \"expected\": \"(555) 011\", \"passed\": false}, {\"check\": \"nothing typed\", \"actual\": \"(\", \"expected\": \"\", \"passed\": false}, {\"check\": \"pattern ending in a literal\", \"actual\": \"(555)\", \"expected\": \"(555)\", \"passed\": true}, {\"check\": \"escaped letter X\", \"actual\": \"EXT 5550\", \"expected\": \"EXT 5550\", \"passed\": true}, {\"check\": \"one digit too many\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"pairs pattern complete\", \"actual\": \"55 50 11 34 56\", \"expected\": \"55 50 11 34 56\", \"passed\": true}, {\"check\": \"pairs pattern partial\", \"actual\": \"55 50 \", \"expected\": \"55 50\", \"passed\": false}], \"passed\": false}\n"},"fixed":{"elapsed_ms":40.124,"exit_code":0,"observations":[{"actual":"(555) 011-3456","check":"complete ten digits","expected":"(555) 011-3456","passed":true},{"actual":"(555","check":"three digits keep the bracket pending","expected":"(555","passed":true},{"actual":"(555) 011","check":"six digits","expected":"(555) 011","passed":true},{"actual":"","check":"nothing typed","expected":"","passed":true},{"actual":"(555)","check":"pattern ending in a literal","expected":"(555)","passed":true},{"actual":"EXT 5550","check":"escaped letter X","expected":"EXT 5550","passed":true},{"actual":null,"check":"one digit too many","expected":null,"passed":true},{"actual":"55 50 11 34 56","check":"pairs pattern complete","expected":"55 50 11 34 56","passed":true},{"actual":"55 50","check":"pairs pattern partial","expected":"55 50","passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"complete ten digits\", \"actual\": \"(555) 011-3456\", \"expected\": \"(555) 011-3456\", \"passed\": true}, {\"check\": \"three digits keep the bracket pending\", \"actual\": \"(555\", \"expected\": \"(555\", \"passed\": true}, {\"check\": \"six digits\", \"actual\": \"(555) 011\", \"expected\": \"(555) 011\", \"passed\": true}, {\"check\": \"nothing typed\", \"actual\": \"\", \"expected\": \"\", \"passed\": true}, {\"check\": \"pattern ending in a literal\", \"actual\": \"(555)\", \"expected\": \"(555)\", \"passed\": true}, {\"check\": \"escaped letter X\", \"actual\": \"EXT 5550\", \"expected\": \"EXT 5550\", \"passed\": true}, {\"check\": \"one digit too many\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"pairs pattern complete\", \"actual\": \"55 50 11 34 56\", \"expected\": \"55 50 11 34 56\", \"passed\": true}, {\"check\": \"pairs pattern partial\", \"actual\": \"55 50\", \"expected\": \"55 50\", \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}