broken_source:
"""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):
    out = []
    for text, quoted in data['cells']:
        if text == 'NULL': out.append(None)
        elif not quoted and text == '': out.append({'missing': True})
        elif not quoted and text == '!DEFAULT': out.append(data['default'])
        else: out.append(text)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('null origin', solve(_vary({'cells': [['NULL', False], ['NULL', True]], 'default': '@'})), _vary([None, 'NULL']))
check('empty origin', solve(_vary({'cells': [['', False], ['', True]], 'default': '@'})), _vary([{'missing': True}, '']))
check('default origin', solve(_vary({'cells': [['!DEFAULT', False], ['!DEFAULT', True]], 'default': '@'})), _vary(['@', '!DEFAULT']))
check('spaces', solve(_vary({'cells': [[' NULL ', False], [' ', True]], 'default': '@'})), _vary([' NULL ', ' ']))
check('case', solve(_vary({'cells': [['null', False]], 'default': '@'})), _vary(['null']))
check('normal', solve(_vary({'cells': [['@', False]], 'default': 'z'})), _vary(['@']))
check('no columns', solve(_vary({'cells': [], 'default': '@'})), _vary([]))
check('bare space', solve(_vary({'cells': [[' ', False]], 'default': '@'})), _vary([' ']))
check('unknown directive', solve(_vary({'cells': [['!hello', False]], 'default': '@'})), _vary(['!hello']))
check('typed default', solve(_vary({'cells': [['!DEFAULT', False]], 'default': 7})), _vary([7]))
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)

source:
"""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):
    out = []
    for text, quoted in data['cells']:
        if text.upper() == 'NULL' and not quoted: out.append(None)
        elif not quoted and text == '': out.append({'missing': True})
        elif not quoted and text == '!DEFAULT': out.append(data['default'])
        else: out.append(text)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('null origin', solve(_vary({'cells': [['NULL', False], ['NULL', True]], 'default': '@'})), _vary([None, 'NULL']))
check('empty origin', solve(_vary({'cells': [['', False], ['', True]], 'default': '@'})), _vary([{'missing': True}, '']))
check('default origin', solve(_vary({'cells': [['!DEFAULT', False], ['!DEFAULT', True]], 'default': '@'})), _vary(['@', '!DEFAULT']))
check('spaces', solve(_vary({'cells': [[' NULL ', False], [' ', True]], 'default': '@'})), _vary([' NULL ', ' ']))
check('case', solve(_vary({'cells': [['null', False]], 'default': '@'})), _vary(['null']))
check('normal', solve(_vary({'cells': [['@', False]], 'default': 'z'})), _vary(['@']))
check('no columns', solve(_vary({'cells': [], 'default': '@'})), _vary([]))
check('bare space', solve(_vary({'cells': [[' ', False]], 'default': '@'})), _vary([' ']))
check('unknown directive', solve(_vary({'cells': [['!hello', False]], 'default': '@'})), _vary(['!hello']))
check('typed default', solve(_vary({'cells': [['!DEFAULT', False]], 'default': 7})), _vary([7]))
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)

prompt:
A structured table violates the declared record or column contract.

Read already lexed cells represented as [text, was_quoted]. Only unquoted NULL is null. An unquoted empty cell is absent, encoded as {missing:True}; quoted empties are empty strings. Unquoted !DEFAULT expands to supplied default. Ordinary whitespace is significant.

split: open-access


broken_source:
"""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):
    out = []
    for text, quoted in data['cells']:
        if not quoted and text == 'NULL': out.append(None)
        elif text == '': out.append({'missing': True})
        elif not quoted and text == '!DEFAULT': out.append(data['default'])
        else: out.append(text)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('null origin', solve(_vary({'cells': [['NULL', False], ['NULL', True]], 'default': '@'})), _vary([None, 'NULL']))
check('empty origin', solve(_vary({'cells': [['', False], ['', True]], 'default': '@'})), _vary([{'missing': True}, '']))
check('default origin', solve(_vary({'cells': [['!DEFAULT', False], ['!DEFAULT', True]], 'default': '@'})), _vary(['@', '!DEFAULT']))
check('spaces', solve(_vary({'cells': [[' NULL ', False], [' ', True]], 'default': '@'})), _vary([' NULL ', ' ']))
check('case', solve(_vary({'cells': [['null', False]], 'default': '@'})), _vary(['null']))
check('normal', solve(_vary({'cells': [['@', False]], 'default': 'z'})), _vary(['@']))
check('no columns', solve(_vary({'cells': [], 'default': '@'})), _vary([]))
check('bare space', solve(_vary({'cells': [[' ', False]], 'default': '@'})), _vary([' ']))
check('unknown directive', solve(_vary({'cells': [['!hello', False]], 'default': '@'})), _vary(['!hello']))
check('typed default', solve(_vary({'cells': [['!DEFAULT', False]], 'default': 7})), _vary([7]))
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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""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):
    out = []
    for text, quoted in data['cells']:
        if not quoted and text == 'NULL': out.append(None)
        elif not quoted and not text.strip(): out.append({'missing': True})
        elif not quoted and text == '!DEFAULT': out.append(data['default'])
        else: out.append(text)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('null origin', solve(_vary({'cells': [['NULL', False], ['NULL', True]], 'default': '@'})), _vary([None, 'NULL']))
check('empty origin', solve(_vary({'cells': [['', False], ['', True]], 'default': '@'})), _vary([{'missing': True}, '']))
check('default origin', solve(_vary({'cells': [['!DEFAULT', False], ['!DEFAULT', True]], 'default': '@'})), _vary(['@', '!DEFAULT']))
check('spaces', solve(_vary({'cells': [[' NULL ', False], [' ', True]], 'default': '@'})), _vary([' NULL ', ' ']))
check('case', solve(_vary({'cells': [['null', False]], 'default': '@'})), _vary(['null']))
check('normal', solve(_vary({'cells': [['@', False]], 'default': 'z'})), _vary(['@']))
check('no columns', solve(_vary({'cells': [], 'default': '@'})), _vary([]))
check('bare space', solve(_vary({'cells': [[' ', False]], 'default': '@'})), _vary([' ']))
check('unknown directive', solve(_vary({'cells': [['!hello', False]], 'default': '@'})), _vary(['!hello']))
check('typed default', solve(_vary({'cells': [['!DEFAULT', False]], 'default': 7})), _vary([7]))
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)

prompt:
A structured table violates the declared record or column contract.

Read already lexed cells represented as [text, was_quoted]. Only unquoted NULL is null. An unquoted empty cell is absent, encoded as {missing:True}; quoted empties are empty strings. Unquoted !DEFAULT expands to supplied default. Ordinary whitespace is significant.

split: open-access


broken_source:
"""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):
    out = []
    for text, quoted in data['cells']:
        if not quoted and text == 'NULL': out.append(None)
        elif not quoted and text == '': out.append({'missing': True})
        elif text == '!DEFAULT': out.append(data['default'])
        else: out.append(text)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('null origin', solve(_vary({'cells': [['NULL', False], ['NULL', True]], 'default': '@'})), _vary([None, 'NULL']))
check('empty origin', solve(_vary({'cells': [['', False], ['', True]], 'default': '@'})), _vary([{'missing': True}, '']))
check('default origin', solve(_vary({'cells': [['!DEFAULT', False], ['!DEFAULT', True]], 'default': '@'})), _vary(['@', '!DEFAULT']))
check('spaces', solve(_vary({'cells': [[' NULL ', False], [' ', True]], 'default': '@'})), _vary([' NULL ', ' ']))
check('case', solve(_vary({'cells': [['null', False]], 'default': '@'})), _vary(['null']))
check('normal', solve(_vary({'cells': [['@', False]], 'default': 'z'})), _vary(['@']))
check('no columns', solve(_vary({'cells': [], 'default': '@'})), _vary([]))
check('bare space', solve(_vary({'cells': [[' ', False]], 'default': '@'})), _vary([' ']))
check('unknown directive', solve(_vary({'cells': [['!hello', False]], 'default': '@'})), _vary(['!hello']))
check('typed default', solve(_vary({'cells': [['!DEFAULT', False]], 'default': 7})), _vary([7]))
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)

