FAILURE MAP
← Case archive

FA-31856 / Keyboard interactions / Open access

Keyboard usage snapshot delta decoder: Modifier mask indexes bit values incorrectly or reverses modifier positions · case 01

The event trace violates the modifier bit rule and produces incorrect keyboard state or command output.

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

ROOT CAUSE

Modifier mask indexes bit values incorrectly or reverses modifier positions.

THE FAILURE

Modifier mask indexes bit values incorrectly or reverses modifier positions.

Unsuccessful approach: The partial repair changes this transition to mask & (1<<(7-bit)), which still violates the model contract on the explicit regression traces.

Case contract

Each report is [modifier_mask,usage_slots]. Usages are integers >=0; 0 is padding, 1 is an error sentinel that invalidates the whole report. Other usages are unique logical keys even when slots duplicate. Modifier bits 0..7 identify M0..M7. Emit sorted key releases, sorted modifier releases, sorted modifier presses, then sorted key presses per valid report. Return emitted [phase,kind,identity] and final usage/modifier sets. 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):
        old_keys=set(); old_mods=set(); out=[]; rejected=0
        for mask,slots in c:
            if 1 in slots:
                rejected+=1
                continue
            keys=set(slots)-{0}
            mods={bit for bit in range(8) if mask & bit}
            for key in sorted(old_keys-keys): out.append(['up','key',key])
            for mod in sorted(old_mods-mods): out.append(['up','mod',mod])
            for mod in sorted(mods-old_mods): out.append(['down','mod',mod])
            for key in sorted(keys-old_keys): out.append(['down','key',key])
            old_keys=keys
            old_mods=mods
        return [out,sorted(old_keys),sorted(old_mods),rejected]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('hid-report-delta scenario 0', solve([[]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 1', solve([[[0, [0, 0]]]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 2', solve([[[1, [2, 3, 3, 0]], [1, [2, 3, 0]]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3]], [2, 3], [0], 0]] * N)
check('hid-report-delta scenario 3', solve([[[1, [2, 3]], [2, [3, 4]], [0, []]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3], ['up', 'key', 2], ['up', 'mod', 0], ['down', 'mod', 1], ['down', 'key', 4], ['up', 'key', 3], ['up', 'key', 4], ['up', 'mod', 1]], [], [], 0]] * N)
check('hid-report-delta scenario 4', solve([[[4, [5]], [0, [1, 0, 0]], [4, [5]]]] * N), [[[['down', 'mod', 2], ['down', 'key', 5]], [5], [2], 1]] * N)
check('hid-report-delta scenario 5', solve([[[0, [1, 0]], [0, [1, 2]]]] * N), [[[], [], [], 2]] * N)
check('hid-report-delta scenario 6', solve([[[128, [2]], [0, []], [128, [2]]]] * N), [[[['down', 'mod', 7], ['down', 'key', 2], ['up', 'key', 2], ['up', 'mod', 7], ['down', 'mod', 7], ['down', 'key', 2]], [2], [7], 0]] * N)
check('hid-report-delta scenario 7', solve([[[0, [2]], [0, []], [0, [2]]]] * N), [[[['down', 'key', 2], ['up', 'key', 2], ['down', 'key', 2]], [2], [], 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 fixtureActualExpectedOutcome
hid-report-delta scenario 0[[[], [], [], 0]][[[], [], [], 0]]Passed
hid-report-delta scenario 1[[[], [], [], 0]][[[], [], [], 0]]Passed
hid-report-delta scenario 2[[[['down', 'mod', 1], ['down', 'mod', 3], ['down', 'mod', 5], ['down', 'mod', 7], ['down', 'key', 2], ['down', 'key', 3]], [2, 3], [1, 3, 5, 7], 0]][[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3]], [2, 3], [0], 0]]Failed
hid-report-delta scenario 3[[[['down', 'mod', 1], ['down', 'mod', 3], ['down', 'mod', 5], ['down', 'mod', 7], ['down', 'key', 2], ['down', 'key', 3], ['up', 'key', 2], ['up', 'mod', 1], ['up', 'mod', 5], ['down', 'mod', 2], ['down', 'mod', 6], ['down', 'key', 4], ['up', 'key', 3], ['up', 'key', 4], ['up', 'mod', 2], ['up', 'mod', 3], ['up', 'mod', 6], ['up', 'mod', 7]], [], [], 0]][[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3], ['up', 'key', 2], ['up', 'mod', 0], ['down', 'mod', 1], ['down', 'key', 4], ['up', 'key', 3], ['up', 'key', 4], ['up', 'mod', 1]], [], [], 0]]Failed
hid-report-delta scenario 4[[[['down', 'mod', 4], ['down', 'mod', 5], ['down', 'mod', 6], ['down', 'mod', 7], ['down', 'key', 5]], [5], [4, 5, 6, 7], 1]][[[['down', 'mod', 2], ['down', 'key', 5]], [5], [2], 1]]Failed
hid-report-delta scenario 5[[[], [], [], 2]][[[], [], [], 2]]Passed
hid-report-delta scenario 6[[[['down', 'key', 2], ['up', 'key', 2], ['down', 'key', 2]], [2], [], 0]][[[['down', 'mod', 7], ['down', 'key', 2], ['up', 'key', 2], ['up', 'mod', 7], ['down', 'mod', 7], ['down', 'key', 2]], [2], [7], 0]]Failed
hid-report-delta scenario 7[[[['down', 'key', 2], ['up', 'key', 2], ['down', 'key', 2]], [2], [], 0]][[[['down', 'key', 2], ['up', 'key', 2], ['down', 'key', 2]], [2], [], 0]]Passed

