§2.5 is the legacy stream: the fixed salt, IV and iteration count with citations into the pre-a9e1f0f20e Encryption.cs, the missing cleartext header, why the sacrificial block exists, the MacCipherScheme setting and the mismatch diagnostic. §2.3 now says plainly that it describes v0.101 and later only. §10.9 records the one fact in this document confirmed against a live Windows machine rather than the source: the lead's independent Python probe completed the whole handshake against the user's PC under the legacy scheme, which proves framing, the magic hash, the packet layout and the handshake as transcribed, and localises the earlier failure to the stream cipher alone. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
17 KiB
17 KiB
TODO — mwb-mac backlog, one lane at a time
Lanes run strictly in this order (docs/loop.md). Each lane ticks only
its own lines. Items name the Windows behaviour to port and the
docs/protocol.md section (§) or Windows file that specifies it. There
are no test-writing items: the user tests the app (CLAUDE.md).
Target: a native macOS app with a menu-bar status item and a settings
window that supports every function of the PowerToys module except the
ones in §Out of scope. Cross-module behaviour (sequencing, recovery,
concurrency, shared constants, checkpoints) is fixed in docs/contracts.md.
0. bootstrap — done 2026-09-15
- SwiftPM skeleton,
tools/gates.sh,tools/bundle.sh,mwb --version/--check-permissions,docs/loop.md.
1. wire-core (core) — Sources/MWBCore/Packet.swift, Framing.swift, MagicHash.swift, CipherStream.swift
PackageType(rawUInt8, every value §1.2), big/small rule §1.1, unknown values tolerated.Packetover a 32/64-byte little-endian buffer with union views: mouse, keyboard, nonce, postAction, machineName, 48-byte clipboard payload at offset 16.- ASCII space-padded 32-byte machine name; non-ASCII refused.
Framing.seal/openexactly §1.3 (checksum bytes 2..31, magic top 16 bits, bytes 1–3 zeroed on open).magicNumber(for:)§2.1 (50 001 SHA-512 rounds,<< 23overlap, UTF-16 unit truncated to a byte, 32-byte buffer).- PBKDF2-HMAC-SHA512 100 000 rounds / 32 bytes via CommonCrypto;
CipherWriter/CipherReaderwith 16+16 header, sacrificial block, streaming AES-256-CBC no padding §2.3. No secrets in descriptions or logs. - Key rules §2.4: 16-char minimum, generator with the four charsets, display grouping.
2. session-matrix (core) — Sources/MWBCore/Sequencing.swift, Session.swift, Matrix.swift, MachinePool.swift, Switching.swift, Edge.swift, Coordinates.swift — done 2026-09-16
Session: sans-I/O state machine,feed(bytes) -> [Event],outgoing() -> Data,SocketStatusNA…Connected §3.2, injected clock.- Handshake §3.2: 10×
Handshake, nonce complement,HandshakeAck, adopt peer name/id, >10 untrusted ⇒ InvalidKey, self-connect close, >10 failures ⇒ give up. (The per-endpoint failure counter is the control-channel's — see that lane's §3 and the session-matrix Handshakes request.) - Dedup ring of 50 ids with the four exemptions §1.4;
Idcounter persisted via settings hook. - Heartbeat 60 s / 300 s,
AwakevsHeartbeat,Hi,ByeBye, 25 min liveness §3.3. Matrix(4 slots, one/two rows, wrap) andMachinePool(Name:Id,…, alive) §4.1;Matrixpacket encode/decode §4.2; learning peers from Heartbeat/Hello/Awake;LiveMachineMatrix.- Switching: move left/right/up/down,
desMachineID, ALL mode,MachineSwitched,NextMachine(id inWheelDelta) §4.4. - Edge detection §4.3 (primary-vs-desktop rule, 100 ms debounce,
corner blocking) and coordinate normalisation §4.4 (four rectangle
cases,
MOVE_MOUSE_RELATIVE/XY_BY_PIXELbiases).
3. control-channel (net) — Sources/MWBNet/ControlChannel.swift, PeerConnection.swift, Resolver.swift — done 2026-09-16
ChannelConfigstruct (C4); bounded outbound queue of 512 with 500 ms send timeout, overflow/timeout closes the connection (C3); per-connection read queue; events forwarded to anEngineSinkprotocol the app implements (the Engine itself arrives in lane 6).NWListeneron port+1, both IP families; one client per non-local matrix name; 1 s retry for 30 s; one connected client per peer §3.1.PeerConnection: oneSession+ cipher pair; serialised sends with 500 ms timeout; 32-then-32 receive; status reported for the UI colours.Resolver:getaddrinfo+Name2IPlines; optional /16 and reverse-lookup checks off by default §7.- Reconnect triggers §3.3:
NWPathMonitorchange, wake, reset, hotkey;reopenAll(); deletePlaceholder.swift. - Machine-ID collision ⇒ regenerate and reopen (§1.5).
4. input-capture (mac) — Sources/MWBMac/EventTap.swift, Permissions.swift, Screens.swift, Cursor.swift, Hotkeys.swift, RoutingState.swift, CaptureQueue.swift, Sources/MWBCore/KeyMap.swift, Sources/MWBCore/InputTypes.swift — done 2026-09-16
InputTypes.swift(core):CapturedInput,RoutingSnapshot, the injected-event tag constant, the escape-hotkey definitions (contracts C3, C4) — defined here so input-inject can consume them.Permissions.request…added to the preflight file; health check every 5 s reporting revocation (C2).- Session-level head-insert swallowing
CGEventTapon its own run-loop thread for keys, flags, mouse, scroll; reads the routing snapshot underOSAllocatedUnfairLockto decide swallowing synchronously; appends to the bounded capture ring (4096, motion coalesced, transitions never dropped — on overflow route local); passes tagged injected events; ontapDisabledByTimeout/UserInputre-enables and routes local (C2, C3, invariants 3, 4). - Escape: switch-machine hotkey naming the local slot and ⌃⌥⌘Escape flip the snapshot to local inside the callback, then notify (C2).
KeyMap: macOS keycode ↔ Windows VK,flagsChanged→ modifier VK pairs,LLKHFflags §5.1;WM_*mouse mapping, wheel ×120, X-buttons, absolute 0..65535 moves §5.2.- Hotkeys §4.5 with D4 (⌘=Win, ⌥=Alt): switch machine ⌃⌥F1–F4, lock (double-press ⇒ ALL + lock), reconnect, toggle Easy Mouse, switch-to-all; ignore when Shift/⌘ also held; Easy Mouse modes.
Screens: displays, primary, desktop union, corners; refresh on change.Cursor: park (centre-x, y=4) / hide, decouple while controlling remote, restore;HideMouse (50); clamp while controlled §5.3.
5. input-inject (mac) — Sources/MWBMac/Injector.swift, KeyState.swift — done 2026-09-16
Keyboardpacket →CGEventdown/up via KeyMap; modifiers asflagsChanged; repeats as repeated downs; 10 ms after key-up like Windows only if needed. (Not needed: the Windows sleep comparesLLKHFbits againstWM_KEYUPand never fires — §10.5 note 1.)Mousepacket → absolute move (de-normalise onto desktop bounds §4.4), buttons with click-count, wheel (WheelDelta/120), X-buttons.- Reads the injected-event tag from
InputTypes.swift(C4); tracks held keys/buttons;releaseAll()=ReleaseAllKeysfor every recovery row in C2 plus switch/lock/mode change; remote Win+L ⇒ lock (CGSession -suspend); remote Ctrl+Alt+Del ⇒ ignored, logged. (releaseAll()andlockThisMac()are published; calling them on each recovery row is app-shell's wiring — see the lane's Handshakes.)
6. app-engine (app + core) — Sources/mwb/main.swift, Sources/mwb/Engine.swift, Sources/mwb/EngineActions.swift, Sources/mwb/Recovery.swift, Sources/mwb/AppLifecycle.swift, Sources/MWBCore/Settings.swift, Sources/MWBMac/Log.swift
Settings: PowerToys schema (README §Settings), JSON load/save at~/Library/Application Support/mwb-mac/settings.json(0600), file watch, random key /MachineID/DeviceIDon first run,LastX/LastY/PackageIDpersistence, hostname validation (D7); mapping toSessionConfig/ChannelConfig/EdgeConfig/CaptureConfig/InjectorConfig(C4).- The
Engineactor (C3): owns Switcher, sequencer, replay filter, channel, tap, routing state, capture queue, injector, cursor, screens; publishes the routing snapshot; drains the capture ring; stamps ids once and forwards to every target (C1); dispatches.packetevents to injector / switcher; applies everySwitchAction. - Recovery wiring (C2): every trigger row end-to-end — escape
hotkeys, controlled-peer disconnect, 30 s silence, outbound stall,
tap disable, permission loss, quit/crash handler — each ending in
route-local +
releaseAll+Cursor.recouple. - Open requests from lanes 3–5: reopen countdown while nothing is
connected;
markControlledon every switch;EventTap.now()timestamps; swallow flags (false in ALL mode); lock chord forwarding; layout into everyinject;HotKeyLockMachine→InjectorConfig;Screens.startObserving()on main;canInject. mwbruns as anNSApplication(LSUIElement) with a minimal status item showing only "mwb: running / permissions missing" and Quit — enough to run headless for CP0 smoke by the lead; the real UI is lane 7.mwb --check-permissionskept. Single instance; file log at~/Library/Logs/mwb-mac/without key material.
7. app-ui (mac) — Sources/MWBMac/StatusItem.swift, Sources/MWBMac/SettingsWindow/*.swift, Sources/MWBMac/Notifications.swift, Sources/MWBMac/LaunchAgent.swift, Sources/mwb/UIBridge.swift
- Menu-bar
NSStatusItem: per-machine status dot in the documented colours (doc/devdocs/modules/mousewithoutborders.md), current controlled machine, Reconnect, Easy Mouse toggle, Lock all, Open Settings, Quit. - Settings window (SwiftUI in an
NSHostingView): machine matrix editor (4 slots, reorder, one/two rows), security key (show/generate/copy), port, every boolean in README §Settings, Easy Mouse picker, hotkey recorders, Name2IP editor, permissions status with "Open System Settings" buttons, LaunchAgent toggle (SMAppService.mainApp).DrawMouseCursoris the one property of README §Settings not shown:Settingspublishes no accessor for it (open Handshake request indocs/features/app-ui/README.md). - Status messages (
ShowClipboardAndNetworkStatusMessages) viaUserNotifications: connected / lost / wrong key, gated on the setting and on the process having a bundle identifier. - Checkpoint CP1 (contracts C5):
dist/mwb.apphanded to the user 2026-09-16 with the checklist: switch by edge and hotkey, wrap, one/two rows, keyboard with modifiers and function keys, wheel, reconnect after sleep, wrong key, and every C2 recovery row. Findings land in §10.
8. clipboard (core + net + mac) — Sources/MWBCore/ClipboardCodec.swift, Sources/MWBMac/Pasteboard.swift, Sources/MWBNet/BulkChannel.swift, Sources/MWBMac/ReceivedFile.swift
- Text codec
TXT/RTF/HTM+ SEP, UTF-16LE, raw DEFLATE §6.1 (Foundation.zlibis raw DEFLATE like .NETDeflateStream; say so); PNG images; single file path. — verified, §10.7 note 2 - In-band: 48-byte chunks at offset 16,
ClipboardDataEnd, zero-padding, 1 MB limit §6.2. - Bulk channel §6.3: listener on port,
Clipboard (69)broadcast, pull onMachineSwitched, push onClipboardAsk, cipher layout, 64-byteDATAeach way,"<len>*<name>"1024-byte UTF-16LE header, 1 MB chunks, 32-byte file padding, exact-length read. — the 64-byteDATAis raw, not framed: §10.7 note 1 - Files: atomic temp-file commit to
~/Desktop/MouseWithoutBorders/, 100 MB limit, folders refused,TransferFileflag; reveal in Finder. Pasteboard:changeCountpoll 500 ms, 1 s suppression, write on receive (text/RTF/HTML/PNG/file URL),ShareClipboardflag.- Checkpoint CP2 (C5): handed to the user 2026-09-16 together with CP1 — clipboard both ways, in-band and bulk.
9. extras (mac + core) — Sources/MWBMac/Awake.swift, Sources/MWBMac/Fullscreen.swift, Sources/MWBMac/FakeCursor.swift
BlockScreenSaverOnOtherMachines: hold anIOPMAssertion(PreventUserIdleDisplaySleep) whileAwakepackets arrive within the heartbeat window; release onHeartbeat/timeout (§3.3). Shipped as a 90 skIOPMAssertionTimeoutKeyrenewed perAwake, so the assertion lapses by itself rather than needing aHeartbeatto clear it (protocol §10.8 note 1).DisableEasyMouseWhenForegroundWindowIsFullscreen+EasyMouseFullscreenSwitchBlockExcludedApps: frontmost app viaNSWorkspace, fullscreen via the Accessibility API; excluded-apps editor in the settings window. Shipped viaCGWindowListCopy WindowInfobounds rather than the Accessibility API — no extra TCC grant, and it is the testSHQueryUserNotificationStateis approximating (protocol §10.8 note 3). The editor was already in the Behaviour pane from app-ui.Settings.drawMouseCursoraccessor + the Behaviour-pane toggle (app-ui's open request), thenDrawMouseCursor/DrawMouseEx: a borderless transparent overlay window drawing a cursor image where the remote pointer is, so the user sees where the pointer went (WindowsCustomCursor.cs).DrawMouseExaccepted and ignored. Known deviation for CP3: the Windows "only when the real cursor is suppressed" gate has no macOS equivalent (protocol §10.8 note 4).BlockMouseAtScreenCornersend-to-end;MoveMouseRelativelyend-to-end withNextMachine§4.4. Verified by reading againstMachineStuff.cs:203-283,Receiver.cs:145-172,Common.cs:516-539andInputHook.cs:311-312; corners needed no change. Two gaps recorded in the extras README Handshakes:NextMachineignores the held Ctrl/Shift Easy-Mouse key (input-capture does not publish it), and nothing sets an equivalent ofHasSwitchedMachineSinceLastCopy(clipboard).- Checkpoint CP3 (C5): handed to the user 2026-09-16 with CP1 and CP2.
10. polish — driven by the user's testing
- Each finding from the user becomes a line here with the file that
owns the fix. Findings and decisions:
docs/features/polish/README.md. - P1 legacy cipher scheme (PowerToys ≤ 0.100) with a
MacCipherSchemesetting defaulting to legacy, plus the scheme-mismatch diagnostic —CipherStream.swift,Settings.swift,PeerConnection.swift,BulkConnection.swift,SecurityPane.swift. AlsoSession.swift(InvalidKeyReason.cipherSchemeMismatch,SocketStatus.cipherSchemeMismatch),ChannelConfig.swift,BulkChannel.swift(BulkConfig.cipherScheme),StatusItem.swift,EngineActions.swift,ClipboardBridge.swift; protocol §2.5 and §10.9, README D3 and §Status. Legacy constants verified offline against Pythoncryptographyin both directions. - P1 follow-up (app-ui):
UIBridge.updateNotificationsposts no notification for.cipherSchemeMismatch— it only testsstatus == .invalidKey(UIBridge.swift:198-200). Oneelse if; requested in the polish README Handshakes. - Extras follow-ups: document that Windows pokes the idle timer only
when local input is idle (
Common.cs:561-572) — ours renews on everyAwake(§10.8 note 1); publishEventTap.easyMouseKeyDownso.nextMachinealso accepts the held Ctrl/Shift key (Event.cs:152-155); add aHasSwitchedMachineSinceLastCopyequivalent so identical content re-copied after a switch is resent (Event.cs:81,Receiver.cs:160). - CP3 question: at the PowerToys default
DrawMouseCursor = truea controlled Mac shows the overlay beside its own visible pointer (Windows draws only when the real cursor is hidden); decide the Mac default after the user has seen it. - Clipboard follow-ups (QA, lane 8): serialise bulk receives to
one at a time like
ClipboardReceiveGate(BulkChannel.swift); delete deadReceivedFile.stagingURL; fix the 20 MB text-gate comment (Pasteboard.swift); drop unusedimport AppKitinClipboardBridge.swift; distinct "File too big" on the send-time re-check (BulkConnection.swift). Engine↔UIBridgestrong cycle (AppLifecycle.swift,UIBridge.swift): make one side weak before any second pair can exist (QA, app-ui).
Later (post-v1)
- Keychain storage for
SecurityKey(D3). Heartbeat_exkey propagation (§3.3).- "Swap ⌘/⌃ when controlling Windows" option.
- Non-US layouts: VKs by position vs by character.
- Finder drag-and-drop file transfer (the Windows Explorer choreography §6.4, re-designed for Finder).
- CI on the Gitea runner running
tools/gates.sh. - Updates, notarization, Homebrew cask.
Out of scope, with reasons (D6)
- Windows service / logon-screen / UAC secure-desktop control: the macOS login window cannot be driven from a user-session event tap.
- Screen capture to Paint (
CaptureScreenCommand): niche; packets are ignored and logged. - GPO, telemetry,
ShowOriginalUI,UseService: Windows-only.