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

N = 1
observations = []
def solve(d):
    try:
        cutoff,updates=d
        out=[]
        for ident,before,after in updates:
            old=after is not None and after>=cutoff and before is not None
            new=after is not None and after>=cutoff
            if old and new and before==after: continue
            if old: out.append([ident,before,-1])
            if new: out.append([ident,after,1])
        return out
    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('leaves filter', solve([1, [[7, 3, 0]]]), [[7, 3, -1]])
    check('enters filter', solve([1, [[7, 0, 3]]]), [[7, 3, 1]])
    check('changes within filter', solve([1, [[7, 2, 3]]]), [[7, 2, -1], [7, 3, 1]])
    check('unchanged', solve([1, [[7, 1, 1]]]), [])
    check('insert', solve([1, [[7, None, 2]]]), [[7, 2, 1]])
    check('delete', solve([1, [[7, 2, None]]]), [[7, 2, -1]])
    check('outside both', solve([1, [[7, -1, 0]]]), [])
    check('no updates', solve([1, []]), [])
elif N == 2:
    check('leaves filter', solve([2, [[7, 4, 1]]]), [[7, 4, -1]])
    check('enters filter', solve([2, [[7, 1, 4]]]), [[7, 4, 1]])
    check('changes within filter', solve([2, [[7, 3, 4]]]), [[7, 3, -1], [7, 4, 1]])
    check('unchanged', solve([2, [[7, 2, 2]]]), [])
    check('insert', solve([2, [[7, None, 3]]]), [[7, 3, 1]])
    check('delete', solve([2, [[7, 3, None]]]), [[7, 3, -1]])
    check('outside both', solve([2, [[7, 0, 1]]]), [])
    check('no updates', solve([2, []]), [])
elif N == 3:
    check('leaves filter', solve([3, [[7, 5, 2]]]), [[7, 5, -1]])
    check('enters filter', solve([3, [[7, 2, 5]]]), [[7, 5, 1]])
    check('changes within filter', solve([3, [[7, 4, 5]]]), [[7, 4, -1], [7, 5, 1]])
    check('unchanged', solve([3, [[7, 3, 3]]]), [])
    check('insert', solve([3, [[7, None, 4]]]), [[7, 4, 1]])
    check('delete', solve([3, [[7, 4, None]]]), [[7, 4, -1]])
    check('outside both', solve([3, [[7, 1, 2]]]), [])
    check('no updates', solve([3, []]), [])
elif N == 4:
    check('leaves filter', solve([4, [[7, 6, 3]]]), [[7, 6, -1]])
    check('enters filter', solve([4, [[7, 3, 6]]]), [[7, 6, 1]])
    check('changes within filter', solve([4, [[7, 5, 6]]]), [[7, 5, -1], [7, 6, 1]])
    check('unchanged', solve([4, [[7, 4, 4]]]), [])
    check('insert', solve([4, [[7, None, 5]]]), [[7, 5, 1]])
    check('delete', solve([4, [[7, 5, None]]]), [[7, 5, -1]])
    check('outside both', solve([4, [[7, 2, 3]]]), [])
    check('no updates', solve([4, []]), [])
