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):
    values = data['row'].split(',')
    if len(values) > 2: return None
    out = []
    for i in range(2):
        if i < len(values): out.append(values[i])
        elif False: return None
        else: out.append(data['defaults'][i])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('missing optional', solve(_vary({'row': '@', 'required': [True, False], 'defaults': ['x', 'y']})), _vary(['@', 'y']))
check('present empty', solve(_vary({'row': '@,', 'required': [True, False], 'defaults': ['x', 'y']})), _vary(['@', '']))
check('missing required', solve(_vary({'row': '@', 'required': [False, True], 'defaults': ['x', 'y']})), _vary(None))
check('typed default', solve(_vary({'row': '@', 'required': [False, False], 'defaults': [0, [1, 2]]})), _vary(['@', [1, 2]]))
check('null default', solve(_vary({'row': '@', 'required': [False, False], 'defaults': [0, None]})), _vary(['@', None]))
check('extra', solve(_vary({'row': 'a,b,c', 'required': [False, False], 'defaults': [0, 1]})), _vary(None))
check('both present', solve(_vary({'row': '@,z', 'required': [True, True], 'defaults': [0, 1]})), _vary(['@', 'z']))
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):
    values = data['row'].split(',')
    if len(values) > 2: return None
    out = []
    for i in range(2):
        if i < len(values): out.append(values[i])
        elif data['required'][i] and data['defaults'][i] is None: return None
        else: out.append(data['defaults'][i])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('missing optional', solve(_vary({'row': '@', 'required': [True, False], 'defaults': ['x', 'y']})), _vary(['@', 'y']))
check('present empty', solve(_vary({'row': '@,', 'required': [True, False], 'defaults': ['x', 'y']})), _vary(['@', '']))
check('missing required', solve(_vary({'row': '@', 'required': [False, True], 'defaults': ['x', 'y']})), _vary(None))
check('typed default', solve(_vary({'row': '@', 'required': [False, False], 'defaults': [0, [1, 2]]})), _vary(['@', [1, 2]]))
check('null default', solve(_vary({'row': '@', 'required': [False, False], 'defaults': [0, None]})), _vary(['@', None]))
check('extra', solve(_vary({'row': 'a,b,c', 'required': [False, False], 'defaults': [0, 1]})), _vary(None))
check('both present', solve(_vary({'row': '@,z', 'required': [True, True], 'defaults': [0, 1]})), _vary(['@', 'z']))
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.

Bind a two-column comma row to [a,b] with per-column defaults. An absent cell uses its default only if its required flag is false; a present empty cell stays empty. Surplus cells reject. Return ordered values. Defaults may be null or lists and must remain typed.

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):
    values = data['row'].split(',')
    if len(values) > 2: return None
    out = []
    for i in range(2):
        if i < len(values): out.append(values[i])
        elif data['required'][i]: return None
        else: out.append(data['defaults'][0])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('missing optional', solve(_vary({'row': '@', 'required': [True, False], 'defaults': ['x', 'y']})), _vary(['@', 'y']))
check('present empty', solve(_vary({'row': '@,', 'required': [True, False], 'defaults': ['x', 'y']})), _vary(['@', '']))
check('missing required', solve(_vary({'row': '@', 'required': [False, True], 'defaults': ['x', 'y']})), _vary(None))
check('typed default', solve(_vary({'row': '@', 'required': [False, False], 'defaults': [0, [1, 2]]})), _vary(['@', [1, 2]]))
check('null default', solve(_vary({'row': '@', 'required': [False, False], 'defaults': [0, None]})), _vary(['@', None]))
check('extra', solve(_vary({'row': 'a,b,c', 'required': [False, False], 'defaults': [0, 1]})), _vary(None))
check('both present', solve(_vary({'row': '@,z', 'required': [True, True], 'defaults': [0, 1]})), _vary(['@', 'z']))
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):
    values = data['row'].split(',')
    if len(values) > 2: return None
    out = []
    for i in range(2):
        if i < len(values): out.append(values[i])
        elif data['required'][i]: return None
        else: out.append(data['defaults'][-1] if i == 0 else data['defaults'][0])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('missing optional', solve(_vary({'row': '@', 'required': [True, False], 'defaults': ['x', 'y']})), _vary(['@', 'y']))
check('present empty', solve(_vary({'row': '@,', 'required': [True, False], 'defaults': ['x', 'y']})), _vary(['@', '']))
check('missing required', solve(_vary({'row': '@', 'required': [False, True], 'defaults': ['x', 'y']})), _vary(None))
check('typed default', solve(_vary({'row': '@', 'required': [False, False], 'defaults': [0, [1, 2]]})), _vary(['@', [1, 2]]))
check('null default', solve(_vary({'row': '@', 'required': [False, False], 'defaults': [0, None]})), _vary(['@', None]))
check('extra', solve(_vary({'row': 'a,b,c', 'required': [False, False], 'defaults': [0, 1]})), _vary(None))
check('both present', solve(_vary({'row': '@,z', 'required': [True, True], 'defaults': [0, 1]})), _vary(['@', 'z']))
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.

Bind a two-column comma row to [a,b] with per-column defaults. An absent cell uses its default only if its required flag is false; a present empty cell stays empty. Surplus cells reject. Return ordered values. Defaults may be null or lists and must remain typed.

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):
    values = data['row'].split(',')
    if len(values) > 2: return None
    out = []
    for i in range(2):
        if i < len(values): out.append(values[i])
        elif data['required'][i]: return None
        else: out.append(str(data['defaults'][i]))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('missing optional', solve(_vary({'row': '@', 'required': [True, False], 'defaults': ['x', 'y']})), _vary(['@', 'y']))
check('present empty', solve(_vary({'row': '@,', 'required': [True, False], 'defaults': ['x', 'y']})), _vary(['@', '']))
check('missing required', solve(_vary({'row': '@', 'required': [False, True], 'defaults': ['x', 'y']})), _vary(None))
check('typed default', solve(_vary({'row': '@', 'required': [False, False], 'defaults': [0, [1, 2]]})), _vary(['@', [1, 2]]))
check('null default', solve(_vary({'row': '@', 'required': [False, False], 'defaults': [0, None]})), _vary(['@', None]))
check('extra', solve(_vary({'row': 'a,b,c', 'required': [False, False], 'defaults': [0, 1]})), _vary(None))
check('both present', solve(_vary({'row': '@,z', 'required': [True, True], 'defaults': [0, 1]})), _vary(['@', 'z']))
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):
    values = data['row'].split(',')
    if len(values) > 2: return None
    out = []
    for i in range(2):
        if i < len(values): out.append(values[i])
        elif data['required'][i]: return None
        else: out.append('' if data['defaults'][i] is None else str(data['defaults'][i]))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('missing optional', solve(_vary({'row': '@', 'required': [True, False], 'defaults': ['x', 'y']})), _vary(['@', 'y']))
check('present empty', solve(_vary({'row': '@,', 'required': [True, False], 'defaults': ['x', 'y']})), _vary(['@', '']))
check('missing required', solve(_vary({'row': '@', 'required': [False, True], 'defaults': ['x', 'y']})), _vary(None))
check('typed default', solve(_vary({'row': '@', 'required': [False, False], 'defaults': [0, [1, 2]]})), _vary(['@', [1, 2]]))
check('null default', solve(_vary({'row': '@', 'required': [False, False], 'defaults': [0, None]})), _vary(['@', None]))
check('extra', solve(_vary({'row': 'a,b,c', 'required': [False, False], 'defaults': [0, 1]})), _vary(None))
check('both present', solve(_vary({'row': '@,z', 'required': [True, True], 'defaults': [0, 1]})), _vary(['@', 'z']))
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.

