FAILURE MAP
← Case archive

FA-47766 / Delimited text / Open access

A quoted number drives numeric schema inference · 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

Type inference forgets a lexically quoted literal is textual evidence.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: if quoted: kind = 'text'

Unsuccessful approach: Protecting only quoted empty strings misses quoted numbers.

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 False: 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['int', 'text']['text', 'text']Failed
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 / e4e2596528255064e97f3454780540f8f80ae9139725d95352cab3582a484f73

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 and not value: 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['int', 'text']['text', 'text']Failed
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 / 79c8ae9dc5edf4ec8f9d22a37705d3805dcd7a19a53660fdf78993cf8e3e0555

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

Case digest / 86e37f9d17071a9ef4dcf2907e1acdaf06687f1d4ae7878834d1cf034fbb285c