SHA-256 / 74da1ca59d604205d07b00237a03aa8bf0c113db4511332bdcc82ce41db1fb0e

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):
        old_keys=set(); old_mods=set(); out=[]; rejected=0
        for mask,slots in c:
            if 1 in slots:
                rejected+=1
                continue
            keys=set(slots)-{0}
            mods={bit for bit in range(8) if mask & (1<<(7-bit))}
            for key in sorted(old_keys-keys): out.append(['up','key',key])
            for mod in sorted(old_mods-mods): out.append(['up','mod',mod])
            for mod in sorted(mods-old_mods): out.append(['down','mod',mod])
            for key in sorted(keys-old_keys): out.append(['down','key',key])
            old_keys=keys
            old_mods=mods
        return [out,sorted(old_keys),sorted(old_mods),rejected]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('hid-report-delta scenario 0', solve([[]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 1', solve([[[0, [0, 0]]]] * N), [[[], [], [], 0]] * N)
check('hid-report-delta scenario 2', solve([[[1, [2, 3, 3, 0]], [1, [2, 3, 0]]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3]], [2, 3], [0], 0]] * N)
check('hid-report-delta scenario 3', solve([[[1, [2, 3]], [2, [3, 4]], [0, []]]] * N), [[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3], ['up', 'key', 2], ['up', 'mod', 0], ['down', 'mod', 1], ['down', 'key', 4], ['up', 'key', 3], ['up', 'key', 4], ['up', 'mod', 1]], [], [], 0]] * N)
check('hid-report-delta scenario 4', solve([[[4, [5]], [0, [1, 0, 0]], [4, [5]]]] * N), [[[['down', 'mod', 2], ['down', 'key', 5]], [5], [2], 1]] * N)
check('hid-report-delta scenario 5', solve([[[0, [1, 0]], [0, [1, 2]]]] * N), [[[], [], [], 2]] * N)
check('hid-report-delta scenario 6', solve([[[128, [2]], [0, []], [128, [2]]]] * N), [[[['down', 'mod', 7], ['down', 'key', 2], ['up', 'key', 2], ['up', 'mod', 7], ['down', 'mod', 7], ['down', 'key', 2]], [2], [7], 0]] * N)
check('hid-report-delta scenario 7', solve([[[0, [2]], [0, []], [0, [2]]]] * N), [[[['down', 'key', 2], ['up', 'key', 2], ['down', 'key', 2]], [2], [], 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 fixtureActualExpectedOutcome
hid-report-delta scenario 0[[[], [], [], 0]][[[], [], [], 0]]Passed
hid-report-delta scenario 1[[[], [], [], 0]][[[], [], [], 0]]Passed
hid-report-delta scenario 2[[[['down', 'mod', 7], ['down', 'key', 2], ['down', 'key', 3]], [2, 3], [7], 0]][[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3]], [2, 3], [0], 0]]Failed
hid-report-delta scenario 3[[[['down', 'mod', 7], ['down', 'key', 2], ['down', 'key', 3], ['up', 'key', 2], ['up', 'mod', 7], ['down', 'mod', 6], ['down', 'key', 4], ['up', 'key', 3], ['up', 'key', 4], ['up', 'mod', 6]], [], [], 0]][[[['down', 'mod', 0], ['down', 'key', 2], ['down', 'key', 3], ['up', 'key', 2], ['up', 'mod', 0], ['down', 'mod', 1], ['down', 'key', 4], ['up', 'key', 3], ['up', 'key', 4], ['up', 'mod', 1]], [], [], 0]]Failed
hid-report-delta scenario 4[[[['down', 'mod', 5], ['down', 'key', 5]], [5], [5], 1]][[[['down', 'mod', 2], ['down', 'key', 5]], [5], [2], 1]]Failed
hid-report-delta scenario 5[[[], [], [], 2]][[[], [], [], 2]]Passed
hid-report-delta scenario 6[[[['down', 'mod', 0], ['down', 'key', 2], ['up', 'key', 2], ['up', 'mod', 0], ['down', 'mod', 0], ['down', 'key', 2]], [2], [0], 0]][[[['down', 'mod', 7], ['down', 'key', 2], ['up', 'key', 2], ['up', 'mod', 7], ['down', 'mod', 7], ['down', 'key', 2]], [2], [7], 0]]Failed
hid-report-delta scenario 7[[[['down', 'key', 2], ['up', 'key', 2], ['down', 'key', 2]], [2], [], 0]][[[['down', 'key', 2], ['up', 'key', 2], ['down', 'key', 2]], [2], [], 0]]Passed

SHA-256 / 076e8b1415be1f99acb0f150a6d7c8244b2413e08ba74ebcb743560f374bd808

HELD IN THE MEMBER ARCHIVE

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

This mechanism has 8 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:06.500913+00:00.

Case digest / 637adb30b97ab952ff45bd46295f72a1b3cca0ef54ae64b8102b8cd56775a95d