source:
"""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):
    out = []
    for text, quoted in data['cells']:
        if not quoted and text == 'NULL': out.append(None)
        elif not quoted and text == '': out.append({'missing': True})
        elif not quoted and text.startswith('!'): out.append(data['default'])
        else: out.append(text)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('null origin', solve(_vary({'cells': [['NULL', False], ['NULL', True]], 'default': '@'})), _vary([None, 'NULL']))
check('empty origin', solve(_vary({'cells': [['', False], ['', True]], 'default': '@'})), _vary([{'missing': True}, '']))
check('default origin', solve(_vary({'cells': [['!DEFAULT', False], ['!DEFAULT', True]], 'default': '@'})), _vary(['@', '!DEFAULT']))
check('spaces', solve(_vary({'cells': [[' NULL ', False], [' ', True]], 'default': '@'})), _vary([' NULL ', ' ']))
check('case', solve(_vary({'cells': [['null', False]], 'default': '@'})), _vary(['null']))
check('normal', solve(_vary({'cells': [['@', False]], 'default': 'z'})), _vary(['@']))
check('no columns', solve(_vary({'cells': [], 'default': '@'})), _vary([]))
check('bare space', solve(_vary({'cells': [[' ', False]], 'default': '@'})), _vary([' ']))
check('unknown directive', solve(_vary({'cells': [['!hello', False]], 'default': '@'})), _vary(['!hello']))
check('typed default', solve(_vary({'cells': [['!DEFAULT', False]], 'default': 7})), _vary([7]))
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)

prompt:
A structured table violates the declared record or column contract.

Read already lexed cells represented as [text, was_quoted]. Only unquoted NULL is null. An unquoted empty cell is absent, encoded as {missing:True}; quoted empties are empty strings. Unquoted !DEFAULT expands to supplied default. Ordinary whitespace is significant.

split: open-access


broken_source:
"""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):
    out = []
    for text, quoted in data['cells']:
        if not quoted and text == 'NULL': out.append(None)
        elif not quoted and text == '': out.append({'missing': True})
        elif not quoted and text == '!DEFAULT': out.append('default')
        else: out.append(text)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('null origin', solve(_vary({'cells': [['NULL', False], ['NULL', True]], 'default': '@'})), _vary([None, 'NULL']))
check('empty origin', solve(_vary({'cells': [['', False], ['', True]], 'default': '@'})), _vary([{'missing': True}, '']))
check('default origin', solve(_vary({'cells': [['!DEFAULT', False], ['!DEFAULT', True]], 'default': '@'})), _vary(['@', '!DEFAULT']))
check('spaces', solve(_vary({'cells': [[' NULL ', False], [' ', True]], 'default': '@'})), _vary([' NULL ', ' ']))
check('case', solve(_vary({'cells': [['null', False]], 'default': '@'})), _vary(['null']))
check('normal', solve(_vary({'cells': [['@', False]], 'default': 'z'})), _vary(['@']))
check('no columns', solve(_vary({'cells': [], 'default': '@'})), _vary([]))
check('bare space', solve(_vary({'cells': [[' ', False]], 'default': '@'})), _vary([' ']))
check('unknown directive', solve(_vary({'cells': [['!hello', False]], 'default': '@'})), _vary(['!hello']))
check('typed default', solve(_vary({'cells': [['!DEFAULT', False]], 'default': 7})), _vary([7]))
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)

source:
"""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):
    out = []
    for text, quoted in data['cells']:
        if not quoted and text == 'NULL': out.append(None)
        elif not quoted and text == '': out.append({'missing': True})
        elif not quoted and text == '!DEFAULT': out.append(str(data['default']))
        else: out.append(text)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('null origin', solve(_vary({'cells': [['NULL', False], ['NULL', True]], 'default': '@'})), _vary([None, 'NULL']))
check('empty origin', solve(_vary({'cells': [['', False], ['', True]], 'default': '@'})), _vary([{'missing': True}, '']))
check('default origin', solve(_vary({'cells': [['!DEFAULT', False], ['!DEFAULT', True]], 'default': '@'})), _vary(['@', '!DEFAULT']))
check('spaces', solve(_vary({'cells': [[' NULL ', False], [' ', True]], 'default': '@'})), _vary([' NULL ', ' ']))
check('case', solve(_vary({'cells': [['null', False]], 'default': '@'})), _vary(['null']))
check('normal', solve(_vary({'cells': [['@', False]], 'default': 'z'})), _vary(['@']))
check('no columns', solve(_vary({'cells': [], 'default': '@'})), _vary([]))
check('bare space', solve(_vary({'cells': [[' ', False]], 'default': '@'})), _vary([' ']))
check('unknown directive', solve(_vary({'cells': [['!hello', False]], 'default': '@'})), _vary(['!hello']))
check('typed default', solve(_vary({'cells': [['!DEFAULT', False]], 'default': 7})), _vary([7]))
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)

prompt:
A structured table violates the declared record or column contract.

Read already lexed cells represented as [text, was_quoted]. Only unquoted NULL is null. An unquoted empty cell is absent, encoded as {missing:True}; quoted empties are empty strings. Unquoted !DEFAULT expands to supplied default. Ordinary whitespace is significant.

split: open-access


broken_source:
"""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):
    out = []
    for text, quoted in data['cells']:
        if not quoted and text == 'NULL': out.append(None)
        elif not quoted and text == '': out.append({'missing': True})
        elif not quoted and text == '!DEFAULT': out.append(data['default'])
        else: out.append(text.strip())
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('null origin', solve(_vary({'cells': [['NULL', False], ['NULL', True]], 'default': '@'})), _vary([None, 'NULL']))
check('empty origin', solve(_vary({'cells': [['', False], ['', True]], 'default': '@'})), _vary([{'missing': True}, '']))
check('default origin', solve(_vary({'cells': [['!DEFAULT', False], ['!DEFAULT', True]], 'default': '@'})), _vary(['@', '!DEFAULT']))
check('spaces', solve(_vary({'cells': [[' NULL ', False], [' ', True]], 'default': '@'})), _vary([' NULL ', ' ']))
check('case', solve(_vary({'cells': [['null', False]], 'default': '@'})), _vary(['null']))
check('normal', solve(_vary({'cells': [['@', False]], 'default': 'z'})), _vary(['@']))
check('no columns', solve(_vary({'cells': [], 'default': '@'})), _vary([]))
check('bare space', solve(_vary({'cells': [[' ', False]], 'default': '@'})), _vary([' ']))
check('unknown directive', solve(_vary({'cells': [['!hello', False]], 'default': '@'})), _vary(['!hello']))
check('typed default', solve(_vary({'cells': [['!DEFAULT', False]], 'default': 7})), _vary([7]))
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)

source:
"""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):
    out = []
    for text, quoted in data['cells']:
        if not quoted and text == 'NULL': out.append(None)
        elif not quoted and text == '': out.append({'missing': True})
        elif not quoted and text == '!DEFAULT': out.append(data['default'])
        else: out.append(text.lower())
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('null origin', solve(_vary({'cells': [['NULL', False], ['NULL', True]], 'default': '@'})), _vary([None, 'NULL']))
check('empty origin', solve(_vary({'cells': [['', False], ['', True]], 'default': '@'})), _vary([{'missing': True}, '']))
check('default origin', solve(_vary({'cells': [['!DEFAULT', False], ['!DEFAULT', True]], 'default': '@'})), _vary(['@', '!DEFAULT']))
check('spaces', solve(_vary({'cells': [[' NULL ', False], [' ', True]], 'default': '@'})), _vary([' NULL ', ' ']))
check('case', solve(_vary({'cells': [['null', False]], 'default': '@'})), _vary(['null']))
check('normal', solve(_vary({'cells': [['@', False]], 'default': 'z'})), _vary(['@']))
check('no columns', solve(_vary({'cells': [], 'default': '@'})), _vary([]))
check('bare space', solve(_vary({'cells': [[' ', False]], 'default': '@'})), _vary([' ']))
check('unknown directive', solve(_vary({'cells': [['!hello', False]], 'default': '@'})), _vary(['!hello']))
check('typed default', solve(_vary({'cells': [['!DEFAULT', False]], 'default': 7})), _vary([7]))
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)

prompt:
A structured table violates the declared record or column contract.

Read already lexed cells represented as [text, was_quoted]. Only unquoted NULL is null. An unquoted empty cell is absent, encoded as {missing:True}; quoted empties are empty strings. Unquoted !DEFAULT expands to supplied default. Ordinary whitespace is significant.

split: open-access


broken_source:
"""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):
    result, buf, state, origin = [], [], 'start', False
    for ch in data:
        if state == 'quoted':
            if ch == '"': state = 'closed'
            else: buf.append(ch)
        elif state == 'closed':
            if ch == '"':
                buf.append('"')
                state = 'quoted'
            elif ch == ',':
                result.append([''.join(buf), origin])
                buf, state, origin = [], 'start', False
            else: return None
        elif ch == ',':
            result.append([''.join(buf), origin])
            buf, state, origin = [], 'start', False
        elif ch == '"':
            if state != 'start': return None
            state, origin = 'quoted', False
        elif ch in '\r\n': return None
        else:
            buf.append(ch)
            state = 'bare'
    if state == 'quoted': return None
    result.append([''.join(buf), origin])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('quoted flags', solve(_vary('"@",a')), _vary([['@', True], ['a', False]]))
