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

N = 1
observations = []
def solve(d):
    try:
        row,rules=d
        result=dict(row)
        pending=[rule for rule in rules if rule[0] not in result]
        while pending:
            progressed=False; later=[]
            for target,source,constant in pending:
                if source is not None and source not in result:
                    later.append([target,source,constant]); continue
                result[target]=constant if source is None else (None if result[source] is None else constant)
                progressed=True
            if not progressed: return 'DEFAULT_CYCLE'
            pending=later
        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('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 1]]]), {'a': 1, 'b': 3})
    check('explicit null', solve([{'a': None}, [['a', None, 1], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 1], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 1}, [['a', None, 2]]]), {'x': 1, 'a': 2})
    check('source provided', solve([{'a': 1}, [['b', 'a', 3]]]), {'a': 1, 'b': 4})
    check('no defaults', solve([{'a': 1}, []]), {'a': 1})
elif N == 2:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 2]]]), {'a': 2, 'b': 4})
    check('explicit null', solve([{'a': None}, [['a', None, 2], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 2], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 2}, [['a', None, 3]]]), {'x': 2, 'a': 3})
    check('source provided', solve([{'a': 2}, [['b', 'a', 3]]]), {'a': 2, 'b': 5})
    check('no defaults', solve([{'a': 2}, []]), {'a': 2})
elif N == 3:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 3]]]), {'a': 3, 'b': 5})
    check('explicit null', solve([{'a': None}, [['a', None, 3], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 3], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 3}, [['a', None, 4]]]), {'x': 3, 'a': 4})
    check('source provided', solve([{'a': 3}, [['b', 'a', 3]]]), {'a': 3, 'b': 6})
    check('no defaults', solve([{'a': 3}, []]), {'a': 3})
elif N == 4:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 4]]]), {'a': 4, 'b': 6})
    check('explicit null', solve([{'a': None}, [['a', None, 4], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 4], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 4}, [['a', None, 5]]]), {'x': 4, 'a': 5})
    check('source provided', solve([{'a': 4}, [['b', 'a', 3]]]), {'a': 4, 'b': 7})
    check('no defaults', solve([{'a': 4}, []]), {'a': 4})
elif N == 5:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 5]]]), {'a': 5, 'b': 7})
    check('explicit null', solve([{'a': None}, [['a', None, 5], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 5], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 5}, [['a', None, 6]]]), {'x': 5, 'a': 6})
    check('source provided', solve([{'a': 5}, [['b', 'a', 3]]]), {'a': 5, 'b': 8})
    check('no defaults', solve([{'a': 5}, []]), {'a': 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:
        row,rules=d
        result=dict(row)
        pending=[rule for rule in rules if rule[0] not in result]
        while pending:
            progressed=False; later=[]
            for target,source,constant in pending:
                if source is not None and source not in result:
                    later.append([target,source,constant]); continue
                result[target]=constant if source is None else (None if result[source] is None else result[source])
                progressed=True
            if not progressed: return 'DEFAULT_CYCLE'
            pending=later
        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('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 1]]]), {'a': 1, 'b': 3})
    check('explicit null', solve([{'a': None}, [['a', None, 1], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 1], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 1}, [['a', None, 2]]]), {'x': 1, 'a': 2})
    check('source provided', solve([{'a': 1}, [['b', 'a', 3]]]), {'a': 1, 'b': 4})
    check('no defaults', solve([{'a': 1}, []]), {'a': 1})
elif N == 2:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 2]]]), {'a': 2, 'b': 4})
    check('explicit null', solve([{'a': None}, [['a', None, 2], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 2], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 2}, [['a', None, 3]]]), {'x': 2, 'a': 3})
    check('source provided', solve([{'a': 2}, [['b', 'a', 3]]]), {'a': 2, 'b': 5})
    check('no defaults', solve([{'a': 2}, []]), {'a': 2})
elif N == 3:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 3]]]), {'a': 3, 'b': 5})
    check('explicit null', solve([{'a': None}, [['a', None, 3], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 3], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 3}, [['a', None, 4]]]), {'x': 3, 'a': 4})
    check('source provided', solve([{'a': 3}, [['b', 'a', 3]]]), {'a': 3, 'b': 6})
    check('no defaults', solve([{'a': 3}, []]), {'a': 3})
elif N == 4:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 4]]]), {'a': 4, 'b': 6})
    check('explicit null', solve([{'a': None}, [['a', None, 4], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 4], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 4}, [['a', None, 5]]]), {'x': 4, 'a': 5})
    check('source provided', solve([{'a': 4}, [['b', 'a', 3]]]), {'a': 4, 'b': 7})
    check('no defaults', solve([{'a': 4}, []]), {'a': 4})
elif N == 5:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 5]]]), {'a': 5, 'b': 7})
    check('explicit null', solve([{'a': None}, [['a', None, 5], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 5], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 5}, [['a', None, 6]]]), {'x': 5, 'a': 6})
    check('source provided', solve([{'a': 5}, [['b', 'a', 3]]]), {'a': 5, 'b': 8})
    check('no defaults', solve([{'a': 5}, []]), {'a': 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 dependent default writes only its constant without reading the source.

Materialize missing columns using ordered default rules [target,source-or-None,constant]. A constant rule writes constant; a dependent rule writes source+constant, propagating explicit null. Existing columns including None and zero never change. Resolve forward dependencies to a fixed point; unresolved dependencies return DEFAULT_CYCLE.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        row,rules=d
        result=dict(row)
        pending=[rule for rule in rules if rule[0] not in result]
        while pending:
            progressed=False; later=[]
            for target,source,constant in pending:
                if source is not None and source not in result:
                    later.append([target,source,constant]); continue
                result[target]=constant if source is None else (None if result[source] is None else result[source]+constant)
                progressed=True
            if not progressed: return result
            pending=later
        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('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 1]]]), {'a': 1, 'b': 3})
    check('explicit null', solve([{'a': None}, [['a', None, 1], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 1], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 1}, [['a', None, 2]]]), {'x': 1, 'a': 2})
    check('source provided', solve([{'a': 1}, [['b', 'a', 3]]]), {'a': 1, 'b': 4})
    check('no defaults', solve([{'a': 1}, []]), {'a': 1})
elif N == 2:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 2]]]), {'a': 2, 'b': 4})
    check('explicit null', solve([{'a': None}, [['a', None, 2], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 2], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 2}, [['a', None, 3]]]), {'x': 2, 'a': 3})
    check('source provided', solve([{'a': 2}, [['b', 'a', 3]]]), {'a': 2, 'b': 5})
    check('no defaults', solve([{'a': 2}, []]), {'a': 2})
