broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        rows,expressions,seed=d
        counter=seed; cache={}; result=[]
        for row in rows:
            projected=[]
            for kind,key in expressions:
                if kind=='row': value=row
                elif kind=='stable':
                    if key not in cache: counter+=1; cache[key]=counter
                    value=cache[key]
                else:
                    if key not in cache: counter+=1; cache[key]=counter
                    value=cache[key]
                projected.append(value)
            result.append(projected)
        return result
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 1]), [[2, 3]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 1]), [[2], [2]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 1]), [[2, 3]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 1]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 1]), [[2, 9, 3]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 1]), [[9, 2, 3]])
    check('empty projection', solve([[9, 2], [], 1]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 1]), [])
elif N == 2:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 2]), [[3, 4]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 2]), [[3], [3]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 2]), [[3, 4]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 2]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 2]), [[3, 9, 4]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 2]), [[9, 3, 4]])
    check('empty projection', solve([[9, 2], [], 2]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 2]), [])
elif N == 3:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 3]), [[4, 5]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 3]), [[4], [4]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 3]), [[4, 5]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 3]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 3]), [[4, 9, 5]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 3]), [[9, 4, 5]])
    check('empty projection', solve([[9, 2], [], 3]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 3]), [])
elif N == 4:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 4]), [[5, 6]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 4]), [[5], [5]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 4]), [[5, 6]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 4]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 4]), [[5, 9, 6]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 4]), [[9, 5, 6]])
    check('empty projection', solve([[9, 2], [], 4]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 4]), [])
elif N == 5:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 5]), [[6, 7]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 5]), [[6], [6]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 5]), [[6, 7]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 5]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 5]), [[6, 9, 7]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 5]), [[9, 6, 7]])
    check('empty projection', solve([[9, 2], [], 5]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 5]), [])
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

N = 1
observations = []
def solve(d):
    try:
        rows,expressions,seed=d
        counter=seed; cache={}; result=[]
        for row in rows:
            projected=[]
            for kind,key in expressions:
                if kind=='row': value=row
                elif kind=='stable':
                    if key not in cache: counter+=1; cache[key]=counter
                    value=cache[key]
                else:
                    if key not in cache or not projected: counter+=1; cache[key]=counter
                    value=cache[key]
                projected.append(value)
            result.append(projected)
        return result
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 1]), [[2, 3]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 1]), [[2], [2]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 1]), [[2, 3]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 1]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 1]), [[2, 9, 3]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 1]), [[9, 2, 3]])
    check('empty projection', solve([[9, 2], [], 1]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 1]), [])
elif N == 2:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 2]), [[3, 4]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 2]), [[3], [3]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 2]), [[3, 4]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 2]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 2]), [[3, 9, 4]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 2]), [[9, 3, 4]])
    check('empty projection', solve([[9, 2], [], 2]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 2]), [])
elif N == 3:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 3]), [[4, 5]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 3]), [[4], [4]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 3]), [[4, 5]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 3]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 3]), [[4, 9, 5]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 3]), [[9, 4, 5]])
    check('empty projection', solve([[9, 2], [], 3]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 3]), [])
elif N == 4:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 4]), [[5, 6]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 4]), [[5], [5]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 4]), [[5, 6]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 4]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 4]), [[5, 9, 6]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 4]), [[9, 5, 6]])
    check('empty projection', solve([[9, 2], [], 4]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 4]), [])
elif N == 5:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 5]), [[6, 7]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 5]), [[6], [6]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 5]), [[6, 7]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 5]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 5]), [[6, 9, 7]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 5]), [[9, 6, 7]])
    check('empty projection', solve([[9, 2], [], 5]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 5]), [])
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:
Volatile projection calls are cached by expression key.

Evaluate projection expressions over row IDs. Expressions are [kind,key] with stable, volatile, or row. A deterministic counter starts at seed and increments on each stable first call or volatile call; stable calls cache by key for the whole query. Row expressions return the current row ID. Preserve expression and row order.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        rows,expressions,seed=d
        counter=seed; cache={}; result=[]
        for row in rows:
            projected=[]; cache={}
            for kind,key in expressions:
                if kind=='row': value=row
                elif kind=='stable':
                    if key not in cache: counter+=1; cache[key]=counter
                    value=cache[key]
                else:
                    counter+=1; value=counter
                projected.append(value)
            result.append(projected)
        return result
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 1]), [[2, 3]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 1]), [[2], [2]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 1]), [[2, 3]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 1]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 1]), [[2, 9, 3]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 1]), [[9, 2, 3]])
    check('empty projection', solve([[9, 2], [], 1]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 1]), [])
elif N == 2:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 2]), [[3, 4]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 2]), [[3], [3]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 2]), [[3, 4]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 2]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 2]), [[3, 9, 4]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 2]), [[9, 3, 4]])
    check('empty projection', solve([[9, 2], [], 2]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 2]), [])
elif N == 3:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 3]), [[4, 5]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 3]), [[4], [4]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 3]), [[4, 5]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 3]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 3]), [[4, 9, 5]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 3]), [[9, 4, 5]])
    check('empty projection', solve([[9, 2], [], 3]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 3]), [])
elif N == 4:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 4]), [[5, 6]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 4]), [[5], [5]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 4]), [[5, 6]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 4]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 4]), [[5, 9, 6]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 4]), [[9, 5, 6]])
    check('empty projection', solve([[9, 2], [], 4]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 4]), [])
elif N == 5:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 5]), [[6, 7]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 5]), [[6], [6]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 5]), [[6, 7]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 5]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 5]), [[6, 9, 7]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 5]), [[9, 6, 7]])
    check('empty projection', solve([[9, 2], [], 5]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 5]), [])
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

N = 1
observations = []
def solve(d):
    try:
        rows,expressions,seed=d
        counter=seed; cache={}; result=[]
        for row in rows:
            projected=[]; cache={k:v for k,v in cache.items() if False}
            for kind,key in expressions:
                if kind=='row': value=row
                elif kind=='stable':
                    if key not in cache: counter+=1; cache[key]=counter
                    value=cache[key]
                else:
                    counter+=1; value=counter
                projected.append(value)
            result.append(projected)
        return result
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 1]), [[2, 3]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 1]), [[2], [2]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 1]), [[2, 3]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 1]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 1]), [[2, 9, 3]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 1]), [[9, 2, 3]])
    check('empty projection', solve([[9, 2], [], 1]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 1]), [])
elif N == 2:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 2]), [[3, 4]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 2]), [[3], [3]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 2]), [[3, 4]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 2]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 2]), [[3, 9, 4]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 2]), [[9, 3, 4]])
    check('empty projection', solve([[9, 2], [], 2]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 2]), [])
elif N == 3:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 3]), [[4, 5]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 3]), [[4], [4]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 3]), [[4, 5]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 3]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 3]), [[4, 9, 5]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 3]), [[9, 4, 5]])
    check('empty projection', solve([[9, 2], [], 3]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 3]), [])
elif N == 4:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 4]), [[5, 6]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 4]), [[5], [5]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 4]), [[5, 6]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 4]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 4]), [[5, 9, 6]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 4]), [[9, 5, 6]])
    check('empty projection', solve([[9, 2], [], 4]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 4]), [])