Bind a two-column comma row to [a,b] with per-column defaults. An absent cell uses its default only if its required flag is false; a present empty cell stays empty. Surplus cells reject. Return ordered values. Defaults may be null or lists and must remain typed.

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):
    values = data['row'].split(',')
    if len(values) > 2: values = values[:2]
    out = []
    for i in range(2):
        if i < len(values): out.append(values[i])
        elif data['required'][i]: return None
        else: out.append(data['defaults'][i])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('missing optional', solve(_vary({'row': '@', 'required': [True, False], 'defaults': ['x', 'y']})), _vary(['@', 'y']))
check('present empty', solve(_vary({'row': '@,', 'required': [True, False], 'defaults': ['x', 'y']})), _vary(['@', '']))
check('missing required', solve(_vary({'row': '@', 'required': [False, True], 'defaults': ['x', 'y']})), _vary(None))
check('typed default', solve(_vary({'row': '@', 'required': [False, False], 'defaults': [0, [1, 2]]})), _vary(['@', [1, 2]]))
check('null default', solve(_vary({'row': '@', 'required': [False, False], 'defaults': [0, None]})), _vary(['@', None]))
check('extra', solve(_vary({'row': 'a,b,c', 'required': [False, False], 'defaults': [0, 1]})), _vary(None))
check('both present', solve(_vary({'row': '@,z', 'required': [True, True], 'defaults': [0, 1]})), _vary(['@', 'z']))
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):
    values = data['row'].split(',')
    if len(values) > 2: values = values[-2:]
    out = []
    for i in range(2):
        if i < len(values): out.append(values[i])
        elif data['required'][i]: return None
        else: out.append(data['defaults'][i])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('missing optional', solve(_vary({'row': '@', 'required': [True, False], 'defaults': ['x', 'y']})), _vary(['@', 'y']))
check('present empty', solve(_vary({'row': '@,', 'required': [True, False], 'defaults': ['x', 'y']})), _vary(['@', '']))
check('missing required', solve(_vary({'row': '@', 'required': [False, True], 'defaults': ['x', 'y']})), _vary(None))
check('typed default', solve(_vary({'row': '@', 'required': [False, False], 'defaults': [0, [1, 2]]})), _vary(['@', [1, 2]]))
check('null default', solve(_vary({'row': '@', 'required': [False, False], 'defaults': [0, None]})), _vary(['@', None]))
check('extra', solve(_vary({'row': 'a,b,c', 'required': [False, False], 'defaults': [0, 1]})), _vary(None))
check('both present', solve(_vary({'row': '@,z', 'required': [True, True], 'defaults': [0, 1]})), _vary(['@', 'z']))
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.

Bind a two-column comma row to [a,b] with per-column defaults. An absent cell uses its default only if its required flag is false; a present empty cell stays empty. Surplus cells reject. Return ordered values. Defaults may be null or lists and must remain typed.

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 cell in data:
        probe = cell
        if not cell.startswith("'") and probe[:1] in ('=', '+', '-', '@'):
            cell = "'" + cell
        cell = cell.replace('"', '""')
        out.append('"' + cell + '"')
    return ','.join(out) + '\n'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('formula', solve(_vary(['=1+1'])), _vary('"\'=1+1"\n'))
check('leading space', solve(_vary([' \t+2'])), _vary('"\' \t+2"\n'))
check('existing prefix', solve(_vary(["'=3"])), _vary('"\'=3"\n'))
check('minus', solve(_vary(['-12'])), _vary('"\'-12"\n'))
check('ordinary', solve(_vary(['text', 'a"b'])), _vary('"text","a""b"\n'))
check('empty', solve(_vary([''])), _vary('""\n'))
check('interior', solve(_vary(['x=1'])), _vary('"x=1"\n'))
check('no cells', solve(_vary([])), _vary('\n'))
check('variant formula width', solve(['='+str(N)+'+1']), '"\'='+str(N)+'+1"\n')
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 cell in data:
        probe = cell.lstrip(' ')
        if not cell.startswith("'") and probe[:1] in ('=', '+', '-', '@'):
            cell = "'" + cell
        cell = cell.replace('"', '""')
        out.append('"' + cell + '"')
    return ','.join(out) + '\n'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('formula', solve(_vary(['=1+1'])), _vary('"\'=1+1"\n'))
check('leading space', solve(_vary([' \t+2'])), _vary('"\' \t+2"\n'))
check('existing prefix', solve(_vary(["'=3"])), _vary('"\'=3"\n'))
check('minus', solve(_vary(['-12'])), _vary('"\'-12"\n'))
check('ordinary', solve(_vary(['text', 'a"b'])), _vary('"text","a""b"\n'))
check('empty', solve(_vary([''])), _vary('""\n'))
check('interior', solve(_vary(['x=1'])), _vary('"x=1"\n'))
check('no cells', solve(_vary([])), _vary('\n'))
check('variant formula width', solve(['='+str(N)+'+1']), '"\'='+str(N)+'+1"\n')
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.

Encode already textual comma cells for a spreadsheet-facing export. Prefix a single apostrophe if the first non-space/non-tab character is =,+,-, or @. An existing leading apostrophe is preserved without duplication. Then double embedded quotes and quote every cell. Return LF-terminated row. This is a stipulated conservative transport policy, not a universal spreadsheet security guarantee.

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 cell in data:
        probe = cell.lstrip(' \t')
        if not cell.startswith("'") and probe[:1] in ('=', '+', '-', '@'):
            cell = cell[:len(cell)-len(probe)] + "'" + probe
        cell = cell.replace('"', '""')
        out.append('"' + cell + '"')
    return ','.join(out) + '\n'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('formula', solve(_vary(['=1+1'])), _vary('"\'=1+1"\n'))
check('leading space', solve(_vary([' \t+2'])), _vary('"\' \t+2"\n'))
check('existing prefix', solve(_vary(["'=3"])), _vary('"\'=3"\n'))
check('minus', solve(_vary(['-12'])), _vary('"\'-12"\n'))
check('ordinary', solve(_vary(['text', 'a"b'])), _vary('"text","a""b"\n'))
check('empty', solve(_vary([''])), _vary('""\n'))
check('interior', solve(_vary(['x=1'])), _vary('"x=1"\n'))
check('no cells', solve(_vary([])), _vary('\n'))
check('variant formula width', solve(['='+str(N)+'+1']), '"\'='+str(N)+'+1"\n')
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 cell in data:
        probe = cell.lstrip(' \t')
        if not cell.startswith("'") and probe[:1] in ('=', '+', '-', '@'):
            cell = probe + "'"
        cell = cell.replace('"', '""')
        out.append('"' + cell + '"')
    return ','.join(out) + '\n'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('formula', solve(_vary(['=1+1'])), _vary('"\'=1+1"\n'))
check('leading space', solve(_vary([' \t+2'])), _vary('"\' \t+2"\n'))
check('existing prefix', solve(_vary(["'=3"])), _vary('"\'=3"\n'))
check('minus', solve(_vary(['-12'])), _vary('"\'-12"\n'))
check('ordinary', solve(_vary(['text', 'a"b'])), _vary('"text","a""b"\n'))
check('empty', solve(_vary([''])), _vary('""\n'))
check('interior', solve(_vary(['x=1'])), _vary('"x=1"\n'))
check('no cells', solve(_vary([])), _vary('\n'))
check('variant formula width', solve(['='+str(N)+'+1']), '"\'='+str(N)+'+1"\n')
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.

Encode already textual comma cells for a spreadsheet-facing export. Prefix a single apostrophe if the first non-space/non-tab character is =,+,-, or @. An existing leading apostrophe is preserved without duplication. Then double embedded quotes and quote every cell. Return LF-terminated row. This is a stipulated conservative transport policy, not a universal spreadsheet security guarantee.

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 cell in data:
        probe = cell.lstrip(' \t')
        if cell.startswith("'") or probe[:1] in ('=', '+', '-', '@'):
            cell = "'" + cell
        cell = cell.replace('"', '""')
        out.append('"' + cell + '"')
    return ','.join(out) + '\n'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('formula', solve(_vary(['=1+1'])), _vary('"\'=1+1"\n'))