elif N == 5:
    check('leaves filter', solve([5, [[7, 7, 4]]]), [[7, 7, -1]])
    check('enters filter', solve([5, [[7, 4, 7]]]), [[7, 7, 1]])
    check('changes within filter', solve([5, [[7, 6, 7]]]), [[7, 6, -1], [7, 7, 1]])
    check('unchanged', solve([5, [[7, 5, 5]]]), [])
    check('insert', solve([5, [[7, None, 6]]]), [[7, 6, 1]])
    check('delete', solve([5, [[7, 6, None]]]), [[7, 6, -1]])
    check('outside both', solve([5, [[7, 3, 4]]]), [])
    check('no updates', solve([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:
        cutoff,updates=d
        out=[]
        for ident,before,after in updates:
            old=before is not None and after is not None and before>=cutoff
            new=after is not None and after>=cutoff
            if old and new and before==after: continue
            if old: out.append([ident,before,-1])
            if new: out.append([ident,after,1])
        return out
    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('leaves filter', solve([1, [[7, 3, 0]]]), [[7, 3, -1]])
    check('enters filter', solve([1, [[7, 0, 3]]]), [[7, 3, 1]])
    check('changes within filter', solve([1, [[7, 2, 3]]]), [[7, 2, -1], [7, 3, 1]])
    check('unchanged', solve([1, [[7, 1, 1]]]), [])
    check('insert', solve([1, [[7, None, 2]]]), [[7, 2, 1]])
    check('delete', solve([1, [[7, 2, None]]]), [[7, 2, -1]])
    check('outside both', solve([1, [[7, -1, 0]]]), [])
    check('no updates', solve([1, []]), [])
elif N == 2:
    check('leaves filter', solve([2, [[7, 4, 1]]]), [[7, 4, -1]])
    check('enters filter', solve([2, [[7, 1, 4]]]), [[7, 4, 1]])
    check('changes within filter', solve([2, [[7, 3, 4]]]), [[7, 3, -1], [7, 4, 1]])
    check('unchanged', solve([2, [[7, 2, 2]]]), [])
    check('insert', solve([2, [[7, None, 3]]]), [[7, 3, 1]])
    check('delete', solve([2, [[7, 3, None]]]), [[7, 3, -1]])
    check('outside both', solve([2, [[7, 0, 1]]]), [])
    check('no updates', solve([2, []]), [])
elif N == 3:
    check('leaves filter', solve([3, [[7, 5, 2]]]), [[7, 5, -1]])
    check('enters filter', solve([3, [[7, 2, 5]]]), [[7, 5, 1]])
    check('changes within filter', solve([3, [[7, 4, 5]]]), [[7, 4, -1], [7, 5, 1]])
    check('unchanged', solve([3, [[7, 3, 3]]]), [])
    check('insert', solve([3, [[7, None, 4]]]), [[7, 4, 1]])
    check('delete', solve([3, [[7, 4, None]]]), [[7, 4, -1]])
    check('outside both', solve([3, [[7, 1, 2]]]), [])
    check('no updates', solve([3, []]), [])
elif N == 4:
    check('leaves filter', solve([4, [[7, 6, 3]]]), [[7, 6, -1]])
    check('enters filter', solve([4, [[7, 3, 6]]]), [[7, 6, 1]])
    check('changes within filter', solve([4, [[7, 5, 6]]]), [[7, 5, -1], [7, 6, 1]])
    check('unchanged', solve([4, [[7, 4, 4]]]), [])
    check('insert', solve([4, [[7, None, 5]]]), [[7, 5, 1]])
    check('delete', solve([4, [[7, 5, None]]]), [[7, 5, -1]])
    check('outside both', solve([4, [[7, 2, 3]]]), [])
    check('no updates', solve([4, []]), [])
elif N == 5:
    check('leaves filter', solve([5, [[7, 7, 4]]]), [[7, 7, -1]])
    check('enters filter', solve([5, [[7, 4, 7]]]), [[7, 7, 1]])
    check('changes within filter', solve([5, [[7, 6, 7]]]), [[7, 6, -1], [7, 7, 1]])
    check('unchanged', solve([5, [[7, 5, 5]]]), [])
    check('insert', solve([5, [[7, None, 6]]]), [[7, 6, 1]])
    check('delete', solve([5, [[7, 6, None]]]), [[7, 6, -1]])
    check('outside both', solve([5, [[7, 3, 4]]]), [])
    check('no updates', solve([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:
Update filtering uses the after predicate for its before image.

Convert a sequence of [id,before,after] updates into signed filtered rows, with None denoting absent row. The predicate is value>=cutoff. Emit qualifying before-images negatively before qualifying after-images positively; suppress unchanged qualifying values.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        cutoff,updates=d
        out=[]
        for ident,before,after in updates:
            old=before is not None and before>=cutoff
            new=before is not None and before>=cutoff and after is not None
            if old and new and before==after: continue
            if old: out.append([ident,before,-1])
            if new: out.append([ident,after,1])
        return out
    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('leaves filter', solve([1, [[7, 3, 0]]]), [[7, 3, -1]])
    check('enters filter', solve([1, [[7, 0, 3]]]), [[7, 3, 1]])
    check('changes within filter', solve([1, [[7, 2, 3]]]), [[7, 2, -1], [7, 3, 1]])
    check('unchanged', solve([1, [[7, 1, 1]]]), [])
    check('insert', solve([1, [[7, None, 2]]]), [[7, 2, 1]])
    check('delete', solve([1, [[7, 2, None]]]), [[7, 2, -1]])
    check('outside both', solve([1, [[7, -1, 0]]]), [])
    check('no updates', solve([1, []]), [])
elif N == 2:
    check('leaves filter', solve([2, [[7, 4, 1]]]), [[7, 4, -1]])
    check('enters filter', solve([2, [[7, 1, 4]]]), [[7, 4, 1]])
    check('changes within filter', solve([2, [[7, 3, 4]]]), [[7, 3, -1], [7, 4, 1]])
    check('unchanged', solve([2, [[7, 2, 2]]]), [])
    check('insert', solve([2, [[7, None, 3]]]), [[7, 3, 1]])
    check('delete', solve([2, [[7, 3, None]]]), [[7, 3, -1]])
    check('outside both', solve([2, [[7, 0, 1]]]), [])
    check('no updates', solve([2, []]), [])
elif N == 3:
    check('leaves filter', solve([3, [[7, 5, 2]]]), [[7, 5, -1]])
    check('enters filter', solve([3, [[7, 2, 5]]]), [[7, 5, 1]])
    check('changes within filter', solve([3, [[7, 4, 5]]]), [[7, 4, -1], [7, 5, 1]])
    check('unchanged', solve([3, [[7, 3, 3]]]), [])
    check('insert', solve([3, [[7, None, 4]]]), [[7, 4, 1]])
    check('delete', solve([3, [[7, 4, None]]]), [[7, 4, -1]])
    check('outside both', solve([3, [[7, 1, 2]]]), [])
    check('no updates', solve([3, []]), [])
elif N == 4:
    check('leaves filter', solve([4, [[7, 6, 3]]]), [[7, 6, -1]])
    check('enters filter', solve([4, [[7, 3, 6]]]), [[7, 6, 1]])
    check('changes within filter', solve([4, [[7, 5, 6]]]), [[7, 5, -1], [7, 6, 1]])
    check('unchanged', solve([4, [[7, 4, 4]]]), [])
    check('insert', solve([4, [[7, None, 5]]]), [[7, 5, 1]])
    check('delete', solve([4, [[7, 5, None]]]), [[7, 5, -1]])
    check('outside both', solve([4, [[7, 2, 3]]]), [])
    check('no updates', solve([4, []]), [])
elif N == 5:
    check('leaves filter', solve([5, [[7, 7, 4]]]), [[7, 7, -1]])
    check('enters filter', solve([5, [[7, 4, 7]]]), [[7, 7, 1]])
    check('changes within filter', solve([5, [[7, 6, 7]]]), [[7, 6, -1], [7, 7, 1]])
    check('unchanged', solve([5, [[7, 5, 5]]]), [])
    check('insert', solve([5, [[7, None, 6]]]), [[7, 6, 1]])
    check('delete', solve([5, [[7, 6, None]]]), [[7, 6, -1]])
    check('outside both', solve([5, [[7, 3, 4]]]), [])
    check('no updates', solve([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:
        cutoff,updates=d
        out=[]
        for ident,before,after in updates:
            old=before is not None and before>=cutoff
            new=before is not None and after is not None and after>=cutoff
            if old and new and before==after: continue
            if old: out.append([ident,before,-1])
            if new: out.append([ident,after,1])
        return out
    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('leaves filter', solve([1, [[7, 3, 0]]]), [[7, 3, -1]])
    check('enters filter', solve([1, [[7, 0, 3]]]), [[7, 3, 1]])
    check('changes within filter', solve([1, [[7, 2, 3]]]), [[7, 2, -1], [7, 3, 1]])
    check('unchanged', solve([1, [[7, 1, 1]]]), [])
    check('insert', solve([1, [[7, None, 2]]]), [[7, 2, 1]])
    check('delete', solve([1, [[7, 2, None]]]), [[7, 2, -1]])
    check('outside both', solve([1, [[7, -1, 0]]]), [])
    check('no updates', solve([1, []]), [])
elif N == 2:
    check('leaves filter', solve([2, [[7, 4, 1]]]), [[7, 4, -1]])
    check('enters filter', solve([2, [[7, 1, 4]]]), [[7, 4, 1]])
    check('changes within filter', solve([2, [[7, 3, 4]]]), [[7, 3, -1], [7, 4, 1]])
    check('unchanged', solve([2, [[7, 2, 2]]]), [])
    check('insert', solve([2, [[7, None, 3]]]), [[7, 3, 1]])
    check('delete', solve([2, [[7, 3, None]]]), [[7, 3, -1]])
    check('outside both', solve([2, [[7, 0, 1]]]), [])
    check('no updates', solve([2, []]), [])
elif N == 3:
    check('leaves filter', solve([3, [[7, 5, 2]]]), [[7, 5, -1]])
    check('enters filter', solve([3, [[7, 2, 5]]]), [[7, 5, 1]])
    check('changes within filter', solve([3, [[7, 4, 5]]]), [[7, 4, -1], [7, 5, 1]])
    check('unchanged', solve([3, [[7, 3, 3]]]), [])
    check('insert', solve([3, [[7, None, 4]]]), [[7, 4, 1]])
    check('delete', solve([3, [[7, 4, None]]]), [[7, 4, -1]])
    check('outside both', solve([3, [[7, 1, 2]]]), [])
    check('no updates', solve([3, []]), [])
elif N == 4:
    check('leaves filter', solve([4, [[7, 6, 3]]]), [[7, 6, -1]])
    check('enters filter', solve([4, [[7, 3, 6]]]), [[7, 6, 1]])
    check('changes within filter', solve([4, [[7, 5, 6]]]), [[7, 5, -1], [7, 6, 1]])
    check('unchanged', solve([4, [[7, 4, 4]]]), [])
    check('insert', solve([4, [[7, None, 5]]]), [[7, 5, 1]])
    check('delete', solve([4, [[7, 5, None]]]), [[7, 5, -1]])
    check('outside both', solve([4, [[7, 2, 3]]]), [])
    check('no updates', solve([4, []]), [])
elif N == 5:
    check('leaves filter', solve([5, [[7, 7, 4]]]), [[7, 7, -1]])
    check('enters filter', solve([5, [[7, 4, 7]]]), [[7, 7, 1]])
    check('changes within filter', solve([5, [[7, 6, 7]]]), [[7, 6, -1], [7, 7, 1]])
    check('unchanged', solve([5, [[7, 5, 5]]]), [])
    check('insert', solve([5, [[7, None, 6]]]), [[7, 6, 1]])
    check('delete', solve([5, [[7, 6, None]]]), [[7, 6, -1]])
    check('outside both', solve([5, [[7, 3, 4]]]), [])
    check('no updates', solve([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:
Update filtering uses the before predicate for its after image.

Convert a sequence of [id,before,after] updates into signed filtered rows, with None denoting absent row. The predicate is value>=cutoff. Emit qualifying before-images negatively before qualifying after-images positively; suppress unchanged qualifying values.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        cutoff,updates=d
        out=[]
        for ident,before,after in updates:
            old=before is not None and before>=cutoff
            new=after is not None and after>=cutoff
            if False: continue
            if old: out.append([ident,before,-1])
            if new: out.append([ident,after,1])
        return out
    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('leaves filter', solve([1, [[7, 3, 0]]]), [[7, 3, -1]])
    check('enters filter', solve([1, [[7, 0, 3]]]), [[7, 3, 1]])
    check('changes within filter', solve([1, [[7, 2, 3]]]), [[7, 2, -1], [7, 3, 1]])
    check('unchanged', solve([1, [[7, 1, 1]]]), [])
    check('insert', solve([1, [[7, None, 2]]]), [[7, 2, 1]])
    check('delete', solve([1, [[7, 2, None]]]), [[7, 2, -1]])
    check('outside both', solve([1, [[7, -1, 0]]]), [])
    check('no updates', solve([1, []]), [])
elif N == 2:
    check('leaves filter', solve([2, [[7, 4, 1]]]), [[7, 4, -1]])
    check('enters filter', solve([2, [[7, 1, 4]]]), [[7, 4, 1]])
    check('changes within filter', solve([2, [[7, 3, 4]]]), [[7, 3, -1], [7, 4, 1]])
    check('unchanged', solve([2, [[7, 2, 2]]]), [])
    check('insert', solve([2, [[7, None, 3]]]), [[7, 3, 1]])
    check('delete', solve([2, [[7, 3, None]]]), [[7, 3, -1]])
    check('outside both', solve([2, [[7, 0, 1]]]), [])
    check('no updates', solve([2, []]), [])
elif N == 3:
    check('leaves filter', solve([3, [[7, 5, 2]]]), [[7, 5, -1]])
    check('enters filter', solve([3, [[7, 2, 5]]]), [[7, 5, 1]])
    check('changes within filter', solve([3, [[7, 4, 5]]]), [[7, 4, -1], [7, 5, 1]])
    check('unchanged', solve([3, [[7, 3, 3]]]), [])
    check('insert', solve([3, [[7, None, 4]]]), [[7, 4, 1]])
    check('delete', solve([3, [[7, 4, None]]]), [[7, 4, -1]])
    check('outside both', solve([3, [[7, 1, 2]]]), [])
    check('no updates', solve([3, []]), [])
elif N == 4:
    check('leaves filter', solve([4, [[7, 6, 3]]]), [[7, 6, -1]])
    check('enters filter', solve([4, [[7, 3, 6]]]), [[7, 6, 1]])
    check('changes within filter', solve([4, [[7, 5, 6]]]), [[7, 5, -1], [7, 6, 1]])
    check('unchanged', solve([4, [[7, 4, 4]]]), [])
    check('insert', solve([4, [[7, None, 5]]]), [[7, 5, 1]])
    check('delete', solve([4, [[7, 5, None]]]), [[7, 5, -1]])
    check('outside both', solve([4, [[7, 2, 3]]]), [])
    check('no updates', solve([4, []]), [])
elif N == 5:
    check('leaves filter', solve([5, [[7, 7, 4]]]), [[7, 7, -1]])
    check('enters filter', solve([5, [[7, 4, 7]]]), [[7, 7, 1]])
    check('changes within filter', solve([5, [[7, 6, 7]]]), [[7, 6, -1], [7, 7, 1]])
    check('unchanged', solve([5, [[7, 5, 5]]]), [])
    check('insert', solve([5, [[7, None, 6]]]), [[7, 6, 1]])
    check('delete', solve([5, [[7, 6, None]]]), [[7, 6, -1]])
    check('outside both', solve([5, [[7, 3, 4]]]), [])
    check('no updates', solve([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:
        cutoff,updates=d
        out=[]
        for ident,before,after in updates:
            old=before is not None and before>=cutoff
            new=after is not None and after>=cutoff
            if old and new: continue
            if old: out.append([ident,before,-1])
            if new: out.append([ident,after,1])
        return out
    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('leaves filter', solve([1, [[7, 3, 0]]]), [[7, 3, -1]])
    check('enters filter', solve([1, [[7, 0, 3]]]), [[7, 3, 1]])
    check('changes within filter', solve([1, [[7, 2, 3]]]), [[7, 2, -1], [7, 3, 1]])
    check('unchanged', solve([1, [[7, 1, 1]]]), [])
    check('insert', solve([1, [[7, None, 2]]]), [[7, 2, 1]])
    check('delete', solve([1, [[7, 2, None]]]), [[7, 2, -1]])
    check('outside both', solve([1, [[7, -1, 0]]]), [])
    check('no updates', solve([1, []]), [])
elif N == 2:
    check('leaves filter', solve([2, [[7, 4, 1]]]), [[7, 4, -1]])
    check('enters filter', solve([2, [[7, 1, 4]]]), [[7, 4, 1]])
    check('changes within filter', solve([2, [[7, 3, 4]]]), [[7, 3, -1], [7, 4, 1]])
    check('unchanged', solve([2, [[7, 2, 2]]]), [])
    check('insert', solve([2, [[7, None, 3]]]), [[7, 3, 1]])
    check('delete', solve([2, [[7, 3, None]]]), [[7, 3, -1]])
    check('outside both', solve([2, [[7, 0, 1]]]), [])
    check('no updates', solve([2, []]), [])
elif N == 3:
    check('leaves filter', solve([3, [[7, 5, 2]]]), [[7, 5, -1]])
    check('enters filter', solve([3, [[7, 2, 5]]]), [[7, 5, 1]])
    check('changes within filter', solve([3, [[7, 4, 5]]]), [[7, 4, -1], [7, 5, 1]])
    check('unchanged', solve([3, [[7, 3, 3]]]), [])
    check('insert', solve([3, [[7, None, 4]]]), [[7, 4, 1]])
    check('delete', solve([3, [[7, 4, None]]]), [[7, 4, -1]])
    check('outside both', solve([3, [[7, 1, 2]]]), [])
    check('no updates', solve([3, []]), [])
elif N == 4:
    check('leaves filter', solve([4, [[7, 6, 3]]]), [[7, 6, -1]])
    check('enters filter', solve([4, [[7, 3, 6]]]), [[7, 6, 1]])
    check('changes within filter', solve([4, [[7, 5, 6]]]), [[7, 5, -1], [7, 6, 1]])
    check('unchanged', solve([4, [[7, 4, 4]]]), [])
    check('insert', solve([4, [[7, None, 5]]]), [[7, 5, 1]])
    check('delete', solve([4, [[7, 5, None]]]), [[7, 5, -1]])
    check('outside both', solve([4, [[7, 2, 3]]]), [])
    check('no updates', solve([4, []]), [])
elif N == 5:
    check('leaves filter', solve([5, [[7, 7, 4]]]), [[7, 7, -1]])
    check('enters filter', solve([5, [[7, 4, 7]]]), [[7, 7, 1]])
    check('changes within filter', solve([5, [[7, 6, 7]]]), [[7, 6, -1], [7, 7, 1]])
    check('unchanged', solve([5, [[7, 5, 5]]]), [])
    check('insert', solve([5, [[7, None, 6]]]), [[7, 6, 1]])
    check('delete', solve([5, [[7, 6, None]]]), [[7, 6, -1]])
    check('outside both', solve([5, [[7, 3, 4]]]), [])
    check('no updates', solve([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:
Filtered updates emit unchanged rows as spurious changes.

Convert a sequence of [id,before,after] updates into signed filtered rows, with None denoting absent row. The predicate is value>=cutoff. Emit qualifying before-images negatively before qualifying after-images positively; suppress unchanged qualifying values.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        cutoff,updates=d
        out=[]
        for ident,before,after in updates:
            old=before is not None and before>=cutoff
            new=after is not None and after>=cutoff
            if old and new and before==after: continue
            if old: out.append([ident,after,-1])
            if new: out.append([ident,after,1])
        return out
    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('leaves filter', solve([1, [[7, 3, 0]]]), [[7, 3, -1]])
    check('enters filter', solve([1, [[7, 0, 3]]]), [[7, 3, 1]])
    check('changes within filter', solve([1, [[7, 2, 3]]]), [[7, 2, -1], [7, 3, 1]])
    check('unchanged', solve([1, [[7, 1, 1]]]), [])
    check('insert', solve([1, [[7, None, 2]]]), [[7, 2, 1]])
    check('delete', solve([1, [[7, 2, None]]]), [[7, 2, -1]])
    check('outside both', solve([1, [[7, -1, 0]]]), [])
    check('no updates', solve([1, []]), [])
elif N == 2:
    check('leaves filter', solve([2, [[7, 4, 1]]]), [[7, 4, -1]])
    check('enters filter', solve([2, [[7, 1, 4]]]), [[7, 4, 1]])
    check('changes within filter', solve([2, [[7, 3, 4]]]), [[7, 3, -1], [7, 4, 1]])
    check('unchanged', solve([2, [[7, 2, 2]]]), [])
    check('insert', solve([2, [[7, None, 3]]]), [[7, 3, 1]])
    check('delete', solve([2, [[7, 3, None]]]), [[7, 3, -1]])
    check('outside both', solve([2, [[7, 0, 1]]]), [])
    check('no updates', solve([2, []]), [])
elif N == 3:
    check('leaves filter', solve([3, [[7, 5, 2]]]), [[7, 5, -1]])
    check('enters filter', solve([3, [[7, 2, 5]]]), [[7, 5, 1]])
    check('changes within filter', solve([3, [[7, 4, 5]]]), [[7, 4, -1], [7, 5, 1]])
    check('unchanged', solve([3, [[7, 3, 3]]]), [])
    check('insert', solve([3, [[7, None, 4]]]), [[7, 4, 1]])
    check('delete', solve([3, [[7, 4, None]]]), [[7, 4, -1]])
    check('outside both', solve([3, [[7, 1, 2]]]), [])
    check('no updates', solve([3, []]), [])
elif N == 4:
    check('leaves filter', solve([4, [[7, 6, 3]]]), [[7, 6, -1]])
    check('enters filter', solve([4, [[7, 3, 6]]]), [[7, 6, 1]])
    check('changes within filter', solve([4, [[7, 5, 6]]]), [[7, 5, -1], [7, 6, 1]])
    check('unchanged', solve([4, [[7, 4, 4]]]), [])
    check('insert', solve([4, [[7, None, 5]]]), [[7, 5, 1]])
    check('delete', solve([4, [[7, 5, None]]]), [[7, 5, -1]])
    check('outside both', solve([4, [[7, 2, 3]]]), [])
    check('no updates', solve([4, []]), [])
elif N == 5:
    check('leaves filter', solve([5, [[7, 7, 4]]]), [[7, 7, -1]])
    check('enters filter', solve([5, [[7, 4, 7]]]), [[7, 7, 1]])
    check('changes within filter', solve([5, [[7, 6, 7]]]), [[7, 6, -1], [7, 7, 1]])
    check('unchanged', solve([5, [[7, 5, 5]]]), [])
    check('insert', solve([5, [[7, None, 6]]]), [[7, 6, 1]])
    check('delete', solve([5, [[7, 6, None]]]), [[7, 6, -1]])
    check('outside both', solve([5, [[7, 3, 4]]]), [])
    check('no updates', solve([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:
        cutoff,updates=d
        out=[]
        for ident,before,after in updates:
            old=before is not None and before>=cutoff
            new=after is not None and after>=cutoff
            if old and new and before==after: continue
            if old: out.append([ident,cutoff,-1])
            if new: out.append([ident,after,1])
        return out
    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('leaves filter', solve([1, [[7, 3, 0]]]), [[7, 3, -1]])
    check('enters filter', solve([1, [[7, 0, 3]]]), [[7, 3, 1]])
    check('changes within filter', solve([1, [[7, 2, 3]]]), [[7, 2, -1], [7, 3, 1]])
    check('unchanged', solve([1, [[7, 1, 1]]]), [])
    check('insert', solve([1, [[7, None, 2]]]), [[7, 2, 1]])
    check('delete', solve([1, [[7, 2, None]]]), [[7, 2, -1]])
    check('outside both', solve([1, [[7, -1, 0]]]), [])
    check('no updates', solve([1, []]), [])
elif N == 2:
    check('leaves filter', solve([2, [[7, 4, 1]]]), [[7, 4, -1]])
    check('enters filter', solve([2, [[7, 1, 4]]]), [[7, 4, 1]])
    check('changes within filter', solve([2, [[7, 3, 4]]]), [[7, 3, -1], [7, 4, 1]])
    check('unchanged', solve([2, [[7, 2, 2]]]), [])
    check('insert', solve([2, [[7, None, 3]]]), [[7, 3, 1]])
    check('delete', solve([2, [[7, 3, None]]]), [[7, 3, -1]])
    check('outside both', solve([2, [[7, 0, 1]]]), [])
    check('no updates', solve([2, []]), [])
elif N == 3:
    check('leaves filter', solve([3, [[7, 5, 2]]]), [[7, 5, -1]])
    check('enters filter', solve([3, [[7, 2, 5]]]), [[7, 5, 1]])
    check('changes within filter', solve([3, [[7, 4, 5]]]), [[7, 4, -1], [7, 5, 1]])
    check('unchanged', solve([3, [[7, 3, 3]]]), [])
    check('insert', solve([3, [[7, None, 4]]]), [[7, 4, 1]])
    check('delete', solve([3, [[7, 4, None]]]), [[7, 4, -1]])
    check('outside both', solve([3, [[7, 1, 2]]]), [])
    check('no updates', solve([3, []]), [])
elif N == 4:
    check('leaves filter', solve([4, [[7, 6, 3]]]), [[7, 6, -1]])
    check('enters filter', solve([4, [[7, 3, 6]]]), [[7, 6, 1]])
    check('changes within filter', solve([4, [[7, 5, 6]]]), [[7, 5, -1], [7, 6, 1]])
    check('unchanged', solve([4, [[7, 4, 4]]]), [])
    check('insert', solve([4, [[7, None, 5]]]), [[7, 5, 1]])
    check('delete', solve([4, [[7, 5, None]]]), [[7, 5, -1]])
    check('outside both', solve([4, [[7, 2, 3]]]), [])
    check('no updates', solve([4, []]), [])
elif N == 5:
    check('leaves filter', solve([5, [[7, 7, 4]]]), [[7, 7, -1]])
    check('enters filter', solve([5, [[7, 4, 7]]]), [[7, 7, 1]])
    check('changes within filter', solve([5, [[7, 6, 7]]]), [[7, 6, -1], [7, 7, 1]])
    check('unchanged', solve([5, [[7, 5, 5]]]), [])
    check('insert', solve([5, [[7, None, 6]]]), [[7, 6, 1]])
    check('delete', solve([5, [[7, 6, None]]]), [[7, 6, -1]])
    check('outside both', solve([5, [[7, 3, 4]]]), [])
    check('no updates', solve([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:
Retractions carry the new value instead of the old value.

Convert a sequence of [id,before,after] updates into signed filtered rows, with None denoting absent row. The predicate is value>=cutoff. Emit qualifying before-images negatively before qualifying after-images positively; suppress unchanged qualifying values.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        cutoff,updates=d
        out=[]
        for ident,before,after in updates:
            old=before is not None and before>=cutoff
            new=after is not None and after>=cutoff
            if old and new and before==after: continue
            if old: out.append([ident,before,-1])
            if new: out.append([ident,before,1])
        return out
    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('leaves filter', solve([1, [[7, 3, 0]]]), [[7, 3, -1]])
    check('enters filter', solve([1, [[7, 0, 3]]]), [[7, 3, 1]])
    check('changes within filter', solve([1, [[7, 2, 3]]]), [[7, 2, -1], [7, 3, 1]])
    check('unchanged', solve([1, [[7, 1, 1]]]), [])
    check('insert', solve([1, [[7, None, 2]]]), [[7, 2, 1]])
    check('delete', solve([1, [[7, 2, None]]]), [[7, 2, -1]])
    check('outside both', solve([1, [[7, -1, 0]]]), [])
    check('no updates', solve([1, []]), [])
elif N == 2:
    check('leaves filter', solve([2, [[7, 4, 1]]]), [[7, 4, -1]])
    check('enters filter', solve([2, [[7, 1, 4]]]), [[7, 4, 1]])
    check('changes within filter', solve([2, [[7, 3, 4]]]), [[7, 3, -1], [7, 4, 1]])
    check('unchanged', solve([2, [[7, 2, 2]]]), [])
    check('insert', solve([2, [[7, None, 3]]]), [[7, 3, 1]])
    check('delete', solve([2, [[7, 3, None]]]), [[7, 3, -1]])
    check('outside both', solve([2, [[7, 0, 1]]]), [])
    check('no updates', solve([2, []]), [])
elif N == 3:
    check('leaves filter', solve([3, [[7, 5, 2]]]), [[7, 5, -1]])
    check('enters filter', solve([3, [[7, 2, 5]]]), [[7, 5, 1]])
    check('changes within filter', solve([3, [[7, 4, 5]]]), [[7, 4, -1], [7, 5, 1]])
    check('unchanged', solve([3, [[7, 3, 3]]]), [])
    check('insert', solve([3, [[7, None, 4]]]), [[7, 4, 1]])
    check('delete', solve([3, [[7, 4, None]]]), [[7, 4, -1]])
    check('outside both', solve([3, [[7, 1, 2]]]), [])
    check('no updates', solve([3, []]), [])
elif N == 4:
    check('leaves filter', solve([4, [[7, 6, 3]]]), [[7, 6, -1]])
    check('enters filter', solve([4, [[7, 3, 6]]]), [[7, 6, 1]])
    check('changes within filter', solve([4, [[7, 5, 6]]]), [[7, 5, -1], [7, 6, 1]])
    check('unchanged', solve([4, [[7, 4, 4]]]), [])
    check('insert', solve([4, [[7, None, 5]]]), [[7, 5, 1]])
    check('delete', solve([4, [[7, 5, None]]]), [[7, 5, -1]])
    check('outside both', solve([4, [[7, 2, 3]]]), [])
    check('no updates', solve([4, []]), [])
elif N == 5:
    check('leaves filter', solve([5, [[7, 7, 4]]]), [[7, 7, -1]])
    check('enters filter', solve([5, [[7, 4, 7]]]), [[7, 7, 1]])
    check('changes within filter', solve([5, [[7, 6, 7]]]), [[7, 6, -1], [7, 7, 1]])
    check('unchanged', solve([5, [[7, 5, 5]]]), [])
    check('insert', solve([5, [[7, None, 6]]]), [[7, 6, 1]])
    check('delete', solve([5, [[7, 6, None]]]), [[7, 6, -1]])
    check('outside both', solve([5, [[7, 3, 4]]]), [])
    check('no updates', solve([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:
        cutoff,updates=d
        out=[]
        for ident,before,after in updates:
            old=before is not None and before>=cutoff
            new=after is not None and after>=cutoff
            if old and new and before==after: continue
            if old: out.append([ident,before,-1])
            if new: out.append([ident,cutoff,1])
        return out
    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('leaves filter', solve([1, [[7, 3, 0]]]), [[7, 3, -1]])
    check('enters filter', solve([1, [[7, 0, 3]]]), [[7, 3, 1]])
    check('changes within filter', solve([1, [[7, 2, 3]]]), [[7, 2, -1], [7, 3, 1]])
    check('unchanged', solve([1, [[7, 1, 1]]]), [])
    check('insert', solve([1, [[7, None, 2]]]), [[7, 2, 1]])
    check('delete', solve([1, [[7, 2, None]]]), [[7, 2, -1]])
    check('outside both', solve([1, [[7, -1, 0]]]), [])
    check('no updates', solve([1, []]), [])
elif N == 2:
    check('leaves filter', solve([2, [[7, 4, 1]]]), [[7, 4, -1]])
    check('enters filter', solve([2, [[7, 1, 4]]]), [[7, 4, 1]])
    check('changes within filter', solve([2, [[7, 3, 4]]]), [[7, 3, -1], [7, 4, 1]])
    check('unchanged', solve([2, [[7, 2, 2]]]), [])
    check('insert', solve([2, [[7, None, 3]]]), [[7, 3, 1]])
    check('delete', solve([2, [[7, 3, None]]]), [[7, 3, -1]])
    check('outside both', solve([2, [[7, 0, 1]]]), [])
    check('no updates', solve([2, []]), [])
elif N == 3:
    check('leaves filter', solve([3, [[7, 5, 2]]]), [[7, 5, -1]])
    check('enters filter', solve([3, [[7, 2, 5]]]), [[7, 5, 1]])
    check('changes within filter', solve([3, [[7, 4, 5]]]), [[7, 4, -1], [7, 5, 1]])
    check('unchanged', solve([3, [[7, 3, 3]]]), [])
    check('insert', solve([3, [[7, None, 4]]]), [[7, 4, 1]])
    check('delete', solve([3, [[7, 4, None]]]), [[7, 4, -1]])
    check('outside both', solve([3, [[7, 1, 2]]]), [])
    check('no updates', solve([3, []]), [])
elif N == 4:
    check('leaves filter', solve([4, [[7, 6, 3]]]), [[7, 6, -1]])
    check('enters filter', solve([4, [[7, 3, 6]]]), [[7, 6, 1]])
    check('changes within filter', solve([4, [[7, 5, 6]]]), [[7, 5, -1], [7, 6, 1]])
    check('unchanged', solve([4, [[7, 4, 4]]]), [])
    check('insert', solve([4, [[7, None, 5]]]), [[7, 5, 1]])
    check('delete', solve([4, [[7, 5, None]]]), [[7, 5, -1]])
    check('outside both', solve([4, [[7, 2, 3]]]), [])
    check('no updates', solve([4, []]), [])
elif N == 5:
    check('leaves filter', solve([5, [[7, 7, 4]]]), [[7, 7, -1]])
    check('enters filter', solve([5, [[7, 4, 7]]]), [[7, 7, 1]])
    check('changes within filter', solve([5, [[7, 6, 7]]]), [[7, 6, -1], [7, 7, 1]])
    check('unchanged', solve([5, [[7, 5, 5]]]), [])
    check('insert', solve([5, [[7, None, 6]]]), [[7, 6, 1]])
    check('delete', solve([5, [[7, 6, None]]]), [[7, 6, -1]])
    check('outside both', solve([5, [[7, 3, 4]]]), [])
    check('no updates', solve([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:
Insertions carry the old value instead of the new value.

Convert a sequence of [id,before,after] updates into signed filtered rows, with None denoting absent row. The predicate is value>=cutoff. Emit qualifying before-images negatively before qualifying after-images positively; suppress unchanged qualifying values.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        cutoff,updates=d
        out=[]
        for ident,before,after in updates:
            old=before is not None and before>=cutoff
            new=after is not None and after>=cutoff
            if old and new and before==after: continue
            if old: out.append([ident,before,-1])
            if new: out.append([ident,after,1])
        return list(reversed(out))
    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('leaves filter', solve([1, [[7, 3, 0]]]), [[7, 3, -1]])
    check('enters filter', solve([1, [[7, 0, 3]]]), [[7, 3, 1]])
    check('changes within filter', solve([1, [[7, 2, 3]]]), [[7, 2, -1], [7, 3, 1]])
    check('unchanged', solve([1, [[7, 1, 1]]]), [])
    check('insert', solve([1, [[7, None, 2]]]), [[7, 2, 1]])
    check('delete', solve([1, [[7, 2, None]]]), [[7, 2, -1]])
    check('outside both', solve([1, [[7, -1, 0]]]), [])
    check('no updates', solve([1, []]), [])
elif N == 2:
    check('leaves filter', solve([2, [[7, 4, 1]]]), [[7, 4, -1]])
    check('enters filter', solve([2, [[7, 1, 4]]]), [[7, 4, 1]])
    check('changes within filter', solve([2, [[7, 3, 4]]]), [[7, 3, -1], [7, 4, 1]])
    check('unchanged', solve([2, [[7, 2, 2]]]), [])
    check('insert', solve([2, [[7, None, 3]]]), [[7, 3, 1]])
    check('delete', solve([2, [[7, 3, None]]]), [[7, 3, -1]])
    check('outside both', solve([2, [[7, 0, 1]]]), [])
    check('no updates', solve([2, []]), [])
elif N == 3:
    check('leaves filter', solve([3, [[7, 5, 2]]]), [[7, 5, -1]])
    check('enters filter', solve([3, [[7, 2, 5]]]), [[7, 5, 1]])
    check('changes within filter', solve([3, [[7, 4, 5]]]), [[7, 4, -1], [7, 5, 1]])
    check('unchanged', solve([3, [[7, 3, 3]]]), [])
    check('insert', solve([3, [[7, None, 4]]]), [[7, 4, 1]])
    check('delete', solve([3, [[7, 4, None]]]), [[7, 4, -1]])
    check('outside both', solve([3, [[7, 1, 2]]]), [])
    check('no updates', solve([3, []]), [])
elif N == 4:
    check('leaves filter', solve([4, [[7, 6, 3]]]), [[7, 6, -1]])
    check('enters filter', solve([4, [[7, 3, 6]]]), [[7, 6, 1]])
    check('changes within filter', solve([4, [[7, 5, 6]]]), [[7, 5, -1], [7, 6, 1]])
    check('unchanged', solve([4, [[7, 4, 4]]]), [])
    check('insert', solve([4, [[7, None, 5]]]), [[7, 5, 1]])
    check('delete', solve([4, [[7, 5, None]]]), [[7, 5, -1]])
    check('outside both', solve([4, [[7, 2, 3]]]), [])
    check('no updates', solve([4, []]), [])
elif N == 5:
    check('leaves filter', solve([5, [[7, 7, 4]]]), [[7, 7, -1]])
    check('enters filter', solve([5, [[7, 4, 7]]]), [[7, 7, 1]])
    check('changes within filter', solve([5, [[7, 6, 7]]]), [[7, 6, -1], [7, 7, 1]])
    check('unchanged', solve([5, [[7, 5, 5]]]), [])
    check('insert', solve([5, [[7, None, 6]]]), [[7, 6, 1]])
    check('delete', solve([5, [[7, 6, None]]]), [[7, 6, -1]])
    check('outside both', solve([5, [[7, 3, 4]]]), [])
    check('no updates', solve([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:
        cutoff,updates=d
        out=[]
        for ident,before,after in updates:
            old=before is not None and before>=cutoff
            new=after is not None and after>=cutoff
            if old and new and before==after: continue
            if old: out.append([ident,before,-1])
            if new: out.append([ident,after,1])
        return sorted(out,key=lambda r:-r[2])
    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('leaves filter', solve([1, [[7, 3, 0]]]), [[7, 3, -1]])
    check('enters filter', solve([1, [[7, 0, 3]]]), [[7, 3, 1]])
    check('changes within filter', solve([1, [[7, 2, 3]]]), [[7, 2, -1], [7, 3, 1]])
    check('unchanged', solve([1, [[7, 1, 1]]]), [])
    check('insert', solve([1, [[7, None, 2]]]), [[7, 2, 1]])
    check('delete', solve([1, [[7, 2, None]]]), [[7, 2, -1]])
    check('outside both', solve([1, [[7, -1, 0]]]), [])
    check('no updates', solve([1, []]), [])
elif N == 2:
    check('leaves filter', solve([2, [[7, 4, 1]]]), [[7, 4, -1]])
    check('enters filter', solve([2, [[7, 1, 4]]]), [[7, 4, 1]])
    check('changes within filter', solve([2, [[7, 3, 4]]]), [[7, 3, -1], [7, 4, 1]])
    check('unchanged', solve([2, [[7, 2, 2]]]), [])
    check('insert', solve([2, [[7, None, 3]]]), [[7, 3, 1]])
    check('delete', solve([2, [[7, 3, None]]]), [[7, 3, -1]])
    check('outside both', solve([2, [[7, 0, 1]]]), [])
    check('no updates', solve([2, []]), [])
elif N == 3:
    check('leaves filter', solve([3, [[7, 5, 2]]]), [[7, 5, -1]])
    check('enters filter', solve([3, [[7, 2, 5]]]), [[7, 5, 1]])
    check('changes within filter', solve([3, [[7, 4, 5]]]), [[7, 4, -1], [7, 5, 1]])
    check('unchanged', solve([3, [[7, 3, 3]]]), [])
    check('insert', solve([3, [[7, None, 4]]]), [[7, 4, 1]])
    check('delete', solve([3, [[7, 4, None]]]), [[7, 4, -1]])
    check('outside both', solve([3, [[7, 1, 2]]]), [])
    check('no updates', solve([3, []]), [])
elif N == 4:
    check('leaves filter', solve([4, [[7, 6, 3]]]), [[7, 6, -1]])
    check('enters filter', solve([4, [[7, 3, 6]]]), [[7, 6, 1]])
    check('changes within filter', solve([4, [[7, 5, 6]]]), [[7, 5, -1], [7, 6, 1]])
    check('unchanged', solve([4, [[7, 4, 4]]]), [])
    check('insert', solve([4, [[7, None, 5]]]), [[7, 5, 1]])
    check('delete', solve([4, [[7, 5, None]]]), [[7, 5, -1]])
    check('outside both', solve([4, [[7, 2, 3]]]), [])
    check('no updates', solve([4, []]), [])
elif N == 5:
    check('leaves filter', solve([5, [[7, 7, 4]]]), [[7, 7, -1]])
    check('enters filter', solve([5, [[7, 4, 7]]]), [[7, 7, 1]])
    check('changes within filter', solve([5, [[7, 6, 7]]]), [[7, 6, -1], [7, 7, 1]])
    check('unchanged', solve([5, [[7, 5, 5]]]), [])
    check('insert', solve([5, [[7, None, 6]]]), [[7, 6, 1]])
    check('delete', solve([5, [[7, 6, None]]]), [[7, 6, -1]])
    check('outside both', solve([5, [[7, 3, 4]]]), [])
    check('no updates', solve([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:
A filtered update publishes insertion before retraction.

Convert a sequence of [id,before,after] updates into signed filtered rows, with None denoting absent row. The predicate is value>=cutoff. Emit qualifying before-images negatively before qualifying after-images positively; suppress unchanged qualifying values.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        initial,updates=d
        state={ident:[key,value] for ident,key,value in initial}
        out=[]
        for ident,key,value in updates:
            previous=next((r for r in state.values() if r[0]==key),None)
            if previous==[key,value]: continue
            if previous is not None: out.append([ident,previous[0],previous[1],-1])
            state[ident]=[key,value]
            out.append([ident,key,value,1])
        return [sorted([[i,k,v] for i,(k,v) in state.items()]),out]
    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('move key', solve([[[10, 1, 1]], [[10, 2, 2]]]), [[[10, 2, 2]], [[10, 1, 1, -1], [10, 2, 2, 1]]])
    check('same key changed value', solve([[[10, 1, 1]], [[10, 1, 2]]]), [[[10, 1, 2]], [[10, 1, 1, -1], [10, 1, 2, 1]]])
    check('same value moved', solve([[[10, 1, 1]], [[10, 2, 1]]]), [[[10, 2, 1]], [[10, 1, 1, -1], [10, 2, 1, 1]]])
    check('insert new identity', solve([[[10, 1, 1]], [[11, 1, 2]]]), [[[10, 1, 1], [11, 1, 2]], [[11, 1, 2, 1]]])
    check('identical upsert', solve([[[10, 1, 1]], [[10, 1, 1]]]), [[[10, 1, 1]], []])
    check('two updates', solve([[[10, 1, 1]], [[10, 2, 2], [10, 3, 3]]]), [[[10, 3, 3]], [[10, 1, 1, -1], [10, 2, 2, 1], [10, 2, 2, -1], [10, 3, 3, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 2:
    check('move key', solve([[[10, 1, 2]], [[10, 2, 3]]]), [[[10, 2, 3]], [[10, 1, 2, -1], [10, 2, 3, 1]]])
    check('same key changed value', solve([[[10, 1, 2]], [[10, 1, 3]]]), [[[10, 1, 3]], [[10, 1, 2, -1], [10, 1, 3, 1]]])
    check('same value moved', solve([[[10, 1, 2]], [[10, 2, 2]]]), [[[10, 2, 2]], [[10, 1, 2, -1], [10, 2, 2, 1]]])
    check('insert new identity', solve([[[10, 1, 2]], [[11, 1, 3]]]), [[[10, 1, 2], [11, 1, 3]], [[11, 1, 3, 1]]])
    check('identical upsert', solve([[[10, 1, 2]], [[10, 1, 2]]]), [[[10, 1, 2]], []])
    check('two updates', solve([[[10, 1, 2]], [[10, 2, 3], [10, 3, 4]]]), [[[10, 3, 4]], [[10, 1, 2, -1], [10, 2, 3, 1], [10, 2, 3, -1], [10, 3, 4, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 3:
    check('move key', solve([[[10, 1, 3]], [[10, 2, 4]]]), [[[10, 2, 4]], [[10, 1, 3, -1], [10, 2, 4, 1]]])
    check('same key changed value', solve([[[10, 1, 3]], [[10, 1, 4]]]), [[[10, 1, 4]], [[10, 1, 3, -1], [10, 1, 4, 1]]])
    check('same value moved', solve([[[10, 1, 3]], [[10, 2, 3]]]), [[[10, 2, 3]], [[10, 1, 3, -1], [10, 2, 3, 1]]])
    check('insert new identity', solve([[[10, 1, 3]], [[11, 1, 4]]]), [[[10, 1, 3], [11, 1, 4]], [[11, 1, 4, 1]]])
    check('identical upsert', solve([[[10, 1, 3]], [[10, 1, 3]]]), [[[10, 1, 3]], []])
    check('two updates', solve([[[10, 1, 3]], [[10, 2, 4], [10, 3, 5]]]), [[[10, 3, 5]], [[10, 1, 3, -1], [10, 2, 4, 1], [10, 2, 4, -1], [10, 3, 5, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 4:
    check('move key', solve([[[10, 1, 4]], [[10, 2, 5]]]), [[[10, 2, 5]], [[10, 1, 4, -1], [10, 2, 5, 1]]])
    check('same key changed value', solve([[[10, 1, 4]], [[10, 1, 5]]]), [[[10, 1, 5]], [[10, 1, 4, -1], [10, 1, 5, 1]]])
    check('same value moved', solve([[[10, 1, 4]], [[10, 2, 4]]]), [[[10, 2, 4]], [[10, 1, 4, -1], [10, 2, 4, 1]]])
    check('insert new identity', solve([[[10, 1, 4]], [[11, 1, 5]]]), [[[10, 1, 4], [11, 1, 5]], [[11, 1, 5, 1]]])
    check('identical upsert', solve([[[10, 1, 4]], [[10, 1, 4]]]), [[[10, 1, 4]], []])
    check('two updates', solve([[[10, 1, 4]], [[10, 2, 5], [10, 3, 6]]]), [[[10, 3, 6]], [[10, 1, 4, -1], [10, 2, 5, 1], [10, 2, 5, -1], [10, 3, 6, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 5:
    check('move key', solve([[[10, 1, 5]], [[10, 2, 6]]]), [[[10, 2, 6]], [[10, 1, 5, -1], [10, 2, 6, 1]]])
    check('same key changed value', solve([[[10, 1, 5]], [[10, 1, 6]]]), [[[10, 1, 6]], [[10, 1, 5, -1], [10, 1, 6, 1]]])
    check('same value moved', solve([[[10, 1, 5]], [[10, 2, 5]]]), [[[10, 2, 5]], [[10, 1, 5, -1], [10, 2, 5, 1]]])
    check('insert new identity', solve([[[10, 1, 5]], [[11, 1, 6]]]), [[[10, 1, 5], [11, 1, 6]], [[11, 1, 6, 1]]])
    check('identical upsert', solve([[[10, 1, 5]], [[10, 1, 5]]]), [[[10, 1, 5]], []])
    check('two updates', solve([[[10, 1, 5]], [[10, 2, 6], [10, 3, 7]]]), [[[10, 3, 7]], [[10, 1, 5, -1], [10, 2, 6, 1], [10, 2, 6, -1], [10, 3, 7, 1]]])
    check('empty table', solve([[], []]), [[], []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A keyed upsert looks up its old row by new key instead of identity.

Maintain an identity-indexed keyed table while applying [id,newkey,newvalue] upserts. A moved identity retracts its old key/value before adding the new row. Identical upserts emit no change. State and emitted changelog preserve identity distinctions.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        initial,updates=d
        state={ident:[key,value] for ident,key,value in initial}
        out=[]
        for ident,key,value in updates:
            previous=state.get(ident)
            if previous is not None and previous[0]==key: continue
            if previous is not None: out.append([ident,previous[0],previous[1],-1])
            state[ident]=[key,value]
            out.append([ident,key,value,1])
        return [sorted([[i,k,v] for i,(k,v) in state.items()]),out]
    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('move key', solve([[[10, 1, 1]], [[10, 2, 2]]]), [[[10, 2, 2]], [[10, 1, 1, -1], [10, 2, 2, 1]]])
    check('same key changed value', solve([[[10, 1, 1]], [[10, 1, 2]]]), [[[10, 1, 2]], [[10, 1, 1, -1], [10, 1, 2, 1]]])
    check('same value moved', solve([[[10, 1, 1]], [[10, 2, 1]]]), [[[10, 2, 1]], [[10, 1, 1, -1], [10, 2, 1, 1]]])
    check('insert new identity', solve([[[10, 1, 1]], [[11, 1, 2]]]), [[[10, 1, 1], [11, 1, 2]], [[11, 1, 2, 1]]])
    check('identical upsert', solve([[[10, 1, 1]], [[10, 1, 1]]]), [[[10, 1, 1]], []])
    check('two updates', solve([[[10, 1, 1]], [[10, 2, 2], [10, 3, 3]]]), [[[10, 3, 3]], [[10, 1, 1, -1], [10, 2, 2, 1], [10, 2, 2, -1], [10, 3, 3, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 2:
    check('move key', solve([[[10, 1, 2]], [[10, 2, 3]]]), [[[10, 2, 3]], [[10, 1, 2, -1], [10, 2, 3, 1]]])
    check('same key changed value', solve([[[10, 1, 2]], [[10, 1, 3]]]), [[[10, 1, 3]], [[10, 1, 2, -1], [10, 1, 3, 1]]])
    check('same value moved', solve([[[10, 1, 2]], [[10, 2, 2]]]), [[[10, 2, 2]], [[10, 1, 2, -1], [10, 2, 2, 1]]])
    check('insert new identity', solve([[[10, 1, 2]], [[11, 1, 3]]]), [[[10, 1, 2], [11, 1, 3]], [[11, 1, 3, 1]]])
    check('identical upsert', solve([[[10, 1, 2]], [[10, 1, 2]]]), [[[10, 1, 2]], []])
    check('two updates', solve([[[10, 1, 2]], [[10, 2, 3], [10, 3, 4]]]), [[[10, 3, 4]], [[10, 1, 2, -1], [10, 2, 3, 1], [10, 2, 3, -1], [10, 3, 4, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 3:
    check('move key', solve([[[10, 1, 3]], [[10, 2, 4]]]), [[[10, 2, 4]], [[10, 1, 3, -1], [10, 2, 4, 1]]])
    check('same key changed value', solve([[[10, 1, 3]], [[10, 1, 4]]]), [[[10, 1, 4]], [[10, 1, 3, -1], [10, 1, 4, 1]]])
    check('same value moved', solve([[[10, 1, 3]], [[10, 2, 3]]]), [[[10, 2, 3]], [[10, 1, 3, -1], [10, 2, 3, 1]]])
    check('insert new identity', solve([[[10, 1, 3]], [[11, 1, 4]]]), [[[10, 1, 3], [11, 1, 4]], [[11, 1, 4, 1]]])
    check('identical upsert', solve([[[10, 1, 3]], [[10, 1, 3]]]), [[[10, 1, 3]], []])
    check('two updates', solve([[[10, 1, 3]], [[10, 2, 4], [10, 3, 5]]]), [[[10, 3, 5]], [[10, 1, 3, -1], [10, 2, 4, 1], [10, 2, 4, -1], [10, 3, 5, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 4:
    check('move key', solve([[[10, 1, 4]], [[10, 2, 5]]]), [[[10, 2, 5]], [[10, 1, 4, -1], [10, 2, 5, 1]]])
    check('same key changed value', solve([[[10, 1, 4]], [[10, 1, 5]]]), [[[10, 1, 5]], [[10, 1, 4, -1], [10, 1, 5, 1]]])
    check('same value moved', solve([[[10, 1, 4]], [[10, 2, 4]]]), [[[10, 2, 4]], [[10, 1, 4, -1], [10, 2, 4, 1]]])
    check('insert new identity', solve([[[10, 1, 4]], [[11, 1, 5]]]), [[[10, 1, 4], [11, 1, 5]], [[11, 1, 5, 1]]])
    check('identical upsert', solve([[[10, 1, 4]], [[10, 1, 4]]]), [[[10, 1, 4]], []])
    check('two updates', solve([[[10, 1, 4]], [[10, 2, 5], [10, 3, 6]]]), [[[10, 3, 6]], [[10, 1, 4, -1], [10, 2, 5, 1], [10, 2, 5, -1], [10, 3, 6, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 5:
    check('move key', solve([[[10, 1, 5]], [[10, 2, 6]]]), [[[10, 2, 6]], [[10, 1, 5, -1], [10, 2, 6, 1]]])
    check('same key changed value', solve([[[10, 1, 5]], [[10, 1, 6]]]), [[[10, 1, 6]], [[10, 1, 5, -1], [10, 1, 6, 1]]])
    check('same value moved', solve([[[10, 1, 5]], [[10, 2, 5]]]), [[[10, 2, 5]], [[10, 1, 5, -1], [10, 2, 5, 1]]])
    check('insert new identity', solve([[[10, 1, 5]], [[11, 1, 6]]]), [[[10, 1, 5], [11, 1, 6]], [[11, 1, 6, 1]]])
    check('identical upsert', solve([[[10, 1, 5]], [[10, 1, 5]]]), [[[10, 1, 5]], []])
    check('two updates', solve([[[10, 1, 5]], [[10, 2, 6], [10, 3, 7]]]), [[[10, 3, 7]], [[10, 1, 5, -1], [10, 2, 6, 1], [10, 2, 6, -1], [10, 3, 7, 1]]])
    check('empty table', solve([[], []]), [[], []])
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:
        initial,updates=d
        state={ident:[key,value] for ident,key,value in initial}
        out=[]
        for ident,key,value in updates:
            previous=state.get(ident)
            if previous is not None and previous[1]==value: continue
            if previous is not None: out.append([ident,previous[0],previous[1],-1])
            state[ident]=[key,value]
            out.append([ident,key,value,1])
        return [sorted([[i,k,v] for i,(k,v) in state.items()]),out]
    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('move key', solve([[[10, 1, 1]], [[10, 2, 2]]]), [[[10, 2, 2]], [[10, 1, 1, -1], [10, 2, 2, 1]]])
    check('same key changed value', solve([[[10, 1, 1]], [[10, 1, 2]]]), [[[10, 1, 2]], [[10, 1, 1, -1], [10, 1, 2, 1]]])
    check('same value moved', solve([[[10, 1, 1]], [[10, 2, 1]]]), [[[10, 2, 1]], [[10, 1, 1, -1], [10, 2, 1, 1]]])
    check('insert new identity', solve([[[10, 1, 1]], [[11, 1, 2]]]), [[[10, 1, 1], [11, 1, 2]], [[11, 1, 2, 1]]])
    check('identical upsert', solve([[[10, 1, 1]], [[10, 1, 1]]]), [[[10, 1, 1]], []])
    check('two updates', solve([[[10, 1, 1]], [[10, 2, 2], [10, 3, 3]]]), [[[10, 3, 3]], [[10, 1, 1, -1], [10, 2, 2, 1], [10, 2, 2, -1], [10, 3, 3, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 2:
    check('move key', solve([[[10, 1, 2]], [[10, 2, 3]]]), [[[10, 2, 3]], [[10, 1, 2, -1], [10, 2, 3, 1]]])
    check('same key changed value', solve([[[10, 1, 2]], [[10, 1, 3]]]), [[[10, 1, 3]], [[10, 1, 2, -1], [10, 1, 3, 1]]])
    check('same value moved', solve([[[10, 1, 2]], [[10, 2, 2]]]), [[[10, 2, 2]], [[10, 1, 2, -1], [10, 2, 2, 1]]])
    check('insert new identity', solve([[[10, 1, 2]], [[11, 1, 3]]]), [[[10, 1, 2], [11, 1, 3]], [[11, 1, 3, 1]]])
    check('identical upsert', solve([[[10, 1, 2]], [[10, 1, 2]]]), [[[10, 1, 2]], []])
    check('two updates', solve([[[10, 1, 2]], [[10, 2, 3], [10, 3, 4]]]), [[[10, 3, 4]], [[10, 1, 2, -1], [10, 2, 3, 1], [10, 2, 3, -1], [10, 3, 4, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 3:
    check('move key', solve([[[10, 1, 3]], [[10, 2, 4]]]), [[[10, 2, 4]], [[10, 1, 3, -1], [10, 2, 4, 1]]])
    check('same key changed value', solve([[[10, 1, 3]], [[10, 1, 4]]]), [[[10, 1, 4]], [[10, 1, 3, -1], [10, 1, 4, 1]]])
    check('same value moved', solve([[[10, 1, 3]], [[10, 2, 3]]]), [[[10, 2, 3]], [[10, 1, 3, -1], [10, 2, 3, 1]]])
    check('insert new identity', solve([[[10, 1, 3]], [[11, 1, 4]]]), [[[10, 1, 3], [11, 1, 4]], [[11, 1, 4, 1]]])
    check('identical upsert', solve([[[10, 1, 3]], [[10, 1, 3]]]), [[[10, 1, 3]], []])
    check('two updates', solve([[[10, 1, 3]], [[10, 2, 4], [10, 3, 5]]]), [[[10, 3, 5]], [[10, 1, 3, -1], [10, 2, 4, 1], [10, 2, 4, -1], [10, 3, 5, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 4:
    check('move key', solve([[[10, 1, 4]], [[10, 2, 5]]]), [[[10, 2, 5]], [[10, 1, 4, -1], [10, 2, 5, 1]]])
    check('same key changed value', solve([[[10, 1, 4]], [[10, 1, 5]]]), [[[10, 1, 5]], [[10, 1, 4, -1], [10, 1, 5, 1]]])
    check('same value moved', solve([[[10, 1, 4]], [[10, 2, 4]]]), [[[10, 2, 4]], [[10, 1, 4, -1], [10, 2, 4, 1]]])
    check('insert new identity', solve([[[10, 1, 4]], [[11, 1, 5]]]), [[[10, 1, 4], [11, 1, 5]], [[11, 1, 5, 1]]])
    check('identical upsert', solve([[[10, 1, 4]], [[10, 1, 4]]]), [[[10, 1, 4]], []])
    check('two updates', solve([[[10, 1, 4]], [[10, 2, 5], [10, 3, 6]]]), [[[10, 3, 6]], [[10, 1, 4, -1], [10, 2, 5, 1], [10, 2, 5, -1], [10, 3, 6, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 5:
    check('move key', solve([[[10, 1, 5]], [[10, 2, 6]]]), [[[10, 2, 6]], [[10, 1, 5, -1], [10, 2, 6, 1]]])
    check('same key changed value', solve([[[10, 1, 5]], [[10, 1, 6]]]), [[[10, 1, 6]], [[10, 1, 5, -1], [10, 1, 6, 1]]])
    check('same value moved', solve([[[10, 1, 5]], [[10, 2, 5]]]), [[[10, 2, 5]], [[10, 1, 5, -1], [10, 2, 5, 1]]])
    check('insert new identity', solve([[[10, 1, 5]], [[11, 1, 6]]]), [[[10, 1, 5], [11, 1, 6]], [[11, 1, 6, 1]]])
    check('identical upsert', solve([[[10, 1, 5]], [[10, 1, 5]]]), [[[10, 1, 5]], []])
    check('two updates', solve([[[10, 1, 5]], [[10, 2, 6], [10, 3, 7]]]), [[[10, 3, 7]], [[10, 1, 5, -1], [10, 2, 6, 1], [10, 2, 6, -1], [10, 3, 7, 1]]])
    check('empty table', solve([[], []]), [[], []])
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:
An upsert suppresses a changed payload when the key stays equal.

Maintain an identity-indexed keyed table while applying [id,newkey,newvalue] upserts. A moved identity retracts its old key/value before adding the new row. Identical upserts emit no change. State and emitted changelog preserve identity distinctions.

split: open-access


prompt:
A key-changing retraction is sent to the new key.

Maintain an identity-indexed keyed table while applying [id,newkey,newvalue] upserts. A moved identity retracts its old key/value before adding the new row. Identical upserts emit no change. State and emitted changelog preserve identity distinctions.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        initial,updates=d
        state={ident:[key,value] for ident,key,value in initial}
        out=[]
        for ident,key,value in updates:
            previous=state.get(ident)
            if previous==[key,value]: continue
            if previous is not None: out.append([ident,previous[0],previous[1],-1])
            state.setdefault(ident,[key,value])
            out.append([ident,key,value,1])
        return [sorted([[i,k,v] for i,(k,v) in state.items()]),out]
    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('move key', solve([[[10, 1, 1]], [[10, 2, 2]]]), [[[10, 2, 2]], [[10, 1, 1, -1], [10, 2, 2, 1]]])
    check('same key changed value', solve([[[10, 1, 1]], [[10, 1, 2]]]), [[[10, 1, 2]], [[10, 1, 1, -1], [10, 1, 2, 1]]])
    check('same value moved', solve([[[10, 1, 1]], [[10, 2, 1]]]), [[[10, 2, 1]], [[10, 1, 1, -1], [10, 2, 1, 1]]])
    check('insert new identity', solve([[[10, 1, 1]], [[11, 1, 2]]]), [[[10, 1, 1], [11, 1, 2]], [[11, 1, 2, 1]]])
    check('identical upsert', solve([[[10, 1, 1]], [[10, 1, 1]]]), [[[10, 1, 1]], []])
    check('two updates', solve([[[10, 1, 1]], [[10, 2, 2], [10, 3, 3]]]), [[[10, 3, 3]], [[10, 1, 1, -1], [10, 2, 2, 1], [10, 2, 2, -1], [10, 3, 3, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 2:
    check('move key', solve([[[10, 1, 2]], [[10, 2, 3]]]), [[[10, 2, 3]], [[10, 1, 2, -1], [10, 2, 3, 1]]])
    check('same key changed value', solve([[[10, 1, 2]], [[10, 1, 3]]]), [[[10, 1, 3]], [[10, 1, 2, -1], [10, 1, 3, 1]]])
    check('same value moved', solve([[[10, 1, 2]], [[10, 2, 2]]]), [[[10, 2, 2]], [[10, 1, 2, -1], [10, 2, 2, 1]]])
    check('insert new identity', solve([[[10, 1, 2]], [[11, 1, 3]]]), [[[10, 1, 2], [11, 1, 3]], [[11, 1, 3, 1]]])
    check('identical upsert', solve([[[10, 1, 2]], [[10, 1, 2]]]), [[[10, 1, 2]], []])
    check('two updates', solve([[[10, 1, 2]], [[10, 2, 3], [10, 3, 4]]]), [[[10, 3, 4]], [[10, 1, 2, -1], [10, 2, 3, 1], [10, 2, 3, -1], [10, 3, 4, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 3:
    check('move key', solve([[[10, 1, 3]], [[10, 2, 4]]]), [[[10, 2, 4]], [[10, 1, 3, -1], [10, 2, 4, 1]]])
    check('same key changed value', solve([[[10, 1, 3]], [[10, 1, 4]]]), [[[10, 1, 4]], [[10, 1, 3, -1], [10, 1, 4, 1]]])
    check('same value moved', solve([[[10, 1, 3]], [[10, 2, 3]]]), [[[10, 2, 3]], [[10, 1, 3, -1], [10, 2, 3, 1]]])
    check('insert new identity', solve([[[10, 1, 3]], [[11, 1, 4]]]), [[[10, 1, 3], [11, 1, 4]], [[11, 1, 4, 1]]])
    check('identical upsert', solve([[[10, 1, 3]], [[10, 1, 3]]]), [[[10, 1, 3]], []])
    check('two updates', solve([[[10, 1, 3]], [[10, 2, 4], [10, 3, 5]]]), [[[10, 3, 5]], [[10, 1, 3, -1], [10, 2, 4, 1], [10, 2, 4, -1], [10, 3, 5, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 4:
    check('move key', solve([[[10, 1, 4]], [[10, 2, 5]]]), [[[10, 2, 5]], [[10, 1, 4, -1], [10, 2, 5, 1]]])
    check('same key changed value', solve([[[10, 1, 4]], [[10, 1, 5]]]), [[[10, 1, 5]], [[10, 1, 4, -1], [10, 1, 5, 1]]])
    check('same value moved', solve([[[10, 1, 4]], [[10, 2, 4]]]), [[[10, 2, 4]], [[10, 1, 4, -1], [10, 2, 4, 1]]])
    check('insert new identity', solve([[[10, 1, 4]], [[11, 1, 5]]]), [[[10, 1, 4], [11, 1, 5]], [[11, 1, 5, 1]]])
    check('identical upsert', solve([[[10, 1, 4]], [[10, 1, 4]]]), [[[10, 1, 4]], []])
    check('two updates', solve([[[10, 1, 4]], [[10, 2, 5], [10, 3, 6]]]), [[[10, 3, 6]], [[10, 1, 4, -1], [10, 2, 5, 1], [10, 2, 5, -1], [10, 3, 6, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 5:
    check('move key', solve([[[10, 1, 5]], [[10, 2, 6]]]), [[[10, 2, 6]], [[10, 1, 5, -1], [10, 2, 6, 1]]])
    check('same key changed value', solve([[[10, 1, 5]], [[10, 1, 6]]]), [[[10, 1, 6]], [[10, 1, 5, -1], [10, 1, 6, 1]]])
    check('same value moved', solve([[[10, 1, 5]], [[10, 2, 5]]]), [[[10, 2, 5]], [[10, 1, 5, -1], [10, 2, 5, 1]]])
    check('insert new identity', solve([[[10, 1, 5]], [[11, 1, 6]]]), [[[10, 1, 5], [11, 1, 6]], [[11, 1, 6, 1]]])
    check('identical upsert', solve([[[10, 1, 5]], [[10, 1, 5]]]), [[[10, 1, 5]], []])
    check('two updates', solve([[[10, 1, 5]], [[10, 2, 6], [10, 3, 7]]]), [[[10, 3, 7]], [[10, 1, 5, -1], [10, 2, 6, 1], [10, 2, 6, -1], [10, 3, 7, 1]]])
    check('empty table', solve([[], []]), [[], []])
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:
        initial,updates=d
        state={ident:[key,value] for ident,key,value in initial}
        out=[]
        for ident,key,value in updates:
            previous=state.get(ident)
            if previous==[key,value]: continue
            if previous is not None: out.append([ident,previous[0],previous[1],-1])
            state[ident]=[key,previous[1] if previous is not None else value]
            out.append([ident,key,value,1])
        return [sorted([[i,k,v] for i,(k,v) in state.items()]),out]
    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('move key', solve([[[10, 1, 1]], [[10, 2, 2]]]), [[[10, 2, 2]], [[10, 1, 1, -1], [10, 2, 2, 1]]])
    check('same key changed value', solve([[[10, 1, 1]], [[10, 1, 2]]]), [[[10, 1, 2]], [[10, 1, 1, -1], [10, 1, 2, 1]]])
    check('same value moved', solve([[[10, 1, 1]], [[10, 2, 1]]]), [[[10, 2, 1]], [[10, 1, 1, -1], [10, 2, 1, 1]]])
    check('insert new identity', solve([[[10, 1, 1]], [[11, 1, 2]]]), [[[10, 1, 1], [11, 1, 2]], [[11, 1, 2, 1]]])
    check('identical upsert', solve([[[10, 1, 1]], [[10, 1, 1]]]), [[[10, 1, 1]], []])
    check('two updates', solve([[[10, 1, 1]], [[10, 2, 2], [10, 3, 3]]]), [[[10, 3, 3]], [[10, 1, 1, -1], [10, 2, 2, 1], [10, 2, 2, -1], [10, 3, 3, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 2:
    check('move key', solve([[[10, 1, 2]], [[10, 2, 3]]]), [[[10, 2, 3]], [[10, 1, 2, -1], [10, 2, 3, 1]]])
    check('same key changed value', solve([[[10, 1, 2]], [[10, 1, 3]]]), [[[10, 1, 3]], [[10, 1, 2, -1], [10, 1, 3, 1]]])
    check('same value moved', solve([[[10, 1, 2]], [[10, 2, 2]]]), [[[10, 2, 2]], [[10, 1, 2, -1], [10, 2, 2, 1]]])
    check('insert new identity', solve([[[10, 1, 2]], [[11, 1, 3]]]), [[[10, 1, 2], [11, 1, 3]], [[11, 1, 3, 1]]])
    check('identical upsert', solve([[[10, 1, 2]], [[10, 1, 2]]]), [[[10, 1, 2]], []])
    check('two updates', solve([[[10, 1, 2]], [[10, 2, 3], [10, 3, 4]]]), [[[10, 3, 4]], [[10, 1, 2, -1], [10, 2, 3, 1], [10, 2, 3, -1], [10, 3, 4, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 3:
    check('move key', solve([[[10, 1, 3]], [[10, 2, 4]]]), [[[10, 2, 4]], [[10, 1, 3, -1], [10, 2, 4, 1]]])
    check('same key changed value', solve([[[10, 1, 3]], [[10, 1, 4]]]), [[[10, 1, 4]], [[10, 1, 3, -1], [10, 1, 4, 1]]])
    check('same value moved', solve([[[10, 1, 3]], [[10, 2, 3]]]), [[[10, 2, 3]], [[10, 1, 3, -1], [10, 2, 3, 1]]])
    check('insert new identity', solve([[[10, 1, 3]], [[11, 1, 4]]]), [[[10, 1, 3], [11, 1, 4]], [[11, 1, 4, 1]]])
    check('identical upsert', solve([[[10, 1, 3]], [[10, 1, 3]]]), [[[10, 1, 3]], []])
    check('two updates', solve([[[10, 1, 3]], [[10, 2, 4], [10, 3, 5]]]), [[[10, 3, 5]], [[10, 1, 3, -1], [10, 2, 4, 1], [10, 2, 4, -1], [10, 3, 5, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 4:
    check('move key', solve([[[10, 1, 4]], [[10, 2, 5]]]), [[[10, 2, 5]], [[10, 1, 4, -1], [10, 2, 5, 1]]])
    check('same key changed value', solve([[[10, 1, 4]], [[10, 1, 5]]]), [[[10, 1, 5]], [[10, 1, 4, -1], [10, 1, 5, 1]]])
    check('same value moved', solve([[[10, 1, 4]], [[10, 2, 4]]]), [[[10, 2, 4]], [[10, 1, 4, -1], [10, 2, 4, 1]]])
    check('insert new identity', solve([[[10, 1, 4]], [[11, 1, 5]]]), [[[10, 1, 4], [11, 1, 5]], [[11, 1, 5, 1]]])
    check('identical upsert', solve([[[10, 1, 4]], [[10, 1, 4]]]), [[[10, 1, 4]], []])
    check('two updates', solve([[[10, 1, 4]], [[10, 2, 5], [10, 3, 6]]]), [[[10, 3, 6]], [[10, 1, 4, -1], [10, 2, 5, 1], [10, 2, 5, -1], [10, 3, 6, 1]]])
    check('empty table', solve([[], []]), [[], []])
elif N == 5:
    check('move key', solve([[[10, 1, 5]], [[10, 2, 6]]]), [[[10, 2, 6]], [[10, 1, 5, -1], [10, 2, 6, 1]]])
    check('same key changed value', solve([[[10, 1, 5]], [[10, 1, 6]]]), [[[10, 1, 6]], [[10, 1, 5, -1], [10, 1, 6, 1]]])
    check('same value moved', solve([[[10, 1, 5]], [[10, 2, 5]]]), [[[10, 2, 5]], [[10, 1, 5, -1], [10, 2, 5, 1]]])
    check('insert new identity', solve([[[10, 1, 5]], [[11, 1, 6]]]), [[[10, 1, 5], [11, 1, 6]], [[11, 1, 6, 1]]])
    check('identical upsert', solve([[[10, 1, 5]], [[10, 1, 5]]]), [[[10, 1, 5]], []])
    check('two updates', solve([[[10, 1, 5]], [[10, 2, 6], [10, 3, 7]]]), [[[10, 3, 7]], [[10, 1, 5, -1], [10, 2, 6, 1], [10, 2, 6, -1], [10, 3, 7, 1]]])
    check('empty table', solve([[], []]), [[], []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A moved row emits changes without updating identity state.

Maintain an identity-indexed keyed table while applying [id,newkey,newvalue] upserts. A moved identity retracts its old key/value before adding the new row. Identical upserts emit no change. State and emitted changelog preserve identity distinctions.

split: open-access


prompt:
Upsert insertion uses the partition key as row identity.

Maintain an identity-indexed keyed table while applying [id,newkey,newvalue] upserts. A moved identity retracts its old key/value before adding the new row. Identical upserts emit no change. State and emitted changelog preserve identity distinctions.

split: open-access


prompt:
The initial identity map is indexed by partition keys.

Maintain an identity-indexed keyed table while applying [id,newkey,newvalue] upserts. A moved identity retracts its old key/value before adding the new row. Identical upserts emit no change. State and emitted changelog preserve identity distinctions.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        output,batches=d
        result=[]
        for schema,rows in batches:
            columns={name:index for index,(field,name) in enumerate(schema)}
            for row in rows:
                record=[]
                for field,name,default in output:
                    value=row[columns[field]] if field in columns else default
                    record.append(value)
                result.append(record)
        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('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[1, 2]]]]]), [[2, 1]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[1, 2]]], [[[2, 'b'], [1, 'a']], [[3, 4]]]]]), [[1, 2], [4, 3]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 1]], [[[[1, 'a']], [[2]]]]]), [[2, 1]])
    check('explicit null', solve([[[1, 'a', 1]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[1], [1]]]]]), [[1], [1]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 1]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 2:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[2, 3]]]]]), [[3, 2]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[2, 3]]], [[[2, 'b'], [1, 'a']], [[4, 5]]]]]), [[2, 3], [5, 4]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 2]], [[[[1, 'a']], [[3]]]]]), [[3, 2]])
    check('explicit null', solve([[[1, 'a', 2]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[2], [2]]]]]), [[2], [2]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 2]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 3:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[3, 4]]]]]), [[4, 3]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[3, 4]]], [[[2, 'b'], [1, 'a']], [[5, 6]]]]]), [[3, 4], [6, 5]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 3]], [[[[1, 'a']], [[4]]]]]), [[4, 3]])
    check('explicit null', solve([[[1, 'a', 3]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[3], [3]]]]]), [[3], [3]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 3]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 4:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[4, 5]]]]]), [[5, 4]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[4, 5]]], [[[2, 'b'], [1, 'a']], [[6, 7]]]]]), [[4, 5], [7, 6]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 4]], [[[[1, 'a']], [[5]]]]]), [[5, 4]])
    check('explicit null', solve([[[1, 'a', 4]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[4], [4]]]]]), [[4], [4]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 4]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 5:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[5, 6]]]]]), [[6, 5]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[5, 6]]], [[[2, 'b'], [1, 'a']], [[7, 8]]]]]), [[5, 6], [8, 7]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 5]], [[[[1, 'a']], [[6]]]]]), [[6, 5]])
    check('explicit null', solve([[[1, 'a', 5]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[5], [5]]]]]), [[5], [5]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 5]], [[[[1, 'a']], [[0]]]]]), [[0]])
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:
        output,batches=d
        result=[]
        for schema,rows in batches:
            columns={i:index for index,(i,name) in enumerate(schema) if any(i==f and name==n for f,n,v in output)}
            for row in rows:
                record=[]
                for field,name,default in output:
                    value=row[columns[field]] if field in columns else default
                    record.append(value)
                result.append(record)
        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('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[1, 2]]]]]), [[2, 1]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[1, 2]]], [[[2, 'b'], [1, 'a']], [[3, 4]]]]]), [[1, 2], [4, 3]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 1]], [[[[1, 'a']], [[2]]]]]), [[2, 1]])
    check('explicit null', solve([[[1, 'a', 1]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[1], [1]]]]]), [[1], [1]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 1]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 2:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[2, 3]]]]]), [[3, 2]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[2, 3]]], [[[2, 'b'], [1, 'a']], [[4, 5]]]]]), [[2, 3], [5, 4]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 2]], [[[[1, 'a']], [[3]]]]]), [[3, 2]])
    check('explicit null', solve([[[1, 'a', 2]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[2], [2]]]]]), [[2], [2]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 2]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 3:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[3, 4]]]]]), [[4, 3]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[3, 4]]], [[[2, 'b'], [1, 'a']], [[5, 6]]]]]), [[3, 4], [6, 5]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 3]], [[[[1, 'a']], [[4]]]]]), [[4, 3]])
    check('explicit null', solve([[[1, 'a', 3]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[3], [3]]]]]), [[3], [3]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 3]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 4:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[4, 5]]]]]), [[5, 4]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[4, 5]]], [[[2, 'b'], [1, 'a']], [[6, 7]]]]]), [[4, 5], [7, 6]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 4]], [[[[1, 'a']], [[5]]]]]), [[5, 4]])
    check('explicit null', solve([[[1, 'a', 4]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[4], [4]]]]]), [[4], [4]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 4]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 5:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[5, 6]]]]]), [[6, 5]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[5, 6]]], [[[2, 'b'], [1, 'a']], [[7, 8]]]]]), [[5, 6], [8, 7]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 5]], [[[[1, 'a']], [[6]]]]]), [[6, 5]])
    check('explicit null', solve([[[1, 'a', 5]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[5], [5]]]]]), [[5], [5]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 5]], [[[[1, 'a']], [[0]]]]]), [[0]])
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:
Schema union binds fields by display name after a rename.