elif N == 5:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 5]), [[6, 7]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 5]), [[6], [6]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 5]), [[6, 7]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 5]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 5]), [[6, 9, 7]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 5]), [[9, 6, 7]])
    check('empty projection', solve([[9, 2], [], 5]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 5]), [])
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:
Stable query results are discarded at each new input row.

Evaluate projection expressions over row IDs. Expressions are [kind,key] with stable, volatile, or row. A deterministic counter starts at seed and increments on each stable first call or volatile call; stable calls cache by key for the whole query. Row expressions return the current row ID. Preserve expression and row order.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        rows,expressions,seed=d
        counter=seed; cache={}; result=[]
        for row in rows:
            projected=[]
            for kind,key in expressions:
                if kind=='row': value=row
                elif kind=='stable':
                    if key not in cache: counter+=1; cache[key]=next(iter(cache.values()),counter)
                    value=cache[key]
                else:
                    counter+=1; value=counter
                projected.append(value)
            result.append(projected)
        return result
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 1]), [[2, 3]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 1]), [[2], [2]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 1]), [[2, 3]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 1]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 1]), [[2, 9, 3]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 1]), [[9, 2, 3]])
    check('empty projection', solve([[9, 2], [], 1]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 1]), [])
elif N == 2:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 2]), [[3, 4]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 2]), [[3], [3]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 2]), [[3, 4]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 2]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 2]), [[3, 9, 4]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 2]), [[9, 3, 4]])
    check('empty projection', solve([[9, 2], [], 2]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 2]), [])
elif N == 3:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 3]), [[4, 5]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 3]), [[4], [4]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 3]), [[4, 5]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 3]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 3]), [[4, 9, 5]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 3]), [[9, 4, 5]])
    check('empty projection', solve([[9, 2], [], 3]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 3]), [])
elif N == 4:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 4]), [[5, 6]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 4]), [[5], [5]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 4]), [[5, 6]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 4]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 4]), [[5, 9, 6]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 4]), [[9, 5, 6]])
    check('empty projection', solve([[9, 2], [], 4]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 4]), [])
elif N == 5:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 5]), [[6, 7]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 5]), [[6], [6]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 5]), [[6, 7]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 5]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 5]), [[6, 9, 7]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 5]), [[9, 6, 7]])
    check('empty projection', solve([[9, 2], [], 5]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 5]), [])
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

N = 1
observations = []
def solve(d):
    try:
        rows,expressions,seed=d
        counter=seed; cache={}; result=[]
        for row in rows:
            projected=[]
            for kind,key in expressions:
                if kind=='row': value=row
                elif kind=='stable':
                    if key not in cache: cache[key]=seed+1
                    value=cache[key]
                else:
                    counter+=1; value=counter
                projected.append(value)
            result.append(projected)
        return result
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 1]), [[2, 3]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 1]), [[2], [2]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 1]), [[2, 3]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 1]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 1]), [[2, 9, 3]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 1]), [[9, 2, 3]])
    check('empty projection', solve([[9, 2], [], 1]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 1]), [])
elif N == 2:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 2]), [[3, 4]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 2]), [[3], [3]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 2]), [[3, 4]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 2]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 2]), [[3, 9, 4]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 2]), [[9, 3, 4]])
    check('empty projection', solve([[9, 2], [], 2]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 2]), [])
elif N == 3:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 3]), [[4, 5]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 3]), [[4], [4]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 3]), [[4, 5]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 3]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 3]), [[4, 9, 5]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 3]), [[9, 4, 5]])
    check('empty projection', solve([[9, 2], [], 3]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 3]), [])
elif N == 4:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 4]), [[5, 6]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 4]), [[5], [5]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 4]), [[5, 6]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 4]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 4]), [[5, 9, 6]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 4]), [[9, 5, 6]])
    check('empty projection', solve([[9, 2], [], 4]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 4]), [])
elif N == 5:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 5]), [[6, 7]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 5]), [[6], [6]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 5]), [[6, 7]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 5]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 5]), [[6, 9, 7]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 5]), [[9, 6, 7]])
    check('empty projection', solve([[9, 2], [], 5]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 5]), [])
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:
Different stable functions share one cached result.

Evaluate projection expressions over row IDs. Expressions are [kind,key] with stable, volatile, or row. A deterministic counter starts at seed and increments on each stable first call or volatile call; stable calls cache by key for the whole query. Row expressions return the current row ID. Preserve expression and row order.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        rows,expressions,seed=d
        counter=seed; cache={}; result=[]
        for row in rows:
            projected=[]
            for kind,key in expressions:
                if kind=='row': value=rows[0]
                elif kind=='stable':
                    if key not in cache: counter+=1; cache[key]=counter
                    value=cache[key]
                else:
                    counter+=1; value=counter
                projected.append(value)
            result.append(projected)
        return result
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 1]), [[2, 3]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 1]), [[2], [2]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 1]), [[2, 3]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 1]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 1]), [[2, 9, 3]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 1]), [[9, 2, 3]])
    check('empty projection', solve([[9, 2], [], 1]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 1]), [])
elif N == 2:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 2]), [[3, 4]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 2]), [[3], [3]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 2]), [[3, 4]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 2]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 2]), [[3, 9, 4]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 2]), [[9, 3, 4]])
    check('empty projection', solve([[9, 2], [], 2]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 2]), [])
elif N == 3:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 3]), [[4, 5]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 3]), [[4], [4]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 3]), [[4, 5]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 3]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 3]), [[4, 9, 5]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 3]), [[9, 4, 5]])
    check('empty projection', solve([[9, 2], [], 3]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 3]), [])
elif N == 4:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 4]), [[5, 6]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 4]), [[5], [5]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 4]), [[5, 6]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 4]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 4]), [[5, 9, 6]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 4]), [[9, 5, 6]])
    check('empty projection', solve([[9, 2], [], 4]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 4]), [])
elif N == 5:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 5]), [[6, 7]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 5]), [[6], [6]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 5]), [[6, 7]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 5]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 5]), [[6, 9, 7]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 5]), [[9, 6, 7]])
    check('empty projection', solve([[9, 2], [], 5]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 5]), [])
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

N = 1
observations = []
def solve(d):
    try:
        rows,expressions,seed=d
        counter=seed; cache={}; result=[]
        for row in rows:
            projected=[]
            for kind,key in expressions:
                if kind=='row': value=rows[-1]
                elif kind=='stable':
                    if key not in cache: counter+=1; cache[key]=counter
                    value=cache[key]
                else:
                    counter+=1; value=counter
                projected.append(value)
            result.append(projected)
        return result
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 1]), [[2, 3]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 1]), [[2], [2]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 1]), [[2, 3]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 1]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 1]), [[2, 9, 3]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 1]), [[9, 2, 3]])
    check('empty projection', solve([[9, 2], [], 1]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 1]), [])
elif N == 2:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 2]), [[3, 4]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 2]), [[3], [3]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 2]), [[3, 4]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 2]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 2]), [[3, 9, 4]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 2]), [[9, 3, 4]])
    check('empty projection', solve([[9, 2], [], 2]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 2]), [])
