FAILURE MAP
← Case archive

FA-47771 / Delimited text / Open access

Identifier-looking zero-padded cells infer an integer column · case 01

A structured table violates the declared record or column contract.

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

ROOT CAUSE

Numeric recognition discards canonical spelling and leading zeros.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: and value == str(int(value))

Unsuccessful approach: Checking only a positive leading zero still coerces negative zero.

Case contract

Infer per-column wire types from already lexed two-column rows. Unquoted empty and NULL cells supply no evidence; quoted cells force text. Unquoted lowercase true/false are bool; canonical signed decimal integers without leading zeros are int; all other cells text. Mixed non-null kinds promote to text; a column with no evidence is unknown.

Why this case matters

Delimited interchange needs explicit framing, schema and field semantics at ingestion and emission boundaries.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    evidence = [set(), set()]
    for row in data:
        for i, (value, quoted) in enumerate(row):
            if not quoted and value in ('', 'NULL'): continue
            if quoted: kind = 'text'
            elif value in ('true', 'false'): kind = 'bool'
            elif value.lstrip('-').isascii() and value.lstrip('-').isdigit() : kind = 'int'
            else: kind = 'text'
            evidence[i].add(kind)
    return [next(iter(kinds)) if len(kinds) == 1 else 'text' if kinds else 'unknown' for kinds in evidence]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('typed', solve(_vary([[['12', False], ['true', False]], [['-2', False], ['false', False]]])), _vary(['int', 'bool']))
check('quoted number', solve(_vary([[['12', True], ['@', False]]])), _vary(['text', 'text']))
check('null only', solve(_vary([[['NULL', False], ['', False]]])), _vary(['unknown', 'unknown']))
check('quoted empty', solve(_vary([[['', True], ['NULL', True]]])), _vary(['text', 'text']))
check('leading zero', solve(_vary([[['01', False], ['-0', False]]])), _vary(['text', 'text']))
check('mixed', solve(_vary([[['1', False], ['true', False]], [['@', False], ['2', False]]])), _vary(['text', 'text']))
check('null ignored', solve(_vary([[['NULL', False], ['', False]], [['1', False], ['false', False]]])), _vary(['int', 'bool']))
check('empty table', solve(_vary([])), _vary(['unknown', 'unknown']))
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
typed['int', 'bool']['int', 'bool']Passed
quoted number['text', 'text']['text', 'text']Passed
null only['unknown', 'unknown']['unknown', 'unknown']Passed
quoted empty['text', 'text']['text', 'text']Passed
leading zero['int', 'int']['text', 'text']Failed
mixed['text', 'text']['text', 'text']Passed
null ignored['int', 'bool']['int', 'bool']Passed
empty table['unknown', 'unknown']['unknown', 'unknown']Passed

SHA-256 / d4f350d17ea21b0f670e9b7ee3ecdec397c9b9a92390c871b6e47fe9b71abce7

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    evidence = [set(), set()]
    for row in data:
        for i, (value, quoted) in enumerate(row):
            if not quoted and value in ('', 'NULL'): continue
            if quoted: kind = 'text'
            elif value in ('true', 'false'): kind = 'bool'
            elif value.lstrip('-').isascii() and value.lstrip('-').isdigit() and not value.startswith('0'): kind = 'int'
            else: kind = 'text'
            evidence[i].add(kind)
    return [next(iter(kinds)) if len(kinds) == 1 else 'text' if kinds else 'unknown' for kinds in evidence]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('typed', solve(_vary([[['12', False], ['true', False]], [['-2', False], ['false', False]]])), _vary(['int', 'bool']))
check('quoted number', solve(_vary([[['12', True], ['@', False]]])), _vary(['text', 'text']))
check('null only', solve(_vary([[['NULL', False], ['', False]]])), _vary(['unknown', 'unknown']))
check('quoted empty', solve(_vary([[['', True], ['NULL', True]]])), _vary(['text', 'text']))
check('leading zero', solve(_vary([[['01', False], ['-0', False]]])), _vary(['text', 'text']))
check('mixed', solve(_vary([[['1', False], ['true', False]], [['@', False], ['2', False]]])), _vary(['text', 'text']))
check('null ignored', solve(_vary([[['NULL', False], ['', False]], [['1', False], ['false', False]]])), _vary(['int', 'bool']))
check('empty table', solve(_vary([])), _vary(['unknown', 'unknown']))
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
typed['int', 'bool']['int', 'bool']Passed
quoted number['text', 'text']['text', 'text']Passed
null only['unknown', 'unknown']['unknown', 'unknown']Passed
quoted empty['text', 'text']['text', 'text']Passed
leading zero['text', 'int']['text', 'text']Failed
mixed['text', 'text']['text', 'text']Passed
null ignored['int', 'bool']['int', 'bool']Passed
empty table['unknown', 'unknown']['unknown', 'unknown']Passed

SHA-256 / 3b917eeb252dd8e52b499dfbddc9ce1cffc84feb2f9a8a064e4191ae9a801ca8

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    evidence = [set(), set()]
    for row in data:
        for i, (value, quoted) in enumerate(row):
            if not quoted and value in ('', 'NULL'): continue
            if quoted: kind = 'text'
            elif value in ('true', 'false'): kind = 'bool'
            elif value.lstrip('-').isascii() and value.lstrip('-').isdigit() and value == str(int(value)): kind = 'int'
            else: kind = 'text'
            evidence[i].add(kind)
    return [next(iter(kinds)) if len(kinds) == 1 else 'text' if kinds else 'unknown' for kinds in evidence]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('typed', solve(_vary([[['12', False], ['true', False]], [['-2', False], ['false', False]]])), _vary(['int', 'bool']))
check('quoted number', solve(_vary([[['12', True], ['@', False]]])), _vary(['text', 'text']))
check('null only', solve(_vary([[['NULL', False], ['', False]]])), _vary(['unknown', 'unknown']))
check('quoted empty', solve(_vary([[['', True], ['NULL', True]]])), _vary(['text', 'text']))
check('leading zero', solve(_vary([[['01', False], ['-0', False]]])), _vary(['text', 'text']))
check('mixed', solve(_vary([[['1', False], ['true', False]], [['@', False], ['2', False]]])), _vary(['text', 'text']))
check('null ignored', solve(_vary([[['NULL', False], ['', False]], [['1', False], ['false', False]]])), _vary(['int', 'bool']))
check('empty table', solve(_vary([])), _vary(['unknown', 'unknown']))
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
typed['int', 'bool']['int', 'bool']Passed
quoted number['text', 'text']['text', 'text']Passed
null only['unknown', 'unknown']['unknown', 'unknown']Passed
quoted empty['text', 'text']['text', 'text']Passed
leading zero['text', 'text']['text', 'text']Passed
mixed['text', 'text']['text', 'text']Passed
null ignored['int', 'bool']['int', 'bool']Passed
empty table['unknown', 'unknown']['unknown', 'unknown']Passed

SHA-256 / ff76d7e2cb78e5fc37c9122b58bf52c46aa8a0f466da8026d55e34fe1265ce64

Verification & scope

Deterministic bounded in-memory model. No claim of complete CSV or external format conformance. 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:44:44.682764+00:00.

Case digest / 1132ba88bac1e3a4a492c5fa9a0a09551fc2b0806857da2d30f6a7532440b9b1