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

N = 1
observations = []
def solve(cases):
    def run(c):
        held=set(); peak=0; presses=0; releases=0; orphan=0
        for kind,device,code,location in c:
            token=(device,code,0)
            if kind=='down':
                fresh=token not in held
                if fresh: presses+=1
                held.add(token)
                peak=max(peak,len(held))
            elif kind=='up':
                if token in held:
                    held.remove(token)
                    releases+=1
                else: orphan+=1
            elif kind=='disconnect':
                held={x for x in held if x[0]!=device}
            elif kind=='blur':
                held.clear()
        return [sorted([list(x) for x in held]),peak,presses,releases,orphan]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('physical-registry scenario 0', solve([[]] * N), [[[], 0, 0, 0, 0]] * N)
check('physical-registry scenario 1', solve([[['up', 'a', 'A', 0], ['up', 'a', 'B', 0]]] * N), [[[], 0, 0, 0, 2]] * N)
check('physical-registry scenario 2', solve([[['down', 'a', 'A', 0], ['down', 'a', 'A', 0], ['down', 'a', 'A', 0]]] * N), [[[['a', 'A', 0]], 1, 1, 0, 0]] * N)
check('physical-registry scenario 3', solve([[['down', 'a', 'A', 0], ['down', 'b', 'A', 0], ['up', 'a', 'A', 0]]] * N), [[[['b', 'A', 0]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 4', solve([[['down', 'a', 'S', 1], ['down', 'a', 'S', 3], ['up', 'a', 'S', 1]]] * N), [[[['a', 'S', 3]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 5', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 0], ['up', 'a', 'A', 0], ['down', 'a', 'C', 0], ['up', 'a', 'B', 0], ['up', 'a', 'C', 0], ['down', 'a', 'D', 0]]] * N), [[[['a', 'D', 0]], 2, 4, 3, 0]] * N)
check('physical-registry scenario 6', solve([[['down', 'a', 'A', 0], ['down', 'b', 'B', 0], ['disconnect', 'a', '', 0]]] * N), [[[['b', 'B', 0]], 2, 2, 0, 0]] * N)
check('physical-registry scenario 7', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 1], ['blur', '', '', 0]]] * N), [[[], 2, 2, 0, 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):
        held=set(); peak=0; presses=0; releases=0; orphan=0
        for kind,device,code,location in c:
            token=(device,code,location%2)
            if kind=='down':
                fresh=token not in held
                if fresh: presses+=1
                held.add(token)
                peak=max(peak,len(held))
            elif kind=='up':
                if token in held:
                    held.remove(token)
                    releases+=1
                else: orphan+=1
            elif kind=='disconnect':
                held={x for x in held if x[0]!=device}
            elif kind=='blur':
                held.clear()
        return [sorted([list(x) for x in held]),peak,presses,releases,orphan]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('physical-registry scenario 0', solve([[]] * N), [[[], 0, 0, 0, 0]] * N)
check('physical-registry scenario 1', solve([[['up', 'a', 'A', 0], ['up', 'a', 'B', 0]]] * N), [[[], 0, 0, 0, 2]] * N)
check('physical-registry scenario 2', solve([[['down', 'a', 'A', 0], ['down', 'a', 'A', 0], ['down', 'a', 'A', 0]]] * N), [[[['a', 'A', 0]], 1, 1, 0, 0]] * N)
check('physical-registry scenario 3', solve([[['down', 'a', 'A', 0], ['down', 'b', 'A', 0], ['up', 'a', 'A', 0]]] * N), [[[['b', 'A', 0]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 4', solve([[['down', 'a', 'S', 1], ['down', 'a', 'S', 3], ['up', 'a', 'S', 1]]] * N), [[[['a', 'S', 3]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 5', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 0], ['up', 'a', 'A', 0], ['down', 'a', 'C', 0], ['up', 'a', 'B', 0], ['up', 'a', 'C', 0], ['down', 'a', 'D', 0]]] * N), [[[['a', 'D', 0]], 2, 4, 3, 0]] * N)
check('physical-registry scenario 6', solve([[['down', 'a', 'A', 0], ['down', 'b', 'B', 0], ['disconnect', 'a', '', 0]]] * N), [[[['b', 'B', 0]], 2, 2, 0, 0]] * N)
check('physical-registry scenario 7', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 1], ['blur', '', '', 0]]] * N), [[[], 2, 2, 0, 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 location token rule and produces incorrect keyboard state or command output.

Events are [kind,device,code,location]. Down inserts a unique physical token; up removes exactly that token; disconnect clears that device; blur clears all. Track maximum simultaneous held count, accepted presses, releases, orphan ups and sorted held tokens. 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):
        held=set(); peak=0; presses=0; releases=0; orphan=0
        for kind,device,code,location in c:
            token=(device,code,location)
            if kind=='down':
                fresh=token not in held
                presses+=1
                held.add(token)
                peak=max(peak,len(held))
            elif kind=='up':
                if token in held:
                    held.remove(token)
                    releases+=1
                else: orphan+=1
            elif kind=='disconnect':
                held={x for x in held if x[0]!=device}
            elif kind=='blur':
                held.clear()
        return [sorted([list(x) for x in held]),peak,presses,releases,orphan]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('physical-registry scenario 0', solve([[]] * N), [[[], 0, 0, 0, 0]] * N)
check('physical-registry scenario 1', solve([[['up', 'a', 'A', 0], ['up', 'a', 'B', 0]]] * N), [[[], 0, 0, 0, 2]] * N)
check('physical-registry scenario 2', solve([[['down', 'a', 'A', 0], ['down', 'a', 'A', 0], ['down', 'a', 'A', 0]]] * N), [[[['a', 'A', 0]], 1, 1, 0, 0]] * N)
check('physical-registry scenario 3', solve([[['down', 'a', 'A', 0], ['down', 'b', 'A', 0], ['up', 'a', 'A', 0]]] * N), [[[['b', 'A', 0]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 4', solve([[['down', 'a', 'S', 1], ['down', 'a', 'S', 3], ['up', 'a', 'S', 1]]] * N), [[[['a', 'S', 3]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 5', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 0], ['up', 'a', 'A', 0], ['down', 'a', 'C', 0], ['up', 'a', 'B', 0], ['up', 'a', 'C', 0], ['down', 'a', 'D', 0]]] * N), [[[['a', 'D', 0]], 2, 4, 3, 0]] * N)
check('physical-registry scenario 6', solve([[['down', 'a', 'A', 0], ['down', 'b', 'B', 0], ['disconnect', 'a', '', 0]]] * N), [[[['b', 'B', 0]], 2, 2, 0, 0]] * N)
check('physical-registry scenario 7', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 1], ['blur', '', '', 0]]] * N), [[[], 2, 2, 0, 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):
        held=set(); peak=0; presses=0; releases=0; orphan=0
        for kind,device,code,location in c:
            token=(device,code,location)
            if kind=='down':
                fresh=token not in held
                if not fresh: presses+=1
                held.add(token)
                peak=max(peak,len(held))
            elif kind=='up':
                if token in held:
                    held.remove(token)
                    releases+=1
                else: orphan+=1
            elif kind=='disconnect':
                held={x for x in held if x[0]!=device}
            elif kind=='blur':
                held.clear()
        return [sorted([list(x) for x in held]),peak,presses,releases,orphan]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('physical-registry scenario 0', solve([[]] * N), [[[], 0, 0, 0, 0]] * N)
check('physical-registry scenario 1', solve([[['up', 'a', 'A', 0], ['up', 'a', 'B', 0]]] * N), [[[], 0, 0, 0, 2]] * N)
check('physical-registry scenario 2', solve([[['down', 'a', 'A', 0], ['down', 'a', 'A', 0], ['down', 'a', 'A', 0]]] * N), [[[['a', 'A', 0]], 1, 1, 0, 0]] * N)
check('physical-registry scenario 3', solve([[['down', 'a', 'A', 0], ['down', 'b', 'A', 0], ['up', 'a', 'A', 0]]] * N), [[[['b', 'A', 0]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 4', solve([[['down', 'a', 'S', 1], ['down', 'a', 'S', 3], ['up', 'a', 'S', 1]]] * N), [[[['a', 'S', 3]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 5', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 0], ['up', 'a', 'A', 0], ['down', 'a', 'C', 0], ['up', 'a', 'B', 0], ['up', 'a', 'C', 0], ['down', 'a', 'D', 0]]] * N), [[[['a', 'D', 0]], 2, 4, 3, 0]] * N)
check('physical-registry scenario 6', solve([[['down', 'a', 'A', 0], ['down', 'b', 'B', 0], ['disconnect', 'a', '', 0]]] * N), [[[['b', 'B', 0]], 2, 2, 0, 0]] * N)
check('physical-registry scenario 7', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 1], ['blur', '', '', 0]]] * N), [[[], 2, 2, 0, 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 accounting rule and produces incorrect keyboard state or command output.

Events are [kind,device,code,location]. Down inserts a unique physical token; up removes exactly that token; disconnect clears that device; blur clears all. Track maximum simultaneous held count, accepted presses, releases, orphan ups and sorted held tokens. 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):
        held=set(); peak=0; presses=0; releases=0; orphan=0
        for kind,device,code,location in c:
            token=(device,code,location)
            if kind=='down':
                fresh=token not in held
                if fresh: presses+=1
                held.discard(token)
                peak=max(peak,len(held))
            elif kind=='up':
                if token in held:
                    held.remove(token)
                    releases+=1
                else: orphan+=1
            elif kind=='disconnect':
                held={x for x in held if x[0]!=device}
            elif kind=='blur':
                held.clear()
        return [sorted([list(x) for x in held]),peak,presses,releases,orphan]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('physical-registry scenario 0', solve([[]] * N), [[[], 0, 0, 0, 0]] * N)
check('physical-registry scenario 1', solve([[['up', 'a', 'A', 0], ['up', 'a', 'B', 0]]] * N), [[[], 0, 0, 0, 2]] * N)
check('physical-registry scenario 2', solve([[['down', 'a', 'A', 0], ['down', 'a', 'A', 0], ['down', 'a', 'A', 0]]] * N), [[[['a', 'A', 0]], 1, 1, 0, 0]] * N)
check('physical-registry scenario 3', solve([[['down', 'a', 'A', 0], ['down', 'b', 'A', 0], ['up', 'a', 'A', 0]]] * N), [[[['b', 'A', 0]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 4', solve([[['down', 'a', 'S', 1], ['down', 'a', 'S', 3], ['up', 'a', 'S', 1]]] * N), [[[['a', 'S', 3]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 5', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 0], ['up', 'a', 'A', 0], ['down', 'a', 'C', 0], ['up', 'a', 'B', 0], ['up', 'a', 'C', 0], ['down', 'a', 'D', 0]]] * N), [[[['a', 'D', 0]], 2, 4, 3, 0]] * N)
check('physical-registry scenario 6', solve([[['down', 'a', 'A', 0], ['down', 'b', 'B', 0], ['disconnect', 'a', '', 0]]] * N), [[[['b', 'B', 0]], 2, 2, 0, 0]] * N)
check('physical-registry scenario 7', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 1], ['blur', '', '', 0]]] * N), [[[], 2, 2, 0, 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):
        held=set(); peak=0; presses=0; releases=0; orphan=0
        for kind,device,code,location in c:
            token=(device,code,location)
            if kind=='down':
                fresh=token not in held
                if fresh: presses+=1
                held.symmetric_difference_update({token})
                peak=max(peak,len(held))
            elif kind=='up':
                if token in held:
                    held.remove(token)
                    releases+=1
                else: orphan+=1
            elif kind=='disconnect':
                held={x for x in held if x[0]!=device}
            elif kind=='blur':
                held.clear()
        return [sorted([list(x) for x in held]),peak,presses,releases,orphan]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('physical-registry scenario 0', solve([[]] * N), [[[], 0, 0, 0, 0]] * N)
check('physical-registry scenario 1', solve([[['up', 'a', 'A', 0], ['up', 'a', 'B', 0]]] * N), [[[], 0, 0, 0, 2]] * N)
check('physical-registry scenario 2', solve([[['down', 'a', 'A', 0], ['down', 'a', 'A', 0], ['down', 'a', 'A', 0]]] * N), [[[['a', 'A', 0]], 1, 1, 0, 0]] * N)
check('physical-registry scenario 3', solve([[['down', 'a', 'A', 0], ['down', 'b', 'A', 0], ['up', 'a', 'A', 0]]] * N), [[[['b', 'A', 0]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 4', solve([[['down', 'a', 'S', 1], ['down', 'a', 'S', 3], ['up', 'a', 'S', 1]]] * N), [[[['a', 'S', 3]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 5', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 0], ['up', 'a', 'A', 0], ['down', 'a', 'C', 0], ['up', 'a', 'B', 0], ['up', 'a', 'C', 0], ['down', 'a', 'D', 0]]] * N), [[[['a', 'D', 0]], 2, 4, 3, 0]] * N)
check('physical-registry scenario 6', solve([[['down', 'a', 'A', 0], ['down', 'b', 'B', 0], ['disconnect', 'a', '', 0]]] * N), [[[['b', 'B', 0]], 2, 2, 0, 0]] * N)
check('physical-registry scenario 7', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 1], ['blur', '', '', 0]]] * N), [[[], 2, 2, 0, 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 insert press rule and produces incorrect keyboard state or command output.

Events are [kind,device,code,location]. Down inserts a unique physical token; up removes exactly that token; disconnect clears that device; blur clears all. Track maximum simultaneous held count, accepted presses, releases, orphan ups and sorted held tokens. 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):
        held=set(); peak=0; presses=0; releases=0; orphan=0
        for kind,device,code,location in c:
            token=(device,code,location)
            if kind=='down':
                fresh=token not in held
                if fresh: presses+=1
                held.add(token)
                peak=len(held)
            elif kind=='up':
                if token in held:
                    held.remove(token)
                    releases+=1
                else: orphan+=1
            elif kind=='disconnect':
                held={x for x in held if x[0]!=device}
            elif kind=='blur':
                held.clear()
        return [sorted([list(x) for x in held]),peak,presses,releases,orphan]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('physical-registry scenario 0', solve([[]] * N), [[[], 0, 0, 0, 0]] * N)
check('physical-registry scenario 1', solve([[['up', 'a', 'A', 0], ['up', 'a', 'B', 0]]] * N), [[[], 0, 0, 0, 2]] * N)
check('physical-registry scenario 2', solve([[['down', 'a', 'A', 0], ['down', 'a', 'A', 0], ['down', 'a', 'A', 0]]] * N), [[[['a', 'A', 0]], 1, 1, 0, 0]] * N)
check('physical-registry scenario 3', solve([[['down', 'a', 'A', 0], ['down', 'b', 'A', 0], ['up', 'a', 'A', 0]]] * N), [[[['b', 'A', 0]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 4', solve([[['down', 'a', 'S', 1], ['down', 'a', 'S', 3], ['up', 'a', 'S', 1]]] * N), [[[['a', 'S', 3]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 5', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 0], ['up', 'a', 'A', 0], ['down', 'a', 'C', 0], ['up', 'a', 'B', 0], ['up', 'a', 'C', 0], ['down', 'a', 'D', 0]]] * N), [[[['a', 'D', 0]], 2, 4, 3, 0]] * N)
check('physical-registry scenario 6', solve([[['down', 'a', 'A', 0], ['down', 'b', 'B', 0], ['disconnect', 'a', '', 0]]] * N), [[[['b', 'B', 0]], 2, 2, 0, 0]] * N)
check('physical-registry scenario 7', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 1], ['blur', '', '', 0]]] * N), [[[], 2, 2, 0, 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):
        held=set(); peak=0; presses=0; releases=0; orphan=0
        for kind,device,code,location in c:
            token=(device,code,location)
            if kind=='down':
                fresh=token not in held
                if fresh: presses+=1
                held.add(token)
                peak=max(peak,presses)
            elif kind=='up':
                if token in held:
                    held.remove(token)
                    releases+=1
                else: orphan+=1
            elif kind=='disconnect':
                held={x for x in held if x[0]!=device}
            elif kind=='blur':
                held.clear()
        return [sorted([list(x) for x in held]),peak,presses,releases,orphan]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('physical-registry scenario 0', solve([[]] * N), [[[], 0, 0, 0, 0]] * N)
check('physical-registry scenario 1', solve([[['up', 'a', 'A', 0], ['up', 'a', 'B', 0]]] * N), [[[], 0, 0, 0, 2]] * N)
check('physical-registry scenario 2', solve([[['down', 'a', 'A', 0], ['down', 'a', 'A', 0], ['down', 'a', 'A', 0]]] * N), [[[['a', 'A', 0]], 1, 1, 0, 0]] * N)
check('physical-registry scenario 3', solve([[['down', 'a', 'A', 0], ['down', 'b', 'A', 0], ['up', 'a', 'A', 0]]] * N), [[[['b', 'A', 0]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 4', solve([[['down', 'a', 'S', 1], ['down', 'a', 'S', 3], ['up', 'a', 'S', 1]]] * N), [[[['a', 'S', 3]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 5', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 0], ['up', 'a', 'A', 0], ['down', 'a', 'C', 0], ['up', 'a', 'B', 0], ['up', 'a', 'C', 0], ['down', 'a', 'D', 0]]] * N), [[[['a', 'D', 0]], 2, 4, 3, 0]] * N)
check('physical-registry scenario 6', solve([[['down', 'a', 'A', 0], ['down', 'b', 'B', 0], ['disconnect', 'a', '', 0]]] * N), [[[['b', 'B', 0]], 2, 2, 0, 0]] * N)
check('physical-registry scenario 7', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 1], ['blur', '', '', 0]]] * N), [[[], 2, 2, 0, 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 peak count rule and produces incorrect keyboard state or command output.

Events are [kind,device,code,location]. Down inserts a unique physical token; up removes exactly that token; disconnect clears that device; blur clears all. Track maximum simultaneous held count, accepted presses, releases, orphan ups and sorted held tokens. 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):
        held=set(); peak=0; presses=0; releases=0; orphan=0
        for kind,device,code,location in c:
            token=(device,code,location)
            if kind=='down':
                fresh=token not in held
                if fresh: presses+=1
                held.add(token)
                peak=max(peak,len(held))
            elif kind=='up':
                if token in held:
                    held.clear()
                    releases+=1
                else: orphan+=1
            elif kind=='disconnect':
                held={x for x in held if x[0]!=device}
            elif kind=='blur':
                held.clear()
        return [sorted([list(x) for x in held]),peak,presses,releases,orphan]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('physical-registry scenario 0', solve([[]] * N), [[[], 0, 0, 0, 0]] * N)
check('physical-registry scenario 1', solve([[['up', 'a', 'A', 0], ['up', 'a', 'B', 0]]] * N), [[[], 0, 0, 0, 2]] * N)
check('physical-registry scenario 2', solve([[['down', 'a', 'A', 0], ['down', 'a', 'A', 0], ['down', 'a', 'A', 0]]] * N), [[[['a', 'A', 0]], 1, 1, 0, 0]] * N)
check('physical-registry scenario 3', solve([[['down', 'a', 'A', 0], ['down', 'b', 'A', 0], ['up', 'a', 'A', 0]]] * N), [[[['b', 'A', 0]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 4', solve([[['down', 'a', 'S', 1], ['down', 'a', 'S', 3], ['up', 'a', 'S', 1]]] * N), [[[['a', 'S', 3]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 5', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 0], ['up', 'a', 'A', 0], ['down', 'a', 'C', 0], ['up', 'a', 'B', 0], ['up', 'a', 'C', 0], ['down', 'a', 'D', 0]]] * N), [[[['a', 'D', 0]], 2, 4, 3, 0]] * N)
check('physical-registry scenario 6', solve([[['down', 'a', 'A', 0], ['down', 'b', 'B', 0], ['disconnect', 'a', '', 0]]] * N), [[[['b', 'B', 0]], 2, 2, 0, 0]] * N)
check('physical-registry scenario 7', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 1], ['blur', '', '', 0]]] * N), [[[], 2, 2, 0, 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):
        held=set(); peak=0; presses=0; releases=0; orphan=0
        for kind,device,code,location in c:
            token=(device,code,location)
            if kind=='down':
                fresh=token not in held
                if fresh: presses+=1
                held.add(token)
                peak=max(peak,len(held))
            elif kind=='up':
                if token in held:
                    held={x for x in held if x[1]!=code}
                    releases+=1
                else: orphan+=1
            elif kind=='disconnect':
                held={x for x in held if x[0]!=device}
            elif kind=='blur':
                held.clear()
        return [sorted([list(x) for x in held]),peak,presses,releases,orphan]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('physical-registry scenario 0', solve([[]] * N), [[[], 0, 0, 0, 0]] * N)
check('physical-registry scenario 1', solve([[['up', 'a', 'A', 0], ['up', 'a', 'B', 0]]] * N), [[[], 0, 0, 0, 2]] * N)
check('physical-registry scenario 2', solve([[['down', 'a', 'A', 0], ['down', 'a', 'A', 0], ['down', 'a', 'A', 0]]] * N), [[[['a', 'A', 0]], 1, 1, 0, 0]] * N)
check('physical-registry scenario 3', solve([[['down', 'a', 'A', 0], ['down', 'b', 'A', 0], ['up', 'a', 'A', 0]]] * N), [[[['b', 'A', 0]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 4', solve([[['down', 'a', 'S', 1], ['down', 'a', 'S', 3], ['up', 'a', 'S', 1]]] * N), [[[['a', 'S', 3]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 5', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 0], ['up', 'a', 'A', 0], ['down', 'a', 'C', 0], ['up', 'a', 'B', 0], ['up', 'a', 'C', 0], ['down', 'a', 'D', 0]]] * N), [[[['a', 'D', 0]], 2, 4, 3, 0]] * N)
check('physical-registry scenario 6', solve([[['down', 'a', 'A', 0], ['down', 'b', 'B', 0], ['disconnect', 'a', '', 0]]] * N), [[[['b', 'B', 0]], 2, 2, 0, 0]] * N)
check('physical-registry scenario 7', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 1], ['blur', '', '', 0]]] * N), [[[], 2, 2, 0, 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 release identity rule and produces incorrect keyboard state or command output.

Events are [kind,device,code,location]. Down inserts a unique physical token; up removes exactly that token; disconnect clears that device; blur clears all. Track maximum simultaneous held count, accepted presses, releases, orphan ups and sorted held tokens. 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):
        held=set(); peak=0; presses=0; releases=0; orphan=0
        for kind,device,code,location in c:
            token=(device,code,location)
            if kind=='down':
                fresh=token not in held
                if fresh: presses+=1
                held.add(token)
                peak=max(peak,len(held))
            elif kind=='up':
                if token in held:
                    held.remove(token)
                    releases=1
                else: orphan+=1
            elif kind=='disconnect':
                held={x for x in held if x[0]!=device}
            elif kind=='blur':
                held.clear()
        return [sorted([list(x) for x in held]),peak,presses,releases,orphan]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('physical-registry scenario 0', solve([[]] * N), [[[], 0, 0, 0, 0]] * N)
check('physical-registry scenario 1', solve([[['up', 'a', 'A', 0], ['up', 'a', 'B', 0]]] * N), [[[], 0, 0, 0, 2]] * N)
check('physical-registry scenario 2', solve([[['down', 'a', 'A', 0], ['down', 'a', 'A', 0], ['down', 'a', 'A', 0]]] * N), [[[['a', 'A', 0]], 1, 1, 0, 0]] * N)
check('physical-registry scenario 3', solve([[['down', 'a', 'A', 0], ['down', 'b', 'A', 0], ['up', 'a', 'A', 0]]] * N), [[[['b', 'A', 0]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 4', solve([[['down', 'a', 'S', 1], ['down', 'a', 'S', 3], ['up', 'a', 'S', 1]]] * N), [[[['a', 'S', 3]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 5', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 0], ['up', 'a', 'A', 0], ['down', 'a', 'C', 0], ['up', 'a', 'B', 0], ['up', 'a', 'C', 0], ['down', 'a', 'D', 0]]] * N), [[[['a', 'D', 0]], 2, 4, 3, 0]] * N)
check('physical-registry scenario 6', solve([[['down', 'a', 'A', 0], ['down', 'b', 'B', 0], ['disconnect', 'a', '', 0]]] * N), [[[['b', 'B', 0]], 2, 2, 0, 0]] * N)
check('physical-registry scenario 7', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 1], ['blur', '', '', 0]]] * N), [[[], 2, 2, 0, 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):
        held=set(); peak=0; presses=0; releases=0; orphan=0
        for kind,device,code,location in c:
            token=(device,code,location)
            if kind=='down':
                fresh=token not in held
                if fresh: presses+=1
                held.add(token)
                peak=max(peak,len(held))
            elif kind=='up':
                if token in held:
                    held.remove(token)
                    releases+=len(held)
                else: orphan+=1
            elif kind=='disconnect':
                held={x for x in held if x[0]!=device}
            elif kind=='blur':
                held.clear()
        return [sorted([list(x) for x in held]),peak,presses,releases,orphan]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('physical-registry scenario 0', solve([[]] * N), [[[], 0, 0, 0, 0]] * N)
check('physical-registry scenario 1', solve([[['up', 'a', 'A', 0], ['up', 'a', 'B', 0]]] * N), [[[], 0, 0, 0, 2]] * N)
check('physical-registry scenario 2', solve([[['down', 'a', 'A', 0], ['down', 'a', 'A', 0], ['down', 'a', 'A', 0]]] * N), [[[['a', 'A', 0]], 1, 1, 0, 0]] * N)
check('physical-registry scenario 3', solve([[['down', 'a', 'A', 0], ['down', 'b', 'A', 0], ['up', 'a', 'A', 0]]] * N), [[[['b', 'A', 0]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 4', solve([[['down', 'a', 'S', 1], ['down', 'a', 'S', 3], ['up', 'a', 'S', 1]]] * N), [[[['a', 'S', 3]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 5', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 0], ['up', 'a', 'A', 0], ['down', 'a', 'C', 0], ['up', 'a', 'B', 0], ['up', 'a', 'C', 0], ['down', 'a', 'D', 0]]] * N), [[[['a', 'D', 0]], 2, 4, 3, 0]] * N)
check('physical-registry scenario 6', solve([[['down', 'a', 'A', 0], ['down', 'b', 'B', 0], ['disconnect', 'a', '', 0]]] * N), [[[['b', 'B', 0]], 2, 2, 0, 0]] * N)
check('physical-registry scenario 7', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 1], ['blur', '', '', 0]]] * N), [[[], 2, 2, 0, 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 release count rule and produces incorrect keyboard state or command output.

Events are [kind,device,code,location]. Down inserts a unique physical token; up removes exactly that token; disconnect clears that device; blur clears all. Track maximum simultaneous held count, accepted presses, releases, orphan ups and sorted held tokens. 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):
        held=set(); peak=0; presses=0; releases=0; orphan=0
        for kind,device,code,location in c:
            token=(device,code,location)
            if kind=='down':
                fresh=token not in held
                if fresh: presses+=1
                held.add(token)
                peak=max(peak,len(held))
            elif kind=='up':
                if token in held:
                    held.remove(token)
                    releases+=1
                else: orphan=0
            elif kind=='disconnect':
                held={x for x in held if x[0]!=device}
            elif kind=='blur':
                held.clear()
        return [sorted([list(x) for x in held]),peak,presses,releases,orphan]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('physical-registry scenario 0', solve([[]] * N), [[[], 0, 0, 0, 0]] * N)
check('physical-registry scenario 1', solve([[['up', 'a', 'A', 0], ['up', 'a', 'B', 0]]] * N), [[[], 0, 0, 0, 2]] * N)
check('physical-registry scenario 2', solve([[['down', 'a', 'A', 0], ['down', 'a', 'A', 0], ['down', 'a', 'A', 0]]] * N), [[[['a', 'A', 0]], 1, 1, 0, 0]] * N)
check('physical-registry scenario 3', solve([[['down', 'a', 'A', 0], ['down', 'b', 'A', 0], ['up', 'a', 'A', 0]]] * N), [[[['b', 'A', 0]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 4', solve([[['down', 'a', 'S', 1], ['down', 'a', 'S', 3], ['up', 'a', 'S', 1]]] * N), [[[['a', 'S', 3]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 5', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 0], ['up', 'a', 'A', 0], ['down', 'a', 'C', 0], ['up', 'a', 'B', 0], ['up', 'a', 'C', 0], ['down', 'a', 'D', 0]]] * N), [[[['a', 'D', 0]], 2, 4, 3, 0]] * N)
check('physical-registry scenario 6', solve([[['down', 'a', 'A', 0], ['down', 'b', 'B', 0], ['disconnect', 'a', '', 0]]] * N), [[[['b', 'B', 0]], 2, 2, 0, 0]] * N)
check('physical-registry scenario 7', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 1], ['blur', '', '', 0]]] * N), [[[], 2, 2, 0, 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):
        held=set(); peak=0; presses=0; releases=0; orphan=0
        for kind,device,code,location in c:
            token=(device,code,location)
            if kind=='down':
                fresh=token not in held
                if fresh: presses+=1
                held.add(token)
                peak=max(peak,len(held))
            elif kind=='up':
                if token in held:
                    held.remove(token)
                    releases+=1
                else: orphan=1
            elif kind=='disconnect':
                held={x for x in held if x[0]!=device}
            elif kind=='blur':
                held.clear()
        return [sorted([list(x) for x in held]),peak,presses,releases,orphan]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('physical-registry scenario 0', solve([[]] * N), [[[], 0, 0, 0, 0]] * N)
check('physical-registry scenario 1', solve([[['up', 'a', 'A', 0], ['up', 'a', 'B', 0]]] * N), [[[], 0, 0, 0, 2]] * N)
check('physical-registry scenario 2', solve([[['down', 'a', 'A', 0], ['down', 'a', 'A', 0], ['down', 'a', 'A', 0]]] * N), [[[['a', 'A', 0]], 1, 1, 0, 0]] * N)
check('physical-registry scenario 3', solve([[['down', 'a', 'A', 0], ['down', 'b', 'A', 0], ['up', 'a', 'A', 0]]] * N), [[[['b', 'A', 0]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 4', solve([[['down', 'a', 'S', 1], ['down', 'a', 'S', 3], ['up', 'a', 'S', 1]]] * N), [[[['a', 'S', 3]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 5', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 0], ['up', 'a', 'A', 0], ['down', 'a', 'C', 0], ['up', 'a', 'B', 0], ['up', 'a', 'C', 0], ['down', 'a', 'D', 0]]] * N), [[[['a', 'D', 0]], 2, 4, 3, 0]] * N)
check('physical-registry scenario 6', solve([[['down', 'a', 'A', 0], ['down', 'b', 'B', 0], ['disconnect', 'a', '', 0]]] * N), [[[['b', 'B', 0]], 2, 2, 0, 0]] * N)
check('physical-registry scenario 7', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 1], ['blur', '', '', 0]]] * N), [[[], 2, 2, 0, 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 orphan count rule and produces incorrect keyboard state or command output.

Events are [kind,device,code,location]. Down inserts a unique physical token; up removes exactly that token; disconnect clears that device; blur clears all. Track maximum simultaneous held count, accepted presses, releases, orphan ups and sorted held tokens. 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):
        held=set(); peak=0; presses=0; releases=0; orphan=0
        for kind,device,code,location in c:
            token=(device,code,location)
            if kind=='down':
                fresh=token not in held
                if fresh: presses+=1
                held.add(token)
                peak=max(peak,len(held))
            elif kind=='up':
                if token in held:
                    held.remove(token)
                    releases+=1
                else: orphan+=1
            elif kind=='disconnect':
                held.clear()
            elif kind=='blur':
                held.clear()
        return [sorted([list(x) for x in held]),peak,presses,releases,orphan]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('physical-registry scenario 0', solve([[]] * N), [[[], 0, 0, 0, 0]] * N)
check('physical-registry scenario 1', solve([[['up', 'a', 'A', 0], ['up', 'a', 'B', 0]]] * N), [[[], 0, 0, 0, 2]] * N)
check('physical-registry scenario 2', solve([[['down', 'a', 'A', 0], ['down', 'a', 'A', 0], ['down', 'a', 'A', 0]]] * N), [[[['a', 'A', 0]], 1, 1, 0, 0]] * N)
check('physical-registry scenario 3', solve([[['down', 'a', 'A', 0], ['down', 'b', 'A', 0], ['up', 'a', 'A', 0]]] * N), [[[['b', 'A', 0]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 4', solve([[['down', 'a', 'S', 1], ['down', 'a', 'S', 3], ['up', 'a', 'S', 1]]] * N), [[[['a', 'S', 3]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 5', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 0], ['up', 'a', 'A', 0], ['down', 'a', 'C', 0], ['up', 'a', 'B', 0], ['up', 'a', 'C', 0], ['down', 'a', 'D', 0]]] * N), [[[['a', 'D', 0]], 2, 4, 3, 0]] * N)
check('physical-registry scenario 6', solve([[['down', 'a', 'A', 0], ['down', 'b', 'B', 0], ['disconnect', 'a', '', 0]]] * N), [[[['b', 'B', 0]], 2, 2, 0, 0]] * N)
check('physical-registry scenario 7', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 1], ['blur', '', '', 0]]] * N), [[[], 2, 2, 0, 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):
        held=set(); peak=0; presses=0; releases=0; orphan=0
        for kind,device,code,location in c:
            token=(device,code,location)
            if kind=='down':
                fresh=token not in held
                if fresh: presses+=1
                held.add(token)
                peak=max(peak,len(held))
            elif kind=='up':
                if token in held:
                    held.remove(token)
                    releases+=1
                else: orphan+=1
            elif kind=='disconnect':
                held={x for x in held if x[0]==device}
            elif kind=='blur':
                held.clear()
        return [sorted([list(x) for x in held]),peak,presses,releases,orphan]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('physical-registry scenario 0', solve([[]] * N), [[[], 0, 0, 0, 0]] * N)
check('physical-registry scenario 1', solve([[['up', 'a', 'A', 0], ['up', 'a', 'B', 0]]] * N), [[[], 0, 0, 0, 2]] * N)
check('physical-registry scenario 2', solve([[['down', 'a', 'A', 0], ['down', 'a', 'A', 0], ['down', 'a', 'A', 0]]] * N), [[[['a', 'A', 0]], 1, 1, 0, 0]] * N)
check('physical-registry scenario 3', solve([[['down', 'a', 'A', 0], ['down', 'b', 'A', 0], ['up', 'a', 'A', 0]]] * N), [[[['b', 'A', 0]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 4', solve([[['down', 'a', 'S', 1], ['down', 'a', 'S', 3], ['up', 'a', 'S', 1]]] * N), [[[['a', 'S', 3]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 5', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 0], ['up', 'a', 'A', 0], ['down', 'a', 'C', 0], ['up', 'a', 'B', 0], ['up', 'a', 'C', 0], ['down', 'a', 'D', 0]]] * N), [[[['a', 'D', 0]], 2, 4, 3, 0]] * N)
check('physical-registry scenario 6', solve([[['down', 'a', 'A', 0], ['down', 'b', 'B', 0], ['disconnect', 'a', '', 0]]] * N), [[[['b', 'B', 0]], 2, 2, 0, 0]] * N)
check('physical-registry scenario 7', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 1], ['blur', '', '', 0]]] * N), [[[], 2, 2, 0, 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 disconnect scope rule and produces incorrect keyboard state or command output.

Events are [kind,device,code,location]. Down inserts a unique physical token; up removes exactly that token; disconnect clears that device; blur clears all. Track maximum simultaneous held count, accepted presses, releases, orphan ups and sorted held tokens. 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):
        held=set(); peak=0; presses=0; releases=0; orphan=0
        for kind,device,code,location in c:
            token=(device,code,location)
            if kind=='down':
                fresh=token not in held
                if fresh: presses+=1
                held.add(token)
                peak=max(peak,len(held))
            elif kind=='up':
                if token in held:
                    held.remove(token)
                    releases+=1
                else: orphan+=1
            elif kind=='disconnect':
                held={x for x in held if x[0]!=device}
            elif kind=='blur':
                pass
        return [sorted([list(x) for x in held]),peak,presses,releases,orphan]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('physical-registry scenario 0', solve([[]] * N), [[[], 0, 0, 0, 0]] * N)
check('physical-registry scenario 1', solve([[['up', 'a', 'A', 0], ['up', 'a', 'B', 0]]] * N), [[[], 0, 0, 0, 2]] * N)
check('physical-registry scenario 2', solve([[['down', 'a', 'A', 0], ['down', 'a', 'A', 0], ['down', 'a', 'A', 0]]] * N), [[[['a', 'A', 0]], 1, 1, 0, 0]] * N)
check('physical-registry scenario 3', solve([[['down', 'a', 'A', 0], ['down', 'b', 'A', 0], ['up', 'a', 'A', 0]]] * N), [[[['b', 'A', 0]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 4', solve([[['down', 'a', 'S', 1], ['down', 'a', 'S', 3], ['up', 'a', 'S', 1]]] * N), [[[['a', 'S', 3]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 5', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 0], ['up', 'a', 'A', 0], ['down', 'a', 'C', 0], ['up', 'a', 'B', 0], ['up', 'a', 'C', 0], ['down', 'a', 'D', 0]]] * N), [[[['a', 'D', 0]], 2, 4, 3, 0]] * N)
check('physical-registry scenario 6', solve([[['down', 'a', 'A', 0], ['down', 'b', 'B', 0], ['disconnect', 'a', '', 0]]] * N), [[[['b', 'B', 0]], 2, 2, 0, 0]] * N)
check('physical-registry scenario 7', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 1], ['blur', '', '', 0]]] * N), [[[], 2, 2, 0, 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):
        held=set(); peak=0; presses=0; releases=0; orphan=0
        for kind,device,code,location in c:
            token=(device,code,location)
            if kind=='down':
                fresh=token not in held
                if fresh: presses+=1
                held.add(token)
                peak=max(peak,len(held))
            elif kind=='up':
                if token in held:
                    held.remove(token)
                    releases+=1
                else: orphan+=1
            elif kind=='disconnect':
                held={x for x in held if x[0]!=device}
            elif kind=='blur':
                held={x for x in held if x[2]==0}
        return [sorted([list(x) for x in held]),peak,presses,releases,orphan]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('physical-registry scenario 0', solve([[]] * N), [[[], 0, 0, 0, 0]] * N)
check('physical-registry scenario 1', solve([[['up', 'a', 'A', 0], ['up', 'a', 'B', 0]]] * N), [[[], 0, 0, 0, 2]] * N)
check('physical-registry scenario 2', solve([[['down', 'a', 'A', 0], ['down', 'a', 'A', 0], ['down', 'a', 'A', 0]]] * N), [[[['a', 'A', 0]], 1, 1, 0, 0]] * N)
check('physical-registry scenario 3', solve([[['down', 'a', 'A', 0], ['down', 'b', 'A', 0], ['up', 'a', 'A', 0]]] * N), [[[['b', 'A', 0]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 4', solve([[['down', 'a', 'S', 1], ['down', 'a', 'S', 3], ['up', 'a', 'S', 1]]] * N), [[[['a', 'S', 3]], 2, 2, 1, 0]] * N)
check('physical-registry scenario 5', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 0], ['up', 'a', 'A', 0], ['down', 'a', 'C', 0], ['up', 'a', 'B', 0], ['up', 'a', 'C', 0], ['down', 'a', 'D', 0]]] * N), [[[['a', 'D', 0]], 2, 4, 3, 0]] * N)
check('physical-registry scenario 6', solve([[['down', 'a', 'A', 0], ['down', 'b', 'B', 0], ['disconnect', 'a', '', 0]]] * N), [[[['b', 'B', 0]], 2, 2, 0, 0]] * N)
check('physical-registry scenario 7', solve([[['down', 'a', 'A', 0], ['down', 'a', 'B', 1], ['blur', '', '', 0]]] * N), [[[], 2, 2, 0, 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 blur reset rule and produces incorrect keyboard state or command output.

Events are [kind,device,code,location]. Down inserts a unique physical token; up removes exactly that token; disconnect clears that device; blur clears all. Track maximum simultaneous held count, accepted presses, releases, orphan ups and sorted held tokens. 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=None
                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)

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=owner or 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 start owner 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=""
            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)

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 start preedit 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':
                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)

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 owner is not None:
                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 update owner 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)

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[:1]
                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 replace update 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)

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+=len(text)
            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 update count 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':
                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)

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 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 commit owner 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(preedit)
                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)

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.extend(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 commit payload 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=target
                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)

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=''
                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 commit close 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