check('leading space', solve(_vary([' \t+2'])), _vary('"\' \t+2"\n'))
check('existing prefix', solve(_vary(["'=3"])), _vary('"\'=3"\n'))
check('minus', solve(_vary(['-12'])), _vary('"\'-12"\n'))
check('ordinary', solve(_vary(['text', 'a"b'])), _vary('"text","a""b"\n'))
check('empty', solve(_vary([''])), _vary('""\n'))
check('interior', solve(_vary(['x=1'])), _vary('"x=1"\n'))
check('no cells', solve(_vary([])), _vary('\n'))
check('variant formula width', solve(['='+str(N)+'+1']), '"\'='+str(N)+'+1"\n')
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 cell in data:
        probe = cell.lstrip(' \t')
        if cell.startswith("'") or any(x in cell for x in '=+-@'):
            cell = "'" + cell
        cell = cell.replace('"', '""')
        out.append('"' + cell + '"')
    return ','.join(out) + '\n'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('formula', solve(_vary(['=1+1'])), _vary('"\'=1+1"\n'))
check('leading space', solve(_vary([' \t+2'])), _vary('"\' \t+2"\n'))
check('existing prefix', solve(_vary(["'=3"])), _vary('"\'=3"\n'))
check('minus', solve(_vary(['-12'])), _vary('"\'-12"\n'))
check('ordinary', solve(_vary(['text', 'a"b'])), _vary('"text","a""b"\n'))
check('empty', solve(_vary([''])), _vary('""\n'))
check('interior', solve(_vary(['x=1'])), _vary('"x=1"\n'))
check('no cells', solve(_vary([])), _vary('\n'))
check('variant formula width', solve(['='+str(N)+'+1']), '"\'='+str(N)+'+1"\n')
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.

Encode already textual comma cells for a spreadsheet-facing export. Prefix a single apostrophe if the first non-space/non-tab character is =,+,-, or @. An existing leading apostrophe is preserved without duplication. Then double embedded quotes and quote every cell. Return LF-terminated row. This is a stipulated conservative transport policy, not a universal spreadsheet security guarantee.

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 cell in data:
        probe = cell.lstrip(' \t')
        if not cell.startswith("'") and any(x in probe for x in '=+-@'):
            cell = "'" + cell
        cell = cell.replace('"', '""')
        out.append('"' + cell + '"')
    return ','.join(out) + '\n'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('formula', solve(_vary(['=1+1'])), _vary('"\'=1+1"\n'))
check('leading space', solve(_vary([' \t+2'])), _vary('"\' \t+2"\n'))
check('existing prefix', solve(_vary(["'=3"])), _vary('"\'=3"\n'))
check('minus', solve(_vary(['-12'])), _vary('"\'-12"\n'))
check('ordinary', solve(_vary(['text', 'a"b'])), _vary('"text","a""b"\n'))
check('empty', solve(_vary([''])), _vary('""\n'))
check('interior', solve(_vary(['x=1'])), _vary('"x=1"\n'))
check('no cells', solve(_vary([])), _vary('\n'))
check('variant formula width', solve(['='+str(N)+'+1']), '"\'='+str(N)+'+1"\n')
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 cell in data:
        probe = cell.lstrip(' \t')
        if not cell.startswith("'") and any(x in probe for x in '=+'):
            cell = "'" + cell
        cell = cell.replace('"', '""')
        out.append('"' + cell + '"')
    return ','.join(out) + '\n'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('formula', solve(_vary(['=1+1'])), _vary('"\'=1+1"\n'))
check('leading space', solve(_vary([' \t+2'])), _vary('"\' \t+2"\n'))
check('existing prefix', solve(_vary(["'=3"])), _vary('"\'=3"\n'))
check('minus', solve(_vary(['-12'])), _vary('"\'-12"\n'))
check('ordinary', solve(_vary(['text', 'a"b'])), _vary('"text","a""b"\n'))
check('empty', solve(_vary([''])), _vary('""\n'))
check('interior', solve(_vary(['x=1'])), _vary('"x=1"\n'))
check('no cells', solve(_vary([])), _vary('\n'))
check('variant formula width', solve(['='+str(N)+'+1']), '"\'='+str(N)+'+1"\n')
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.

Encode already textual comma cells for a spreadsheet-facing export. Prefix a single apostrophe if the first non-space/non-tab character is =,+,-, or @. An existing leading apostrophe is preserved without duplication. Then double embedded quotes and quote every cell. Return LF-terminated row. This is a stipulated conservative transport policy, not a universal spreadsheet security guarantee.

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 cell in data:
        probe = cell.lstrip(' \t')
        if not cell.startswith("'") and probe[:1] in ('=', '+', '-', '@'):
            cell = "'" + cell
        cell = cell.lstrip("'").replace('"', '""')
        out.append('"' + cell + '"')
    return ','.join(out) + '\n'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('formula', solve(_vary(['=1+1'])), _vary('"\'=1+1"\n'))
check('leading space', solve(_vary([' \t+2'])), _vary('"\' \t+2"\n'))
check('existing prefix', solve(_vary(["'=3"])), _vary('"\'=3"\n'))
check('minus', solve(_vary(['-12'])), _vary('"\'-12"\n'))
check('ordinary', solve(_vary(['text', 'a"b'])), _vary('"text","a""b"\n'))
check('empty', solve(_vary([''])), _vary('""\n'))
check('interior', solve(_vary(['x=1'])), _vary('"x=1"\n'))
check('no cells', solve(_vary([])), _vary('\n'))
check('variant formula width', solve(['='+str(N)+'+1']), '"\'='+str(N)+'+1"\n')
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 cell in data:
        probe = cell.lstrip(' \t')
        if not cell.startswith("'") and probe[:1] in ('=', '+', '-', '@'):
            cell = "'" + cell
        cell = cell.replace("'", '').replace('"', '""')
        out.append('"' + cell + '"')
    return ','.join(out) + '\n'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('formula', solve(_vary(['=1+1'])), _vary('"\'=1+1"\n'))
check('leading space', solve(_vary([' \t+2'])), _vary('"\' \t+2"\n'))
check('existing prefix', solve(_vary(["'=3"])), _vary('"\'=3"\n'))
check('minus', solve(_vary(['-12'])), _vary('"\'-12"\n'))
check('ordinary', solve(_vary(['text', 'a"b'])), _vary('"text","a""b"\n'))
check('empty', solve(_vary([''])), _vary('""\n'))
check('interior', solve(_vary(['x=1'])), _vary('"x=1"\n'))
check('no cells', solve(_vary([])), _vary('\n'))
check('variant formula width', solve(['='+str(N)+'+1']), '"\'='+str(N)+'+1"\n')
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.

Encode already textual comma cells for a spreadsheet-facing export. Prefix a single apostrophe if the first non-space/non-tab character is =,+,-, or @. An existing leading apostrophe is preserved without duplication. Then double embedded quotes and quote every cell. Return LF-terminated row. This is a stipulated conservative transport policy, not a universal spreadsheet security guarantee.

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, buf, quoted, i = [], [], False, 0
    while i < len(data):
        ch=data[i]
        if ch == '"':
            if quoted and i+1 < len(data) and data[i+1] == '"':
                buf.append('"'); i += 2; continue
            quoted = not quoted
        elif ch == '#': break
        elif ch == ',' and not quoted:
            out.append(''.join(buf)); buf=[]
        else: buf.append(ch)
        i += 1
    if quoted: return None
    out.append(''.join(buf))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('comment', solve(_vary('@,x#note')), _vary(['@', 'x']))