check('doubled', solve(_vary('"a""b"')), _vary([['a"b', True]]))
check('triple ending', solve(_vary('"@"""')), _vary([['@"', True]]))
check('empty quoted', solve(_vary('""')), _vary([['', True]]))
check('empty bare', solve(_vary('')), _vary([['', False]]))
check('suffix comma', solve(_vary('"@",')), _vary([['@', True], ['', False]]))
check('bare quote', solve(_vary('a"b')), _vary(None))
check('balanced quote suffix', solve(_vary('a"b"')), _vary(None))
check('junk closing', solve(_vary('"a"x')), _vary(None))
check('space closing', solve(_vary('"a" ')), _vary(None))
check('quoted newlines', solve(_vary('"a\nb"')), _vary([['a\nb', True]]))
check('quoted carriage return', solve(_vary('"a\rb"')), _vary([['a\rb', True]]))
check('unquoted newline', solve(_vary('a\nb')), _vary(None))
check('two quoted', solve(_vary('"a","b"')), _vary([['a', True], ['b', True]]))
check('unterminated', solve(_vary('"a')), _vary(None))
check('plain', solve(_vary('@,z')), _vary([['@', False], ['z', False]]))
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)

source:
"""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):
    result, buf, state, origin = [], [], 'start', False
    for ch in data:
        if state == 'quoted':
            if ch == '"': state = 'closed'
            else: buf.append(ch)
        elif state == 'closed':
            if ch == '"':
                buf.append('"')
                state = 'quoted'
            elif ch == ',':
                result.append([''.join(buf), origin])
                buf, state, origin = [], 'start', False
            else: return None
        elif ch == ',':
            result.append([''.join(buf), origin])
            buf, state, origin = [], 'start', False
        elif ch == '"':
            if state != 'start': return None
            state, origin = 'quoted', len(buf) > 0
        elif ch in '\r\n': return None
        else:
            buf.append(ch)
            state = 'bare'
    if state == 'quoted': return None
    result.append([''.join(buf), origin])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('quoted flags', solve(_vary('"@",a')), _vary([['@', True], ['a', False]]))
check('doubled', solve(_vary('"a""b"')), _vary([['a"b', True]]))
check('triple ending', solve(_vary('"@"""')), _vary([['@"', True]]))
check('empty quoted', solve(_vary('""')), _vary([['', True]]))
check('empty bare', solve(_vary('')), _vary([['', False]]))
check('suffix comma', solve(_vary('"@",')), _vary([['@', True], ['', False]]))
check('bare quote', solve(_vary('a"b')), _vary(None))
check('balanced quote suffix', solve(_vary('a"b"')), _vary(None))
check('junk closing', solve(_vary('"a"x')), _vary(None))
check('space closing', solve(_vary('"a" ')), _vary(None))
check('quoted newlines', solve(_vary('"a\nb"')), _vary([['a\nb', True]]))
check('quoted carriage return', solve(_vary('"a\rb"')), _vary([['a\rb', True]]))
check('unquoted newline', solve(_vary('a\nb')), _vary(None))
check('two quoted', solve(_vary('"a","b"')), _vary([['a', True], ['b', True]]))
check('unterminated', solve(_vary('"a')), _vary(None))
check('plain', solve(_vary('@,z')), _vary([['@', False], ['z', False]]))
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)

prompt:
A structured table violates the declared record or column contract.

Lex one physical comma record. A quote opens only at field start; doubled quotes decode inside quoted fields; after a closing quote only comma or EOF is legal. CR/LF outside quoted fields reject. Return fields and quote-origin flags; a physical newline inside quoted text remains literal.

split: open-access


broken_source:
"""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):
    result, buf, state, origin = [], [], 'start', False
    for ch in data:
        if state == 'quoted':
            if ch == '"': state = 'closed'
            else: buf.append(ch)
        elif state == 'closed':
            if ch == '"':
                buf.append('"')
                state = 'closed'
            elif ch == ',':
                result.append([''.join(buf), origin])
                buf, state, origin = [], 'start', False
            else: return None
        elif ch == ',':
            result.append([''.join(buf), origin])
            buf, state, origin = [], 'start', False
        elif ch == '"':
            if state != 'start': return None
            state, origin = 'quoted', True
        elif ch in '\r\n': return None
        else:
            buf.append(ch)
            state = 'bare'
    if state == 'quoted': return None
    result.append([''.join(buf), origin])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('quoted flags', solve(_vary('"@",a')), _vary([['@', True], ['a', False]]))
check('doubled', solve(_vary('"a""b"')), _vary([['a"b', True]]))
check('triple ending', solve(_vary('"@"""')), _vary([['@"', True]]))
check('empty quoted', solve(_vary('""')), _vary([['', True]]))
check('empty bare', solve(_vary('')), _vary([['', False]]))
check('suffix comma', solve(_vary('"@",')), _vary([['@', True], ['', False]]))
check('bare quote', solve(_vary('a"b')), _vary(None))
check('balanced quote suffix', solve(_vary('a"b"')), _vary(None))
check('junk closing', solve(_vary('"a"x')), _vary(None))
check('space closing', solve(_vary('"a" ')), _vary(None))
check('quoted newlines', solve(_vary('"a\nb"')), _vary([['a\nb', True]]))
check('quoted carriage return', solve(_vary('"a\rb"')), _vary([['a\rb', True]]))
check('unquoted newline', solve(_vary('a\nb')), _vary(None))
check('two quoted', solve(_vary('"a","b"')), _vary([['a', True], ['b', True]]))
check('unterminated', solve(_vary('"a')), _vary(None))
check('plain', solve(_vary('@,z')), _vary([['@', False], ['z', False]]))
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)

source:
"""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):
    result, buf, state, origin = [], [], 'start', False
    for ch in data:
        if state == 'quoted':
            if ch == '"': state = 'closed'
            else: buf.append(ch)
        elif state == 'closed':
            if ch == '"':
                buf.append('"')
                state = 'start'
            elif ch == ',':
                result.append([''.join(buf), origin])
                buf, state, origin = [], 'start', False
            else: return None
        elif ch == ',':
            result.append([''.join(buf), origin])
            buf, state, origin = [], 'start', False
        elif ch == '"':
            if state != 'start': return None
            state, origin = 'quoted', True
        elif ch in '\r\n': return None
        else:
            buf.append(ch)
            state = 'bare'
    if state == 'quoted': return None
    result.append([''.join(buf), origin])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('quoted flags', solve(_vary('"@",a')), _vary([['@', True], ['a', False]]))
check('doubled', solve(_vary('"a""b"')), _vary([['a"b', True]]))
check('triple ending', solve(_vary('"@"""')), _vary([['@"', True]]))
check('empty quoted', solve(_vary('""')), _vary([['', True]]))
check('empty bare', solve(_vary('')), _vary([['', False]]))
check('suffix comma', solve(_vary('"@",')), _vary([['@', True], ['', False]]))
check('bare quote', solve(_vary('a"b')), _vary(None))
check('balanced quote suffix', solve(_vary('a"b"')), _vary(None))
check('junk closing', solve(_vary('"a"x')), _vary(None))
check('space closing', solve(_vary('"a" ')), _vary(None))
check('quoted newlines', solve(_vary('"a\nb"')), _vary([['a\nb', True]]))
check('quoted carriage return', solve(_vary('"a\rb"')), _vary([['a\rb', True]]))
check('unquoted newline', solve(_vary('a\nb')), _vary(None))
check('two quoted', solve(_vary('"a","b"')), _vary([['a', True], ['b', True]]))
check('unterminated', solve(_vary('"a')), _vary(None))
check('plain', solve(_vary('@,z')), _vary([['@', False], ['z', False]]))
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)

prompt:
A structured table violates the declared record or column contract.

Lex one physical comma record. A quote opens only at field start; doubled quotes decode inside quoted fields; after a closing quote only comma or EOF is legal. CR/LF outside quoted fields reject. Return fields and quote-origin flags; a physical newline inside quoted text remains literal.

split: open-access


broken_source:
"""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):
    result, buf, state, origin = [], [], 'start', False
    for ch in data:
        if state == 'quoted':
            if ch == '"': state = 'closed'
            else: buf.append(ch)
        elif state == 'closed':
            if ch == '"':
                buf.append('')
                state = 'quoted'
            elif ch == ',':
                result.append([''.join(buf), origin])
                buf, state, origin = [], 'start', False
            else: return None
        elif ch == ',':
            result.append([''.join(buf), origin])
            buf, state, origin = [], 'start', False
        elif ch == '"':
            if state != 'start': return None
            state, origin = 'quoted', True
        elif ch in '\r\n': return None
        else:
            buf.append(ch)
            state = 'bare'
    if state == 'quoted': return None
    result.append([''.join(buf), origin])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('quoted flags', solve(_vary('"@",a')), _vary([['@', True], ['a', False]]))
check('doubled', solve(_vary('"a""b"')), _vary([['a"b', True]]))
check('triple ending', solve(_vary('"@"""')), _vary([['@"', True]]))
check('empty quoted', solve(_vary('""')), _vary([['', True]]))
check('empty bare', solve(_vary('')), _vary([['', False]]))
check('suffix comma', solve(_vary('"@",')), _vary([['@', True], ['', False]]))
check('bare quote', solve(_vary('a"b')), _vary(None))
check('balanced quote suffix', solve(_vary('a"b"')), _vary(None))
check('junk closing', solve(_vary('"a"x')), _vary(None))
check('space closing', solve(_vary('"a" ')), _vary(None))
check('quoted newlines', solve(_vary('"a\nb"')), _vary([['a\nb', True]]))
check('quoted carriage return', solve(_vary('"a\rb"')), _vary([['a\rb', True]]))
check('unquoted newline', solve(_vary('a\nb')), _vary(None))
check('two quoted', solve(_vary('"a","b"')), _vary([['a', True], ['b', True]]))
check('unterminated', solve(_vary('"a')), _vary(None))
check('plain', solve(_vary('@,z')), _vary([['@', False], ['z', False]]))
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)

