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

N = 1
observations = []
def solve(d):
    try:
        facts,versions=d
        out=[]
        for ident,key,time in facts:
            candidates=[r for r in versions if key is not None and r[0]==key and r[1]<=time]
            if not candidates: out.append([ident,None]); continue
            chosen=max(candidates,key=lambda r:r[1])
            out.append([ident,None if chosen[4] else chosen[3]])
        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('future ignored', solve([[[10, 'a', 2]], [['a', 1, 1, 'old', False], ['a', 3, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 1]], [['a', 1, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 1]], [['a', 1, 1, 'old', False], ['a', 1, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 2]], [['a', 1, 1, 'old', False], ['a', 2, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 1]], [['a', 1, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 2]], [['a', 1, 1, 'right', False], ['b', 2, 1, 'wrong', False], [None, 2, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('future ignored', solve([[[10, 'a', 3]], [['a', 2, 1, 'old', False], ['a', 4, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 2]], [['a', 2, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 2]], [['a', 2, 1, 'old', False], ['a', 2, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 3]], [['a', 2, 1, 'old', False], ['a', 3, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 2]], [['a', 2, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 3]], [['a', 2, 1, 'right', False], ['b', 3, 1, 'wrong', False], [None, 3, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('future ignored', solve([[[10, 'a', 4]], [['a', 3, 1, 'old', False], ['a', 5, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 3]], [['a', 3, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 3]], [['a', 3, 1, 'old', False], ['a', 3, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 4]], [['a', 3, 1, 'old', False], ['a', 4, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 3]], [['a', 3, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 4]], [['a', 3, 1, 'right', False], ['b', 4, 1, 'wrong', False], [None, 4, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('future ignored', solve([[[10, 'a', 5]], [['a', 4, 1, 'old', False], ['a', 6, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 4]], [['a', 4, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 4]], [['a', 4, 1, 'old', False], ['a', 4, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 5]], [['a', 4, 1, 'old', False], ['a', 5, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 4]], [['a', 4, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 5]], [['a', 4, 1, 'right', False], ['b', 5, 1, 'wrong', False], [None, 5, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('future ignored', solve([[[10, 'a', 6]], [['a', 5, 1, 'old', False], ['a', 7, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 5]], [['a', 5, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 5]], [['a', 5, 1, 'old', False], ['a', 5, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 6]], [['a', 5, 1, 'old', False], ['a', 6, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 5]], [['a', 5, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 6]], [['a', 5, 1, 'right', False], ['b', 6, 1, 'wrong', False], [None, 6, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 5]], []]), [[10, None]])
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:
        facts,versions=d
        out=[]
        for ident,key,time in facts:
            candidates=[r for r in versions if key is not None and r[0]==key and r[1]<=time]
            if not candidates: out.append([ident,None]); continue
            chosen=max(candidates,key=lambda r:(r[1],-r[2]))
            out.append([ident,None if chosen[4] else chosen[3]])
        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('future ignored', solve([[[10, 'a', 2]], [['a', 1, 1, 'old', False], ['a', 3, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 1]], [['a', 1, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 1]], [['a', 1, 1, 'old', False], ['a', 1, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 2]], [['a', 1, 1, 'old', False], ['a', 2, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 1]], [['a', 1, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 2]], [['a', 1, 1, 'right', False], ['b', 2, 1, 'wrong', False], [None, 2, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('future ignored', solve([[[10, 'a', 3]], [['a', 2, 1, 'old', False], ['a', 4, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 2]], [['a', 2, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 2]], [['a', 2, 1, 'old', False], ['a', 2, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 3]], [['a', 2, 1, 'old', False], ['a', 3, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 2]], [['a', 2, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 3]], [['a', 2, 1, 'right', False], ['b', 3, 1, 'wrong', False], [None, 3, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('future ignored', solve([[[10, 'a', 4]], [['a', 3, 1, 'old', False], ['a', 5, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 3]], [['a', 3, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 3]], [['a', 3, 1, 'old', False], ['a', 3, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 4]], [['a', 3, 1, 'old', False], ['a', 4, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 3]], [['a', 3, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 4]], [['a', 3, 1, 'right', False], ['b', 4, 1, 'wrong', False], [None, 4, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('future ignored', solve([[[10, 'a', 5]], [['a', 4, 1, 'old', False], ['a', 6, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 4]], [['a', 4, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 4]], [['a', 4, 1, 'old', False], ['a', 4, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 5]], [['a', 4, 1, 'old', False], ['a', 5, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 4]], [['a', 4, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 5]], [['a', 4, 1, 'right', False], ['b', 5, 1, 'wrong', False], [None, 5, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('future ignored', solve([[[10, 'a', 6]], [['a', 5, 1, 'old', False], ['a', 7, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 5]], [['a', 5, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 5]], [['a', 5, 1, 'old', False], ['a', 5, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 6]], [['a', 5, 1, 'old', False], ['a', 6, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 5]], [['a', 5, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 6]], [['a', 5, 1, 'right', False], ['b', 6, 1, 'wrong', False], [None, 6, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 5]], []]), [[10, None]])
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:
Temporal enrichment ignores revisions at equal effective time.

Enrich facts [id,key,event-time] from versioned dimension rows [key,valid-from,revision,payload,tombstone]. For matching non-null key, use the greatest (valid-from,revision) no later than fact time. A selected tombstone yields None and blocks fallback to older versions. Emit [fact-id,payload-or-None].

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        facts,versions=d
        out=[]
        for ident,key,time in facts:
            candidates=[r for r in versions if key is not None and r[0]==key and r[1]<=time and not r[4]]
            if not candidates: out.append([ident,None]); continue
            chosen=max(candidates,key=lambda r:(r[1],r[2]))
            out.append([ident,None if chosen[4] else chosen[3]])
        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('future ignored', solve([[[10, 'a', 2]], [['a', 1, 1, 'old', False], ['a', 3, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 1]], [['a', 1, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 1]], [['a', 1, 1, 'old', False], ['a', 1, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 2]], [['a', 1, 1, 'old', False], ['a', 2, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 1]], [['a', 1, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 2]], [['a', 1, 1, 'right', False], ['b', 2, 1, 'wrong', False], [None, 2, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('future ignored', solve([[[10, 'a', 3]], [['a', 2, 1, 'old', False], ['a', 4, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 2]], [['a', 2, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 2]], [['a', 2, 1, 'old', False], ['a', 2, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 3]], [['a', 2, 1, 'old', False], ['a', 3, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 2]], [['a', 2, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 3]], [['a', 2, 1, 'right', False], ['b', 3, 1, 'wrong', False], [None, 3, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('future ignored', solve([[[10, 'a', 4]], [['a', 3, 1, 'old', False], ['a', 5, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 3]], [['a', 3, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 3]], [['a', 3, 1, 'old', False], ['a', 3, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 4]], [['a', 3, 1, 'old', False], ['a', 4, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 3]], [['a', 3, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 4]], [['a', 3, 1, 'right', False], ['b', 4, 1, 'wrong', False], [None, 4, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('future ignored', solve([[[10, 'a', 5]], [['a', 4, 1, 'old', False], ['a', 6, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 4]], [['a', 4, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 4]], [['a', 4, 1, 'old', False], ['a', 4, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 5]], [['a', 4, 1, 'old', False], ['a', 5, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 4]], [['a', 4, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 5]], [['a', 4, 1, 'right', False], ['b', 5, 1, 'wrong', False], [None, 5, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('future ignored', solve([[[10, 'a', 6]], [['a', 5, 1, 'old', False], ['a', 7, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 5]], [['a', 5, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 5]], [['a', 5, 1, 'old', False], ['a', 5, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 6]], [['a', 5, 1, 'old', False], ['a', 6, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 5]], [['a', 5, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 6]], [['a', 5, 1, 'right', False], ['b', 6, 1, 'wrong', False], [None, 6, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 5]], []]), [[10, None]])
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:
        facts,versions=d
        out=[]
        for ident,key,time in facts:
            candidates=[r for r in versions if key is not None and r[0]==key and r[1]<=time and r[3] is not None]
            if not candidates: out.append([ident,None]); continue
            chosen=max(candidates,key=lambda r:(r[1],r[2]))
            out.append([ident,None if chosen[4] else chosen[3]])
        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('future ignored', solve([[[10, 'a', 2]], [['a', 1, 1, 'old', False], ['a', 3, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 1]], [['a', 1, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 1]], [['a', 1, 1, 'old', False], ['a', 1, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 2]], [['a', 1, 1, 'old', False], ['a', 2, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 1]], [['a', 1, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 2]], [['a', 1, 1, 'right', False], ['b', 2, 1, 'wrong', False], [None, 2, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('future ignored', solve([[[10, 'a', 3]], [['a', 2, 1, 'old', False], ['a', 4, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 2]], [['a', 2, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 2]], [['a', 2, 1, 'old', False], ['a', 2, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 3]], [['a', 2, 1, 'old', False], ['a', 3, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 2]], [['a', 2, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 3]], [['a', 2, 1, 'right', False], ['b', 3, 1, 'wrong', False], [None, 3, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('future ignored', solve([[[10, 'a', 4]], [['a', 3, 1, 'old', False], ['a', 5, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 3]], [['a', 3, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 3]], [['a', 3, 1, 'old', False], ['a', 3, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 4]], [['a', 3, 1, 'old', False], ['a', 4, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 3]], [['a', 3, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 4]], [['a', 3, 1, 'right', False], ['b', 4, 1, 'wrong', False], [None, 4, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('future ignored', solve([[[10, 'a', 5]], [['a', 4, 1, 'old', False], ['a', 6, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 4]], [['a', 4, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 4]], [['a', 4, 1, 'old', False], ['a', 4, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 5]], [['a', 4, 1, 'old', False], ['a', 5, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 4]], [['a', 4, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 5]], [['a', 4, 1, 'right', False], ['b', 5, 1, 'wrong', False], [None, 5, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('future ignored', solve([[[10, 'a', 6]], [['a', 5, 1, 'old', False], ['a', 7, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 5]], [['a', 5, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 5]], [['a', 5, 1, 'old', False], ['a', 5, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 6]], [['a', 5, 1, 'old', False], ['a', 6, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 5]], [['a', 5, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 6]], [['a', 5, 1, 'right', False], ['b', 6, 1, 'wrong', False], [None, 6, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 5]], []]), [[10, None]])
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:
Temporal enrichment skips tombstones and revives older dimension values.

Enrich facts [id,key,event-time] from versioned dimension rows [key,valid-from,revision,payload,tombstone]. For matching non-null key, use the greatest (valid-from,revision) no later than fact time. A selected tombstone yields None and blocks fallback to older versions. Emit [fact-id,payload-or-None].

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        facts,versions=d
        out=[]
        for ident,key,time in facts:
            candidates=[r for r in versions if key is not None and True and r[1]<=time]
            if not candidates: out.append([ident,None]); continue
            chosen=max(candidates,key=lambda r:(r[1],r[2]))
            out.append([ident,None if chosen[4] else chosen[3]])
        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('future ignored', solve([[[10, 'a', 2]], [['a', 1, 1, 'old', False], ['a', 3, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 1]], [['a', 1, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 1]], [['a', 1, 1, 'old', False], ['a', 1, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 2]], [['a', 1, 1, 'old', False], ['a', 2, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 1]], [['a', 1, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 2]], [['a', 1, 1, 'right', False], ['b', 2, 1, 'wrong', False], [None, 2, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('future ignored', solve([[[10, 'a', 3]], [['a', 2, 1, 'old', False], ['a', 4, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 2]], [['a', 2, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 2]], [['a', 2, 1, 'old', False], ['a', 2, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 3]], [['a', 2, 1, 'old', False], ['a', 3, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 2]], [['a', 2, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 3]], [['a', 2, 1, 'right', False], ['b', 3, 1, 'wrong', False], [None, 3, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('future ignored', solve([[[10, 'a', 4]], [['a', 3, 1, 'old', False], ['a', 5, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 3]], [['a', 3, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 3]], [['a', 3, 1, 'old', False], ['a', 3, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 4]], [['a', 3, 1, 'old', False], ['a', 4, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 3]], [['a', 3, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 4]], [['a', 3, 1, 'right', False], ['b', 4, 1, 'wrong', False], [None, 4, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('future ignored', solve([[[10, 'a', 5]], [['a', 4, 1, 'old', False], ['a', 6, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 4]], [['a', 4, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 4]], [['a', 4, 1, 'old', False], ['a', 4, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 5]], [['a', 4, 1, 'old', False], ['a', 5, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 4]], [['a', 4, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 5]], [['a', 4, 1, 'right', False], ['b', 5, 1, 'wrong', False], [None, 5, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('future ignored', solve([[[10, 'a', 6]], [['a', 5, 1, 'old', False], ['a', 7, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 5]], [['a', 5, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 5]], [['a', 5, 1, 'old', False], ['a', 5, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 6]], [['a', 5, 1, 'old', False], ['a', 6, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 5]], [['a', 5, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 6]], [['a', 5, 1, 'right', False], ['b', 6, 1, 'wrong', False], [None, 6, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 5]], []]), [[10, None]])
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:
        facts,versions=d
        out=[]
        for ident,key,time in facts:
            candidates=[r for r in versions if key is not None and (r[0]==key or r[0] is None) and r[1]<=time]
            if not candidates: out.append([ident,None]); continue
            chosen=max(candidates,key=lambda r:(r[1],r[2]))
            out.append([ident,None if chosen[4] else chosen[3]])
        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('future ignored', solve([[[10, 'a', 2]], [['a', 1, 1, 'old', False], ['a', 3, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 1]], [['a', 1, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 1]], [['a', 1, 1, 'old', False], ['a', 1, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 2]], [['a', 1, 1, 'old', False], ['a', 2, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 1]], [['a', 1, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 2]], [['a', 1, 1, 'right', False], ['b', 2, 1, 'wrong', False], [None, 2, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('future ignored', solve([[[10, 'a', 3]], [['a', 2, 1, 'old', False], ['a', 4, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 2]], [['a', 2, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 2]], [['a', 2, 1, 'old', False], ['a', 2, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 3]], [['a', 2, 1, 'old', False], ['a', 3, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 2]], [['a', 2, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 3]], [['a', 2, 1, 'right', False], ['b', 3, 1, 'wrong', False], [None, 3, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('future ignored', solve([[[10, 'a', 4]], [['a', 3, 1, 'old', False], ['a', 5, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 3]], [['a', 3, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 3]], [['a', 3, 1, 'old', False], ['a', 3, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 4]], [['a', 3, 1, 'old', False], ['a', 4, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 3]], [['a', 3, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 4]], [['a', 3, 1, 'right', False], ['b', 4, 1, 'wrong', False], [None, 4, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('future ignored', solve([[[10, 'a', 5]], [['a', 4, 1, 'old', False], ['a', 6, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 4]], [['a', 4, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 4]], [['a', 4, 1, 'old', False], ['a', 4, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 5]], [['a', 4, 1, 'old', False], ['a', 5, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 4]], [['a', 4, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 5]], [['a', 4, 1, 'right', False], ['b', 5, 1, 'wrong', False], [None, 5, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('future ignored', solve([[[10, 'a', 6]], [['a', 5, 1, 'old', False], ['a', 7, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 5]], [['a', 5, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 5]], [['a', 5, 1, 'old', False], ['a', 5, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 6]], [['a', 5, 1, 'old', False], ['a', 6, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 5]], [['a', 5, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 6]], [['a', 5, 1, 'right', False], ['b', 6, 1, 'wrong', False], [None, 6, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 5]], []]), [[10, None]])
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:
Temporal enrichment chooses the newest version across all keys.

Enrich facts [id,key,event-time] from versioned dimension rows [key,valid-from,revision,payload,tombstone]. For matching non-null key, use the greatest (valid-from,revision) no later than fact time. A selected tombstone yields None and blocks fallback to older versions. Emit [fact-id,payload-or-None].

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        facts,versions=d
        out=[]
        for ident,key,time in facts:
            candidates=[r for r in versions if key is not None and r[0]==key and r[1]<=time]
            if not candidates: out.append([ident,None]); continue
            chosen=max(candidates,key=lambda r:(r[1],r[2]))
            out.append([ident,chosen[3]])
        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('future ignored', solve([[[10, 'a', 2]], [['a', 1, 1, 'old', False], ['a', 3, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 1]], [['a', 1, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 1]], [['a', 1, 1, 'old', False], ['a', 1, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 2]], [['a', 1, 1, 'old', False], ['a', 2, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 1]], [['a', 1, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 2]], [['a', 1, 1, 'right', False], ['b', 2, 1, 'wrong', False], [None, 2, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('future ignored', solve([[[10, 'a', 3]], [['a', 2, 1, 'old', False], ['a', 4, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 2]], [['a', 2, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 2]], [['a', 2, 1, 'old', False], ['a', 2, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 3]], [['a', 2, 1, 'old', False], ['a', 3, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 2]], [['a', 2, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 3]], [['a', 2, 1, 'right', False], ['b', 3, 1, 'wrong', False], [None, 3, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('future ignored', solve([[[10, 'a', 4]], [['a', 3, 1, 'old', False], ['a', 5, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 3]], [['a', 3, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 3]], [['a', 3, 1, 'old', False], ['a', 3, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 4]], [['a', 3, 1, 'old', False], ['a', 4, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 3]], [['a', 3, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 4]], [['a', 3, 1, 'right', False], ['b', 4, 1, 'wrong', False], [None, 4, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('future ignored', solve([[[10, 'a', 5]], [['a', 4, 1, 'old', False], ['a', 6, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 4]], [['a', 4, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 4]], [['a', 4, 1, 'old', False], ['a', 4, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 5]], [['a', 4, 1, 'old', False], ['a', 5, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 4]], [['a', 4, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 5]], [['a', 4, 1, 'right', False], ['b', 5, 1, 'wrong', False], [None, 5, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('future ignored', solve([[[10, 'a', 6]], [['a', 5, 1, 'old', False], ['a', 7, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 5]], [['a', 5, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 5]], [['a', 5, 1, 'old', False], ['a', 5, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 6]], [['a', 5, 1, 'old', False], ['a', 6, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 5]], [['a', 5, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 6]], [['a', 5, 1, 'right', False], ['b', 6, 1, 'wrong', False], [None, 6, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 5]], []]), [[10, None]])
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:
        facts,versions=d
        out=[]
        for ident,key,time in facts:
            candidates=[r for r in versions if key is not None and r[0]==key and r[1]<=time]
            if not candidates: out.append([ident,None]); continue
            chosen=max(candidates,key=lambda r:(r[1],r[2]))
            out.append([ident,chosen[3] if chosen[3] is not None else 0])
        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('future ignored', solve([[[10, 'a', 2]], [['a', 1, 1, 'old', False], ['a', 3, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 1]], [['a', 1, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 1]], [['a', 1, 1, 'old', False], ['a', 1, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 2]], [['a', 1, 1, 'old', False], ['a', 2, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 1]], [['a', 1, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 2]], [['a', 1, 1, 'right', False], ['b', 2, 1, 'wrong', False], [None, 2, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('future ignored', solve([[[10, 'a', 3]], [['a', 2, 1, 'old', False], ['a', 4, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 2]], [['a', 2, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 2]], [['a', 2, 1, 'old', False], ['a', 2, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 3]], [['a', 2, 1, 'old', False], ['a', 3, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 2]], [['a', 2, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 3]], [['a', 2, 1, 'right', False], ['b', 3, 1, 'wrong', False], [None, 3, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('future ignored', solve([[[10, 'a', 4]], [['a', 3, 1, 'old', False], ['a', 5, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 3]], [['a', 3, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 3]], [['a', 3, 1, 'old', False], ['a', 3, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 4]], [['a', 3, 1, 'old', False], ['a', 4, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 3]], [['a', 3, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 4]], [['a', 3, 1, 'right', False], ['b', 4, 1, 'wrong', False], [None, 4, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('future ignored', solve([[[10, 'a', 5]], [['a', 4, 1, 'old', False], ['a', 6, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 4]], [['a', 4, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 4]], [['a', 4, 1, 'old', False], ['a', 4, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 5]], [['a', 4, 1, 'old', False], ['a', 5, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 4]], [['a', 4, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 5]], [['a', 4, 1, 'right', False], ['b', 5, 1, 'wrong', False], [None, 5, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('future ignored', solve([[[10, 'a', 6]], [['a', 5, 1, 'old', False], ['a', 7, 1, 'future', False]]]), [[10, 'old']])
    check('exact effective time', solve([[[10, 'a', 5]], [['a', 5, 1, 'current', False]]]), [[10, 'current']])
    check('revision precedence', solve([[[10, 'a', 5]], [['a', 5, 1, 'old', False], ['a', 5, 2, 'new', False]]]), [[10, 'new']])
    check('tombstone blocks old', solve([[[10, 'a', 6]], [['a', 5, 1, 'old', False], ['a', 6, 1, None, True]]]), [[10, None]])
    check('tombstone hidden payload', solve([[[10, 'a', 5]], [['a', 5, 1, 'hidden', True]]]), [[10, None]])
    check('other key', solve([[[10, 'a', 6]], [['a', 5, 1, 'right', False], ['b', 6, 1, 'wrong', False], [None, 6, 2, 'wildcard', False]]]), [[10, 'right']])
    check('absent dimension', solve([[[10, 'a', 5]], []]), [[10, None]])
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:
Temporal enrichment exposes the hidden payload of a deleted dimension row.

Enrich facts [id,key,event-time] from versioned dimension rows [key,valid-from,revision,payload,tombstone]. For matching non-null key, use the greatest (valid-from,revision) no later than fact time. A selected tombstone yields None and blocks fallback to older versions. Emit [fact-id,payload-or-None].

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        rows,mapping,null_partition,count=d
        receivers=[[]]*count; rejected=[]
        for ident,key,payload in rows:
            if key is None: target=null_partition
            elif str(key) in mapping: target=mapping[str(key)]
            else: rejected.append([ident,'UNMAPPED']); continue
            receivers[target].append([ident,payload])
        return [receivers,rejected]
    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('independent receivers', solve([[[10, 1, 1], [11, 2, 2]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 1]], [[11, 2]], []], []])
    check('null receiver', solve([[[10, None, 1]], {}, 1, 3]), [[[], [[10, 1]], []], []])
    check('unmapped', solve([[[10, 7, 1]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 1], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[11, 1], [10, 2]], []], []])
    check('duplicate rows', solve([[[10, 1, 1], [10, 1, 1]], {'1': 0}, 1, 2]), [[[[10, 1], [10, 1]], []], []])
    check('mapped zero', solve([[[10, 0, 1]], {'0': 1}, 0, 2]), [[[], [[10, 1]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 2:
    check('independent receivers', solve([[[10, 1, 2], [11, 2, 3]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 2]], [[11, 3]], []], []])
    check('null receiver', solve([[[10, None, 2]], {}, 1, 3]), [[[], [[10, 2]], []], []])
    check('unmapped', solve([[[10, 7, 2]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 2], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[11, 2], [10, 3]], []], []])
    check('duplicate rows', solve([[[10, 1, 2], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[10, 2], [10, 2]], []], []])
    check('mapped zero', solve([[[10, 0, 2]], {'0': 1}, 0, 2]), [[[], [[10, 2]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 3:
    check('independent receivers', solve([[[10, 1, 3], [11, 2, 4]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 3]], [[11, 4]], []], []])
    check('null receiver', solve([[[10, None, 3]], {}, 1, 3]), [[[], [[10, 3]], []], []])
    check('unmapped', solve([[[10, 7, 3]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 3], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[11, 3], [10, 4]], []], []])
    check('duplicate rows', solve([[[10, 1, 3], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[10, 3], [10, 3]], []], []])
    check('mapped zero', solve([[[10, 0, 3]], {'0': 1}, 0, 2]), [[[], [[10, 3]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 4:
    check('independent receivers', solve([[[10, 1, 4], [11, 2, 5]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 4]], [[11, 5]], []], []])
    check('null receiver', solve([[[10, None, 4]], {}, 1, 3]), [[[], [[10, 4]], []], []])
    check('unmapped', solve([[[10, 7, 4]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 4], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[11, 4], [10, 5]], []], []])
    check('duplicate rows', solve([[[10, 1, 4], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[10, 4], [10, 4]], []], []])
    check('mapped zero', solve([[[10, 0, 4]], {'0': 1}, 0, 2]), [[[], [[10, 4]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 5:
    check('independent receivers', solve([[[10, 1, 5], [11, 2, 6]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 5]], [[11, 6]], []], []])
    check('null receiver', solve([[[10, None, 5]], {}, 1, 3]), [[[], [[10, 5]], []], []])
    check('unmapped', solve([[[10, 7, 5]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 5], [10, 1, 6]], {'1': 0}, 1, 2]), [[[[11, 5], [10, 6]], []], []])
    check('duplicate rows', solve([[[10, 1, 5], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[10, 5], [10, 5]], []], []])
    check('mapped zero', solve([[[10, 0, 5]], {'0': 1}, 0, 2]), [[[], [[10, 5]]], []])
    check('empty relation', solve([[], {}, 0, 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:
        rows,mapping,null_partition,count=d
        receivers=[[]]+[[]]*(count-1); rejected=[]
        for ident,key,payload in rows:
            if key is None: target=null_partition
            elif str(key) in mapping: target=mapping[str(key)]
            else: rejected.append([ident,'UNMAPPED']); continue
            receivers[target].append([ident,payload])
        return [receivers,rejected]
    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('independent receivers', solve([[[10, 1, 1], [11, 2, 2]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 1]], [[11, 2]], []], []])
    check('null receiver', solve([[[10, None, 1]], {}, 1, 3]), [[[], [[10, 1]], []], []])
    check('unmapped', solve([[[10, 7, 1]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 1], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[11, 1], [10, 2]], []], []])
    check('duplicate rows', solve([[[10, 1, 1], [10, 1, 1]], {'1': 0}, 1, 2]), [[[[10, 1], [10, 1]], []], []])
    check('mapped zero', solve([[[10, 0, 1]], {'0': 1}, 0, 2]), [[[], [[10, 1]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 2:
    check('independent receivers', solve([[[10, 1, 2], [11, 2, 3]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 2]], [[11, 3]], []], []])
    check('null receiver', solve([[[10, None, 2]], {}, 1, 3]), [[[], [[10, 2]], []], []])
    check('unmapped', solve([[[10, 7, 2]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 2], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[11, 2], [10, 3]], []], []])
    check('duplicate rows', solve([[[10, 1, 2], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[10, 2], [10, 2]], []], []])
    check('mapped zero', solve([[[10, 0, 2]], {'0': 1}, 0, 2]), [[[], [[10, 2]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 3:
    check('independent receivers', solve([[[10, 1, 3], [11, 2, 4]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 3]], [[11, 4]], []], []])
    check('null receiver', solve([[[10, None, 3]], {}, 1, 3]), [[[], [[10, 3]], []], []])
    check('unmapped', solve([[[10, 7, 3]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 3], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[11, 3], [10, 4]], []], []])
    check('duplicate rows', solve([[[10, 1, 3], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[10, 3], [10, 3]], []], []])
    check('mapped zero', solve([[[10, 0, 3]], {'0': 1}, 0, 2]), [[[], [[10, 3]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 4:
    check('independent receivers', solve([[[10, 1, 4], [11, 2, 5]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 4]], [[11, 5]], []], []])
    check('null receiver', solve([[[10, None, 4]], {}, 1, 3]), [[[], [[10, 4]], []], []])
    check('unmapped', solve([[[10, 7, 4]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 4], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[11, 4], [10, 5]], []], []])
    check('duplicate rows', solve([[[10, 1, 4], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[10, 4], [10, 4]], []], []])
    check('mapped zero', solve([[[10, 0, 4]], {'0': 1}, 0, 2]), [[[], [[10, 4]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 5:
    check('independent receivers', solve([[[10, 1, 5], [11, 2, 6]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 5]], [[11, 6]], []], []])
    check('null receiver', solve([[[10, None, 5]], {}, 1, 3]), [[[], [[10, 5]], []], []])
    check('unmapped', solve([[[10, 7, 5]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 5], [10, 1, 6]], {'1': 0}, 1, 2]), [[[[11, 5], [10, 6]], []], []])
    check('duplicate rows', solve([[[10, 1, 5], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[10, 5], [10, 5]], []], []])
    check('mapped zero', solve([[[10, 0, 5]], {'0': 1}, 0, 2]), [[[], [[10, 5]]], []])
    check('empty relation', solve([[], {}, 0, 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:
Exchange receivers share the same mutable row buffer.

Route [id,key,payload] rows into fixed receiver partitions using a supplied key-to-partition table. Null keys use the explicit null partition; unmapped non-null keys produce UNMAPPED side output. Preserve source order within each receiver, retain empty receivers, and preserve repeated rows.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        rows,mapping,null_partition,count=d
        receivers=[[] for _ in range(count)]; rejected=[]
        for ident,key,payload in rows:
            if key is None: target=0
            elif str(key) in mapping: target=mapping[str(key)]
            else: rejected.append([ident,'UNMAPPED']); continue
            receivers[target].append([ident,payload])
        return [receivers,rejected]
    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('independent receivers', solve([[[10, 1, 1], [11, 2, 2]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 1]], [[11, 2]], []], []])
    check('null receiver', solve([[[10, None, 1]], {}, 1, 3]), [[[], [[10, 1]], []], []])
    check('unmapped', solve([[[10, 7, 1]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 1], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[11, 1], [10, 2]], []], []])
    check('duplicate rows', solve([[[10, 1, 1], [10, 1, 1]], {'1': 0}, 1, 2]), [[[[10, 1], [10, 1]], []], []])
    check('mapped zero', solve([[[10, 0, 1]], {'0': 1}, 0, 2]), [[[], [[10, 1]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 2:
    check('independent receivers', solve([[[10, 1, 2], [11, 2, 3]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 2]], [[11, 3]], []], []])
    check('null receiver', solve([[[10, None, 2]], {}, 1, 3]), [[[], [[10, 2]], []], []])
    check('unmapped', solve([[[10, 7, 2]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 2], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[11, 2], [10, 3]], []], []])
    check('duplicate rows', solve([[[10, 1, 2], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[10, 2], [10, 2]], []], []])
    check('mapped zero', solve([[[10, 0, 2]], {'0': 1}, 0, 2]), [[[], [[10, 2]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 3:
    check('independent receivers', solve([[[10, 1, 3], [11, 2, 4]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 3]], [[11, 4]], []], []])
    check('null receiver', solve([[[10, None, 3]], {}, 1, 3]), [[[], [[10, 3]], []], []])
    check('unmapped', solve([[[10, 7, 3]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 3], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[11, 3], [10, 4]], []], []])
    check('duplicate rows', solve([[[10, 1, 3], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[10, 3], [10, 3]], []], []])
    check('mapped zero', solve([[[10, 0, 3]], {'0': 1}, 0, 2]), [[[], [[10, 3]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 4:
    check('independent receivers', solve([[[10, 1, 4], [11, 2, 5]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 4]], [[11, 5]], []], []])
    check('null receiver', solve([[[10, None, 4]], {}, 1, 3]), [[[], [[10, 4]], []], []])
    check('unmapped', solve([[[10, 7, 4]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 4], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[11, 4], [10, 5]], []], []])
    check('duplicate rows', solve([[[10, 1, 4], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[10, 4], [10, 4]], []], []])
    check('mapped zero', solve([[[10, 0, 4]], {'0': 1}, 0, 2]), [[[], [[10, 4]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 5:
    check('independent receivers', solve([[[10, 1, 5], [11, 2, 6]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 5]], [[11, 6]], []], []])
    check('null receiver', solve([[[10, None, 5]], {}, 1, 3]), [[[], [[10, 5]], []], []])
    check('unmapped', solve([[[10, 7, 5]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 5], [10, 1, 6]], {'1': 0}, 1, 2]), [[[[11, 5], [10, 6]], []], []])
    check('duplicate rows', solve([[[10, 1, 5], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[10, 5], [10, 5]], []], []])
    check('mapped zero', solve([[[10, 0, 5]], {'0': 1}, 0, 2]), [[[], [[10, 5]]], []])
    check('empty relation', solve([[], {}, 0, 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:
        rows,mapping,null_partition,count=d
        receivers=[[] for _ in range(count)]; rejected=[]
        for ident,key,payload in rows:
            if key is None: target=count-1
            elif str(key) in mapping: target=mapping[str(key)]
            else: rejected.append([ident,'UNMAPPED']); continue
            receivers[target].append([ident,payload])
        return [receivers,rejected]
    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('independent receivers', solve([[[10, 1, 1], [11, 2, 2]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 1]], [[11, 2]], []], []])
    check('null receiver', solve([[[10, None, 1]], {}, 1, 3]), [[[], [[10, 1]], []], []])
    check('unmapped', solve([[[10, 7, 1]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 1], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[11, 1], [10, 2]], []], []])
    check('duplicate rows', solve([[[10, 1, 1], [10, 1, 1]], {'1': 0}, 1, 2]), [[[[10, 1], [10, 1]], []], []])
    check('mapped zero', solve([[[10, 0, 1]], {'0': 1}, 0, 2]), [[[], [[10, 1]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 2:
    check('independent receivers', solve([[[10, 1, 2], [11, 2, 3]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 2]], [[11, 3]], []], []])
    check('null receiver', solve([[[10, None, 2]], {}, 1, 3]), [[[], [[10, 2]], []], []])
    check('unmapped', solve([[[10, 7, 2]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 2], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[11, 2], [10, 3]], []], []])
    check('duplicate rows', solve([[[10, 1, 2], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[10, 2], [10, 2]], []], []])
    check('mapped zero', solve([[[10, 0, 2]], {'0': 1}, 0, 2]), [[[], [[10, 2]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 3:
    check('independent receivers', solve([[[10, 1, 3], [11, 2, 4]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 3]], [[11, 4]], []], []])
    check('null receiver', solve([[[10, None, 3]], {}, 1, 3]), [[[], [[10, 3]], []], []])
    check('unmapped', solve([[[10, 7, 3]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 3], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[11, 3], [10, 4]], []], []])
    check('duplicate rows', solve([[[10, 1, 3], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[10, 3], [10, 3]], []], []])
    check('mapped zero', solve([[[10, 0, 3]], {'0': 1}, 0, 2]), [[[], [[10, 3]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 4:
    check('independent receivers', solve([[[10, 1, 4], [11, 2, 5]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 4]], [[11, 5]], []], []])
    check('null receiver', solve([[[10, None, 4]], {}, 1, 3]), [[[], [[10, 4]], []], []])
    check('unmapped', solve([[[10, 7, 4]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 4], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[11, 4], [10, 5]], []], []])
    check('duplicate rows', solve([[[10, 1, 4], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[10, 4], [10, 4]], []], []])
    check('mapped zero', solve([[[10, 0, 4]], {'0': 1}, 0, 2]), [[[], [[10, 4]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 5:
    check('independent receivers', solve([[[10, 1, 5], [11, 2, 6]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 5]], [[11, 6]], []], []])
    check('null receiver', solve([[[10, None, 5]], {}, 1, 3]), [[[], [[10, 5]], []], []])
    check('unmapped', solve([[[10, 7, 5]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 5], [10, 1, 6]], {'1': 0}, 1, 2]), [[[[11, 5], [10, 6]], []], []])
    check('duplicate rows', solve([[[10, 1, 5], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[10, 5], [10, 5]], []], []])
    check('mapped zero', solve([[[10, 0, 5]], {'0': 1}, 0, 2]), [[[], [[10, 5]]], []])
    check('empty relation', solve([[], {}, 0, 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:
Exchange routes null keys to receiver zero instead of the configured receiver.

Route [id,key,payload] rows into fixed receiver partitions using a supplied key-to-partition table. Null keys use the explicit null partition; unmapped non-null keys produce UNMAPPED side output. Preserve source order within each receiver, retain empty receivers, and preserve repeated rows.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        rows,mapping,null_partition,count=d
        receivers=[[] for _ in range(count)]; rejected=[]
        for ident,key,payload in rows:
            if key is None: target=null_partition
            elif str(ident) in mapping: target=mapping[str(ident)]
            else: rejected.append([ident,'UNMAPPED']); continue
            receivers[target].append([ident,payload])
        return [receivers,rejected]
    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('independent receivers', solve([[[10, 1, 1], [11, 2, 2]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 1]], [[11, 2]], []], []])
    check('null receiver', solve([[[10, None, 1]], {}, 1, 3]), [[[], [[10, 1]], []], []])
    check('unmapped', solve([[[10, 7, 1]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 1], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[11, 1], [10, 2]], []], []])
    check('duplicate rows', solve([[[10, 1, 1], [10, 1, 1]], {'1': 0}, 1, 2]), [[[[10, 1], [10, 1]], []], []])
    check('mapped zero', solve([[[10, 0, 1]], {'0': 1}, 0, 2]), [[[], [[10, 1]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 2:
    check('independent receivers', solve([[[10, 1, 2], [11, 2, 3]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 2]], [[11, 3]], []], []])
    check('null receiver', solve([[[10, None, 2]], {}, 1, 3]), [[[], [[10, 2]], []], []])
    check('unmapped', solve([[[10, 7, 2]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 2], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[11, 2], [10, 3]], []], []])
    check('duplicate rows', solve([[[10, 1, 2], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[10, 2], [10, 2]], []], []])
    check('mapped zero', solve([[[10, 0, 2]], {'0': 1}, 0, 2]), [[[], [[10, 2]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 3:
    check('independent receivers', solve([[[10, 1, 3], [11, 2, 4]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 3]], [[11, 4]], []], []])
    check('null receiver', solve([[[10, None, 3]], {}, 1, 3]), [[[], [[10, 3]], []], []])
    check('unmapped', solve([[[10, 7, 3]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 3], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[11, 3], [10, 4]], []], []])
    check('duplicate rows', solve([[[10, 1, 3], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[10, 3], [10, 3]], []], []])
    check('mapped zero', solve([[[10, 0, 3]], {'0': 1}, 0, 2]), [[[], [[10, 3]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 4:
    check('independent receivers', solve([[[10, 1, 4], [11, 2, 5]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 4]], [[11, 5]], []], []])
    check('null receiver', solve([[[10, None, 4]], {}, 1, 3]), [[[], [[10, 4]], []], []])
    check('unmapped', solve([[[10, 7, 4]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 4], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[11, 4], [10, 5]], []], []])
    check('duplicate rows', solve([[[10, 1, 4], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[10, 4], [10, 4]], []], []])
    check('mapped zero', solve([[[10, 0, 4]], {'0': 1}, 0, 2]), [[[], [[10, 4]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 5:
    check('independent receivers', solve([[[10, 1, 5], [11, 2, 6]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 5]], [[11, 6]], []], []])
    check('null receiver', solve([[[10, None, 5]], {}, 1, 3]), [[[], [[10, 5]], []], []])
    check('unmapped', solve([[[10, 7, 5]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 5], [10, 1, 6]], {'1': 0}, 1, 2]), [[[[11, 5], [10, 6]], []], []])
    check('duplicate rows', solve([[[10, 1, 5], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[10, 5], [10, 5]], []], []])
    check('mapped zero', solve([[[10, 0, 5]], {'0': 1}, 0, 2]), [[[], [[10, 5]]], []])
    check('empty relation', solve([[], {}, 0, 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:
        rows,mapping,null_partition,count=d
        receivers=[[] for _ in range(count)]; rejected=[]
        for ident,key,payload in rows:
            if key is None: target=null_partition
            elif str(payload) in mapping: target=mapping[str(payload)]
            else: rejected.append([ident,'UNMAPPED']); continue
            receivers[target].append([ident,payload])
        return [receivers,rejected]
    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('independent receivers', solve([[[10, 1, 1], [11, 2, 2]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 1]], [[11, 2]], []], []])
    check('null receiver', solve([[[10, None, 1]], {}, 1, 3]), [[[], [[10, 1]], []], []])
    check('unmapped', solve([[[10, 7, 1]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 1], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[11, 1], [10, 2]], []], []])
    check('duplicate rows', solve([[[10, 1, 1], [10, 1, 1]], {'1': 0}, 1, 2]), [[[[10, 1], [10, 1]], []], []])
    check('mapped zero', solve([[[10, 0, 1]], {'0': 1}, 0, 2]), [[[], [[10, 1]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 2:
    check('independent receivers', solve([[[10, 1, 2], [11, 2, 3]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 2]], [[11, 3]], []], []])
    check('null receiver', solve([[[10, None, 2]], {}, 1, 3]), [[[], [[10, 2]], []], []])
    check('unmapped', solve([[[10, 7, 2]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 2], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[11, 2], [10, 3]], []], []])
    check('duplicate rows', solve([[[10, 1, 2], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[10, 2], [10, 2]], []], []])
    check('mapped zero', solve([[[10, 0, 2]], {'0': 1}, 0, 2]), [[[], [[10, 2]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 3:
    check('independent receivers', solve([[[10, 1, 3], [11, 2, 4]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 3]], [[11, 4]], []], []])
    check('null receiver', solve([[[10, None, 3]], {}, 1, 3]), [[[], [[10, 3]], []], []])
    check('unmapped', solve([[[10, 7, 3]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 3], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[11, 3], [10, 4]], []], []])
    check('duplicate rows', solve([[[10, 1, 3], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[10, 3], [10, 3]], []], []])
    check('mapped zero', solve([[[10, 0, 3]], {'0': 1}, 0, 2]), [[[], [[10, 3]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 4:
    check('independent receivers', solve([[[10, 1, 4], [11, 2, 5]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 4]], [[11, 5]], []], []])
    check('null receiver', solve([[[10, None, 4]], {}, 1, 3]), [[[], [[10, 4]], []], []])
    check('unmapped', solve([[[10, 7, 4]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 4], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[11, 4], [10, 5]], []], []])
    check('duplicate rows', solve([[[10, 1, 4], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[10, 4], [10, 4]], []], []])
    check('mapped zero', solve([[[10, 0, 4]], {'0': 1}, 0, 2]), [[[], [[10, 4]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 5:
    check('independent receivers', solve([[[10, 1, 5], [11, 2, 6]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 5]], [[11, 6]], []], []])
    check('null receiver', solve([[[10, None, 5]], {}, 1, 3]), [[[], [[10, 5]], []], []])
    check('unmapped', solve([[[10, 7, 5]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 5], [10, 1, 6]], {'1': 0}, 1, 2]), [[[[11, 5], [10, 6]], []], []])
    check('duplicate rows', solve([[[10, 1, 5], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[10, 5], [10, 5]], []], []])
    check('mapped zero', solve([[[10, 0, 5]], {'0': 1}, 0, 2]), [[[], [[10, 5]]], []])
    check('empty relation', solve([[], {}, 0, 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:
Exchange looks up row identity instead of the routing key.

Route [id,key,payload] rows into fixed receiver partitions using a supplied key-to-partition table. Null keys use the explicit null partition; unmapped non-null keys produce UNMAPPED side output. Preserve source order within each receiver, retain empty receivers, and preserve repeated rows.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        rows,mapping,null_partition,count=d
        receivers=[[] for _ in range(count)]; rejected=[]
        for ident,key,payload in rows:
            if key is None: target=null_partition
            elif str(key) in mapping: target=mapping[str(key)]
            else: target=0
            receivers[target].append([ident,payload])
        return [receivers,rejected]
    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('independent receivers', solve([[[10, 1, 1], [11, 2, 2]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 1]], [[11, 2]], []], []])
    check('null receiver', solve([[[10, None, 1]], {}, 1, 3]), [[[], [[10, 1]], []], []])
    check('unmapped', solve([[[10, 7, 1]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 1], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[11, 1], [10, 2]], []], []])
    check('duplicate rows', solve([[[10, 1, 1], [10, 1, 1]], {'1': 0}, 1, 2]), [[[[10, 1], [10, 1]], []], []])
    check('mapped zero', solve([[[10, 0, 1]], {'0': 1}, 0, 2]), [[[], [[10, 1]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 2:
    check('independent receivers', solve([[[10, 1, 2], [11, 2, 3]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 2]], [[11, 3]], []], []])
    check('null receiver', solve([[[10, None, 2]], {}, 1, 3]), [[[], [[10, 2]], []], []])
    check('unmapped', solve([[[10, 7, 2]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 2], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[11, 2], [10, 3]], []], []])
    check('duplicate rows', solve([[[10, 1, 2], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[10, 2], [10, 2]], []], []])
    check('mapped zero', solve([[[10, 0, 2]], {'0': 1}, 0, 2]), [[[], [[10, 2]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 3:
    check('independent receivers', solve([[[10, 1, 3], [11, 2, 4]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 3]], [[11, 4]], []], []])
    check('null receiver', solve([[[10, None, 3]], {}, 1, 3]), [[[], [[10, 3]], []], []])
    check('unmapped', solve([[[10, 7, 3]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 3], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[11, 3], [10, 4]], []], []])
    check('duplicate rows', solve([[[10, 1, 3], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[10, 3], [10, 3]], []], []])
    check('mapped zero', solve([[[10, 0, 3]], {'0': 1}, 0, 2]), [[[], [[10, 3]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 4:
    check('independent receivers', solve([[[10, 1, 4], [11, 2, 5]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 4]], [[11, 5]], []], []])
    check('null receiver', solve([[[10, None, 4]], {}, 1, 3]), [[[], [[10, 4]], []], []])
    check('unmapped', solve([[[10, 7, 4]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 4], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[11, 4], [10, 5]], []], []])
    check('duplicate rows', solve([[[10, 1, 4], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[10, 4], [10, 4]], []], []])
    check('mapped zero', solve([[[10, 0, 4]], {'0': 1}, 0, 2]), [[[], [[10, 4]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 5:
    check('independent receivers', solve([[[10, 1, 5], [11, 2, 6]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 5]], [[11, 6]], []], []])
    check('null receiver', solve([[[10, None, 5]], {}, 1, 3]), [[[], [[10, 5]], []], []])
    check('unmapped', solve([[[10, 7, 5]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 5], [10, 1, 6]], {'1': 0}, 1, 2]), [[[[11, 5], [10, 6]], []], []])
    check('duplicate rows', solve([[[10, 1, 5], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[10, 5], [10, 5]], []], []])
    check('mapped zero', solve([[[10, 0, 5]], {'0': 1}, 0, 2]), [[[], [[10, 5]]], []])
    check('empty relation', solve([[], {}, 0, 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:
        rows,mapping,null_partition,count=d
        receivers=[[] for _ in range(count)]; rejected=[]
        for ident,key,payload in rows:
            if key is None: target=null_partition
            elif str(key) in mapping: target=mapping[str(key)]
            else: target=null_partition
            receivers[target].append([ident,payload])
        return [receivers,rejected]
    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('independent receivers', solve([[[10, 1, 1], [11, 2, 2]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 1]], [[11, 2]], []], []])
    check('null receiver', solve([[[10, None, 1]], {}, 1, 3]), [[[], [[10, 1]], []], []])
    check('unmapped', solve([[[10, 7, 1]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 1], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[11, 1], [10, 2]], []], []])
    check('duplicate rows', solve([[[10, 1, 1], [10, 1, 1]], {'1': 0}, 1, 2]), [[[[10, 1], [10, 1]], []], []])
    check('mapped zero', solve([[[10, 0, 1]], {'0': 1}, 0, 2]), [[[], [[10, 1]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 2:
    check('independent receivers', solve([[[10, 1, 2], [11, 2, 3]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 2]], [[11, 3]], []], []])
    check('null receiver', solve([[[10, None, 2]], {}, 1, 3]), [[[], [[10, 2]], []], []])
    check('unmapped', solve([[[10, 7, 2]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 2], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[11, 2], [10, 3]], []], []])
    check('duplicate rows', solve([[[10, 1, 2], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[10, 2], [10, 2]], []], []])
    check('mapped zero', solve([[[10, 0, 2]], {'0': 1}, 0, 2]), [[[], [[10, 2]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 3:
    check('independent receivers', solve([[[10, 1, 3], [11, 2, 4]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 3]], [[11, 4]], []], []])
    check('null receiver', solve([[[10, None, 3]], {}, 1, 3]), [[[], [[10, 3]], []], []])
    check('unmapped', solve([[[10, 7, 3]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 3], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[11, 3], [10, 4]], []], []])
    check('duplicate rows', solve([[[10, 1, 3], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[10, 3], [10, 3]], []], []])
    check('mapped zero', solve([[[10, 0, 3]], {'0': 1}, 0, 2]), [[[], [[10, 3]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 4:
    check('independent receivers', solve([[[10, 1, 4], [11, 2, 5]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 4]], [[11, 5]], []], []])
    check('null receiver', solve([[[10, None, 4]], {}, 1, 3]), [[[], [[10, 4]], []], []])
    check('unmapped', solve([[[10, 7, 4]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 4], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[11, 4], [10, 5]], []], []])
    check('duplicate rows', solve([[[10, 1, 4], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[10, 4], [10, 4]], []], []])
    check('mapped zero', solve([[[10, 0, 4]], {'0': 1}, 0, 2]), [[[], [[10, 4]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 5:
    check('independent receivers', solve([[[10, 1, 5], [11, 2, 6]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 5]], [[11, 6]], []], []])
    check('null receiver', solve([[[10, None, 5]], {}, 1, 3]), [[[], [[10, 5]], []], []])
    check('unmapped', solve([[[10, 7, 5]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 5], [10, 1, 6]], {'1': 0}, 1, 2]), [[[[11, 5], [10, 6]], []], []])
    check('duplicate rows', solve([[[10, 1, 5], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[10, 5], [10, 5]], []], []])
    check('mapped zero', solve([[[10, 0, 5]], {'0': 1}, 0, 2]), [[[], [[10, 5]]], []])
    check('empty relation', solve([[], {}, 0, 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:
Exchange silently routes unmapped keys to receiver zero.

Route [id,key,payload] rows into fixed receiver partitions using a supplied key-to-partition table. Null keys use the explicit null partition; unmapped non-null keys produce UNMAPPED side output. Preserve source order within each receiver, retain empty receivers, and preserve repeated rows.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        rows,mapping,null_partition,count=d
        receivers=[[] for _ in range(count)]; rejected=[]
        for ident,key,payload in rows:
            if key is None: target=null_partition
            elif str(key) in mapping: target=mapping[str(key)]
            else: rejected.append([ident,'UNMAPPED']); continue
            receivers[target].append([key,payload])
        return [receivers,rejected]
    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('independent receivers', solve([[[10, 1, 1], [11, 2, 2]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 1]], [[11, 2]], []], []])
    check('null receiver', solve([[[10, None, 1]], {}, 1, 3]), [[[], [[10, 1]], []], []])
    check('unmapped', solve([[[10, 7, 1]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 1], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[11, 1], [10, 2]], []], []])
    check('duplicate rows', solve([[[10, 1, 1], [10, 1, 1]], {'1': 0}, 1, 2]), [[[[10, 1], [10, 1]], []], []])
    check('mapped zero', solve([[[10, 0, 1]], {'0': 1}, 0, 2]), [[[], [[10, 1]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 2:
    check('independent receivers', solve([[[10, 1, 2], [11, 2, 3]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 2]], [[11, 3]], []], []])
    check('null receiver', solve([[[10, None, 2]], {}, 1, 3]), [[[], [[10, 2]], []], []])
    check('unmapped', solve([[[10, 7, 2]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 2], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[11, 2], [10, 3]], []], []])
    check('duplicate rows', solve([[[10, 1, 2], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[10, 2], [10, 2]], []], []])
    check('mapped zero', solve([[[10, 0, 2]], {'0': 1}, 0, 2]), [[[], [[10, 2]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 3:
    check('independent receivers', solve([[[10, 1, 3], [11, 2, 4]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 3]], [[11, 4]], []], []])
    check('null receiver', solve([[[10, None, 3]], {}, 1, 3]), [[[], [[10, 3]], []], []])
    check('unmapped', solve([[[10, 7, 3]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 3], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[11, 3], [10, 4]], []], []])
    check('duplicate rows', solve([[[10, 1, 3], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[10, 3], [10, 3]], []], []])
    check('mapped zero', solve([[[10, 0, 3]], {'0': 1}, 0, 2]), [[[], [[10, 3]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 4:
    check('independent receivers', solve([[[10, 1, 4], [11, 2, 5]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 4]], [[11, 5]], []], []])
    check('null receiver', solve([[[10, None, 4]], {}, 1, 3]), [[[], [[10, 4]], []], []])
    check('unmapped', solve([[[10, 7, 4]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 4], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[11, 4], [10, 5]], []], []])
    check('duplicate rows', solve([[[10, 1, 4], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[10, 4], [10, 4]], []], []])
    check('mapped zero', solve([[[10, 0, 4]], {'0': 1}, 0, 2]), [[[], [[10, 4]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 5:
    check('independent receivers', solve([[[10, 1, 5], [11, 2, 6]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 5]], [[11, 6]], []], []])
    check('null receiver', solve([[[10, None, 5]], {}, 1, 3]), [[[], [[10, 5]], []], []])
    check('unmapped', solve([[[10, 7, 5]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 5], [10, 1, 6]], {'1': 0}, 1, 2]), [[[[11, 5], [10, 6]], []], []])
    check('duplicate rows', solve([[[10, 1, 5], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[10, 5], [10, 5]], []], []])
    check('mapped zero', solve([[[10, 0, 5]], {'0': 1}, 0, 2]), [[[], [[10, 5]]], []])
    check('empty relation', solve([[], {}, 0, 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:
        rows,mapping,null_partition,count=d
        receivers=[[] for _ in range(count)]; rejected=[]
        for ident,key,payload in rows:
            if key is None: target=null_partition
            elif str(key) in mapping: target=mapping[str(key)]
            else: rejected.append([ident,'UNMAPPED']); continue
            receivers[target].append([payload,ident])
        return [receivers,rejected]
    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('independent receivers', solve([[[10, 1, 1], [11, 2, 2]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 1]], [[11, 2]], []], []])
    check('null receiver', solve([[[10, None, 1]], {}, 1, 3]), [[[], [[10, 1]], []], []])
    check('unmapped', solve([[[10, 7, 1]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 1], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[11, 1], [10, 2]], []], []])
    check('duplicate rows', solve([[[10, 1, 1], [10, 1, 1]], {'1': 0}, 1, 2]), [[[[10, 1], [10, 1]], []], []])
    check('mapped zero', solve([[[10, 0, 1]], {'0': 1}, 0, 2]), [[[], [[10, 1]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 2:
    check('independent receivers', solve([[[10, 1, 2], [11, 2, 3]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 2]], [[11, 3]], []], []])
    check('null receiver', solve([[[10, None, 2]], {}, 1, 3]), [[[], [[10, 2]], []], []])
    check('unmapped', solve([[[10, 7, 2]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 2], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[11, 2], [10, 3]], []], []])
    check('duplicate rows', solve([[[10, 1, 2], [10, 1, 2]], {'1': 0}, 1, 2]), [[[[10, 2], [10, 2]], []], []])
    check('mapped zero', solve([[[10, 0, 2]], {'0': 1}, 0, 2]), [[[], [[10, 2]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 3:
    check('independent receivers', solve([[[10, 1, 3], [11, 2, 4]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 3]], [[11, 4]], []], []])
    check('null receiver', solve([[[10, None, 3]], {}, 1, 3]), [[[], [[10, 3]], []], []])
    check('unmapped', solve([[[10, 7, 3]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 3], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[11, 3], [10, 4]], []], []])
    check('duplicate rows', solve([[[10, 1, 3], [10, 1, 3]], {'1': 0}, 1, 2]), [[[[10, 3], [10, 3]], []], []])
    check('mapped zero', solve([[[10, 0, 3]], {'0': 1}, 0, 2]), [[[], [[10, 3]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 4:
    check('independent receivers', solve([[[10, 1, 4], [11, 2, 5]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 4]], [[11, 5]], []], []])
    check('null receiver', solve([[[10, None, 4]], {}, 1, 3]), [[[], [[10, 4]], []], []])
    check('unmapped', solve([[[10, 7, 4]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 4], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[11, 4], [10, 5]], []], []])
    check('duplicate rows', solve([[[10, 1, 4], [10, 1, 4]], {'1': 0}, 1, 2]), [[[[10, 4], [10, 4]], []], []])
    check('mapped zero', solve([[[10, 0, 4]], {'0': 1}, 0, 2]), [[[], [[10, 4]]], []])
    check('empty relation', solve([[], {}, 0, 2]), [[[], []], []])
elif N == 5:
    check('independent receivers', solve([[[10, 1, 5], [11, 2, 6]], {'1': 0, '2': 1}, 1, 3]), [[[[10, 5]], [[11, 6]], []], []])
    check('null receiver', solve([[[10, None, 5]], {}, 1, 3]), [[[], [[10, 5]], []], []])
    check('unmapped', solve([[[10, 7, 5]], {'1': 0}, 1, 2]), [[[], []], [[10, 'UNMAPPED']]])
    check('same receiver order', solve([[[11, 1, 5], [10, 1, 6]], {'1': 0}, 1, 2]), [[[[11, 5], [10, 6]], []], []])
    check('duplicate rows', solve([[[10, 1, 5], [10, 1, 5]], {'1': 0}, 1, 2]), [[[[10, 5], [10, 5]], []], []])
    check('mapped zero', solve([[[10, 0, 5]], {'0': 1}, 0, 2]), [[[], [[10, 5]]], []])
    check('empty relation', solve([[], {}, 0, 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:
Exchange drops row identity while transferring payload.

Route [id,key,payload] rows into fixed receiver partitions using a supplied key-to-partition table. Null keys use the explicit null partition; unmapped non-null keys produce UNMAPPED side output. Preserve source order within each receiver, retain empty receivers, and preserve repeated rows.

split: open-access