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

N = 1
observations = []
def solve(cases):
    def run(c):
        generations={}; cache={}; out=[]
        for kind,device,a,b in c:
            if kind=='layout':
                generations[device]=a
                cache={k:v for k,v in cache.items() if k[0]!=device}
            elif kind=='map' and device in generations:
                cache[(a,device)]=b
            elif kind=='lookup' and device in generations:
                out.append(cache.get((device,a),a))
            elif kind=='disconnect':
                generations.pop(device,None)
                cache={k:v for k,v in cache.items() if k[0]!=device}
        return [out,sorted([[k,v] for k,v in generations.items()]),sorted([[d,k,v] for (d,k),v in cache.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layout-cache scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('layout-cache scenario 1', solve([[['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[[], [], []]] * N)
check('layout-cache scenario 2', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] * N)
check('layout-cache scenario 3', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'a', 'KeyA', 'y'], ['lookup', 'a', 'KeyA', '']]] * N), [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] * N)
check('layout-cache scenario 4', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['layout', 'a', 2, ''], ['lookup', 'a', 'KeyA', '']]] * N), [[['KeyA'], [['a', 2]], []]] * N)
check('layout-cache scenario 5', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['layout', 'a', 3, '']]] * N), [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] * N)
check('layout-cache scenario 6', solve([[['layout', 'a', 1, ''], ['lookup', 'b', 'KeyA', '']]] * N), [[[], [['a', 1]], []]] * N)
check('layout-cache scenario 7', solve([[['layout', 'a', 1, ''], ['lookup', 'a', 'Unknown', 'fallback']]] * N), [[['Unknown'], [['a', 1]], []]] * N)
check('layout-cache scenario 8', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['disconnect', 'a', '', '']]] * N), [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        generations={}; cache={}; out=[]
        for kind,device,a,b in c:
            if kind=='layout':
                generations[device]=a
                cache={k:v for k,v in cache.items() if k[0]!=device}
            elif kind=='map' and device in generations:
                cache[(device,b)]=a
            elif kind=='lookup' and device in generations:
                out.append(cache.get((device,a),a))
            elif kind=='disconnect':
                generations.pop(device,None)
                cache={k:v for k,v in cache.items() if k[0]!=device}
        return [out,sorted([[k,v] for k,v in generations.items()]),sorted([[d,k,v] for (d,k),v in cache.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layout-cache scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('layout-cache scenario 1', solve([[['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[[], [], []]] * N)
check('layout-cache scenario 2', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] * N)
check('layout-cache scenario 3', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'a', 'KeyA', 'y'], ['lookup', 'a', 'KeyA', '']]] * N), [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] * N)
check('layout-cache scenario 4', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['layout', 'a', 2, ''], ['lookup', 'a', 'KeyA', '']]] * N), [[['KeyA'], [['a', 2]], []]] * N)
check('layout-cache scenario 5', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['layout', 'a', 3, '']]] * N), [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] * N)
check('layout-cache scenario 6', solve([[['layout', 'a', 1, ''], ['lookup', 'b', 'KeyA', '']]] * N), [[[], [['a', 1]], []]] * N)
check('layout-cache scenario 7', solve([[['layout', 'a', 1, ''], ['lookup', 'a', 'Unknown', 'fallback']]] * N), [[['Unknown'], [['a', 1]], []]] * N)
check('layout-cache scenario 8', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['disconnect', 'a', '', '']]] * N), [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the map key rule and produces incorrect keyboard state or command output.

Events [kind,device,a,b]. layout replaces device generation a and clears cached labels; map caches physical code a to label b in current generation; lookup emits cached label or code a as fallback. Disconnect removes generation and cache. Maps and lookups before layout are ignored. Return emitted labels, generations and cached [device,code,label] rows. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        generations={}; cache={}; out=[]
        for kind,device,a,b in c:
            if kind=='layout':
                generations[device]=a
                cache={k:v for k,v in cache.items() if k[0]!=device}
            elif kind=='map' and device in generations:
                cache.setdefault((device,a),b)
            elif kind=='lookup' and device in generations:
                out.append(cache.get((device,a),a))
            elif kind=='disconnect':
                generations.pop(device,None)
                cache={k:v for k,v in cache.items() if k[0]!=device}
        return [out,sorted([[k,v] for k,v in generations.items()]),sorted([[d,k,v] for (d,k),v in cache.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layout-cache scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('layout-cache scenario 1', solve([[['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[[], [], []]] * N)
check('layout-cache scenario 2', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] * N)
check('layout-cache scenario 3', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'a', 'KeyA', 'y'], ['lookup', 'a', 'KeyA', '']]] * N), [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] * N)
check('layout-cache scenario 4', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['layout', 'a', 2, ''], ['lookup', 'a', 'KeyA', '']]] * N), [[['KeyA'], [['a', 2]], []]] * N)
check('layout-cache scenario 5', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['layout', 'a', 3, '']]] * N), [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] * N)
check('layout-cache scenario 6', solve([[['layout', 'a', 1, ''], ['lookup', 'b', 'KeyA', '']]] * N), [[[], [['a', 1]], []]] * N)
check('layout-cache scenario 7', solve([[['layout', 'a', 1, ''], ['lookup', 'a', 'Unknown', 'fallback']]] * N), [[['Unknown'], [['a', 1]], []]] * N)
check('layout-cache scenario 8', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['disconnect', 'a', '', '']]] * N), [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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(cases):
    def run(c):
        generations={}; cache={}; out=[]
        for kind,device,a,b in c:
            if kind=='layout':
                generations[device]=a
                cache={k:v for k,v in cache.items() if k[0]!=device}
            elif kind=='map' and device in generations:
                cache[(device,a)]=a
            elif kind=='lookup' and device in generations:
                out.append(cache.get((device,a),a))
            elif kind=='disconnect':
                generations.pop(device,None)
                cache={k:v for k,v in cache.items() if k[0]!=device}
        return [out,sorted([[k,v] for k,v in generations.items()]),sorted([[d,k,v] for (d,k),v in cache.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layout-cache scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('layout-cache scenario 1', solve([[['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[[], [], []]] * N)
check('layout-cache scenario 2', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] * N)
check('layout-cache scenario 3', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'a', 'KeyA', 'y'], ['lookup', 'a', 'KeyA', '']]] * N), [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] * N)
check('layout-cache scenario 4', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['layout', 'a', 2, ''], ['lookup', 'a', 'KeyA', '']]] * N), [[['KeyA'], [['a', 2]], []]] * N)
check('layout-cache scenario 5', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['layout', 'a', 3, '']]] * N), [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] * N)
check('layout-cache scenario 6', solve([[['layout', 'a', 1, ''], ['lookup', 'b', 'KeyA', '']]] * N), [[[], [['a', 1]], []]] * N)
check('layout-cache scenario 7', solve([[['layout', 'a', 1, ''], ['lookup', 'a', 'Unknown', 'fallback']]] * N), [[['Unknown'], [['a', 1]], []]] * N)
check('layout-cache scenario 8', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['disconnect', 'a', '', '']]] * N), [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the map replace rule and produces incorrect keyboard state or command output.

Events [kind,device,a,b]. layout replaces device generation a and clears cached labels; map caches physical code a to label b in current generation; lookup emits cached label or code a as fallback. Disconnect removes generation and cache. Maps and lookups before layout are ignored. Return emitted labels, generations and cached [device,code,label] rows. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        generations={}; cache={}; out=[]
        for kind,device,a,b in c:
            if kind=='layout':
                generations[device]=a
                cache={k:v for k,v in cache.items() if k[0]!=device}
            elif kind=='map' and device in generations:
                cache[(device,a)]=b
            elif kind=='lookup':
                out.append(cache.get((device,a),a))
            elif kind=='disconnect':
                generations.pop(device,None)
                cache={k:v for k,v in cache.items() if k[0]!=device}
        return [out,sorted([[k,v] for k,v in generations.items()]),sorted([[d,k,v] for (d,k),v in cache.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layout-cache scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('layout-cache scenario 1', solve([[['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[[], [], []]] * N)
check('layout-cache scenario 2', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] * N)
check('layout-cache scenario 3', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'a', 'KeyA', 'y'], ['lookup', 'a', 'KeyA', '']]] * N), [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] * N)
check('layout-cache scenario 4', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['layout', 'a', 2, ''], ['lookup', 'a', 'KeyA', '']]] * N), [[['KeyA'], [['a', 2]], []]] * N)
check('layout-cache scenario 5', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['layout', 'a', 3, '']]] * N), [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] * N)
check('layout-cache scenario 6', solve([[['layout', 'a', 1, ''], ['lookup', 'b', 'KeyA', '']]] * N), [[[], [['a', 1]], []]] * N)
check('layout-cache scenario 7', solve([[['layout', 'a', 1, ''], ['lookup', 'a', 'Unknown', 'fallback']]] * N), [[['Unknown'], [['a', 1]], []]] * N)
check('layout-cache scenario 8', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['disconnect', 'a', '', '']]] * N), [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        generations={}; cache={}; out=[]
        for kind,device,a,b in c:
            if kind=='layout':
                generations[device]=a
                cache={k:v for k,v in cache.items() if k[0]!=device}
            elif kind=='map' and device in generations:
                cache[(device,a)]=b
            elif kind=='lookup' and bool(generations):
                out.append(cache.get((device,a),a))
            elif kind=='disconnect':
                generations.pop(device,None)
                cache={k:v for k,v in cache.items() if k[0]!=device}
        return [out,sorted([[k,v] for k,v in generations.items()]),sorted([[d,k,v] for (d,k),v in cache.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layout-cache scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('layout-cache scenario 1', solve([[['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[[], [], []]] * N)
check('layout-cache scenario 2', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] * N)
check('layout-cache scenario 3', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'a', 'KeyA', 'y'], ['lookup', 'a', 'KeyA', '']]] * N), [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] * N)
check('layout-cache scenario 4', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['layout', 'a', 2, ''], ['lookup', 'a', 'KeyA', '']]] * N), [[['KeyA'], [['a', 2]], []]] * N)
check('layout-cache scenario 5', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['layout', 'a', 3, '']]] * N), [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] * N)
check('layout-cache scenario 6', solve([[['layout', 'a', 1, ''], ['lookup', 'b', 'KeyA', '']]] * N), [[[], [['a', 1]], []]] * N)
check('layout-cache scenario 7', solve([[['layout', 'a', 1, ''], ['lookup', 'a', 'Unknown', 'fallback']]] * N), [[['Unknown'], [['a', 1]], []]] * N)
check('layout-cache scenario 8', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['disconnect', 'a', '', '']]] * N), [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the lookup lifecycle rule and produces incorrect keyboard state or command output.

Events [kind,device,a,b]. layout replaces device generation a and clears cached labels; map caches physical code a to label b in current generation; lookup emits cached label or code a as fallback. Disconnect removes generation and cache. Maps and lookups before layout are ignored. Return emitted labels, generations and cached [device,code,label] rows. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        generations={}; cache={}; out=[]
        for kind,device,a,b in c:
            if kind=='layout':
                generations[device]=a
                cache={k:v for k,v in cache.items() if k[0]!=device}
            elif kind=='map' and device in generations:
                cache[(device,a)]=b
            elif kind=='lookup' and device in generations:
                out.append(cache.get((a,device),a))
            elif kind=='disconnect':
                generations.pop(device,None)
                cache={k:v for k,v in cache.items() if k[0]!=device}
        return [out,sorted([[k,v] for k,v in generations.items()]),sorted([[d,k,v] for (d,k),v in cache.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layout-cache scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('layout-cache scenario 1', solve([[['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[[], [], []]] * N)
check('layout-cache scenario 2', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] * N)
check('layout-cache scenario 3', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'a', 'KeyA', 'y'], ['lookup', 'a', 'KeyA', '']]] * N), [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] * N)
check('layout-cache scenario 4', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['layout', 'a', 2, ''], ['lookup', 'a', 'KeyA', '']]] * N), [[['KeyA'], [['a', 2]], []]] * N)
check('layout-cache scenario 5', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['layout', 'a', 3, '']]] * N), [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] * N)
check('layout-cache scenario 6', solve([[['layout', 'a', 1, ''], ['lookup', 'b', 'KeyA', '']]] * N), [[[], [['a', 1]], []]] * N)
check('layout-cache scenario 7', solve([[['layout', 'a', 1, ''], ['lookup', 'a', 'Unknown', 'fallback']]] * N), [[['Unknown'], [['a', 1]], []]] * N)
check('layout-cache scenario 8', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['disconnect', 'a', '', '']]] * N), [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        generations={}; cache={}; out=[]
        for kind,device,a,b in c:
            if kind=='layout':
                generations[device]=a
                cache={k:v for k,v in cache.items() if k[0]!=device}
            elif kind=='map' and device in generations:
                cache[(device,a)]=b
            elif kind=='lookup' and device in generations:
                out.append(cache.get((device,b),a))
            elif kind=='disconnect':
                generations.pop(device,None)
                cache={k:v for k,v in cache.items() if k[0]!=device}
        return [out,sorted([[k,v] for k,v in generations.items()]),sorted([[d,k,v] for (d,k),v in cache.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layout-cache scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('layout-cache scenario 1', solve([[['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[[], [], []]] * N)
check('layout-cache scenario 2', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] * N)
check('layout-cache scenario 3', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'a', 'KeyA', 'y'], ['lookup', 'a', 'KeyA', '']]] * N), [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] * N)
check('layout-cache scenario 4', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['layout', 'a', 2, ''], ['lookup', 'a', 'KeyA', '']]] * N), [[['KeyA'], [['a', 2]], []]] * N)
check('layout-cache scenario 5', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['layout', 'a', 3, '']]] * N), [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] * N)
check('layout-cache scenario 6', solve([[['layout', 'a', 1, ''], ['lookup', 'b', 'KeyA', '']]] * N), [[[], [['a', 1]], []]] * N)
check('layout-cache scenario 7', solve([[['layout', 'a', 1, ''], ['lookup', 'a', 'Unknown', 'fallback']]] * N), [[['Unknown'], [['a', 1]], []]] * N)
check('layout-cache scenario 8', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['disconnect', 'a', '', '']]] * N), [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the lookup key rule and produces incorrect keyboard state or command output.

Events [kind,device,a,b]. layout replaces device generation a and clears cached labels; map caches physical code a to label b in current generation; lookup emits cached label or code a as fallback. Disconnect removes generation and cache. Maps and lookups before layout are ignored. Return emitted labels, generations and cached [device,code,label] rows. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        generations={}; cache={}; out=[]
        for kind,device,a,b in c:
            if kind=='layout':
                generations[device]=a
                cache={k:v for k,v in cache.items() if k[0]!=device}
            elif kind=='map' and device in generations:
                cache[(device,a)]=b
            elif kind=='lookup' and device in generations:
                out.append(cache.get((device,a),None))
            elif kind=='disconnect':
                generations.pop(device,None)
                cache={k:v for k,v in cache.items() if k[0]!=device}
        return [out,sorted([[k,v] for k,v in generations.items()]),sorted([[d,k,v] for (d,k),v in cache.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layout-cache scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('layout-cache scenario 1', solve([[['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[[], [], []]] * N)
check('layout-cache scenario 2', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] * N)
check('layout-cache scenario 3', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'a', 'KeyA', 'y'], ['lookup', 'a', 'KeyA', '']]] * N), [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] * N)
check('layout-cache scenario 4', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['layout', 'a', 2, ''], ['lookup', 'a', 'KeyA', '']]] * N), [[['KeyA'], [['a', 2]], []]] * N)
check('layout-cache scenario 5', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['layout', 'a', 3, '']]] * N), [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] * N)
check('layout-cache scenario 6', solve([[['layout', 'a', 1, ''], ['lookup', 'b', 'KeyA', '']]] * N), [[[], [['a', 1]], []]] * N)
check('layout-cache scenario 7', solve([[['layout', 'a', 1, ''], ['lookup', 'a', 'Unknown', 'fallback']]] * N), [[['Unknown'], [['a', 1]], []]] * N)
check('layout-cache scenario 8', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['disconnect', 'a', '', '']]] * N), [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        generations={}; cache={}; out=[]
        for kind,device,a,b in c:
            if kind=='layout':
                generations[device]=a
                cache={k:v for k,v in cache.items() if k[0]!=device}
            elif kind=='map' and device in generations:
                cache[(device,a)]=b
            elif kind=='lookup' and device in generations:
                out.append(cache.get((device,a),b))
            elif kind=='disconnect':
                generations.pop(device,None)
                cache={k:v for k,v in cache.items() if k[0]!=device}
        return [out,sorted([[k,v] for k,v in generations.items()]),sorted([[d,k,v] for (d,k),v in cache.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layout-cache scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('layout-cache scenario 1', solve([[['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[[], [], []]] * N)
check('layout-cache scenario 2', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] * N)
check('layout-cache scenario 3', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'a', 'KeyA', 'y'], ['lookup', 'a', 'KeyA', '']]] * N), [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] * N)
check('layout-cache scenario 4', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['layout', 'a', 2, ''], ['lookup', 'a', 'KeyA', '']]] * N), [[['KeyA'], [['a', 2]], []]] * N)
check('layout-cache scenario 5', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['layout', 'a', 3, '']]] * N), [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] * N)
check('layout-cache scenario 6', solve([[['layout', 'a', 1, ''], ['lookup', 'b', 'KeyA', '']]] * N), [[[], [['a', 1]], []]] * N)
check('layout-cache scenario 7', solve([[['layout', 'a', 1, ''], ['lookup', 'a', 'Unknown', 'fallback']]] * N), [[['Unknown'], [['a', 1]], []]] * N)
check('layout-cache scenario 8', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['disconnect', 'a', '', '']]] * N), [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the lookup fallback rule and produces incorrect keyboard state or command output.

Events [kind,device,a,b]. layout replaces device generation a and clears cached labels; map caches physical code a to label b in current generation; lookup emits cached label or code a as fallback. Disconnect removes generation and cache. Maps and lookups before layout are ignored. Return emitted labels, generations and cached [device,code,label] rows. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        generations={}; cache={}; out=[]
        for kind,device,a,b in c:
            if kind=='layout':
                generations[device]=a
                cache={k:v for k,v in cache.items() if k[0]!=device}
            elif kind=='map' and device in generations:
                cache[(device,a)]=b
            elif kind=='lookup' and device in generations:
                out.append(cache.get((device,a),a))
            elif kind=='disconnect':
                generations.clear()
                cache={k:v for k,v in cache.items() if k[0]!=device}
        return [out,sorted([[k,v] for k,v in generations.items()]),sorted([[d,k,v] for (d,k),v in cache.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layout-cache scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('layout-cache scenario 1', solve([[['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[[], [], []]] * N)
check('layout-cache scenario 2', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] * N)
check('layout-cache scenario 3', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'a', 'KeyA', 'y'], ['lookup', 'a', 'KeyA', '']]] * N), [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] * N)
check('layout-cache scenario 4', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['layout', 'a', 2, ''], ['lookup', 'a', 'KeyA', '']]] * N), [[['KeyA'], [['a', 2]], []]] * N)
check('layout-cache scenario 5', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['layout', 'a', 3, '']]] * N), [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] * N)
check('layout-cache scenario 6', solve([[['layout', 'a', 1, ''], ['lookup', 'b', 'KeyA', '']]] * N), [[[], [['a', 1]], []]] * N)
check('layout-cache scenario 7', solve([[['layout', 'a', 1, ''], ['lookup', 'a', 'Unknown', 'fallback']]] * N), [[['Unknown'], [['a', 1]], []]] * N)
check('layout-cache scenario 8', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['disconnect', 'a', '', '']]] * N), [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        generations={}; cache={}; out=[]
        for kind,device,a,b in c:
            if kind=='layout':
                generations[device]=a
                cache={k:v for k,v in cache.items() if k[0]!=device}
            elif kind=='map' and device in generations:
                cache[(device,a)]=b
            elif kind=='lookup' and device in generations:
                out.append(cache.get((device,a),a))
            elif kind=='disconnect':
                generations.pop(a,None)
                cache={k:v for k,v in cache.items() if k[0]!=device}
        return [out,sorted([[k,v] for k,v in generations.items()]),sorted([[d,k,v] for (d,k),v in cache.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layout-cache scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('layout-cache scenario 1', solve([[['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[[], [], []]] * N)
check('layout-cache scenario 2', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] * N)
check('layout-cache scenario 3', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'a', 'KeyA', 'y'], ['lookup', 'a', 'KeyA', '']]] * N), [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] * N)
check('layout-cache scenario 4', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['layout', 'a', 2, ''], ['lookup', 'a', 'KeyA', '']]] * N), [[['KeyA'], [['a', 2]], []]] * N)
check('layout-cache scenario 5', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['layout', 'a', 3, '']]] * N), [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] * N)
check('layout-cache scenario 6', solve([[['layout', 'a', 1, ''], ['lookup', 'b', 'KeyA', '']]] * N), [[[], [['a', 1]], []]] * N)
check('layout-cache scenario 7', solve([[['layout', 'a', 1, ''], ['lookup', 'a', 'Unknown', 'fallback']]] * N), [[['Unknown'], [['a', 1]], []]] * N)
check('layout-cache scenario 8', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['disconnect', 'a', '', '']]] * N), [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the disconnect generation rule and produces incorrect keyboard state or command output.

Events [kind,device,a,b]. layout replaces device generation a and clears cached labels; map caches physical code a to label b in current generation; lookup emits cached label or code a as fallback. Disconnect removes generation and cache. Maps and lookups before layout are ignored. Return emitted labels, generations and cached [device,code,label] rows. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        generations={}; cache={}; out=[]
        for kind,device,a,b in c:
            if kind=='layout':
                generations[device]=a
                cache={k:v for k,v in cache.items() if k[0]!=device}
            elif kind=='map' and device in generations:
                cache[(device,a)]=b
            elif kind=='lookup' and device in generations:
                out.append(cache.get((device,a),a))
            elif kind=='disconnect':
                generations.pop(device,None)
                cache={}
        return [out,sorted([[k,v] for k,v in generations.items()]),sorted([[d,k,v] for (d,k),v in cache.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layout-cache scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('layout-cache scenario 1', solve([[['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[[], [], []]] * N)
check('layout-cache scenario 2', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] * N)
check('layout-cache scenario 3', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'a', 'KeyA', 'y'], ['lookup', 'a', 'KeyA', '']]] * N), [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] * N)
check('layout-cache scenario 4', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['layout', 'a', 2, ''], ['lookup', 'a', 'KeyA', '']]] * N), [[['KeyA'], [['a', 2]], []]] * N)
check('layout-cache scenario 5', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['layout', 'a', 3, '']]] * N), [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] * N)
check('layout-cache scenario 6', solve([[['layout', 'a', 1, ''], ['lookup', 'b', 'KeyA', '']]] * N), [[[], [['a', 1]], []]] * N)
check('layout-cache scenario 7', solve([[['layout', 'a', 1, ''], ['lookup', 'a', 'Unknown', 'fallback']]] * N), [[['Unknown'], [['a', 1]], []]] * N)
check('layout-cache scenario 8', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['disconnect', 'a', '', '']]] * N), [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        generations={}; cache={}; out=[]
        for kind,device,a,b in c:
            if kind=='layout':
                generations[device]=a
                cache={k:v for k,v in cache.items() if k[0]!=device}
            elif kind=='map' and device in generations:
                cache[(device,a)]=b
            elif kind=='lookup' and device in generations:
                out.append(cache.get((device,a),a))
            elif kind=='disconnect':
                generations.pop(device,None)
                cache={k:v for k,v in cache.items() if k[0]==device}
        return [out,sorted([[k,v] for k,v in generations.items()]),sorted([[d,k,v] for (d,k),v in cache.items()])]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layout-cache scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('layout-cache scenario 1', solve([[['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[[], [], []]] * N)
check('layout-cache scenario 2', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] * N)
check('layout-cache scenario 3', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'a', 'KeyA', 'y'], ['lookup', 'a', 'KeyA', '']]] * N), [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] * N)
check('layout-cache scenario 4', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['layout', 'a', 2, ''], ['lookup', 'a', 'KeyA', '']]] * N), [[['KeyA'], [['a', 2]], []]] * N)
check('layout-cache scenario 5', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['layout', 'a', 3, '']]] * N), [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] * N)
check('layout-cache scenario 6', solve([[['layout', 'a', 1, ''], ['lookup', 'b', 'KeyA', '']]] * N), [[[], [['a', 1]], []]] * N)
check('layout-cache scenario 7', solve([[['layout', 'a', 1, ''], ['lookup', 'a', 'Unknown', 'fallback']]] * N), [[['Unknown'], [['a', 1]], []]] * N)
check('layout-cache scenario 8', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['disconnect', 'a', '', '']]] * N), [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the disconnect cache rule and produces incorrect keyboard state or command output.

Events [kind,device,a,b]. layout replaces device generation a and clears cached labels; map caches physical code a to label b in current generation; lookup emits cached label or code a as fallback. Disconnect removes generation and cache. Maps and lookups before layout are ignored. Return emitted labels, generations and cached [device,code,label] rows. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and a not in layers:
                if a not in stack: stack.append(a)
            elif kind=='pop':
                stack=[x for x in stack if x!=a]
            elif kind=='clear':
                stack=[]
            elif kind=='key':
                result=a
                for layer in reversed(stack):
                    if a in layers[layer]:
                        result=layers[layer][a]
                        break
                if result is None: blocked+=1
                else: out.append(result)
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and layers.get(a):
                if a not in stack: stack.append(a)
            elif kind=='pop':
                stack=[x for x in stack if x!=a]
            elif kind=='clear':
                stack=[]
            elif kind=='key':
                result=a
                for layer in reversed(stack):
                    if a in layers[layer]:
                        result=layers[layer][a]
                        break
                if result is None: blocked+=1
                else: out.append(result)
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the unknown layer rule and produces incorrect keyboard state or command output.

Case [layers,events]. layers maps layer names to key-to-output maps; None output blocks a key and empty string is valid output. Events [kind,a,b]. Push adds a known layer unless already active; pop removes named layer; key resolves from newest active layer defining the key, falling through transparent missing entries to original key. Clear removes layers. Return emitted strings and layer stack. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and a in layers:
                stack.append(a)
            elif kind=='pop':
                stack=[x for x in stack if x!=a]
            elif kind=='clear':
                stack=[]
            elif kind=='key':
                result=a
                for layer in reversed(stack):
                    if a in layers[layer]:
                        result=layers[layer][a]
                        break
                if result is None: blocked+=1
                else: out.append(result)
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and a in layers:
                if a in stack: stack.append(a)
            elif kind=='pop':
                stack=[x for x in stack if x!=a]
            elif kind=='clear':
                stack=[]
            elif kind=='key':
                result=a
                for layer in reversed(stack):
                    if a in layers[layer]:
                        result=layers[layer][a]
                        break
                if result is None: blocked+=1
                else: out.append(result)
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the duplicate push rule and produces incorrect keyboard state or command output.

Case [layers,events]. layers maps layer names to key-to-output maps; None output blocks a key and empty string is valid output. Events [kind,a,b]. Push adds a known layer unless already active; pop removes named layer; key resolves from newest active layer defining the key, falling through transparent missing entries to original key. Clear removes layers. Return emitted strings and layer stack. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and a in layers:
                if a not in stack: stack.append(a)
            elif kind=='pop':
                stack=stack[:-1]
            elif kind=='clear':
                stack=[]
            elif kind=='key':
                result=a
                for layer in reversed(stack):
                    if a in layers[layer]:
                        result=layers[layer][a]
                        break
                if result is None: blocked+=1
                else: out.append(result)
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and a in layers:
                if a not in stack: stack.append(a)
            elif kind=='pop':
                stack=[x for x in stack if x==a]
            elif kind=='clear':
                stack=[]
            elif kind=='key':
                result=a
                for layer in reversed(stack):
                    if a in layers[layer]:
                        result=layers[layer][a]
                        break
                if result is None: blocked+=1
                else: out.append(result)
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the named pop rule and produces incorrect keyboard state or command output.

Case [layers,events]. layers maps layer names to key-to-output maps; None output blocks a key and empty string is valid output. Events [kind,a,b]. Push adds a known layer unless already active; pop removes named layer; key resolves from newest active layer defining the key, falling through transparent missing entries to original key. Clear removes layers. Return emitted strings and layer stack. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and a in layers:
                if a not in stack: stack.append(a)
            elif kind=='pop':
                stack=[x for x in stack if x!=a]
            elif kind=='clear':
                stack=stack[:1]
            elif kind=='key':
                result=a
                for layer in reversed(stack):
                    if a in layers[layer]:
                        result=layers[layer][a]
                        break
                if result is None: blocked+=1
                else: out.append(result)
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and a in layers:
                if a not in stack: stack.append(a)
            elif kind=='pop':
                stack=[x for x in stack if x!=a]
            elif kind=='clear':
                stack=stack[:-1]
            elif kind=='key':
                result=a
                for layer in reversed(stack):
                    if a in layers[layer]:
                        result=layers[layer][a]
                        break
                if result is None: blocked+=1
                else: out.append(result)
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the clear stack rule and produces incorrect keyboard state or command output.

Case [layers,events]. layers maps layer names to key-to-output maps; None output blocks a key and empty string is valid output. Events [kind,a,b]. Push adds a known layer unless already active; pop removes named layer; key resolves from newest active layer defining the key, falling through transparent missing entries to original key. Clear removes layers. Return emitted strings and layer stack. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and a in layers:
                if a not in stack: stack.append(a)
            elif kind=='pop':
                stack=[x for x in stack if x!=a]
            elif kind=='clear':
                stack=[]
            elif kind=='key':
                result=b
                for layer in reversed(stack):
                    if a in layers[layer]:
                        result=layers[layer][a]
                        break
                if result is None: blocked+=1
                else: out.append(result)
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and a in layers:
                if a not in stack: stack.append(a)
            elif kind=='pop':
                stack=[x for x in stack if x!=a]
            elif kind=='clear':
                stack=[]
            elif kind=='key':
                result=None
                for layer in reversed(stack):
                    if a in layers[layer]:
                        result=layers[layer][a]
                        break
                if result is None: blocked+=1
                else: out.append(result)
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the fallback key rule and produces incorrect keyboard state or command output.

Case [layers,events]. layers maps layer names to key-to-output maps; None output blocks a key and empty string is valid output. Events [kind,a,b]. Push adds a known layer unless already active; pop removes named layer; key resolves from newest active layer defining the key, falling through transparent missing entries to original key. Clear removes layers. Return emitted strings and layer stack. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and a in layers:
                if a not in stack: stack.append(a)
            elif kind=='pop':
                stack=[x for x in stack if x!=a]
            elif kind=='clear':
                stack=[]
            elif kind=='key':
                result=a
                for layer in stack:
                    if a in layers[layer]:
                        result=layers[layer][a]
                        break
                if result is None: blocked+=1
                else: out.append(result)
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and a in layers:
                if a not in stack: stack.append(a)
            elif kind=='pop':
                stack=[x for x in stack if x!=a]
            elif kind=='clear':
                stack=[]
            elif kind=='key':
                result=a
                for layer in stack[:1]:
                    if a in layers[layer]:
                        result=layers[layer][a]
                        break
                if result is None: blocked+=1
                else: out.append(result)
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the layer precedence rule and produces incorrect keyboard state or command output.

Case [layers,events]. layers maps layer names to key-to-output maps; None output blocks a key and empty string is valid output. Events [kind,a,b]. Push adds a known layer unless already active; pop removes named layer; key resolves from newest active layer defining the key, falling through transparent missing entries to original key. Clear removes layers. Return emitted strings and layer stack. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and a in layers:
                if a not in stack: stack.append(a)
            elif kind=='pop':
                stack=[x for x in stack if x!=a]
            elif kind=='clear':
                stack=[]
            elif kind=='key':
                result=a
                for layer in reversed(stack):
                    if layers[layer].get(a):
                        result=layers[layer][a]
                        break
                if result is None: blocked+=1
                else: out.append(result)
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and a in layers:
                if a not in stack: stack.append(a)
            elif kind=='pop':
                stack=[x for x in stack if x!=a]
            elif kind=='clear':
                stack=[]
            elif kind=='key':
                result=a
                for layer in reversed(stack):
                    if layers[layer].get(a) is not None:
                        result=layers[layer][a]
                        break
                if result is None: blocked+=1
                else: out.append(result)
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the defined entry rule and produces incorrect keyboard state or command output.

Case [layers,events]. layers maps layer names to key-to-output maps; None output blocks a key and empty string is valid output. Events [kind,a,b]. Push adds a known layer unless already active; pop removes named layer; key resolves from newest active layer defining the key, falling through transparent missing entries to original key. Clear removes layers. Return emitted strings and layer stack. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and a in layers:
                if a not in stack: stack.append(a)
            elif kind=='pop':
                stack=[x for x in stack if x!=a]
            elif kind=='clear':
                stack=[]
            elif kind=='key':
                result=a
                for layer in reversed(stack):
                    if a in layers[layer]:
                        result=layers[layer][a]
                        continue
                if result is None: blocked+=1
                else: out.append(result)
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and a in layers:
                if a not in stack: stack.append(a)
            elif kind=='pop':
                stack=[x for x in stack if x!=a]
            elif kind=='clear':
                stack=[]
            elif kind=='key':
                result=a
                for layer in reversed(stack):
                    if a in layers[layer]:
                        result=layers[layer][a]
                        pass
                if result is None: blocked+=1
                else: out.append(result)
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the stop resolution rule and produces incorrect keyboard state or command output.

Case [layers,events]. layers maps layer names to key-to-output maps; None output blocks a key and empty string is valid output. Events [kind,a,b]. Push adds a known layer unless already active; pop removes named layer; key resolves from newest active layer defining the key, falling through transparent missing entries to original key. Clear removes layers. Return emitted strings and layer stack. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and a in layers:
                if a not in stack: stack.append(a)
            elif kind=='pop':
                stack=[x for x in stack if x!=a]
            elif kind=='clear':
                stack=[]
            elif kind=='key':
                result=a
                for layer in reversed(stack):
                    if a in layers[layer]:
                        result=layers[layer][a]
                        break
                if not result: blocked+=1
                else: out.append(result)
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and a in layers:
                if a not in stack: stack.append(a)
            elif kind=='pop':
                stack=[x for x in stack if x!=a]
            elif kind=='clear':
                stack=[]
            elif kind=='key':
                result=a
                for layer in reversed(stack):
                    if a in layers[layer]:
                        result=layers[layer][a]
                        break
                if result=="": blocked+=1
                else: out.append(result)
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the blocked output rule and produces incorrect keyboard state or command output.

Case [layers,events]. layers maps layer names to key-to-output maps; None output blocks a key and empty string is valid output. Events [kind,a,b]. Push adds a known layer unless already active; pop removes named layer; key resolves from newest active layer defining the key, falling through transparent missing entries to original key. Clear removes layers. Return emitted strings and layer stack. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and a in layers:
                if a not in stack: stack.append(a)
            elif kind=='pop':
                stack=[x for x in stack if x!=a]
            elif kind=='clear':
                stack=[]
            elif kind=='key':
                result=a
                for layer in reversed(stack):
                    if a in layers[layer]:
                        result=layers[layer][a]
                        break
                if result is None: blocked+=1
                else: out.append(a)
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(cases):
    def run(c):
        layers,events=c
        stack=[]; out=[]; blocked=0
        for kind,a,b in events:
            if kind=='push' and a in layers:
                if a not in stack: stack.append(a)
            elif kind=='pop':
                stack=[x for x in stack if x!=a]
            elif kind=='clear':
                stack=[]
            elif kind=='key':
                result=a
                for layer in reversed(stack):
                    if a in layers[layer]:
                        result=layers[layer][a]
                        break
                if result is None: blocked+=1
                else: out.append([result])
        return [out,stack,blocked]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remap-layers scenario 0', solve([[{}, []]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 1', solve([[{'empty': {}}, [['push', 'empty', ''], ['key', 'A', 'x']]]] * N), [[['A'], ['empty'], 0]] * N)