source:
"""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):
    result, buf, state, origin = [], [], 'start', False
    for ch in data:
        if state == 'quoted':
            if ch == '"': state = 'closed'
            else: buf.append(ch)
        elif state == 'closed':
            if ch == '"':
                buf.extend(['"', '"'])
                state = 'quoted'
            elif ch == ',':
                result.append([''.join(buf), origin])
                buf, state, origin = [], 'start', False
            else: return None
        elif ch == ',':
            result.append([''.join(buf), origin])
            buf, state, origin = [], 'start', False
        elif ch == '"':
            if state != 'start': return None
            state, origin = 'quoted', True
        elif ch in '\r\n': return None
        else:
            buf.append(ch)
            state = 'bare'
    if state == 'quoted': return None
    result.append([''.join(buf), origin])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('quoted flags', solve(_vary('"@",a')), _vary([['@', True], ['a', False]]))
check('doubled', solve(_vary('"a""b"')), _vary([['a"b', True]]))
check('triple ending', solve(_vary('"@"""')), _vary([['@"', True]]))
check('empty quoted', solve(_vary('""')), _vary([['', True]]))
check('empty bare', solve(_vary('')), _vary([['', False]]))
check('suffix comma', solve(_vary('"@",')), _vary([['@', True], ['', False]]))
check('bare quote', solve(_vary('a"b')), _vary(None))
check('balanced quote suffix', solve(_vary('a"b"')), _vary(None))
check('junk closing', solve(_vary('"a"x')), _vary(None))
check('space closing', solve(_vary('"a" ')), _vary(None))
check('quoted newlines', solve(_vary('"a\nb"')), _vary([['a\nb', True]]))
check('quoted carriage return', solve(_vary('"a\rb"')), _vary([['a\rb', True]]))
check('unquoted newline', solve(_vary('a\nb')), _vary(None))
check('two quoted', solve(_vary('"a","b"')), _vary([['a', True], ['b', True]]))
check('unterminated', solve(_vary('"a')), _vary(None))
check('plain', solve(_vary('@,z')), _vary([['@', False], ['z', False]]))
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)

prompt:
A structured table violates the declared record or column contract.

Lex one physical comma record. A quote opens only at field start; doubled quotes decode inside quoted fields; after a closing quote only comma or EOF is legal. CR/LF outside quoted fields reject. Return fields and quote-origin flags; a physical newline inside quoted text remains literal.

split: open-access


broken_source:
"""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):
    result, buf, state, origin = [], [], 'start', False
    for ch in data:
        if state == 'quoted':
            if ch == '"': state = 'closed'
            else: buf.append(ch)
        elif state == 'closed':
            if ch == '"':
                buf.append('"')
                state = 'quoted'
            elif ch == ',':
                result.append([''.join(buf), origin])
                buf, state, origin = [], 'start', False
            else: pass
        elif ch == ',':
            result.append([''.join(buf), origin])
            buf, state, origin = [], 'start', False
        elif ch == '"':
            if state != 'start': return None
            state, origin = 'quoted', True
        elif ch in '\r\n': return None
        else:
            buf.append(ch)
            state = 'bare'
    if state == 'quoted': return None
    result.append([''.join(buf), origin])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('quoted flags', solve(_vary('"@",a')), _vary([['@', True], ['a', False]]))
check('doubled', solve(_vary('"a""b"')), _vary([['a"b', True]]))
check('triple ending', solve(_vary('"@"""')), _vary([['@"', True]]))
check('empty quoted', solve(_vary('""')), _vary([['', True]]))
check('empty bare', solve(_vary('')), _vary([['', False]]))
check('suffix comma', solve(_vary('"@",')), _vary([['@', True], ['', False]]))
check('bare quote', solve(_vary('a"b')), _vary(None))
check('balanced quote suffix', solve(_vary('a"b"')), _vary(None))
check('junk closing', solve(_vary('"a"x')), _vary(None))
check('space closing', solve(_vary('"a" ')), _vary(None))
check('quoted newlines', solve(_vary('"a\nb"')), _vary([['a\nb', True]]))
check('quoted carriage return', solve(_vary('"a\rb"')), _vary([['a\rb', True]]))
check('unquoted newline', solve(_vary('a\nb')), _vary(None))
check('two quoted', solve(_vary('"a","b"')), _vary([['a', True], ['b', True]]))
check('unterminated', solve(_vary('"a')), _vary(None))
check('plain', solve(_vary('@,z')), _vary([['@', False], ['z', False]]))
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)

source:
"""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):
    result, buf, state, origin = [], [], 'start', False
    for ch in data:
        if state == 'quoted':
            if ch == '"': state = 'closed'
            else: buf.append(ch)
        elif state == 'closed':
            if ch == '"':
                buf.append('"')
                state = 'quoted'
            elif ch == ',':
                result.append([''.join(buf), origin])
                buf, state, origin = [], 'start', False
            else: buf.append(ch)
        elif ch == ',':
            result.append([''.join(buf), origin])
            buf, state, origin = [], 'start', False
        elif ch == '"':
            if state != 'start': return None
            state, origin = 'quoted', True
        elif ch in '\r\n': return None
        else:
            buf.append(ch)
            state = 'bare'
    if state == 'quoted': return None
    result.append([''.join(buf), origin])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('quoted flags', solve(_vary('"@",a')), _vary([['@', True], ['a', False]]))
check('doubled', solve(_vary('"a""b"')), _vary([['a"b', True]]))
check('triple ending', solve(_vary('"@"""')), _vary([['@"', True]]))
check('empty quoted', solve(_vary('""')), _vary([['', True]]))
check('empty bare', solve(_vary('')), _vary([['', False]]))
check('suffix comma', solve(_vary('"@",')), _vary([['@', True], ['', False]]))
check('bare quote', solve(_vary('a"b')), _vary(None))
check('balanced quote suffix', solve(_vary('a"b"')), _vary(None))
check('junk closing', solve(_vary('"a"x')), _vary(None))
check('space closing', solve(_vary('"a" ')), _vary(None))
check('quoted newlines', solve(_vary('"a\nb"')), _vary([['a\nb', True]]))
check('quoted carriage return', solve(_vary('"a\rb"')), _vary([['a\rb', True]]))
check('unquoted newline', solve(_vary('a\nb')), _vary(None))
check('two quoted', solve(_vary('"a","b"')), _vary([['a', True], ['b', True]]))
check('unterminated', solve(_vary('"a')), _vary(None))
check('plain', solve(_vary('@,z')), _vary([['@', False], ['z', False]]))
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)

prompt:
A structured table violates the declared record or column contract.

Lex one physical comma record. A quote opens only at field start; doubled quotes decode inside quoted fields; after a closing quote only comma or EOF is legal. CR/LF outside quoted fields reject. Return fields and quote-origin flags; a physical newline inside quoted text remains literal.

split: open-access


broken_source:
"""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):
    result, buf, state, origin = [], [], 'start', False
    for ch in data:
        if state == 'quoted':
            if ch == '"': state = 'closed'
            else: buf.append(ch)
        elif state == 'closed':
            if ch == '"':
                buf.append('"')
                state = 'quoted'
            elif ch == ',':
                result.append([''.join(buf), origin])
                buf, state, origin = [], 'start', origin
            else: return None
        elif ch == ',':
            result.append([''.join(buf), origin])
            buf, state, origin = [], 'start', False
        elif ch == '"':
            if state != 'start': return None
            state, origin = 'quoted', True
        elif ch in '\r\n': return None
        else:
            buf.append(ch)
            state = 'bare'
    if state == 'quoted': return None
    result.append([''.join(buf), origin])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('quoted flags', solve(_vary('"@",a')), _vary([['@', True], ['a', False]]))
check('doubled', solve(_vary('"a""b"')), _vary([['a"b', True]]))
check('triple ending', solve(_vary('"@"""')), _vary([['@"', True]]))
check('empty quoted', solve(_vary('""')), _vary([['', True]]))
check('empty bare', solve(_vary('')), _vary([['', False]]))
check('suffix comma', solve(_vary('"@",')), _vary([['@', True], ['', False]]))
check('bare quote', solve(_vary('a"b')), _vary(None))
check('balanced quote suffix', solve(_vary('a"b"')), _vary(None))
check('junk closing', solve(_vary('"a"x')), _vary(None))
check('space closing', solve(_vary('"a" ')), _vary(None))
check('quoted newlines', solve(_vary('"a\nb"')), _vary([['a\nb', True]]))
check('quoted carriage return', solve(_vary('"a\rb"')), _vary([['a\rb', True]]))
check('unquoted newline', solve(_vary('a\nb')), _vary(None))
check('two quoted', solve(_vary('"a","b"')), _vary([['a', True], ['b', True]]))
check('unterminated', solve(_vary('"a')), _vary(None))
check('plain', solve(_vary('@,z')), _vary([['@', False], ['z', False]]))
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)