Union batches using stable numeric field identities. The output schema is an ordered list [id,current_name,default]; batch schemas map old names to IDs. Project each batch row into output order, use defaults only for absent columns, and preserve explicit nulls and all rows.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        output,batches=d
        result=[]
        for schema,rows in [(batches[0][0],rows) for schema,rows in batches]:
            columns={field:index for index,(field,name) in enumerate(schema)}
            for row in rows:
                record=[]
                for field,name,default in output:
                    value=row[columns[field]] if field in columns else default
                    record.append(value)
                result.append(record)
        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('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[1, 2]]]]]), [[2, 1]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[1, 2]]], [[[2, 'b'], [1, 'a']], [[3, 4]]]]]), [[1, 2], [4, 3]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 1]], [[[[1, 'a']], [[2]]]]]), [[2, 1]])
    check('explicit null', solve([[[1, 'a', 1]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[1], [1]]]]]), [[1], [1]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 1]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 2:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[2, 3]]]]]), [[3, 2]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[2, 3]]], [[[2, 'b'], [1, 'a']], [[4, 5]]]]]), [[2, 3], [5, 4]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 2]], [[[[1, 'a']], [[3]]]]]), [[3, 2]])
    check('explicit null', solve([[[1, 'a', 2]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[2], [2]]]]]), [[2], [2]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 2]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 3:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[3, 4]]]]]), [[4, 3]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[3, 4]]], [[[2, 'b'], [1, 'a']], [[5, 6]]]]]), [[3, 4], [6, 5]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 3]], [[[[1, 'a']], [[4]]]]]), [[4, 3]])
    check('explicit null', solve([[[1, 'a', 3]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[3], [3]]]]]), [[3], [3]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 3]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 4:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[4, 5]]]]]), [[5, 4]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[4, 5]]], [[[2, 'b'], [1, 'a']], [[6, 7]]]]]), [[4, 5], [7, 6]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 4]], [[[[1, 'a']], [[5]]]]]), [[5, 4]])
    check('explicit null', solve([[[1, 'a', 4]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[4], [4]]]]]), [[4], [4]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 4]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 5:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[5, 6]]]]]), [[6, 5]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[5, 6]]], [[[2, 'b'], [1, 'a']], [[7, 8]]]]]), [[5, 6], [8, 7]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 5]], [[[[1, 'a']], [[6]]]]]), [[6, 5]])
    check('explicit null', solve([[[1, 'a', 5]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[5], [5]]]]]), [[5], [5]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 5]], [[[[1, 'a']], [[0]]]]]), [[0]])
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:
        output,batches=d
        result=[]
        for schema,rows in [(sorted(schema),rows) for schema,rows in batches]:
            columns={field:index for index,(field,name) in enumerate(schema)}
            for row in rows:
                record=[]
                for field,name,default in output:
                    value=row[columns[field]] if field in columns else default
                    record.append(value)
                result.append(record)
        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('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[1, 2]]]]]), [[2, 1]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[1, 2]]], [[[2, 'b'], [1, 'a']], [[3, 4]]]]]), [[1, 2], [4, 3]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 1]], [[[[1, 'a']], [[2]]]]]), [[2, 1]])
    check('explicit null', solve([[[1, 'a', 1]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[1], [1]]]]]), [[1], [1]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 1]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 2:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[2, 3]]]]]), [[3, 2]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[2, 3]]], [[[2, 'b'], [1, 'a']], [[4, 5]]]]]), [[2, 3], [5, 4]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 2]], [[[[1, 'a']], [[3]]]]]), [[3, 2]])
    check('explicit null', solve([[[1, 'a', 2]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[2], [2]]]]]), [[2], [2]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 2]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 3:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[3, 4]]]]]), [[4, 3]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[3, 4]]], [[[2, 'b'], [1, 'a']], [[5, 6]]]]]), [[3, 4], [6, 5]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 3]], [[[[1, 'a']], [[4]]]]]), [[4, 3]])
    check('explicit null', solve([[[1, 'a', 3]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[3], [3]]]]]), [[3], [3]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 3]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 4:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[4, 5]]]]]), [[5, 4]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[4, 5]]], [[[2, 'b'], [1, 'a']], [[6, 7]]]]]), [[4, 5], [7, 6]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 4]], [[[[1, 'a']], [[5]]]]]), [[5, 4]])
    check('explicit null', solve([[[1, 'a', 4]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[4], [4]]]]]), [[4], [4]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 4]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 5:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[5, 6]]]]]), [[6, 5]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[5, 6]]], [[[2, 'b'], [1, 'a']], [[7, 8]]]]]), [[5, 6], [8, 7]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 5]], [[[[1, 'a']], [[6]]]]]), [[6, 5]])
    check('explicit null', solve([[[1, 'a', 5]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[5], [5]]]]]), [[5], [5]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 5]], [[[[1, 'a']], [[0]]]]]), [[0]])
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:
Schema union reuses the first batch schema for later batches.

