Commit Graph
37 Commits
Author SHA1 Message Date
lucioandClaude Fable 5.1 1c24c9f67c control-channel: close lane (lead review); brief: input-capture
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-16 01:57:56 -07:00
lucioandClaude Opus 5 c03b8cdbcf control-channel: the Awake test moves into Session, where the beat is
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]>
2026-09-16 01:57:03 -07:00
lucioandClaude Sonnet 5 23eddb42b9 control-channel: round-2 QA — findings 1/2 fixed, new heartbeat-phase finding
Verified the rework against SocketStuff.cs, Common.cs, Event.cs and
InputHook.cs: finding 1 (Resolver two-group control flow) and finding 2
(id-collision gated to outbound) are both correctly fixed and cited, and
the literal ask for finding 3 (counter compare, not sliding window) is met.

But reading how ControlChannel's userActive is actually consumed by
Session.tick (Sources/MWBCore/Session.swift) turned up a new problem: the
channel's own beat-reset clock (ControlChannel.swift:457-471) is not
synchronized with any connection's actual heartbeat send, which is decided
independently by each Session's own nextHeartbeat. A connection can read
userActive == false at its own send instant even though real input happened
since its own previous heartbeat, silently downgrading Awake to Heartbeat
for that peer — in the default (blockScreenSaver = true) configuration.
Documented with a concrete timeline; verdict REWORK.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-09-16 01:52:56 -07:00
lucioandClaude Opus 5 fa9d914c91 control-channel: README rework entry for the three QA findings
Dated 2026-09-16 work-log entry answering findings 1-3 by number plus the
CLAUDE.md re-read, and the Assumptions bullets the fixes changed (name
resolution per group, the client-only id collision, the userActive
counter rule).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
2026-09-16 01:44:32 -07:00
lucioandClaude Opus 5 a892af6ca3 control-channel: userActive is the SendAwakeBeat test, not a time window
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]>
2026-09-16 01:41:41 -07:00
lucioandClaude Opus 5 c9ea89ac50 control-channel: detect a machine-id collision on client sockets only
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]>
2026-09-16 01:40:55 -07:00
lucioandClaude Opus 5 43dc25ac71 control-channel: Resolver filters the Name2IP and DNS groups separately
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]>
2026-09-16 01:40:22 -07:00
lucioandClaude Sonnet 5 09ca9906e8 qa: control-channel QA log — gates green, two protocol findings, verdict REWORK
Verified gates, TODO ticks against SocketStuff.cs, C1-C4 compliance,
Sendable justification and no key/packet logging. Two undocumented
behavioural deviations from Windows found by line-by-line comparison:
Resolver.addresses merges the Name2IP/DNS same-subnet checks instead of
running them separately (and misses Windows's early return when the
Name2IP group fails its check), and ControlChannel detects machine-id
collision on inbound connections too where Windows gates that on
IsClient. A third, minor, doc-only note on the userActive heuristic.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-09-16 01:37:08 -07:00
lucio 4e4a6d745c control-channel: a matrix change resets the dial budget 2026-09-16 01:26:36 -07:00
lucio 5a9a1dd60a control-channel: README (shipped API, deviations, work log) and TODO §3 2026-09-16 01:25:32 -07:00
lucio 3411293776 protocol: §10.3 control-channel findings (dial budget, reopen countdown, dedup, failure budget, Name2IP grouping) 2026-09-16 01:23:15 -07:00
lucioandClaude Fable 5.1 0db3aa8c9a session-matrix: topo handshakes 3/4/6, loop log
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-16 01:09:41 -07:00
lucioandClaude Fable 5.1 5f9a18cf83 session-matrix: close lane (lead review, topo handshakes 3/4/6)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-16 01:09:13 -07:00
lucio b085023f3a brief: control-channel 2026-09-16 01:08:39 -07:00
lucioandClaude Sonnet 5 43e5e35885 qa: session-matrix round-2 QA log (PASS) and a stale protocol.md citation
Verified the rework against the reference checkout at 3104d5c: read-error
counting now matches SocketStuff.cs:1330-1529/1531, Switcher.learn persists
only on a new machine (MachineStuff.cs:737/755), parkCursor carries the
HideMouseCursor gate (Common.cs:1488, MachineStuff.cs:1025), and contract
C1's forward(_:)-only stamping matches SkSend (Common.cs:901-935). Fixed a
trivially wrong citation in protocol.md §10.2 note 11 (Common.cs:914 ->
916, the actual PackageID increment line). tools/gates.sh green.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-09-16 01:07:10 -07:00
lucioandClaude Opus 5 f190157535 session-matrix: CLAUDE.md compliance pass and the rework work-log entry
Re-read all seven files: no force-unwrap, try!, fatalError or
precondition; longest file 422 lines (Session.swift), longest function 26
(countUntrusted); nothing logs. Corrected four SocketStuff.cs citations
that were off by one or two against the reference checkout (:1390->:1389,
:1441->:1439, the untrusted branch :1386-1500 -> :1387-1529).
`xcrun swift-format format -i --recursive Sources Package.swift` made no
further changes; tools/gates.sh green.