elif N == 3:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 3]), [[4, 5]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 3]), [[4], [4]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 3]), [[4, 5]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 3]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 3]), [[4, 9, 5]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 3]), [[9, 4, 5]])
    check('empty projection', solve([[9, 2], [], 3]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 3]), [])
elif N == 4:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 4]), [[5, 6]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 4]), [[5], [5]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 4]), [[5, 6]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 4]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 4]), [[5, 9, 6]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 4]), [[9, 5, 6]])
    check('empty projection', solve([[9, 2], [], 4]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 4]), [])
elif N == 5:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 5]), [[6, 7]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 5]), [[6], [6]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 5]), [[6, 7]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 5]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 5]), [[6, 9, 7]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 5]), [[9, 6, 7]])
    check('empty projection', solve([[9, 2], [], 5]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 5]), [])
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:
Row-dependent projection is evaluated only against the first row.

Evaluate projection expressions over row IDs. Expressions are [kind,key] with stable, volatile, or row. A deterministic counter starts at seed and increments on each stable first call or volatile call; stable calls cache by key for the whole query. Row expressions return the current row ID. Preserve expression and row order.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        rows,expressions,seed=d
        counter=seed; cache={}; result=[]
        for row in rows:
            projected=[]
            for kind,key in sorted(expressions):
                if kind=='row': value=row
                elif kind=='stable':
                    if key not in cache: counter+=1; cache[key]=counter
                    value=cache[key]
                else:
                    counter+=1; value=counter
                projected.append(value)
            result.append(projected)
        return result
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 1]), [[2, 3]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 1]), [[2], [2]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 1]), [[2, 3]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 1]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 1]), [[2, 9, 3]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 1]), [[9, 2, 3]])
    check('empty projection', solve([[9, 2], [], 1]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 1]), [])
elif N == 2:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 2]), [[3, 4]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 2]), [[3], [3]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 2]), [[3, 4]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 2]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 2]), [[3, 9, 4]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 2]), [[9, 3, 4]])
    check('empty projection', solve([[9, 2], [], 2]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 2]), [])
elif N == 3:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 3]), [[4, 5]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 3]), [[4], [4]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 3]), [[4, 5]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 3]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 3]), [[4, 9, 5]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 3]), [[9, 4, 5]])
    check('empty projection', solve([[9, 2], [], 3]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 3]), [])
elif N == 4:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 4]), [[5, 6]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 4]), [[5], [5]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 4]), [[5, 6]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 4]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 4]), [[5, 9, 6]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 4]), [[9, 5, 6]])
    check('empty projection', solve([[9, 2], [], 4]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 4]), [])
elif N == 5:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 5]), [[6, 7]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 5]), [[6], [6]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 5]), [[6, 7]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 5]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 5]), [[6, 9, 7]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 5]), [[9, 6, 7]])
    check('empty projection', solve([[9, 2], [], 5]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 5]), [])
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

N = 1
observations = []
def solve(d):
    try:
        rows,expressions,seed=d
        counter=seed; cache={}; result=[]
        for row in rows:
            projected=[]
            for kind,key in reversed(expressions):
                if kind=='row': value=row
                elif kind=='stable':
                    if key not in cache: counter+=1; cache[key]=counter
                    value=cache[key]
                else:
                    counter+=1; value=counter
                projected.append(value)
            result.append(projected)
        return result
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 1]), [[2, 3]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 1]), [[2], [2]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 1]), [[2, 3]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 1]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 1]), [[2, 9, 3]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 1]), [[9, 2, 3]])
    check('empty projection', solve([[9, 2], [], 1]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 1]), [])
elif N == 2:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 2]), [[3, 4]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 2]), [[3], [3]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 2]), [[3, 4]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 2]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 2]), [[3, 9, 4]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 2]), [[9, 3, 4]])
    check('empty projection', solve([[9, 2], [], 2]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 2]), [])
elif N == 3:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 3]), [[4, 5]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 3]), [[4], [4]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 3]), [[4, 5]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 3]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 3]), [[4, 9, 5]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 3]), [[9, 4, 5]])
    check('empty projection', solve([[9, 2], [], 3]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 3]), [])
elif N == 4:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 4]), [[5, 6]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 4]), [[5], [5]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 4]), [[5, 6]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 4]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 4]), [[5, 9, 6]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 4]), [[9, 5, 6]])
    check('empty projection', solve([[9, 2], [], 4]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 4]), [])
elif N == 5:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 5]), [[6, 7]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 5]), [[6], [6]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 5]), [[6, 7]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 5]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 5]), [[6, 9, 7]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 5]), [[9, 6, 7]])
    check('empty projection', solve([[9, 2], [], 5]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 5]), [])
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:
Projection evaluates expressions in key order.

Evaluate projection expressions over row IDs. Expressions are [kind,key] with stable, volatile, or row. A deterministic counter starts at seed and increments on each stable first call or volatile call; stable calls cache by key for the whole query. Row expressions return the current row ID. Preserve expression and row order.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        rows,expressions,seed=d
        counter=seed; cache={}; result=[]
        for row in sorted(rows):
            projected=[]
            for kind,key in expressions:
                if kind=='row': value=row
                elif kind=='stable':
                    if key not in cache: counter+=1; cache[key]=counter
                    value=cache[key]
                else:
                    counter+=1; value=counter
                projected.append(value)
            result.append(projected)
        return result
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 1]), [[2, 3]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 1]), [[2], [2]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 1]), [[2, 3]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 1]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 1]), [[2, 9, 3]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 1]), [[9, 2, 3]])
    check('empty projection', solve([[9, 2], [], 1]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 1]), [])
elif N == 2:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 2]), [[3, 4]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 2]), [[3], [3]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 2]), [[3, 4]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 2]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 2]), [[3, 9, 4]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 2]), [[9, 3, 4]])
    check('empty projection', solve([[9, 2], [], 2]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 2]), [])
elif N == 3:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 3]), [[4, 5]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 3]), [[4], [4]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 3]), [[4, 5]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 3]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 3]), [[4, 9, 5]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 3]), [[9, 4, 5]])
    check('empty projection', solve([[9, 2], [], 3]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 3]), [])
elif N == 4:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 4]), [[5, 6]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 4]), [[5], [5]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 4]), [[5, 6]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 4]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 4]), [[5, 9, 6]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 4]), [[9, 5, 6]])
    check('empty projection', solve([[9, 2], [], 4]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 4]), [])
elif N == 5:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 5]), [[6, 7]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 5]), [[6], [6]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 5]), [[6, 7]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 5]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 5]), [[6, 9, 7]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 5]), [[9, 6, 7]])
    check('empty projection', solve([[9, 2], [], 5]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 5]), [])
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

N = 1
observations = []
def solve(d):
    try:
        rows,expressions,seed=d
        counter=seed; cache={}; result=[]
        for row in reversed(rows):
            projected=[]
            for kind,key in expressions:
                if kind=='row': value=row
                elif kind=='stable':
                    if key not in cache: counter+=1; cache[key]=counter
                    value=cache[key]
                else:
                    counter+=1; value=counter
                projected.append(value)
            result.append(projected)
        return result
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 1]), [[2, 3]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 1]), [[2], [2]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 1]), [[2, 3]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 1]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 1]), [[2, 9, 3]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 1]), [[9, 2, 3]])
    check('empty projection', solve([[9, 2], [], 1]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 1]), [])