check('quoted marker', solve(_vary('"#@",x')), _vary(['#@', 'x']))
check('escaped quote', solve(_vary('"a""#b",z')), _vary(['a"#b', 'z']))
check('spaces', solve(_vary('@  #x')), _vary(['@  ']))
check('only comment', solve(_vary('#note')), _vary(['']))
check('unclosed', solve(_vary('"@#note')), _vary(None))
check('normal', solve(_vary('@,x')), _vary(['@', 'x']))
check('comment commas', solve(_vary('@#x,y')), _vary(['@']))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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, buf, quoted, i = [], [], False, 0
    while i < len(data):
        ch=data[i]
        if ch == '"':
            if quoted and i+1 < len(data) and data[i+1] == '"':
                buf.append('"'); i += 2; continue
            quoted = not quoted
        elif ch == '#' and (not quoted or not buf): break
        elif ch == ',' and not quoted:
            out.append(''.join(buf)); buf=[]
        else: buf.append(ch)
        i += 1
    if quoted: return None
    out.append(''.join(buf))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('comment', solve(_vary('@,x#note')), _vary(['@', 'x']))
check('quoted marker', solve(_vary('"#@",x')), _vary(['#@', 'x']))
check('escaped quote', solve(_vary('"a""#b",z')), _vary(['a"#b', 'z']))
check('spaces', solve(_vary('@  #x')), _vary(['@  ']))
check('only comment', solve(_vary('#note')), _vary(['']))
check('unclosed', solve(_vary('"@#note')), _vary(None))
check('normal', solve(_vary('@,x')), _vary(['@', 'x']))
check('comment commas', solve(_vary('@#x,y')), _vary(['@']))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Split a comma record with trailing comments. A # outside double quotes ends the record; inside quotes it is data. Quotes toggle quoted state and are removed; doubled quotes inside quotes emit one quote. Whitespace before a trailing comment is data. Unterminated quoting rejects.

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, buf, quoted, i = [], [], False, 0
    while i < len(data):
        ch=data[i]
        if ch == '"':
            if quoted and i+1 < len(data) and data[i+1] == '"':
                buf.append('"'); i += 2; continue
            quoted = not quoted
        elif ch == '#' and not quoted: i += 1; continue
        elif ch == ',' and not quoted:
            out.append(''.join(buf)); buf=[]
        else: buf.append(ch)
        i += 1
    if quoted: return None
    out.append(''.join(buf))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('comment', solve(_vary('@,x#note')), _vary(['@', 'x']))
check('quoted marker', solve(_vary('"#@",x')), _vary(['#@', 'x']))
check('escaped quote', solve(_vary('"a""#b",z')), _vary(['a"#b', 'z']))
check('spaces', solve(_vary('@  #x')), _vary(['@  ']))
check('only comment', solve(_vary('#note')), _vary(['']))
check('unclosed', solve(_vary('"@#note')), _vary(None))
check('normal', solve(_vary('@,x')), _vary(['@', 'x']))
check('comment commas', solve(_vary('@#x,y')), _vary(['@']))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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, buf, quoted, i = [], [], False, 0
    while i < len(data):
        ch=data[i]
        if ch == '"':
            if quoted and i+1 < len(data) and data[i+1] == '"':
                buf.append('"'); i += 2; continue
            quoted = not quoted
        elif ch == '#' and not quoted: buf=[]
        elif ch == ',' and not quoted:
            out.append(''.join(buf)); buf=[]
        else: buf.append(ch)
        i += 1
    if quoted: return None
    out.append(''.join(buf))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('comment', solve(_vary('@,x#note')), _vary(['@', 'x']))
check('quoted marker', solve(_vary('"#@",x')), _vary(['#@', 'x']))
check('escaped quote', solve(_vary('"a""#b",z')), _vary(['a"#b', 'z']))
check('spaces', solve(_vary('@  #x')), _vary(['@  ']))
check('only comment', solve(_vary('#note')), _vary(['']))
check('unclosed', solve(_vary('"@#note')), _vary(None))
check('normal', solve(_vary('@,x')), _vary(['@', 'x']))
check('comment commas', solve(_vary('@#x,y')), _vary(['@']))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Split a comma record with trailing comments. A # outside double quotes ends the record; inside quotes it is data. Quotes toggle quoted state and are removed; doubled quotes inside quotes emit one quote. Whitespace before a trailing comment is data. Unterminated quoting rejects.

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, buf, quoted, i = [], [], False, 0
    while i < len(data):
        ch=data[i]
        if ch == '"':
            if quoted and i+1 < len(data) and data[i+1] == '"':
                buf.append('"'); i += 2; continue
            quoted = not quoted
        elif ch == '#' and not quoted: break
        elif ch == ',' and not quoted:
            out.append(''.join(buf)); buf=[]
        else: buf.append(ch)
        i += 1
    if quoted: return None
    out.append(''.join(buf).rstrip())
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('comment', solve(_vary('@,x#note')), _vary(['@', 'x']))
check('quoted marker', solve(_vary('"#@",x')), _vary(['#@', 'x']))
check('escaped quote', solve(_vary('"a""#b",z')), _vary(['a"#b', 'z']))
check('spaces', solve(_vary('@  #x')), _vary(['@  ']))
check('only comment', solve(_vary('#note')), _vary(['']))
check('unclosed', solve(_vary('"@#note')), _vary(None))
check('normal', solve(_vary('@,x')), _vary(['@', 'x']))
check('comment commas', solve(_vary('@#x,y')), _vary(['@']))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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, buf, quoted, i = [], [], False, 0
    while i < len(data):
        ch=data[i]
        if ch == '"':
            if quoted and i+1 < len(data) and data[i+1] == '"':
                buf.append('"'); i += 2; continue
            quoted = not quoted
        elif ch == '#' and not quoted: break
        elif ch == ',' and not quoted:
            out.append(''.join(buf)); buf=[]
        else: buf.append(ch)
        i += 1
    if quoted: return None
    out.append(''.join(buf).strip())
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('comment', solve(_vary('@,x#note')), _vary(['@', 'x']))
check('quoted marker', solve(_vary('"#@",x')), _vary(['#@', 'x']))
check('escaped quote', solve(_vary('"a""#b",z')), _vary(['a"#b', 'z']))
check('spaces', solve(_vary('@  #x')), _vary(['@  ']))
check('only comment', solve(_vary('#note')), _vary(['']))
check('unclosed', solve(_vary('"@#note')), _vary(None))
check('normal', solve(_vary('@,x')), _vary(['@', 'x']))
check('comment commas', solve(_vary('@#x,y')), _vary(['@']))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Split a comma record with trailing comments. A # outside double quotes ends the record; inside quotes it is data. Quotes toggle quoted state and are removed; doubled quotes inside quotes emit one quote. Whitespace before a trailing comment is data. Unterminated quoting rejects.

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, buf, quoted, i = [], [], False, 0
    while i < len(data):
        ch=data[i]
        if ch == '"':
            if quoted and i+1 < len(data) and data[i+1] == '"':
                buf.append('"'); i += 1; continue
            quoted = not quoted
        elif ch == '#' and not quoted: break
        elif ch == ',' and not quoted:
            out.append(''.join(buf)); buf=[]
        else: buf.append(ch)
        i += 1
    if quoted: return None
    out.append(''.join(buf))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('comment', solve(_vary('@,x#note')), _vary(['@', 'x']))
check('quoted marker', solve(_vary('"#@",x')), _vary(['#@', 'x']))
check('escaped quote', solve(_vary('"a""#b",z')), _vary(['a"#b', 'z']))
check('spaces', solve(_vary('@  #x')), _vary(['@  ']))
check('only comment', solve(_vary('#note')), _vary(['']))
check('unclosed', solve(_vary('"@#note')), _vary(None))
check('normal', solve(_vary('@,x')), _vary(['@', 'x']))
check('comment commas', solve(_vary('@#x,y')), _vary(['@']))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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, buf, quoted, i = [], [], False, 0
    while i < len(data):
        ch=data[i]
        if ch == '"':
            if quoted and i+1 < len(data) and data[i+1] == '"':
                buf.append('"'); i += 3; continue
            quoted = not quoted
        elif ch == '#' and not quoted: break
        elif ch == ',' and not quoted:
            out.append(''.join(buf)); buf=[]
        else: buf.append(ch)
        i += 1
    if quoted: return None
    out.append(''.join(buf))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('comment', solve(_vary('@,x#note')), _vary(['@', 'x']))
