FAILURE MAP
← Case archive

FA-3876 / Tokenization / Open access

A prefix tokenizer chooses the first rather than longest keyword · case 01

A prefix tokenizer chooses the first rather than longest keyword.

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

ROOT CAUSE

The implementation applies an operation whose text or grammar semantics violate this contract: Return longest prefix among in, int, integer, or None.

VERIFIED REPAIR

Implement the complete stated contract, including the boundary fixtures: Return longest prefix among in, int, integer, or None.

Unsuccessful approach: The attempted repair handles the primary example but still violates a separate boundary of the same contract.

Case contract

Return longest prefix among in, int, integer, or None.

Why this case matters

A local executable model for consumers of structured text; oracle values are authored literals, not outputs copied from the repaired implementation.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return next((p for p in ('in','int','integer') if x.startswith(p)),None)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('integerx'), 'integer')
check('boundary 2', solve('int32'), 'int')
check('boundary 3', solve('inside'), 'in')
check('boundary 4', solve('else'), None)
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
boundary 1inintegerFailed
boundary 2inintFailed
boundary 3ininPassed
boundary 4NoneNonePassed

SHA-256 / bbf2bf397ec41014d5d808fb7c1593468dbaadf443ac003275aa503527e63b42

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return next((p for p in ('int','in','integer') if x.startswith(p)),None)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('integerx'), 'integer')
check('boundary 2', solve('int32'), 'int')
check('boundary 3', solve('inside'), 'in')
check('boundary 4', solve('else'), None)
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
boundary 1intintegerFailed
boundary 2intintPassed
boundary 3ininPassed
boundary 4NoneNonePassed

SHA-256 / d15622809702d28bf874cbb7826bd5419a68c1f33126657e7e500bb38968f9ac

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return next((p for p in ('integer','int','in') if x.startswith(p)),None)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('integerx'), 'integer')
check('boundary 2', solve('int32'), 'int')
check('boundary 3', solve('inside'), 'in')
check('boundary 4', solve('else'), None)
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
boundary 1integerintegerPassed
boundary 2intintPassed
boundary 3ininPassed
boundary 4NoneNonePassed

SHA-256 / 20954c9586fc6b65c11675d3c65767a5e63472191183ac2964a5c7a0f31506ca

Verification & scope

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:37:32.189325+00:00.

Case digest / d2ee6c3873ab9123a3548e674f175d2d9f7a4fb6831cf0a31f25b5c364fc6a77