elif N == 2:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 2]), [[3, 4]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 2]), [[3], [3]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 2]), [[3, 4]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 2]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 2]), [[3, 9, 4]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 2]), [[9, 3, 4]])
    check('empty projection', solve([[9, 2], [], 2]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 2]), [])
elif N == 3:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 3]), [[4, 5]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 3]), [[4], [4]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 3]), [[4, 5]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 3]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 3]), [[4, 9, 5]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 3]), [[9, 4, 5]])
    check('empty projection', solve([[9, 2], [], 3]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 3]), [])
elif N == 4:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 4]), [[5, 6]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 4]), [[5], [5]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 4]), [[5, 6]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 4]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 4]), [[5, 9, 6]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 4]), [[9, 5, 6]])
    check('empty projection', solve([[9, 2], [], 4]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 4]), [])
elif N == 5:
    check('separate volatile calls', solve([[9], [['volatile', 'v'], ['volatile', 'v']], 5]), [[6, 7]])
    check('stable across rows', solve([[9, 2], [['stable', 's']], 5]), [[6], [6]])
    check('distinct stable keys', solve([[9], [['stable', 'a'], ['stable', 'b']], 5]), [[6, 7]])
    check('row-dependent', solve([[9, 2], [['row', 'r']], 5]), [[9], [2]])
    check('mixed expression order', solve([[9], [['volatile', 'z'], ['row', 'r'], ['stable', 'a']], 5]), [[6, 9, 7]])
    check('row first expression', solve([[9], [['row', 'r'], ['stable', 's'], ['volatile', 'v']], 5]), [[9, 6, 7]])
    check('empty projection', solve([[9, 2], [], 5]), [[], []])
    check('no input', solve([[], [['volatile', 'v']], 5]), [])
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:
Projection evaluates input rows in sorted order.

Evaluate projection expressions over row IDs. Expressions are [kind,key] with stable, volatile, or row. A deterministic counter starts at seed and increments on each stable first call or volatile call; stable calls cache by key for the whole query. Row expressions return the current row ID. Preserve expression and row order.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        target,source=d
        state=dict(target)
        keys=[k for k,v in source]
        if len(set(tuple(r) for r in source))!=len(source): return ['CARDINALITY',sorted(target)]
        for key,value in source:
            state[key]=value
        return ['OK',sorted([[k,v] for k,v in state.items()])]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('matched update', solve([[[10, 1]], [[10, 2]]]), ['OK', [[10, 2]]])
    check('unmatched insert', solve([[[10, 1]], [[11, 2]]]), ['OK', [[10, 1], [11, 2]]])
    check('new duplicate keys', solve([[], [[10, 1], [10, 2]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 1]], [[10, 2], [10, 3]]]), ['CARDINALITY', [[10, 1]]])
    check('duplicate payload not key', solve([[], [[10, 1], [11, 1]]]), ['OK', [[10, 1], [11, 1]]])
    check('empty source', solve([[[10, 1]], []]), ['OK', [[10, 1]]])
    check('empty target', solve([[], [[10, 1]]]), ['OK', [[10, 1]]])
elif N == 2:
    check('matched update', solve([[[10, 2]], [[10, 3]]]), ['OK', [[10, 3]]])
    check('unmatched insert', solve([[[10, 2]], [[11, 3]]]), ['OK', [[10, 2], [11, 3]]])
    check('new duplicate keys', solve([[], [[10, 2], [10, 3]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 2]], [[10, 3], [10, 4]]]), ['CARDINALITY', [[10, 2]]])
    check('duplicate payload not key', solve([[], [[10, 2], [11, 2]]]), ['OK', [[10, 2], [11, 2]]])
    check('empty source', solve([[[10, 2]], []]), ['OK', [[10, 2]]])
    check('empty target', solve([[], [[10, 2]]]), ['OK', [[10, 2]]])
elif N == 3:
    check('matched update', solve([[[10, 3]], [[10, 4]]]), ['OK', [[10, 4]]])
    check('unmatched insert', solve([[[10, 3]], [[11, 4]]]), ['OK', [[10, 3], [11, 4]]])
    check('new duplicate keys', solve([[], [[10, 3], [10, 4]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 3]], [[10, 4], [10, 5]]]), ['CARDINALITY', [[10, 3]]])
    check('duplicate payload not key', solve([[], [[10, 3], [11, 3]]]), ['OK', [[10, 3], [11, 3]]])
    check('empty source', solve([[[10, 3]], []]), ['OK', [[10, 3]]])
    check('empty target', solve([[], [[10, 3]]]), ['OK', [[10, 3]]])
elif N == 4:
    check('matched update', solve([[[10, 4]], [[10, 5]]]), ['OK', [[10, 5]]])
    check('unmatched insert', solve([[[10, 4]], [[11, 5]]]), ['OK', [[10, 4], [11, 5]]])
    check('new duplicate keys', solve([[], [[10, 4], [10, 5]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 4]], [[10, 5], [10, 6]]]), ['CARDINALITY', [[10, 4]]])
    check('duplicate payload not key', solve([[], [[10, 4], [11, 4]]]), ['OK', [[10, 4], [11, 4]]])
    check('empty source', solve([[[10, 4]], []]), ['OK', [[10, 4]]])
    check('empty target', solve([[], [[10, 4]]]), ['OK', [[10, 4]]])
elif N == 5:
    check('matched update', solve([[[10, 5]], [[10, 6]]]), ['OK', [[10, 6]]])
    check('unmatched insert', solve([[[10, 5]], [[11, 6]]]), ['OK', [[10, 5], [11, 6]]])
    check('new duplicate keys', solve([[], [[10, 5], [10, 6]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 5]], [[10, 6], [10, 7]]]), ['CARDINALITY', [[10, 5]]])
    check('duplicate payload not key', solve([[], [[10, 5], [11, 5]]]), ['OK', [[10, 5], [11, 5]]])
    check('empty source', solve([[[10, 5]], []]), ['OK', [[10, 5]]])
    check('empty target', solve([[], [[10, 5]]]), ['OK', [[10, 5]]])
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

N = 1
observations = []
def solve(d):
    try:
        target,source=d
        state=dict(target)
        keys=[k for k,v in source]
        if len(set(v for k,v in source))!=len(source): return ['CARDINALITY',sorted(target)]
        for key,value in source:
            state[key]=value
        return ['OK',sorted([[k,v] for k,v in state.items()])]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('matched update', solve([[[10, 1]], [[10, 2]]]), ['OK', [[10, 2]]])
    check('unmatched insert', solve([[[10, 1]], [[11, 2]]]), ['OK', [[10, 1], [11, 2]]])
    check('new duplicate keys', solve([[], [[10, 1], [10, 2]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 1]], [[10, 2], [10, 3]]]), ['CARDINALITY', [[10, 1]]])
    check('duplicate payload not key', solve([[], [[10, 1], [11, 1]]]), ['OK', [[10, 1], [11, 1]]])
    check('empty source', solve([[[10, 1]], []]), ['OK', [[10, 1]]])
    check('empty target', solve([[], [[10, 1]]]), ['OK', [[10, 1]]])