source:
"""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):
    result, buf, state, origin = [], [], 'start', False
    for ch in data:
        if state == 'quoted':
            if ch == '"': state = 'closed'
            else: buf.append(ch)
        elif state == 'closed':
            if ch == '"':
                buf.append('"')
                state = 'quoted'
            elif ch == ',':
                result.append([''.join(buf), origin])
                buf, state, origin = [], 'start', True
            else: return None
        elif ch == ',':
            result.append([''.join(buf), origin])
            buf, state, origin = [], 'start', False
        elif ch == '"':
            if state != 'start': return None
            state, origin = 'quoted', True
        elif ch in '\r\n': return None
        else:
            buf.append(ch)
            state = 'bare'
    if state == 'quoted': return None
    result.append([''.join(buf), origin])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('quoted flags', solve(_vary('"@",a')), _vary([['@', True], ['a', False]]))
check('doubled', solve(_vary('"a""b"')), _vary([['a"b', True]]))
check('triple ending', solve(_vary('"@"""')), _vary([['@"', True]]))
check('empty quoted', solve(_vary('""')), _vary([['', True]]))
check('empty bare', solve(_vary('')), _vary([['', False]]))
check('suffix comma', solve(_vary('"@",')), _vary([['@', True], ['', False]]))
check('bare quote', solve(_vary('a"b')), _vary(None))
check('balanced quote suffix', solve(_vary('a"b"')), _vary(None))
check('junk closing', solve(_vary('"a"x')), _vary(None))
check('space closing', solve(_vary('"a" ')), _vary(None))
check('quoted newlines', solve(_vary('"a\nb"')), _vary([['a\nb', True]]))
check('quoted carriage return', solve(_vary('"a\rb"')), _vary([['a\rb', True]]))
check('unquoted newline', solve(_vary('a\nb')), _vary(None))
check('two quoted', solve(_vary('"a","b"')), _vary([['a', True], ['b', True]]))
check('unterminated', solve(_vary('"a')), _vary(None))
check('plain', solve(_vary('@,z')), _vary([['@', False], ['z', False]]))
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)

prompt:
A structured table violates the declared record or column contract.

Lex one physical comma record. A quote opens only at field start; doubled quotes decode inside quoted fields; after a closing quote only comma or EOF is legal. CR/LF outside quoted fields reject. Return fields and quote-origin flags; a physical newline inside quoted text remains literal.

split: open-access


broken_source:
"""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):
    result, buf, state, origin = [], [], 'start', False
    for ch in data:
        if state == 'quoted':
            if ch == '"': state = 'closed'
            else: buf.append(ch)
        elif state == 'closed':
            if ch == '"':
                buf.append('"')
                state = 'quoted'
            elif ch == ',':
                result.append([''.join(buf), origin])
                buf, state, origin = [], 'start', False
            else: return None
        elif ch == ',':
            result.append([''.join(buf), origin])
            buf, state, origin = [], 'start', False
        elif ch == '"':
            if state != 'start': return None
            state, origin = 'quoted', True
        elif ch in '\r\n': return None
        else:
            buf.append(ch)
            state = 'start'
    if state == 'quoted': return None
    result.append([''.join(buf), origin])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('quoted flags', solve(_vary('"@",a')), _vary([['@', True], ['a', False]]))
check('doubled', solve(_vary('"a""b"')), _vary([['a"b', True]]))
check('triple ending', solve(_vary('"@"""')), _vary([['@"', True]]))
check('empty quoted', solve(_vary('""')), _vary([['', True]]))
check('empty bare', solve(_vary('')), _vary([['', False]]))
check('suffix comma', solve(_vary('"@",')), _vary([['@', True], ['', False]]))
check('bare quote', solve(_vary('a"b')), _vary(None))
check('balanced quote suffix', solve(_vary('a"b"')), _vary(None))
check('junk closing', solve(_vary('"a"x')), _vary(None))
check('space closing', solve(_vary('"a" ')), _vary(None))
check('quoted newlines', solve(_vary('"a\nb"')), _vary([['a\nb', True]]))
check('quoted carriage return', solve(_vary('"a\rb"')), _vary([['a\rb', True]]))
check('unquoted newline', solve(_vary('a\nb')), _vary(None))
check('two quoted', solve(_vary('"a","b"')), _vary([['a', True], ['b', True]]))
check('unterminated', solve(_vary('"a')), _vary(None))
check('plain', solve(_vary('@,z')), _vary([['@', False], ['z', False]]))
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)

source:
"""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):
    result, buf, state, origin = [], [], 'start', False
    for ch in data:
        if state == 'quoted':
            if ch == '"': state = 'closed'
            else: buf.append(ch)
        elif state == 'closed':
            if ch == '"':
                buf.append('"')
                state = 'quoted'
            elif ch == ',':
                result.append([''.join(buf), origin])
                buf, state, origin = [], 'start', False
            else: return None
        elif ch == ',':
            result.append([''.join(buf), origin])
            buf, state, origin = [], 'start', False
        elif ch == '"':
            if state != 'start': return None
            state, origin = 'quoted', True
        elif ch in '\r\n': return None
        else:
            buf.append(ch)
            state = 'closed'
    if state == 'quoted': return None
    result.append([''.join(buf), origin])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('quoted flags', solve(_vary('"@",a')), _vary([['@', True], ['a', False]]))
check('doubled', solve(_vary('"a""b"')), _vary([['a"b', True]]))
check('triple ending', solve(_vary('"@"""')), _vary([['@"', True]]))
check('empty quoted', solve(_vary('""')), _vary([['', True]]))
check('empty bare', solve(_vary('')), _vary([['', False]]))
check('suffix comma', solve(_vary('"@",')), _vary([['@', True], ['', False]]))
check('bare quote', solve(_vary('a"b')), _vary(None))
check('balanced quote suffix', solve(_vary('a"b"')), _vary(None))
check('junk closing', solve(_vary('"a"x')), _vary(None))
check('space closing', solve(_vary('"a" ')), _vary(None))
check('quoted newlines', solve(_vary('"a\nb"')), _vary([['a\nb', True]]))
check('quoted carriage return', solve(_vary('"a\rb"')), _vary([['a\rb', True]]))
check('unquoted newline', solve(_vary('a\nb')), _vary(None))
check('two quoted', solve(_vary('"a","b"')), _vary([['a', True], ['b', True]]))
check('unterminated', solve(_vary('"a')), _vary(None))
check('plain', solve(_vary('@,z')), _vary([['@', False], ['z', False]]))
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)

prompt:
A structured table violates the declared record or column contract.

Lex one physical comma record. A quote opens only at field start; doubled quotes decode inside quoted fields; after a closing quote only comma or EOF is legal. CR/LF outside quoted fields reject. Return fields and quote-origin flags; a physical newline inside quoted text remains literal.

split: open-access


broken_source:
"""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):
    result, buf, state, origin = [], [], 'start', False
    for ch in data:
        if state == 'quoted':
            if ch == '"': state = 'closed'
            else: buf.append(ch)
        elif state == 'closed':
            if ch == '"':
                buf.append('"')
                state = 'quoted'
            elif ch == ',':
                result.append([''.join(buf), origin])
                buf, state, origin = [], 'start', False
            else: return None
        elif ch == ',':
            result.append([''.join(buf), origin])
            buf, state, origin = [], 'start', False
        elif ch == '"':
            if state != 'start': return None
            state, origin = 'quoted', True
        elif ch in '\r\n': return None
        else:
            buf.append(ch)
            state = 'bare'
    if state == 'quoted': return None
    if buf: result.append([''.join(buf), origin])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('quoted flags', solve(_vary('"@",a')), _vary([['@', True], ['a', False]]))
check('doubled', solve(_vary('"a""b"')), _vary([['a"b', True]]))
check('triple ending', solve(_vary('"@"""')), _vary([['@"', True]]))
check('empty quoted', solve(_vary('""')), _vary([['', True]]))
check('empty bare', solve(_vary('')), _vary([['', False]]))
check('suffix comma', solve(_vary('"@",')), _vary([['@', True], ['', False]]))
check('bare quote', solve(_vary('a"b')), _vary(None))
check('balanced quote suffix', solve(_vary('a"b"')), _vary(None))
check('junk closing', solve(_vary('"a"x')), _vary(None))
check('space closing', solve(_vary('"a" ')), _vary(None))
check('quoted newlines', solve(_vary('"a\nb"')), _vary([['a\nb', True]]))
check('quoted carriage return', solve(_vary('"a\rb"')), _vary([['a\rb', True]]))
check('unquoted newline', solve(_vary('a\nb')), _vary(None))
check('two quoted', solve(_vary('"a","b"')), _vary([['a', True], ['b', True]]))
check('unterminated', solve(_vary('"a')), _vary(None))
check('plain', solve(_vary('@,z')), _vary([['@', False], ['z', False]]))
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)