check('quoted marker', solve(_vary('"#@",x')), _vary(['#@', 'x']))
check('escaped quote', solve(_vary('"a""#b",z')), _vary(['a"#b', 'z']))
check('spaces', solve(_vary('@  #x')), _vary(['@  ']))
check('only comment', solve(_vary('#note')), _vary(['']))
check('unclosed', solve(_vary('"@#note')), _vary(None))
check('normal', solve(_vary('@,x')), _vary(['@', 'x']))
check('comment commas', solve(_vary('@#x,y')), _vary(['@']))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Split a comma record with trailing comments. A # outside double quotes ends the record; inside quotes it is data. Quotes toggle quoted state and are removed; doubled quotes inside quotes emit one quote. Whitespace before a trailing comment is data. Unterminated quoting rejects.

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, buf, quoted, i = [], [], False, 0
    while i < len(data):
        ch=data[i]
        if ch == '"':
            if quoted and i+1 < len(data) and data[i+1] == '"':
                buf.append('"'); i += 2; continue
            quoted = not quoted
        elif ch == '#' and not quoted: break
        elif ch == ',' and not quoted:
            out.append(''.join(buf)); buf=[]
        else: buf.append(ch)
        i += 1
    if quoted: quoted=False
    out.append(''.join(buf))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('comment', solve(_vary('@,x#note')), _vary(['@', 'x']))
check('quoted marker', solve(_vary('"#@",x')), _vary(['#@', 'x']))
check('escaped quote', solve(_vary('"a""#b",z')), _vary(['a"#b', 'z']))
check('spaces', solve(_vary('@  #x')), _vary(['@  ']))
check('only comment', solve(_vary('#note')), _vary(['']))
check('unclosed', solve(_vary('"@#note')), _vary(None))
check('normal', solve(_vary('@,x')), _vary(['@', 'x']))
check('comment commas', solve(_vary('@#x,y')), _vary(['@']))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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, buf, quoted, i = [], [], False, 0
    while i < len(data):
        ch=data[i]
        if ch == '"':
            if quoted and i+1 < len(data) and data[i+1] == '"':
                buf.append('"'); i += 2; continue
            quoted = not quoted
        elif ch == '#' and not quoted: break
        elif ch == ',' and not quoted:
            out.append(''.join(buf)); buf=[]
        else: buf.append(ch)
        i += 1
    if quoted and '#' not in data: return None
    out.append(''.join(buf))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('comment', solve(_vary('@,x#note')), _vary(['@', 'x']))
check('quoted marker', solve(_vary('"#@",x')), _vary(['#@', 'x']))
check('escaped quote', solve(_vary('"a""#b",z')), _vary(['a"#b', 'z']))
check('spaces', solve(_vary('@  #x')), _vary(['@  ']))
check('only comment', solve(_vary('#note')), _vary(['']))
check('unclosed', solve(_vary('"@#note')), _vary(None))
check('normal', solve(_vary('@,x')), _vary(['@', 'x']))
check('comment commas', solve(_vary('@#x,y')), _vary(['@']))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

