FAILURE MAP
← Case archive

FA-96716 / Phone number formatting / Open access

Emergency and service code classifier: short digit strings are service codes · case 01

"11" is classified as a service code.

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

ROOT CAUSE

The service rule accepts any length up to svc_len.

THE FAILURE

The service rule accepts any length up to svc_len.

Unsuccessful approach: Accepting svc_len or more digits turns longer numbers into service codes.

Case contract

Input [dialed, country] with toy tables AA (emergency 133/144, service = 4 digits starting 1, trunk 0, 9 national digits) and BB (emergency 755, service = 3 digits starting 7, no trunk, 7 national digits). Remove spaces; strip any number of leading "*NN" feature codes into tags. The rest must be digits. Classify in order: exact emergency code, service code, then a national number (trunk required and removed when the country has one). Return tags + [class].

Why this case matters

Emergency and short service codes must be recognized before any national formatting, or emergency calls are rewritten or blocked.

1 / The failure

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

N = 1
observations = []
def solve(x):
    s, country = x
    T = {'AA': {'emergency': ('133', '144'), 'svc': '1', 'svc_len': 4, 'trunk': '0', 'nsn': 9},
         'BB': {'emergency': ('755',), 'svc': '7', 'svc_len': 3, 'trunk': '', 'nsn': 7}}
    c = T[country]
    tags = []
    s = s.replace(' ', '')
    while s.startswith('*') and len(s) >= 3 and s[1:3].isdigit():
        tags.append('feature:' + s[1:3])
        s = s[3:]
    if not s.isdigit():
        return tags + ['invalid']
    if s in c['emergency']:
        return tags + ['emergency']
    if s.startswith(c['svc']) and len(s) <= c['svc_len']:
        return tags + ['service']
    if c['trunk'] and s.startswith(c['trunk']):
        s = s[len(c['trunk']):]
    elif c['trunk']:
        return tags + ['invalid']
    return tags + (['national'] if len(s) == c['nsn'] else ['invalid'])
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['emergency code', ['133', 'AA'], ['emergency']], ['emergency code inside the service range', ['755', 'BB'], ['emergency']], ['feature code before emergency code', ['*67 755', 'BB'], ['feature:67', 'emergency']], ['service code sharing the emergency prefix', ['1331', 'AA'], ['service']], ['trunk before an emergency code', ['0133', 'AA'], ['invalid']], ['two feature codes', ['*67*82 0555010111', 'AA'], ['feature:67', 'feature:82', 'national']], ['national number without trunk', ['555010111', 'AA'], ['invalid']], ['too short for a service code', ['11', 'AA'], ['invalid']], ['too long for a service code', ['11111', 'AA'], ['invalid']], ['hash inside a number', ['5550#11', 'BB'], ['invalid']], ['BB national number', ['555 0111', 'BB'], ['national']], ['BB service code', ['712', 'BB'], ['service']]], [['emergency code', ['133', 'AA'], ['emergency']], ['emergency code inside the service range', ['755', 'BB'], ['emergency']], ['feature code before emergency code', ['*67 755', 'BB'], ['feature:67', 'emergency']], ['service code sharing the emergency prefix', ['1332', 'AA'], ['service']], ['trunk before an emergency code', ['0133', 'AA'], ['invalid']], ['two feature codes', ['*67*82 0555010222', 'AA'], ['feature:67', 'feature:82', 'national']], ['national number without trunk', ['555010222', 'AA'], ['invalid']], ['too short for a service code', ['12', 'AA'], ['invalid']], ['too long for a service code', ['12222', 'AA'], ['invalid']], ['hash inside a number', ['5550#12', 'BB'], ['invalid']], ['BB national number', ['555 0122', 'BB'], ['national']], ['BB service code', ['723', 'BB'], ['service']]], [['emergency code', ['133', 'AA'], ['emergency']], ['emergency code inside the service range', ['755', 'BB'], ['emergency']], ['feature code before emergency code', ['*67 755', 'BB'], ['feature:67', 'emergency']], ['service code sharing the emergency prefix', ['1333', 'AA'], ['service']], ['trunk before an emergency code', ['0133', 'AA'], ['invalid']], ['two feature codes', ['*67*82 0555010333', 'AA'], ['feature:67', 'feature:82', 'national']], ['national number without trunk', ['555010333', 'AA'], ['invalid']], ['too short for a service code', ['13', 'AA'], ['invalid']], ['too long for a service code', ['13333', 'AA'], ['invalid']], ['hash inside a number', ['5550#13', 'BB'], ['invalid']], ['BB national number', ['555 0133', 'BB'], ['national']], ['BB service code', ['734', 'BB'], ['service']]], [['emergency code', ['133', 'AA'], ['emergency']], ['emergency code inside the service range', ['755', 'BB'], ['emergency']], ['feature code before emergency code', ['*67 755', 'BB'], ['feature:67', 'emergency']], ['service code sharing the emergency prefix', ['1334', 'AA'], ['service']], ['trunk before an emergency code', ['0133', 'AA'], ['invalid']], ['two feature codes', ['*67*82 0555010444', 'AA'], ['feature:67', 'feature:82', 'national']], ['national number without trunk', ['555010444', 'AA'], ['invalid']], ['too short for a service code', ['14', 'AA'], ['invalid']], ['too long for a service code', ['14444', 'AA'], ['invalid']], ['hash inside a number', ['5550#14', 'BB'], ['invalid']], ['BB national number', ['555 0144', 'BB'], ['national']], ['BB service code', ['745', 'BB'], ['service']]], [['emergency code', ['133', 'AA'], ['emergency']], ['emergency code inside the service range', ['755', 'BB'], ['emergency']], ['feature code before emergency code', ['*67 755', 'BB'], ['feature:67', 'emergency']], ['service code sharing the emergency prefix', ['1335', 'AA'], ['service']], ['trunk before an emergency code', ['0133', 'AA'], ['invalid']], ['two feature codes', ['*67*82 0555010555', 'AA'], ['feature:67', 'feature:82', 'national']], ['national number without trunk', ['555010555', 'AA'], ['invalid']], ['too short for a service code', ['15', 'AA'], ['invalid']], ['too long for a service code', ['15555', 'AA'], ['invalid']], ['hash inside a number', ['5550#15', 'BB'], ['invalid']], ['BB national number', ['555 0155', 'BB'], ['national']], ['BB service code', ['756', 'BB'], ['service']]]]
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
emergency code['emergency']['emergency']Passed
emergency code inside the service range['emergency']['emergency']Passed
feature code before emergency code['feature:67', 'emergency']['feature:67', 'emergency']Passed
service code sharing the emergency prefix['service']['service']Passed
trunk before an emergency code['invalid']['invalid']Passed
two feature codes['feature:67', 'feature:82', 'national']['feature:67', 'feature:82', 'national']Passed
national number without trunk['invalid']['invalid']Passed
too short for a service code['service']['invalid']Failed
too long for a service code['invalid']['invalid']Passed
hash inside a number['invalid']['invalid']Passed
BB national number['national']['national']Passed
BB service code['service']['service']Passed

