FAILURE MAP
← Case archive

FA-96231 / Postal address normalization / Open access

Country address template renderer: empty components leave doubled spaces · case 01

A missing region renders "Faketown 11345".

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Rendered lines are only stripped, not collapsed.

VERIFIED REPAIR

Collapse whitespace runs inside each rendered line.

Unsuccessful approach: Replacing a double space once leaves a leading space when both city and region are empty.

Case contract

Input fields name, street, city, region, postal, country (destination) and origin. Toy templates: AA "{city} {region} {postal}", BB "{postal} {city}", CC city and postal on separate lines with the city uppercased; unknown destinations use AA. Each rendered line is whitespace-collapsed and empty lines are dropped. When origin differs from destination the destination name (or its code when unknown) is appended.

Why this case matters

Cross-border labels must follow the destination order; misplaced or doubled components delay or return shipments.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    T = {'AA': ['{name}', '{street}', '{city} {region} {postal}'], 'BB': ['{name}', '{street}', '{postal} {city}'],
         'CC': ['{name}', '{street}', '{city}', '{postal}']}
    NAMES = {'AA': 'AALANDIA', 'BB': 'BEEMARK', 'CC': 'CEELAND'}
    dest = x['country']
    fields = dict(x)
    if dest == 'CC':
        fields['city'] = fields['city'].upper()
    lines = []
    for tpl in T.get(dest, T['AA']):
        line = tpl.format(**fields).strip()
        if line:
            lines.append(line)
    if x['origin'] != dest:
        lines.append(NAMES.get(dest, dest))
    return lines
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['domestic three-part last line', {'name': 'Pat Example', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'AA', 'origin': 'AA'}, ['Pat Example', '4 Fake Rd', 'Faketown ZZ 11345']], ['missing region collapses spacing', {'name': 'Pat Example', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': '', 'postal': '11345', 'country': 'AA', 'origin': 'AA'}, ['Pat Example', '4 Fake Rd', 'Faketown 11345']], ['only a postal code on the last line', {'name': 'Pat Example', 'street': '4 Fake Rd', 'city': '', 'region': '', 'postal': '11345', 'country': 'AA', 'origin': 'AA'}, ['Pat Example', '4 Fake Rd', '11345']], ['postal code first, international', {'name': 'Pat Example', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': '', 'postal': '1234', 'country': 'BB', 'origin': 'AA'}, ['Pat Example', '4 Fake Rd', '1234 Faketown', 'BEEMARK']], ['uppercase city on its own line', {'name': 'Pat Example', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': '', 'postal': '11345', 'country': 'CC', 'origin': 'BB'}, ['Pat Example', '4 Fake Rd', 'FAKETOWN', '11345', 'CEELAND']], ['unknown destination falls back', {'name': 'Pat Example', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'DD', 'origin': 'AA'}, ['Pat Example', '4 Fake Rd', 'Faketown ZZ 11345', 'DD']], ['empty name line dropped', {'name': '', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'AA', 'origin': 'AA'}, ['4 Fake Rd', 'Faketown ZZ 11345']], ['one-letter name kept', {'name': 'Q', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'AA', 'origin': 'AA'}, ['Q', '4 Fake Rd', 'Faketown ZZ 11345']]], [['domestic three-part last line', {'name': 'Lee Sample', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'AA', 'origin': 'AA'}, ['Lee Sample', '5 Fake Rd', 'Nowhereville ZZ 12345']], ['missing region collapses spacing', {'name': 'Lee Sample', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': '', 'postal': '12345', 'country': 'AA', 'origin': 'AA'}, ['Lee Sample', '5 Fake Rd', 'Nowhereville 12345']], ['only a postal code on the last line', {'name': 'Lee Sample', 'street': '5 Fake Rd', 'city': '', 'region': '', 'postal': '12345', 'country': 'AA', 'origin': 'AA'}, ['Lee Sample', '5 Fake Rd', '12345']], ['postal code first, international', {'name': 'Lee Sample', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': '', 'postal': '2234', 'country': 'BB', 'origin': 'AA'}, ['Lee Sample', '5 Fake Rd', '2234 Nowhereville', 'BEEMARK']], ['uppercase city on its own line', {'name': 'Lee Sample', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': '', 'postal': '12345', 'country': 'CC', 'origin': 'BB'}, ['Lee Sample', '5 Fake Rd', 'NOWHEREVILLE', '12345', 'CEELAND']], ['unknown destination falls back', {'name': 'Lee Sample', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'DD', 'origin': 'AA'}, ['Lee Sample', '5 Fake Rd', 'Nowhereville ZZ 12345', 'DD']], ['empty name line dropped', {'name': '', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'AA', 'origin': 'AA'}, ['5 Fake Rd', 'Nowhereville ZZ 12345']], ['one-letter name kept', {'name': 'Q', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'AA', 'origin': 'AA'}, ['Q', '5 Fake Rd', 'Nowhereville ZZ 12345']]], [['domestic three-part last line', {'name': 'Robin Placeholder', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'AA', 'origin': 'AA'}, ['Robin Placeholder', '6 Fake Rd', 'Zorbleton ZZ 13345']], ['missing region collapses spacing', {'name': 'Robin Placeholder', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': '', 'postal': '13345', 'country': 'AA', 'origin': 'AA'}, ['Robin Placeholder', '6 Fake Rd', 'Zorbleton 13345']], ['only a postal code on the last line', {'name': 'Robin Placeholder', 'street': '6 Fake Rd', 'city': '', 'region': '', 'postal': '13345', 'country': 'AA', 'origin': 'AA'}, ['Robin Placeholder', '6 Fake Rd', '13345']], ['postal code first, international', {'name': 'Robin Placeholder', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': '', 'postal': '3234', 'country': 'BB', 'origin': 'AA'}, ['Robin Placeholder', '6 Fake Rd', '3234 Zorbleton', 'BEEMARK']], ['uppercase city on its own line', {'name': 'Robin Placeholder', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': '', 'postal': '13345', 'country': 'CC', 'origin': 'BB'}, ['Robin Placeholder', '6 Fake Rd', 'ZORBLETON', '13345', 'CEELAND']], ['unknown destination falls back', {'name': 'Robin Placeholder', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'DD', 'origin': 'AA'}, ['Robin Placeholder', '6 Fake Rd', 'Zorbleton ZZ 13345', 'DD']], ['empty name line dropped', {'name': '', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'AA', 'origin': 'AA'}, ['6 Fake Rd', 'Zorbleton ZZ 13345']], ['one-letter name kept', {'name': 'Q', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'AA', 'origin': 'AA'}, ['Q', '6 Fake Rd', 'Zorbleton ZZ 13345']]], [['domestic three-part last line', {'name': 'Sam Demo', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'AA', 'origin': 'AA'}, ['Sam Demo', '7 Fake Rd', 'Quillby ZZ 14345']], ['missing region collapses spacing', {'name': 'Sam Demo', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': '', 'postal': '14345', 'country': 'AA', 'origin': 'AA'}, ['Sam Demo', '7 Fake Rd', 'Quillby 14345']], ['only a postal code on the last line', {'name': 'Sam Demo', 'street': '7 Fake Rd', 'city': '', 'region': '', 'postal': '14345', 'country': 'AA', 'origin': 'AA'}, ['Sam Demo', '7 Fake Rd', '14345']], ['postal code first, international', {'name': 'Sam Demo', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': '', 'postal': '4234', 'country': 'BB', 'origin': 'AA'}, ['Sam Demo', '7 Fake Rd', '4234 Quillby', 'BEEMARK']], ['uppercase city on its own line', {'name': 'Sam Demo', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': '', 'postal': '14345', 'country': 'CC', 'origin': 'BB'}, ['Sam Demo', '7 Fake Rd', 'QUILLBY', '14345', 'CEELAND']], ['unknown destination falls back', {'name': 'Sam Demo', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'DD', 'origin': 'AA'}, ['Sam Demo', '7 Fake Rd', 'Quillby ZZ 14345', 'DD']], ['empty name line dropped', {'name': '', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'AA', 'origin': 'AA'}, ['7 Fake Rd', 'Quillby ZZ 14345']], ['one-letter name kept', {'name': 'Q', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'AA', 'origin': 'AA'}, ['Q', '7 Fake Rd', 'Quillby ZZ 14345']]], [['domestic three-part last line', {'name': 'Alex Fiction', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'AA', 'origin': 'AA'}, ['Alex Fiction', '8 Fake Rd', 'Spraxham ZZ 15345']], ['missing region collapses spacing', {'name': 'Alex Fiction', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': '', 'postal': '15345', 'country': 'AA', 'origin': 'AA'}, ['Alex Fiction', '8 Fake Rd', 'Spraxham 15345']], ['only a postal code on the last line', {'name': 'Alex Fiction', 'street': '8 Fake Rd', 'city': '', 'region': '', 'postal': '15345', 'country': 'AA', 'origin': 'AA'}, ['Alex Fiction', '8 Fake Rd', '15345']], ['postal code first, international', {'name': 'Alex Fiction', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': '', 'postal': '5234', 'country': 'BB', 'origin': 'AA'}, ['Alex Fiction', '8 Fake Rd', '5234 Spraxham', 'BEEMARK']], ['uppercase city on its own line', {'name': 'Alex Fiction', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': '', 'postal': '15345', 'country': 'CC', 'origin': 'BB'}, ['Alex Fiction', '8 Fake Rd', 'SPRAXHAM', '15345', 'CEELAND']], ['unknown destination falls back', {'name': 'Alex Fiction', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'DD', 'origin': 'AA'}, ['Alex Fiction', '8 Fake Rd', 'Spraxham ZZ 15345', 'DD']], ['empty name line dropped', {'name': '', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'AA', 'origin': 'AA'}, ['8 Fake Rd', 'Spraxham ZZ 15345']], ['one-letter name kept', {'name': 'Q', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'AA', 'origin': 'AA'}, ['Q', '8 Fake Rd', 'Spraxham ZZ 15345']]]]
for label, arg, expected in fixtures[N - 1]:
    check(label, solve(arg), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
domestic three-part last line['Pat Example', '4 Fake Rd', 'Faketown ZZ 11345']['Pat Example', '4 Fake Rd', 'Faketown ZZ 11345']Passed
missing region collapses spacing['Pat Example', '4 Fake Rd', 'Faketown 11345']['Pat Example', '4 Fake Rd', 'Faketown 11345']Failed
only a postal code on the last line['Pat Example', '4 Fake Rd', '11345']['Pat Example', '4 Fake Rd', '11345']Passed
postal code first, international['Pat Example', '4 Fake Rd', '1234 Faketown', 'BEEMARK']['Pat Example', '4 Fake Rd', '1234 Faketown', 'BEEMARK']Passed
uppercase city on its own line['Pat Example', '4 Fake Rd', 'FAKETOWN', '11345', 'CEELAND']['Pat Example', '4 Fake Rd', 'FAKETOWN', '11345', 'CEELAND']Passed
unknown destination falls back['Pat Example', '4 Fake Rd', 'Faketown ZZ 11345', 'DD']['Pat Example', '4 Fake Rd', 'Faketown ZZ 11345', 'DD']Passed
empty name line dropped['4 Fake Rd', 'Faketown ZZ 11345']['4 Fake Rd', 'Faketown ZZ 11345']Passed
one-letter name kept['Q', '4 Fake Rd', 'Faketown ZZ 11345']['Q', '4 Fake Rd', 'Faketown ZZ 11345']Passed

SHA-256 / ca2a07cf1e014fcacc155b8f0349ad936995bd055e5bb6055337e2861e00b743

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    T = {'AA': ['{name}', '{street}', '{city} {region} {postal}'], 'BB': ['{name}', '{street}', '{postal} {city}'],
         'CC': ['{name}', '{street}', '{city}', '{postal}']}
    NAMES = {'AA': 'AALANDIA', 'BB': 'BEEMARK', 'CC': 'CEELAND'}
    dest = x['country']
    fields = dict(x)
    if dest == 'CC':
        fields['city'] = fields['city'].upper()
    lines = []
    for tpl in T.get(dest, T['AA']):
        line = tpl.format(**fields).replace('  ', ' ')
        if line:
            lines.append(line)
    if x['origin'] != dest:
        lines.append(NAMES.get(dest, dest))
    return lines
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['domestic three-part last line', {'name': 'Pat Example', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'AA', 'origin': 'AA'}, ['Pat Example', '4 Fake Rd', 'Faketown ZZ 11345']], ['missing region collapses spacing', {'name': 'Pat Example', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': '', 'postal': '11345', 'country': 'AA', 'origin': 'AA'}, ['Pat Example', '4 Fake Rd', 'Faketown 11345']], ['only a postal code on the last line', {'name': 'Pat Example', 'street': '4 Fake Rd', 'city': '', 'region': '', 'postal': '11345', 'country': 'AA', 'origin': 'AA'}, ['Pat Example', '4 Fake Rd', '11345']], ['postal code first, international', {'name': 'Pat Example', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': '', 'postal': '1234', 'country': 'BB', 'origin': 'AA'}, ['Pat Example', '4 Fake Rd', '1234 Faketown', 'BEEMARK']], ['uppercase city on its own line', {'name': 'Pat Example', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': '', 'postal': '11345', 'country': 'CC', 'origin': 'BB'}, ['Pat Example', '4 Fake Rd', 'FAKETOWN', '11345', 'CEELAND']], ['unknown destination falls back', {'name': 'Pat Example', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'DD', 'origin': 'AA'}, ['Pat Example', '4 Fake Rd', 'Faketown ZZ 11345', 'DD']], ['empty name line dropped', {'name': '', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'AA', 'origin': 'AA'}, ['4 Fake Rd', 'Faketown ZZ 11345']], ['one-letter name kept', {'name': 'Q', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'AA', 'origin': 'AA'}, ['Q', '4 Fake Rd', 'Faketown ZZ 11345']]], [['domestic three-part last line', {'name': 'Lee Sample', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'AA', 'origin': 'AA'}, ['Lee Sample', '5 Fake Rd', 'Nowhereville ZZ 12345']], ['missing region collapses spacing', {'name': 'Lee Sample', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': '', 'postal': '12345', 'country': 'AA', 'origin': 'AA'}, ['Lee Sample', '5 Fake Rd', 'Nowhereville 12345']], ['only a postal code on the last line', {'name': 'Lee Sample', 'street': '5 Fake Rd', 'city': '', 'region': '', 'postal': '12345', 'country': 'AA', 'origin': 'AA'}, ['Lee Sample', '5 Fake Rd', '12345']], ['postal code first, international', {'name': 'Lee Sample', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': '', 'postal': '2234', 'country': 'BB', 'origin': 'AA'}, ['Lee Sample', '5 Fake Rd', '2234 Nowhereville', 'BEEMARK']], ['uppercase city on its own line', {'name': 'Lee Sample', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': '', 'postal': '12345', 'country': 'CC', 'origin': 'BB'}, ['Lee Sample', '5 Fake Rd', 'NOWHEREVILLE', '12345', 'CEELAND']], ['unknown destination falls back', {'name': 'Lee Sample', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'DD', 'origin': 'AA'}, ['Lee Sample', '5 Fake Rd', 'Nowhereville ZZ 12345', 'DD']], ['empty name line dropped', {'name': '', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'AA', 'origin': 'AA'}, ['5 Fake Rd', 'Nowhereville ZZ 12345']], ['one-letter name kept', {'name': 'Q', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'AA', 'origin': 'AA'}, ['Q', '5 Fake Rd', 'Nowhereville ZZ 12345']]], [['domestic three-part last line', {'name': 'Robin Placeholder', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'AA', 'origin': 'AA'}, ['Robin Placeholder', '6 Fake Rd', 'Zorbleton ZZ 13345']], ['missing region collapses spacing', {'name': 'Robin Placeholder', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': '', 'postal': '13345', 'country': 'AA', 'origin': 'AA'}, ['Robin Placeholder', '6 Fake Rd', 'Zorbleton 13345']], ['only a postal code on the last line', {'name': 'Robin Placeholder', 'street': '6 Fake Rd', 'city': '', 'region': '', 'postal': '13345', 'country': 'AA', 'origin': 'AA'}, ['Robin Placeholder', '6 Fake Rd', '13345']], ['postal code first, international', {'name': 'Robin Placeholder', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': '', 'postal': '3234', 'country': 'BB', 'origin': 'AA'}, ['Robin Placeholder', '6 Fake Rd', '3234 Zorbleton', 'BEEMARK']], ['uppercase city on its own line', {'name': 'Robin Placeholder', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': '', 'postal': '13345', 'country': 'CC', 'origin': 'BB'}, ['Robin Placeholder', '6 Fake Rd', 'ZORBLETON', '13345', 'CEELAND']], ['unknown destination falls back', {'name': 'Robin Placeholder', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'DD', 'origin': 'AA'}, ['Robin Placeholder', '6 Fake Rd', 'Zorbleton ZZ 13345', 'DD']], ['empty name line dropped', {'name': '', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'AA', 'origin': 'AA'}, ['6 Fake Rd', 'Zorbleton ZZ 13345']], ['one-letter name kept', {'name': 'Q', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'AA', 'origin': 'AA'}, ['Q', '6 Fake Rd', 'Zorbleton ZZ 13345']]], [['domestic three-part last line', {'name': 'Sam Demo', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'AA', 'origin': 'AA'}, ['Sam Demo', '7 Fake Rd', 'Quillby ZZ 14345']], ['missing region collapses spacing', {'name': 'Sam Demo', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': '', 'postal': '14345', 'country': 'AA', 'origin': 'AA'}, ['Sam Demo', '7 Fake Rd', 'Quillby 14345']], ['only a postal code on the last line', {'name': 'Sam Demo', 'street': '7 Fake Rd', 'city': '', 'region': '', 'postal': '14345', 'country': 'AA', 'origin': 'AA'}, ['Sam Demo', '7 Fake Rd', '14345']], ['postal code first, international', {'name': 'Sam Demo', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': '', 'postal': '4234', 'country': 'BB', 'origin': 'AA'}, ['Sam Demo', '7 Fake Rd', '4234 Quillby', 'BEEMARK']], ['uppercase city on its own line', {'name': 'Sam Demo', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': '', 'postal': '14345', 'country': 'CC', 'origin': 'BB'}, ['Sam Demo', '7 Fake Rd', 'QUILLBY', '14345', 'CEELAND']], ['unknown destination falls back', {'name': 'Sam Demo', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'DD', 'origin': 'AA'}, ['Sam Demo', '7 Fake Rd', 'Quillby ZZ 14345', 'DD']], ['empty name line dropped', {'name': '', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'AA', 'origin': 'AA'}, ['7 Fake Rd', 'Quillby ZZ 14345']], ['one-letter name kept', {'name': 'Q', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'AA', 'origin': 'AA'}, ['Q', '7 Fake Rd', 'Quillby ZZ 14345']]], [['domestic three-part last line', {'name': 'Alex Fiction', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'AA', 'origin': 'AA'}, ['Alex Fiction', '8 Fake Rd', 'Spraxham ZZ 15345']], ['missing region collapses spacing', {'name': 'Alex Fiction', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': '', 'postal': '15345', 'country': 'AA', 'origin': 'AA'}, ['Alex Fiction', '8 Fake Rd', 'Spraxham 15345']], ['only a postal code on the last line', {'name': 'Alex Fiction', 'street': '8 Fake Rd', 'city': '', 'region': '', 'postal': '15345', 'country': 'AA', 'origin': 'AA'}, ['Alex Fiction', '8 Fake Rd', '15345']], ['postal code first, international', {'name': 'Alex Fiction', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': '', 'postal': '5234', 'country': 'BB', 'origin': 'AA'}, ['Alex Fiction', '8 Fake Rd', '5234 Spraxham', 'BEEMARK']], ['uppercase city on its own line', {'name': 'Alex Fiction', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': '', 'postal': '15345', 'country': 'CC', 'origin': 'BB'}, ['Alex Fiction', '8 Fake Rd', 'SPRAXHAM', '15345', 'CEELAND']], ['unknown destination falls back', {'name': 'Alex Fiction', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'DD', 'origin': 'AA'}, ['Alex Fiction', '8 Fake Rd', 'Spraxham ZZ 15345', 'DD']], ['empty name line dropped', {'name': '', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'AA', 'origin': 'AA'}, ['8 Fake Rd', 'Spraxham ZZ 15345']], ['one-letter name kept', {'name': 'Q', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'AA', 'origin': 'AA'}, ['Q', '8 Fake Rd', 'Spraxham ZZ 15345']]]]
for label, arg, expected in fixtures[N - 1]:
    check(label, solve(arg), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
domestic three-part last line['Pat Example', '4 Fake Rd', 'Faketown ZZ 11345']['Pat Example', '4 Fake Rd', 'Faketown ZZ 11345']Passed
missing region collapses spacing['Pat Example', '4 Fake Rd', 'Faketown 11345']['Pat Example', '4 Fake Rd', 'Faketown 11345']Passed
only a postal code on the last line['Pat Example', '4 Fake Rd', ' 11345']['Pat Example', '4 Fake Rd', '11345']Failed
postal code first, international['Pat Example', '4 Fake Rd', '1234 Faketown', 'BEEMARK']['Pat Example', '4 Fake Rd', '1234 Faketown', 'BEEMARK']Passed
uppercase city on its own line['Pat Example', '4 Fake Rd', 'FAKETOWN', '11345', 'CEELAND']['Pat Example', '4 Fake Rd', 'FAKETOWN', '11345', 'CEELAND']Passed
unknown destination falls back['Pat Example', '4 Fake Rd', 'Faketown ZZ 11345', 'DD']['Pat Example', '4 Fake Rd', 'Faketown ZZ 11345', 'DD']Passed
empty name line dropped['4 Fake Rd', 'Faketown ZZ 11345']['4 Fake Rd', 'Faketown ZZ 11345']Passed
one-letter name kept['Q', '4 Fake Rd', 'Faketown ZZ 11345']['Q', '4 Fake Rd', 'Faketown ZZ 11345']Passed

SHA-256 / be703735581368b8f32c6e4f3a8a7ab9398b30f24cca2058cb3896a9b41e9b65

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    T = {'AA': ['{name}', '{street}', '{city} {region} {postal}'], 'BB': ['{name}', '{street}', '{postal} {city}'],
         'CC': ['{name}', '{street}', '{city}', '{postal}']}
    NAMES = {'AA': 'AALANDIA', 'BB': 'BEEMARK', 'CC': 'CEELAND'}
    dest = x['country']
    fields = dict(x)
    if dest == 'CC':
        fields['city'] = fields['city'].upper()
    lines = []
    for tpl in T.get(dest, T['AA']):
        line = ' '.join(tpl.format(**fields).split())
        if line:
            lines.append(line)
    if x['origin'] != dest:
        lines.append(NAMES.get(dest, dest))
    return lines
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['domestic three-part last line', {'name': 'Pat Example', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'AA', 'origin': 'AA'}, ['Pat Example', '4 Fake Rd', 'Faketown ZZ 11345']], ['missing region collapses spacing', {'name': 'Pat Example', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': '', 'postal': '11345', 'country': 'AA', 'origin': 'AA'}, ['Pat Example', '4 Fake Rd', 'Faketown 11345']], ['only a postal code on the last line', {'name': 'Pat Example', 'street': '4 Fake Rd', 'city': '', 'region': '', 'postal': '11345', 'country': 'AA', 'origin': 'AA'}, ['Pat Example', '4 Fake Rd', '11345']], ['postal code first, international', {'name': 'Pat Example', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': '', 'postal': '1234', 'country': 'BB', 'origin': 'AA'}, ['Pat Example', '4 Fake Rd', '1234 Faketown', 'BEEMARK']], ['uppercase city on its own line', {'name': 'Pat Example', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': '', 'postal': '11345', 'country': 'CC', 'origin': 'BB'}, ['Pat Example', '4 Fake Rd', 'FAKETOWN', '11345', 'CEELAND']], ['unknown destination falls back', {'name': 'Pat Example', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'DD', 'origin': 'AA'}, ['Pat Example', '4 Fake Rd', 'Faketown ZZ 11345', 'DD']], ['empty name line dropped', {'name': '', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'AA', 'origin': 'AA'}, ['4 Fake Rd', 'Faketown ZZ 11345']], ['one-letter name kept', {'name': 'Q', 'street': '4 Fake Rd', 'city': 'Faketown', 'region': 'ZZ', 'postal': '11345', 'country': 'AA', 'origin': 'AA'}, ['Q', '4 Fake Rd', 'Faketown ZZ 11345']]], [['domestic three-part last line', {'name': 'Lee Sample', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'AA', 'origin': 'AA'}, ['Lee Sample', '5 Fake Rd', 'Nowhereville ZZ 12345']], ['missing region collapses spacing', {'name': 'Lee Sample', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': '', 'postal': '12345', 'country': 'AA', 'origin': 'AA'}, ['Lee Sample', '5 Fake Rd', 'Nowhereville 12345']], ['only a postal code on the last line', {'name': 'Lee Sample', 'street': '5 Fake Rd', 'city': '', 'region': '', 'postal': '12345', 'country': 'AA', 'origin': 'AA'}, ['Lee Sample', '5 Fake Rd', '12345']], ['postal code first, international', {'name': 'Lee Sample', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': '', 'postal': '2234', 'country': 'BB', 'origin': 'AA'}, ['Lee Sample', '5 Fake Rd', '2234 Nowhereville', 'BEEMARK']], ['uppercase city on its own line', {'name': 'Lee Sample', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': '', 'postal': '12345', 'country': 'CC', 'origin': 'BB'}, ['Lee Sample', '5 Fake Rd', 'NOWHEREVILLE', '12345', 'CEELAND']], ['unknown destination falls back', {'name': 'Lee Sample', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'DD', 'origin': 'AA'}, ['Lee Sample', '5 Fake Rd', 'Nowhereville ZZ 12345', 'DD']], ['empty name line dropped', {'name': '', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'AA', 'origin': 'AA'}, ['5 Fake Rd', 'Nowhereville ZZ 12345']], ['one-letter name kept', {'name': 'Q', 'street': '5 Fake Rd', 'city': 'Nowhereville', 'region': 'ZZ', 'postal': '12345', 'country': 'AA', 'origin': 'AA'}, ['Q', '5 Fake Rd', 'Nowhereville ZZ 12345']]], [['domestic three-part last line', {'name': 'Robin Placeholder', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'AA', 'origin': 'AA'}, ['Robin Placeholder', '6 Fake Rd', 'Zorbleton ZZ 13345']], ['missing region collapses spacing', {'name': 'Robin Placeholder', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': '', 'postal': '13345', 'country': 'AA', 'origin': 'AA'}, ['Robin Placeholder', '6 Fake Rd', 'Zorbleton 13345']], ['only a postal code on the last line', {'name': 'Robin Placeholder', 'street': '6 Fake Rd', 'city': '', 'region': '', 'postal': '13345', 'country': 'AA', 'origin': 'AA'}, ['Robin Placeholder', '6 Fake Rd', '13345']], ['postal code first, international', {'name': 'Robin Placeholder', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': '', 'postal': '3234', 'country': 'BB', 'origin': 'AA'}, ['Robin Placeholder', '6 Fake Rd', '3234 Zorbleton', 'BEEMARK']], ['uppercase city on its own line', {'name': 'Robin Placeholder', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': '', 'postal': '13345', 'country': 'CC', 'origin': 'BB'}, ['Robin Placeholder', '6 Fake Rd', 'ZORBLETON', '13345', 'CEELAND']], ['unknown destination falls back', {'name': 'Robin Placeholder', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'DD', 'origin': 'AA'}, ['Robin Placeholder', '6 Fake Rd', 'Zorbleton ZZ 13345', 'DD']], ['empty name line dropped', {'name': '', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'AA', 'origin': 'AA'}, ['6 Fake Rd', 'Zorbleton ZZ 13345']], ['one-letter name kept', {'name': 'Q', 'street': '6 Fake Rd', 'city': 'Zorbleton', 'region': 'ZZ', 'postal': '13345', 'country': 'AA', 'origin': 'AA'}, ['Q', '6 Fake Rd', 'Zorbleton ZZ 13345']]], [['domestic three-part last line', {'name': 'Sam Demo', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'AA', 'origin': 'AA'}, ['Sam Demo', '7 Fake Rd', 'Quillby ZZ 14345']], ['missing region collapses spacing', {'name': 'Sam Demo', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': '', 'postal': '14345', 'country': 'AA', 'origin': 'AA'}, ['Sam Demo', '7 Fake Rd', 'Quillby 14345']], ['only a postal code on the last line', {'name': 'Sam Demo', 'street': '7 Fake Rd', 'city': '', 'region': '', 'postal': '14345', 'country': 'AA', 'origin': 'AA'}, ['Sam Demo', '7 Fake Rd', '14345']], ['postal code first, international', {'name': 'Sam Demo', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': '', 'postal': '4234', 'country': 'BB', 'origin': 'AA'}, ['Sam Demo', '7 Fake Rd', '4234 Quillby', 'BEEMARK']], ['uppercase city on its own line', {'name': 'Sam Demo', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': '', 'postal': '14345', 'country': 'CC', 'origin': 'BB'}, ['Sam Demo', '7 Fake Rd', 'QUILLBY', '14345', 'CEELAND']], ['unknown destination falls back', {'name': 'Sam Demo', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'DD', 'origin': 'AA'}, ['Sam Demo', '7 Fake Rd', 'Quillby ZZ 14345', 'DD']], ['empty name line dropped', {'name': '', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'AA', 'origin': 'AA'}, ['7 Fake Rd', 'Quillby ZZ 14345']], ['one-letter name kept', {'name': 'Q', 'street': '7 Fake Rd', 'city': 'Quillby', 'region': 'ZZ', 'postal': '14345', 'country': 'AA', 'origin': 'AA'}, ['Q', '7 Fake Rd', 'Quillby ZZ 14345']]], [['domestic three-part last line', {'name': 'Alex Fiction', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'AA', 'origin': 'AA'}, ['Alex Fiction', '8 Fake Rd', 'Spraxham ZZ 15345']], ['missing region collapses spacing', {'name': 'Alex Fiction', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': '', 'postal': '15345', 'country': 'AA', 'origin': 'AA'}, ['Alex Fiction', '8 Fake Rd', 'Spraxham 15345']], ['only a postal code on the last line', {'name': 'Alex Fiction', 'street': '8 Fake Rd', 'city': '', 'region': '', 'postal': '15345', 'country': 'AA', 'origin': 'AA'}, ['Alex Fiction', '8 Fake Rd', '15345']], ['postal code first, international', {'name': 'Alex Fiction', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': '', 'postal': '5234', 'country': 'BB', 'origin': 'AA'}, ['Alex Fiction', '8 Fake Rd', '5234 Spraxham', 'BEEMARK']], ['uppercase city on its own line', {'name': 'Alex Fiction', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': '', 'postal': '15345', 'country': 'CC', 'origin': 'BB'}, ['Alex Fiction', '8 Fake Rd', 'SPRAXHAM', '15345', 'CEELAND']], ['unknown destination falls back', {'name': 'Alex Fiction', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'DD', 'origin': 'AA'}, ['Alex Fiction', '8 Fake Rd', 'Spraxham ZZ 15345', 'DD']], ['empty name line dropped', {'name': '', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'AA', 'origin': 'AA'}, ['8 Fake Rd', 'Spraxham ZZ 15345']], ['one-letter name kept', {'name': 'Q', 'street': '8 Fake Rd', 'city': 'Spraxham', 'region': 'ZZ', 'postal': '15345', 'country': 'AA', 'origin': 'AA'}, ['Q', '8 Fake Rd', 'Spraxham ZZ 15345']]]]
for label, arg, expected in fixtures[N - 1]:
    check(label, solve(arg), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
domestic three-part last line['Pat Example', '4 Fake Rd', 'Faketown ZZ 11345']['Pat Example', '4 Fake Rd', 'Faketown ZZ 11345']Passed
missing region collapses spacing['Pat Example', '4 Fake Rd', 'Faketown 11345']['Pat Example', '4 Fake Rd', 'Faketown 11345']Passed
only a postal code on the last line['Pat Example', '4 Fake Rd', '11345']['Pat Example', '4 Fake Rd', '11345']Passed
postal code first, international['Pat Example', '4 Fake Rd', '1234 Faketown', 'BEEMARK']['Pat Example', '4 Fake Rd', '1234 Faketown', 'BEEMARK']Passed
uppercase city on its own line['Pat Example', '4 Fake Rd', 'FAKETOWN', '11345', 'CEELAND']['Pat Example', '4 Fake Rd', 'FAKETOWN', '11345', 'CEELAND']Passed
unknown destination falls back['Pat Example', '4 Fake Rd', 'Faketown ZZ 11345', 'DD']['Pat Example', '4 Fake Rd', 'Faketown ZZ 11345', 'DD']Passed
empty name line dropped['4 Fake Rd', 'Faketown ZZ 11345']['4 Fake Rd', 'Faketown ZZ 11345']Passed
one-letter name kept['Q', '4 Fake Rd', 'Faketown ZZ 11345']['Q', '4 Fake Rd', 'Faketown ZZ 11345']Passed

SHA-256 / b6029c54e1361dacd50cea9b7e90febebe40b79670b296ec3d59e60327ffee76

Verification & scope

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.

Observations recorded using Python 3.12.14 at 2026-09-29T14:52:20.896448+00:00.

Case digest / 3c257382676c86356b7556343423a0a82e3040db95e2fcdad1827298e7826ec5