elif N == 3:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 3]]]), {'a': 3, 'b': 5})
    check('explicit null', solve([{'a': None}, [['a', None, 3], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 3], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 3}, [['a', None, 4]]]), {'x': 3, 'a': 4})
    check('source provided', solve([{'a': 3}, [['b', 'a', 3]]]), {'a': 3, 'b': 6})
    check('no defaults', solve([{'a': 3}, []]), {'a': 3})
elif N == 4:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 4]]]), {'a': 4, 'b': 6})
    check('explicit null', solve([{'a': None}, [['a', None, 4], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 4], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 4}, [['a', None, 5]]]), {'x': 4, 'a': 5})
    check('source provided', solve([{'a': 4}, [['b', 'a', 3]]]), {'a': 4, 'b': 7})
    check('no defaults', solve([{'a': 4}, []]), {'a': 4})
elif N == 5:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 5]]]), {'a': 5, 'b': 7})
    check('explicit null', solve([{'a': None}, [['a', None, 5], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 5], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 5}, [['a', None, 6]]]), {'x': 5, 'a': 6})
    check('source provided', solve([{'a': 5}, [['b', 'a', 3]]]), {'a': 5, 'b': 8})
    check('no defaults', solve([{'a': 5}, []]), {'a': 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:
        row,rules=d
        result=dict(row)
        pending=[rule for rule in rules if rule[0] not in result]
        while pending:
            progressed=False; later=[]
            for target,source,constant in pending:
                if source is not None and source not in result:
                    later.append([target,source,constant]); continue
                result[target]=constant if source is None else (None if result[source] is None else result[source]+constant)
                progressed=True
            if not progressed: return {}
            pending=later
        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('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 1]]]), {'a': 1, 'b': 3})
    check('explicit null', solve([{'a': None}, [['a', None, 1], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 1], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 1}, [['a', None, 2]]]), {'x': 1, 'a': 2})
    check('source provided', solve([{'a': 1}, [['b', 'a', 3]]]), {'a': 1, 'b': 4})
    check('no defaults', solve([{'a': 1}, []]), {'a': 1})
elif N == 2:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 2]]]), {'a': 2, 'b': 4})
    check('explicit null', solve([{'a': None}, [['a', None, 2], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 2], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 2}, [['a', None, 3]]]), {'x': 2, 'a': 3})
    check('source provided', solve([{'a': 2}, [['b', 'a', 3]]]), {'a': 2, 'b': 5})
    check('no defaults', solve([{'a': 2}, []]), {'a': 2})
elif N == 3:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 3]]]), {'a': 3, 'b': 5})
    check('explicit null', solve([{'a': None}, [['a', None, 3], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 3], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 3}, [['a', None, 4]]]), {'x': 3, 'a': 4})
    check('source provided', solve([{'a': 3}, [['b', 'a', 3]]]), {'a': 3, 'b': 6})
    check('no defaults', solve([{'a': 3}, []]), {'a': 3})
elif N == 4:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 4]]]), {'a': 4, 'b': 6})
    check('explicit null', solve([{'a': None}, [['a', None, 4], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 4], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 4}, [['a', None, 5]]]), {'x': 4, 'a': 5})
    check('source provided', solve([{'a': 4}, [['b', 'a', 3]]]), {'a': 4, 'b': 7})
    check('no defaults', solve([{'a': 4}, []]), {'a': 4})
elif N == 5:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 5]]]), {'a': 5, 'b': 7})
    check('explicit null', solve([{'a': None}, [['a', None, 5], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 5], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 5}, [['a', None, 6]]]), {'x': 5, 'a': 6})
    check('source provided', solve([{'a': 5}, [['b', 'a', 3]]]), {'a': 5, 'b': 8})
    check('no defaults', solve([{'a': 5}, []]), {'a': 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:
Default dependency cycles silently return a partial row.

Materialize missing columns using ordered default rules [target,source-or-None,constant]. A constant rule writes constant; a dependent rule writes source+constant, propagating explicit null. Existing columns including None and zero never change. Resolve forward dependencies to a fixed point; unresolved dependencies return DEFAULT_CYCLE.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        row,rules=d
        result={}
        pending=[rule for rule in rules if rule[0] not in result]
        while pending:
            progressed=False; later=[]
            for target,source,constant in pending:
                if source is not None and source not in result:
                    later.append([target,source,constant]); continue
                result[target]=constant if source is None else (None if result[source] is None else result[source]+constant)
                progressed=True
            if not progressed: return 'DEFAULT_CYCLE'
            pending=later
        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('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 1]]]), {'a': 1, 'b': 3})
    check('explicit null', solve([{'a': None}, [['a', None, 1], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 1], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 1}, [['a', None, 2]]]), {'x': 1, 'a': 2})
    check('source provided', solve([{'a': 1}, [['b', 'a', 3]]]), {'a': 1, 'b': 4})
    check('no defaults', solve([{'a': 1}, []]), {'a': 1})
elif N == 2:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 2]]]), {'a': 2, 'b': 4})
    check('explicit null', solve([{'a': None}, [['a', None, 2], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 2], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 2}, [['a', None, 3]]]), {'x': 2, 'a': 3})
    check('source provided', solve([{'a': 2}, [['b', 'a', 3]]]), {'a': 2, 'b': 5})
    check('no defaults', solve([{'a': 2}, []]), {'a': 2})
elif N == 3:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 3]]]), {'a': 3, 'b': 5})
    check('explicit null', solve([{'a': None}, [['a', None, 3], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 3], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 3}, [['a', None, 4]]]), {'x': 3, 'a': 4})
    check('source provided', solve([{'a': 3}, [['b', 'a', 3]]]), {'a': 3, 'b': 6})
    check('no defaults', solve([{'a': 3}, []]), {'a': 3})