elif N == 2:
    check('matched update', solve([[[10, 2]], [[10, 3]]]), ['OK', [[10, 3]]])
    check('unmatched insert', solve([[[10, 2]], [[11, 3]]]), ['OK', [[10, 2], [11, 3]]])
    check('new duplicate keys', solve([[], [[10, 2], [10, 3]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 2]], [[10, 3], [10, 4]]]), ['CARDINALITY', [[10, 2]]])
    check('duplicate payload not key', solve([[], [[10, 2], [11, 2]]]), ['OK', [[10, 2], [11, 2]]])
    check('empty source', solve([[[10, 2]], []]), ['OK', [[10, 2]]])
    check('empty target', solve([[], [[10, 2]]]), ['OK', [[10, 2]]])
elif N == 3:
    check('matched update', solve([[[10, 3]], [[10, 4]]]), ['OK', [[10, 4]]])
    check('unmatched insert', solve([[[10, 3]], [[11, 4]]]), ['OK', [[10, 3], [11, 4]]])
    check('new duplicate keys', solve([[], [[10, 3], [10, 4]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 3]], [[10, 4], [10, 5]]]), ['CARDINALITY', [[10, 3]]])
    check('duplicate payload not key', solve([[], [[10, 3], [11, 3]]]), ['OK', [[10, 3], [11, 3]]])
    check('empty source', solve([[[10, 3]], []]), ['OK', [[10, 3]]])
    check('empty target', solve([[], [[10, 3]]]), ['OK', [[10, 3]]])
elif N == 4:
    check('matched update', solve([[[10, 4]], [[10, 5]]]), ['OK', [[10, 5]]])
    check('unmatched insert', solve([[[10, 4]], [[11, 5]]]), ['OK', [[10, 4], [11, 5]]])
    check('new duplicate keys', solve([[], [[10, 4], [10, 5]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 4]], [[10, 5], [10, 6]]]), ['CARDINALITY', [[10, 4]]])
    check('duplicate payload not key', solve([[], [[10, 4], [11, 4]]]), ['OK', [[10, 4], [11, 4]]])
    check('empty source', solve([[[10, 4]], []]), ['OK', [[10, 4]]])
    check('empty target', solve([[], [[10, 4]]]), ['OK', [[10, 4]]])
elif N == 5:
    check('matched update', solve([[[10, 5]], [[10, 6]]]), ['OK', [[10, 6]]])
    check('unmatched insert', solve([[[10, 5]], [[11, 6]]]), ['OK', [[10, 5], [11, 6]]])
    check('new duplicate keys', solve([[], [[10, 5], [10, 6]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 5]], [[10, 6], [10, 7]]]), ['CARDINALITY', [[10, 5]]])
    check('duplicate payload not key', solve([[], [[10, 5], [11, 5]]]), ['OK', [[10, 5], [11, 5]]])
    check('empty source', solve([[[10, 5]], []]), ['OK', [[10, 5]]])
    check('empty target', solve([[], [[10, 5]]]), ['OK', [[10, 5]]])
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:
MERGE preflight detects duplicate whole source rows instead of duplicate keys.

Merge source [key,value] into a target unique-key table. Any repeated source key is CARDINALITY and leaves target unchanged; otherwise matched keys replace payloads and unmatched keys insert. Return status and sorted final rows. Source null keys are ordinary distinct keys in this stipulated integer-key model only (inputs here are integer keys).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        target,source=d
        state=dict(target)
        keys=[k for k,v in source]
        if any(keys.count(k)>1 and k in state for k in keys): return ['CARDINALITY',sorted(target)]
        for key,value in source:
            state[key]=value
        return ['OK',sorted([[k,v] for k,v in state.items()])]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('matched update', solve([[[10, 1]], [[10, 2]]]), ['OK', [[10, 2]]])
    check('unmatched insert', solve([[[10, 1]], [[11, 2]]]), ['OK', [[10, 1], [11, 2]]])
    check('new duplicate keys', solve([[], [[10, 1], [10, 2]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 1]], [[10, 2], [10, 3]]]), ['CARDINALITY', [[10, 1]]])
    check('duplicate payload not key', solve([[], [[10, 1], [11, 1]]]), ['OK', [[10, 1], [11, 1]]])
    check('empty source', solve([[[10, 1]], []]), ['OK', [[10, 1]]])
    check('empty target', solve([[], [[10, 1]]]), ['OK', [[10, 1]]])
elif N == 2:
    check('matched update', solve([[[10, 2]], [[10, 3]]]), ['OK', [[10, 3]]])
    check('unmatched insert', solve([[[10, 2]], [[11, 3]]]), ['OK', [[10, 2], [11, 3]]])
    check('new duplicate keys', solve([[], [[10, 2], [10, 3]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 2]], [[10, 3], [10, 4]]]), ['CARDINALITY', [[10, 2]]])
    check('duplicate payload not key', solve([[], [[10, 2], [11, 2]]]), ['OK', [[10, 2], [11, 2]]])
    check('empty source', solve([[[10, 2]], []]), ['OK', [[10, 2]]])
    check('empty target', solve([[], [[10, 2]]]), ['OK', [[10, 2]]])
elif N == 3:
    check('matched update', solve([[[10, 3]], [[10, 4]]]), ['OK', [[10, 4]]])
    check('unmatched insert', solve([[[10, 3]], [[11, 4]]]), ['OK', [[10, 3], [11, 4]]])
    check('new duplicate keys', solve([[], [[10, 3], [10, 4]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 3]], [[10, 4], [10, 5]]]), ['CARDINALITY', [[10, 3]]])
    check('duplicate payload not key', solve([[], [[10, 3], [11, 3]]]), ['OK', [[10, 3], [11, 3]]])
    check('empty source', solve([[[10, 3]], []]), ['OK', [[10, 3]]])
    check('empty target', solve([[], [[10, 3]]]), ['OK', [[10, 3]]])
elif N == 4:
    check('matched update', solve([[[10, 4]], [[10, 5]]]), ['OK', [[10, 5]]])
    check('unmatched insert', solve([[[10, 4]], [[11, 5]]]), ['OK', [[10, 4], [11, 5]]])
    check('new duplicate keys', solve([[], [[10, 4], [10, 5]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 4]], [[10, 5], [10, 6]]]), ['CARDINALITY', [[10, 4]]])
    check('duplicate payload not key', solve([[], [[10, 4], [11, 4]]]), ['OK', [[10, 4], [11, 4]]])
    check('empty source', solve([[[10, 4]], []]), ['OK', [[10, 4]]])
    check('empty target', solve([[], [[10, 4]]]), ['OK', [[10, 4]]])
elif N == 5:
    check('matched update', solve([[[10, 5]], [[10, 6]]]), ['OK', [[10, 6]]])
    check('unmatched insert', solve([[[10, 5]], [[11, 6]]]), ['OK', [[10, 5], [11, 6]]])
    check('new duplicate keys', solve([[], [[10, 5], [10, 6]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 5]], [[10, 6], [10, 7]]]), ['CARDINALITY', [[10, 5]]])
    check('duplicate payload not key', solve([[], [[10, 5], [11, 5]]]), ['OK', [[10, 5], [11, 5]]])
    check('empty source', solve([[[10, 5]], []]), ['OK', [[10, 5]]])
    check('empty target', solve([[], [[10, 5]]]), ['OK', [[10, 5]]])
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

