FAILURE MAP
← Case archive

FA-48301 / Delimited text / Open access

Consuming a row decreases a counted block by two · 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

Consuming a row decreases a counted block by two.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: remaining-=1

Unsuccessful approach: The alternate implementation still violates the same declared invariant: consuming a row decreases a counted block by two.

Case contract

Decode pipe records arranged as C|count followed by exactly count R|value rows. Multiple blocks may follow. Counts are ASCII nonnegative decimals; values contain no pipe in this bounded grammar. Empty blocks are emitted as empty lists. Missing, unexpected, and surplus R records reject.

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):
    blocks=[]; current=None; remaining=0
    for line in data:
        cells=line.split('|')
        if len(cells)!=2: return None
        tag,value=cells
        if tag=='C':
            if remaining: return None
            if not value.isascii() or not value.isdecimal(): return None
            remaining=int(value); current=[]; blocks.append(current)
        elif tag=='R':
            if remaining==0: return None
            current.append(value); remaining-=2
        else: return None
    if remaining: return None
    return blocks
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('blocks', solve(_vary(['C|2', 'R|@', 'R|x', 'C|1', 'R|z'])), _vary([['@', 'x'], ['z']]))
check('empty block', solve(_vary(['C|0', 'C|1', 'R|@'])), _vary([[], ['@']]))
check('short', solve(_vary(['C|2', 'R|@'])), _vary(None))
check('extra', solve(_vary(['C|1', 'R|@', 'R|x'])), _vary(None))
check('orphan', solve(_vary(['R|@'])), _vary(None))
check('premature block', solve(_vary(['C|2', 'R|@', 'C|0'])), _vary(None))
check('bad tag', solve(_vary(['X|0'])), _vary(None))
check('zero stream', solve(_vary([])), _vary([]))
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
blocksNone[['cell', 'x'], ['z']]Failed
empty blockNone[[], ['cell']]Failed
short[['cell']]NoneFailed
extraNoneNonePassed
orphanNoneNonePassed
premature block[['cell'], []]NoneFailed
bad tagNoneNonePassed
zero stream[][]Passed

SHA-256 / b934cde79a75e60b9ac39feaf948b13644918f402f7b5261b1e23de875354764

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):
    blocks=[]; current=None; remaining=0
    for line in data:
        cells=line.split('|')
        if len(cells)!=2: return None
        tag,value=cells
        if tag=='C':
            if remaining: return None
            if not value.isascii() or not value.isdecimal(): return None
            remaining=int(value); current=[]; blocks.append(current)
        elif tag=='R':
            if remaining==0: return None
            current.append(value); remaining=0
        else: return None
    if remaining: return None
    return blocks
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('blocks', solve(_vary(['C|2', 'R|@', 'R|x', 'C|1', 'R|z'])), _vary([['@', 'x'], ['z']]))
check('empty block', solve(_vary(['C|0', 'C|1', 'R|@'])), _vary([[], ['@']]))
check('short', solve(_vary(['C|2', 'R|@'])), _vary(None))
check('extra', solve(_vary(['C|1', 'R|@', 'R|x'])), _vary(None))
check('orphan', solve(_vary(['R|@'])), _vary(None))
check('premature block', solve(_vary(['C|2', 'R|@', 'C|0'])), _vary(None))
check('bad tag', solve(_vary(['X|0'])), _vary(None))
check('zero stream', solve(_vary([])), _vary([]))
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
blocksNone[['cell', 'x'], ['z']]Failed
empty block[[], ['cell']][[], ['cell']]Passed
short[['cell']]NoneFailed
extraNoneNonePassed
orphanNoneNonePassed
premature block[['cell'], []]NoneFailed
bad tagNoneNonePassed
zero stream[][]Passed

SHA-256 / 99d526d77573252f71327fe7d247c8f8398df0cad0e931320b145d4494472a2d

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):
    blocks=[]; current=None; remaining=0
    for line in data:
        cells=line.split('|')
        if len(cells)!=2: return None
        tag,value=cells
        if tag=='C':
            if remaining: return None
            if not value.isascii() or not value.isdecimal(): return None
            remaining=int(value); current=[]; blocks.append(current)
        elif tag=='R':
            if remaining==0: return None
            current.append(value); remaining-=1
        else: return None
    if remaining: return None
    return blocks
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('blocks', solve(_vary(['C|2', 'R|@', 'R|x', 'C|1', 'R|z'])), _vary([['@', 'x'], ['z']]))
check('empty block', solve(_vary(['C|0', 'C|1', 'R|@'])), _vary([[], ['@']]))
check('short', solve(_vary(['C|2', 'R|@'])), _vary(None))
check('extra', solve(_vary(['C|1', 'R|@', 'R|x'])), _vary(None))
check('orphan', solve(_vary(['R|@'])), _vary(None))
check('premature block', solve(_vary(['C|2', 'R|@', 'C|0'])), _vary(None))
check('bad tag', solve(_vary(['X|0'])), _vary(None))
check('zero stream', solve(_vary([])), _vary([]))
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
blocks[['cell', 'x'], ['z']][['cell', 'x'], ['z']]Passed
empty block[[], ['cell']][[], ['cell']]Passed
shortNoneNonePassed
extraNoneNonePassed
orphanNoneNonePassed
premature blockNoneNonePassed
bad tagNoneNonePassed
zero stream[][]Passed

SHA-256 / 147fb34ed9c6b113b4f94c510f8b31c66039ee91e86ffc77c9729190bb72dfa9

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

Case digest / f304de64f7548048b9830119aef40bf27fe01ee0bdc8afaa605063bf4e950b06