elif N == 4:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 4]]]), {'a': 4, 'b': 6})
    check('explicit null', solve([{'a': None}, [['a', None, 4], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 4], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 4}, [['a', None, 5]]]), {'x': 4, 'a': 5})
    check('source provided', solve([{'a': 4}, [['b', 'a', 3]]]), {'a': 4, 'b': 7})
    check('no defaults', solve([{'a': 4}, []]), {'a': 4})
elif N == 5:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 5]]]), {'a': 5, 'b': 7})
    check('explicit null', solve([{'a': None}, [['a', None, 5], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 5], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 5}, [['a', None, 6]]]), {'x': 5, 'a': 6})
    check('source provided', solve([{'a': 5}, [['b', 'a', 3]]]), {'a': 5, 'b': 8})
    check('no defaults', solve([{'a': 5}, []]), {'a': 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:
        row,rules=d
        result={k:v for k,v in row.items() if any(k==r[0] for r in rules)}
        pending=[rule for rule in rules if rule[0] not in result]
        while pending:
            progressed=False; later=[]
            for target,source,constant in pending:
                if source is not None and source not in result:
                    later.append([target,source,constant]); continue
                result[target]=constant if source is None else (None if result[source] is None else result[source]+constant)
                progressed=True
            if not progressed: return 'DEFAULT_CYCLE'
            pending=later
        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('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 1]]]), {'a': 1, 'b': 3})
    check('explicit null', solve([{'a': None}, [['a', None, 1], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 1], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 1}, [['a', None, 2]]]), {'x': 1, 'a': 2})
    check('source provided', solve([{'a': 1}, [['b', 'a', 3]]]), {'a': 1, 'b': 4})
    check('no defaults', solve([{'a': 1}, []]), {'a': 1})
elif N == 2:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 2]]]), {'a': 2, 'b': 4})
    check('explicit null', solve([{'a': None}, [['a', None, 2], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 2], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 2}, [['a', None, 3]]]), {'x': 2, 'a': 3})
    check('source provided', solve([{'a': 2}, [['b', 'a', 3]]]), {'a': 2, 'b': 5})
    check('no defaults', solve([{'a': 2}, []]), {'a': 2})
elif N == 3:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 3]]]), {'a': 3, 'b': 5})
    check('explicit null', solve([{'a': None}, [['a', None, 3], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 3], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 3}, [['a', None, 4]]]), {'x': 3, 'a': 4})
    check('source provided', solve([{'a': 3}, [['b', 'a', 3]]]), {'a': 3, 'b': 6})
    check('no defaults', solve([{'a': 3}, []]), {'a': 3})
elif N == 4:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 4]]]), {'a': 4, 'b': 6})
    check('explicit null', solve([{'a': None}, [['a', None, 4], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 4], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 4}, [['a', None, 5]]]), {'x': 4, 'a': 5})
    check('source provided', solve([{'a': 4}, [['b', 'a', 3]]]), {'a': 4, 'b': 7})
    check('no defaults', solve([{'a': 4}, []]), {'a': 4})