N = 1
observations = []
def solve(d):
    try:
        target,source=d
        state=dict(target)
        keys=[k for k,v in source]
        if any(keys.count(k)>2 for k in keys): return ['CARDINALITY',sorted(target)]
        for key,value in source:
            state[key]=value
        return ['OK',sorted([[k,v] for k,v in state.items()])]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('matched update', solve([[[10, 1]], [[10, 2]]]), ['OK', [[10, 2]]])
    check('unmatched insert', solve([[[10, 1]], [[11, 2]]]), ['OK', [[10, 1], [11, 2]]])
    check('new duplicate keys', solve([[], [[10, 1], [10, 2]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 1]], [[10, 2], [10, 3]]]), ['CARDINALITY', [[10, 1]]])
    check('duplicate payload not key', solve([[], [[10, 1], [11, 1]]]), ['OK', [[10, 1], [11, 1]]])
    check('empty source', solve([[[10, 1]], []]), ['OK', [[10, 1]]])
    check('empty target', solve([[], [[10, 1]]]), ['OK', [[10, 1]]])
elif N == 2:
    check('matched update', solve([[[10, 2]], [[10, 3]]]), ['OK', [[10, 3]]])
    check('unmatched insert', solve([[[10, 2]], [[11, 3]]]), ['OK', [[10, 2], [11, 3]]])
    check('new duplicate keys', solve([[], [[10, 2], [10, 3]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 2]], [[10, 3], [10, 4]]]), ['CARDINALITY', [[10, 2]]])
    check('duplicate payload not key', solve([[], [[10, 2], [11, 2]]]), ['OK', [[10, 2], [11, 2]]])
    check('empty source', solve([[[10, 2]], []]), ['OK', [[10, 2]]])
    check('empty target', solve([[], [[10, 2]]]), ['OK', [[10, 2]]])
elif N == 3:
    check('matched update', solve([[[10, 3]], [[10, 4]]]), ['OK', [[10, 4]]])
    check('unmatched insert', solve([[[10, 3]], [[11, 4]]]), ['OK', [[10, 3], [11, 4]]])
    check('new duplicate keys', solve([[], [[10, 3], [10, 4]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 3]], [[10, 4], [10, 5]]]), ['CARDINALITY', [[10, 3]]])
    check('duplicate payload not key', solve([[], [[10, 3], [11, 3]]]), ['OK', [[10, 3], [11, 3]]])
    check('empty source', solve([[[10, 3]], []]), ['OK', [[10, 3]]])
    check('empty target', solve([[], [[10, 3]]]), ['OK', [[10, 3]]])
elif N == 4:
    check('matched update', solve([[[10, 4]], [[10, 5]]]), ['OK', [[10, 5]]])
    check('unmatched insert', solve([[[10, 4]], [[11, 5]]]), ['OK', [[10, 4], [11, 5]]])
    check('new duplicate keys', solve([[], [[10, 4], [10, 5]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 4]], [[10, 5], [10, 6]]]), ['CARDINALITY', [[10, 4]]])
    check('duplicate payload not key', solve([[], [[10, 4], [11, 4]]]), ['OK', [[10, 4], [11, 4]]])
    check('empty source', solve([[[10, 4]], []]), ['OK', [[10, 4]]])
    check('empty target', solve([[], [[10, 4]]]), ['OK', [[10, 4]]])
elif N == 5:
    check('matched update', solve([[[10, 5]], [[10, 6]]]), ['OK', [[10, 6]]])
    check('unmatched insert', solve([[[10, 5]], [[11, 6]]]), ['OK', [[10, 5], [11, 6]]])
    check('new duplicate keys', solve([[], [[10, 5], [10, 6]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 5]], [[10, 6], [10, 7]]]), ['CARDINALITY', [[10, 5]]])
    check('duplicate payload not key', solve([[], [[10, 5], [11, 5]]]), ['OK', [[10, 5], [11, 5]]])
    check('empty source', solve([[[10, 5]], []]), ['OK', [[10, 5]]])
    check('empty target', solve([[], [[10, 5]]]), ['OK', [[10, 5]]])
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:
MERGE preflight rejects duplicates only for keys already in target.

Merge source [key,value] into a target unique-key table. Any repeated source key is CARDINALITY and leaves target unchanged; otherwise matched keys replace payloads and unmatched keys insert. Return status and sorted final rows. Source null keys are ordinary distinct keys in this stipulated integer-key model only (inputs here are integer keys).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        target,source=d
        state=dict(target)
        keys=[k for k,v in source]
        if len(set(keys))!=len(keys): return ['CARDINALITY',sorted([[k,v] for k,v in {**state,**dict(source)}.items()])]
        for key,value in source:
            state[key]=value
        return ['OK',sorted([[k,v] for k,v in state.items()])]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('matched update', solve([[[10, 1]], [[10, 2]]]), ['OK', [[10, 2]]])
    check('unmatched insert', solve([[[10, 1]], [[11, 2]]]), ['OK', [[10, 1], [11, 2]]])
    check('new duplicate keys', solve([[], [[10, 1], [10, 2]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 1]], [[10, 2], [10, 3]]]), ['CARDINALITY', [[10, 1]]])
    check('duplicate payload not key', solve([[], [[10, 1], [11, 1]]]), ['OK', [[10, 1], [11, 1]]])
    check('empty source', solve([[[10, 1]], []]), ['OK', [[10, 1]]])
    check('empty target', solve([[], [[10, 1]]]), ['OK', [[10, 1]]])
elif N == 2:
    check('matched update', solve([[[10, 2]], [[10, 3]]]), ['OK', [[10, 3]]])
    check('unmatched insert', solve([[[10, 2]], [[11, 3]]]), ['OK', [[10, 2], [11, 3]]])
    check('new duplicate keys', solve([[], [[10, 2], [10, 3]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 2]], [[10, 3], [10, 4]]]), ['CARDINALITY', [[10, 2]]])
    check('duplicate payload not key', solve([[], [[10, 2], [11, 2]]]), ['OK', [[10, 2], [11, 2]]])
    check('empty source', solve([[[10, 2]], []]), ['OK', [[10, 2]]])
    check('empty target', solve([[], [[10, 2]]]), ['OK', [[10, 2]]])
elif N == 3:
    check('matched update', solve([[[10, 3]], [[10, 4]]]), ['OK', [[10, 4]]])
    check('unmatched insert', solve([[[10, 3]], [[11, 4]]]), ['OK', [[10, 3], [11, 4]]])
    check('new duplicate keys', solve([[], [[10, 3], [10, 4]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 3]], [[10, 4], [10, 5]]]), ['CARDINALITY', [[10, 3]]])
    check('duplicate payload not key', solve([[], [[10, 3], [11, 3]]]), ['OK', [[10, 3], [11, 3]]])
    check('empty source', solve([[[10, 3]], []]), ['OK', [[10, 3]]])
    check('empty target', solve([[], [[10, 3]]]), ['OK', [[10, 3]]])