Split a comma record with trailing comments. A # outside double quotes ends the record; inside quotes it is data. Quotes toggle quoted state and are removed; doubled quotes inside quotes emit one quote. Whitespace before a trailing comment is data. Unterminated quoting rejects.

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):
    cells=data.split(',')
    if len(cells)<2: return None
    head=cells[0]
    tail=cells[-1]
    rest=cells[1:]
    return {'head':head,'rest':rest,'tail':tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rest', solve(_vary('a,@,x,z')), _vary({'head': 'a', 'rest': ['@', 'x'], 'tail': 'z'}))
check('none', solve(_vary('a,z')), _vary({'head': 'a', 'rest': [], 'tail': 'z'}))
check('empty rest', solve(_vary('a,,z')), _vary({'head': 'a', 'rest': [''], 'tail': 'z'}))
check('two empties', solve(_vary(',')), _vary({'head': '', 'rest': [], 'tail': ''}))
check('short', solve(_vary('@')), _vary(None))
check('one rest', solve(_vary('a,@,z')), _vary({'head': 'a', 'rest': ['@'], 'tail': 'z'}))
check('trailing', solve(_vary('a,@,')), _vary({'head': 'a', 'rest': ['@'], 'tail': ''}))
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):
    cells=data.split(',')
    if len(cells)<2: return None
    head=cells[0]
    tail=cells[-1]
    rest=cells[:-1]
    return {'head':head,'rest':rest,'tail':tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rest', solve(_vary('a,@,x,z')), _vary({'head': 'a', 'rest': ['@', 'x'], 'tail': 'z'}))
check('none', solve(_vary('a,z')), _vary({'head': 'a', 'rest': [], 'tail': 'z'}))
check('empty rest', solve(_vary('a,,z')), _vary({'head': 'a', 'rest': [''], 'tail': 'z'}))
check('two empties', solve(_vary(',')), _vary({'head': '', 'rest': [], 'tail': ''}))
check('short', solve(_vary('@')), _vary(None))
check('one rest', solve(_vary('a,@,z')), _vary({'head': 'a', 'rest': ['@'], 'tail': 'z'}))
check('trailing', solve(_vary('a,@,')), _vary({'head': 'a', 'rest': ['@'], 'tail': ''}))
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.

Bind a parsed comma row to an exact schema [head, ..., tail] where the middle ... captures zero or more fields as a list. The first and last physical cells bind head and tail; at least two cells are required. The rest list preserves empty cells and order.

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):
    cells=data.split(',')
    if len(cells)<2: return None
    head=cells[0]
    tail=cells[-1]
    rest=cells[2:-1]
    return {'head':head,'rest':rest,'tail':tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rest', solve(_vary('a,@,x,z')), _vary({'head': 'a', 'rest': ['@', 'x'], 'tail': 'z'}))
check('none', solve(_vary('a,z')), _vary({'head': 'a', 'rest': [], 'tail': 'z'}))
check('empty rest', solve(_vary('a,,z')), _vary({'head': 'a', 'rest': [''], 'tail': 'z'}))
check('two empties', solve(_vary(',')), _vary({'head': '', 'rest': [], 'tail': ''}))
check('short', solve(_vary('@')), _vary(None))
check('one rest', solve(_vary('a,@,z')), _vary({'head': 'a', 'rest': ['@'], 'tail': 'z'}))
check('trailing', solve(_vary('a,@,')), _vary({'head': 'a', 'rest': ['@'], 'tail': ''}))
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):
    cells=data.split(',')
    if len(cells)<2: return None
    head=cells[0]
    tail=cells[-1]
    rest=cells[1:-2]
    return {'head':head,'rest':rest,'tail':tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rest', solve(_vary('a,@,x,z')), _vary({'head': 'a', 'rest': ['@', 'x'], 'tail': 'z'}))
check('none', solve(_vary('a,z')), _vary({'head': 'a', 'rest': [], 'tail': 'z'}))
check('empty rest', solve(_vary('a,,z')), _vary({'head': 'a', 'rest': [''], 'tail': 'z'}))
check('two empties', solve(_vary(',')), _vary({'head': '', 'rest': [], 'tail': ''}))
check('short', solve(_vary('@')), _vary(None))
check('one rest', solve(_vary('a,@,z')), _vary({'head': 'a', 'rest': ['@'], 'tail': 'z'}))
check('trailing', solve(_vary('a,@,')), _vary({'head': 'a', 'rest': ['@'], 'tail': ''}))
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.

Bind a parsed comma row to an exact schema [head, ..., tail] where the middle ... captures zero or more fields as a list. The first and last physical cells bind head and tail; at least two cells are required. The rest list preserves empty cells and order.

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):
    cells=data.split(',')
    if len(cells)<2: return None
    head=cells[0]
    tail=cells[-1]
    rest=','.join(cells[1:-1])
    return {'head':head,'rest':rest,'tail':tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rest', solve(_vary('a,@,x,z')), _vary({'head': 'a', 'rest': ['@', 'x'], 'tail': 'z'}))
check('none', solve(_vary('a,z')), _vary({'head': 'a', 'rest': [], 'tail': 'z'}))
check('empty rest', solve(_vary('a,,z')), _vary({'head': 'a', 'rest': [''], 'tail': 'z'}))
check('two empties', solve(_vary(',')), _vary({'head': '', 'rest': [], 'tail': ''}))
check('short', solve(_vary('@')), _vary(None))
check('one rest', solve(_vary('a,@,z')), _vary({'head': 'a', 'rest': ['@'], 'tail': 'z'}))
check('trailing', solve(_vary('a,@,')), _vary({'head': 'a', 'rest': ['@'], 'tail': ''}))
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):
    cells=data.split(',')
    if len(cells)<2: return None
    head=cells[0]
    tail=cells[-1]
    rest=''.join(cells[1:-1])
    return {'head':head,'rest':rest,'tail':tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rest', solve(_vary('a,@,x,z')), _vary({'head': 'a', 'rest': ['@', 'x'], 'tail': 'z'}))
check('none', solve(_vary('a,z')), _vary({'head': 'a', 'rest': [], 'tail': 'z'}))
check('empty rest', solve(_vary('a,,z')), _vary({'head': 'a', 'rest': [''], 'tail': 'z'}))
check('two empties', solve(_vary(',')), _vary({'head': '', 'rest': [], 'tail': ''}))
check('short', solve(_vary('@')), _vary(None))
check('one rest', solve(_vary('a,@,z')), _vary({'head': 'a', 'rest': ['@'], 'tail': 'z'}))
check('trailing', solve(_vary('a,@,')), _vary({'head': 'a', 'rest': ['@'], 'tail': ''}))
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.

Bind a parsed comma row to an exact schema [head, ..., tail] where the middle ... captures zero or more fields as a list. The first and last physical cells bind head and tail; at least two cells are required. The rest list preserves empty cells and order.

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):
    cells=data.split(',')
    if len(cells)<2: return None
    head=cells[0]
    tail=cells[1]
    rest=cells[1:-1]
    return {'head':head,'rest':rest,'tail':tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rest', solve(_vary('a,@,x,z')), _vary({'head': 'a', 'rest': ['@', 'x'], 'tail': 'z'}))
check('none', solve(_vary('a,z')), _vary({'head': 'a', 'rest': [], 'tail': 'z'}))
check('empty rest', solve(_vary('a,,z')), _vary({'head': 'a', 'rest': [''], 'tail': 'z'}))
check('two empties', solve(_vary(',')), _vary({'head': '', 'rest': [], 'tail': ''}))
check('short', solve(_vary('@')), _vary(None))
check('one rest', solve(_vary('a,@,z')), _vary({'head': 'a', 'rest': ['@'], 'tail': 'z'}))
check('trailing', solve(_vary('a,@,')), _vary({'head': 'a', 'rest': ['@'], 'tail': ''}))
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):
    cells=data.split(',')
    if len(cells)<2: return None
    head=cells[0]
    tail=cells[min(2,len(cells)-1)]
    rest=cells[1:-1]
    return {'head':head,'rest':rest,'tail':tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rest', solve(_vary('a,@,x,z')), _vary({'head': 'a', 'rest': ['@', 'x'], 'tail': 'z'}))
check('none', solve(_vary('a,z')), _vary({'head': 'a', 'rest': [], 'tail': 'z'}))
check('empty rest', solve(_vary('a,,z')), _vary({'head': 'a', 'rest': [''], 'tail': 'z'}))
check('two empties', solve(_vary(',')), _vary({'head': '', 'rest': [], 'tail': ''}))
check('short', solve(_vary('@')), _vary(None))
check('one rest', solve(_vary('a,@,z')), _vary({'head': 'a', 'rest': ['@'], 'tail': 'z'}))
check('trailing', solve(_vary('a,@,')), _vary({'head': 'a', 'rest': ['@'], 'tail': ''}))
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.

Bind a parsed comma row to an exact schema [head, ..., tail] where the middle ... captures zero or more fields as a list. The first and last physical cells bind head and tail; at least two cells are required. The rest list preserves empty cells and order.

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):
    cells=data.split(',')
    if len(cells)<2: return None
    head=cells[0]
    tail=cells[-1]
    rest=[x for x in cells[1:-1] if x]
    return {'head':head,'rest':rest,'tail':tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rest', solve(_vary('a,@,x,z')), _vary({'head': 'a', 'rest': ['@', 'x'], 'tail': 'z'}))
check('none', solve(_vary('a,z')), _vary({'head': 'a', 'rest': [], 'tail': 'z'}))
check('empty rest', solve(_vary('a,,z')), _vary({'head': 'a', 'rest': [''], 'tail': 'z'}))
check('two empties', solve(_vary(',')), _vary({'head': '', 'rest': [], 'tail': ''}))
check('short', solve(_vary('@')), _vary(None))
check('one rest', solve(_vary('a,@,z')), _vary({'head': 'a', 'rest': ['@'], 'tail': 'z'}))
check('trailing', solve(_vary('a,@,')), _vary({'head': 'a', 'rest': ['@'], 'tail': ''}))
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):
    cells=data.split(',')
    if len(cells)<2: return None
    head=cells[0]
    tail=cells[-1]
    rest=[x for x in cells[1:-1] if x.strip()]
    return {'head':head,'rest':rest,'tail':tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rest', solve(_vary('a,@,x,z')), _vary({'head': 'a', 'rest': ['@', 'x'], 'tail': 'z'}))
check('none', solve(_vary('a,z')), _vary({'head': 'a', 'rest': [], 'tail': 'z'}))
check('empty rest', solve(_vary('a,,z')), _vary({'head': 'a', 'rest': [''], 'tail': 'z'}))
check('two empties', solve(_vary(',')), _vary({'head': '', 'rest': [], 'tail': ''}))
check('short', solve(_vary('@')), _vary(None))
check('one rest', solve(_vary('a,@,z')), _vary({'head': 'a', 'rest': ['@'], 'tail': 'z'}))
check('trailing', solve(_vary('a,@,')), _vary({'head': 'a', 'rest': ['@'], 'tail': ''}))
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.

Bind a parsed comma row to an exact schema [head, ..., tail] where the middle ... captures zero or more fields as a list. The first and last physical cells bind head and tail; at least two cells are required. The rest list preserves empty cells and order.

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=[line.split(',') for line in data]
    width=len(rows[0]) if rows else 0
    out=[]
    for col in range(width):
        out.append([row[col] if col<len(row) else None for row in rows])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ragged', solve(_vary(['@,a,b', 'x'])), _vary([['@', 'x'], ['a', None], ['b', None]]))
check('later wider', solve(_vary(['@', 'x,y'])), _vary([['@', 'x'], [None, 'y']]))
check('explicit empty', solve(_vary(['@,', 'x'])), _vary([['@', 'x'], ['', None]]))
check('empty input', solve(_vary([])), _vary([]))
check('one empty', solve(_vary([''])), _vary([['']]))
check('rectangular', solve(_vary(['a,b', 'c,d'])), _vary([['a', 'c'], ['b', 'd']]))
check('unsorted', solve(_vary(['z,1', 'a,2'])), _vary([['z', 'a'], ['1', '2']]))
check('three rows', solve(_vary(['@,x', 'y', 'z,w'])), _vary([['@', 'y', 'z'], ['x', None, 'w']]))
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=[line.split(',') for line in data]
    width=min((len(row) for row in rows),default=0)
    out=[]
    for col in range(width):
        out.append([row[col] if col<len(row) else None for row in rows])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ragged', solve(_vary(['@,a,b', 'x'])), _vary([['@', 'x'], ['a', None], ['b', None]]))
check('later wider', solve(_vary(['@', 'x,y'])), _vary([['@', 'x'], [None, 'y']]))
check('explicit empty', solve(_vary(['@,', 'x'])), _vary([['@', 'x'], ['', None]]))
check('empty input', solve(_vary([])), _vary([]))
check('one empty', solve(_vary([''])), _vary([['']]))
check('rectangular', solve(_vary(['a,b', 'c,d'])), _vary([['a', 'c'], ['b', 'd']]))
check('unsorted', solve(_vary(['z,1', 'a,2'])), _vary([['z', 'a'], ['1', '2']]))
check('three rows', solve(_vary(['@,x', 'y', 'z,w'])), _vary([['@', 'y', 'z'], ['x', None, 'w']]))
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.

Transpose comma records into physical columns. Pad missing trailing cells with null, preserving explicit empty strings. Width is the largest source row width; empty input has no columns. Output columns are in increasing physical position.

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=[line.split(',') for line in data]
    width=max((len(row) for row in rows),default=0)
    out=[]
    for col in range(width):
        out.append([row[col] if col<len(row) else '' for row in rows])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ragged', solve(_vary(['@,a,b', 'x'])), _vary([['@', 'x'], ['a', None], ['b', None]]))
check('later wider', solve(_vary(['@', 'x,y'])), _vary([['@', 'x'], [None, 'y']]))
check('explicit empty', solve(_vary(['@,', 'x'])), _vary([['@', 'x'], ['', None]]))
check('empty input', solve(_vary([])), _vary([]))
check('one empty', solve(_vary([''])), _vary([['']]))
check('rectangular', solve(_vary(['a,b', 'c,d'])), _vary([['a', 'c'], ['b', 'd']]))
check('unsorted', solve(_vary(['z,1', 'a,2'])), _vary([['z', 'a'], ['1', '2']]))
check('three rows', solve(_vary(['@,x', 'y', 'z,w'])), _vary([['@', 'y', 'z'], ['x', None, 'w']]))
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=[line.split(',') for line in data]
    width=max((len(row) for row in rows),default=0)
    out=[]
    for col in range(width):
        out.append([row[col] if col<len(row) else 0 for row in rows])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ragged', solve(_vary(['@,a,b', 'x'])), _vary([['@', 'x'], ['a', None], ['b', None]]))
check('later wider', solve(_vary(['@', 'x,y'])), _vary([['@', 'x'], [None, 'y']]))
check('explicit empty', solve(_vary(['@,', 'x'])), _vary([['@', 'x'], ['', None]]))
check('empty input', solve(_vary([])), _vary([]))
check('one empty', solve(_vary([''])), _vary([['']]))
check('rectangular', solve(_vary(['a,b', 'c,d'])), _vary([['a', 'c'], ['b', 'd']]))
check('unsorted', solve(_vary(['z,1', 'a,2'])), _vary([['z', 'a'], ['1', '2']]))
check('three rows', solve(_vary(['@,x', 'y', 'z,w'])), _vary([['@', 'y', 'z'], ['x', None, 'w']]))
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.

Transpose comma records into physical columns. Pad missing trailing cells with null, preserving explicit empty strings. Width is the largest source row width; empty input has no columns. Output columns are in increasing physical position.

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=[line.split(',') for line in data]
    width=max((len(row) for row in rows),default=0)
    out=[]
    for col in range(width):
        out.append([row[col] for row in rows if col<len(row)])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ragged', solve(_vary(['@,a,b', 'x'])), _vary([['@', 'x'], ['a', None], ['b', None]]))
check('later wider', solve(_vary(['@', 'x,y'])), _vary([['@', 'x'], [None, 'y']]))
check('explicit empty', solve(_vary(['@,', 'x'])), _vary([['@', 'x'], ['', None]]))
check('empty input', solve(_vary([])), _vary([]))
check('one empty', solve(_vary([''])), _vary([['']]))
check('rectangular', solve(_vary(['a,b', 'c,d'])), _vary([['a', 'c'], ['b', 'd']]))
check('unsorted', solve(_vary(['z,1', 'a,2'])), _vary([['z', 'a'], ['1', '2']]))
check('three rows', solve(_vary(['@,x', 'y', 'z,w'])), _vary([['@', 'y', 'z'], ['x', None, 'w']]))
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=[line.split(',') for line in data]
    width=max((len(row) for row in rows),default=0)
    out=[]
    for col in range(width):
        out.append([row[col] for row in rows if col<len(row) and row[col]])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ragged', solve(_vary(['@,a,b', 'x'])), _vary([['@', 'x'], ['a', None], ['b', None]]))
check('later wider', solve(_vary(['@', 'x,y'])), _vary([['@', 'x'], [None, 'y']]))
check('explicit empty', solve(_vary(['@,', 'x'])), _vary([['@', 'x'], ['', None]]))
check('empty input', solve(_vary([])), _vary([]))
check('one empty', solve(_vary([''])), _vary([['']]))
check('rectangular', solve(_vary(['a,b', 'c,d'])), _vary([['a', 'c'], ['b', 'd']]))
check('unsorted', solve(_vary(['z,1', 'a,2'])), _vary([['z', 'a'], ['1', '2']]))
check('three rows', solve(_vary(['@,x', 'y', 'z,w'])), _vary([['@', 'y', 'z'], ['x', None, 'w']]))
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.

Transpose comma records into physical columns. Pad missing trailing cells with null, preserving explicit empty strings. Width is the largest source row width; empty input has no columns. Output columns are in increasing physical position.

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=[line.split(',') for line in data]
    width=max((len(row) for row in rows),default=0)
    out=[]
    for col in reversed(range(width)):
        out.append([row[col] if col<len(row) else None for row in rows])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ragged', solve(_vary(['@,a,b', 'x'])), _vary([['@', 'x'], ['a', None], ['b', None]]))
check('later wider', solve(_vary(['@', 'x,y'])), _vary([['@', 'x'], [None, 'y']]))
check('explicit empty', solve(_vary(['@,', 'x'])), _vary([['@', 'x'], ['', None]]))
check('empty input', solve(_vary([])), _vary([]))
check('one empty', solve(_vary([''])), _vary([['']]))
check('rectangular', solve(_vary(['a,b', 'c,d'])), _vary([['a', 'c'], ['b', 'd']]))
check('unsorted', solve(_vary(['z,1', 'a,2'])), _vary([['z', 'a'], ['1', '2']]))
check('three rows', solve(_vary(['@,x', 'y', 'z,w'])), _vary([['@', 'y', 'z'], ['x', None, 'w']]))
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=[line.split(',') for line in data]
    width=max((len(row) for row in rows),default=0)
    out=[]
    for col in range(max(width-1,0)):
        out.append([row[col] if col<len(row) else None for row in rows])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ragged', solve(_vary(['@,a,b', 'x'])), _vary([['@', 'x'], ['a', None], ['b', None]]))
check('later wider', solve(_vary(['@', 'x,y'])), _vary([['@', 'x'], [None, 'y']]))
check('explicit empty', solve(_vary(['@,', 'x'])), _vary([['@', 'x'], ['', None]]))
check('empty input', solve(_vary([])), _vary([]))
check('one empty', solve(_vary([''])), _vary([['']]))
check('rectangular', solve(_vary(['a,b', 'c,d'])), _vary([['a', 'c'], ['b', 'd']]))
check('unsorted', solve(_vary(['z,1', 'a,2'])), _vary([['z', 'a'], ['1', '2']]))
check('three rows', solve(_vary(['@,x', 'y', 'z,w'])), _vary([['@', 'y', 'z'], ['x', None, 'w']]))
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.

Transpose comma records into physical columns. Pad missing trailing cells with null, preserving explicit empty strings. Width is the largest source row width; empty input has no columns. Output columns are in increasing physical position.

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=[line.split(',') for line in data]
    width=max((len(row) for row in rows),default=0)
    out=[]
    for col in range(width):
        out.append([row[col] if col<len(row) else None for row in reversed(rows)])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ragged', solve(_vary(['@,a,b', 'x'])), _vary([['@', 'x'], ['a', None], ['b', None]]))
check('later wider', solve(_vary(['@', 'x,y'])), _vary([['@', 'x'], [None, 'y']]))
check('explicit empty', solve(_vary(['@,', 'x'])), _vary([['@', 'x'], ['', None]]))
check('empty input', solve(_vary([])), _vary([]))
check('one empty', solve(_vary([''])), _vary([['']]))
check('rectangular', solve(_vary(['a,b', 'c,d'])), _vary([['a', 'c'], ['b', 'd']]))
check('unsorted', solve(_vary(['z,1', 'a,2'])), _vary([['z', 'a'], ['1', '2']]))
check('three rows', solve(_vary(['@,x', 'y', 'z,w'])), _vary([['@', 'y', 'z'], ['x', None, 'w']]))
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=[line.split(',') for line in data]
    width=max((len(row) for row in rows),default=0)
    out=[]
    for col in range(width):
        out.append([row[col] if col<len(row) else None for row in sorted(rows)])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ragged', solve(_vary(['@,a,b', 'x'])), _vary([['@', 'x'], ['a', None], ['b', None]]))
check('later wider', solve(_vary(['@', 'x,y'])), _vary([['@', 'x'], [None, 'y']]))
check('explicit empty', solve(_vary(['@,', 'x'])), _vary([['@', 'x'], ['', None]]))
check('empty input', solve(_vary([])), _vary([]))
check('one empty', solve(_vary([''])), _vary([['']]))
check('rectangular', solve(_vary(['a,b', 'c,d'])), _vary([['a', 'c'], ['b', 'd']]))
check('unsorted', solve(_vary(['z,1', 'a,2'])), _vary([['z', 'a'], ['1', '2']]))
check('three rows', solve(_vary(['@,x', 'y', 'z,w'])), _vary([['@', 'y', 'z'], ['x', None, 'w']]))
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.

Transpose comma records into physical columns. Pad missing trailing cells with null, preserving explicit empty strings. Width is the largest source row width; empty input has no columns. Output columns are in increasing physical position.

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):
    if not data['rows']: return data['existing']
    text=data['existing']
    if True: text+=','.join(data['header']) + '\n'
    elif not text.endswith('\n'): text+='\n'
    for row in data['rows']:
        text+=','.join(row)+'\n'
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('new', solve(_vary({'existing': '', 'header': ['a', 'b'], 'rows': [['@', 'x']]})), _vary('a,b\n@,x\n'))
check('terminated', solve(_vary({'existing': 'a,b\nq,z\n', 'header': ['a', 'b'], 'rows': [['@', 'x']]})), _vary('a,b\nq,z\n@,x\n'))
check('unterminated', solve(_vary({'existing': 'a,b\nq,z', 'header': ['a', 'b'], 'rows': [['@', 'x']]})), _vary('a,b\nq,z\n@,x\n'))
check('no new', solve(_vary({'existing': 'a,b', 'header': ['a', 'b'], 'rows': []})), _vary('a,b'))
check('empty untouched', solve(_vary({'existing': '', 'header': ['a', 'b'], 'rows': []})), _vary(''))
check('two appended', solve(_vary({'existing': 'a\n', 'header': ['a'], 'rows': [['@'], ['z']]})), _vary('a\n@\nz\n'))
check('empty cells', solve(_vary({'existing': '', 'header': ['a', 'b'], 'rows': [['', '']]})), _vary('a,b\n,\n'))
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):
    if not data['rows']: return data['existing']
    text=data['existing']
    if not text or text.endswith('\n'): text+=','.join(data['header']) + '\n'
    elif not text.endswith('\n'): text+='\n'
    for row in data['rows']:
        text+=','.join(row)+'\n'
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('new', solve(_vary({'existing': '', 'header': ['a', 'b'], 'rows': [['@', 'x']]})), _vary('a,b\n@,x\n'))
check('terminated', solve(_vary({'existing': 'a,b\nq,z\n', 'header': ['a', 'b'], 'rows': [['@', 'x']]})), _vary('a,b\nq,z\n@,x\n'))
check('unterminated', solve(_vary({'existing': 'a,b\nq,z', 'header': ['a', 'b'], 'rows': [['@', 'x']]})), _vary('a,b\nq,z\n@,x\n'))
check('no new', solve(_vary({'existing': 'a,b', 'header': ['a', 'b'], 'rows': []})), _vary('a,b'))
check('empty untouched', solve(_vary({'existing': '', 'header': ['a', 'b'], 'rows': []})), _vary(''))
check('two appended', solve(_vary({'existing': 'a\n', 'header': ['a'], 'rows': [['@'], ['z']]})), _vary('a\n@\nz\n'))
check('empty cells', solve(_vary({'existing': '', 'header': ['a', 'b'], 'rows': [['', '']]})), _vary('a,b\n,\n'))
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.

