FA-96711 / Phone number formatting / Open access
Emergency and service code classifier: national numbers without the trunk are accepted · case 01
A nine-digit AA number without its leading 0 is classified national.
ROOT CAUSE
The rejection for missing trunk is absent.
THE FAILURE
The rejection for missing trunk is absent.
Unsuccessful approach: Rejecting only when the length is also wrong still accepts a nine-digit number without trunk.
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']):]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| 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 | ['national'] | ['invalid'] | Failed |
| too short for a service code | ['invalid'] | ['invalid'] | Passed |
| 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 / 1359c1d09e37e2803916131d58279ab08d22504ed38aa0d9889d97b48215fb4e
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'] and len(s) != c['nsn']:
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| 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 | ['national'] | ['invalid'] | Failed |
| too short for a service code | ['invalid'] | ['invalid'] | Passed |
| 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 / d3c60767fd8513c0c8c68ce604c4a52bcb2cf510b0d532c8a9fa78532390300a
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 / 89258d16c138955e63b566956e695bdb21d0106252c1f6561ec3ba2b296b3d9a