FAILURE MAP
← Case archive

FA-31711 / Keyboard interactions / Open access

Adjacent keyboard repeat batch coalescing: Changing physical token loses the previous repeat batch or emits the wrong entry type · case 01

The event trace violates the token flush rule and produces incorrect keyboard state or command output.

Verified by executionVariant 1 · 9 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Changing physical token loses the previous repeat batch or emits the wrong entry type.

THE FAILURE

Changing physical token loses the previous repeat batch or emits the wrong entry type.

Unsuccessful approach: The partial repair changes this transition to if batch is not None: out.append(['raw']+batch) batch, which still violates the model contract on the explicit regression traces.

Case contract

Events [kind,device,code,time,repeat]. Consecutive repeated down events for the same device/code coalesce into [device,code,first,last,count]; any nonrepeat or non-down event flushes the batch and is emitted as a raw event. A repeated down for a different token flushes and starts another. Return ordered entries tagged repeat or raw. 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):
        out=[]; batch=None
        for kind,device,code,now,repeat in c:
            eligible=kind=='down' and repeat
            if eligible:
                if batch is not None and batch[0]==device and batch[1]==code:
                    batch[3]=now
                    batch[4]+=1
                else:
                    if batch is not None: pass
                    batch=[device,code,now,now,1]
            else:
                if batch is not None:
                    out.append(['repeat']+batch)
                    batch=None
                out.append(['raw',kind,device,code,now])
        if batch is not None: out.append(['repeat']+batch)
        return out
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeat-coalescing scenario 0', solve([[]] * N), [[]] * N)
check('repeat-coalescing scenario 1', solve([[['down', 'a', 'A', 10, False]]] * N), [[['raw', 'down', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 2', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 12, 2]]] * N)
check('repeat-coalescing scenario 3', solve([[['down', 'a', 'A', 10, True], ['down', 'b', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'b', 'A', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 4', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'B', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'a', 'B', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 5', solve([[['down', 'a', 'A', 10, True], ['up', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'up', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]] * N)
check('repeat-coalescing scenario 6', solve([[['up', 'a', 'A', 10, True]]] * N), [[['raw', 'up', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 7', solve([[['down', 'a', 'A', 10, True], ['text', 'a', 'A', 12, False]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'text', 'a', 'A', 12]]] * N)
check('repeat-coalescing scenario 8', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'down', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]] * 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 fixtureActualExpectedOutcome
repeat-coalescing scenario 0[[]][[]]Passed
repeat-coalescing scenario 1[[['raw', 'down', 'a', 'A', 10]]][[['raw', 'down', 'a', 'A', 10]]]Passed
repeat-coalescing scenario 2[[['repeat', 'a', 'A', 10, 12, 2]]][[['repeat', 'a', 'A', 10, 12, 2]]]Passed
repeat-coalescing scenario 3[[['repeat', 'b', 'A', 12, 12, 1]]][[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'b', 'A', 12, 12, 1]]]Failed
repeat-coalescing scenario 4[[['repeat', 'a', 'B', 12, 12, 1]]][[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'a', 'B', 12, 12, 1]]]Failed
repeat-coalescing scenario 5[[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'up', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]][[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'up', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]]Passed
repeat-coalescing scenario 6[[['raw', 'up', 'a', 'A', 10]]][[['raw', 'up', 'a', 'A', 10]]]Passed
repeat-coalescing scenario 7[[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'text', 'a', 'A', 12]]][[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'text', 'a', 'A', 12]]]Passed
repeat-coalescing scenario 8[[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'down', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]][[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'down', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]]Passed

SHA-256 / f394f22ac30c8544275cf79c53a894ce62e706255b77301346e19c93f507963b

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):
        out=[]; batch=None
        for kind,device,code,now,repeat in c:
            eligible=kind=='down' and repeat
            if eligible:
                if batch is not None and batch[0]==device and batch[1]==code:
                    batch[3]=now
                    batch[4]+=1
                else:
                    if batch is not None: out.append(['raw']+batch)
                    batch=[device,code,now,now,1]
            else:
                if batch is not None:
                    out.append(['repeat']+batch)
                    batch=None
                out.append(['raw',kind,device,code,now])
        if batch is not None: out.append(['repeat']+batch)
        return out
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeat-coalescing scenario 0', solve([[]] * N), [[]] * N)
check('repeat-coalescing scenario 1', solve([[['down', 'a', 'A', 10, False]]] * N), [[['raw', 'down', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 2', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 12, 2]]] * N)
check('repeat-coalescing scenario 3', solve([[['down', 'a', 'A', 10, True], ['down', 'b', 'A', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'b', 'A', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 4', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'B', 12, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'a', 'B', 12, 12, 1]]] * N)
check('repeat-coalescing scenario 5', solve([[['down', 'a', 'A', 10, True], ['up', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'up', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]] * N)
check('repeat-coalescing scenario 6', solve([[['up', 'a', 'A', 10, True]]] * N), [[['raw', 'up', 'a', 'A', 10]]] * N)
check('repeat-coalescing scenario 7', solve([[['down', 'a', 'A', 10, True], ['text', 'a', 'A', 12, False]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'text', 'a', 'A', 12]]] * N)
check('repeat-coalescing scenario 8', solve([[['down', 'a', 'A', 10, True], ['down', 'a', 'A', 12, False], ['down', 'a', 'A', 14, True]]] * N), [[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'down', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]] * 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 fixtureActualExpectedOutcome
repeat-coalescing scenario 0[[]][[]]Passed
repeat-coalescing scenario 1[[['raw', 'down', 'a', 'A', 10]]][[['raw', 'down', 'a', 'A', 10]]]Passed
repeat-coalescing scenario 2[[['repeat', 'a', 'A', 10, 12, 2]]][[['repeat', 'a', 'A', 10, 12, 2]]]Passed
repeat-coalescing scenario 3[[['raw', 'a', 'A', 10, 10, 1], ['repeat', 'b', 'A', 12, 12, 1]]][[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'b', 'A', 12, 12, 1]]]Failed
repeat-coalescing scenario 4[[['raw', 'a', 'A', 10, 10, 1], ['repeat', 'a', 'B', 12, 12, 1]]][[['repeat', 'a', 'A', 10, 10, 1], ['repeat', 'a', 'B', 12, 12, 1]]]Failed
repeat-coalescing scenario 5[[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'up', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]][[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'up', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]]Passed
repeat-coalescing scenario 6[[['raw', 'up', 'a', 'A', 10]]][[['raw', 'up', 'a', 'A', 10]]]Passed
repeat-coalescing scenario 7[[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'text', 'a', 'A', 12]]][[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'text', 'a', 'A', 12]]]Passed
repeat-coalescing scenario 8[[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'down', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]][[['repeat', 'a', 'A', 10, 10, 1], ['raw', 'down', 'a', 'A', 12], ['repeat', 'a', 'A', 14, 14, 1]]]Passed

SHA-256 / f94adec4e86369ed3fb606dc469ee157197ce6b593e9996486a8242705ad775b

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 9 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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:05.057461+00:00.

Case digest / adeeaa879b332d734fbf347fbbe4f1294234e6691b2a2714a0a81b72c55f911a