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

N = 1
observations = []
def solve(cases):
    def run(c):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                if pending is None: pending=[now,False]
            elif kind=='down':
                if pending is not None:
                    out.append(['down',modifier]); pending[1]=True
                out.append(['down',key])
            elif kind=='tick':
                if pending is not None and not pending[1] and now-pending[0]>=threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['up',modifier])
                    else: out.extend([['down',tap],['up',tap]])
                    pending=None
            elif kind=='up': out.append(['up',key])
            elif kind=='cancel':
                if pending is not None and pending[1]: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], None]] * 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):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                if pending is None: pending=[now,False]
            elif kind=='down':
                if pending is not None and pending[1]:
                    out.append(['down',modifier]); pending[1]=True
                out.append(['down',key])
            elif kind=='tick':
                if pending is not None and not pending[1] and now-pending[0]>=threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['up',modifier])
                    else: out.extend([['down',tap],['up',tap]])
                    pending=None
            elif kind=='up': out.append(['up',key])
            elif kind=='cancel':
                if pending is not None and pending[1]: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], None]] * 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 foreign promotion rule and produces incorrect keyboard state or command output.

Case [dual,tap,modifier,threshold,events]. Events [kind,key,time]. Dual down arms tap; repeated dual downs ignored. A foreign down or threshold tick promotes pending dual into modifier down before forwarding foreign down. Dual up emits tap when pending, modifier up when promoted. Cancel releases a promoted modifier and cancels pending tap. Foreign up is forwarded. Return emitted [phase,key] and pending [start,promoted] or None. 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):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                if pending is None: pending=[now,False]
            elif kind=='down':
                if pending is not None and not pending[1]:
                    out.append(['down',key]); pending[1]=True
                out.append(['down',modifier])
            elif kind=='tick':
                if pending is not None and not pending[1] and now-pending[0]>=threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['up',modifier])
                    else: out.extend([['down',tap],['up',tap]])
                    pending=None
            elif kind=='up': out.append(['up',key])
            elif kind=='cancel':
                if pending is not None and pending[1]: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], None]] * 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):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                if pending is None: pending=[now,False]
            elif kind=='down':
                if pending is not None and not pending[1]:
                    pending[1]=True
                out.append(['down',key])
            elif kind=='tick':
                if pending is not None and not pending[1] and now-pending[0]>=threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['up',modifier])
                    else: out.extend([['down',tap],['up',tap]])
                    pending=None
            elif kind=='up': out.append(['up',key])
            elif kind=='cancel':
                if pending is not None and pending[1]: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], None]] * 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 foreign order rule and produces incorrect keyboard state or command output.

Case [dual,tap,modifier,threshold,events]. Events [kind,key,time]. Dual down arms tap; repeated dual downs ignored. A foreign down or threshold tick promotes pending dual into modifier down before forwarding foreign down. Dual up emits tap when pending, modifier up when promoted. Cancel releases a promoted modifier and cancels pending tap. Foreign up is forwarded. Return emitted [phase,key] and pending [start,promoted] or None. 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):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                if pending is None: pending=[now,False]
            elif kind=='down':
                if pending is not None and not pending[1]:
                    out.append(['down',modifier]); pending[1]=True
                out.append(['down',key])
            elif kind=='tick':
                if pending is not None and not pending[1] and now-pending[0]>threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['up',modifier])
                    else: out.extend([['down',tap],['up',tap]])
                    pending=None
            elif kind=='up': out.append(['up',key])
            elif kind=='cancel':
                if pending is not None and pending[1]: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], None]] * 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):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                if pending is None: pending=[now,False]
            elif kind=='down':
                if pending is not None and not pending[1]:
                    out.append(['down',modifier]); pending[1]=True
                out.append(['down',key])
            elif kind=='tick':
                if pending is not None and not pending[1] and now>=threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['up',modifier])
                    else: out.extend([['down',tap],['up',tap]])
                    pending=None
            elif kind=='up': out.append(['up',key])
            elif kind=='cancel':
                if pending is not None and pending[1]: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], None]] * 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 hold boundary rule and produces incorrect keyboard state or command output.

Case [dual,tap,modifier,threshold,events]. Events [kind,key,time]. Dual down arms tap; repeated dual downs ignored. A foreign down or threshold tick promotes pending dual into modifier down before forwarding foreign down. Dual up emits tap when pending, modifier up when promoted. Cancel releases a promoted modifier and cancels pending tap. Foreign up is forwarded. Return emitted [phase,key] and pending [start,promoted] or None. 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):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                if pending is None: pending=[now,False]
            elif kind=='down':
                if pending is not None and not pending[1]:
                    out.append(['down',modifier]); pending[1]=True
                out.append(['down',key])
            elif kind=='tick':
                if pending is not None and now-pending[0]>=threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['up',modifier])
                    else: out.extend([['down',tap],['up',tap]])
                    pending=None
            elif kind=='up': out.append(['up',key])
            elif kind=='cancel':
                if pending is not None and pending[1]: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], None]] * 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):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                if pending is None: pending=[now,False]
            elif kind=='down':
                if pending is not None and not pending[1]:
                    out.append(['down',modifier]); pending[1]=True
                out.append(['down',key])
            elif kind=='tick':
                if pending is not None and pending[1] and now-pending[0]>=threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['up',modifier])
                    else: out.extend([['down',tap],['up',tap]])
                    pending=None
            elif kind=='up': out.append(['up',key])
            elif kind=='cancel':
                if pending is not None and pending[1]: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], None]] * 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 tick single rule and produces incorrect keyboard state or command output.