source:
"""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):
    result, buf, state, origin = [], [], 'start', False
    for ch in data:
        if state == 'quoted':
            if ch == '"': state = 'closed'
            else: buf.append(ch)
        elif state == 'closed':
            if ch == '"':
                buf.append('"')
                state = 'quoted'
            elif ch == ',':
                result.append([''.join(buf), origin])
                buf, state, origin = [], 'start', False
            else: return None
        elif ch == ',':
            result.append([''.join(buf), origin])
            buf, state, origin = [], 'start', False
        elif ch == '"':
            if state != 'start': return None
            state, origin = 'quoted', True
        elif ch in '\r\n': return None
        else:
            buf.append(ch)
            state = 'bare'
    if state == 'quoted': return None
    if buf or origin: result.append([''.join(buf), origin])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('quoted flags', solve(_vary('"@",a')), _vary([['@', True], ['a', False]]))
check('doubled', solve(_vary('"a""b"')), _vary([['a"b', True]]))
check('triple ending', solve(_vary('"@"""')), _vary([['@"', True]]))
check('empty quoted', solve(_vary('""')), _vary([['', True]]))
check('empty bare', solve(_vary('')), _vary([['', False]]))
check('suffix comma', solve(_vary('"@",')), _vary([['@', True], ['', False]]))
check('bare quote', solve(_vary('a"b')), _vary(None))
check('balanced quote suffix', solve(_vary('a"b"')), _vary(None))
check('junk closing', solve(_vary('"a"x')), _vary(None))
check('space closing', solve(_vary('"a" ')), _vary(None))
check('quoted newlines', solve(_vary('"a\nb"')), _vary([['a\nb', True]]))
check('quoted carriage return', solve(_vary('"a\rb"')), _vary([['a\rb', True]]))
check('unquoted newline', solve(_vary('a\nb')), _vary(None))
check('two quoted', solve(_vary('"a","b"')), _vary([['a', True], ['b', True]]))
check('unterminated', solve(_vary('"a')), _vary(None))
check('plain', solve(_vary('@,z')), _vary([['@', False], ['z', False]]))
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)

prompt:
A structured table violates the declared record or column contract.

Lex one physical comma record. A quote opens only at field start; doubled quotes decode inside quoted fields; after a closing quote only comma or EOF is legal. CR/LF outside quoted fields reject. Return fields and quote-origin flags; a physical newline inside quoted text remains literal.

split: open-access


broken_source:
"""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):
    result, buf, state, origin = [], [], 'start', False
    for ch in data:
        if state == 'quoted':
            if ch == '"': state = 'closed'
            else: buf.append(' ' if ch == '\n' else ch)
        elif state == 'closed':
            if ch == '"':
                buf.append('"')
                state = 'quoted'
            elif ch == ',':
                result.append([''.join(buf), origin])
                buf, state, origin = [], 'start', False
            else: return None
        elif ch == ',':
            result.append([''.join(buf), origin])
            buf, state, origin = [], 'start', False
        elif ch == '"':
            if state != 'start': return None
            state, origin = 'quoted', True
        elif ch in '\r\n': return None
        else:
            buf.append(ch)
            state = 'bare'
    if state == 'quoted': return None
    result.append([''.join(buf), origin])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('quoted flags', solve(_vary('"@",a')), _vary([['@', True], ['a', False]]))
check('doubled', solve(_vary('"a""b"')), _vary([['a"b', True]]))
check('triple ending', solve(_vary('"@"""')), _vary([['@"', True]]))
check('empty quoted', solve(_vary('""')), _vary([['', True]]))
check('empty bare', solve(_vary('')), _vary([['', False]]))
check('suffix comma', solve(_vary('"@",')), _vary([['@', True], ['', False]]))
check('bare quote', solve(_vary('a"b')), _vary(None))
check('balanced quote suffix', solve(_vary('a"b"')), _vary(None))
check('junk closing', solve(_vary('"a"x')), _vary(None))
check('space closing', solve(_vary('"a" ')), _vary(None))
check('quoted newlines', solve(_vary('"a\nb"')), _vary([['a\nb', True]]))
check('quoted carriage return', solve(_vary('"a\rb"')), _vary([['a\rb', True]]))
check('unquoted newline', solve(_vary('a\nb')), _vary(None))
check('two quoted', solve(_vary('"a","b"')), _vary([['a', True], ['b', True]]))
check('unterminated', solve(_vary('"a')), _vary(None))
check('plain', solve(_vary('@,z')), _vary([['@', False], ['z', False]]))
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)

source:
"""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):
    result, buf, state, origin = [], [], 'start', False
    for ch in data:
        if state == 'quoted':
            if ch == '"': state = 'closed'
            else: buf.append('\n' if ch == '\r' else ch)
        elif state == 'closed':
            if ch == '"':
                buf.append('"')
                state = 'quoted'
            elif ch == ',':
                result.append([''.join(buf), origin])
                buf, state, origin = [], 'start', False
            else: return None
        elif ch == ',':
            result.append([''.join(buf), origin])
            buf, state, origin = [], 'start', False
        elif ch == '"':
            if state != 'start': return None
            state, origin = 'quoted', True
        elif ch in '\r\n': return None
        else:
            buf.append(ch)
            state = 'bare'
    if state == 'quoted': return None
    result.append([''.join(buf), origin])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('quoted flags', solve(_vary('"@",a')), _vary([['@', True], ['a', False]]))
check('doubled', solve(_vary('"a""b"')), _vary([['a"b', True]]))
check('triple ending', solve(_vary('"@"""')), _vary([['@"', True]]))
check('empty quoted', solve(_vary('""')), _vary([['', True]]))
check('empty bare', solve(_vary('')), _vary([['', False]]))
check('suffix comma', solve(_vary('"@",')), _vary([['@', True], ['', False]]))
check('bare quote', solve(_vary('a"b')), _vary(None))
check('balanced quote suffix', solve(_vary('a"b"')), _vary(None))
check('junk closing', solve(_vary('"a"x')), _vary(None))
check('space closing', solve(_vary('"a" ')), _vary(None))
check('quoted newlines', solve(_vary('"a\nb"')), _vary([['a\nb', True]]))
check('quoted carriage return', solve(_vary('"a\rb"')), _vary([['a\rb', True]]))
check('unquoted newline', solve(_vary('a\nb')), _vary(None))
check('two quoted', solve(_vary('"a","b"')), _vary([['a', True], ['b', True]]))
check('unterminated', solve(_vary('"a')), _vary(None))
check('plain', solve(_vary('@,z')), _vary([['@', False], ['z', False]]))
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)

prompt:
A structured table violates the declared record or column contract.

Lex one physical comma record. A quote opens only at field start; doubled quotes decode inside quoted fields; after a closing quote only comma or EOF is legal. CR/LF outside quoted fields reject. Return fields and quote-origin flags; a physical newline inside quoted text remains literal.

split: open-access


broken_source:
"""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):
    rows, buf, pending = [], [], False
    for chunk in data:
        pending = False
        for ch in chunk:
            if pending:
                if ch != '\n': return None
                rows.append(''.join(buf))
                buf, pending = [], False
            elif ch == '\r': pending = True
            elif ch == '\n': return None
            else: buf.append(ch)
    if pending: return None
    if buf: rows.append(''.join(buf))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split terminator', solve(_vary(['@\r', '\nZ\r', '\n'])), _vary(['@', 'Z']))
check('whole', solve(_vary(['@\tA\r\nB'])), _vary(['@\tA', 'B']))
check('empty records', solve(_vary(['\r\n\r\n'])), _vary(['', '']))
check('empty chunks', solve(_vary(['', '@', '', '\r', '', '\n', ''])), _vary(['@']))
check('trailing CR', solve(_vary(['@\r'])), _vary(None))
check('bare LF', solve(_vary(['@\n'])), _vary(None))
check('bad CR', solve(_vary(['@\rZ'])), _vary(None))
check('no data', solve(_vary([])), _vary([]))
check('trailing unframed', solve(_vary(['@'])), _vary(['@']))
check('three chunks', solve(_vary(['@\r', '\n', 'X'])), _vary(['@', 'X']))
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)

source:
"""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):
    rows, buf, pending = [], [], False
    for chunk in data:
        if chunk: pending = False
        for ch in chunk:
            if pending:
                if ch != '\n': return None
                rows.append(''.join(buf))
                buf, pending = [], False
            elif ch == '\r': pending = True
            elif ch == '\n': return None
            else: buf.append(ch)
    if pending: return None
    if buf: rows.append(''.join(buf))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split terminator', solve(_vary(['@\r', '\nZ\r', '\n'])), _vary(['@', 'Z']))