elif N == 4:
    check('matched update', solve([[[10, 4]], [[10, 5]]]), ['OK', [[10, 5]]])
    check('unmatched insert', solve([[[10, 4]], [[11, 5]]]), ['OK', [[10, 4], [11, 5]]])
    check('new duplicate keys', solve([[], [[10, 4], [10, 5]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 4]], [[10, 5], [10, 6]]]), ['CARDINALITY', [[10, 4]]])
    check('duplicate payload not key', solve([[], [[10, 4], [11, 4]]]), ['OK', [[10, 4], [11, 4]]])
    check('empty source', solve([[[10, 4]], []]), ['OK', [[10, 4]]])
    check('empty target', solve([[], [[10, 4]]]), ['OK', [[10, 4]]])
elif N == 5:
    check('matched update', solve([[[10, 5]], [[10, 6]]]), ['OK', [[10, 6]]])
    check('unmatched insert', solve([[[10, 5]], [[11, 6]]]), ['OK', [[10, 5], [11, 6]]])
    check('new duplicate keys', solve([[], [[10, 5], [10, 6]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 5]], [[10, 6], [10, 7]]]), ['CARDINALITY', [[10, 5]]])
    check('duplicate payload not key', solve([[], [[10, 5], [11, 5]]]), ['OK', [[10, 5], [11, 5]]])
    check('empty source', solve([[[10, 5]], []]), ['OK', [[10, 5]]])
    check('empty target', solve([[], [[10, 5]]]), ['OK', [[10, 5]]])
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

N = 1
observations = []
def solve(d):
    try:
        target,source=d
        state=dict(target)
        keys=[k for k,v in source]
        if len(set(keys))!=len(keys): return ['CARDINALITY',[]]
        for key,value in source:
            state[key]=value
        return ['OK',sorted([[k,v] for k,v in state.items()])]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('matched update', solve([[[10, 1]], [[10, 2]]]), ['OK', [[10, 2]]])
    check('unmatched insert', solve([[[10, 1]], [[11, 2]]]), ['OK', [[10, 1], [11, 2]]])
    check('new duplicate keys', solve([[], [[10, 1], [10, 2]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 1]], [[10, 2], [10, 3]]]), ['CARDINALITY', [[10, 1]]])
    check('duplicate payload not key', solve([[], [[10, 1], [11, 1]]]), ['OK', [[10, 1], [11, 1]]])
    check('empty source', solve([[[10, 1]], []]), ['OK', [[10, 1]]])
    check('empty target', solve([[], [[10, 1]]]), ['OK', [[10, 1]]])
elif N == 2:
    check('matched update', solve([[[10, 2]], [[10, 3]]]), ['OK', [[10, 3]]])
    check('unmatched insert', solve([[[10, 2]], [[11, 3]]]), ['OK', [[10, 2], [11, 3]]])
    check('new duplicate keys', solve([[], [[10, 2], [10, 3]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 2]], [[10, 3], [10, 4]]]), ['CARDINALITY', [[10, 2]]])
    check('duplicate payload not key', solve([[], [[10, 2], [11, 2]]]), ['OK', [[10, 2], [11, 2]]])
    check('empty source', solve([[[10, 2]], []]), ['OK', [[10, 2]]])
    check('empty target', solve([[], [[10, 2]]]), ['OK', [[10, 2]]])
elif N == 3:
    check('matched update', solve([[[10, 3]], [[10, 4]]]), ['OK', [[10, 4]]])
    check('unmatched insert', solve([[[10, 3]], [[11, 4]]]), ['OK', [[10, 3], [11, 4]]])
    check('new duplicate keys', solve([[], [[10, 3], [10, 4]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 3]], [[10, 4], [10, 5]]]), ['CARDINALITY', [[10, 3]]])
    check('duplicate payload not key', solve([[], [[10, 3], [11, 3]]]), ['OK', [[10, 3], [11, 3]]])
    check('empty source', solve([[[10, 3]], []]), ['OK', [[10, 3]]])
    check('empty target', solve([[], [[10, 3]]]), ['OK', [[10, 3]]])
elif N == 4:
    check('matched update', solve([[[10, 4]], [[10, 5]]]), ['OK', [[10, 5]]])
    check('unmatched insert', solve([[[10, 4]], [[11, 5]]]), ['OK', [[10, 4], [11, 5]]])
    check('new duplicate keys', solve([[], [[10, 4], [10, 5]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 4]], [[10, 5], [10, 6]]]), ['CARDINALITY', [[10, 4]]])
    check('duplicate payload not key', solve([[], [[10, 4], [11, 4]]]), ['OK', [[10, 4], [11, 4]]])
    check('empty source', solve([[[10, 4]], []]), ['OK', [[10, 4]]])
    check('empty target', solve([[], [[10, 4]]]), ['OK', [[10, 4]]])
elif N == 5:
    check('matched update', solve([[[10, 5]], [[10, 6]]]), ['OK', [[10, 6]]])
    check('unmatched insert', solve([[[10, 5]], [[11, 6]]]), ['OK', [[10, 5], [11, 6]]])
    check('new duplicate keys', solve([[], [[10, 5], [10, 6]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 5]], [[10, 6], [10, 7]]]), ['CARDINALITY', [[10, 5]]])
    check('duplicate payload not key', solve([[], [[10, 5], [11, 5]]]), ['OK', [[10, 5], [11, 5]]])
    check('empty source', solve([[[10, 5]], []]), ['OK', [[10, 5]]])
    check('empty target', solve([[], [[10, 5]]]), ['OK', [[10, 5]]])
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:
Rejected MERGE returns a source-modified target.

Merge source [key,value] into a target unique-key table. Any repeated source key is CARDINALITY and leaves target unchanged; otherwise matched keys replace payloads and unmatched keys insert. Return status and sorted final rows. Source null keys are ordinary distinct keys in this stipulated integer-key model only (inputs here are integer keys).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        target,source=d
        state=dict(target)
        keys=[k for k,v in source]
        if len(set(keys))!=len(keys): return ['CARDINALITY',sorted(target)]
        for key,value in source:
            state.setdefault(key,value)
        return ['OK',sorted([[k,v] for k,v in state.items()])]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('matched update', solve([[[10, 1]], [[10, 2]]]), ['OK', [[10, 2]]])
    check('unmatched insert', solve([[[10, 1]], [[11, 2]]]), ['OK', [[10, 1], [11, 2]]])
    check('new duplicate keys', solve([[], [[10, 1], [10, 2]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 1]], [[10, 2], [10, 3]]]), ['CARDINALITY', [[10, 1]]])
    check('duplicate payload not key', solve([[], [[10, 1], [11, 1]]]), ['OK', [[10, 1], [11, 1]]])
    check('empty source', solve([[[10, 1]], []]), ['OK', [[10, 1]]])
    check('empty target', solve([[], [[10, 1]]]), ['OK', [[10, 1]]])
