FA-181 / Protocols / Open access
A character count truncates a UTF-8 frame · case 01
The declared payload length is smaller than the actual UTF-8 payload for non-ASCII text.
ROOT CAUSE
A protocol byte count is calculated from Unicode characters rather than the encoded payload.
VERIFIED REPAIR
Encode once to UTF-8 and prefix the length of the encoded bytes.
Unsuccessful approach: Counting UTF-16 code units still does not measure UTF-8 payload bytes.
Case contract
Return the hexadecimal representation of an ASCII decimal byte-length prefix, a colon, then the UTF-8 payload. The prefix excludes its own bytes and the colon.
Why this case matters
Length-prefixed protocols operate on bytes. Unicode code points and UTF-16 units match byte counts for some fixtures, making ASCII-only tests insufficient.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(text):
return (str(len(text)).encode('ascii') + b':' + text.encode('utf-8')).hex()
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ASCII length', solve('x' * N), (str(N).encode() + b':' + b'x' * N).hex())
check('two-byte code point', solve('é' * N), (str(2 * N).encode() + b':' + b'\xc3\xa9' * N).hex())
check('four-byte code point', solve('🙂' * N), (str(4 * N).encode() + b':' + b'\xf0\x9f\x99\x82' * N).hex())
check('combining mark remains separate', solve('e\u0301' * N), (str(3 * N).encode() + b':' + b'e\xcc\x81' * N).hex())
check('mixed encoding widths', solve('A界' * N), (str(4 * N).encode() + b':' + b'A\xe7\x95\x8c' * N).hex())
check('empty payload', solve(''), '303a')
check('delimiter inside payload', solve(':' * N), (str(N).encode() + b':' + b':' * N).hex())
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 |
|---|---|---|---|
| ASCII length | 313a78 | 313a78 | Passed |
| two-byte code point | 313ac3a9 | 323ac3a9 | Failed |
| four-byte code point | 313af09f9982 | 343af09f9982 | Failed |
| combining mark remains separate | 323a65cc81 | 333a65cc81 | Failed |
| mixed encoding widths | 323a41e7958c | 343a41e7958c | Failed |
| empty payload | 303a | 303a | Passed |
| delimiter inside payload | 313a3a | 313a3a | Passed |
SHA-256 / 3ff8d5519ba47fb21760914b1684da866c42289365f73a6fdf0400396bd4e281
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(text):
return (str(len(text.encode('utf-16-le')) // 2).encode('ascii') + b':' + text.encode('utf-8')).hex()
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ASCII length', solve('x' * N), (str(N).encode() + b':' + b'x' * N).hex())
check('two-byte code point', solve('é' * N), (str(2 * N).encode() + b':' + b'\xc3\xa9' * N).hex())
check('four-byte code point', solve('🙂' * N), (str(4 * N).encode() + b':' + b'\xf0\x9f\x99\x82' * N).hex())
check('combining mark remains separate', solve('e\u0301' * N), (str(3 * N).encode() + b':' + b'e\xcc\x81' * N).hex())
check('mixed encoding widths', solve('A界' * N), (str(4 * N).encode() + b':' + b'A\xe7\x95\x8c' * N).hex())
check('empty payload', solve(''), '303a')
check('delimiter inside payload', solve(':' * N), (str(N).encode() + b':' + b':' * N).hex())
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 |
|---|---|---|---|
| ASCII length | 313a78 | 313a78 | Passed |
| two-byte code point | 313ac3a9 | 323ac3a9 | Failed |
| four-byte code point | 323af09f9982 | 343af09f9982 | Failed |
| combining mark remains separate | 323a65cc81 | 333a65cc81 | Failed |
| mixed encoding widths | 323a41e7958c | 343a41e7958c | Failed |
| empty payload | 303a | 303a | Passed |
| delimiter inside payload | 313a3a | 313a3a | Passed |
SHA-256 / 58a2a6a7bf0be2f0f74466ec4bda0a13e4d99c99fbe9d74c3703d9161bba1028
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(text):
payload = text.encode('utf-8')
return (str(len(payload)).encode('ascii') + b':' + payload).hex()
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ASCII length', solve('x' * N), (str(N).encode() + b':' + b'x' * N).hex())
check('two-byte code point', solve('é' * N), (str(2 * N).encode() + b':' + b'\xc3\xa9' * N).hex())
check('four-byte code point', solve('🙂' * N), (str(4 * N).encode() + b':' + b'\xf0\x9f\x99\x82' * N).hex())
check('combining mark remains separate', solve('e\u0301' * N), (str(3 * N).encode() + b':' + b'e\xcc\x81' * N).hex())
check('mixed encoding widths', solve('A界' * N), (str(4 * N).encode() + b':' + b'A\xe7\x95\x8c' * N).hex())
check('empty payload', solve(''), '303a')
check('delimiter inside payload', solve(':' * N), (str(N).encode() + b':' + b':' * N).hex())
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 |
|---|---|---|---|
| ASCII length | 313a78 | 313a78 | Passed |
| two-byte code point | 323ac3a9 | 323ac3a9 | Passed |
| four-byte code point | 343af09f9982 | 343af09f9982 | Passed |
| combining mark remains separate | 333a65cc81 | 333a65cc81 | Passed |
| mixed encoding widths | 343a41e7958c | 343a41e7958c | Passed |
| empty payload | 303a | 303a | Passed |
| delimiter inside payload | 313a3a | 313a3a | Passed |
SHA-256 / d704e9c3120f56f4c8c7d56b3463be04bd16f47cc3a0149761f775f63f34e370
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:36:51.018177+00:00.
Case digest / f6b2f977625fa55b2bfc8cfcd3179516066be288bf6ba0661479d8b515ee6c14