FA-96486 / Phone number formatting / Open access
Display masking of subscriber digits: five trailing digits are shown · case 01
One extra digit is revealed.
ROOT CAUSE
The visibility test is seen >= total - 4.
VERIFIED REPAIR
Show a digit only when seen > total - 4.
Unsuccessful approach: Comparing with total - 3 reveals only three digits.
Case contract
Strip. A leading "+" and the digits right after it (the country code) are shown. Among the remaining digits only the last four are shown and the others become "*"; separators are kept. If four or fewer digits remain they are all masked.
Why this case matters
Masked numbers appear in receipts, logs and support tools; revealing too much leaks personal data and revealing too little makes verification impossible.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
s = x.strip()
cc_end = 0
if s.startswith('+'):
cc_end = 1
while cc_end < len(s) and s[cc_end].isdigit():
cc_end += 1
head, body = s[:cc_end], s[cc_end:]
total = sum(c.isdigit() for c in body)
if total <= 4:
return head + ''.join('*' if c.isdigit() else c for c in body)
seen, out = 0, []
for c in body:
if c.isdigit():
seen += 1
out.append(c if seen >= total - 4 else '*')
else:
out.append(c)
return head + ''.join(out)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['international with country code kept', '+42 555 010 1123', '+42 *** *** 1123'], ['three-digit code with hyphen', '+891 555-0114', '+891 ***-0114'], ['four subscriber digits are fully masked', '+8 1122', '+8 ****'], ['five subscriber digits', '+83 11123', '+83 *1123'], ['national number without code', '555 0115', '*** 0115'], ['parenthesized area', '+42 (555) 0112', '+42 (***) 0112'], ['hyphenated national number', '555-010-1122', '***-***-1122']], [['international with country code kept', '+42 555 010 1234', '+42 *** *** 1234'], ['three-digit code with hyphen', '+891 555-0125', '+891 ***-0125'], ['four subscriber digits are fully masked', '+8 2233', '+8 ****'], ['five subscriber digits', '+83 22234', '+83 *2234'], ['national number without code', '555 0126', '*** 0126'], ['parenthesized area', '+42 (555) 0123', '+42 (***) 0123'], ['hyphenated national number', '555-010-2233', '***-***-2233']], [['international with country code kept', '+42 555 010 1345', '+42 *** *** 1345'], ['three-digit code with hyphen', '+891 555-0136', '+891 ***-0136'], ['four subscriber digits are fully masked', '+8 3344', '+8 ****'], ['five subscriber digits', '+83 33345', '+83 *3345'], ['national number without code', '555 0137', '*** 0137'], ['parenthesized area', '+42 (555) 0134', '+42 (***) 0134'], ['hyphenated national number', '555-010-3344', '***-***-3344']], [['international with country code kept', '+42 555 010 1456', '+42 *** *** 1456'], ['three-digit code with hyphen', '+891 555-0147', '+891 ***-0147'], ['four subscriber digits are fully masked', '+8 4455', '+8 ****'], ['five subscriber digits', '+83 44456', '+83 *4456'], ['national number without code', '555 0148', '*** 0148'], ['parenthesized area', '+42 (555) 0145', '+42 (***) 0145'], ['hyphenated national number', '555-010-4455', '***-***-4455']], [['international with country code kept', '+42 555 010 1567', '+42 *** *** 1567'], ['three-digit code with hyphen', '+891 555-0158', '+891 ***-0158'], ['four subscriber digits are fully masked', '+8 5566', '+8 ****'], ['five subscriber digits', '+83 55567', '+83 *5567'], ['national number without code', '555 0159', '*** 0159'], ['parenthesized area', '+42 (555) 0156', '+42 (***) 0156'], ['hyphenated national number', '555-010-5566', '***-***-5566']]]
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 |
|---|---|---|---|
| international with country code kept | +42 *** **0 1123 | +42 *** *** 1123 | Failed |
| three-digit code with hyphen | +891 **5-0114 | +891 ***-0114 | Failed |
| four subscriber digits are fully masked | +8 **** | +8 **** | Passed |
| five subscriber digits | +83 11123 | +83 *1123 | Failed |
| national number without code | **5 0115 | *** 0115 | Failed |
| parenthesized area | +42 (**5) 0112 | +42 (***) 0112 | Failed |
| hyphenated national number | ***-**0-1122 | ***-***-1122 | Failed |
SHA-256 / ac3abd0e30b470fe04ef61c9e0387ba4cd4cbcbb7a3e4994e9cae1eea5dd9107
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
s = x.strip()
cc_end = 0
if s.startswith('+'):
cc_end = 1
while cc_end < len(s) and s[cc_end].isdigit():
cc_end += 1
head, body = s[:cc_end], s[cc_end:]
total = sum(c.isdigit() for c in body)
if total <= 4:
return head + ''.join('*' if c.isdigit() else c for c in body)
seen, out = 0, []
for c in body:
if c.isdigit():
seen += 1
out.append(c if seen > total - 3 else '*')
else:
out.append(c)
return head + ''.join(out)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['international with country code kept', '+42 555 010 1123', '+42 *** *** 1123'], ['three-digit code with hyphen', '+891 555-0114', '+891 ***-0114'], ['four subscriber digits are fully masked', '+8 1122', '+8 ****'], ['five subscriber digits', '+83 11123', '+83 *1123'], ['national number without code', '555 0115', '*** 0115'], ['parenthesized area', '+42 (555) 0112', '+42 (***) 0112'], ['hyphenated national number', '555-010-1122', '***-***-1122']], [['international with country code kept', '+42 555 010 1234', '+42 *** *** 1234'], ['three-digit code with hyphen', '+891 555-0125', '+891 ***-0125'], ['four subscriber digits are fully masked', '+8 2233', '+8 ****'], ['five subscriber digits', '+83 22234', '+83 *2234'], ['national number without code', '555 0126', '*** 0126'], ['parenthesized area', '+42 (555) 0123', '+42 (***) 0123'], ['hyphenated national number', '555-010-2233', '***-***-2233']], [['international with country code kept', '+42 555 010 1345', '+42 *** *** 1345'], ['three-digit code with hyphen', '+891 555-0136', '+891 ***-0136'], ['four subscriber digits are fully masked', '+8 3344', '+8 ****'], ['five subscriber digits', '+83 33345', '+83 *3345'], ['national number without code', '555 0137', '*** 0137'], ['parenthesized area', '+42 (555) 0134', '+42 (***) 0134'], ['hyphenated national number', '555-010-3344', '***-***-3344']], [['international with country code kept', '+42 555 010 1456', '+42 *** *** 1456'], ['three-digit code with hyphen', '+891 555-0147', '+891 ***-0147'], ['four subscriber digits are fully masked', '+8 4455', '+8 ****'], ['five subscriber digits', '+83 44456', '+83 *4456'], ['national number without code', '555 0148', '*** 0148'], ['parenthesized area', '+42 (555) 0145', '+42 (***) 0145'], ['hyphenated national number', '555-010-4455', '***-***-4455']], [['international with country code kept', '+42 555 010 1567', '+42 *** *** 1567'], ['three-digit code with hyphen', '+891 555-0158', '+891 ***-0158'], ['four subscriber digits are fully masked', '+8 5566', '+8 ****'], ['five subscriber digits', '+83 55567', '+83 *5567'], ['national number without code', '555 0159', '*** 0159'], ['parenthesized area', '+42 (555) 0156', '+42 (***) 0156'], ['hyphenated national number', '555-010-5566', '***-***-5566']]]
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 |
|---|---|---|---|
| international with country code kept | +42 *** *** *123 | +42 *** *** 1123 | Failed |
| three-digit code with hyphen | +891 ***-*114 | +891 ***-0114 | Failed |
| four subscriber digits are fully masked | +8 **** | +8 **** | Passed |
| five subscriber digits | +83 **123 | +83 *1123 | Failed |
| national number without code | *** *115 | *** 0115 | Failed |
| parenthesized area | +42 (***) *112 | +42 (***) 0112 | Failed |
| hyphenated national number | ***-***-*122 | ***-***-1122 | Failed |
SHA-256 / b3c35f0a489726232f8eb8ba29cdd12bab6c1f438d6a03ad231158ced249a991
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
s = x.strip()
cc_end = 0
if s.startswith('+'):
cc_end = 1
while cc_end < len(s) and s[cc_end].isdigit():
cc_end += 1
head, body = s[:cc_end], s[cc_end:]
total = sum(c.isdigit() for c in body)
if total <= 4:
return head + ''.join('*' if c.isdigit() else c for c in body)
seen, out = 0, []
for c in body:
if c.isdigit():
seen += 1
out.append(c if seen > total - 4 else '*')
else:
out.append(c)
return head + ''.join(out)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['international with country code kept', '+42 555 010 1123', '+42 *** *** 1123'], ['three-digit code with hyphen', '+891 555-0114', '+891 ***-0114'], ['four subscriber digits are fully masked', '+8 1122', '+8 ****'], ['five subscriber digits', '+83 11123', '+83 *1123'], ['national number without code', '555 0115', '*** 0115'], ['parenthesized area', '+42 (555) 0112', '+42 (***) 0112'], ['hyphenated national number', '555-010-1122', '***-***-1122']], [['international with country code kept', '+42 555 010 1234', '+42 *** *** 1234'], ['three-digit code with hyphen', '+891 555-0125', '+891 ***-0125'], ['four subscriber digits are fully masked', '+8 2233', '+8 ****'], ['five subscriber digits', '+83 22234', '+83 *2234'], ['national number without code', '555 0126', '*** 0126'], ['parenthesized area', '+42 (555) 0123', '+42 (***) 0123'], ['hyphenated national number', '555-010-2233', '***-***-2233']], [['international with country code kept', '+42 555 010 1345', '+42 *** *** 1345'], ['three-digit code with hyphen', '+891 555-0136', '+891 ***-0136'], ['four subscriber digits are fully masked', '+8 3344', '+8 ****'], ['five subscriber digits', '+83 33345', '+83 *3345'], ['national number without code', '555 0137', '*** 0137'], ['parenthesized area', '+42 (555) 0134', '+42 (***) 0134'], ['hyphenated national number', '555-010-3344', '***-***-3344']], [['international with country code kept', '+42 555 010 1456', '+42 *** *** 1456'], ['three-digit code with hyphen', '+891 555-0147', '+891 ***-0147'], ['four subscriber digits are fully masked', '+8 4455', '+8 ****'], ['five subscriber digits', '+83 44456', '+83 *4456'], ['national number without code', '555 0148', '*** 0148'], ['parenthesized area', '+42 (555) 0145', '+42 (***) 0145'], ['hyphenated national number', '555-010-4455', '***-***-4455']], [['international with country code kept', '+42 555 010 1567', '+42 *** *** 1567'], ['three-digit code with hyphen', '+891 555-0158', '+891 ***-0158'], ['four subscriber digits are fully masked', '+8 5566', '+8 ****'], ['five subscriber digits', '+83 55567', '+83 *5567'], ['national number without code', '555 0159', '*** 0159'], ['parenthesized area', '+42 (555) 0156', '+42 (***) 0156'], ['hyphenated national number', '555-010-5566', '***-***-5566']]]
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 |
|---|---|---|---|
| international with country code kept | +42 *** *** 1123 | +42 *** *** 1123 | Passed |
| three-digit code with hyphen | +891 ***-0114 | +891 ***-0114 | Passed |
| four subscriber digits are fully masked | +8 **** | +8 **** | Passed |
| five subscriber digits | +83 *1123 | +83 *1123 | Passed |
| national number without code | *** 0115 | *** 0115 | Passed |
| parenthesized area | +42 (***) 0112 | +42 (***) 0112 | Passed |
| hyphenated national number | ***-***-1122 | ***-***-1122 | Passed |
SHA-256 / f8332f5b881a35f77f502d796816059ee631605638760dc1e3a779d9558f24c4
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:23.161104+00:00.
Case digest / 8d2ef99a2cc505df836e24e11f5bf5e5fdaa31a54a3c17eac5e68d9b6c610ece