check('whole', solve(_vary(['@\tA\r\nB'])), _vary(['@\tA', 'B']))
check('empty records', solve(_vary(['\r\n\r\n'])), _vary(['', '']))
check('empty chunks', solve(_vary(['', '@', '', '\r', '', '\n', ''])), _vary(['@']))
check('trailing CR', solve(_vary(['@\r'])), _vary(None))
check('bare LF', solve(_vary(['@\n'])), _vary(None))
check('bad CR', solve(_vary(['@\rZ'])), _vary(None))
check('no data', solve(_vary([])), _vary([]))
check('trailing unframed', solve(_vary(['@'])), _vary(['@']))
check('three chunks', solve(_vary(['@\r', '\n', 'X'])), _vary(['@', 'X']))
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)

prompt:
A structured table violates the declared record or column contract.

Frame raw TSV records from arbitrary string chunks using CRLF only. Bare CR and bare LF are invalid. A trailing nonterminated record is allowed; a final CR is invalid. Return records without terminators, retaining empty records.

split: open-access


broken_source:
"""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):
    rows, buf, pending = [], [], False
    for chunk in data:
        for ch in chunk:
            if pending:
                if False: return None
                rows.append(''.join(buf))
                buf, pending = [], False
            elif ch == '\r': pending = True
            elif ch == '\n': return None
            else: buf.append(ch)
    if pending: return None
    if buf: rows.append(''.join(buf))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split terminator', solve(_vary(['@\r', '\nZ\r', '\n'])), _vary(['@', 'Z']))
check('whole', solve(_vary(['@\tA\r\nB'])), _vary(['@\tA', 'B']))
check('empty records', solve(_vary(['\r\n\r\n'])), _vary(['', '']))
check('empty chunks', solve(_vary(['', '@', '', '\r', '', '\n', ''])), _vary(['@']))
check('trailing CR', solve(_vary(['@\r'])), _vary(None))
check('bare LF', solve(_vary(['@\n'])), _vary(None))
check('bad CR', solve(_vary(['@\rZ'])), _vary(None))
check('no data', solve(_vary([])), _vary([]))
check('trailing unframed', solve(_vary(['@'])), _vary(['@']))
check('three chunks', solve(_vary(['@\r', '\n', 'X'])), _vary(['@', 'X']))
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)

source:
"""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):
    rows, buf, pending = [], [], False
    for chunk in data:
        for ch in chunk:
            if pending:
                if ch == '\r': return None
                rows.append(''.join(buf))
                buf, pending = [], False
            elif ch == '\r': pending = True
            elif ch == '\n': return None
            else: buf.append(ch)
    if pending: return None
    if buf: rows.append(''.join(buf))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split terminator', solve(_vary(['@\r', '\nZ\r', '\n'])), _vary(['@', 'Z']))
check('whole', solve(_vary(['@\tA\r\nB'])), _vary(['@\tA', 'B']))
check('empty records', solve(_vary(['\r\n\r\n'])), _vary(['', '']))
check('empty chunks', solve(_vary(['', '@', '', '\r', '', '\n', ''])), _vary(['@']))
check('trailing CR', solve(_vary(['@\r'])), _vary(None))
check('bare LF', solve(_vary(['@\n'])), _vary(None))
check('bad CR', solve(_vary(['@\rZ'])), _vary(None))
check('no data', solve(_vary([])), _vary([]))
check('trailing unframed', solve(_vary(['@'])), _vary(['@']))
check('three chunks', solve(_vary(['@\r', '\n', 'X'])), _vary(['@', 'X']))
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)

prompt:
A structured table violates the declared record or column contract.

Frame raw TSV records from arbitrary string chunks using CRLF only. Bare CR and bare LF are invalid. A trailing nonterminated record is allowed; a final CR is invalid. Return records without terminators, retaining empty records.

split: open-access


broken_source:
"""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):
    rows, buf, pending = [], [], False
    for chunk in data:
        for ch in chunk:
            if pending:
                if ch != '\n': return None
                rows.append(''.join(buf))
                buf, pending = buf, False
            elif ch == '\r': pending = True
            elif ch == '\n': return None
            else: buf.append(ch)
    if pending: return None
    if buf: rows.append(''.join(buf))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split terminator', solve(_vary(['@\r', '\nZ\r', '\n'])), _vary(['@', 'Z']))
check('whole', solve(_vary(['@\tA\r\nB'])), _vary(['@\tA', 'B']))
check('empty records', solve(_vary(['\r\n\r\n'])), _vary(['', '']))
check('empty chunks', solve(_vary(['', '@', '', '\r', '', '\n', ''])), _vary(['@']))
check('trailing CR', solve(_vary(['@\r'])), _vary(None))
check('bare LF', solve(_vary(['@\n'])), _vary(None))
check('bad CR', solve(_vary(['@\rZ'])), _vary(None))
check('no data', solve(_vary([])), _vary([]))
check('trailing unframed', solve(_vary(['@'])), _vary(['@']))
check('three chunks', solve(_vary(['@\r', '\n', 'X'])), _vary(['@', 'X']))
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)

source:
"""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):
    rows, buf, pending = [], [], False
    for chunk in data:
        for ch in chunk:
            if pending:
                if ch != '\n': return None
                rows.append(''.join(buf))
                buf, pending = buf[-1:], False
            elif ch == '\r': pending = True
            elif ch == '\n': return None
            else: buf.append(ch)
    if pending: return None
    if buf: rows.append(''.join(buf))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split terminator', solve(_vary(['@\r', '\nZ\r', '\n'])), _vary(['@', 'Z']))
check('whole', solve(_vary(['@\tA\r\nB'])), _vary(['@\tA', 'B']))
check('empty records', solve(_vary(['\r\n\r\n'])), _vary(['', '']))
check('empty chunks', solve(_vary(['', '@', '', '\r', '', '\n', ''])), _vary(['@']))
check('trailing CR', solve(_vary(['@\r'])), _vary(None))
check('bare LF', solve(_vary(['@\n'])), _vary(None))
check('bad CR', solve(_vary(['@\rZ'])), _vary(None))
check('no data', solve(_vary([])), _vary([]))
check('trailing unframed', solve(_vary(['@'])), _vary(['@']))
check('three chunks', solve(_vary(['@\r', '\n', 'X'])), _vary(['@', 'X']))
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)

prompt:
A structured table violates the declared record or column contract.

Frame raw TSV records from arbitrary string chunks using CRLF only. Bare CR and bare LF are invalid. A trailing nonterminated record is allowed; a final CR is invalid. Return records without terminators, retaining empty records.

split: open-access


broken_source:
"""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):
    rows, buf, pending = [], [], False
    for chunk in data:
        for ch in chunk:
            if pending:
                if ch != '\n': return None
                rows.append(''.join(buf))
                buf, pending = [], True
            elif ch == '\r': pending = True
            elif ch == '\n': return None
            else: buf.append(ch)
    if pending: return None
    if buf: rows.append(''.join(buf))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split terminator', solve(_vary(['@\r', '\nZ\r', '\n'])), _vary(['@', 'Z']))
check('whole', solve(_vary(['@\tA\r\nB'])), _vary(['@\tA', 'B']))
check('empty records', solve(_vary(['\r\n\r\n'])), _vary(['', '']))
check('empty chunks', solve(_vary(['', '@', '', '\r', '', '\n', ''])), _vary(['@']))
check('trailing CR', solve(_vary(['@\r'])), _vary(None))
check('bare LF', solve(_vary(['@\n'])), _vary(None))
check('bad CR', solve(_vary(['@\rZ'])), _vary(None))
check('no data', solve(_vary([])), _vary([]))
check('trailing unframed', solve(_vary(['@'])), _vary(['@']))
check('three chunks', solve(_vary(['@\r', '\n', 'X'])), _vary(['@', 'X']))
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)

source:
"""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):
    rows, buf, pending = [], [], False
    for chunk in data:
        for ch in chunk:
            if pending:
                if ch != '\n': return None
                rows.append(''.join(buf))
                buf, pending = [], ch == '\n'
            elif ch == '\r': pending = True
            elif ch == '\n': return None
            else: buf.append(ch)
    if pending: return None
    if buf: rows.append(''.join(buf))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split terminator', solve(_vary(['@\r', '\nZ\r', '\n'])), _vary(['@', 'Z']))
check('whole', solve(_vary(['@\tA\r\nB'])), _vary(['@\tA', 'B']))
check('empty records', solve(_vary(['\r\n\r\n'])), _vary(['', '']))
check('empty chunks', solve(_vary(['', '@', '', '\r', '', '\n', ''])), _vary(['@']))
check('trailing CR', solve(_vary(['@\r'])), _vary(None))
check('bare LF', solve(_vary(['@\n'])), _vary(None))
check('bad CR', solve(_vary(['@\rZ'])), _vary(None))
check('no data', solve(_vary([])), _vary([]))
check('trailing unframed', solve(_vary(['@'])), _vary(['@']))
check('three chunks', solve(_vary(['@\r', '\n', 'X'])), _vary(['@', 'X']))
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)

prompt:
A structured table violates the declared record or column contract.

