input-inject: work log — rework entry answering both QA findings

Dated 2026-09-16 rework entry in docs/features/input-inject/README.md:
finding 1 accepted and fixed (chord tracking and the lock-hotkey test
now see the raw wire VK; `normalise(vk:)` is the posting path only),
finding 2 accepted as a documentation gap and recorded (Windows'
secure-desktop gate has no macOS analogue, so always-eat-and-lock is a
decision). Notes why 10.5 note 8 was appended rather than inserted.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
lucioandClaude Opus 5 committed 2026-09-16 03:07:01 -07:00
1 parent 9a1ad519de
commit c7d294a7a3
1 file changed
+59
+59
View File
@@ -349,6 +349,65 @@ the reasoning here).
and input-capture's request 2 partly declined with a redirect (the
injector encodes the lock chord, the Engine sends it).
### 2026-09-16 — dev, rework after QA (lane `input-inject`, from 22b077b)
Both QA findings addressed, one commit each; `tools/gates.sh` green
after each. Nothing was run that posts a `CGEvent`, locks the screen or
moves the cursor (CLAUDE.md invariant 5) — build-only verification
again. No public name changed, so the Handshakes block above still
describes what ships.
**Finding 1 — normalise-before-chord-match. Accepted, fixed.** The QA
reading is right and the lane's own §10.4 note 3 / §10.5 note 3 already
said so: `InputProcessKeyEx` matches side-specific VKs only, in both
switches (`App/Class/InputSimulation.cs:372-403` for the `LLKHF.UP`
half — `VK.LWIN/RWIN`, `VK.LCONTROL/RCONTROL`, `VK.LMENU/RMENU`,
`VK.LSHIFT/RSHIFT` — and `:418-438` for the down half, same labels), and
`Common.HotkeyMatched` (`:406`) is handed the raw `vkCode`. The side-less
`VK_SHIFT 0x10` / `VK_CONTROL 0x11` / `VK_MENU 0x12` that
`GetVkCodesList` (`App/Class/InputHook.cs:485-512`) puts on the wire
therefore fall through `default` and never move `shiftDown`/`ctrlDown`/
`altDown` on Windows, whereas our `normalise`-first ordering was setting
`chord.control`/`chord.option` from them — so a replayed lock chord
locked a Mac peer for any `HotKeyLockMachine` requiring Ctrl or Alt while
the Windows peer beside it ignored the same bytes (invariant 1).
`Injector.injectKey` (`Sources/MWBMac/Injector.swift`) now passes
`data.virtualKey` unchanged to `state.process(vk:isUp:lockMachine:)` and
calls `KeyState.normalise(vk:)` only afterwards, for
`keycode(for:flags:)`, `postKey` and `state.note` — the posting path,
which is where "macOS has no keycode meaning either Shift" actually
applies. `heldKeys` and therefore `eventFlags` and `releaseOrder()` are
unchanged: they still hold normalised side-specific VKs, so a side-less
key-up off the wire still releases the left modifier we posted. The
contract is now stated at both ends — on `KeyState.process` (raw VK
required, with the `:372-403` / `:418-438` citations) and on
`KeyState.normalise` (posting path only).
**Finding 2 — the `RunOnLogonDesktop`/`RunOnScrSaverDesktop` gate.
Accepted as a documentation gap; considered and inapplicable, now
recorded.** `InputSimulation.cs:408-409` skips the whole
`HotKeyLockMachine` body — `eatKey` included — on those two desktops.
Chased the flags: both are set only in `Program.Main`
(`App/Class/Program.cs:150-167`, properties at `App/Core/Common.cs:176-186`)
when the MWB **service** launches a second copy of the process onto the
Win32 `Winlogon` or `Screen-saver` secure desktop, one instance per
desktop with its own hook. macOS has no such split: one process per
login session, nothing of ours running behind `loginwindow` or the
screen saver, and a user-space `CGEventTap` neither receives nor posts
once the screen is actually locked. The service that creates those
desktops is out of scope in the first place (README D6). So the
condition is unconditionally true for a Mac receiver and
`KeyState.processDown`'s always-eat-and-lock is the faithful port, not
an omission. Written up in the Assumptions above, as
`docs/protocol.md` §10.5 note 8, and as a comment at the site. QA's own
observation that the hardcoded Win+L branch (`:450-460`) is ungated on
Windows too is repeated in all three places. No behaviour change.
Note 8 was **appended** rather than inserted before §10.5's "macOS-side
facts" note, so the existing citations of §10.5 note 7 (Assumptions,
work-log item 1) keep pointing at what they name.
## QA log
### 2026-09-16 — QA (lane `input-inject`, dev from 3c51e95)