SHA-256 / 40544b06868d49b10e89b599bb538de89be4cda95c5ed28422866b231380d06d

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    s, country = x
    T = {'AA': {'emergency': ('133', '144'), 'svc': '1', 'svc_len': 4, 'trunk': '0', 'nsn': 9},
         'BB': {'emergency': ('755',), 'svc': '7', 'svc_len': 3, 'trunk': '', 'nsn': 7}}
    c = T[country]
    tags = []
    s = s.replace(' ', '')
    while s.startswith('*') and len(s) >= 3 and s[1:3].isdigit():
        tags.append('feature:' + s[1:3])
        s = s[3:]
    if not s.isdigit():
        return tags + ['invalid']
    if s in c['emergency']:
        return tags + ['emergency']
    if s.startswith(c['svc']) and len(s) >= c['svc_len']:
        return tags + ['service']
    if c['trunk'] and s.startswith(c['trunk']):
        s = s[len(c['trunk']):]
    elif c['trunk']:
        return tags + ['invalid']
    return tags + (['national'] if len(s) == c['nsn'] else ['invalid'])
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['emergency code', ['133', 'AA'], ['emergency']], ['emergency code inside the service range', ['755', 'BB'], ['emergency']], ['feature code before emergency code', ['*67 755', 'BB'], ['feature:67', 'emergency']], ['service code sharing the emergency prefix', ['1331', 'AA'], ['service']], ['trunk before an emergency code', ['0133', 'AA'], ['invalid']], ['two feature codes', ['*67*82 0555010111', 'AA'], ['feature:67', 'feature:82', 'national']], ['national number without trunk', ['555010111', 'AA'], ['invalid']], ['too short for a service code', ['11', 'AA'], ['invalid']], ['too long for a service code', ['11111', 'AA'], ['invalid']], ['hash inside a number', ['5550#11', 'BB'], ['invalid']], ['BB national number', ['555 0111', 'BB'], ['national']], ['BB service code', ['712', 'BB'], ['service']]], [['emergency code', ['133', 'AA'], ['emergency']], ['emergency code inside the service range', ['755', 'BB'], ['emergency']], ['feature code before emergency code', ['*67 755', 'BB'], ['feature:67', 'emergency']], ['service code sharing the emergency prefix', ['1332', 'AA'], ['service']], ['trunk before an emergency code', ['0133', 'AA'], ['invalid']], ['two feature codes', ['*67*82 0555010222', 'AA'], ['feature:67', 'feature:82', 'national']], ['national number without trunk', ['555010222', 'AA'], ['invalid']], ['too short for a service code', ['12', 'AA'], ['invalid']], ['too long for a service code', ['12222', 'AA'], ['invalid']], ['hash inside a number', ['5550#12', 'BB'], ['invalid']], ['BB national number', ['555 0122', 'BB'], ['national']], ['BB service code', ['723', 'BB'], ['service']]], [['emergency code', ['133', 'AA'], ['emergency']], ['emergency code inside the service range', ['755', 'BB'], ['emergency']], ['feature code before emergency code', ['*67 755', 'BB'], ['feature:67', 'emergency']], ['service code sharing the emergency prefix', ['1333', 'AA'], ['service']], ['trunk before an emergency code', ['0133', 'AA'], ['invalid']], ['two feature codes', ['*67*82 0555010333', 'AA'], ['feature:67', 'feature:82', 'national']], ['national number without trunk', ['555010333', 'AA'], ['invalid']], ['too short for a service code', ['13', 'AA'], ['invalid']], ['too long for a service code', ['13333', 'AA'], ['invalid']], ['hash inside a number', ['5550#13', 'BB'], ['invalid']], ['BB national number', ['555 0133', 'BB'], ['national']], ['BB service code', ['734', 'BB'], ['service']]], [['emergency code', ['133', 'AA'], ['emergency']], ['emergency code inside the service range', ['755', 'BB'], ['emergency']], ['feature code before emergency code', ['*67 755', 'BB'], ['feature:67', 'emergency']], ['service code sharing the emergency prefix', ['1334', 'AA'], ['service']], ['trunk before an emergency code', ['0133', 'AA'], ['invalid']], ['two feature codes', ['*67*82 0555010444', 'AA'], ['feature:67', 'feature:82', 'national']], ['national number without trunk', ['555010444', 'AA'], ['invalid']], ['too short for a service code', ['14', 'AA'], ['invalid']], ['too long for a service code', ['14444', 'AA'], ['invalid']], ['hash inside a number', ['5550#14', 'BB'], ['invalid']], ['BB national number', ['555 0144', 'BB'], ['national']], ['BB service code', ['745', 'BB'], ['service']]], [['emergency code', ['133', 'AA'], ['emergency']], ['emergency code inside the service range', ['755', 'BB'], ['emergency']], ['feature code before emergency code', ['*67 755', 'BB'], ['feature:67', 'emergency']], ['service code sharing the emergency prefix', ['1335', 'AA'], ['service']], ['trunk before an emergency code', ['0133', 'AA'], ['invalid']], ['two feature codes', ['*67*82 0555010555', 'AA'], ['feature:67', 'feature:82', 'national']], ['national number without trunk', ['555010555', 'AA'], ['invalid']], ['too short for a service code', ['15', 'AA'], ['invalid']], ['too long for a service code', ['15555', 'AA'], ['invalid']], ['hash inside a number', ['5550#15', 'BB'], ['invalid']], ['BB national number', ['555 0155', 'BB'], ['national']], ['BB service code', ['756', 'BB'], ['service']]]]
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
emergency code['emergency']['emergency']Passed
emergency code inside the service range['emergency']['emergency']Passed
feature code before emergency code['feature:67', 'emergency']['feature:67', 'emergency']Passed
service code sharing the emergency prefix['service']['service']Passed
trunk before an emergency code['invalid']['invalid']Passed
two feature codes['feature:67', 'feature:82', 'national']['feature:67', 'feature:82', 'national']Passed
national number without trunk['invalid']['invalid']Passed
too short for a service code['invalid']['invalid']Passed
too long for a service code['service']['invalid']Failed
hash inside a number['invalid']['invalid']Passed
BB national number['national']['national']Passed
BB service code['service']['service']Passed

SHA-256 / 47bac88ae480598aafa3edbfaa8c594b52e75059500008a35ca8b4ef5a28ddf9

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 12 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

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.

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

Case digest / 8a61a8a7bd00911fc16a3aa2732e5d5e1569af9672d57c8cfdb5fbf1384d3206