check('remap-layers scenario 2', solve([[{'one': {'A': 'X'}}, [['push', 'one', ''], ['push', 'one', ''], ['key', 'A', '']]]] * N), [[['X'], ['one'], 0]] * N)
check('remap-layers scenario 3', solve([[{'one': {'A': 'X'}, 'two': {'A': 'Y'}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[['Y'], ['one', 'two'], 0]] * N)
check('remap-layers scenario 4', solve([[{'one': {'A': 'X'}, 'two': {}}, [['push', 'one', ''], ['push', 'two', ''], ['pop', 'one', ''], ['key', 'A', '']]]] * N), [[['A'], ['two'], 0]] * N)
check('remap-layers scenario 5', solve([[{'one': {'A': None, 'B': ''}}, [['push', 'one', ''], ['key', 'A', ''], ['key', 'B', ''], ['key', 'C', '']]]] * N), [[['', 'C'], ['one'], 1]] * N)
check('remap-layers scenario 6', solve([[{'one': {}, 'two': {}, 'three': {}}, [['push', 'one', ''], ['push', 'two', ''], ['push', 'three', ''], ['clear', '', '']]]] * N), [[[], [], 0]] * N)
check('remap-layers scenario 7', solve([[{'one': {'A': 'X'}, 'two': {'A': None}}, [['push', 'one', ''], ['push', 'two', ''], ['key', 'A', '']]]] * N), [[[], ['one', 'two'], 1]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The event trace violates the emitted value rule and produces incorrect keyboard state or command output.

Case [layers,events]. layers maps layer names to key-to-output maps; None output blocks a key and empty string is valid output. Events [kind,a,b]. Push adds a known layer unless already active; pop removes named layer; key resolves from newest active layer defining the key, falling through transparent missing entries to original key. Clear removes layers. Return emitted strings and layer stack. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access