FAILURE MAP
← Case archive

FA-31166 / Keyboard interactions / Open access

Per-key double tap recognizer: A valid first release at timestamp zero is mistaken for missing history · case 01

The event trace violates the zero timestamp rule and produces incorrect keyboard state or command output.

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

ROOT CAUSE

A valid first release at timestamp zero is mistaken for missing history.

THE FAILURE

A valid first release at timestamp zero is mistaken for missing history.

Unsuccessful approach: The partial repair changes this transition to if previous is not None and previous>0 and, which still violates the model contract on the explicit regression traces.

Case contract

Case [window,events] with nondecreasing timestamps and events [kind,key,time]. Down repeats do not count. A matched up produces tap and may complete a double if the prior release of the same key is within the inclusive window. Completing a double consumes that prior release. Cancel clears that key, blur clears all state. Return doubles [key,time], held keys and remembered release times. 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):
        window,events=c
        held=set(); last={}; doubles=[]; taps=0
        for kind,key,now in events:
            if kind=='down': held.add(key)
            elif kind=='up' and key in held:
                held.discard(key)
                taps+=1
                previous=last.get(key)
                if previous and now-previous<=window:
                    doubles.append([key,now])
                    last.pop(key,None)
                else:
                    last[key]=now
            elif kind=='cancel':
                held.discard(key); last.pop(key,None)
            elif kind=='blur':
                held.clear(); last.clear()
        return [doubles,sorted(held),sorted([[k,v] for k,v in last.items()]),taps]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('double-tap scenario 0', solve([[4, []]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 1', solve([[4, [['down', 'A', 0], ['up', 'B', 1]]]] * N), [[[], ['A'], [], 0]] * N)
check('double-tap scenario 2', solve([[4, [['up', 'A', 1]]]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 3', solve([[4, [['down', 'A', 0], ['up', 'A', 0], ['down', 'A', 2], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [], 2]] * N)
check('double-tap scenario 4', solve([[4, [['down', 'A', 10], ['up', 'A', 11], ['down', 'B', 12], ['up', 'B', 13]]]] * N), [[[], [], [['A', 11], ['B', 13]], 2]] * N)
check('double-tap scenario 5', solve([[4, [['down', 'A', 1], ['down', 'A', 1], ['up', 'A', 2]]]] * N), [[[], [], [['A', 2]], 1]] * N)
check('double-tap scenario 6', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 10], ['up', 'A', 11], ['down', 'A', 12], ['up', 'A', 13]]]] * N), [[[['A', 13]], [], [], 3]] * N)
check('double-tap scenario 7', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 2], ['up', 'A', 3], ['down', 'A', 4], ['up', 'A', 5]]]] * N), [[[['A', 3]], [], [['A', 5]], 3]] * N)
check('double-tap scenario 8', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['up', 'B', 3], ['down', 'A', 3], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [['B', 3]], 3]] * N)
check('double-tap scenario 9', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['blur', '', 3]]]] * N), [[[], [], [], 1]] * N)
check('double-tap scenario 10', solve([[4, [['down', 'A', 0], ['down', 'B', 1], ['up', 'A', 2]]]] * N), [[[], ['B'], [['A', 2]], 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
double-tap scenario 0[[[], [], [], 0]][[[], [], [], 0]]Passed
double-tap scenario 1[[[], ['A'], [], 0]][[[], ['A'], [], 0]]Passed
double-tap scenario 2[[[], [], [], 0]][[[], [], [], 0]]Passed
double-tap scenario 3[[[], [], [['A', 4]], 2]][[[['A', 4]], [], [], 2]]Failed
double-tap scenario 4[[[], [], [['A', 11], ['B', 13]], 2]][[[], [], [['A', 11], ['B', 13]], 2]]Passed
double-tap scenario 5[[[], [], [['A', 2]], 1]][[[], [], [['A', 2]], 1]]Passed
double-tap scenario 6[[[['A', 13]], [], [], 3]][[[['A', 13]], [], [], 3]]Passed
double-tap scenario 7[[[['A', 3]], [], [['A', 5]], 3]][[[['A', 3]], [], [['A', 5]], 3]]Passed
double-tap scenario 8[[[['A', 4]], [], [['B', 3]], 3]][[[['A', 4]], [], [['B', 3]], 3]]Passed
double-tap scenario 9[[[], [], [], 1]][[[], [], [], 1]]Passed
double-tap scenario 10[[[], ['B'], [['A', 2]], 1]][[[], ['B'], [['A', 2]], 1]]Passed

SHA-256 / 1768de925eaf7bf86300763c2c910f09a90b73a2ef833b55f5635cf05f4b8141

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):
        window,events=c
        held=set(); last={}; doubles=[]; taps=0
        for kind,key,now in events:
            if kind=='down': held.add(key)
            elif kind=='up' and key in held:
                held.discard(key)
                taps+=1
                previous=last.get(key)
                if previous is not None and previous>0 and now-previous<=window:
                    doubles.append([key,now])
                    last.pop(key,None)
                else:
                    last[key]=now
            elif kind=='cancel':
                held.discard(key); last.pop(key,None)
            elif kind=='blur':
                held.clear(); last.clear()
        return [doubles,sorted(held),sorted([[k,v] for k,v in last.items()]),taps]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('double-tap scenario 0', solve([[4, []]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 1', solve([[4, [['down', 'A', 0], ['up', 'B', 1]]]] * N), [[[], ['A'], [], 0]] * N)
check('double-tap scenario 2', solve([[4, [['up', 'A', 1]]]] * N), [[[], [], [], 0]] * N)
check('double-tap scenario 3', solve([[4, [['down', 'A', 0], ['up', 'A', 0], ['down', 'A', 2], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [], 2]] * N)
check('double-tap scenario 4', solve([[4, [['down', 'A', 10], ['up', 'A', 11], ['down', 'B', 12], ['up', 'B', 13]]]] * N), [[[], [], [['A', 11], ['B', 13]], 2]] * N)
check('double-tap scenario 5', solve([[4, [['down', 'A', 1], ['down', 'A', 1], ['up', 'A', 2]]]] * N), [[[], [], [['A', 2]], 1]] * N)
check('double-tap scenario 6', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 10], ['up', 'A', 11], ['down', 'A', 12], ['up', 'A', 13]]]] * N), [[[['A', 13]], [], [], 3]] * N)
check('double-tap scenario 7', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'A', 2], ['up', 'A', 3], ['down', 'A', 4], ['up', 'A', 5]]]] * N), [[[['A', 3]], [], [['A', 5]], 3]] * N)
check('double-tap scenario 8', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['up', 'B', 3], ['down', 'A', 3], ['up', 'A', 4]]]] * N), [[[['A', 4]], [], [['B', 3]], 3]] * N)
check('double-tap scenario 9', solve([[4, [['down', 'A', 0], ['up', 'A', 1], ['down', 'B', 2], ['blur', '', 3]]]] * N), [[[], [], [], 1]] * N)
check('double-tap scenario 10', solve([[4, [['down', 'A', 0], ['down', 'B', 1], ['up', 'A', 2]]]] * N), [[[], ['B'], [['A', 2]], 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
double-tap scenario 0[[[], [], [], 0]][[[], [], [], 0]]Passed
double-tap scenario 1[[[], ['A'], [], 0]][[[], ['A'], [], 0]]Passed
double-tap scenario 2[[[], [], [], 0]][[[], [], [], 0]]Passed
double-tap scenario 3[[[], [], [['A', 4]], 2]][[[['A', 4]], [], [], 2]]Failed
double-tap scenario 4[[[], [], [['A', 11], ['B', 13]], 2]][[[], [], [['A', 11], ['B', 13]], 2]]Passed
double-tap scenario 5[[[], [], [['A', 2]], 1]][[[], [], [['A', 2]], 1]]Passed
double-tap scenario 6[[[['A', 13]], [], [], 3]][[[['A', 13]], [], [], 3]]Passed
double-tap scenario 7[[[['A', 3]], [], [['A', 5]], 3]][[[['A', 3]], [], [['A', 5]], 3]]Passed
double-tap scenario 8[[[['A', 4]], [], [['B', 3]], 3]][[[['A', 4]], [], [['B', 3]], 3]]Passed
double-tap scenario 9[[[], [], [], 1]][[[], [], [], 1]]Passed
double-tap scenario 10[[[], ['B'], [['A', 2]], 1]][[[], ['B'], [['A', 2]], 1]]Passed

SHA-256 / 6c91fd92cda2ef2d5a99da5ffc75755800b5164a0d1e9c82c1a9d5f7cf552461

HELD IN THE MEMBER ARCHIVE

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

This mechanism has 11 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:41:59.706245+00:00.

Case digest / 6a12179247b404c9a5c1cf880049e899de468a531c643345a34fdb25aa842212