Case [dual,tap,modifier,threshold,events]. Events [kind,key,time]. Dual down arms tap; repeated dual downs ignored. A foreign down or threshold tick promotes pending dual into modifier down before forwarding foreign down. Dual up emits tap when pending, modifier up when promoted. Cancel releases a promoted modifier and cancels pending tap. Foreign up is forwarded. Return emitted [phase,key] and pending [start,promoted] or None. 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):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                if pending is None: pending=[now,False]
            elif kind=='down':
                if pending is not None and not pending[1]:
                    out.append(['down',modifier]); pending[1]=True
                out.append(['down',key])
            elif kind=='tick':
                if pending is not None and not pending[1] and now-pending[0]>=threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['up',dual])
                    else: out.extend([['down',tap],['up',tap]])
                    pending=None
            elif kind=='up': out.append(['up',key])
            elif kind=='cancel':
                if pending is not None and pending[1]: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], None]] * 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):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                if pending is None: pending=[now,False]
            elif kind=='down':
                if pending is not None and not pending[1]:
                    out.append(['down',modifier]); pending[1]=True
                out.append(['down',key])
            elif kind=='tick':
                if pending is not None and not pending[1] and now-pending[0]>=threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['down',modifier])
                    else: out.extend([['down',tap],['up',tap]])
                    pending=None
            elif kind=='up': out.append(['up',key])
            elif kind=='cancel':
                if pending is not None and pending[1]: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], None]] * 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 promoted release rule and produces incorrect keyboard state or command output.

Case [dual,tap,modifier,threshold,events]. Events [kind,key,time]. Dual down arms tap; repeated dual downs ignored. A foreign down or threshold tick promotes pending dual into modifier down before forwarding foreign down. Dual up emits tap when pending, modifier up when promoted. Cancel releases a promoted modifier and cancels pending tap. Foreign up is forwarded. Return emitted [phase,key] and pending [start,promoted] or None. 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):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                if pending is None: pending=[now,False]
            elif kind=='down':
                if pending is not None and not pending[1]:
                    out.append(['down',modifier]); pending[1]=True
                out.append(['down',key])
            elif kind=='tick':
                if pending is not None and not pending[1] and now-pending[0]>=threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['up',modifier])
                    else: out.extend([['up',tap],['down',tap]])
                    pending=None
            elif kind=='up': out.append(['up',key])
            elif kind=='cancel':
                if pending is not None and pending[1]: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], None]] * 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):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                if pending is None: pending=[now,False]
            elif kind=='down':
                if pending is not None and not pending[1]:
                    out.append(['down',modifier]); pending[1]=True
                out.append(['down',key])
            elif kind=='tick':
                if pending is not None and not pending[1] and now-pending[0]>=threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['up',modifier])
                    else: out.extend([['down',tap]])
                    pending=None
            elif kind=='up': out.append(['up',key])
            elif kind=='cancel':
                if pending is not None and pending[1]: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], None]] * 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 tap pair rule and produces incorrect keyboard state or command output.

Case [dual,tap,modifier,threshold,events]. Events [kind,key,time]. Dual down arms tap; repeated dual downs ignored. A foreign down or threshold tick promotes pending dual into modifier down before forwarding foreign down. Dual up emits tap when pending, modifier up when promoted. Cancel releases a promoted modifier and cancels pending tap. Foreign up is forwarded. Return emitted [phase,key] and pending [start,promoted] or None. 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):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                if pending is None: pending=[now,False]
            elif kind=='down':
                if pending is not None and not pending[1]:
                    out.append(['down',modifier]); pending[1]=True
                out.append(['down',key])
            elif kind=='tick':
                if pending is not None and not pending[1] and now-pending[0]>=threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['up',modifier])
                    else: out.extend([['down',tap],['up',tap]])
                    pending=pending
            elif kind=='up': out.append(['up',key])
            elif kind=='cancel':
                if pending is not None and pending[1]: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], None]] * 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):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                if pending is None: pending=[now,False]
            elif kind=='down':
                if pending is not None and not pending[1]:
                    out.append(['down',modifier]); pending[1]=True
                out.append(['down',key])
            elif kind=='tick':
                if pending is not None and not pending[1] and now-pending[0]>=threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['up',modifier])
                    else: out.extend([['down',tap],['up',tap]])
                    pending=[now,False]
            elif kind=='up': out.append(['up',key])
            elif kind=='cancel':
                if pending is not None and pending[1]: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], None]] * 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 release close rule and produces incorrect keyboard state or command output.

Case [dual,tap,modifier,threshold,events]. Events [kind,key,time]. Dual down arms tap; repeated dual downs ignored. A foreign down or threshold tick promotes pending dual into modifier down before forwarding foreign down. Dual up emits tap when pending, modifier up when promoted. Cancel releases a promoted modifier and cancels pending tap. Foreign up is forwarded. Return emitted [phase,key] and pending [start,promoted] or None. 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):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                if pending is None: pending=[now,False]
            elif kind=='down':
                if pending is not None and not pending[1]:
                    out.append(['down',modifier]); pending[1]=True
                out.append(['down',key])
            elif kind=='tick':
                if pending is not None and not pending[1] and now-pending[0]>=threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['up',modifier])
                    else: out.extend([['down',tap],['up',tap]])
                    pending=None
            elif kind=='up': out.append(['up',modifier])
            elif kind=='cancel':
                if pending is not None and pending[1]: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], None]] * 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):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                if pending is None: pending=[now,False]
            elif kind=='down':
                if pending is not None and not pending[1]:
                    out.append(['down',modifier]); pending[1]=True
                out.append(['down',key])
            elif kind=='tick':
                if pending is not None and not pending[1] and now-pending[0]>=threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['up',modifier])
                    else: out.extend([['down',tap],['up',tap]])
                    pending=None
            elif kind=='up': pass
            elif kind=='cancel':
                if pending is not None and pending[1]: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], None]] * 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 foreign release rule and produces incorrect keyboard state or command output.