Union batches using stable numeric field identities. The output schema is an ordered list [id,current_name,default]; batch schemas map old names to IDs. Project each batch row into output order, use defaults only for absent columns, and preserve explicit nulls and all rows.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        output,batches=d
        result=[]
        for schema,rows in batches:
            columns={field:index for index,(field,name) in enumerate(schema)}
            for row in rows:
                record=[]
                for field,name,default in sorted(output):
                    value=row[columns[field]] if field in columns else default
                    record.append(value)
                result.append(record)
        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('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[1, 2]]]]]), [[2, 1]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[1, 2]]], [[[2, 'b'], [1, 'a']], [[3, 4]]]]]), [[1, 2], [4, 3]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 1]], [[[[1, 'a']], [[2]]]]]), [[2, 1]])
    check('explicit null', solve([[[1, 'a', 1]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[1], [1]]]]]), [[1], [1]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 1]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 2:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[2, 3]]]]]), [[3, 2]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[2, 3]]], [[[2, 'b'], [1, 'a']], [[4, 5]]]]]), [[2, 3], [5, 4]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 2]], [[[[1, 'a']], [[3]]]]]), [[3, 2]])
    check('explicit null', solve([[[1, 'a', 2]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[2], [2]]]]]), [[2], [2]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 2]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 3:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[3, 4]]]]]), [[4, 3]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[3, 4]]], [[[2, 'b'], [1, 'a']], [[5, 6]]]]]), [[3, 4], [6, 5]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 3]], [[[[1, 'a']], [[4]]]]]), [[4, 3]])
    check('explicit null', solve([[[1, 'a', 3]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[3], [3]]]]]), [[3], [3]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 3]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 4:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[4, 5]]]]]), [[5, 4]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[4, 5]]], [[[2, 'b'], [1, 'a']], [[6, 7]]]]]), [[4, 5], [7, 6]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 4]], [[[[1, 'a']], [[5]]]]]), [[5, 4]])
    check('explicit null', solve([[[1, 'a', 4]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[4], [4]]]]]), [[4], [4]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 4]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 5:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[5, 6]]]]]), [[6, 5]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[5, 6]]], [[[2, 'b'], [1, 'a']], [[7, 8]]]]]), [[5, 6], [8, 7]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 5]], [[[[1, 'a']], [[6]]]]]), [[6, 5]])
    check('explicit null', solve([[[1, 'a', 5]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[5], [5]]]]]), [[5], [5]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 5]], [[[[1, 'a']], [[0]]]]]), [[0]])
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:
        output,batches=d
        result=[]
        for schema,rows in batches:
            columns={field:index for index,(field,name) in enumerate(schema)}
            for row in rows:
                record=[]
                for field,name,default in reversed(output):
                    value=row[columns[field]] if field in columns else default
                    record.append(value)
                result.append(record)
        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('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[1, 2]]]]]), [[2, 1]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[1, 2]]], [[[2, 'b'], [1, 'a']], [[3, 4]]]]]), [[1, 2], [4, 3]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 1]], [[[[1, 'a']], [[2]]]]]), [[2, 1]])
    check('explicit null', solve([[[1, 'a', 1]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[1], [1]]]]]), [[1], [1]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 1]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 2:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[2, 3]]]]]), [[3, 2]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[2, 3]]], [[[2, 'b'], [1, 'a']], [[4, 5]]]]]), [[2, 3], [5, 4]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 2]], [[[[1, 'a']], [[3]]]]]), [[3, 2]])
    check('explicit null', solve([[[1, 'a', 2]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[2], [2]]]]]), [[2], [2]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 2]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 3:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[3, 4]]]]]), [[4, 3]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[3, 4]]], [[[2, 'b'], [1, 'a']], [[5, 6]]]]]), [[3, 4], [6, 5]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 3]], [[[[1, 'a']], [[4]]]]]), [[4, 3]])
    check('explicit null', solve([[[1, 'a', 3]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[3], [3]]]]]), [[3], [3]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 3]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 4:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[4, 5]]]]]), [[5, 4]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[4, 5]]], [[[2, 'b'], [1, 'a']], [[6, 7]]]]]), [[4, 5], [7, 6]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 4]], [[[[1, 'a']], [[5]]]]]), [[5, 4]])
    check('explicit null', solve([[[1, 'a', 4]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[4], [4]]]]]), [[4], [4]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 4]], [[[[1, 'a']], [[0]]]]]), [[0]])