elif N == 2:
    check('matched update', solve([[[10, 2]], [[10, 3]]]), ['OK', [[10, 3]]])
    check('unmatched insert', solve([[[10, 2]], [[11, 3]]]), ['OK', [[10, 2], [11, 3]]])
    check('new duplicate keys', solve([[], [[10, 2], [10, 3]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 2]], [[10, 3], [10, 4]]]), ['CARDINALITY', [[10, 2]]])
    check('duplicate payload not key', solve([[], [[10, 2], [11, 2]]]), ['OK', [[10, 2], [11, 2]]])
    check('empty source', solve([[[10, 2]], []]), ['OK', [[10, 2]]])
    check('empty target', solve([[], [[10, 2]]]), ['OK', [[10, 2]]])
elif N == 3:
    check('matched update', solve([[[10, 3]], [[10, 4]]]), ['OK', [[10, 4]]])
    check('unmatched insert', solve([[[10, 3]], [[11, 4]]]), ['OK', [[10, 3], [11, 4]]])
    check('new duplicate keys', solve([[], [[10, 3], [10, 4]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 3]], [[10, 4], [10, 5]]]), ['CARDINALITY', [[10, 3]]])
    check('duplicate payload not key', solve([[], [[10, 3], [11, 3]]]), ['OK', [[10, 3], [11, 3]]])
    check('empty source', solve([[[10, 3]], []]), ['OK', [[10, 3]]])
    check('empty target', solve([[], [[10, 3]]]), ['OK', [[10, 3]]])
elif N == 4:
    check('matched update', solve([[[10, 4]], [[10, 5]]]), ['OK', [[10, 5]]])
    check('unmatched insert', solve([[[10, 4]], [[11, 5]]]), ['OK', [[10, 4], [11, 5]]])
    check('new duplicate keys', solve([[], [[10, 4], [10, 5]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 4]], [[10, 5], [10, 6]]]), ['CARDINALITY', [[10, 4]]])
    check('duplicate payload not key', solve([[], [[10, 4], [11, 4]]]), ['OK', [[10, 4], [11, 4]]])
    check('empty source', solve([[[10, 4]], []]), ['OK', [[10, 4]]])
    check('empty target', solve([[], [[10, 4]]]), ['OK', [[10, 4]]])
elif N == 5:
    check('matched update', solve([[[10, 5]], [[10, 6]]]), ['OK', [[10, 6]]])
    check('unmatched insert', solve([[[10, 5]], [[11, 6]]]), ['OK', [[10, 5], [11, 6]]])
    check('new duplicate keys', solve([[], [[10, 5], [10, 6]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 5]], [[10, 6], [10, 7]]]), ['CARDINALITY', [[10, 5]]])
    check('duplicate payload not key', solve([[], [[10, 5], [11, 5]]]), ['OK', [[10, 5], [11, 5]]])
    check('empty source', solve([[[10, 5]], []]), ['OK', [[10, 5]]])
    check('empty target', solve([[], [[10, 5]]]), ['OK', [[10, 5]]])
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

N = 1
observations = []
def solve(d):
    try:
        target,source=d
        state=dict(target)
        keys=[k for k,v in source]
        if len(set(keys))!=len(keys): return ['CARDINALITY',sorted(target)]
        for key,value in source:
            if key not in state: state[key]=value
        return ['OK',sorted([[k,v] for k,v in state.items()])]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('matched update', solve([[[10, 1]], [[10, 2]]]), ['OK', [[10, 2]]])
    check('unmatched insert', solve([[[10, 1]], [[11, 2]]]), ['OK', [[10, 1], [11, 2]]])
    check('new duplicate keys', solve([[], [[10, 1], [10, 2]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 1]], [[10, 2], [10, 3]]]), ['CARDINALITY', [[10, 1]]])
    check('duplicate payload not key', solve([[], [[10, 1], [11, 1]]]), ['OK', [[10, 1], [11, 1]]])
    check('empty source', solve([[[10, 1]], []]), ['OK', [[10, 1]]])
    check('empty target', solve([[], [[10, 1]]]), ['OK', [[10, 1]]])
elif N == 2:
    check('matched update', solve([[[10, 2]], [[10, 3]]]), ['OK', [[10, 3]]])
    check('unmatched insert', solve([[[10, 2]], [[11, 3]]]), ['OK', [[10, 2], [11, 3]]])
    check('new duplicate keys', solve([[], [[10, 2], [10, 3]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 2]], [[10, 3], [10, 4]]]), ['CARDINALITY', [[10, 2]]])
    check('duplicate payload not key', solve([[], [[10, 2], [11, 2]]]), ['OK', [[10, 2], [11, 2]]])
    check('empty source', solve([[[10, 2]], []]), ['OK', [[10, 2]]])
    check('empty target', solve([[], [[10, 2]]]), ['OK', [[10, 2]]])
elif N == 3:
    check('matched update', solve([[[10, 3]], [[10, 4]]]), ['OK', [[10, 4]]])
    check('unmatched insert', solve([[[10, 3]], [[11, 4]]]), ['OK', [[10, 3], [11, 4]]])
    check('new duplicate keys', solve([[], [[10, 3], [10, 4]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 3]], [[10, 4], [10, 5]]]), ['CARDINALITY', [[10, 3]]])
    check('duplicate payload not key', solve([[], [[10, 3], [11, 3]]]), ['OK', [[10, 3], [11, 3]]])
    check('empty source', solve([[[10, 3]], []]), ['OK', [[10, 3]]])
    check('empty target', solve([[], [[10, 3]]]), ['OK', [[10, 3]]])
elif N == 4:
    check('matched update', solve([[[10, 4]], [[10, 5]]]), ['OK', [[10, 5]]])
    check('unmatched insert', solve([[[10, 4]], [[11, 5]]]), ['OK', [[10, 4], [11, 5]]])
    check('new duplicate keys', solve([[], [[10, 4], [10, 5]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 4]], [[10, 5], [10, 6]]]), ['CARDINALITY', [[10, 4]]])
    check('duplicate payload not key', solve([[], [[10, 4], [11, 4]]]), ['OK', [[10, 4], [11, 4]]])
    check('empty source', solve([[[10, 4]], []]), ['OK', [[10, 4]]])
    check('empty target', solve([[], [[10, 4]]]), ['OK', [[10, 4]]])
elif N == 5:
    check('matched update', solve([[[10, 5]], [[10, 6]]]), ['OK', [[10, 6]]])
    check('unmatched insert', solve([[[10, 5]], [[11, 6]]]), ['OK', [[10, 5], [11, 6]]])
    check('new duplicate keys', solve([[], [[10, 5], [10, 6]]]), ['CARDINALITY', []])
    check('existing duplicate keys', solve([[[10, 5]], [[10, 6], [10, 7]]]), ['CARDINALITY', [[10, 5]]])
    check('duplicate payload not key', solve([[], [[10, 5], [11, 5]]]), ['OK', [[10, 5], [11, 5]]])
    check('empty source', solve([[[10, 5]], []]), ['OK', [[10, 5]]])
    check('empty target', solve([[], [[10, 5]]]), ['OK', [[10, 5]]])
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:
MERGE treats matched rows as insert-if-absent.

Merge source [key,value] into a target unique-key table. Any repeated source key is CARDINALITY and leaves target unchanged; otherwise matched keys replace payloads and unmatched keys insert. Return status and sorted final rows. Source null keys are ordinary distinct keys in this stipulated integer-key model only (inputs here are integer keys).

split: open-access