Case [dual,tap,modifier,threshold,events]. Events [kind,key,time]. Dual down arms tap; repeated dual downs ignored. A foreign down or threshold tick promotes pending dual into modifier down before forwarding foreign down. Dual up emits tap when pending, modifier up when promoted. Cancel releases a promoted modifier and cancels pending tap. Foreign up is forwarded. Return emitted [phase,key] and pending [start,promoted] or None. 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):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                if pending is None: pending=[now,False]
            elif kind=='down':
                if pending is not None and not pending[1]:
                    out.append(['down',modifier]); pending[1]=True
                out.append(['down',key])
            elif kind=='tick':
                if pending is not None and not pending[1] and now-pending[0]>=threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['up',modifier])
                    else: out.extend([['down',tap],['up',tap]])
                    pending=None
            elif kind=='up': out.append(['up',key])
            elif kind=='cancel':
                if pending is not None: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], None]] * 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):
        dual,tap,modifier,threshold,events=c
        pending=None; out=[]
        for kind,key,now in events:
            if kind=='down' and key==dual:
                if pending is None: pending=[now,False]
            elif kind=='down':
                if pending is not None and not pending[1]:
                    out.append(['down',modifier]); pending[1]=True
                out.append(['down',key])
            elif kind=='tick':
                if pending is not None and not pending[1] and now-pending[0]>=threshold:
                    out.append(['down',modifier]); pending[1]=True
            elif kind=='up' and key==dual:
                if pending is not None:
                    if pending[1]: out.append(['up',modifier])
                    else: out.extend([['down',tap],['up',tap]])
                    pending=None
            elif kind=='up': out.append(['up',key])
            elif kind=='cancel':
                if pending is not None and not pending[1]: out.append(['up',modifier])
                pending=None
        return [out,pending]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dual-role-key scenario 0', solve([['X', 'Escape', 'Control', 5, []]] * N), [[[], None]] * N)