Work log gains a dated rework entry answering QA findings 1-3 and
contract C1 by number.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
2026-09-16 01:02:10 -07:00
lucioandClaude Opus 5 9980c685e2 session-matrix: Session cannot stamp an application packet (contracts C1)
Session.send(_:) is gone as a public entry point. Application traffic gets
its Id once from the process-wide PacketSequencer and reaches each target
connection through forward(_:), which never re-stamps; the per-connection
stamp survives only as `private func originate(_:)` for the packets
Windows also sends per connection — the handshake pair, heartbeats, Hi and
ByeBye. Nothing outside the type can now sequence an application packet.

README Assumptions and Handshakes say this is API-enforced rather than a
convention. protocol.md gains §10.2 note 11: SkSend increments PackageID
once before the socket loop (Common.cs:914) and hands the same DATA to
every matching socket, which is exactly what makes the receiver's 50-entry
replay ring collapse a peer pair's duplicate delivery.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
2026-09-16 01:00:39 -07:00
lucioandClaude Opus 5 9252158bbc session-matrix: parkCursor carries the HideMouseCursor gate
QA finding 3. HideMouseCursor moves the real cursor only when
(desMachineID != MachineID && desMachineID != ID.ALL) || byHideMouseMessage
(Common.cs:1488), and SwitchToMachine calls it after setting DesMachineID
(MachineStuff.cs:1025) — so control coming home parks nothing. The action
is now .parkCursor(destinationIsRemote:byHideMouseMessage:), both halves
of that gate pre-evaluated by Switcher (new .destinationIsRemote), so
input-inject can implement it without reading the Windows source. Spelled
out as a consumer rule in the README's Handshakes.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
2026-09-16 00:59:29 -07:00
lucioandClaude Opus 5 e0638de0b9 session-matrix: learn() persists only when a new machine is learned
QA finding 2. AddToMachinePool returns inside the TryFindMachineByName
branch (MachineStuff.cs:737), before the UpdateMachinePoolStringSetting()
at :755 — which is reachable only from the fall-through "new machine"
path. Switcher.learn was returning [.persistMachinePool] from the known
branch too, asking the app to write MachinePool to disk on every
heartbeat cadence tick from every already-known peer. It now returns [].

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
2026-09-16 00:58:52 -07:00
lucioandClaude Opus 5 0e6ee77dc7 session-matrix: a failed read spends the untrusted budget, as on Windows
QA finding 1. TcpReceiveData does not signal a bad read out of band: it
rewrites the buffer's type byte to PackageType.Error (0 bytes) or
PackageType.Invalid (short read) (SocketStuff.cs:574-578, 588-593) and
MainTCPRoutine runs that package through the whole loop body — the
private errCount for the Error case (:1332-1364), then the same untrusted
counting as any garbage packet (:1370-1529). So a run of malformed reads
ends in .invalidKey, not .error, and the trusted branch's
`receivedCount > 0` guard (:1531) keeps a 0-byte read out of the receiver.

