ChannelConfig and BulkConfig carry MacCipherScheme; a change to it reopens
every connection the way a key change does. PeerConnection reads the
scheme's preamble length (16 legacy, 48 modern) instead of a hard-coded 48.
The diagnostic: the peer's opening bytes are kept until one packet has
framed. If the first packet fails framing under the configured scheme and
the same raw bytes frame under the other one, the connection closes with
.invalidKey(.cipherSchemeMismatch) and reports status
.cipherSchemeMismatch, so the menu names the setting to change rather than
blaming the security key. Costs one AES setup on a connection that was
going to fail anyway, and nothing at all on success.
The bulk channel needs no diagnostic: a transfer only starts with a peer
whose control connection already framed.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
ClipboardBridge ports CheckClipboardEx (Clipboard.cs:85-251), the in-band
chunking and reassembly (253-373), GetRemoteClipboard (377-449) and the
clipboard cases of Receiver.cs (273-380) and Event.cs (219-231). It is held
by the Engine actor and returns [ClipboardAction] the way Switcher returns
[SwitchAction]; ClipboardRelay is the Sendable sink the bulk channel and the
pasteboard watcher call.
Engine.swift: the bridge property and the authorised dispatch cases. Four
further lines (Engine.start/stop, EngineActions.applyConfiguration and the
.remoteClipboardWanted case) are beyond the letter of the brief and are
flagged in the feature README's Handshakes for the lead to rule on.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Listener and dials ported from SocketStuff.cs:475-495, 1566-1666 and
Clipboard.cs:401-485, 1068-1099; the transfer from Clipboard.ShakeHand
(961-1066), ReceiveAndProcessClipboardDataCore (498-923) and
SocketStuff.SendClipboardData/SendFileEx/SendData (1673-1931).
The 64-byte DATA on this connection is raw, not framed (docs/protocol.md
§10.7 (a)): bytes 1..3 must be zero and are checked.
Verified on loopback in the scratchpad: pull of text, push of a file,
a 3 MB image across chunks, and an unauthorised peer refused.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Round-2 QA finding: the channel reset beatInputEventCount on its own
clock, out of phase with every connection's heartbeat instant, so a
session could send Heartbeat (20) where Windows sends Awake (21) — and
Awake is what drives the peer's Common.HumanBeingDetected()
(Receiver.cs:245-248), the default-on BlockScreenSaver mechanism.
Windows's beat is the send: SendAwakeBeat() compares
lastRealInputEventCount against Event.RealInputEventCount and re-records
it in the same call (Common.cs:542-559). So the comparison belongs at the
send. Session.tick(now:userActive:) becomes
Session.tick(now:inputEventCount:), taking the raw process-wide counter
(Event.cs:51-55, InputHook.cs:223, 345) and keeping its own
beatInputEventCount — Common.lastRealInputEventCount, Common.cs:543 —
recorded on both branches (:558).
ControlChannel loses lastBeatAt and beatInputEventCount entirely;
noteUserActivity() only increments the counter and tick() hands the same
value to every connection. No userActive-shaped name is left in Sources.
Sources/MWBCore/Session.swift is session-matrix's file, edited for this
fix with the lead's authorisation, as is that lane's Handshakes section.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Item 4 of the rework brief: re-read the four MWBNet files against
CLAUDE.md. Sizes (189/234/356/524), function lengths, layering, the
one-sentence responsibility test, no force-unwrap/try!/fatalError/
precondition, no logging of any kind and no packet interpretation all
hold; `swift-format format -i` is a no-op on all four. Three citations
were off and are corrected against the source:
- `Common.SendByeBye` is Common.cs:611-615, not 612-616 (ControlChannel,
PeerConnection).
- `SkSend`'s stamp-and-fan-out is Common.cs:916-930, and the
`Des == ID.ALL` matrix test is :922-930, not :912-930 / :919-929.
`DisconnectReason.idCollision` and `channelDetectedIDCollision` now say
in their doc comments what the previous commit made true in the code:
the collision is looked for on outbound connections only
(SocketStuff.cs:1980-1992).
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
QA finding 3. `tick` computed `userActive` as "input within the last
heartbeat interval". `SendAwakeBeat` instead sends `Awake` when
`lastRealInputEventCount != Event.RealInputEventCount` — real input since
the previous heartbeat — and re-records the counter every time it runs
(Common.cs:545-558). Keep the same two counters: `noteUserActivity()` is
`Event.RealInputEventCount++` (InputHook.cs:223, 345) and the channel
re-records on its own heartbeat boundary, which is the one global beat
Windows's 100 ms timer runs for every socket (frmScreen.cs:565-575).
Also fixes the stale citation for this rule in docs/protocol.md §3.3,
which pointed at SendHeartBeat/screen-capture code (Common.cs:499-513,
662-676) instead of SendAwakeBeat.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
QA finding 2. The id check ran for every connection that finished its
handshake, so an inbound peer announcing our own id could force-close
every socket and make the app draw a new machine id. Windows runs the id
comparison and the keep-the-first-client rule as two branches of one
block gated by `status == Connected && tcp.IsClient`
(SocketStuff.cs:1980-1981): a server-accepted socket reaches neither.
Move the collision check inside the `isOutbound` gate the dedup half
already had, and say so in the README and docs/protocol.md §10.3 note 3.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
QA finding 1. `Resolver.addresses` applied one same-subnet check to the
union of the Name2IP mappings and the DNS results. `StartNewTcpClient`
checks each group on its own: the mapped group's failure is a `return`
that skips `Dns.GetHostEntry` entirely (SocketStuff.cs:934-937, 950), so
nothing is dialled for that name that round; the DNS group's failure
(:1037-1040) drops only the DNS addresses, because the mapped ones have
already been dialled (:941). Port that control flow, and document it in
the feature README's Assumptions and docs/protocol.md §10.3 note 6.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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]>