elif N == 5:
    check('forward dependency', solve([{}, [['b', 'a', 2], ['a', None, 5]]]), {'a': 5, 'b': 7})
    check('explicit null', solve([{'a': None}, [['a', None, 5], ['b', 'a', 1]]]), {'a': None, 'b': None})
    check('explicit zero', solve([{'a': 0}, [['a', None, 5], ['b', 'a', 2]]]), {'a': 0, 'b': 2})
    check('dependency cycle', solve([{}, [['a', 'b', 1], ['b', 'a', 1]]]), 'DEFAULT_CYCLE')
    check('provided unrelated', solve([{'x': 5}, [['a', None, 6]]]), {'x': 5, 'a': 6})
    check('source provided', solve([{'a': 5}, [['b', 'a', 3]]]), {'a': 5, 'b': 8})
    check('no defaults', solve([{'a': 5}, []]), {'a': 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:
Default materialization discards explicitly provided columns.

Materialize missing columns using ordered default rules [target,source-or-None,constant]. A constant rule writes constant; a dependent rule writes source+constant, propagating explicit null. Existing columns including None and zero never change. Resolve forward dependencies to a fixed point; unresolved dependencies return DEFAULT_CYCLE.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        scopes=[{}]; out=[]
        for action,arg in d:
            if action=='push': scopes.append(dict(arg))
            elif action=='pop': scopes.pop()
            else:
                found='MISSING'
                for scope in scopes:
                    if arg in scope: found=scope[arg]; break
                out.append(found)
        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('inner shadow', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[2], [1]])
    check('outer fallback', solve([['push', {'x': [1]}], ['push', {}], ['read', 'x']]), [[1]])
    check('empty shadow', solve([['push', {'x': [1]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [1]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[1]])
    check('no actions', solve([]), [])
elif N == 2:
    check('inner shadow', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[3], [2]])
    check('outer fallback', solve([['push', {'x': [2]}], ['push', {}], ['read', 'x']]), [[2]])
    check('empty shadow', solve([['push', {'x': [2]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [2]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[2]])
    check('no actions', solve([]), [])
elif N == 3:
    check('inner shadow', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[4], [3]])
    check('outer fallback', solve([['push', {'x': [3]}], ['push', {}], ['read', 'x']]), [[3]])
    check('empty shadow', solve([['push', {'x': [3]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [3]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[3]])
    check('no actions', solve([]), [])
elif N == 4:
    check('inner shadow', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[5], [4]])
    check('outer fallback', solve([['push', {'x': [4]}], ['push', {}], ['read', 'x']]), [[4]])
    check('empty shadow', solve([['push', {'x': [4]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [4]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[4]])
    check('no actions', solve([]), [])
elif N == 5:
    check('inner shadow', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[6], [5]])
    check('outer fallback', solve([['push', {'x': [5]}], ['push', {}], ['read', 'x']]), [[5]])
    check('empty shadow', solve([['push', {'x': [5]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [5]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[5]])
    check('no actions', 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:
        scopes=[{}]; out=[]
        for action,arg in d:
            if action=='push': scopes.append(dict(arg))
            elif action=='pop': scopes.pop()
            else:
                found='MISSING'
                for scope in scopes[-1:]:
                    if arg in scope: found=scope[arg]; break
                out.append(found)
        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('inner shadow', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[2], [1]])
    check('outer fallback', solve([['push', {'x': [1]}], ['push', {}], ['read', 'x']]), [[1]])
    check('empty shadow', solve([['push', {'x': [1]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [1]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[1]])
    check('no actions', solve([]), [])
elif N == 2:
    check('inner shadow', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[3], [2]])
    check('outer fallback', solve([['push', {'x': [2]}], ['push', {}], ['read', 'x']]), [[2]])
    check('empty shadow', solve([['push', {'x': [2]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [2]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[2]])
    check('no actions', solve([]), [])
elif N == 3:
    check('inner shadow', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[4], [3]])
    check('outer fallback', solve([['push', {'x': [3]}], ['push', {}], ['read', 'x']]), [[3]])
    check('empty shadow', solve([['push', {'x': [3]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [3]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[3]])
    check('no actions', solve([]), [])
elif N == 4:
    check('inner shadow', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[5], [4]])
    check('outer fallback', solve([['push', {'x': [4]}], ['push', {}], ['read', 'x']]), [[4]])
    check('empty shadow', solve([['push', {'x': [4]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [4]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[4]])
    check('no actions', solve([]), [])
elif N == 5:
    check('inner shadow', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[6], [5]])
    check('outer fallback', solve([['push', {'x': [5]}], ['push', {}], ['read', 'x']]), [[5]])
    check('empty shadow', solve([['push', {'x': [5]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [5]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[5]])
    check('no actions', 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:
CTE lookup searches outer scopes before inner scopes.

Interpret nested query blocks using actions push(definitions), pop, and read(name). Every push opens a new CTE scope; reads search innermost scope first then outer scopes. Empty inner scopes still hide nothing, popping restores outer definitions, and unresolved names yield MISSING. Definitions are already evaluated row lists.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        scopes=[{}]; out=[]
        for action,arg in d:
            if action=='push': scopes[-1].update(arg); scopes.append({})
            elif action=='pop': scopes.pop()
            else:
                found='MISSING'
                for scope in reversed(scopes):
                    if arg in scope: found=scope[arg]; break
                out.append(found)
        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('inner shadow', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[2], [1]])
    check('outer fallback', solve([['push', {'x': [1]}], ['push', {}], ['read', 'x']]), [[1]])
    check('empty shadow', solve([['push', {'x': [1]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [1]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[1]])
    check('no actions', solve([]), [])
elif N == 2:
    check('inner shadow', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[3], [2]])
    check('outer fallback', solve([['push', {'x': [2]}], ['push', {}], ['read', 'x']]), [[2]])
    check('empty shadow', solve([['push', {'x': [2]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [2]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[2]])
    check('no actions', solve([]), [])
elif N == 3:
    check('inner shadow', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[4], [3]])
    check('outer fallback', solve([['push', {'x': [3]}], ['push', {}], ['read', 'x']]), [[3]])
    check('empty shadow', solve([['push', {'x': [3]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [3]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[3]])
    check('no actions', solve([]), [])
elif N == 4:
    check('inner shadow', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[5], [4]])
    check('outer fallback', solve([['push', {'x': [4]}], ['push', {}], ['read', 'x']]), [[4]])
    check('empty shadow', solve([['push', {'x': [4]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [4]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[4]])
    check('no actions', solve([]), [])
elif N == 5:
    check('inner shadow', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[6], [5]])
    check('outer fallback', solve([['push', {'x': [5]}], ['push', {}], ['read', 'x']]), [[5]])
    check('empty shadow', solve([['push', {'x': [5]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [5]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[5]])
    check('no actions', 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:
        scopes=[{}]; out=[]
        for action,arg in d:
            if action=='push': scopes.append(scopes[-1]); scopes[-1].update(arg)
            elif action=='pop': scopes.pop()
            else:
                found='MISSING'
                for scope in reversed(scopes):
                    if arg in scope: found=scope[arg]; break
                out.append(found)
        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('inner shadow', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[2], [1]])
    check('outer fallback', solve([['push', {'x': [1]}], ['push', {}], ['read', 'x']]), [[1]])
    check('empty shadow', solve([['push', {'x': [1]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [1]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[1]])
    check('no actions', solve([]), [])
elif N == 2:
    check('inner shadow', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[3], [2]])
    check('outer fallback', solve([['push', {'x': [2]}], ['push', {}], ['read', 'x']]), [[2]])
    check('empty shadow', solve([['push', {'x': [2]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [2]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[2]])
    check('no actions', solve([]), [])
elif N == 3:
    check('inner shadow', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[4], [3]])
    check('outer fallback', solve([['push', {'x': [3]}], ['push', {}], ['read', 'x']]), [[3]])
    check('empty shadow', solve([['push', {'x': [3]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [3]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[3]])
    check('no actions', solve([]), [])
elif N == 4:
    check('inner shadow', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[5], [4]])
    check('outer fallback', solve([['push', {'x': [4]}], ['push', {}], ['read', 'x']]), [[4]])
    check('empty shadow', solve([['push', {'x': [4]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [4]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[4]])
    check('no actions', solve([]), [])
elif N == 5:
    check('inner shadow', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[6], [5]])
    check('outer fallback', solve([['push', {'x': [5]}], ['push', {}], ['read', 'x']]), [[5]])
    check('empty shadow', solve([['push', {'x': [5]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [5]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[5]])
    check('no actions', 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:
Opening a query block overwrites its parent CTE dictionary.

Interpret nested query blocks using actions push(definitions), pop, and read(name). Every push opens a new CTE scope; reads search innermost scope first then outer scopes. Empty inner scopes still hide nothing, popping restores outer definitions, and unresolved names yield MISSING. Definitions are already evaluated row lists.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        scopes=[{}]; out=[]
        for action,arg in d:
            if action=='push': scopes.append(dict(arg))
            elif action=='pop': pass
            else:
                found='MISSING'
                for scope in reversed(scopes):
                    if arg in scope: found=scope[arg]; break
                out.append(found)
        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('inner shadow', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[2], [1]])
    check('outer fallback', solve([['push', {'x': [1]}], ['push', {}], ['read', 'x']]), [[1]])
    check('empty shadow', solve([['push', {'x': [1]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [1]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[1]])
    check('no actions', solve([]), [])
elif N == 2:
    check('inner shadow', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[3], [2]])
    check('outer fallback', solve([['push', {'x': [2]}], ['push', {}], ['read', 'x']]), [[2]])
    check('empty shadow', solve([['push', {'x': [2]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [2]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[2]])
    check('no actions', solve([]), [])
elif N == 3:
    check('inner shadow', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[4], [3]])
    check('outer fallback', solve([['push', {'x': [3]}], ['push', {}], ['read', 'x']]), [[3]])
    check('empty shadow', solve([['push', {'x': [3]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [3]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[3]])
    check('no actions', solve([]), [])
elif N == 4:
    check('inner shadow', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[5], [4]])
    check('outer fallback', solve([['push', {'x': [4]}], ['push', {}], ['read', 'x']]), [[4]])
    check('empty shadow', solve([['push', {'x': [4]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [4]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[4]])
    check('no actions', solve([]), [])
elif N == 5:
    check('inner shadow', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[6], [5]])
    check('outer fallback', solve([['push', {'x': [5]}], ['push', {}], ['read', 'x']]), [[5]])
    check('empty shadow', solve([['push', {'x': [5]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [5]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[5]])
    check('no actions', 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:
        scopes=[{}]; out=[]
        for action,arg in d:
            if action=='push': scopes.append(dict(arg))
            elif action=='pop': scopes[-1].clear()
            else:
                found='MISSING'
                for scope in reversed(scopes):
                    if arg in scope: found=scope[arg]; break
                out.append(found)
        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('inner shadow', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[2], [1]])
    check('outer fallback', solve([['push', {'x': [1]}], ['push', {}], ['read', 'x']]), [[1]])
    check('empty shadow', solve([['push', {'x': [1]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [1]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[1]])
    check('no actions', solve([]), [])
elif N == 2:
    check('inner shadow', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[3], [2]])
    check('outer fallback', solve([['push', {'x': [2]}], ['push', {}], ['read', 'x']]), [[2]])
    check('empty shadow', solve([['push', {'x': [2]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [2]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[2]])
    check('no actions', solve([]), [])
elif N == 3:
    check('inner shadow', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[4], [3]])
    check('outer fallback', solve([['push', {'x': [3]}], ['push', {}], ['read', 'x']]), [[3]])
    check('empty shadow', solve([['push', {'x': [3]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [3]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[3]])
    check('no actions', solve([]), [])
elif N == 4:
    check('inner shadow', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[5], [4]])
    check('outer fallback', solve([['push', {'x': [4]}], ['push', {}], ['read', 'x']]), [[4]])
    check('empty shadow', solve([['push', {'x': [4]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [4]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[4]])
    check('no actions', solve([]), [])
elif N == 5:
    check('inner shadow', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[6], [5]])
    check('outer fallback', solve([['push', {'x': [5]}], ['push', {}], ['read', 'x']]), [[5]])
    check('empty shadow', solve([['push', {'x': [5]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [5]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[5]])
    check('no actions', 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:
Leaving a query block retains its CTE definitions.

Interpret nested query blocks using actions push(definitions), pop, and read(name). Every push opens a new CTE scope; reads search innermost scope first then outer scopes. Empty inner scopes still hide nothing, popping restores outer definitions, and unresolved names yield MISSING. Definitions are already evaluated row lists.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        scopes=[{}]; out=[]
        for action,arg in d:
            if action=='push': scopes.append(dict(arg))
            elif action=='pop': scopes.pop()
            else:
                found='MISSING'
                for scope in reversed(scopes):
                    if scope.get(arg): found=scope[arg]; break
                out.append(found)
        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('inner shadow', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[2], [1]])
    check('outer fallback', solve([['push', {'x': [1]}], ['push', {}], ['read', 'x']]), [[1]])
    check('empty shadow', solve([['push', {'x': [1]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [1]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[1]])
    check('no actions', solve([]), [])
elif N == 2:
    check('inner shadow', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[3], [2]])
    check('outer fallback', solve([['push', {'x': [2]}], ['push', {}], ['read', 'x']]), [[2]])
    check('empty shadow', solve([['push', {'x': [2]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [2]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[2]])
    check('no actions', solve([]), [])
elif N == 3:
    check('inner shadow', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[4], [3]])
    check('outer fallback', solve([['push', {'x': [3]}], ['push', {}], ['read', 'x']]), [[3]])
    check('empty shadow', solve([['push', {'x': [3]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [3]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[3]])
    check('no actions', solve([]), [])
elif N == 4:
    check('inner shadow', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[5], [4]])
    check('outer fallback', solve([['push', {'x': [4]}], ['push', {}], ['read', 'x']]), [[4]])
    check('empty shadow', solve([['push', {'x': [4]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [4]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[4]])
    check('no actions', solve([]), [])
elif N == 5:
    check('inner shadow', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[6], [5]])
    check('outer fallback', solve([['push', {'x': [5]}], ['push', {}], ['read', 'x']]), [[5]])
    check('empty shadow', solve([['push', {'x': [5]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [5]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[5]])
    check('no actions', 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:
        scopes=[{}]; out=[]
        for action,arg in d:
            if action=='push': scopes.append(dict(arg))
            elif action=='pop': scopes.pop()
            else:
                found='MISSING'
                for scope in reversed(scopes):
                    if arg in scope and scope[arg]!=[]: found=scope[arg]; break
                out.append(found)
        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('inner shadow', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[2], [1]])
    check('outer fallback', solve([['push', {'x': [1]}], ['push', {}], ['read', 'x']]), [[1]])
    check('empty shadow', solve([['push', {'x': [1]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [1]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[1]])
    check('no actions', solve([]), [])
elif N == 2:
    check('inner shadow', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[3], [2]])
    check('outer fallback', solve([['push', {'x': [2]}], ['push', {}], ['read', 'x']]), [[2]])
    check('empty shadow', solve([['push', {'x': [2]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [2]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[2]])
    check('no actions', solve([]), [])
elif N == 3:
    check('inner shadow', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[4], [3]])
    check('outer fallback', solve([['push', {'x': [3]}], ['push', {}], ['read', 'x']]), [[3]])
    check('empty shadow', solve([['push', {'x': [3]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [3]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[3]])
    check('no actions', solve([]), [])
elif N == 4:
    check('inner shadow', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[5], [4]])
    check('outer fallback', solve([['push', {'x': [4]}], ['push', {}], ['read', 'x']]), [[4]])
    check('empty shadow', solve([['push', {'x': [4]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [4]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[4]])
    check('no actions', solve([]), [])
elif N == 5:
    check('inner shadow', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[6], [5]])
    check('outer fallback', solve([['push', {'x': [5]}], ['push', {}], ['read', 'x']]), [[5]])
    check('empty shadow', solve([['push', {'x': [5]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [5]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[5]])
    check('no actions', 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 empty CTE relation is mistaken for an unresolved name.

Interpret nested query blocks using actions push(definitions), pop, and read(name). Every push opens a new CTE scope; reads search innermost scope first then outer scopes. Empty inner scopes still hide nothing, popping restores outer definitions, and unresolved names yield MISSING. Definitions are already evaluated row lists.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        scopes=[{}]; out=[]
        for action,arg in d:
            if action=='push': scopes.append(dict(arg))
            elif action=='pop': scopes.pop()
            else:
                found='MISSING'
                for scope in reversed(scopes):
                    if arg in scope: found=scope[arg]
                out.append(found)
        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('inner shadow', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[2], [1]])
    check('outer fallback', solve([['push', {'x': [1]}], ['push', {}], ['read', 'x']]), [[1]])
    check('empty shadow', solve([['push', {'x': [1]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [1]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[1]])
    check('no actions', solve([]), [])
elif N == 2:
    check('inner shadow', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[3], [2]])
    check('outer fallback', solve([['push', {'x': [2]}], ['push', {}], ['read', 'x']]), [[2]])
    check('empty shadow', solve([['push', {'x': [2]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [2]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[2]])
    check('no actions', solve([]), [])
elif N == 3:
    check('inner shadow', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[4], [3]])
    check('outer fallback', solve([['push', {'x': [3]}], ['push', {}], ['read', 'x']]), [[3]])
    check('empty shadow', solve([['push', {'x': [3]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [3]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[3]])
    check('no actions', solve([]), [])
elif N == 4:
    check('inner shadow', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[5], [4]])
    check('outer fallback', solve([['push', {'x': [4]}], ['push', {}], ['read', 'x']]), [[4]])
    check('empty shadow', solve([['push', {'x': [4]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [4]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[4]])
    check('no actions', solve([]), [])
elif N == 5:
    check('inner shadow', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[6], [5]])
    check('outer fallback', solve([['push', {'x': [5]}], ['push', {}], ['read', 'x']]), [[5]])
    check('empty shadow', solve([['push', {'x': [5]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [5]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[5]])
    check('no actions', 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:
        scopes=[{}]; out=[]
        for action,arg in d:
            if action=='push': scopes.append(dict(arg))
            elif action=='pop': scopes.pop()
            else:
                found='MISSING'
                for scope in reversed(scopes):
                    if arg in scope: found=scope[arg]; continue
                out.append(found)
        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('inner shadow', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[2], [1]])
    check('outer fallback', solve([['push', {'x': [1]}], ['push', {}], ['read', 'x']]), [[1]])
    check('empty shadow', solve([['push', {'x': [1]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [1]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[1]])
    check('no actions', solve([]), [])
elif N == 2:
    check('inner shadow', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[3], [2]])
    check('outer fallback', solve([['push', {'x': [2]}], ['push', {}], ['read', 'x']]), [[2]])
    check('empty shadow', solve([['push', {'x': [2]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [2]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[2]])
    check('no actions', solve([]), [])
elif N == 3:
    check('inner shadow', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[4], [3]])
    check('outer fallback', solve([['push', {'x': [3]}], ['push', {}], ['read', 'x']]), [[3]])
    check('empty shadow', solve([['push', {'x': [3]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [3]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[3]])
    check('no actions', solve([]), [])
elif N == 4:
    check('inner shadow', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[5], [4]])
    check('outer fallback', solve([['push', {'x': [4]}], ['push', {}], ['read', 'x']]), [[4]])
    check('empty shadow', solve([['push', {'x': [4]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [4]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[4]])
    check('no actions', solve([]), [])
elif N == 5:
    check('inner shadow', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[6], [5]])
    check('outer fallback', solve([['push', {'x': [5]}], ['push', {}], ['read', 'x']]), [[5]])
    check('empty shadow', solve([['push', {'x': [5]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [5]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[5]])
    check('no actions', 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:
CTE lookup keeps scanning after finding an inner definition.

Interpret nested query blocks using actions push(definitions), pop, and read(name). Every push opens a new CTE scope; reads search innermost scope first then outer scopes. Empty inner scopes still hide nothing, popping restores outer definitions, and unresolved names yield MISSING. Definitions are already evaluated row lists.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        scopes=[{}]; out=[]
        for action,arg in d:
            if action=='push': scopes.append(dict(arg))
            elif action=='pop': scopes.pop()
            else:
                found=[]
                for scope in reversed(scopes):
                    if arg in scope: found=scope[arg]; break
                out.append(found)
        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('inner shadow', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[2], [1]])
    check('outer fallback', solve([['push', {'x': [1]}], ['push', {}], ['read', 'x']]), [[1]])
    check('empty shadow', solve([['push', {'x': [1]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [1]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[1]])
    check('no actions', solve([]), [])
elif N == 2:
    check('inner shadow', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[3], [2]])
    check('outer fallback', solve([['push', {'x': [2]}], ['push', {}], ['read', 'x']]), [[2]])
    check('empty shadow', solve([['push', {'x': [2]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [2]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[2]])
    check('no actions', solve([]), [])
elif N == 3:
    check('inner shadow', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[4], [3]])
    check('outer fallback', solve([['push', {'x': [3]}], ['push', {}], ['read', 'x']]), [[3]])
    check('empty shadow', solve([['push', {'x': [3]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [3]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[3]])
    check('no actions', solve([]), [])
elif N == 4:
    check('inner shadow', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[5], [4]])
    check('outer fallback', solve([['push', {'x': [4]}], ['push', {}], ['read', 'x']]), [[4]])
    check('empty shadow', solve([['push', {'x': [4]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [4]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[4]])
    check('no actions', solve([]), [])
elif N == 5:
    check('inner shadow', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[6], [5]])
    check('outer fallback', solve([['push', {'x': [5]}], ['push', {}], ['read', 'x']]), [[5]])
    check('empty shadow', solve([['push', {'x': [5]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [5]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[5]])
    check('no actions', 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:
        scopes=[{}]; out=[]
        for action,arg in d:
            if action=='push': scopes.append(dict(arg))
            elif action=='pop': scopes.pop()
            else:
                found=None
                for scope in reversed(scopes):
                    if arg in scope: found=scope[arg]; break
                out.append(found)
        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('inner shadow', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[2], [1]])
    check('outer fallback', solve([['push', {'x': [1]}], ['push', {}], ['read', 'x']]), [[1]])
    check('empty shadow', solve([['push', {'x': [1]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [1]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[1]])
    check('no actions', solve([]), [])
elif N == 2:
    check('inner shadow', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[3], [2]])
    check('outer fallback', solve([['push', {'x': [2]}], ['push', {}], ['read', 'x']]), [[2]])
    check('empty shadow', solve([['push', {'x': [2]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [2]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[2]])
    check('no actions', solve([]), [])
elif N == 3:
    check('inner shadow', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[4], [3]])
    check('outer fallback', solve([['push', {'x': [3]}], ['push', {}], ['read', 'x']]), [[3]])
    check('empty shadow', solve([['push', {'x': [3]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [3]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[3]])
    check('no actions', solve([]), [])
elif N == 4:
    check('inner shadow', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[5], [4]])
    check('outer fallback', solve([['push', {'x': [4]}], ['push', {}], ['read', 'x']]), [[4]])
    check('empty shadow', solve([['push', {'x': [4]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [4]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[4]])
    check('no actions', solve([]), [])
elif N == 5:
    check('inner shadow', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[6], [5]])
    check('outer fallback', solve([['push', {'x': [5]}], ['push', {}], ['read', 'x']]), [[5]])
    check('empty shadow', solve([['push', {'x': [5]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [5]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[5]])
    check('no actions', 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 unresolved CTE name becomes an empty successful relation.

Interpret nested query blocks using actions push(definitions), pop, and read(name). Every push opens a new CTE scope; reads search innermost scope first then outer scopes. Empty inner scopes still hide nothing, popping restores outer definitions, and unresolved names yield MISSING. Definitions are already evaluated row lists.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        events,gap=d
        out=[]
        for key in sorted(set(k for k,t,i in events)):
            rows=sorted((t,i) for k,t,i in events if k==key)
            start=last=None; ids=[]
            for time,ident in rows:
                if ids and time-start>gap:
                    out.append([key,start,last,ids]); ids=[]
                if not ids: start=time
                ids.append(ident); last=time
            if ids: out.append([key,start,last,ids])
        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('bridge chain', solve([[['a', 1, 10], ['a', 3, 11], ['a', 5, 12]], 2]), [['a', 1, 5, [10, 11, 12]]])
    check('arrival order', solve([[['a', 3, 10], ['a', 1, 11]], 2]), [['a', 1, 3, [11, 10]]])
    check('key separation', solve([[['a', 1, 10], ['b', 1, 11]], 2]), [['a', 1, 1, [10]], ['b', 1, 1, [11]]])
    check('separate sessions', solve([[['a', 1, 10], ['a', 6, 11]], 2]), [['a', 1, 1, [10]], ['a', 6, 6, [11]]])
    check('equal timestamp', solve([[['a', 1, 11], ['a', 1, 10]], 0]), [['a', 1, 1, [10, 11]]])
    check('single event', solve([[['a', 1, 10]], 2]), [['a', 1, 1, [10]]])
    check('empty stream', solve([[], 2]), [])
elif N == 2:
    check('bridge chain', solve([[['a', 2, 10], ['a', 4, 11], ['a', 6, 12]], 2]), [['a', 2, 6, [10, 11, 12]]])
    check('arrival order', solve([[['a', 4, 10], ['a', 2, 11]], 2]), [['a', 2, 4, [11, 10]]])
    check('key separation', solve([[['a', 2, 10], ['b', 2, 11]], 2]), [['a', 2, 2, [10]], ['b', 2, 2, [11]]])
    check('separate sessions', solve([[['a', 2, 10], ['a', 7, 11]], 2]), [['a', 2, 2, [10]], ['a', 7, 7, [11]]])
    check('equal timestamp', solve([[['a', 2, 11], ['a', 2, 10]], 0]), [['a', 2, 2, [10, 11]]])
    check('single event', solve([[['a', 2, 10]], 2]), [['a', 2, 2, [10]]])
    check('empty stream', solve([[], 2]), [])
elif N == 3:
    check('bridge chain', solve([[['a', 3, 10], ['a', 5, 11], ['a', 7, 12]], 2]), [['a', 3, 7, [10, 11, 12]]])
    check('arrival order', solve([[['a', 5, 10], ['a', 3, 11]], 2]), [['a', 3, 5, [11, 10]]])
    check('key separation', solve([[['a', 3, 10], ['b', 3, 11]], 2]), [['a', 3, 3, [10]], ['b', 3, 3, [11]]])
    check('separate sessions', solve([[['a', 3, 10], ['a', 8, 11]], 2]), [['a', 3, 3, [10]], ['a', 8, 8, [11]]])
    check('equal timestamp', solve([[['a', 3, 11], ['a', 3, 10]], 0]), [['a', 3, 3, [10, 11]]])
    check('single event', solve([[['a', 3, 10]], 2]), [['a', 3, 3, [10]]])
    check('empty stream', solve([[], 2]), [])
elif N == 4:
    check('bridge chain', solve([[['a', 4, 10], ['a', 6, 11], ['a', 8, 12]], 2]), [['a', 4, 8, [10, 11, 12]]])
    check('arrival order', solve([[['a', 6, 10], ['a', 4, 11]], 2]), [['a', 4, 6, [11, 10]]])
    check('key separation', solve([[['a', 4, 10], ['b', 4, 11]], 2]), [['a', 4, 4, [10]], ['b', 4, 4, [11]]])
    check('separate sessions', solve([[['a', 4, 10], ['a', 9, 11]], 2]), [['a', 4, 4, [10]], ['a', 9, 9, [11]]])
    check('equal timestamp', solve([[['a', 4, 11], ['a', 4, 10]], 0]), [['a', 4, 4, [10, 11]]])
    check('single event', solve([[['a', 4, 10]], 2]), [['a', 4, 4, [10]]])
    check('empty stream', solve([[], 2]), [])
elif N == 5:
    check('bridge chain', solve([[['a', 5, 10], ['a', 7, 11], ['a', 9, 12]], 2]), [['a', 5, 9, [10, 11, 12]]])
    check('arrival order', solve([[['a', 7, 10], ['a', 5, 11]], 2]), [['a', 5, 7, [11, 10]]])
    check('key separation', solve([[['a', 5, 10], ['b', 5, 11]], 2]), [['a', 5, 5, [10]], ['b', 5, 5, [11]]])
    check('separate sessions', solve([[['a', 5, 10], ['a', 10, 11]], 2]), [['a', 5, 5, [10]], ['a', 10, 10, [11]]])
    check('equal timestamp', solve([[['a', 5, 11], ['a', 5, 10]], 0]), [['a', 5, 5, [10, 11]]])
    check('single event', solve([[['a', 5, 10]], 2]), [['a', 5, 5, [10]]])
    check('empty stream', solve([[], 2]), [])
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:
        events,gap=d
        out=[]
        for key in sorted(set(k for k,t,i in events)):
            rows=sorted((t,i) for k,t,i in events if k==key)
            start=last=None; ids=[]
            for time,ident in rows:
                if ids and time-start>=gap:
                    out.append([key,start,last,ids]); ids=[]
                if not ids: start=time
                ids.append(ident); last=time
            if ids: out.append([key,start,last,ids])
        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('bridge chain', solve([[['a', 1, 10], ['a', 3, 11], ['a', 5, 12]], 2]), [['a', 1, 5, [10, 11, 12]]])
    check('arrival order', solve([[['a', 3, 10], ['a', 1, 11]], 2]), [['a', 1, 3, [11, 10]]])
    check('key separation', solve([[['a', 1, 10], ['b', 1, 11]], 2]), [['a', 1, 1, [10]], ['b', 1, 1, [11]]])
    check('separate sessions', solve([[['a', 1, 10], ['a', 6, 11]], 2]), [['a', 1, 1, [10]], ['a', 6, 6, [11]]])
    check('equal timestamp', solve([[['a', 1, 11], ['a', 1, 10]], 0]), [['a', 1, 1, [10, 11]]])
    check('single event', solve([[['a', 1, 10]], 2]), [['a', 1, 1, [10]]])
    check('empty stream', solve([[], 2]), [])
elif N == 2:
    check('bridge chain', solve([[['a', 2, 10], ['a', 4, 11], ['a', 6, 12]], 2]), [['a', 2, 6, [10, 11, 12]]])
    check('arrival order', solve([[['a', 4, 10], ['a', 2, 11]], 2]), [['a', 2, 4, [11, 10]]])
    check('key separation', solve([[['a', 2, 10], ['b', 2, 11]], 2]), [['a', 2, 2, [10]], ['b', 2, 2, [11]]])
    check('separate sessions', solve([[['a', 2, 10], ['a', 7, 11]], 2]), [['a', 2, 2, [10]], ['a', 7, 7, [11]]])
    check('equal timestamp', solve([[['a', 2, 11], ['a', 2, 10]], 0]), [['a', 2, 2, [10, 11]]])
    check('single event', solve([[['a', 2, 10]], 2]), [['a', 2, 2, [10]]])
    check('empty stream', solve([[], 2]), [])
elif N == 3:
    check('bridge chain', solve([[['a', 3, 10], ['a', 5, 11], ['a', 7, 12]], 2]), [['a', 3, 7, [10, 11, 12]]])
    check('arrival order', solve([[['a', 5, 10], ['a', 3, 11]], 2]), [['a', 3, 5, [11, 10]]])
    check('key separation', solve([[['a', 3, 10], ['b', 3, 11]], 2]), [['a', 3, 3, [10]], ['b', 3, 3, [11]]])
    check('separate sessions', solve([[['a', 3, 10], ['a', 8, 11]], 2]), [['a', 3, 3, [10]], ['a', 8, 8, [11]]])
    check('equal timestamp', solve([[['a', 3, 11], ['a', 3, 10]], 0]), [['a', 3, 3, [10, 11]]])
    check('single event', solve([[['a', 3, 10]], 2]), [['a', 3, 3, [10]]])
    check('empty stream', solve([[], 2]), [])
elif N == 4:
    check('bridge chain', solve([[['a', 4, 10], ['a', 6, 11], ['a', 8, 12]], 2]), [['a', 4, 8, [10, 11, 12]]])
    check('arrival order', solve([[['a', 6, 10], ['a', 4, 11]], 2]), [['a', 4, 6, [11, 10]]])
    check('key separation', solve([[['a', 4, 10], ['b', 4, 11]], 2]), [['a', 4, 4, [10]], ['b', 4, 4, [11]]])
    check('separate sessions', solve([[['a', 4, 10], ['a', 9, 11]], 2]), [['a', 4, 4, [10]], ['a', 9, 9, [11]]])
    check('equal timestamp', solve([[['a', 4, 11], ['a', 4, 10]], 0]), [['a', 4, 4, [10, 11]]])
    check('single event', solve([[['a', 4, 10]], 2]), [['a', 4, 4, [10]]])
    check('empty stream', solve([[], 2]), [])
elif N == 5:
    check('bridge chain', solve([[['a', 5, 10], ['a', 7, 11], ['a', 9, 12]], 2]), [['a', 5, 9, [10, 11, 12]]])
    check('arrival order', solve([[['a', 7, 10], ['a', 5, 11]], 2]), [['a', 5, 7, [11, 10]]])
    check('key separation', solve([[['a', 5, 10], ['b', 5, 11]], 2]), [['a', 5, 5, [10]], ['b', 5, 5, [11]]])
    check('separate sessions', solve([[['a', 5, 10], ['a', 10, 11]], 2]), [['a', 5, 5, [10]], ['a', 10, 10, [11]]])
    check('equal timestamp', solve([[['a', 5, 11], ['a', 5, 10]], 0]), [['a', 5, 5, [10, 11]]])
    check('single event', solve([[['a', 5, 10]], 2]), [['a', 5, 5, [10]]])
    check('empty stream', solve([[], 2]), [])
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:
Session grouping compares every event with the first timestamp.

Group [key,time,id] events into sessions independently by key. Sort each key by (time,id); consecutive gaps <=gap belong to one transitive session. Emit [key,first-time,last-time,ordered-ids] ordered by key and session time. An intervening bridge may join otherwise distant endpoints.

split: open-access