Session.noteReceiveError now takes the byte count and feeds a synthetic
.error/.invalid packet through the new receive(_:bytesReceived:), which
is the loop body; feed() goes through it too. Written up as protocol
§10.2 note 10 and in the README's Assumptions.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
2026-09-16 00:58:29 -07:00
lucioandClaude Fable 5.1 08b243a29a contracts: sequencing, recovery, concurrency, shared constants, checkpoints
Written after an external review of the plan found cross-module
behaviour under-specified. TODO, topo, loop and the session-matrix
brief now reference docs/contracts.md.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-16 00:54:33 -07:00
lucioandClaude Sonnet 5 e588f1f71c session-matrix: QA log — gates green, three findings, verdict REWORK
Verified handshake/trust gate, dedup ring, one-row/two-row neighbour
search, matrix packet encoding, edge/landing geometry and the relative
and pixel biases against the Windows source; all faithful. Three
findings: the 10-untrusted-packets rule doesn't count read errors like
Windows does, Switcher.learn persists the pool on every known-peer
heartbeat, and SwitchAction.parkCursor doesn't carry enough information
for a future consumer to replicate HideMouseCursor's real-cursor-move
gating without rereading the Windows source.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-09-16 00:52:25 -07:00
lucio 2997c88440 session-matrix: Session.forward for pre-sequenced broadcasts; doc counts 2026-09-16 00:42:52 -07:00
lucio 605a9753b0 session-matrix: README handshakes/status/work log, TODO section 2 2026-09-16 00:42:32 -07:00
lucio 0e826d3b8f session-matrix: protocol.md 10.2 — handshake ids, Hi, cadence, matrix search quirks 2026-09-16 00:39:45 -07:00
lucio 55213cb9d8 brief: session-matrix 2026-09-16 00:22:33 -07:00
lucioandClaude Fable 5.1 be7c4e934b wire-core: close lane; lanes now run directly on main, no worktrees
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-16 00:21:29 -07:00
lucio 9283946c30 wire-core: lead review — merge 2026-09-16 00:21:25 -07:00
lucioandClaude Sonnet 5 e13748c225 wire-core: QA log — gates green, port verified against Windows source
Verdict: PASS. Checked every PackageType value, byte offset, the
checksum range, the magic-hash shift/overflow expression, PBKDF2
parameters and the 48-byte stream preamble against the Windows source
directly, and re-derived the documented magic-number and PBKDF2
examples independently in Python. No findings beyond the hex-gloss typo
already fixed in the prior commit.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-09-16 00:19:53 -07:00
lucio 56448cca0d qa: fix wrong hex annotation for the verified magic-number example
334517251 decimal is 0x13F0_5403, not 0x13EC_4F03; the decimal value
(independently re-verified against a Python SHA-512 chain) was already
correct, only the hex gloss was wrong.
2026-09-16 00:18:57 -07:00
lucio 8a59685dbf wire-core: publish the shipped API in Handshakes, log the lane, tick TODO §1 2026-09-16 00:13:00 -07:00
lucio 76fd4366d2 protocol: wire-core lane notes (invalid packets are 64 bytes, magic overflow, 48-byte preamble) 2026-09-16 00:11:36 -07:00
lucioandClaude Fable 5.1 9810ba441b brief: wire-core; consolidate the backlog into eight serial lanes
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-16 00:02:11 -07:00
lucioandClaude Fable 5.1 5bb415c7bc Drop remaining test-suite references from topo.md and guard.sh
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-15 23:55:57 -07:00
lucioandClaude Fable 5.1 87aeee6f93 Adopt the user's development rule: one lane at a time, no test suites
CLAUDE.md gains a 'How this project is developed' section: strictly
serial Dev (Opus 5) -> QA (Sonnet 5, code quality) -> lead inspection;
commit along the way without requiring every commit to compile; the
user is the tester. docs/loop.md, docs/topo.md and TODO.md are
rewritten to a serial lane order with no test-writing items; the test
targets are removed and tools/gates.sh is lint + layering grep + build.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-15 23:55:41 -07:00
lucioandClaude Fable 5.1 671b3dfa61 bootstrap: SwiftPM skeleton, gates, bundler, and the lane procedure
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]>
2026-09-15 23:46:24 -07:00
lucioandClaude Fable 5.1 69c0f7ab53 Plan the macOS port of Mouse Without Borders
Planning documents only: CLAUDE.md rules, README with decisions and
architecture, docs/protocol.md transcribed from the Windows source with
citations, docs/topo.md, TODO.md milestones and the first-wave feature
briefs (bootstrap, packet-codec, cipher-stream), plus tools/guard.sh.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-15 23:33:27 -07:00