check('dual-role-key scenario 1', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['up', 'X', 11]]]] * N), [[[['down', 'Escape'], ['up', 'Escape']], None]] * N)
check('dual-role-key scenario 2', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'A', 11], ['down', 'B', 12], ['up', 'A', 13], ['up', 'X', 14]]]] * N), [[[['down', 'Control'], ['down', 'A'], ['down', 'B'], ['up', 'A'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 3', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 12]]]] * N), [[[], [10, False]]] * N)
check('dual-role-key scenario 4', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['tick', '', 16], ['up', 'X', 17]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 5', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['down', 'X', 13], ['tick', '', 15]]]] * N), [[[['down', 'Control']], [10, True]]] * N)
check('dual-role-key scenario 6', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['cancel', '', 11]]]] * N), [[[], None]] * N)
check('dual-role-key scenario 7', solve([['X', 'Escape', 'Control', 5, [['down', 'X', 10], ['tick', '', 15], ['cancel', '', 16]]]] * N), [[[['down', 'Control'], ['up', 'Control']], None]] * N)
check('dual-role-key scenario 8', solve([['X', 'Escape', 'Control', 5, [['down', 'A', 10], ['up', 'A', 11]]]] * N), [[[['down', 'A'], ['up', 'A']], None]] * 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 cancel promoted rule and produces incorrect keyboard state or command output.

Case [dual,tap,modifier,threshold,events]. Events [kind,key,time]. Dual down arms tap; repeated dual downs ignored. A foreign down or threshold tick promotes pending dual into modifier down before forwarding foreign down. Dual up emits tap when pending, modifier up when promoted. Cancel releases a promoted modifier and cancels pending tap. Foreign up is forwarded. Return emitted [phase,key] and pending [start,promoted] or None. 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):
        old_keys=set(); old_mods=set(); out=[]; rejected=0
        for mask,slots in c:
            if slots==[1]:
                rejected+=1
                continue
            keys=set(slots)-{0}
            mods={bit for bit in range(8) if mask & (1<<bit)}
            for key in sorted(old_keys-keys): out.append(['up','key',key])
            for mod in sorted(old_mods-mods): out.append(['up','mod',mod])
            for mod in sorted(mods-old_mods): out.append(['down','mod',mod])
            for key in sorted(keys-old_keys): out.append(['down','key',key])
            old_keys=keys
            old_mods=mods
        return [out,sorted(old_keys),sorted(old_mods),rejected]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('hid-report-delta scenario 0', solve([[]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 1', solve([[[0, [0, 0]]]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 2', solve([[[1, [2, 3, 3, 0]], [1, [2, 3, 0]]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3]], [2, 3], [0], 0]] * N)
check('hid-report-delta scenario 3', solve([[[1, [2, 3]], [2, [3, 4]], [0, []]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3], ['up', 'key', 2], ['up', 'mod', 0], ['down', 'mod', 1], ['down', 'key', 4], ['up', 'key', 3], ['up', 'key', 4], ['up', 'mod', 1]], [], [], 0]] * N)
check('hid-report-delta scenario 4', solve([[[4, [5]], [0, [1, 0, 0]], [4, [5]]]] * N), [[[['down', 'mod', 2], ['down', 'key', 5]], [5], [2], 1]] * N)
check('hid-report-delta scenario 5', solve([[[0, [1, 0]], [0, [1, 2]]]] * N), [[[], [], [], 2]] * N)
check('hid-report-delta scenario 6', solve([[[128, [2]], [0, []], [128, [2]]]] * N), [[[['down', 'mod', 7], ['down', 'key', 2], ['up', 'key', 2], ['up', 'mod', 7], ['down', 'mod', 7], ['down', 'key', 2]], [2], [7], 0]] * N)
check('hid-report-delta scenario 7', solve([[[0, [2]], [0, []], [0, [2]]]] * N), [[[['down', 'key', 2], ['up', 'key', 2], ['down', 'key', 2]], [2], [], 0]] * 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):
        old_keys=set(); old_mods=set(); out=[]; rejected=0
        for mask,slots in c:
            if all(x==1 for x in slots) and slots:
                rejected+=1
                continue
            keys=set(slots)-{0}
            mods={bit for bit in range(8) if mask & (1<<bit)}
            for key in sorted(old_keys-keys): out.append(['up','key',key])
            for mod in sorted(old_mods-mods): out.append(['up','mod',mod])
            for mod in sorted(mods-old_mods): out.append(['down','mod',mod])
            for key in sorted(keys-old_keys): out.append(['down','key',key])
            old_keys=keys
            old_mods=mods
        return [out,sorted(old_keys),sorted(old_mods),rejected]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('hid-report-delta scenario 0', solve([[]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 1', solve([[[0, [0, 0]]]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 2', solve([[[1, [2, 3, 3, 0]], [1, [2, 3, 0]]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3]], [2, 3], [0], 0]] * N)
check('hid-report-delta scenario 3', solve([[[1, [2, 3]], [2, [3, 4]], [0, []]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3], ['up', 'key', 2], ['up', 'mod', 0], ['down', 'mod', 1], ['down', 'key', 4], ['up', 'key', 3], ['up', 'key', 4], ['up', 'mod', 1]], [], [], 0]] * N)
check('hid-report-delta scenario 4', solve([[[4, [5]], [0, [1, 0, 0]], [4, [5]]]] * N), [[[['down', 'mod', 2], ['down', 'key', 5]], [5], [2], 1]] * N)
check('hid-report-delta scenario 5', solve([[[0, [1, 0]], [0, [1, 2]]]] * N), [[[], [], [], 2]] * N)
check('hid-report-delta scenario 6', solve([[[128, [2]], [0, []], [128, [2]]]] * N), [[[['down', 'mod', 7], ['down', 'key', 2], ['up', 'key', 2], ['up', 'mod', 7], ['down', 'mod', 7], ['down', 'key', 2]], [2], [7], 0]] * N)
check('hid-report-delta scenario 7', solve([[[0, [2]], [0, []], [0, [2]]]] * N), [[[['down', 'key', 2], ['up', 'key', 2], ['down', 'key', 2]], [2], [], 0]] * 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 error report rule and produces incorrect keyboard state or command output.

Each report is [modifier_mask,usage_slots]. Usages are integers >=0; 0 is padding, 1 is an error sentinel that invalidates the whole report. Other usages are unique logical keys even when slots duplicate. Modifier bits 0..7 identify M0..M7. Emit sorted key releases, sorted modifier releases, sorted modifier presses, then sorted key presses per valid report. Return emitted [phase,kind,identity] and final usage/modifier sets. 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):
        old_keys=set(); old_mods=set(); out=[]; rejected=0
        for mask,slots in c:
            if 1 in slots:
                rejected=1
                continue
            keys=set(slots)-{0}
            mods={bit for bit in range(8) if mask & (1<<bit)}
            for key in sorted(old_keys-keys): out.append(['up','key',key])
            for mod in sorted(old_mods-mods): out.append(['up','mod',mod])
            for mod in sorted(mods-old_mods): out.append(['down','mod',mod])
            for key in sorted(keys-old_keys): out.append(['down','key',key])
            old_keys=keys
            old_mods=mods
        return [out,sorted(old_keys),sorted(old_mods),rejected]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('hid-report-delta scenario 0', solve([[]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 1', solve([[[0, [0, 0]]]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 2', solve([[[1, [2, 3, 3, 0]], [1, [2, 3, 0]]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3]], [2, 3], [0], 0]] * N)
check('hid-report-delta scenario 3', solve([[[1, [2, 3]], [2, [3, 4]], [0, []]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3], ['up', 'key', 2], ['up', 'mod', 0], ['down', 'mod', 1], ['down', 'key', 4], ['up', 'key', 3], ['up', 'key', 4], ['up', 'mod', 1]], [], [], 0]] * N)
check('hid-report-delta scenario 4', solve([[[4, [5]], [0, [1, 0, 0]], [4, [5]]]] * N), [[[['down', 'mod', 2], ['down', 'key', 5]], [5], [2], 1]] * N)
check('hid-report-delta scenario 5', solve([[[0, [1, 0]], [0, [1, 2]]]] * N), [[[], [], [], 2]] * N)
check('hid-report-delta scenario 6', solve([[[128, [2]], [0, []], [128, [2]]]] * N), [[[['down', 'mod', 7], ['down', 'key', 2], ['up', 'key', 2], ['up', 'mod', 7], ['down', 'mod', 7], ['down', 'key', 2]], [2], [7], 0]] * N)
check('hid-report-delta scenario 7', solve([[[0, [2]], [0, []], [0, [2]]]] * N), [[[['down', 'key', 2], ['up', 'key', 2], ['down', 'key', 2]], [2], [], 0]] * 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):
        old_keys=set(); old_mods=set(); out=[]; rejected=0
        for mask,slots in c:
            if 1 in slots:
                rejected+=len(slots)
                continue
            keys=set(slots)-{0}
            mods={bit for bit in range(8) if mask & (1<<bit)}
            for key in sorted(old_keys-keys): out.append(['up','key',key])
            for mod in sorted(old_mods-mods): out.append(['up','mod',mod])
            for mod in sorted(mods-old_mods): out.append(['down','mod',mod])
            for key in sorted(keys-old_keys): out.append(['down','key',key])
            old_keys=keys
            old_mods=mods
        return [out,sorted(old_keys),sorted(old_mods),rejected]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('hid-report-delta scenario 0', solve([[]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 1', solve([[[0, [0, 0]]]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 2', solve([[[1, [2, 3, 3, 0]], [1, [2, 3, 0]]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3]], [2, 3], [0], 0]] * N)
check('hid-report-delta scenario 3', solve([[[1, [2, 3]], [2, [3, 4]], [0, []]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3], ['up', 'key', 2], ['up', 'mod', 0], ['down', 'mod', 1], ['down', 'key', 4], ['up', 'key', 3], ['up', 'key', 4], ['up', 'mod', 1]], [], [], 0]] * N)
check('hid-report-delta scenario 4', solve([[[4, [5]], [0, [1, 0, 0]], [4, [5]]]] * N), [[[['down', 'mod', 2], ['down', 'key', 5]], [5], [2], 1]] * N)
check('hid-report-delta scenario 5', solve([[[0, [1, 0]], [0, [1, 2]]]] * N), [[[], [], [], 2]] * N)
check('hid-report-delta scenario 6', solve([[[128, [2]], [0, []], [128, [2]]]] * N), [[[['down', 'mod', 7], ['down', 'key', 2], ['up', 'key', 2], ['up', 'mod', 7], ['down', 'mod', 7], ['down', 'key', 2]], [2], [7], 0]] * N)
check('hid-report-delta scenario 7', solve([[[0, [2]], [0, []], [0, [2]]]] * N), [[[['down', 'key', 2], ['up', 'key', 2], ['down', 'key', 2]], [2], [], 0]] * 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 reject counter rule and produces incorrect keyboard state or command output.

Each report is [modifier_mask,usage_slots]. Usages are integers >=0; 0 is padding, 1 is an error sentinel that invalidates the whole report. Other usages are unique logical keys even when slots duplicate. Modifier bits 0..7 identify M0..M7. Emit sorted key releases, sorted modifier releases, sorted modifier presses, then sorted key presses per valid report. Return emitted [phase,kind,identity] and final usage/modifier sets. 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):
        old_keys=set(); old_mods=set(); out=[]; rejected=0
        for mask,slots in c:
            if 1 in slots:
                rejected+=1
                continue
            keys=set(slots)
            mods={bit for bit in range(8) if mask & (1<<bit)}
            for key in sorted(old_keys-keys): out.append(['up','key',key])
            for mod in sorted(old_mods-mods): out.append(['up','mod',mod])
            for mod in sorted(mods-old_mods): out.append(['down','mod',mod])
            for key in sorted(keys-old_keys): out.append(['down','key',key])
            old_keys=keys
            old_mods=mods
        return [out,sorted(old_keys),sorted(old_mods),rejected]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('hid-report-delta scenario 0', solve([[]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 1', solve([[[0, [0, 0]]]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 2', solve([[[1, [2, 3, 3, 0]], [1, [2, 3, 0]]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3]], [2, 3], [0], 0]] * N)
check('hid-report-delta scenario 3', solve([[[1, [2, 3]], [2, [3, 4]], [0, []]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3], ['up', 'key', 2], ['up', 'mod', 0], ['down', 'mod', 1], ['down', 'key', 4], ['up', 'key', 3], ['up', 'key', 4], ['up', 'mod', 1]], [], [], 0]] * N)
check('hid-report-delta scenario 4', solve([[[4, [5]], [0, [1, 0, 0]], [4, [5]]]] * N), [[[['down', 'mod', 2], ['down', 'key', 5]], [5], [2], 1]] * N)
check('hid-report-delta scenario 5', solve([[[0, [1, 0]], [0, [1, 2]]]] * N), [[[], [], [], 2]] * N)
check('hid-report-delta scenario 6', solve([[[128, [2]], [0, []], [128, [2]]]] * N), [[[['down', 'mod', 7], ['down', 'key', 2], ['up', 'key', 2], ['up', 'mod', 7], ['down', 'mod', 7], ['down', 'key', 2]], [2], [7], 0]] * N)
check('hid-report-delta scenario 7', solve([[[0, [2]], [0, []], [0, [2]]]] * N), [[[['down', 'key', 2], ['up', 'key', 2], ['down', 'key', 2]], [2], [], 0]] * 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):
        old_keys=set(); old_mods=set(); out=[]; rejected=0
        for mask,slots in c:
            if 1 in slots:
                rejected+=1
                continue
            keys=set(slots)-{0,2}
            mods={bit for bit in range(8) if mask & (1<<bit)}
            for key in sorted(old_keys-keys): out.append(['up','key',key])
            for mod in sorted(old_mods-mods): out.append(['up','mod',mod])
            for mod in sorted(mods-old_mods): out.append(['down','mod',mod])
            for key in sorted(keys-old_keys): out.append(['down','key',key])
            old_keys=keys
            old_mods=mods
        return [out,sorted(old_keys),sorted(old_mods),rejected]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('hid-report-delta scenario 0', solve([[]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 1', solve([[[0, [0, 0]]]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 2', solve([[[1, [2, 3, 3, 0]], [1, [2, 3, 0]]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3]], [2, 3], [0], 0]] * N)
check('hid-report-delta scenario 3', solve([[[1, [2, 3]], [2, [3, 4]], [0, []]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3], ['up', 'key', 2], ['up', 'mod', 0], ['down', 'mod', 1], ['down', 'key', 4], ['up', 'key', 3], ['up', 'key', 4], ['up', 'mod', 1]], [], [], 0]] * N)
check('hid-report-delta scenario 4', solve([[[4, [5]], [0, [1, 0, 0]], [4, [5]]]] * N), [[[['down', 'mod', 2], ['down', 'key', 5]], [5], [2], 1]] * N)
check('hid-report-delta scenario 5', solve([[[0, [1, 0]], [0, [1, 2]]]] * N), [[[], [], [], 2]] * N)
check('hid-report-delta scenario 6', solve([[[128, [2]], [0, []], [128, [2]]]] * N), [[[['down', 'mod', 7], ['down', 'key', 2], ['up', 'key', 2], ['up', 'mod', 7], ['down', 'mod', 7], ['down', 'key', 2]], [2], [7], 0]] * N)
check('hid-report-delta scenario 7', solve([[[0, [2]], [0, []], [0, [2]]]] * N), [[[['down', 'key', 2], ['up', 'key', 2], ['down', 'key', 2]], [2], [], 0]] * 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 padding key rule and produces incorrect keyboard state or command output.

Each report is [modifier_mask,usage_slots]. Usages are integers >=0; 0 is padding, 1 is an error sentinel that invalidates the whole report. Other usages are unique logical keys even when slots duplicate. Modifier bits 0..7 identify M0..M7. Emit sorted key releases, sorted modifier releases, sorted modifier presses, then sorted key presses per valid report. Return emitted [phase,kind,identity] and final usage/modifier sets. 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):
        old_keys=set(); old_mods=set(); out=[]; rejected=0
        for mask,slots in c:
            if 1 in slots:
                rejected+=1
                continue
            keys=set(slots)-{0}
            mods={bit for bit in range(8) if mask & bit}
            for key in sorted(old_keys-keys): out.append(['up','key',key])
            for mod in sorted(old_mods-mods): out.append(['up','mod',mod])
            for mod in sorted(mods-old_mods): out.append(['down','mod',mod])
            for key in sorted(keys-old_keys): out.append(['down','key',key])
            old_keys=keys
            old_mods=mods
        return [out,sorted(old_keys),sorted(old_mods),rejected]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('hid-report-delta scenario 0', solve([[]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 1', solve([[[0, [0, 0]]]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 2', solve([[[1, [2, 3, 3, 0]], [1, [2, 3, 0]]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3]], [2, 3], [0], 0]] * N)
check('hid-report-delta scenario 3', solve([[[1, [2, 3]], [2, [3, 4]], [0, []]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3], ['up', 'key', 2], ['up', 'mod', 0], ['down', 'mod', 1], ['down', 'key', 4], ['up', 'key', 3], ['up', 'key', 4], ['up', 'mod', 1]], [], [], 0]] * N)
check('hid-report-delta scenario 4', solve([[[4, [5]], [0, [1, 0, 0]], [4, [5]]]] * N), [[[['down', 'mod', 2], ['down', 'key', 5]], [5], [2], 1]] * N)
check('hid-report-delta scenario 5', solve([[[0, [1, 0]], [0, [1, 2]]]] * N), [[[], [], [], 2]] * N)
check('hid-report-delta scenario 6', solve([[[128, [2]], [0, []], [128, [2]]]] * N), [[[['down', 'mod', 7], ['down', 'key', 2], ['up', 'key', 2], ['up', 'mod', 7], ['down', 'mod', 7], ['down', 'key', 2]], [2], [7], 0]] * N)
check('hid-report-delta scenario 7', solve([[[0, [2]], [0, []], [0, [2]]]] * N), [[[['down', 'key', 2], ['up', 'key', 2], ['down', 'key', 2]], [2], [], 0]] * 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):
        old_keys=set(); old_mods=set(); out=[]; rejected=0
        for mask,slots in c:
            if 1 in slots:
                rejected+=1
                continue
            keys=set(slots)-{0}
            mods={bit for bit in range(8) if mask & (1<<(7-bit))}
            for key in sorted(old_keys-keys): out.append(['up','key',key])
            for mod in sorted(old_mods-mods): out.append(['up','mod',mod])
            for mod in sorted(mods-old_mods): out.append(['down','mod',mod])
            for key in sorted(keys-old_keys): out.append(['down','key',key])
            old_keys=keys
            old_mods=mods
        return [out,sorted(old_keys),sorted(old_mods),rejected]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('hid-report-delta scenario 0', solve([[]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 1', solve([[[0, [0, 0]]]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 2', solve([[[1, [2, 3, 3, 0]], [1, [2, 3, 0]]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3]], [2, 3], [0], 0]] * N)
check('hid-report-delta scenario 3', solve([[[1, [2, 3]], [2, [3, 4]], [0, []]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3], ['up', 'key', 2], ['up', 'mod', 0], ['down', 'mod', 1], ['down', 'key', 4], ['up', 'key', 3], ['up', 'key', 4], ['up', 'mod', 1]], [], [], 0]] * N)
check('hid-report-delta scenario 4', solve([[[4, [5]], [0, [1, 0, 0]], [4, [5]]]] * N), [[[['down', 'mod', 2], ['down', 'key', 5]], [5], [2], 1]] * N)
check('hid-report-delta scenario 5', solve([[[0, [1, 0]], [0, [1, 2]]]] * N), [[[], [], [], 2]] * N)
check('hid-report-delta scenario 6', solve([[[128, [2]], [0, []], [128, [2]]]] * N), [[[['down', 'mod', 7], ['down', 'key', 2], ['up', 'key', 2], ['up', 'mod', 7], ['down', 'mod', 7], ['down', 'key', 2]], [2], [7], 0]] * N)
check('hid-report-delta scenario 7', solve([[[0, [2]], [0, []], [0, [2]]]] * N), [[[['down', 'key', 2], ['up', 'key', 2], ['down', 'key', 2]], [2], [], 0]] * 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 modifier bit rule and produces incorrect keyboard state or command output.

Each report is [modifier_mask,usage_slots]. Usages are integers >=0; 0 is padding, 1 is an error sentinel that invalidates the whole report. Other usages are unique logical keys even when slots duplicate. Modifier bits 0..7 identify M0..M7. Emit sorted key releases, sorted modifier releases, sorted modifier presses, then sorted key presses per valid report. Return emitted [phase,kind,identity] and final usage/modifier sets. 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):
        old_keys=set(); old_mods=set(); out=[]; rejected=0
        for mask,slots in c:
            if 1 in slots:
                rejected+=1
                continue
            keys=set(slots)-{0}
            mods={bit for bit in range(8) if mask & (1<<bit)}
            for key in sorted(keys-old_keys): out.append(['up','key',key])
            for mod in sorted(old_mods-mods): out.append(['up','mod',mod])
            for mod in sorted(mods-old_mods): out.append(['down','mod',mod])
            for key in sorted(keys-old_keys): out.append(['down','key',key])
            old_keys=keys
            old_mods=mods
        return [out,sorted(old_keys),sorted(old_mods),rejected]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('hid-report-delta scenario 0', solve([[]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 1', solve([[[0, [0, 0]]]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 2', solve([[[1, [2, 3, 3, 0]], [1, [2, 3, 0]]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3]], [2, 3], [0], 0]] * N)
check('hid-report-delta scenario 3', solve([[[1, [2, 3]], [2, [3, 4]], [0, []]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3], ['up', 'key', 2], ['up', 'mod', 0], ['down', 'mod', 1], ['down', 'key', 4], ['up', 'key', 3], ['up', 'key', 4], ['up', 'mod', 1]], [], [], 0]] * N)
check('hid-report-delta scenario 4', solve([[[4, [5]], [0, [1, 0, 0]], [4, [5]]]] * N), [[[['down', 'mod', 2], ['down', 'key', 5]], [5], [2], 1]] * N)
check('hid-report-delta scenario 5', solve([[[0, [1, 0]], [0, [1, 2]]]] * N), [[[], [], [], 2]] * N)
check('hid-report-delta scenario 6', solve([[[128, [2]], [0, []], [128, [2]]]] * N), [[[['down', 'mod', 7], ['down', 'key', 2], ['up', 'key', 2], ['up', 'mod', 7], ['down', 'mod', 7], ['down', 'key', 2]], [2], [7], 0]] * N)
check('hid-report-delta scenario 7', solve([[[0, [2]], [0, []], [0, [2]]]] * N), [[[['down', 'key', 2], ['up', 'key', 2], ['down', 'key', 2]], [2], [], 0]] * 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):
        old_keys=set(); old_mods=set(); out=[]; rejected=0
        for mask,slots in c:
            if 1 in slots:
                rejected+=1
                continue
            keys=set(slots)-{0}
            mods={bit for bit in range(8) if mask & (1<<bit)}
            for key in sorted(old_keys): out.append(['up','key',key])
            for mod in sorted(old_mods-mods): out.append(['up','mod',mod])
            for mod in sorted(mods-old_mods): out.append(['down','mod',mod])
            for key in sorted(keys-old_keys): out.append(['down','key',key])
            old_keys=keys
            old_mods=mods
        return [out,sorted(old_keys),sorted(old_mods),rejected]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('hid-report-delta scenario 0', solve([[]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 1', solve([[[0, [0, 0]]]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 2', solve([[[1, [2, 3, 3, 0]], [1, [2, 3, 0]]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3]], [2, 3], [0], 0]] * N)
check('hid-report-delta scenario 3', solve([[[1, [2, 3]], [2, [3, 4]], [0, []]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3], ['up', 'key', 2], ['up', 'mod', 0], ['down', 'mod', 1], ['down', 'key', 4], ['up', 'key', 3], ['up', 'key', 4], ['up', 'mod', 1]], [], [], 0]] * N)
check('hid-report-delta scenario 4', solve([[[4, [5]], [0, [1, 0, 0]], [4, [5]]]] * N), [[[['down', 'mod', 2], ['down', 'key', 5]], [5], [2], 1]] * N)
check('hid-report-delta scenario 5', solve([[[0, [1, 0]], [0, [1, 2]]]] * N), [[[], [], [], 2]] * N)
check('hid-report-delta scenario 6', solve([[[128, [2]], [0, []], [128, [2]]]] * N), [[[['down', 'mod', 7], ['down', 'key', 2], ['up', 'key', 2], ['up', 'mod', 7], ['down', 'mod', 7], ['down', 'key', 2]], [2], [7], 0]] * N)
check('hid-report-delta scenario 7', solve([[[0, [2]], [0, []], [0, [2]]]] * N), [[[['down', 'key', 2], ['up', 'key', 2], ['down', 'key', 2]], [2], [], 0]] * 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 key release delta rule and produces incorrect keyboard state or command output.

Each report is [modifier_mask,usage_slots]. Usages are integers >=0; 0 is padding, 1 is an error sentinel that invalidates the whole report. Other usages are unique logical keys even when slots duplicate. Modifier bits 0..7 identify M0..M7. Emit sorted key releases, sorted modifier releases, sorted modifier presses, then sorted key presses per valid report. Return emitted [phase,kind,identity] and final usage/modifier sets. 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):
        old_keys=set(); old_mods=set(); out=[]; rejected=0
        for mask,slots in c:
            if 1 in slots:
                rejected+=1
                continue
            keys=set(slots)-{0}
            mods={bit for bit in range(8) if mask & (1<<bit)}
            for key in sorted(old_keys-keys): out.append(['up','key',key])
            for mod in sorted(mods-old_mods): out.append(['up','mod',mod])
            for mod in sorted(mods-old_mods): out.append(['down','mod',mod])
            for key in sorted(keys-old_keys): out.append(['down','key',key])
            old_keys=keys
            old_mods=mods
        return [out,sorted(old_keys),sorted(old_mods),rejected]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('hid-report-delta scenario 0', solve([[]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 1', solve([[[0, [0, 0]]]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 2', solve([[[1, [2, 3, 3, 0]], [1, [2, 3, 0]]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3]], [2, 3], [0], 0]] * N)
check('hid-report-delta scenario 3', solve([[[1, [2, 3]], [2, [3, 4]], [0, []]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3], ['up', 'key', 2], ['up', 'mod', 0], ['down', 'mod', 1], ['down', 'key', 4], ['up', 'key', 3], ['up', 'key', 4], ['up', 'mod', 1]], [], [], 0]] * N)
check('hid-report-delta scenario 4', solve([[[4, [5]], [0, [1, 0, 0]], [4, [5]]]] * N), [[[['down', 'mod', 2], ['down', 'key', 5]], [5], [2], 1]] * N)
check('hid-report-delta scenario 5', solve([[[0, [1, 0]], [0, [1, 2]]]] * N), [[[], [], [], 2]] * N)
check('hid-report-delta scenario 6', solve([[[128, [2]], [0, []], [128, [2]]]] * N), [[[['down', 'mod', 7], ['down', 'key', 2], ['up', 'key', 2], ['up', 'mod', 7], ['down', 'mod', 7], ['down', 'key', 2]], [2], [7], 0]] * N)
check('hid-report-delta scenario 7', solve([[[0, [2]], [0, []], [0, [2]]]] * N), [[[['down', 'key', 2], ['up', 'key', 2], ['down', 'key', 2]], [2], [], 0]] * 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):
        old_keys=set(); old_mods=set(); out=[]; rejected=0
        for mask,slots in c:
            if 1 in slots:
                rejected+=1
                continue
            keys=set(slots)-{0}
            mods={bit for bit in range(8) if mask & (1<<bit)}
            for key in sorted(old_keys-keys): out.append(['up','key',key])
            for mod in sorted(old_mods): out.append(['up','mod',mod])
            for mod in sorted(mods-old_mods): out.append(['down','mod',mod])
            for key in sorted(keys-old_keys): out.append(['down','key',key])
            old_keys=keys
            old_mods=mods
        return [out,sorted(old_keys),sorted(old_mods),rejected]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('hid-report-delta scenario 0', solve([[]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 1', solve([[[0, [0, 0]]]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 2', solve([[[1, [2, 3, 3, 0]], [1, [2, 3, 0]]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3]], [2, 3], [0], 0]] * N)
check('hid-report-delta scenario 3', solve([[[1, [2, 3]], [2, [3, 4]], [0, []]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3], ['up', 'key', 2], ['up', 'mod', 0], ['down', 'mod', 1], ['down', 'key', 4], ['up', 'key', 3], ['up', 'key', 4], ['up', 'mod', 1]], [], [], 0]] * N)
check('hid-report-delta scenario 4', solve([[[4, [5]], [0, [1, 0, 0]], [4, [5]]]] * N), [[[['down', 'mod', 2], ['down', 'key', 5]], [5], [2], 1]] * N)
check('hid-report-delta scenario 5', solve([[[0, [1, 0]], [0, [1, 2]]]] * N), [[[], [], [], 2]] * N)
check('hid-report-delta scenario 6', solve([[[128, [2]], [0, []], [128, [2]]]] * N), [[[['down', 'mod', 7], ['down', 'key', 2], ['up', 'key', 2], ['up', 'mod', 7], ['down', 'mod', 7], ['down', 'key', 2]], [2], [7], 0]] * N)
check('hid-report-delta scenario 7', solve([[[0, [2]], [0, []], [0, [2]]]] * N), [[[['down', 'key', 2], ['up', 'key', 2], ['down', 'key', 2]], [2], [], 0]] * 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 modifier release delta rule and produces incorrect keyboard state or command output.

Each report is [modifier_mask,usage_slots]. Usages are integers >=0; 0 is padding, 1 is an error sentinel that invalidates the whole report. Other usages are unique logical keys even when slots duplicate. Modifier bits 0..7 identify M0..M7. Emit sorted key releases, sorted modifier releases, sorted modifier presses, then sorted key presses per valid report. Return emitted [phase,kind,identity] and final usage/modifier sets. 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