{"abstract":"BB addresses without a region are reported as region_missing.","category":"Postal address normalization","checks":12,"contract":"Input a dict. Unknown country (not AA, BB, CC) returns [\"country_unknown\"]. Values are stripped of all whitespace (None counts as blank). Issues, in order: line1_missing; line2_duplicate when a non-blank line2 equals line1 ignoring case; city_missing; for AA region_missing or region_invalid (not two letters); for AA and BB postal_missing or postal_invalid (AA 5 digits, BB 4 digits); for CC postal_unexpected when a non-blank code is given.","evaluation_group":"w2-postal-address-normalization-completeness","failed_approach":"Also validating any region that happens to be present still reports a BB region as invalid.","family":"w2-postal-address-normalization-completeness-region-scope","id":"FA-96316","implementations":{"attempt":{"sha256":"be933337ab5e59f69f58322c3005eddcf00f3f54bcf00b6dab34401142e4349d","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    c = x.get('country', '')\n    if c not in ('AA', 'BB', 'CC'):\n        return ['country_unknown']\n    g = lambda k: (x.get(k) or '').strip()\n    issues = []\n    if not g('line1'):\n        issues.append('line1_missing')\n    if g('line2') and g('line2').upper() == g('line1').upper():\n        issues.append('line2_duplicate')\n    if not g('city'):\n        issues.append('city_missing')\n    if c == 'AA' or g('region'):\n        if not g('region'):\n            issues.append('region_missing')\n        elif not (len(g('region')) == 2 and g('region').isalpha()):\n            issues.append('region_invalid')\n    if c in ('AA', 'BB'):\n        need = 5 if c == 'AA' else 4\n        if not g('postal'):\n            issues.append('postal_missing')\n        elif not (len(g('postal')) == need and g('postal').isdigit()):\n            issues.append('postal_invalid')\n    elif g('postal'):\n        issues.append('postal_unexpected')\n    return issues\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['complete domestic address', {'line1': '21 Fake Rd', 'line2': '', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'AA'}, []], ['tab-only city is missing', {'line1': '21 Fake Rd', 'line2': '', 'city': '\\t', 'region': 'ZZ', 'postal': '11345', 'country': 'AA'}, ['city_missing']], ['second line repeats the first in capitals', {'line1': '21 Fake Rd', 'line2': '21 FAKE RD', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'AA'}, ['line2_duplicate']], ['region not needed for BB', {'line1': '21 Fake Rd', 'city': 'Faketown', 'postal': '1234', 'country': 'BB'}, []], ['region ignored for BB', {'line1': '21 Fake Rd', 'city': 'Faketown', 'postal': '1234', 'country': 'BB', 'region': 'Q1'}, []], ['region with a digit', {'line1': '21 Fake Rd', 'line2': '', 'city': 'Faketown', 'region': 'Z9', 'postal': '11345', 'country': 'AA'}, ['region_invalid']], ['three-letter region', {'line1': '21 Fake Rd', 'line2': '', 'city': 'Faketown', 'region': 'ZZZ', 'postal': '11345', 'country': 'AA'}, ['region_invalid']], ['four-digit AA code', {'line1': '21 Fake Rd', 'line2': '', 'city': 'Faketown', 'region': 'ZZ', 'postal': '1234', 'country': 'AA'}, ['postal_invalid']], ['code given where none is used', {'line1': '21 Fake Rd', 'city': 'Faketown', 'country': 'CC', 'postal': '9919'}, ['postal_unexpected']], ['blank code where none is used', {'line1': '21 Fake Rd', 'city': 'Faketown', 'country': 'CC', 'postal': ''}, []], ['blank required code', {'line1': '21 Fake Rd', 'line2': '', 'city': 'Faketown', 'region': 'ZZ', 'postal': '', 'country': 'AA'}, ['postal_missing']], ['unknown country', {'line1': '21 Fake Rd', 'line2': '', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'DD'}, ['country_unknown']]], [['complete domestic address', {'line1': '22 Fake Rd', 'line2': '', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'AA'}, []], ['tab-only city is missing', {'line1': '22 Fake Rd', 'line2': '', 'city': '\\t', 'region': 'ZZ', 'postal': '12345', 'country': 'AA'}, ['city_missing']], ['second line repeats the first in capitals', {'line1': '22 Fake Rd', 'line2': '22 FAKE RD', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'AA'}, ['line2_duplicate']], ['region not needed for BB', {'line1': '22 Fake Rd', 'city': 'Nowhereville', 'postal': '2234', 'country': 'BB'}, []], ['region ignored for BB', {'line1': '22 Fake Rd', 'city': 'Nowhereville', 'postal': '2234', 'country': 'BB', 'region': 'Q1'}, []], ['region with a digit', {'line1': '22 Fake Rd', 'line2': '', 'city': 'Nowhereville', 'region': 'Z9', 'postal': '12345', 'country': 'AA'}, ['region_invalid']], ['three-letter region', {'line1': '22 Fake Rd', 'line2': '', 'city': 'Nowhereville', 'region': 'ZZZ', 'postal': '12345', 'country': 'AA'}, ['region_invalid']], ['four-digit AA code', {'line1': '22 Fake Rd', 'line2': '', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '1234', 'country': 'AA'}, ['postal_invalid']], ['code given where none is used', {'line1': '22 Fake Rd', 'city': 'Nowhereville', 'country': 'CC', 'postal': '9929'}, ['postal_unexpected']], ['blank code where none is used', {'line1': '22 Fake Rd', 'city': 'Nowhereville', 'country': 'CC', 'postal': ''}, []], ['blank required code', {'line1': '22 Fake Rd', 'line2': '', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '', 'country': 'AA'}, ['postal_missing']], ['unknown country', {'line1': '22 Fake Rd', 'line2': '', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'DD'}, ['country_unknown']]], [['complete domestic address', {'line1': '23 Fake Rd', 'line2': '', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'AA'}, []], ['tab-only city is missing', {'line1': '23 Fake Rd', 'line2': '', 'city': '\\t', 'region': 'ZZ', 'postal': '13345', 'country': 'AA'}, ['city_missing']], ['second line repeats the first in capitals', {'line1': '23 Fake Rd', 'line2': '23 FAKE RD', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'AA'}, ['line2_duplicate']], ['region not needed for BB', {'line1': '23 Fake Rd', 'city': 'Zorbleton', 'postal': '3234', 'country': 'BB'}, []], ['region ignored for BB', {'line1': '23 Fake Rd', 'city': 'Zorbleton', 'postal': '3234', 'country': 'BB', 'region': 'Q1'}, []], ['region with a digit', {'line1': '23 Fake Rd', 'line2': '', 'city': 'Zorbleton', 'region': 'Z9', 'postal': '13345', 'country': 'AA'}, ['region_invalid']], ['three-letter region', {'line1': '23 Fake Rd', 'line2': '', 'city': 'Zorbleton', 'region': 'ZZZ', 'postal': '13345', 'country': 'AA'}, ['region_invalid']], ['four-digit AA code', {'line1': '23 Fake Rd', 'line2': '', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '1234', 'country': 'AA'}, ['postal_invalid']], ['code given where none is used', {'line1': '23 Fake Rd', 'city': 'Zorbleton', 'country': 'CC', 'postal': '9939'}, ['postal_unexpected']], ['blank code where none is used', {'line1': '23 Fake Rd', 'city': 'Zorbleton', 'country': 'CC', 'postal': ''}, []], ['blank required code', {'line1': '23 Fake Rd', 'line2': '', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '', 'country': 'AA'}, ['postal_missing']], ['unknown country', {'line1': '23 Fake Rd', 'line2': '', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'DD'}, ['country_unknown']]], [['complete domestic address', {'line1': '24 Fake Rd', 'line2': '', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'AA'}, []], ['tab-only city is missing', {'line1': '24 Fake Rd', 'line2': '', 'city': '\\t', 'region': 'ZZ', 'postal': '14345', 'country': 'AA'}, ['city_missing']], ['second line repeats the first in capitals', {'line1': '24 Fake Rd', 'line2': '24 FAKE RD', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'AA'}, ['line2_duplicate']], ['region not needed for BB', {'line1': '24 Fake Rd', 'city': 'Quillby', 'postal': '4234', 'country': 'BB'}, []], ['region ignored for BB', {'line1': '24 Fake Rd', 'city': 'Quillby', 'postal': '4234', 'country': 'BB', 'region': 'Q1'}, []], ['region with a digit', {'line1': '24 Fake Rd', 'line2': '', 'city': 'Quillby', 'region': 'Z9', 'postal': '14345', 'country': 'AA'}, ['region_invalid']], ['three-letter region', {'line1': '24 Fake Rd', 'line2': '', 'city': 'Quillby', 'region': 'ZZZ', 'postal': '14345', 'country': 'AA'}, ['region_invalid']], ['four-digit AA code', {'line1': '24 Fake Rd', 'line2': '', 'city': 'Quillby', 'region': 'ZZ', 'postal': '1234', 'country': 'AA'}, ['postal_invalid']], ['code given where none is used', {'line1': '24 Fake Rd', 'city': 'Quillby', 'country': 'CC', 'postal': '9949'}, ['postal_unexpected']], ['blank code where none is used', {'line1': '24 Fake Rd', 'city': 'Quillby', 'country': 'CC', 'postal': ''}, []], ['blank required code', {'line1': '24 Fake Rd', 'line2': '', 'city': 'Quillby', 'region': 'ZZ', 'postal': '', 'country': 'AA'}, ['postal_missing']], ['unknown country', {'line1': '24 Fake Rd', 'line2': '', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'DD'}, ['country_unknown']]], [['complete domestic address', {'line1': '25 Fake Rd', 'line2': '', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'AA'}, []], ['tab-only city is missing', {'line1': '25 Fake Rd', 'line2': '', 'city': '\\t', 'region': 'ZZ', 'postal': '15345', 'country': 'AA'}, ['city_missing']], ['second line repeats the first in capitals', {'line1': '25 Fake Rd', 'line2': '25 FAKE RD', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'AA'}, ['line2_duplicate']], ['region not needed for BB', {'line1': '25 Fake Rd', 'city': 'Spraxham', 'postal': '5234', 'country': 'BB'}, []], ['region ignored for BB', {'line1': '25 Fake Rd', 'city': 'Spraxham', 'postal': '5234', 'country': 'BB', 'region': 'Q1'}, []], ['region with a digit', {'line1': '25 Fake Rd', 'line2': '', 'city': 'Spraxham', 'region': 'Z9', 'postal': '15345', 'country': 'AA'}, ['region_invalid']], ['three-letter region', {'line1': '25 Fake Rd', 'line2': '', 'city': 'Spraxham', 'region': 'ZZZ', 'postal': '15345', 'country': 'AA'}, ['region_invalid']], ['four-digit AA code', {'line1': '25 Fake Rd', 'line2': '', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '1234', 'country': 'AA'}, ['postal_invalid']], ['code given where none is used', {'line1': '25 Fake Rd', 'city': 'Spraxham', 'country': 'CC', 'postal': '9959'}, ['postal_unexpected']], ['blank code where none is used', {'line1': '25 Fake Rd', 'city': 'Spraxham', 'country': 'CC', 'postal': ''}, []], ['blank required code', {'line1': '25 Fake Rd', 'line2': '', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '', 'country': 'AA'}, ['postal_missing']], ['unknown country', {'line1': '25 Fake Rd', 'line2': '', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'DD'}, ['country_unknown']]]]\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":"61e3962d8884c1609707f9c61e94d3cd004f6bc48c8764513f1723c3cee9b70e","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    c = x.get('country', '')\n    if c not in ('AA', 'BB', 'CC'):\n        return ['country_unknown']\n    g = lambda k: (x.get(k) or '').strip()\n    issues = []\n    if not g('line1'):\n        issues.append('line1_missing')\n    if g('line2') and g('line2').upper() == g('line1').upper():\n        issues.append('line2_duplicate')\n    if not g('city'):\n        issues.append('city_missing')\n    if c in ('AA', 'BB'):\n        if not g('region'):\n            issues.append('region_missing')\n        elif not (len(g('region')) == 2 and g('region').isalpha()):\n            issues.append('region_invalid')\n    if c in ('AA', 'BB'):\n        need = 5 if c == 'AA' else 4\n        if not g('postal'):\n            issues.append('postal_missing')\n        elif not (len(g('postal')) == need and g('postal').isdigit()):\n            issues.append('postal_invalid')\n    elif g('postal'):\n        issues.append('postal_unexpected')\n    return issues\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['complete domestic address', {'line1': '21 Fake Rd', 'line2': '', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'AA'}, []], ['tab-only city is missing', {'line1': '21 Fake Rd', 'line2': '', 'city': '\\t', 'region': 'ZZ', 'postal': '11345', 'country': 'AA'}, ['city_missing']], ['second line repeats the first in capitals', {'line1': '21 Fake Rd', 'line2': '21 FAKE RD', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'AA'}, ['line2_duplicate']], ['region not needed for BB', {'line1': '21 Fake Rd', 'city': 'Faketown', 'postal': '1234', 'country': 'BB'}, []], ['region ignored for BB', {'line1': '21 Fake Rd', 'city': 'Faketown', 'postal': '1234', 'country': 'BB', 'region': 'Q1'}, []], ['region with a digit', {'line1': '21 Fake Rd', 'line2': '', 'city': 'Faketown', 'region': 'Z9', 'postal': '11345', 'country': 'AA'}, ['region_invalid']], ['three-letter region', {'line1': '21 Fake Rd', 'line2': '', 'city': 'Faketown', 'region': 'ZZZ', 'postal': '11345', 'country': 'AA'}, ['region_invalid']], ['four-digit AA code', {'line1': '21 Fake Rd', 'line2': '', 'city': 'Faketown', 'region': 'ZZ', 'postal': '1234', 'country': 'AA'}, ['postal_invalid']], ['code given where none is used', {'line1': '21 Fake Rd', 'city': 'Faketown', 'country': 'CC', 'postal': '9919'}, ['postal_unexpected']], ['blank code where none is used', {'line1': '21 Fake Rd', 'city': 'Faketown', 'country': 'CC', 'postal': ''}, []], ['blank required code', {'line1': '21 Fake Rd', 'line2': '', 'city': 'Faketown', 'region': 'ZZ', 'postal': '', 'country': 'AA'}, ['postal_missing']], ['unknown country', {'line1': '21 Fake Rd', 'line2': '', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'DD'}, ['country_unknown']]], [['complete domestic address', {'line1': '22 Fake Rd', 'line2': '', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'AA'}, []], ['tab-only city is missing', {'line1': '22 Fake Rd', 'line2': '', 'city': '\\t', 'region': 'ZZ', 'postal': '12345', 'country': 'AA'}, ['city_missing']], ['second line repeats the first in capitals', {'line1': '22 Fake Rd', 'line2': '22 FAKE RD', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'AA'}, ['line2_duplicate']], ['region not needed for BB', {'line1': '22 Fake Rd', 'city': 'Nowhereville', 'postal': '2234', 'country': 'BB'}, []], ['region ignored for BB', {'line1': '22 Fake Rd', 'city': 'Nowhereville', 'postal': '2234', 'country': 'BB', 'region': 'Q1'}, []], ['region with a digit', {'line1': '22 Fake Rd', 'line2': '', 'city': 'Nowhereville', 'region': 'Z9', 'postal': '12345', 'country': 'AA'}, ['region_invalid']], ['three-letter region', {'line1': '22 Fake Rd', 'line2': '', 'city': 'Nowhereville', 'region': 'ZZZ', 'postal': '12345', 'country': 'AA'}, ['region_invalid']], ['four-digit AA code', {'line1': '22 Fake Rd', 'line2': '', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '1234', 'country': 'AA'}, ['postal_invalid']], ['code given where none is used', {'line1': '22 Fake Rd', 'city': 'Nowhereville', 'country': 'CC', 'postal': '9929'}, ['postal_unexpected']], ['blank code where none is used', {'line1': '22 Fake Rd', 'city': 'Nowhereville', 'country': 'CC', 'postal': ''}, []], ['blank required code', {'line1': '22 Fake Rd', 'line2': '', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '', 'country': 'AA'}, ['postal_missing']], ['unknown country', {'line1': '22 Fake Rd', 'line2': '', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'DD'}, ['country_unknown']]], [['complete domestic address', {'line1': '23 Fake Rd', 'line2': '', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'AA'}, []], ['tab-only city is missing', {'line1': '23 Fake Rd', 'line2': '', 'city': '\\t', 'region': 'ZZ', 'postal': '13345', 'country': 'AA'}, ['city_missing']], ['second line repeats the first in capitals', {'line1': '23 Fake Rd', 'line2': '23 FAKE RD', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'AA'}, ['line2_duplicate']], ['region not needed for BB', {'line1': '23 Fake Rd', 'city': 'Zorbleton', 'postal': '3234', 'country': 'BB'}, []], ['region ignored for BB', {'line1': '23 Fake Rd', 'city': 'Zorbleton', 'postal': '3234', 'country': 'BB', 'region': 'Q1'}, []], ['region with a digit', {'line1': '23 Fake Rd', 'line2': '', 'city': 'Zorbleton', 'region': 'Z9', 'postal': '13345', 'country': 'AA'}, ['region_invalid']], ['three-letter region', {'line1': '23 Fake Rd', 'line2': '', 'city': 'Zorbleton', 'region': 'ZZZ', 'postal': '13345', 'country': 'AA'}, ['region_invalid']], ['four-digit AA code', {'line1': '23 Fake Rd', 'line2': '', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '1234', 'country': 'AA'}, ['postal_invalid']], ['code given where none is used', {'line1': '23 Fake Rd', 'city': 'Zorbleton', 'country': 'CC', 'postal': '9939'}, ['postal_unexpected']], ['blank code where none is used', {'line1': '23 Fake Rd', 'city': 'Zorbleton', 'country': 'CC', 'postal': ''}, []], ['blank required code', {'line1': '23 Fake Rd', 'line2': '', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '', 'country': 'AA'}, ['postal_missing']], ['unknown country', {'line1': '23 Fake Rd', 'line2': '', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'DD'}, ['country_unknown']]], [['complete domestic address', {'line1': '24 Fake Rd', 'line2': '', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'AA'}, []], ['tab-only city is missing', {'line1': '24 Fake Rd', 'line2': '', 'city': '\\t', 'region': 'ZZ', 'postal': '14345', 'country': 'AA'}, ['city_missing']], ['second line repeats the first in capitals', {'line1': '24 Fake Rd', 'line2': '24 FAKE RD', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'AA'}, ['line2_duplicate']], ['region not needed for BB', {'line1': '24 Fake Rd', 'city': 'Quillby', 'postal': '4234', 'country': 'BB'}, []], ['region ignored for BB', {'line1': '24 Fake Rd', 'city': 'Quillby', 'postal': '4234', 'country': 'BB', 'region': 'Q1'}, []], ['region with a digit', {'line1': '24 Fake Rd', 'line2': '', 'city': 'Quillby', 'region': 'Z9', 'postal': '14345', 'country': 'AA'}, ['region_invalid']], ['three-letter region', {'line1': '24 Fake Rd', 'line2': '', 'city': 'Quillby', 'region': 'ZZZ', 'postal': '14345', 'country': 'AA'}, ['region_invalid']], ['four-digit AA code', {'line1': '24 Fake Rd', 'line2': '', 'city': 'Quillby', 'region': 'ZZ', 'postal': '1234', 'country': 'AA'}, ['postal_invalid']], ['code given where none is used', {'line1': '24 Fake Rd', 'city': 'Quillby', 'country': 'CC', 'postal': '9949'}, ['postal_unexpected']], ['blank code where none is used', {'line1': '24 Fake Rd', 'city': 'Quillby', 'country': 'CC', 'postal': ''}, []], ['blank required code', {'line1': '24 Fake Rd', 'line2': '', 'city': 'Quillby', 'region': 'ZZ', 'postal': '', 'country': 'AA'}, ['postal_missing']], ['unknown country', {'line1': '24 Fake Rd', 'line2': '', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'DD'}, ['country_unknown']]], [['complete domestic address', {'line1': '25 Fake Rd', 'line2': '', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'AA'}, []], ['tab-only city is missing', {'line1': '25 Fake Rd', 'line2': '', 'city': '\\t', 'region': 'ZZ', 'postal': '15345', 'country': 'AA'}, ['city_missing']], ['second line repeats the first in capitals', {'line1': '25 Fake Rd', 'line2': '25 FAKE RD', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'AA'}, ['line2_duplicate']], ['region not needed for BB', {'line1': '25 Fake Rd', 'city': 'Spraxham', 'postal': '5234', 'country': 'BB'}, []], ['region ignored for BB', {'line1': '25 Fake Rd', 'city': 'Spraxham', 'postal': '5234', 'country': 'BB', 'region': 'Q1'}, []], ['region with a digit', {'line1': '25 Fake Rd', 'line2': '', 'city': 'Spraxham', 'region': 'Z9', 'postal': '15345', 'country': 'AA'}, ['region_invalid']], ['three-letter region', {'line1': '25 Fake Rd', 'line2': '', 'city': 'Spraxham', 'region': 'ZZZ', 'postal': '15345', 'country': 'AA'}, ['region_invalid']], ['four-digit AA code', {'line1': '25 Fake Rd', 'line2': '', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '1234', 'country': 'AA'}, ['postal_invalid']], ['code given where none is used', {'line1': '25 Fake Rd', 'city': 'Spraxham', 'country': 'CC', 'postal': '9959'}, ['postal_unexpected']], ['blank code where none is used', {'line1': '25 Fake Rd', 'city': 'Spraxham', 'country': 'CC', 'postal': ''}, []], ['blank required code', {'line1': '25 Fake Rd', 'line2': '', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '', 'country': 'AA'}, ['postal_missing']], ['unknown country', {'line1': '25 Fake Rd', 'line2': '', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'DD'}, ['country_unknown']]]]\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":"dbc7a59dfcc4b9ccefc400edef9c44e27ea69ba556363ba18b0a3a058249131c","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    c = x.get('country', '')\n    if c not in ('AA', 'BB', 'CC'):\n        return ['country_unknown']\n    g = lambda k: (x.get(k) or '').strip()\n    issues = []\n    if not g('line1'):\n        issues.append('line1_missing')\n    if g('line2') and g('line2').upper() == g('line1').upper():\n        issues.append('line2_duplicate')\n    if not g('city'):\n        issues.append('city_missing')\n    if c == 'AA':\n        if not g('region'):\n            issues.append('region_missing')\n        elif not (len(g('region')) == 2 and g('region').isalpha()):\n            issues.append('region_invalid')\n    if c in ('AA', 'BB'):\n        need = 5 if c == 'AA' else 4\n        if not g('postal'):\n            issues.append('postal_missing')\n        elif not (len(g('postal')) == need and g('postal').isdigit()):\n            issues.append('postal_invalid')\n    elif g('postal'):\n        issues.append('postal_unexpected')\n    return issues\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['complete domestic address', {'line1': '21 Fake Rd', 'line2': '', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'AA'}, []], ['tab-only city is missing', {'line1': '21 Fake Rd', 'line2': '', 'city': '\\t', 'region': 'ZZ', 'postal': '11345', 'country': 'AA'}, ['city_missing']], ['second line repeats the first in capitals', {'line1': '21 Fake Rd', 'line2': '21 FAKE RD', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'AA'}, ['line2_duplicate']], ['region not needed for BB', {'line1': '21 Fake Rd', 'city': 'Faketown', 'postal': '1234', 'country': 'BB'}, []], ['region ignored for BB', {'line1': '21 Fake Rd', 'city': 'Faketown', 'postal': '1234', 'country': 'BB', 'region': 'Q1'}, []], ['region with a digit', {'line1': '21 Fake Rd', 'line2': '', 'city': 'Faketown', 'region': 'Z9', 'postal': '11345', 'country': 'AA'}, ['region_invalid']], ['three-letter region', {'line1': '21 Fake Rd', 'line2': '', 'city': 'Faketown', 'region': 'ZZZ', 'postal': '11345', 'country': 'AA'}, ['region_invalid']], ['four-digit AA code', {'line1': '21 Fake Rd', 'line2': '', 'city': 'Faketown', 'region': 'ZZ', 'postal': '1234', 'country': 'AA'}, ['postal_invalid']], ['code given where none is used', {'line1': '21 Fake Rd', 'city': 'Faketown', 'country': 'CC', 'postal': '9919'}, ['postal_unexpected']], ['blank code where none is used', {'line1': '21 Fake Rd', 'city': 'Faketown', 'country': 'CC', 'postal': ''}, []], ['blank required code', {'line1': '21 Fake Rd', 'line2': '', 'city': 'Faketown', 'region': 'ZZ', 'postal': '', 'country': 'AA'}, ['postal_missing']], ['unknown country', {'line1': '21 Fake Rd', 'line2': '', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'DD'}, ['country_unknown']]], [['complete domestic address', {'line1': '22 Fake Rd', 'line2': '', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'AA'}, []], ['tab-only city is missing', {'line1': '22 Fake Rd', 'line2': '', 'city': '\\t', 'region': 'ZZ', 'postal': '12345', 'country': 'AA'}, ['city_missing']], ['second line repeats the first in capitals', {'line1': '22 Fake Rd', 'line2': '22 FAKE RD', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'AA'}, ['line2_duplicate']], ['region not needed for BB', {'line1': '22 Fake Rd', 'city': 'Nowhereville', 'postal': '2234', 'country': 'BB'}, []], ['region ignored for BB', {'line1': '22 Fake Rd', 'city': 'Nowhereville', 'postal': '2234', 'country': 'BB', 'region': 'Q1'}, []], ['region with a digit', {'line1': '22 Fake Rd', 'line2': '', 'city': 'Nowhereville', 'region': 'Z9', 'postal': '12345', 'country': 'AA'}, ['region_invalid']], ['three-letter region', {'line1': '22 Fake Rd', 'line2': '', 'city': 'Nowhereville', 'region': 'ZZZ', 'postal': '12345', 'country': 'AA'}, ['region_invalid']], ['four-digit AA code', {'line1': '22 Fake Rd', 'line2': '', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '1234', 'country': 'AA'}, ['postal_invalid']], ['code given where none is used', {'line1': '22 Fake Rd', 'city': 'Nowhereville', 'country': 'CC', 'postal': '9929'}, ['postal_unexpected']], ['blank code where none is used', {'line1': '22 Fake Rd', 'city': 'Nowhereville', 'country': 'CC', 'postal': ''}, []], ['blank required code', {'line1': '22 Fake Rd', 'line2': '', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '', 'country': 'AA'}, ['postal_missing']], ['unknown country', {'line1': '22 Fake Rd', 'line2': '', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'DD'}, ['country_unknown']]], [['complete domestic address', {'line1': '23 Fake Rd', 'line2': '', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'AA'}, []], ['tab-only city is missing', {'line1': '23 Fake Rd', 'line2': '', 'city': '\\t', 'region': 'ZZ', 'postal': '13345', 'country': 'AA'}, ['city_missing']], ['second line repeats the first in capitals', {'line1': '23 Fake Rd', 'line2': '23 FAKE RD', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'AA'}, ['line2_duplicate']], ['region not needed for BB', {'line1': '23 Fake Rd', 'city': 'Zorbleton', 'postal': '3234', 'country': 'BB'}, []], ['region ignored for BB', {'line1': '23 Fake Rd', 'city': 'Zorbleton', 'postal': '3234', 'country': 'BB', 'region': 'Q1'}, []], ['region with a digit', {'line1': '23 Fake Rd', 'line2': '', 'city': 'Zorbleton', 'region': 'Z9', 'postal': '13345', 'country': 'AA'}, ['region_invalid']], ['three-letter region', {'line1': '23 Fake Rd', 'line2': '', 'city': 'Zorbleton', 'region': 'ZZZ', 'postal': '13345', 'country': 'AA'}, ['region_invalid']], ['four-digit AA code', {'line1': '23 Fake Rd', 'line2': '', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '1234', 'country': 'AA'}, ['postal_invalid']], ['code given where none is used', {'line1': '23 Fake Rd', 'city': 'Zorbleton', 'country': 'CC', 'postal': '9939'}, ['postal_unexpected']], ['blank code where none is used', {'line1': '23 Fake Rd', 'city': 'Zorbleton', 'country': 'CC', 'postal': ''}, []], ['blank required code', {'line1': '23 Fake Rd', 'line2': '', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '', 'country': 'AA'}, ['postal_missing']], ['unknown country', {'line1': '23 Fake Rd', 'line2': '', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'DD'}, ['country_unknown']]], [['complete domestic address', {'line1': '24 Fake Rd', 'line2': '', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'AA'}, []], ['tab-only city is missing', {'line1': '24 Fake Rd', 'line2': '', 'city': '\\t', 'region': 'ZZ', 'postal': '14345', 'country': 'AA'}, ['city_missing']], ['second line repeats the first in capitals', {'line1': '24 Fake Rd', 'line2': '24 FAKE RD', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'AA'}, ['line2_duplicate']], ['region not needed for BB', {'line1': '24 Fake Rd', 'city': 'Quillby', 'postal': '4234', 'country': 'BB'}, []], ['region ignored for BB', {'line1': '24 Fake Rd', 'city': 'Quillby', 'postal': '4234', 'country': 'BB', 'region': 'Q1'}, []], ['region with a digit', {'line1': '24 Fake Rd', 'line2': '', 'city': 'Quillby', 'region': 'Z9', 'postal': '14345', 'country': 'AA'}, ['region_invalid']], ['three-letter region', {'line1': '24 Fake Rd', 'line2': '', 'city': 'Quillby', 'region': 'ZZZ', 'postal': '14345', 'country': 'AA'}, ['region_invalid']], ['four-digit AA code', {'line1': '24 Fake Rd', 'line2': '', 'city': 'Quillby', 'region': 'ZZ', 'postal': '1234', 'country': 'AA'}, ['postal_invalid']], ['code given where none is used', {'line1': '24 Fake Rd', 'city': 'Quillby', 'country': 'CC', 'postal': '9949'}, ['postal_unexpected']], ['blank code where none is used', {'line1': '24 Fake Rd', 'city': 'Quillby', 'country': 'CC', 'postal': ''}, []], ['blank required code', {'line1': '24 Fake Rd', 'line2': '', 'city': 'Quillby', 'region': 'ZZ', 'postal': '', 'country': 'AA'}, ['postal_missing']], ['unknown country', {'line1': '24 Fake Rd', 'line2': '', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'DD'}, ['country_unknown']]], [['complete domestic address', {'line1': '25 Fake Rd', 'line2': '', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'AA'}, []], ['tab-only city is missing', {'line1': '25 Fake Rd', 'line2': '', 'city': '\\t', 'region': 'ZZ', 'postal': '15345', 'country': 'AA'}, ['city_missing']], ['second line repeats the first in capitals', {'line1': '25 Fake Rd', 'line2': '25 FAKE RD', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'AA'}, ['line2_duplicate']], ['region not needed for BB', {'line1': '25 Fake Rd', 'city': 'Spraxham', 'postal': '5234', 'country': 'BB'}, []], ['region ignored for BB', {'line1': '25 Fake Rd', 'city': 'Spraxham', 'postal': '5234', 'country': 'BB', 'region': 'Q1'}, []], ['region with a digit', {'line1': '25 Fake Rd', 'line2': '', 'city': 'Spraxham', 'region': 'Z9', 'postal': '15345', 'country': 'AA'}, ['region_invalid']], ['three-letter region', {'line1': '25 Fake Rd', 'line2': '', 'city': 'Spraxham', 'region': 'ZZZ', 'postal': '15345', 'country': 'AA'}, ['region_invalid']], ['four-digit AA code', {'line1': '25 Fake Rd', 'line2': '', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '1234', 'country': 'AA'}, ['postal_invalid']], ['code given where none is used', {'line1': '25 Fake Rd', 'city': 'Spraxham', 'country': 'CC', 'postal': '9959'}, ['postal_unexpected']], ['blank code where none is used', {'line1': '25 Fake Rd', 'city': 'Spraxham', 'country': 'CC', 'postal': ''}, []], ['blank required code', {'line1': '25 Fake Rd', 'line2': '', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '', 'country': 'AA'}, ['postal_missing']], ['unknown country', {'line1': '25 Fake Rd', 'line2': '', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'DD'}, ['country_unknown']]]]\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 addresses. The rules are stipulated for this model only and make no claim of conformance with any postal authority 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-postal-address-normalization-completeness-region-scope","generated_at":"2026-09-29T14:52:21.614497+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Completeness checks gate address entry; false positives block valid orders and false negatives let undeliverable addresses through.","repair":"Apply region rules to AA only.","root_cause":"The region block runs for AA and BB.","sha256":"8fb798b66298f2333228deb72ab4458906bb880c52f96aeb2835fbed59498ff0","title":"Address completeness checker: region rules applied to BB · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":41.086,"exit_code":1,"observations":[{"actual":[],"check":"complete domestic address","expected":[],"passed":true},{"actual":["city_missing"],"check":"tab-only city is missing","expected":["city_missing"],"passed":true},{"actual":["line2_duplicate"],"check":"second line repeats the first in capitals","expected":["line2_duplicate"],"passed":true},{"actual":[],"check":"region not needed for BB","expected":[],"passed":true},{"actual":["region_invalid"],"check":"region ignored for BB","expected":[],"passed":false},{"actual":["region_invalid"],"check":"region with a digit","expected":["region_invalid"],"passed":true},{"actual":["region_invalid"],"check":"three-letter region","expected":["region_invalid"],"passed":true},{"actual":["postal_invalid"],"check":"four-digit AA code","expected":["postal_invalid"],"passed":true},{"actual":["postal_unexpected"],"check":"code given where none is used","expected":["postal_unexpected"],"passed":true},{"actual":[],"check":"blank code where none is used","expected":[],"passed":true},{"actual":["postal_missing"],"check":"blank required code","expected":["postal_missing"],"passed":true},{"actual":["country_unknown"],"check":"unknown country","expected":["country_unknown"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"complete domestic address\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"tab-only city is missing\", \"actual\": [\"city_missing\"], \"expected\": [\"city_missing\"], \"passed\": true}, {\"check\": \"second line repeats the first in capitals\", \"actual\": [\"line2_duplicate\"], \"expected\": [\"line2_duplicate\"], \"passed\": true}, {\"check\": \"region not needed for BB\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"region ignored for BB\", \"actual\": [\"region_invalid\"], \"expected\": [], \"passed\": false}, {\"check\": \"region with a digit\", \"actual\": [\"region_invalid\"], \"expected\": [\"region_invalid\"], \"passed\": true}, {\"check\": \"three-letter region\", \"actual\": [\"region_invalid\"], \"expected\": [\"region_invalid\"], \"passed\": true}, {\"check\": \"four-digit AA code\", \"actual\": [\"postal_invalid\"], \"expected\": [\"postal_invalid\"], \"passed\": true}, {\"check\": \"code given where none is used\", \"actual\": [\"postal_unexpected\"], \"expected\": [\"postal_unexpected\"], \"passed\": true}, {\"check\": \"blank code where none is used\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"blank required code\", \"actual\": [\"postal_missing\"], \"expected\": [\"postal_missing\"], \"passed\": true}, {\"check\": \"unknown country\", \"actual\": [\"country_unknown\"], \"expected\": [\"country_unknown\"], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":40.256,"exit_code":1,"observations":[{"actual":[],"check":"complete domestic address","expected":[],"passed":true},{"actual":["city_missing"],"check":"tab-only city is missing","expected":["city_missing"],"passed":true},{"actual":["line2_duplicate"],"check":"second line repeats the first in capitals","expected":["line2_duplicate"],"passed":true},{"actual":["region_missing"],"check":"region not needed for BB","expected":[],"passed":false},{"actual":["region_invalid"],"check":"region ignored for BB","expected":[],"passed":false},{"actual":["region_invalid"],"check":"region with a digit","expected":["region_invalid"],"passed":true},{"actual":["region_invalid"],"check":"three-letter region","expected":["region_invalid"],"passed":true},{"actual":["postal_invalid"],"check":"four-digit AA code","expected":["postal_invalid"],"passed":true},{"actual":["postal_unexpected"],"check":"code given where none is used","expected":["postal_unexpected"],"passed":true},{"actual":[],"check":"blank code where none is used","expected":[],"passed":true},{"actual":["postal_missing"],"check":"blank required code","expected":["postal_missing"],"passed":true},{"actual":["country_unknown"],"check":"unknown country","expected":["country_unknown"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"complete domestic address\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"tab-only city is missing\", \"actual\": [\"city_missing\"], \"expected\": [\"city_missing\"], \"passed\": true}, {\"check\": \"second line repeats the first in capitals\", \"actual\": [\"line2_duplicate\"], \"expected\": [\"line2_duplicate\"], \"passed\": true}, {\"check\": \"region not needed for BB\", \"actual\": [\"region_missing\"], \"expected\": [], \"passed\": false}, {\"check\": \"region ignored for BB\", \"actual\": [\"region_invalid\"], \"expected\": [], \"passed\": false}, {\"check\": \"region with a digit\", \"actual\": [\"region_invalid\"], \"expected\": [\"region_invalid\"], \"passed\": true}, {\"check\": \"three-letter region\", \"actual\": [\"region_invalid\"], \"expected\": [\"region_invalid\"], \"passed\": true}, {\"check\": \"four-digit AA code\", \"actual\": [\"postal_invalid\"], \"expected\": [\"postal_invalid\"], \"passed\": true}, {\"check\": \"code given where none is used\", \"actual\": [\"postal_unexpected\"], \"expected\": [\"postal_unexpected\"], \"passed\": true}, {\"check\": \"blank code where none is used\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"blank required code\", \"actual\": [\"postal_missing\"], \"expected\": [\"postal_missing\"], \"passed\": true}, {\"check\": \"unknown country\", \"actual\": [\"country_unknown\"], \"expected\": [\"country_unknown\"], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":39.162,"exit_code":0,"observations":[{"actual":[],"check":"complete domestic address","expected":[],"passed":true},{"actual":["city_missing"],"check":"tab-only city is missing","expected":["city_missing"],"passed":true},{"actual":["line2_duplicate"],"check":"second line repeats the first in capitals","expected":["line2_duplicate"],"passed":true},{"actual":[],"check":"region not needed for BB","expected":[],"passed":true},{"actual":[],"check":"region ignored for BB","expected":[],"passed":true},{"actual":["region_invalid"],"check":"region with a digit","expected":["region_invalid"],"passed":true},{"actual":["region_invalid"],"check":"three-letter region","expected":["region_invalid"],"passed":true},{"actual":["postal_invalid"],"check":"four-digit AA code","expected":["postal_invalid"],"passed":true},{"actual":["postal_unexpected"],"check":"code given where none is used","expected":["postal_unexpected"],"passed":true},{"actual":[],"check":"blank code where none is used","expected":[],"passed":true},{"actual":["postal_missing"],"check":"blank required code","expected":["postal_missing"],"passed":true},{"actual":["country_unknown"],"check":"unknown country","expected":["country_unknown"],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"complete domestic address\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"tab-only city is missing\", \"actual\": [\"city_missing\"], \"expected\": [\"city_missing\"], \"passed\": true}, {\"check\": \"second line repeats the first in capitals\", \"actual\": [\"line2_duplicate\"], \"expected\": [\"line2_duplicate\"], \"passed\": true}, {\"check\": \"region not needed for BB\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"region ignored for BB\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"region with a digit\", \"actual\": [\"region_invalid\"], \"expected\": [\"region_invalid\"], \"passed\": true}, {\"check\": \"three-letter region\", \"actual\": [\"region_invalid\"], \"expected\": [\"region_invalid\"], \"passed\": true}, {\"check\": \"four-digit AA code\", \"actual\": [\"postal_invalid\"], \"expected\": [\"postal_invalid\"], \"passed\": true}, {\"check\": \"code given where none is used\", \"actual\": [\"postal_unexpected\"], \"expected\": [\"postal_unexpected\"], \"passed\": true}, {\"check\": \"blank code where none is used\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"blank required code\", \"actual\": [\"postal_missing\"], \"expected\": [\"postal_missing\"], \"passed\": true}, {\"check\": \"unknown country\", \"actual\": [\"country_unknown\"], \"expected\": [\"country_unknown\"], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}