elif N == 5:
    check('renamed field', solve([[[2, 'new', 99], [1, 'a', 88]], [[[[1, 'a'], [2, 'old']], [[5, 6]]]]]), [[6, 5]])
    check('reordered batch', solve([[[1, 'a', 0], [2, 'b', 0]], [[[[1, 'a'], [2, 'b']], [[5, 6]]], [[[2, 'b'], [1, 'a']], [[7, 8]]]]]), [[5, 6], [8, 7]])
    check('absent default', solve([[[1, 'a', 7], [2, 'b', 5]], [[[[1, 'a']], [[6]]]]]), [[6, 5]])
    check('explicit null', solve([[[1, 'a', 5]], [[[[1, 'a']], [[None]]]]]), [[None]])
    check('duplicate rows', solve([[[1, 'a', 0]], [[[[1, 'a']], [[5], [5]]]]]), [[5], [5]])
    check('no batches', solve([[[1, 'a', 0]], []]), [])
    check('zero preserved', solve([[[1, 'a', 5]], [[[[1, 'a']], [[0]]]]]), [[0]])
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:
Schema union sorts stable field IDs instead of output order.

Union batches using stable numeric field identities. The output schema is an ordered list [id,current_name,default]; batch schemas map old names to IDs. Project each batch row into output order, use defaults only for absent columns, and preserve explicit nulls and all rows.

split: open-access