FA-31246 / Keyboard interactions / Open access
Keyboard layout mapping generations: Changing one keyboard layout invalidates unrelated devices or preserves its own stale labels · case 01
The event trace violates the layout invalidate rule and produces incorrect keyboard state or command output.
ROOT CAUSE
Changing one keyboard layout invalidates unrelated devices or preserves its own stale labels.
VERIFIED REPAIR
Use the contract transition `cache={k:v for k,v in cache.items() if k[0]!=device} elif kind=='map'` at the layout invalidate fault site; preserve the other state transitions.
Unsuccessful approach: The partial repair changes this transition to cache={k:v for k,v in cache.items() if k[0]==device} elif kind=='map', which still violates the model contract on the explicit regression traces.
Case contract
Events [kind,device,a,b]. layout replaces device generation a and clears cached labels; map caches physical code a to label b in current generation; lookup emits cached label or code a as fallback. Disconnect removes generation and cache. Maps and lookups before layout are ignored. Return emitted labels, generations and cached [device,code,label] rows. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.
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):
generations={}; cache={}; out=[]
for kind,device,a,b in c:
if kind=='layout':
generations[device]=a
cache={}
elif kind=='map' and device in generations:
cache[(device,a)]=b
elif kind=='lookup' and device in generations:
out.append(cache.get((device,a),a))
elif kind=='disconnect':
generations.pop(device,None)
cache={k:v for k,v in cache.items() if k[0]!=device}
return [out,sorted([[k,v] for k,v in generations.items()]),sorted([[d,k,v] for (d,k),v in cache.items()])]
return [run(c) for c in cases]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layout-cache scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('layout-cache scenario 1', solve([[['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[[], [], []]] * N)
check('layout-cache scenario 2', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] * N)
check('layout-cache scenario 3', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'a', 'KeyA', 'y'], ['lookup', 'a', 'KeyA', '']]] * N), [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] * N)
check('layout-cache scenario 4', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['layout', 'a', 2, ''], ['lookup', 'a', 'KeyA', '']]] * N), [[['KeyA'], [['a', 2]], []]] * N)
check('layout-cache scenario 5', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['layout', 'a', 3, '']]] * N), [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] * N)
check('layout-cache scenario 6', solve([[['layout', 'a', 1, ''], ['lookup', 'b', 'KeyA', '']]] * N), [[[], [['a', 1]], []]] * N)
check('layout-cache scenario 7', solve([[['layout', 'a', 1, ''], ['lookup', 'a', 'Unknown', 'fallback']]] * N), [[['Unknown'], [['a', 1]], []]] * N)
check('layout-cache scenario 8', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['disconnect', 'a', '', '']]] * N), [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| layout-cache scenario 0 | [[[], [], []]] | [[[], [], []]] | Passed |
| layout-cache scenario 1 | [[[], [], []]] | [[[], [], []]] | Passed |
| layout-cache scenario 2 | [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] | [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] | Passed |
| layout-cache scenario 3 | [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] | [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] | Passed |
| layout-cache scenario 4 | [[['KeyA'], [['a', 2]], []]] | [[['KeyA'], [['a', 2]], []]] | Passed |
| layout-cache scenario 5 | [[[], [['a', 3], ['b', 2]], []]] | [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] | Failed |
| layout-cache scenario 6 | [[[], [['a', 1]], []]] | [[[], [['a', 1]], []]] | Passed |
| layout-cache scenario 7 | [[['Unknown'], [['a', 1]], []]] | [[['Unknown'], [['a', 1]], []]] | Passed |
| layout-cache scenario 8 | [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] | [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] | Passed |
SHA-256 / 017133d65fa56f616234df97bf46cc9a1ec112e3d161c1e06da8296cd01844d8
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):
generations={}; cache={}; out=[]
for kind,device,a,b in c:
if kind=='layout':
generations[device]=a
cache={k:v for k,v in cache.items() if k[0]==device}
elif kind=='map' and device in generations:
cache[(device,a)]=b
elif kind=='lookup' and device in generations:
out.append(cache.get((device,a),a))
elif kind=='disconnect':
generations.pop(device,None)
cache={k:v for k,v in cache.items() if k[0]!=device}
return [out,sorted([[k,v] for k,v in generations.items()]),sorted([[d,k,v] for (d,k),v in cache.items()])]
return [run(c) for c in cases]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layout-cache scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('layout-cache scenario 1', solve([[['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[[], [], []]] * N)
check('layout-cache scenario 2', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] * N)
check('layout-cache scenario 3', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'a', 'KeyA', 'y'], ['lookup', 'a', 'KeyA', '']]] * N), [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] * N)
check('layout-cache scenario 4', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['layout', 'a', 2, ''], ['lookup', 'a', 'KeyA', '']]] * N), [[['KeyA'], [['a', 2]], []]] * N)
check('layout-cache scenario 5', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['layout', 'a', 3, '']]] * N), [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] * N)
check('layout-cache scenario 6', solve([[['layout', 'a', 1, ''], ['lookup', 'b', 'KeyA', '']]] * N), [[[], [['a', 1]], []]] * N)
check('layout-cache scenario 7', solve([[['layout', 'a', 1, ''], ['lookup', 'a', 'Unknown', 'fallback']]] * N), [[['Unknown'], [['a', 1]], []]] * N)
check('layout-cache scenario 8', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['disconnect', 'a', '', '']]] * N), [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| layout-cache scenario 0 | [[[], [], []]] | [[[], [], []]] | Passed |
| layout-cache scenario 1 | [[[], [], []]] | [[[], [], []]] | Passed |
| layout-cache scenario 2 | [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] | [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] | Passed |
| layout-cache scenario 3 | [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] | [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] | Passed |
| layout-cache scenario 4 | [[['x'], [['a', 2]], [['a', 'KeyA', 'x']]]] | [[['KeyA'], [['a', 2]], []]] | Failed |
| layout-cache scenario 5 | [[[], [['a', 3], ['b', 2]], [['a', 'KeyA', 'x']]]] | [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] | Failed |
| layout-cache scenario 6 | [[[], [['a', 1]], []]] | [[[], [['a', 1]], []]] | Passed |
| layout-cache scenario 7 | [[['Unknown'], [['a', 1]], []]] | [[['Unknown'], [['a', 1]], []]] | Passed |
| layout-cache scenario 8 | [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] | [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] | Passed |
SHA-256 / 2aafd3500f77c4fa98c99f54e60b33e4edc17f3c814d5b876e2e28454c29af29
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):
generations={}; cache={}; out=[]
for kind,device,a,b in c:
if kind=='layout':
generations[device]=a
cache={k:v for k,v in cache.items() if k[0]!=device}
elif kind=='map' and device in generations:
cache[(device,a)]=b
elif kind=='lookup' and device in generations:
out.append(cache.get((device,a),a))
elif kind=='disconnect':
generations.pop(device,None)
cache={k:v for k,v in cache.items() if k[0]!=device}
return [out,sorted([[k,v] for k,v in generations.items()]),sorted([[d,k,v] for (d,k),v in cache.items()])]
return [run(c) for c in cases]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layout-cache scenario 0', solve([[]] * N), [[[], [], []]] * N)
check('layout-cache scenario 1', solve([[['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[[], [], []]] * N)
check('layout-cache scenario 2', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['lookup', 'a', 'KeyA', '']]] * N), [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] * N)
check('layout-cache scenario 3', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'a', 'KeyA', 'y'], ['lookup', 'a', 'KeyA', '']]] * N), [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] * N)
check('layout-cache scenario 4', solve([[['layout', 'a', 1, ''], ['map', 'a', 'KeyA', 'x'], ['layout', 'a', 2, ''], ['lookup', 'a', 'KeyA', '']]] * N), [[['KeyA'], [['a', 2]], []]] * N)
check('layout-cache scenario 5', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['layout', 'a', 3, '']]] * N), [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] * N)
check('layout-cache scenario 6', solve([[['layout', 'a', 1, ''], ['lookup', 'b', 'KeyA', '']]] * N), [[[], [['a', 1]], []]] * N)
check('layout-cache scenario 7', solve([[['layout', 'a', 1, ''], ['lookup', 'a', 'Unknown', 'fallback']]] * N), [[['Unknown'], [['a', 1]], []]] * N)
check('layout-cache scenario 8', solve([[['layout', 'a', 1, ''], ['layout', 'b', 2, ''], ['map', 'a', 'KeyA', 'x'], ['map', 'b', 'KeyB', 'y'], ['disconnect', 'a', '', '']]] * N), [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] * N)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| layout-cache scenario 0 | [[[], [], []]] | [[[], [], []]] | Passed |
| layout-cache scenario 1 | [[[], [], []]] | [[[], [], []]] | Passed |
| layout-cache scenario 2 | [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] | [[['x'], [['a', 1]], [['a', 'KeyA', 'x']]]] | Passed |
| layout-cache scenario 3 | [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] | [[['y'], [['a', 1]], [['a', 'KeyA', 'y']]]] | Passed |
| layout-cache scenario 4 | [[['KeyA'], [['a', 2]], []]] | [[['KeyA'], [['a', 2]], []]] | Passed |
| layout-cache scenario 5 | [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] | [[[], [['a', 3], ['b', 2]], [['b', 'KeyB', 'y']]]] | Passed |
| layout-cache scenario 6 | [[[], [['a', 1]], []]] | [[[], [['a', 1]], []]] | Passed |
| layout-cache scenario 7 | [[['Unknown'], [['a', 1]], []]] | [[['Unknown'], [['a', 1]], []]] | Passed |
| layout-cache scenario 8 | [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] | [[[], [['b', 2]], [['b', 'KeyB', 'y']]]] | Passed |
SHA-256 / 81957e9e152d851f1942bafe5f3b7fdc8d346d726d7b19d2110c209673b8efed
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:00.302933+00:00.
Case digest / 36c9ef7998c134de5813a5a523346812746d9cf39e297ba46dfc7957e65c0de0