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

N = 1
observations = []
def solve(cases):
    def run(c):
        owner=None; preedit=''; committed=[]; updates=0
        for kind,target,text in c:
            if kind=='start':
                owner=target
                preedit=text
            elif kind=='update' and target==owner:
                preedit=text
                updates+=1
            elif kind=='commit' and target==owner and owner is not None:
                committed.append(text)
                owner=None
                preedit=''
            elif kind=='cancel':
                owner=None; preedit=''
            elif kind=='focus' and target!=owner:
                owner=None; preedit=''
        return [committed,owner,preedit,updates]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-transaction scenario 0', solve([[]] * N), [[[], None, '', 0]] * N)
check('composition-transaction scenario 1', solve([[['start', 'a', 'x'], ['update', 'a', 'xy'], ['update', 'a', 'xyz']]] * N), [[[], 'a', 'xyz', 2]] * N)
check('composition-transaction scenario 2', solve([[['start', 'a', 'x'], ['start', 'b', 'b']]] * N), [[[], 'b', 'b', 0]] * N)
check('composition-transaction scenario 3', solve([[['start', 'a', 'x'], ['update', 'b', 'oops']]] * N), [[[], 'a', 'x', 0]] * N)
check('composition-transaction scenario 4', solve([[['start', 'a', 'x'], ['commit', 'a', 'word'], ['commit', 'a', 'word']]] * N), [[['word'], None, '', 0]] * N)
check('composition-transaction scenario 5', solve([[['commit', 'x', 'orphan']]] * N), [[[], None, '', 0]] * N)
check('composition-transaction scenario 6', solve([[['start', 'a', 'x'], ['commit', 'b', 'bad']]] * N), [[[], 'a', 'x', 0]] * N)
check('composition-transaction scenario 7', solve([[['start', 'a', 'x'], ['cancel', 'b', '']]] * N), [[[], 'a', 'x', 0]] * N)
check('composition-transaction scenario 8', solve([[['start', 'a', 'x'], ['cancel', 'a', '']]] * N), [[[], None, '', 0]] * N)
check('composition-transaction scenario 9', solve([[['start', 'a', 'x'], ['focus', 'b', '']]] * N), [[[], None, '', 0]] * N)
check('composition-transaction scenario 10', solve([[['start', 'a', 'x'], ['focus', 'a', '']]] * N), [[[], 'a', 'x', 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):
        owner=None; preedit=''; committed=[]; updates=0
        for kind,target,text in c:
            if kind=='start':
                owner=target
                preedit=text
            elif kind=='update' and target==owner:
                preedit=text
                updates+=1
            elif kind=='commit' and target==owner and owner is not None:
                committed.append(text)
                owner=None
                preedit=''
            elif kind=='cancel' and target!=owner:
                owner=None; preedit=''
            elif kind=='focus' and target!=owner:
                owner=None; preedit=''
        return [committed,owner,preedit,updates]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-transaction scenario 0', solve([[]] * N), [[[], None, '', 0]] * N)
check('composition-transaction scenario 1', solve([[['start', 'a', 'x'], ['update', 'a', 'xy'], ['update', 'a', 'xyz']]] * N), [[[], 'a', 'xyz', 2]] * N)
check('composition-transaction scenario 2', solve([[['start', 'a', 'x'], ['start', 'b', 'b']]] * N), [[[], 'b', 'b', 0]] * N)
check('composition-transaction scenario 3', solve([[['start', 'a', 'x'], ['update', 'b', 'oops']]] * N), [[[], 'a', 'x', 0]] * N)
check('composition-transaction scenario 4', solve([[['start', 'a', 'x'], ['commit', 'a', 'word'], ['commit', 'a', 'word']]] * N), [[['word'], None, '', 0]] * N)
check('composition-transaction scenario 5', solve([[['commit', 'x', 'orphan']]] * N), [[[], None, '', 0]] * N)
check('composition-transaction scenario 6', solve([[['start', 'a', 'x'], ['commit', 'b', 'bad']]] * N), [[[], 'a', 'x', 0]] * N)
check('composition-transaction scenario 7', solve([[['start', 'a', 'x'], ['cancel', 'b', '']]] * N), [[[], 'a', 'x', 0]] * N)
check('composition-transaction scenario 8', solve([[['start', 'a', 'x'], ['cancel', 'a', '']]] * N), [[[], None, '', 0]] * N)
check('composition-transaction scenario 9', solve([[['start', 'a', 'x'], ['focus', 'b', '']]] * N), [[[], None, '', 0]] * N)
check('composition-transaction scenario 10', solve([[['start', 'a', 'x'], ['focus', 'a', '']]] * N), [[[], 'a', 'x', 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 cancel match rule and produces incorrect keyboard state or command output.

Events [kind,owner,text]. Start replaces active preedit, update applies only to active owner, commit appends supplied text once for active owner and closes, cancel closes matching owner without committing, focus switches cancel old owner. Return committed strings, active owner and preedit. 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):
        owner=None; preedit=''; committed=[]; updates=0
        for kind,target,text in c:
            if kind=='start':
                owner=target
                preedit=text
            elif kind=='update' and target==owner:
                preedit=text
                updates+=1
            elif kind=='commit' and target==owner and owner is not None:
                committed.append(text)
                owner=None
                preedit=''
            elif kind=='cancel' and target==owner:
                owner=None; preedit=''
            elif kind=='focus' and target==owner:
                owner=None; preedit=''
        return [committed,owner,preedit,updates]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-transaction scenario 0', solve([[]] * N), [[[], None, '', 0]] * N)
check('composition-transaction scenario 1', solve([[['start', 'a', 'x'], ['update', 'a', 'xy'], ['update', 'a', 'xyz']]] * N), [[[], 'a', 'xyz', 2]] * N)
check('composition-transaction scenario 2', solve([[['start', 'a', 'x'], ['start', 'b', 'b']]] * N), [[[], 'b', 'b', 0]] * N)
check('composition-transaction scenario 3', solve([[['start', 'a', 'x'], ['update', 'b', 'oops']]] * N), [[[], 'a', 'x', 0]] * N)
check('composition-transaction scenario 4', solve([[['start', 'a', 'x'], ['commit', 'a', 'word'], ['commit', 'a', 'word']]] * N), [[['word'], None, '', 0]] * N)
check('composition-transaction scenario 5', solve([[['commit', 'x', 'orphan']]] * N), [[[], None, '', 0]] * N)
check('composition-transaction scenario 6', solve([[['start', 'a', 'x'], ['commit', 'b', 'bad']]] * N), [[[], 'a', 'x', 0]] * N)
check('composition-transaction scenario 7', solve([[['start', 'a', 'x'], ['cancel', 'b', '']]] * N), [[[], 'a', 'x', 0]] * N)
check('composition-transaction scenario 8', solve([[['start', 'a', 'x'], ['cancel', 'a', '']]] * N), [[[], None, '', 0]] * N)
check('composition-transaction scenario 9', solve([[['start', 'a', 'x'], ['focus', 'b', '']]] * N), [[[], None, '', 0]] * N)
check('composition-transaction scenario 10', solve([[['start', 'a', 'x'], ['focus', 'a', '']]] * N), [[[], 'a', 'x', 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)

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):
        owner=None; preedit=''; committed=[]; updates=0
        for kind,target,text in c:
            if kind=='start':
                owner=target
                preedit=text
            elif kind=='update' and target==owner:
                preedit=text
                updates+=1
            elif kind=='commit' and target==owner and owner is not None:
                committed.append(text)
                owner=None
                preedit=''
            elif kind=='cancel' and target==owner:
                owner=None; preedit=''
            elif kind=='focus' and target is None:
                owner=None; preedit=''
        return [committed,owner,preedit,updates]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-transaction scenario 0', solve([[]] * N), [[[], None, '', 0]] * N)
check('composition-transaction scenario 1', solve([[['start', 'a', 'x'], ['update', 'a', 'xy'], ['update', 'a', 'xyz']]] * N), [[[], 'a', 'xyz', 2]] * N)
check('composition-transaction scenario 2', solve([[['start', 'a', 'x'], ['start', 'b', 'b']]] * N), [[[], 'b', 'b', 0]] * N)
check('composition-transaction scenario 3', solve([[['start', 'a', 'x'], ['update', 'b', 'oops']]] * N), [[[], 'a', 'x', 0]] * N)
check('composition-transaction scenario 4', solve([[['start', 'a', 'x'], ['commit', 'a', 'word'], ['commit', 'a', 'word']]] * N), [[['word'], None, '', 0]] * N)
check('composition-transaction scenario 5', solve([[['commit', 'x', 'orphan']]] * N), [[[], None, '', 0]] * N)
check('composition-transaction scenario 6', solve([[['start', 'a', 'x'], ['commit', 'b', 'bad']]] * N), [[[], 'a', 'x', 0]] * N)
check('composition-transaction scenario 7', solve([[['start', 'a', 'x'], ['cancel', 'b', '']]] * N), [[[], 'a', 'x', 0]] * N)
check('composition-transaction scenario 8', solve([[['start', 'a', 'x'], ['cancel', 'a', '']]] * N), [[[], None, '', 0]] * N)
check('composition-transaction scenario 9', solve([[['start', 'a', 'x'], ['focus', 'b', '']]] * N), [[[], None, '', 0]] * N)
check('composition-transaction scenario 10', solve([[['start', 'a', 'x'], ['focus', 'a', '']]] * N), [[[], 'a', 'x', 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 focus invalidation rule and produces incorrect keyboard state or command output.

Events [kind,owner,text]. Start replaces active preedit, update applies only to active owner, commit appends supplied text once for active owner and closes, cancel closes matching owner without committing, focus switches cancel old owner. Return committed strings, active owner and preedit. 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held.symmetric_difference_update({key})
            elif kind=='up': held.discard(key)
            elif kind=='cancel': held.clear()
            complete=bool(required) and held==set(required)
            if complete and armed and kind=='down':
                fires+=1
                last=key
                armed=False
            elif not complete:
                armed=True
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held={key}
            elif kind=='up': held.discard(key)
            elif kind=='cancel': held.clear()
            complete=bool(required) and held==set(required)
            if complete and armed and kind=='down':
                fires+=1
                last=key
                armed=False
            elif not complete:
                armed=True
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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 down set rule and produces incorrect keyboard state or command output.

Case is [required_keys, events]. Down/up update held keys; cancel clears state. A chord fires on the first transition from incomplete to all required keys held, with no extra keys. It rearms after becoming incomplete. Empty chord never fires. Return fire count, sorted held, armed state, last triggering key and current completeness. 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held.add(key)
            elif kind=='up': held.clear()
            elif kind=='cancel': held.clear()
            complete=bool(required) and held==set(required)
            if complete and armed and kind=='down':
                fires+=1
                last=key
                armed=False
            elif not complete:
                armed=True
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held.add(key)
            elif kind=='up': held.add(key)
            elif kind=='cancel': held.clear()
            complete=bool(required) and held==set(required)
            if complete and armed and kind=='down':
                fires+=1
                last=key
                armed=False
            elif not complete:
                armed=True
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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 up removal rule and produces incorrect keyboard state or command output.

Case is [required_keys, events]. Down/up update held keys; cancel clears state. A chord fires on the first transition from incomplete to all required keys held, with no extra keys. It rearms after becoming incomplete. Empty chord never fires. Return fire count, sorted held, armed state, last triggering key and current completeness. 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held.add(key)
            elif kind=='up': held.discard(key)
            elif kind=='cancel': pass
            complete=bool(required) and held==set(required)
            if complete and armed and kind=='down':
                fires+=1
                last=key
                armed=False
            elif not complete:
                armed=True
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held.add(key)
            elif kind=='up': held.discard(key)
            elif kind=='cancel': held.discard(key)
            complete=bool(required) and held==set(required)
            if complete and armed and kind=='down':
                fires+=1
                last=key
                armed=False
            elif not complete:
                armed=True
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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 reset rule and produces incorrect keyboard state or command output.

Case is [required_keys, events]. Down/up update held keys; cancel clears state. A chord fires on the first transition from incomplete to all required keys held, with no extra keys. It rearms after becoming incomplete. Empty chord never fires. Return fire count, sorted held, armed state, last triggering key and current completeness. 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held.add(key)
            elif kind=='up': held.discard(key)
            elif kind=='cancel': held.clear()
            complete=held==set(required)
            if complete and armed and kind=='down':
                fires+=1
                last=key
                armed=False
            elif not complete:
                armed=True
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held.add(key)
            elif kind=='up': held.discard(key)
            elif kind=='cancel': held.clear()
            complete=(not required) or held==set(required)
            if complete and armed and kind=='down':
                fires+=1
                last=key
                armed=False
            elif not complete:
                armed=True
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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 empty chord rule and produces incorrect keyboard state or command output.

Case is [required_keys, events]. Down/up update held keys; cancel clears state. A chord fires on the first transition from incomplete to all required keys held, with no extra keys. It rearms after becoming incomplete. Empty chord never fires. Return fire count, sorted held, armed state, last triggering key and current completeness. 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held.add(key)
            elif kind=='up': held.discard(key)
            elif kind=='cancel': held.clear()
            complete=bool(required) and set(required).issubset(held)
            if complete and armed and kind=='down':
                fires+=1
                last=key
                armed=False
            elif not complete:
                armed=True
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held.add(key)
            elif kind=='up': held.discard(key)
            elif kind=='cancel': held.clear()
            complete=bool(required) and bool(held & set(required))
            if complete and armed and kind=='down':
                fires+=1
                last=key
                armed=False
            elif not complete:
                armed=True
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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 extra key rule and produces incorrect keyboard state or command output.

Case is [required_keys, events]. Down/up update held keys; cancel clears state. A chord fires on the first transition from incomplete to all required keys held, with no extra keys. It rearms after becoming incomplete. Empty chord never fires. Return fire count, sorted held, armed state, last triggering key and current completeness. 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held.add(key)
            elif kind=='up': held.discard(key)
            elif kind=='cancel': held.clear()
            complete=bool(required) and held==set(required)
            if complete and kind=='down':
                fires+=1
                last=key
                armed=False
            elif not complete:
                armed=True
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held.add(key)
            elif kind=='up': held.discard(key)
            elif kind=='cancel': held.clear()
            complete=bool(required) and held==set(required)
            if complete and (armed or key in held) and kind=='down':
                fires+=1
                last=key
                armed=False
            elif not complete:
                armed=True
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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 edge latch rule and produces incorrect keyboard state or command output.

Case is [required_keys, events]. Down/up update held keys; cancel clears state. A chord fires on the first transition from incomplete to all required keys held, with no extra keys. It rearms after becoming incomplete. Empty chord never fires. Return fire count, sorted held, armed state, last triggering key and current completeness. 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held.add(key)
            elif kind=='up': held.discard(key)
            elif kind=='cancel': held.clear()
            complete=bool(required) and held==set(required)
            if complete and armed :
                fires+=1
                last=key
                armed=False
            elif not complete:
                armed=True
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held.add(key)
            elif kind=='up': held.discard(key)
            elif kind=='cancel': held.clear()
            complete=bool(required) and held==set(required)
            if complete and armed and kind!='cancel':
                fires+=1
                last=key
                armed=False
            elif not complete:
                armed=True
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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 event phase rule and produces incorrect keyboard state or command output.

Case is [required_keys, events]. Down/up update held keys; cancel clears state. A chord fires on the first transition from incomplete to all required keys held, with no extra keys. It rearms after becoming incomplete. Empty chord never fires. Return fire count, sorted held, armed state, last triggering key and current completeness. 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held.add(key)
            elif kind=='up': held.discard(key)
            elif kind=='cancel': held.clear()
            complete=bool(required) and held==set(required)
            if complete and armed and kind=='down':
                fires=1
                last=key
                armed=False
            elif not complete:
                armed=True
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held.add(key)
            elif kind=='up': held.discard(key)
            elif kind=='cancel': held.clear()
            complete=bool(required) and held==set(required)
            if complete and armed and kind=='down':
                fires+=len(required)
                last=key
                armed=False
            elif not complete:
                armed=True
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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 fire counter rule and produces incorrect keyboard state or command output.

Case is [required_keys, events]. Down/up update held keys; cancel clears state. A chord fires on the first transition from incomplete to all required keys held, with no extra keys. It rearms after becoming incomplete. Empty chord never fires. Return fire count, sorted held, armed state, last triggering key and current completeness. 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held.add(key)
            elif kind=='up': held.discard(key)
            elif kind=='cancel': held.clear()
            complete=bool(required) and held==set(required)
            if complete and armed and kind=='down':
                fires+=1
                last=None
                armed=False
            elif not complete:
                armed=True
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held.add(key)
            elif kind=='up': held.discard(key)
            elif kind=='cancel': held.clear()
            complete=bool(required) and held==set(required)
            if complete and armed and kind=='down':
                fires+=1
                last=sorted(held)[0]
                armed=False
            elif not complete:
                armed=True
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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 trigger key rule and produces incorrect keyboard state or command output.

Case is [required_keys, events]. Down/up update held keys; cancel clears state. A chord fires on the first transition from incomplete to all required keys held, with no extra keys. It rearms after becoming incomplete. Empty chord never fires. Return fire count, sorted held, armed state, last triggering key and current completeness. 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held.add(key)
            elif kind=='up': held.discard(key)
            elif kind=='cancel': held.clear()
            complete=bool(required) and held==set(required)
            if complete and armed and kind=='down':
                fires+=1
                last=key
                armed=False
            elif not complete:
                armed=False
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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):
        required,events=c
        held=set(); armed=True; fires=0; last=None; complete=False
        for kind,key in events:
            if kind=='down': held.add(key)
            elif kind=='up': held.discard(key)
            elif kind=='cancel': held.clear()
            complete=bool(required) and held==set(required)
            if complete and armed and kind=='down':
                fires+=1
                last=key
                armed=False
            elif not complete and not held:
                armed=True
        return [fires,sorted(held),armed,last,complete]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('simultaneous-chord scenario 0', solve([[[], []]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 1', solve([[[], [['down', 'x'], ['up', 'x'], ['down', 'x'], ['up', 'x']]]] * N), [[0, [], True, None, False]] * N)
check('simultaneous-chord scenario 2', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 3', solve([[['A', 'B'], [['down', 'A'], ['down', 'B'], ['up', 'B'], ['down', 'B']]]] * N), [[2, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 4', solve([[['A', 'B'], [['down', 'A'], ['down', 'X'], ['down', 'B'], ['up', 'X']]]] * N), [[0, ['A', 'B'], True, None, True]] * N)
check('simultaneous-chord scenario 5', solve([[['A', 'B'], [['down', 'A'], ['cancel', ''], ['down', 'B']]]] * N), [[0, ['B'], True, None, False]] * N)
check('simultaneous-chord scenario 6', solve([[['A', 'B'], [['down', 'A'], ['up', 'X'], ['down', 'B']]]] * N), [[1, ['A', 'B'], False, 'B', True]] * N)
check('simultaneous-chord scenario 7', solve([[['A'], [['down', 'A'], ['up', 'A'], ['down', 'A']]]] * N), [[2, ['A'], False, 'A', True]] * N)
check('simultaneous-chord scenario 8', solve([[['A', 'B'], [['down', 'B'], ['down', 'A']]]] * N), [[1, ['A', 'B'], False, 'A', True]] * 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 rearm rule and produces incorrect keyboard state or command output.

Case is [required_keys, events]. Down/up update held keys; cancel clears state. A chord fires on the first transition from incomplete to all required keys held, with no extra keys. It rearms after becoming incomplete. Empty chord never fires. Return fire count, sorted held, armed state, last triggering key and current completeness. 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):
        pending={}; emitted=[]; cancelled=0; unmatched=0
        for kind,key,owner in c:
            if kind=='down':
                pending[key]=owner
            elif kind=='up':
                if key in pending and pending[key]==owner:
                    emitted.append([key,owner])
                else: unmatched+=1
                pending.pop(key,None)
            elif kind=='cancel':
                cancelled+=len(pending)
                pending.clear()
            elif kind=='owner-left':
                dropped=[k for k,v in pending.items() if v==owner]
                cancelled+=len(dropped)
                for k in dropped: pending.pop(k)
        return [emitted,sorted([[k,v] for k,v in pending.items()]),cancelled,unmatched]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('release-binding scenario 0', solve([[]] * N), [[[], [], 0, 0]] * N)
check('release-binding scenario 1', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 2', solve([[['up', 'A', 'one'], ['up', 'B', 'one']]] * N), [[[], [], 0, 2]] * N)
check('release-binding scenario 3', solve([[['down', 'A', 'one'], ['down', 'A', 'two'], ['up', 'A', 'two']]] * N), [[[], [], 0, 1]] * N)
check('release-binding scenario 4', solve([[['down', 'A', 'one'], ['up', 'A', 'one'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [], 0, 1]] * N)
check('release-binding scenario 5', solve([[['down', 'A', 'one'], ['down', 'B', 'two'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [['B', 'two']], 0, 0]] * N)
check('release-binding scenario 6', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', ''], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 7', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['down', 'C', 'two'], ['owner-left', '', 'one']]] * N), [[[], [['C', 'two']], 2, 0]] * N)
check('release-binding scenario 8', solve([[['down', 'A', 'one'], ['owner-left', '', 'two']]] * N), [[[], [['A', 'one']], 0, 0]] * N)
check('release-binding scenario 9', solve([[['down', 'A', 'one'], ['cancel', '', ''], ['down', 'B', 'two'], ['cancel', '', '']]] * N), [[[], [], 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):
        pending={}; emitted=[]; cancelled=0; unmatched=0
        for kind,key,owner in c:
            if kind=='down':
                if key in pending: pending[key]=owner
            elif kind=='up':
                if key in pending and pending[key]==owner:
                    emitted.append([key,owner])
                else: unmatched+=1
                pending.pop(key,None)
            elif kind=='cancel':
                cancelled+=len(pending)
                pending.clear()
            elif kind=='owner-left':
                dropped=[k for k,v in pending.items() if v==owner]
                cancelled+=len(dropped)
                for k in dropped: pending.pop(k)
        return [emitted,sorted([[k,v] for k,v in pending.items()]),cancelled,unmatched]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('release-binding scenario 0', solve([[]] * N), [[[], [], 0, 0]] * N)
check('release-binding scenario 1', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 2', solve([[['up', 'A', 'one'], ['up', 'B', 'one']]] * N), [[[], [], 0, 2]] * N)
check('release-binding scenario 3', solve([[['down', 'A', 'one'], ['down', 'A', 'two'], ['up', 'A', 'two']]] * N), [[[], [], 0, 1]] * N)
check('release-binding scenario 4', solve([[['down', 'A', 'one'], ['up', 'A', 'one'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [], 0, 1]] * N)
check('release-binding scenario 5', solve([[['down', 'A', 'one'], ['down', 'B', 'two'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [['B', 'two']], 0, 0]] * N)
check('release-binding scenario 6', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', ''], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 7', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['down', 'C', 'two'], ['owner-left', '', 'one']]] * N), [[[], [['C', 'two']], 2, 0]] * N)
check('release-binding scenario 8', solve([[['down', 'A', 'one'], ['owner-left', '', 'two']]] * N), [[[], [['A', 'one']], 0, 0]] * N)
check('release-binding scenario 9', solve([[['down', 'A', 'one'], ['cancel', '', ''], ['down', 'B', 'two'], ['cancel', '', '']]] * N), [[[], [], 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 repeat owner rule and produces incorrect keyboard state or command output.

Events [kind,key,owner]. Down arms a key for its owner; repeated down preserves the original owner. Up emits key only for matching key and owner then always disarms that physical key. Cancel clears all pending keys; owner-left clears that owner. Return emitted key-owner pairs and sorted pending pairs. 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):
        pending={}; emitted=[]; cancelled=0; unmatched=0
        for kind,key,owner in c:
            if kind=='down':
                if key not in pending: pending[key]=owner
            elif kind=='up':
                if key in pending:
                    emitted.append([key,owner])
                else: unmatched+=1
                pending.pop(key,None)
            elif kind=='cancel':
                cancelled+=len(pending)
                pending.clear()
            elif kind=='owner-left':
                dropped=[k for k,v in pending.items() if v==owner]
                cancelled+=len(dropped)
                for k in dropped: pending.pop(k)
        return [emitted,sorted([[k,v] for k,v in pending.items()]),cancelled,unmatched]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('release-binding scenario 0', solve([[]] * N), [[[], [], 0, 0]] * N)
check('release-binding scenario 1', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 2', solve([[['up', 'A', 'one'], ['up', 'B', 'one']]] * N), [[[], [], 0, 2]] * N)
check('release-binding scenario 3', solve([[['down', 'A', 'one'], ['down', 'A', 'two'], ['up', 'A', 'two']]] * N), [[[], [], 0, 1]] * N)
check('release-binding scenario 4', solve([[['down', 'A', 'one'], ['up', 'A', 'one'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [], 0, 1]] * N)
check('release-binding scenario 5', solve([[['down', 'A', 'one'], ['down', 'B', 'two'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [['B', 'two']], 0, 0]] * N)
check('release-binding scenario 6', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', ''], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 7', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['down', 'C', 'two'], ['owner-left', '', 'one']]] * N), [[[], [['C', 'two']], 2, 0]] * N)
check('release-binding scenario 8', solve([[['down', 'A', 'one'], ['owner-left', '', 'two']]] * N), [[[], [['A', 'one']], 0, 0]] * N)
check('release-binding scenario 9', solve([[['down', 'A', 'one'], ['cancel', '', ''], ['down', 'B', 'two'], ['cancel', '', '']]] * N), [[[], [], 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):
        pending={}; emitted=[]; cancelled=0; unmatched=0
        for kind,key,owner in c:
            if kind=='down':
                if key not in pending: pending[key]=owner
            elif kind=='up':
                if key in pending and pending[key]!=owner:
                    emitted.append([key,owner])
                else: unmatched+=1
                pending.pop(key,None)
            elif kind=='cancel':
                cancelled+=len(pending)
                pending.clear()
            elif kind=='owner-left':
                dropped=[k for k,v in pending.items() if v==owner]
                cancelled+=len(dropped)
                for k in dropped: pending.pop(k)
        return [emitted,sorted([[k,v] for k,v in pending.items()]),cancelled,unmatched]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('release-binding scenario 0', solve([[]] * N), [[[], [], 0, 0]] * N)
check('release-binding scenario 1', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 2', solve([[['up', 'A', 'one'], ['up', 'B', 'one']]] * N), [[[], [], 0, 2]] * N)
check('release-binding scenario 3', solve([[['down', 'A', 'one'], ['down', 'A', 'two'], ['up', 'A', 'two']]] * N), [[[], [], 0, 1]] * N)
check('release-binding scenario 4', solve([[['down', 'A', 'one'], ['up', 'A', 'one'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [], 0, 1]] * N)
check('release-binding scenario 5', solve([[['down', 'A', 'one'], ['down', 'B', 'two'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [['B', 'two']], 0, 0]] * N)
check('release-binding scenario 6', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', ''], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 7', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['down', 'C', 'two'], ['owner-left', '', 'one']]] * N), [[[], [['C', 'two']], 2, 0]] * N)
check('release-binding scenario 8', solve([[['down', 'A', 'one'], ['owner-left', '', 'two']]] * N), [[[], [['A', 'one']], 0, 0]] * N)
check('release-binding scenario 9', solve([[['down', 'A', 'one'], ['cancel', '', ''], ['down', 'B', 'two'], ['cancel', '', '']]] * N), [[[], [], 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 up owner rule and produces incorrect keyboard state or command output.

Events [kind,key,owner]. Down arms a key for its owner; repeated down preserves the original owner. Up emits key only for matching key and owner then always disarms that physical key. Cancel clears all pending keys; owner-left clears that owner. Return emitted key-owner pairs and sorted pending pairs. 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):
        pending={}; emitted=[]; cancelled=0; unmatched=0
        for kind,key,owner in c:
            if kind=='down':
                if key not in pending: pending[key]=owner
            elif kind=='up':
                if key in pending and pending[key]==owner:
                    emitted.append([owner,key])
                else: unmatched+=1
                pending.pop(key,None)
            elif kind=='cancel':
                cancelled+=len(pending)
                pending.clear()
            elif kind=='owner-left':
                dropped=[k for k,v in pending.items() if v==owner]
                cancelled+=len(dropped)
                for k in dropped: pending.pop(k)
        return [emitted,sorted([[k,v] for k,v in pending.items()]),cancelled,unmatched]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('release-binding scenario 0', solve([[]] * N), [[[], [], 0, 0]] * N)
check('release-binding scenario 1', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 2', solve([[['up', 'A', 'one'], ['up', 'B', 'one']]] * N), [[[], [], 0, 2]] * N)
check('release-binding scenario 3', solve([[['down', 'A', 'one'], ['down', 'A', 'two'], ['up', 'A', 'two']]] * N), [[[], [], 0, 1]] * N)
check('release-binding scenario 4', solve([[['down', 'A', 'one'], ['up', 'A', 'one'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [], 0, 1]] * N)
check('release-binding scenario 5', solve([[['down', 'A', 'one'], ['down', 'B', 'two'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [['B', 'two']], 0, 0]] * N)
check('release-binding scenario 6', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', ''], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 7', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['down', 'C', 'two'], ['owner-left', '', 'one']]] * N), [[[], [['C', 'two']], 2, 0]] * N)
check('release-binding scenario 8', solve([[['down', 'A', 'one'], ['owner-left', '', 'two']]] * N), [[[], [['A', 'one']], 0, 0]] * N)
check('release-binding scenario 9', solve([[['down', 'A', 'one'], ['cancel', '', ''], ['down', 'B', 'two'], ['cancel', '', '']]] * N), [[[], [], 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):
        pending={}; emitted=[]; cancelled=0; unmatched=0
        for kind,key,owner in c:
            if kind=='down':
                if key not in pending: pending[key]=owner
            elif kind=='up':
                if key in pending and pending[key]==owner:
                    emitted.append([key,key])
                else: unmatched+=1
                pending.pop(key,None)
            elif kind=='cancel':
                cancelled+=len(pending)
                pending.clear()
            elif kind=='owner-left':
                dropped=[k for k,v in pending.items() if v==owner]
                cancelled+=len(dropped)
                for k in dropped: pending.pop(k)
        return [emitted,sorted([[k,v] for k,v in pending.items()]),cancelled,unmatched]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('release-binding scenario 0', solve([[]] * N), [[[], [], 0, 0]] * N)
check('release-binding scenario 1', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 2', solve([[['up', 'A', 'one'], ['up', 'B', 'one']]] * N), [[[], [], 0, 2]] * N)
check('release-binding scenario 3', solve([[['down', 'A', 'one'], ['down', 'A', 'two'], ['up', 'A', 'two']]] * N), [[[], [], 0, 1]] * N)
check('release-binding scenario 4', solve([[['down', 'A', 'one'], ['up', 'A', 'one'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [], 0, 1]] * N)
check('release-binding scenario 5', solve([[['down', 'A', 'one'], ['down', 'B', 'two'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [['B', 'two']], 0, 0]] * N)
check('release-binding scenario 6', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', ''], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 7', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['down', 'C', 'two'], ['owner-left', '', 'one']]] * N), [[[], [['C', 'two']], 2, 0]] * N)
check('release-binding scenario 8', solve([[['down', 'A', 'one'], ['owner-left', '', 'two']]] * N), [[[], [['A', 'one']], 0, 0]] * N)
check('release-binding scenario 9', solve([[['down', 'A', 'one'], ['cancel', '', ''], ['down', 'B', 'two'], ['cancel', '', '']]] * N), [[[], [], 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 emission pair rule and produces incorrect keyboard state or command output.

Events [kind,key,owner]. Down arms a key for its owner; repeated down preserves the original owner. Up emits key only for matching key and owner then always disarms that physical key. Cancel clears all pending keys; owner-left clears that owner. Return emitted key-owner pairs and sorted pending pairs. 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):
        pending={}; emitted=[]; cancelled=0; unmatched=0
        for kind,key,owner in c:
            if kind=='down':
                if key not in pending: pending[key]=owner
            elif kind=='up':
                if key in pending and pending[key]==owner:
                    emitted.append([key,owner])
                else: unmatched=1
                pending.pop(key,None)
            elif kind=='cancel':
                cancelled+=len(pending)
                pending.clear()
            elif kind=='owner-left':
                dropped=[k for k,v in pending.items() if v==owner]
                cancelled+=len(dropped)
                for k in dropped: pending.pop(k)
        return [emitted,sorted([[k,v] for k,v in pending.items()]),cancelled,unmatched]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('release-binding scenario 0', solve([[]] * N), [[[], [], 0, 0]] * N)
check('release-binding scenario 1', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 2', solve([[['up', 'A', 'one'], ['up', 'B', 'one']]] * N), [[[], [], 0, 2]] * N)
check('release-binding scenario 3', solve([[['down', 'A', 'one'], ['down', 'A', 'two'], ['up', 'A', 'two']]] * N), [[[], [], 0, 1]] * N)
check('release-binding scenario 4', solve([[['down', 'A', 'one'], ['up', 'A', 'one'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [], 0, 1]] * N)
check('release-binding scenario 5', solve([[['down', 'A', 'one'], ['down', 'B', 'two'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [['B', 'two']], 0, 0]] * N)
check('release-binding scenario 6', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', ''], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 7', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['down', 'C', 'two'], ['owner-left', '', 'one']]] * N), [[[], [['C', 'two']], 2, 0]] * N)
check('release-binding scenario 8', solve([[['down', 'A', 'one'], ['owner-left', '', 'two']]] * N), [[[], [['A', 'one']], 0, 0]] * N)
check('release-binding scenario 9', solve([[['down', 'A', 'one'], ['cancel', '', ''], ['down', 'B', 'two'], ['cancel', '', '']]] * N), [[[], [], 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):
        pending={}; emitted=[]; cancelled=0; unmatched=0
        for kind,key,owner in c:
            if kind=='down':
                if key not in pending: pending[key]=owner
            elif kind=='up':
                if key in pending and pending[key]==owner:
                    emitted.append([key,owner])
                else: unmatched+=len(pending)
                pending.pop(key,None)
            elif kind=='cancel':
                cancelled+=len(pending)
                pending.clear()
            elif kind=='owner-left':
                dropped=[k for k,v in pending.items() if v==owner]
                cancelled+=len(dropped)
                for k in dropped: pending.pop(k)
        return [emitted,sorted([[k,v] for k,v in pending.items()]),cancelled,unmatched]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('release-binding scenario 0', solve([[]] * N), [[[], [], 0, 0]] * N)
check('release-binding scenario 1', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 2', solve([[['up', 'A', 'one'], ['up', 'B', 'one']]] * N), [[[], [], 0, 2]] * N)
check('release-binding scenario 3', solve([[['down', 'A', 'one'], ['down', 'A', 'two'], ['up', 'A', 'two']]] * N), [[[], [], 0, 1]] * N)
check('release-binding scenario 4', solve([[['down', 'A', 'one'], ['up', 'A', 'one'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [], 0, 1]] * N)
check('release-binding scenario 5', solve([[['down', 'A', 'one'], ['down', 'B', 'two'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [['B', 'two']], 0, 0]] * N)
check('release-binding scenario 6', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', ''], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 7', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['down', 'C', 'two'], ['owner-left', '', 'one']]] * N), [[[], [['C', 'two']], 2, 0]] * N)
check('release-binding scenario 8', solve([[['down', 'A', 'one'], ['owner-left', '', 'two']]] * N), [[[], [['A', 'one']], 0, 0]] * N)
check('release-binding scenario 9', solve([[['down', 'A', 'one'], ['cancel', '', ''], ['down', 'B', 'two'], ['cancel', '', '']]] * N), [[[], [], 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 unmatched count rule and produces incorrect keyboard state or command output.

Events [kind,key,owner]. Down arms a key for its owner; repeated down preserves the original owner. Up emits key only for matching key and owner then always disarms that physical key. Cancel clears all pending keys; owner-left clears that owner. Return emitted key-owner pairs and sorted pending pairs. 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):
        pending={}; emitted=[]; cancelled=0; unmatched=0
        for kind,key,owner in c:
            if kind=='down':
                if key not in pending: pending[key]=owner
            elif kind=='up':
                if key in pending and pending[key]==owner:
                    emitted.append([key,owner])
                else: unmatched+=1
                pending.clear()
            elif kind=='cancel':
                cancelled+=len(pending)
                pending.clear()
            elif kind=='owner-left':
                dropped=[k for k,v in pending.items() if v==owner]
                cancelled+=len(dropped)
                for k in dropped: pending.pop(k)
        return [emitted,sorted([[k,v] for k,v in pending.items()]),cancelled,unmatched]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('release-binding scenario 0', solve([[]] * N), [[[], [], 0, 0]] * N)
check('release-binding scenario 1', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 2', solve([[['up', 'A', 'one'], ['up', 'B', 'one']]] * N), [[[], [], 0, 2]] * N)
check('release-binding scenario 3', solve([[['down', 'A', 'one'], ['down', 'A', 'two'], ['up', 'A', 'two']]] * N), [[[], [], 0, 1]] * N)
check('release-binding scenario 4', solve([[['down', 'A', 'one'], ['up', 'A', 'one'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [], 0, 1]] * N)
check('release-binding scenario 5', solve([[['down', 'A', 'one'], ['down', 'B', 'two'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [['B', 'two']], 0, 0]] * N)
check('release-binding scenario 6', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', ''], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 7', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['down', 'C', 'two'], ['owner-left', '', 'one']]] * N), [[[], [['C', 'two']], 2, 0]] * N)
check('release-binding scenario 8', solve([[['down', 'A', 'one'], ['owner-left', '', 'two']]] * N), [[[], [['A', 'one']], 0, 0]] * N)
check('release-binding scenario 9', solve([[['down', 'A', 'one'], ['cancel', '', ''], ['down', 'B', 'two'], ['cancel', '', '']]] * N), [[[], [], 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):
        pending={}; emitted=[]; cancelled=0; unmatched=0
        for kind,key,owner in c:
            if kind=='down':
                if key not in pending: pending[key]=owner
            elif kind=='up':
                if key in pending and pending[key]==owner:
                    emitted.append([key,owner])
                else: unmatched+=1
                pending.pop(owner,None)
            elif kind=='cancel':
                cancelled+=len(pending)
                pending.clear()
            elif kind=='owner-left':
                dropped=[k for k,v in pending.items() if v==owner]
                cancelled+=len(dropped)
                for k in dropped: pending.pop(k)
        return [emitted,sorted([[k,v] for k,v in pending.items()]),cancelled,unmatched]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('release-binding scenario 0', solve([[]] * N), [[[], [], 0, 0]] * N)
check('release-binding scenario 1', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 2', solve([[['up', 'A', 'one'], ['up', 'B', 'one']]] * N), [[[], [], 0, 2]] * N)
check('release-binding scenario 3', solve([[['down', 'A', 'one'], ['down', 'A', 'two'], ['up', 'A', 'two']]] * N), [[[], [], 0, 1]] * N)
check('release-binding scenario 4', solve([[['down', 'A', 'one'], ['up', 'A', 'one'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [], 0, 1]] * N)
check('release-binding scenario 5', solve([[['down', 'A', 'one'], ['down', 'B', 'two'], ['up', 'A', 'one']]] * N), [[[['A', 'one']], [['B', 'two']], 0, 0]] * N)
check('release-binding scenario 6', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['cancel', '', ''], ['cancel', '', '']]] * N), [[[], [], 2, 0]] * N)
check('release-binding scenario 7', solve([[['down', 'A', 'one'], ['down', 'B', 'one'], ['down', 'C', 'two'], ['owner-left', '', 'one']]] * N), [[[], [['C', 'two']], 2, 0]] * N)
check('release-binding scenario 8', solve([[['down', 'A', 'one'], ['owner-left', '', 'two']]] * N), [[[], [['A', 'one']], 0, 0]] * N)
check('release-binding scenario 9', solve([[['down', 'A', 'one'], ['cancel', '', ''], ['down', 'B', 'two'], ['cancel', '', '']]] * N), [[[], [], 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 up disarm rule and produces incorrect keyboard state or command output.

Events [kind,key,owner]. Down arms a key for its owner; repeated down preserves the original owner. Up emits key only for matching key and owner then always disarms that physical key. Cancel clears all pending keys; owner-left clears that owner. Return emitted key-owner pairs and sorted pending pairs. 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