Four targets (MWBCore, MWBNet, MWBMac, mwb) with a layering test that keeps MWBCore free of AppKit/CoreGraphics/Network; tools/gates.sh as the definition of done; tools/bundle.sh producing a signed dist/mwb.app; tools/lane.sh for lane worktrees; smoke binary with --version and --check-permissions. docs/loop.md records the Dev -> QA -> lead loop with the literal dispatch prompts, the wave schedule and escalations. Co-Authored-By: Claude Fable 5.1 <[email protected]>
14 KiB
14 KiB
TODO — mwb-mac backlog, by milestone
Legend: (core) pure logic in MWBCore, (net) MWBNet, (mac)
MWBMac, (app) executable/tooling. Section numbers are referenced
from docs/topo.md and feature READMEs as "TODO §n". Each lane's brief
names its files; a lane ticks only its own lines. Milestones are ordered;
lanes inside a milestone may run in parallel when docs/topo.md §3
says they are independent.
0. Toolchain and skeleton (M0, serial — docs/features/bootstrap)
- Unblock SwiftPM.
swift buildfailed with Command Line Tools only (README §Build). Fixed 2026-09-15 by installing Xcode 27.0; smoke build + XCTest verified. Recorded in the bootstrap README. Package.swiftwith targetsMWBCore,MWBNet,MWBMac,mwb, testsMWBCoreTests,MWBNetTests; Swift 6 language mode; macOS 14 minimum. Layering is enforced by a test inMWBCoreTeststhat grepsSources/MWBCoreforimport AppKit|CoreGraphics|Networkand fails on any hit.tools/gates.sh:swift-format lint --strict --recursive Sources Tests,swift build -Xswiftc -warnings-as-errors,tools/guard.sh -- swift test.tools/bundle.sh: release build →dist/mwb.app(Info.plist withLSUIElement = true, bundle idcom.luciochen.mwb-mac),codesign --force --sign "$MWB_SIGN_IDENTITY"; document how to create a self-signed identity once (D5)..swift-formatconfig;.gitignore(.build/,dist/).- Smoke executable:
mwb --version,mwb --check-permissions(prints preflight results, exit 0 when complete, 3 otherwise). docs/loop.md(the Dev → QA → lead procedure with literal prompts),docs/features/TEMPLATE.md,tools/lane.sh.
1. Wire core (M1 — two lanes: packet-codec ‖ cipher-stream)
1.1 packet-codec (core) — Sources/MWBCore/Packet.swift, Framing.swift, Tests/MWBCoreTests/PacketTests.swift, FramingTests.swift
PackageTypeenum, rawUInt8, every value from protocol §1.2;isBigrule (§1.1) as a table-driven test over all 256 byte values.Packetvalue type with the union views (mouse,keyboard,nonce,postAction,machineName) reading/writing a fixed 32/64-byte little-endian buffer at the documented offsets.MachineNameASCII, space-padded, trimmed; non-ASCII rejected.Framing.seal(magic:bytes:)andFraming.open(magic:bytes:)exactly as §1.3, including the "only bytes 2..31" checksum and the zeroing of bytes 1–3 on the receive side.- Golden vectors: hand-assembled bytes for
Handshake,Mouse,Keyboard,Matrix(slot 4, both flags),ClipboardTextchunk. Property test:open(seal(p)) == pfor random packets; flipping any of bytes 2..31 is detected; flipping bytes 32..63 is not (pinned as documented behaviour).
1.2 cipher-stream (core) — Sources/MWBCore/MagicHash.swift, CipherStream.swift, Tests/MWBCoreTests/MagicHashTests.swift, CipherStreamTests.swift
magicNumber(for key: String) -> UInt32per §2.1 (50 001 SHA-512 rounds, the<< 23overlap, UTF-16 code unit truncation to a byte). Pin one vector computed independently (Python transcription inTests/Fixtures/magic_reference.py, run once, result committed).deriveKey(password:salt:)= PBKDF2-HMAC-SHA512, 100 000 rounds, 32 bytes, via CommonCrypto. Vector pinned against Pythonhashlib.pbkdf2_hmac.CipherWriter/CipherReader: emit/consume the 16+16 header, the sacrificial block, then a raw AES-256-CBC no-padding stream (§2.3). Streaming API:write(Data) -> Data/read(Data) -> Dataaccumulating partial blocks; aCipherReaderfed one byte at a time must produce the same plaintext as one fed all at once.- Round-trip test writer→reader; a wrong key yields garbage, not a
throw, and the caller's framing check rejects it (that is the
Windows behaviour:
InvalidKeyafter >10 bad packets). - Never log key material: a test asserts
String(describing:)anddebugDescriptionof every crypto type omit key/salt/IV bytes.
2. Session logic (M2 — two lanes: session ‖ matrix-edge)
2.1 session (core) — Sources/MWBCore/Session.swift, Tests/MWBCoreTests/SessionTests.swift
- Sans-I/O
Sessionstate machine:feed(bytes)→[Event],outgoing()→ bytes; states NA…Connected per §3.2SocketStatus. - Handshake exactly as §3.2 (10×
Handshake, nonce complement,HandshakeAck, adopt peer name/id, >10 untrusted packets ⇒ InvalidKey, self-connection detection). - Dedup ring of 50 ids with the four exemptions (§1.4).
- Heartbeat scheduling (60 s / 300 s,
AwakevsHeartbeat),Hiprobe counting,ByeBye, 25 min liveness (§3.3) — all driven by an injected clock. - Two
Sessions wired back-to-back in a test reachConnectedboth ways and exchange aMousepacket.
2.2 matrix-edge (core) — Sources/MWBCore/Matrix.swift, Edge.swift, Tests/MWBCoreTests/MatrixTests.swift, EdgeTests.swift
Matrix(4 slots, one/two rows, wrap) andMachinePool(serialize/parseName:Id,…, 25 min alive) per §4.1.Matrixpacket encode/decode (slot inSrc, flags inType) §4.2.LiveMachineMatrix, moveLeft/Right/Up/Down,desMachineID/ ALL.- Edge detection §4.3 with the primary-vs-desktop rectangle rule,
100 ms debounce, corner blocking; coordinate normalization §4.4 with
all four rectangle cases,
MOVE_MOUSE_RELATIVE/XY_BY_PIXELbiases,NextMachineencoding (id inWheelDelta). - Table tests on 1-, 2- and 3-monitor layouts including a negative- origin monitor left of primary.
3. Platform capture (M3 — two lanes: control-channel ‖ event-tap)
3.1 control-channel (net) — Sources/MWBNet/ControlChannel.swift, Resolver.swift, Tests/MWBNetTests/LoopbackTests.swift
NWListeneron port+1, all interfaces, IPv4+IPv6; oneNWConnectionclient per non-local matrix name; 1 s retry for 30 s; dedup to one client socket per peer (§3.1).Resolver:getaddrinfo+Name2IPlines (§7); optional same-/16 check and reverse validation as settings, off by default.- Each connection owns one
Sessionand aCipherWriter/Readerpair per direction; send serialised through one queue with 500 ms send timeout; receive loop reads 32 then 32. - Reconnect on path change (
NWPathMonitor), wake (NSWorkspace.didWakeNotificationismac; expose areopenAll()the app calls), connection reset, hotkey. - Loopback test: two channels on 127.0.0.1 with random ports reach
Connectedand pass 1 000Mousepackets in order with no dedup drops; wrong key on one side ends inInvalidKey.
3.2 event-tap (mac) — Sources/MWBMac/EventTap.swift, Permissions.swift, Sources/MWBCore/KeyMap.swift, Tests/MWBCoreTests/KeyMapTests.swift
Permissions: preflight/request Accessibility + Input Monitoring; never loops on request; reports per-permission state.EventTap: session tap, head-insert, default (swallowing) tap for key down/up/flagsChanged, mouse move/drag/buttons/scroll; callback converts to aCapturedInputvalue and enqueues; returnsnilto swallow when the destination is remote; passes tagged injected events through; re-enables on timeout/user-input disable (invariant 3 and 4).- Modifier tracking (Cmd/Ctrl/Opt/Shift) and hotkey matching per
§4.5 with D4 mapping; the tap reports
.hotkey(...)events. KeyMap: macOS keycode → Windows VK and back,flagsChanged→ modifier VK down/up pairs,LLKHFflags,NSEvent.ModifierFlags→ nothing (VKs carry modifiers themselves). Table pinned by tests: letters, digits, F1–F19, arrows, editing keys, numpad, punctuation on US layout; unknown keys are dropped and counted.- Mouse:
WM_*mapping, wheel line deltas × 120, X-buttons, moves as absolute 0..65535 against the primary display (§5.2, §4.4).
4. Platform injection and screens (M4 — two lanes: input-inject ‖ screens-cursor)
4.1 input-inject (mac) — Sources/MWBMac/Injector.swift
Keyboardpacket →CGEventkey down/up with VK→keycode; modifier VKs →flagsChangedwith maintained flag state;EXTENDEDignored; autorepeat handled by repeated downs like Windows.Mousepacket → move (absolute, §4.4 de-normalization onto the desktop bounds), buttons with click-count tracking (double-click = two downs withinNSEvent.doubleClickInterval, since Windows drops*DBLCLK), wheel (WheelDelta/120 lines), X-buttons → other mouse buttons 3/4.- Every posted event tagged with the injected marker (README mapping).
ReleaseAllKeysequivalent on switch/lock.- Remote Win+L → lock; remote Ctrl+Alt+Del → nothing (documented).
4.2 screens-cursor (mac) — Sources/MWBMac/Screens.swift, Cursor.swift
Screens: active displays, primary (CGMainDisplayID), desktop union, corner points forBlockMouseAtScreenCorners; refresh onNSApplication.didChangeScreenParametersNotification.Cursor: park at primary centre-x / y=4 (HideMouseon) or centre;CGAssociateMouseAndMouseCursorPosition(false)while controlling a remote, deltas read from the tap; restore on return to the last local position.HideMouse (50)packet handling.
5. Clipboard and app shell (M5 — two lanes: clipboard-inband ‖ menubar-app)
5.1 clipboard-inband (core + mac) — Sources/MWBCore/ClipboardCodec.swift, Sources/MWBMac/Pasteboard.swift
- Text codec:
TXT/RTF/HTM+ SEP, UTF-16LE, raw DEFLATE (§6.1). First task: prove Foundation.zlib== .NETDeflateStreamon a fixture (README mapping note); fall back tocompression_streamwithCOMPRESSION_ZLIBif not. - 48-byte chunking at offset 16,
ClipboardDataEnd, zero-padding semantics on decode (§6.2); 1 MB in-band limit. - Image: PNG from
NSPasteboard(.png, else TIFF → PNG). Pasteboard:changeCountpoll at 500 ms, 1 s suppression, write on receive; never write when we were the source.- Feature flag from
ShareClipboard.
5.2 menubar-app (app + mac) — Sources/mwb/*, Sources/MWBMac/StatusItem.swift, Sources/MWBCore/Settings.swift
Settings: schema per README §Settings, load/save/watch, 0600, random key/MachineID/DeviceIDon first run.NSStatusItemwith per-machine status dots in the documented colours, matrix editor (4 names, one/two rows), key entry, port, toggles; "Reconnect", "Quit".- Permissions onboarding panel; LaunchAgent install/uninstall.
- Single instance via pid-file lock; log to
~/Library/Logs/mwb-mac/with rotation, never key material. - Lock-machine hotkey →
CGSession -suspend(decide vspmset displaysleepnow; record).
6. Bulk transfer and interop (M6 — two lanes: clipboard-bulk ‖ interop-vectors)
6.1 clipboard-bulk (net) — Sources/MWBNet/BulkChannel.swift
- Listener on port;
Clipboard (69)broadcast on big data; pull onMachineSwitched, push onClipboardAsk(§6.3). - Bulk handshake: cipher layout, one 64-byte
DATAeach way,ResolveID(name) == Srcgate, 1024-byte UTF-16LE header"<len>*<name>", 1 MB chunks, 32-byte file padding, exact-length read, atomic temp-file commit to~/Desktop/MouseWithoutBorders/. - 100 MB file limit, single file only, folders refused with the
Windows message;
TransferFileflag.
6.2 interop-vectors (tests) — Tests/Fixtures/, tools/winvectors/
- A small .NET console program (
tools/winvectors/, runs on a Windows machine with the PowerToys tree) that links the MWB assembly and dumps:Get24BitHashfor 5 keys, PBKDF2 key for fixed salt, one full encrypted control-stream capture for a scripted handshake with fixed RNG, framed bytes for each packet type, a deflated clipboard text fixture. - Until a Windows machine is available: a
pcapof a real Windows↔Windows session (user-provided) plus the typed key lets us decrypt and replay; document how to capture it. - Every
[transcribed]mark indocs/protocol.mdflips to[verified]only when a fixture from this lane pins it.
7. End to end (M7, serial — needs the real devices)
docs/features/end-to-end: Mac ↔ Windows over the LAN, both directions, checklist: switch by edge, by hotkey, wrap, one/two rows, keyboard incl. modifiers and function keys, wheel, clipboard text/image/file, reconnect on sleep/wake, wrong key, kill the peer mid-control (invariant 3).- Soak: 8 h with heartbeats and periodic switches under
tools/guard.sh; memory flat; tap never stays disabled. docs/perf/README.mdfilled with measured tap-callback and end-to-end latencies.
8. Later (post-v1, ordered by value)
- CI on the existing Gitea runner (
.gitea/workflows/ci.ymlrunningtools/gates.sh) — only once invariant 5 is provably safe on a runner that shares the user's session. - Keychain storage for
SecurityKey(D3). - Easy Mouse fullscreen suppression + excluded apps (
NSWorkspacefrontmost app,NSWindowfullscreen detection via Accessibility). Heartbeat_exkey propagation (§3.3) so a key typed on one machine spreads.- "Swap ⌘/⌃ when controlling Windows" option.
- Non-US layouts: send VKs by physical position vs by character — needs a decision and a test matrix.
- Sparkle-style updates, notarization, Homebrew cask.
9. Out of scope, with reasons (D6)
- Windows service / logon-screen / UAC secure desktop control: macOS login window cannot be driven by a user-session event tap.
- Explorer drag-and-drop (§6.4): depends on a Windows-shell helper; a Finder equivalent is a separate design.
- Screen capture to Paint (
CaptureScreenCommand,ClipboardCapture): niche; packets are ignored and logged. - GPO, telemetry,
ShowOriginalUI: Windows-only. - Animated fake cursor (
DrawMouse): cosmetic.