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]>
This commit is contained in:
lucioandClaude Opus 5 committed 2026-09-16 01:00:39 -07:00
1 parent 9252158bbc
commit 9980c685e2
3 files changed
+62 -27

No files matched your search

+16
View File
@@ -592,3 +592,19 @@ sees them. One subsection per lane, appended, never rewritten.
- The trusted branch is guarded by `receivedCount > 0` (`:1531`), so a
0-byte read never reaches `Receiver.ProcessPackage`; a short read does,
and `PreProcess` drops it for being `Invalid` (`Receiver.cs:42-50`).
11. **`SkSend` stamps one `Id` and writes the same `DATA` to every matching
socket.** The increment happens once, before the loop
(`Common.cs:914`), and the same struct is then handed to `TcpSend` for
each socket whose `MachineId` matches `Des` — or, for `Des == ID.ALL`,
every socket that is not `exceptDes` and whose machine is in the matrix
(`:919-929`). `TcpSend` fills `Src` when it is `ID.NONE` and touches
nothing else (`SocketStuff.cs:666-669`). So a peer reached over two
connections receives the *same* `Id` twice and the receiver's 50-entry
replay ring collapses the second delivery (`Receiver.cs:40-82`) — which
is the mechanism, not an accident, and the reason contracts C1 requires
the app to stamp an application packet once and distribute it unchanged.
A per-connection stamp would give the duplicate a fresh `Id` and defeat
the ring. Only the packets Windows itself sends per connection — the
handshake pair, the heartbeat written on a fresh connection
(`SocketStuff.cs:1451`), `Hi` and `ByeBye` — go out through `TcpSend`
with no `SkSend` in front of them.