Append comma rows to existing serialized text. Existing text is either empty or ends in a complete physical record, optionally lacking its final LF. On an empty file emit the supplied header once, followed by new rows. For a nonempty unterminated tail insert exactly one LF before new rows. With no new rows return existing text unchanged.

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):
    if not data['rows']: return data['existing']
    text=data['existing']
    if not text: text=','.join(data['header']) + '\n'
    elif False: text+='\n'
    for row in data['rows']:
        text+=','.join(row)+'\n'
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('new', solve(_vary({'existing': '', 'header': ['a', 'b'], 'rows': [['@', 'x']]})), _vary('a,b\n@,x\n'))
check('terminated', solve(_vary({'existing': 'a,b\nq,z\n', 'header': ['a', 'b'], 'rows': [['@', 'x']]})), _vary('a,b\nq,z\n@,x\n'))
check('unterminated', solve(_vary({'existing': 'a,b\nq,z', 'header': ['a', 'b'], 'rows': [['@', 'x']]})), _vary('a,b\nq,z\n@,x\n'))
check('no new', solve(_vary({'existing': 'a,b', 'header': ['a', 'b'], 'rows': []})), _vary('a,b'))
check('empty untouched', solve(_vary({'existing': '', 'header': ['a', 'b'], 'rows': []})), _vary(''))
check('two appended', solve(_vary({'existing': 'a\n', 'header': ['a'], 'rows': [['@'], ['z']]})), _vary('a\n@\nz\n'))
check('empty cells', solve(_vary({'existing': '', 'header': ['a', 'b'], 'rows': [['', '']]})), _vary('a,b\n,\n'))
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):
    if not data['rows']: return data['existing']
    text=data['existing']
    if not text: text=','.join(data['header']) + '\n'
    elif not text.endswith('\n'): text+=','
    for row in data['rows']:
        text+=','.join(row)+'\n'
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('new', solve(_vary({'existing': '', 'header': ['a', 'b'], 'rows': [['@', 'x']]})), _vary('a,b\n@,x\n'))
check('terminated', solve(_vary({'existing': 'a,b\nq,z\n', 'header': ['a', 'b'], 'rows': [['@', 'x']]})), _vary('a,b\nq,z\n@,x\n'))
check('unterminated', solve(_vary({'existing': 'a,b\nq,z', 'header': ['a', 'b'], 'rows': [['@', 'x']]})), _vary('a,b\nq,z\n@,x\n'))
check('no new', solve(_vary({'existing': 'a,b', 'header': ['a', 'b'], 'rows': []})), _vary('a,b'))
check('empty untouched', solve(_vary({'existing': '', 'header': ['a', 'b'], 'rows': []})), _vary(''))
check('two appended', solve(_vary({'existing': 'a\n', 'header': ['a'], 'rows': [['@'], ['z']]})), _vary('a\n@\nz\n'))
check('empty cells', solve(_vary({'existing': '', 'header': ['a', 'b'], 'rows': [['', '']]})), _vary('a,b\n,\n'))
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.

Append comma rows to existing serialized text. Existing text is either empty or ends in a complete physical record, optionally lacking its final LF. On an empty file emit the supplied header once, followed by new rows. For a nonempty unterminated tail insert exactly one LF before new rows. With no new rows return existing text unchanged.

split: open-access