FA-32306 / Keyboard interactions / Open access
Bounded keyboard queue with lossless release backpressure: Release admission consults dispatched state instead of accepted-but-buffered physical presses · case 01
The event trace violates the release admission rule and produces incorrect keyboard state or command output.
ROOT CAUSE
Release admission consults dispatched state instead of accepted-but-buffered physical presses.
VERIFIED REPAIR
Use the contract transition `elif kind=='up' and key in admitted:` at the release admission fault site; preserve the other state transitions.
Unsuccessful approach: The partial repair changes this transition to elif kind=='up' and key not in admitted:, which still violates the model contract on the explicit regression traces.
Case contract
Case [capacity,events], positive capacity; events [kind,key]. Down admitted only once per physical key and only when queue has capacity; overflow drops down. Up for an admitted key must be retained: dispatch oldest queued events until a slot exists, then queue the up. Tick dispatches one queued event; flush dispatches all. Reset discards pending queue and emits sorted synthetic ups for actually dispatched held keys. Return emitted edges,queue,admitted keys,delivered-held keys,dropped downs. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.
Why this case matters
Controlled keyboard event processing model for debugging application event logic.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(cases):
def run(c):
capacity,events=c
queue=[]; admitted=set(); held=set(); out=[]; dropped=0
def dispatch(event):
phase,key=event
out.append([phase,key])
if phase=='down': held.add(key)
else: held.discard(key)
for kind,key in events:
if kind=='down' and key not in admitted:
if len(queue)>=capacity: dropped+=1
else:
admitted.add(key)
queue.append(['down',key])
elif kind=='up' and key in held:
admitted.discard(key)
while len(queue)>=capacity: dispatch(queue.pop(0))
queue.append(['up',key])
elif kind=='tick' and queue: dispatch(queue.pop(0))
elif kind=='flush':
while queue: dispatch(queue.pop(0))
elif kind=='reset':
queue.clear(); admitted.clear()
for k in sorted(held): out.append(['up',k])
held.clear()
return [out,queue,sorted(admitted),sorted(held),dropped]
return [run(c) for c in cases]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('bounded-keyboard-pump scenario 0', solve([[2, []]] * N), [[[], [], [], [], 0]] * N)
check('bounded-keyboard-pump scenario 1', solve([[2, [['down', 'A'], ['down', 'B'], ['down', 'C']]]] * N), [[[], [['down', 'A'], ['down', 'B']], ['A', 'B'], [], 1]] * N)
check('bounded-keyboard-pump scenario 2', solve([[2, [['down', 'A'], ['down', 'B'], ['up', 'A']]]] * N), [[[['down', 'A']], [['down', 'B'], ['up', 'A']], ['B'], ['A'], 0]] * N)
check('bounded-keyboard-pump scenario 3', solve([[2, [['down', 'A'], ['down', 'B'], ['tick', '']]]] * N), [[[['down', 'A']], [['down', 'B']], ['A', 'B'], ['A'], 0]] * N)
check('bounded-keyboard-pump scenario 4', solve([[2, [['down', 'A'], ['down', 'B'], ['flush', '']]]] * N), [[[['down', 'A'], ['down', 'B']], [], ['A', 'B'], ['A', 'B'], 0]] * N)
check('bounded-keyboard-pump scenario 5', solve([[2, [['down', 'A'], ['down', 'B'], ['reset', '']]]] * N), [[[], [], [], [], 0]] * N)
check('bounded-keyboard-pump scenario 6', solve([[2, [['down', 'A'], ['tick', ''], ['down', 'B'], ['reset', '']]]] * N), [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] * N)
check('bounded-keyboard-pump scenario 7', solve([[1, [['down', 'A'], ['up', 'A'], ['flush', '']]]] * N), [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] * N)
check('bounded-keyboard-pump scenario 8', solve([[2, [['down', 'A'], ['down', 'A'], ['up', 'A'], ['flush', '']]]] * N), [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] * N)
check('bounded-keyboard-pump scenario 9', solve([[2, [['up', 'A']]]] * N), [[[], [], [], [], 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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| bounded-keyboard-pump scenario 0 | [[[], [], [], [], 0]] | [[[], [], [], [], 0]] | Passed |
| bounded-keyboard-pump scenario 1 | [[[], [['down', 'A'], ['down', 'B']], ['A', 'B'], [], 1]] | [[[], [['down', 'A'], ['down', 'B']], ['A', 'B'], [], 1]] | Passed |
| bounded-keyboard-pump scenario 2 | [[[], [['down', 'A'], ['down', 'B']], ['A', 'B'], [], 0]] | [[[['down', 'A']], [['down', 'B'], ['up', 'A']], ['B'], ['A'], 0]] | Failed |
| bounded-keyboard-pump scenario 3 | [[[['down', 'A']], [['down', 'B']], ['A', 'B'], ['A'], 0]] | [[[['down', 'A']], [['down', 'B']], ['A', 'B'], ['A'], 0]] | Passed |
| bounded-keyboard-pump scenario 4 | [[[['down', 'A'], ['down', 'B']], [], ['A', 'B'], ['A', 'B'], 0]] | [[[['down', 'A'], ['down', 'B']], [], ['A', 'B'], ['A', 'B'], 0]] | Passed |
| bounded-keyboard-pump scenario 5 | [[[], [], [], [], 0]] | [[[], [], [], [], 0]] | Passed |
| bounded-keyboard-pump scenario 6 | [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] | [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] | Passed |
| bounded-keyboard-pump scenario 7 | [[[['down', 'A']], [], ['A'], ['A'], 0]] | [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] | Failed |
| bounded-keyboard-pump scenario 8 | [[[['down', 'A']], [], ['A'], ['A'], 0]] | [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] | Failed |
| bounded-keyboard-pump scenario 9 | [[[], [], [], [], 0]] | [[[], [], [], [], 0]] | Passed |
SHA-256 / c4f897fae62621c55defd5478c721e544bdc086698e5771c254c8e10eb49144b
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(cases):
def run(c):
capacity,events=c
queue=[]; admitted=set(); held=set(); out=[]; dropped=0
def dispatch(event):
phase,key=event
out.append([phase,key])
if phase=='down': held.add(key)
else: held.discard(key)
for kind,key in events:
if kind=='down' and key not in admitted:
if len(queue)>=capacity: dropped+=1
else:
admitted.add(key)
queue.append(['down',key])
elif kind=='up' and key not in admitted:
admitted.discard(key)
while len(queue)>=capacity: dispatch(queue.pop(0))
queue.append(['up',key])
elif kind=='tick' and queue: dispatch(queue.pop(0))
elif kind=='flush':
while queue: dispatch(queue.pop(0))
elif kind=='reset':
queue.clear(); admitted.clear()
for k in sorted(held): out.append(['up',k])
held.clear()
return [out,queue,sorted(admitted),sorted(held),dropped]
return [run(c) for c in cases]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('bounded-keyboard-pump scenario 0', solve([[2, []]] * N), [[[], [], [], [], 0]] * N)
check('bounded-keyboard-pump scenario 1', solve([[2, [['down', 'A'], ['down', 'B'], ['down', 'C']]]] * N), [[[], [['down', 'A'], ['down', 'B']], ['A', 'B'], [], 1]] * N)
check('bounded-keyboard-pump scenario 2', solve([[2, [['down', 'A'], ['down', 'B'], ['up', 'A']]]] * N), [[[['down', 'A']], [['down', 'B'], ['up', 'A']], ['B'], ['A'], 0]] * N)
check('bounded-keyboard-pump scenario 3', solve([[2, [['down', 'A'], ['down', 'B'], ['tick', '']]]] * N), [[[['down', 'A']], [['down', 'B']], ['A', 'B'], ['A'], 0]] * N)
check('bounded-keyboard-pump scenario 4', solve([[2, [['down', 'A'], ['down', 'B'], ['flush', '']]]] * N), [[[['down', 'A'], ['down', 'B']], [], ['A', 'B'], ['A', 'B'], 0]] * N)
check('bounded-keyboard-pump scenario 5', solve([[2, [['down', 'A'], ['down', 'B'], ['reset', '']]]] * N), [[[], [], [], [], 0]] * N)
check('bounded-keyboard-pump scenario 6', solve([[2, [['down', 'A'], ['tick', ''], ['down', 'B'], ['reset', '']]]] * N), [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] * N)
check('bounded-keyboard-pump scenario 7', solve([[1, [['down', 'A'], ['up', 'A'], ['flush', '']]]] * N), [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] * N)
check('bounded-keyboard-pump scenario 8', solve([[2, [['down', 'A'], ['down', 'A'], ['up', 'A'], ['flush', '']]]] * N), [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] * N)
check('bounded-keyboard-pump scenario 9', solve([[2, [['up', 'A']]]] * N), [[[], [], [], [], 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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| bounded-keyboard-pump scenario 0 | [[[], [], [], [], 0]] | [[[], [], [], [], 0]] | Passed |
| bounded-keyboard-pump scenario 1 | [[[], [['down', 'A'], ['down', 'B']], ['A', 'B'], [], 1]] | [[[], [['down', 'A'], ['down', 'B']], ['A', 'B'], [], 1]] | Passed |
| bounded-keyboard-pump scenario 2 | [[[], [['down', 'A'], ['down', 'B']], ['A', 'B'], [], 0]] | [[[['down', 'A']], [['down', 'B'], ['up', 'A']], ['B'], ['A'], 0]] | Failed |
| bounded-keyboard-pump scenario 3 | [[[['down', 'A']], [['down', 'B']], ['A', 'B'], ['A'], 0]] | [[[['down', 'A']], [['down', 'B']], ['A', 'B'], ['A'], 0]] | Passed |
| bounded-keyboard-pump scenario 4 | [[[['down', 'A'], ['down', 'B']], [], ['A', 'B'], ['A', 'B'], 0]] | [[[['down', 'A'], ['down', 'B']], [], ['A', 'B'], ['A', 'B'], 0]] | Passed |
| bounded-keyboard-pump scenario 5 | [[[], [], [], [], 0]] | [[[], [], [], [], 0]] | Passed |
| bounded-keyboard-pump scenario 6 | [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] | [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] | Passed |
| bounded-keyboard-pump scenario 7 | [[[['down', 'A']], [], ['A'], ['A'], 0]] | [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] | Failed |
| bounded-keyboard-pump scenario 8 | [[[['down', 'A']], [], ['A'], ['A'], 0]] | [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] | Failed |
| bounded-keyboard-pump scenario 9 | [[[], [['up', 'A']], [], [], 0]] | [[[], [], [], [], 0]] | Failed |
SHA-256 / ab64f97385bef0aa3de188f478a12d552c06a9ea7868016c64394f733c1c0023
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(cases):
def run(c):
capacity,events=c
queue=[]; admitted=set(); held=set(); out=[]; dropped=0
def dispatch(event):
phase,key=event
out.append([phase,key])
if phase=='down': held.add(key)
else: held.discard(key)
for kind,key in events:
if kind=='down' and key not in admitted:
if len(queue)>=capacity: dropped+=1
else:
admitted.add(key)
queue.append(['down',key])
elif kind=='up' and key in admitted:
admitted.discard(key)
while len(queue)>=capacity: dispatch(queue.pop(0))
queue.append(['up',key])
elif kind=='tick' and queue: dispatch(queue.pop(0))
elif kind=='flush':
while queue: dispatch(queue.pop(0))
elif kind=='reset':
queue.clear(); admitted.clear()
for k in sorted(held): out.append(['up',k])
held.clear()
return [out,queue,sorted(admitted),sorted(held),dropped]
return [run(c) for c in cases]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('bounded-keyboard-pump scenario 0', solve([[2, []]] * N), [[[], [], [], [], 0]] * N)
check('bounded-keyboard-pump scenario 1', solve([[2, [['down', 'A'], ['down', 'B'], ['down', 'C']]]] * N), [[[], [['down', 'A'], ['down', 'B']], ['A', 'B'], [], 1]] * N)
check('bounded-keyboard-pump scenario 2', solve([[2, [['down', 'A'], ['down', 'B'], ['up', 'A']]]] * N), [[[['down', 'A']], [['down', 'B'], ['up', 'A']], ['B'], ['A'], 0]] * N)
check('bounded-keyboard-pump scenario 3', solve([[2, [['down', 'A'], ['down', 'B'], ['tick', '']]]] * N), [[[['down', 'A']], [['down', 'B']], ['A', 'B'], ['A'], 0]] * N)
check('bounded-keyboard-pump scenario 4', solve([[2, [['down', 'A'], ['down', 'B'], ['flush', '']]]] * N), [[[['down', 'A'], ['down', 'B']], [], ['A', 'B'], ['A', 'B'], 0]] * N)
check('bounded-keyboard-pump scenario 5', solve([[2, [['down', 'A'], ['down', 'B'], ['reset', '']]]] * N), [[[], [], [], [], 0]] * N)
check('bounded-keyboard-pump scenario 6', solve([[2, [['down', 'A'], ['tick', ''], ['down', 'B'], ['reset', '']]]] * N), [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] * N)
check('bounded-keyboard-pump scenario 7', solve([[1, [['down', 'A'], ['up', 'A'], ['flush', '']]]] * N), [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] * N)
check('bounded-keyboard-pump scenario 8', solve([[2, [['down', 'A'], ['down', 'A'], ['up', 'A'], ['flush', '']]]] * N), [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] * N)
check('bounded-keyboard-pump scenario 9', solve([[2, [['up', 'A']]]] * N), [[[], [], [], [], 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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| bounded-keyboard-pump scenario 0 | [[[], [], [], [], 0]] | [[[], [], [], [], 0]] | Passed |
| bounded-keyboard-pump scenario 1 | [[[], [['down', 'A'], ['down', 'B']], ['A', 'B'], [], 1]] | [[[], [['down', 'A'], ['down', 'B']], ['A', 'B'], [], 1]] | Passed |
| bounded-keyboard-pump scenario 2 | [[[['down', 'A']], [['down', 'B'], ['up', 'A']], ['B'], ['A'], 0]] | [[[['down', 'A']], [['down', 'B'], ['up', 'A']], ['B'], ['A'], 0]] | Passed |
| bounded-keyboard-pump scenario 3 | [[[['down', 'A']], [['down', 'B']], ['A', 'B'], ['A'], 0]] | [[[['down', 'A']], [['down', 'B']], ['A', 'B'], ['A'], 0]] | Passed |
| bounded-keyboard-pump scenario 4 | [[[['down', 'A'], ['down', 'B']], [], ['A', 'B'], ['A', 'B'], 0]] | [[[['down', 'A'], ['down', 'B']], [], ['A', 'B'], ['A', 'B'], 0]] | Passed |
| bounded-keyboard-pump scenario 5 | [[[], [], [], [], 0]] | [[[], [], [], [], 0]] | Passed |
| bounded-keyboard-pump scenario 6 | [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] | [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] | Passed |
| bounded-keyboard-pump scenario 7 | [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] | [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] | Passed |
| bounded-keyboard-pump scenario 8 | [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] | [[[['down', 'A'], ['up', 'A']], [], [], [], 0]] | Passed |
| bounded-keyboard-pump scenario 9 | [[[], [], [], [], 0]] | [[[], [], [], [], 0]] | Passed |
SHA-256 / 88afbb7ade9386a82690d9f1449d00b31aa4372fd0bd450460f5bf49b3b56ed4
Verification & scope
Offline stipulated event model, not a browser implementation or web standard conformance claim. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:42:10.870029+00:00.
Case digest / 7fcba27638566955416f072f255845afcd44e56ac867fc00dcf8e046daf6f43e