Frame raw TSV records from arbitrary string chunks using CRLF only. Bare CR and bare LF are invalid. A trailing nonterminated record is allowed; a final CR is invalid. Return records without terminators, retaining empty records.

split: open-access


broken_source:
"""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):
    rows, buf, pending = [], [], False
    for chunk in data:
        for ch in chunk:
            if pending:
                if ch != '\n': return None
                rows.append(''.join(buf))
                buf, pending = [], False
            elif ch == '\r': pending = True
            elif ch == '\n': return None
            else: buf.append(ch)
    if pending: return None
    if False: rows.append(''.join(buf))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split terminator', solve(_vary(['@\r', '\nZ\r', '\n'])), _vary(['@', 'Z']))
check('whole', solve(_vary(['@\tA\r\nB'])), _vary(['@\tA', 'B']))
check('empty records', solve(_vary(['\r\n\r\n'])), _vary(['', '']))
check('empty chunks', solve(_vary(['', '@', '', '\r', '', '\n', ''])), _vary(['@']))
check('trailing CR', solve(_vary(['@\r'])), _vary(None))
check('bare LF', solve(_vary(['@\n'])), _vary(None))
check('bad CR', solve(_vary(['@\rZ'])), _vary(None))
check('no data', solve(_vary([])), _vary([]))
check('trailing unframed', solve(_vary(['@'])), _vary(['@']))
check('three chunks', solve(_vary(['@\r', '\n', 'X'])), _vary(['@', 'X']))
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)

source:
"""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):
    rows, buf, pending = [], [], False
    for chunk in data:
        for ch in chunk:
            if pending:
                if ch != '\n': return None
                rows.append(''.join(buf))
                buf, pending = [], False
            elif ch == '\r': pending = True
            elif ch == '\n': return None
            else: buf.append(ch)
    if pending: return None
    if len(buf) > 1: rows.append(''.join(buf))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split terminator', solve(_vary(['@\r', '\nZ\r', '\n'])), _vary(['@', 'Z']))
check('whole', solve(_vary(['@\tA\r\nB'])), _vary(['@\tA', 'B']))
check('empty records', solve(_vary(['\r\n\r\n'])), _vary(['', '']))
check('empty chunks', solve(_vary(['', '@', '', '\r', '', '\n', ''])), _vary(['@']))
check('trailing CR', solve(_vary(['@\r'])), _vary(None))
check('bare LF', solve(_vary(['@\n'])), _vary(None))
check('bad CR', solve(_vary(['@\rZ'])), _vary(None))
check('no data', solve(_vary([])), _vary([]))
check('trailing unframed', solve(_vary(['@'])), _vary(['@']))
check('three chunks', solve(_vary(['@\r', '\n', 'X'])), _vary(['@', 'X']))
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)

prompt:
A structured table violates the declared record or column contract.

Frame raw TSV records from arbitrary string chunks using CRLF only. Bare CR and bare LF are invalid. A trailing nonterminated record is allowed; a final CR is invalid. Return records without terminators, retaining empty records.

split: open-access


broken_source:
"""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):
    rows, buf, pending = [], [], False
    for chunk in data:
        for ch in chunk:
            if pending:
                if ch != '\n': return None
                if buf: rows.append(''.join(buf))
                buf, pending = [], False
            elif ch == '\r': pending = True
            elif ch == '\n': return None
            else: buf.append(ch)
    if pending: return None
    if buf: rows.append(''.join(buf))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split terminator', solve(_vary(['@\r', '\nZ\r', '\n'])), _vary(['@', 'Z']))
check('whole', solve(_vary(['@\tA\r\nB'])), _vary(['@\tA', 'B']))
check('empty records', solve(_vary(['\r\n\r\n'])), _vary(['', '']))
check('empty chunks', solve(_vary(['', '@', '', '\r', '', '\n', ''])), _vary(['@']))
check('trailing CR', solve(_vary(['@\r'])), _vary(None))
check('bare LF', solve(_vary(['@\n'])), _vary(None))
check('bad CR', solve(_vary(['@\rZ'])), _vary(None))
check('no data', solve(_vary([])), _vary([]))
check('trailing unframed', solve(_vary(['@'])), _vary(['@']))
check('three chunks', solve(_vary(['@\r', '\n', 'X'])), _vary(['@', 'X']))
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)

source:
"""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):
    rows, buf, pending = [], [], False
    for chunk in data:
        for ch in chunk:
            if pending:
                if ch != '\n': return None
                if ''.join(buf).strip(): rows.append(''.join(buf))
                buf, pending = [], False
            elif ch == '\r': pending = True
            elif ch == '\n': return None
            else: buf.append(ch)
    if pending: return None
    if buf: rows.append(''.join(buf))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split terminator', solve(_vary(['@\r', '\nZ\r', '\n'])), _vary(['@', 'Z']))
check('whole', solve(_vary(['@\tA\r\nB'])), _vary(['@\tA', 'B']))
check('empty records', solve(_vary(['\r\n\r\n'])), _vary(['', '']))
check('empty chunks', solve(_vary(['', '@', '', '\r', '', '\n', ''])), _vary(['@']))
check('trailing CR', solve(_vary(['@\r'])), _vary(None))
check('bare LF', solve(_vary(['@\n'])), _vary(None))
check('bad CR', solve(_vary(['@\rZ'])), _vary(None))
check('no data', solve(_vary([])), _vary([]))
check('trailing unframed', solve(_vary(['@'])), _vary(['@']))
check('three chunks', solve(_vary(['@\r', '\n', 'X'])), _vary(['@', 'X']))
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)

prompt:
A structured table violates the declared record or column contract.

Frame raw TSV records from arbitrary string chunks using CRLF only. Bare CR and bare LF are invalid. A trailing nonterminated record is allowed; a final CR is invalid. Return records without terminators, retaining empty records.

split: open-access


broken_source:
"""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):
    sections, current, needs_header = [], None, False
    for line in data:
        if line.startswith('%'):
            if False: return None
            name = line[1:]
            if not name or any(s[0] == name for s in sections): return None
            current = [name, [], []]
            sections.append(current)
            needs_header = True
        elif line == '':
            if needs_header: return None
            current = None
        elif current is None: return None
        elif needs_header:
            current[1] = line.split('\t')
            needs_header = False
        else: current[2].append(line.split('\t'))
    if needs_header: return None
    return sections
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('two sections', solve(_vary(['%one', 'a\tb', '@\tz', '%two', 'x', 'q'])), _vary([['one', ['a', 'b'], [['@', 'z']]], ['two', ['x'], [['q']]]]))
check('section close', solve(_vary(['%one', 'a', 'x', '', 'orphan'])), _vary(None))
check('empty section', solve(_vary(['%one', '%two', 'a'])), _vary(None))
check('missing eof header', solve(_vary(['%one'])), _vary(None))
check('duplicate', solve(_vary(['%one', 'a', '%one', 'b'])), _vary(None))
check('empty name', solve(_vary(['%', 'a'])), _vary(None))
check('normal', solve(_vary(['%one', 'a', '%'])), _vary(None))
check('zero', solve(_vary([])), _vary([]))
check('body control', solve(_vary(['%one', 'a', 'cell', 'two'])), _vary([['one', ['a'], [['cell'], ['two']]]]))
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)

source:
"""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):
    sections, current, needs_header = [], None, False
    for line in data:
        if line.startswith('%'):
            if current is not None and needs_header and len(sections) > 1: return None
            name = line[1:]
            if not name or any(s[0] == name for s in sections): return None
            current = [name, [], []]
            sections.append(current)
            needs_header = True
        elif line == '':
            if needs_header: return None
            current = None
        elif current is None: return None
        elif needs_header:
            current[1] = line.split('\t')
            needs_header = False
        else: current[2].append(line.split('\t'))
    if needs_header: return None
    return sections
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('two sections', solve(_vary(['%one', 'a\tb', '@\tz', '%two', 'x', 'q'])), _vary([['one', ['a', 'b'], [['@', 'z']]], ['two', ['x'], [['q']]]]))
check('section close', solve(_vary(['%one', 'a', 'x', '', 'orphan'])), _vary(None))
check('empty section', solve(_vary(['%one', '%two', 'a'])), _vary(None))
check('missing eof header', solve(_vary(['%one'])), _vary(None))
check('duplicate', solve(_vary(['%one', 'a', '%one', 'b'])), _vary(None))
check('empty name', solve(_vary(['%', 'a'])), _vary(None))
check('normal', solve(_vary(['%one', 'a', '%'])), _vary(None))
check('zero', solve(_vary([])), _vary([]))
check('body control', solve(_vary(['%one', 'a', 'cell', 'two'])), _vary([['one', ['a'], [['cell'], ['two']]]]))
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)

prompt:
A structured table violates the declared record or column contract.

Read a bounded sectioned TSV stream: @name starts a new table, the next record is its header, subsequent records its data. Names are unique and nonempty. A blank line closes a section; body records outside sections and sections without headers reject. Return ordered [name, header, rows] sections.

split: open-access