feat: implement WireMeshTransport over wire-mesh-core - #57
Merged
Conversation
The P2 substrate swap's own centrepiece: a MeshTransport implementation carrying agent-comms' existing MeshMessage union as an opaque payload under one namespaced manage-command verb, rather than inventing new wire semantics. Coordinator election, the connection-approval flow, and listener management are all reimplemented against createMeshSession/acceptMeshSession/createTlsTransport, but MeshStore, CommsTool, and every agent/room/message behaviour above the transport are completely unaffected. Peer identity is authenticated at the transport layer via Connection.peerDeviceId (createTlsTransport's own cryptographic verification), never asserted on the wire, which is what lets the pong self-identification message retire entirely. connect_request's accept/reject flow maps onto sendManageRequest's own request/response round trip directly: the IncomingManageRequest's own respond callback is held open until acceptConnection/rejectConnection is actually called, since manage-request-frame already tolerates arbitrary latency between a request and its response. Two real bugs found and fixed while building this against the actual mesh-formation protocol, not assumed correct from the design alone: - connectToPeer's own "already connected" guard was checking the same peerSessions map used for general send()/broadcast() addressing, which an unrelated session to the same peer (most concretely the coordinator-client session connectToCoordinator opens) had already populated -- silently skipping the second, independent connection each direction of mesh formation depends on to push its own state. Outbound dials now track their own dedicated dataDials set instead. - peerSessions is a single-slot-per-peer map by construction, so when a peer legitimately has two simultaneous sessions (the same scenario above), the second one silently overwrote the first as far as shutdown's own cleanup could see -- leaving one session's underlying connection never closed, which made its own listener's close() wait forever for it to end. A separate allSessions registry, used only for shutdown, now closes every live session regardless of how many share a peer id. Both were caught by testing against the real, multi-peer mesh-formation protocol end to end rather than trusting the design in isolation.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
🎉 This PR is included in version 1.31.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This was referenced Sep 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #47 (P2: substrate swap). Step 3 of the phase's own sequencing plan -- see the P2 design pass. Not yet wired into any bridge; MeshStore.peerId still comes from the certificate fingerprint in production (step 4's own job).
WireMeshTransport implements the existing MeshTransport interface unchanged in shape, carrying agent-comms' existing MeshMessage union as an opaque payload under one namespaced manage-command verb (exadev.io/agent-comms-v1:frame) rather than inventing new wire semantics -- needs no CDDL/spec change, since manage-command-params is already an open extension socket for exactly this.
Peer identity is authenticated at the transport layer via Connection.peerDeviceId (createTlsTransport's own cryptographic certificate verification), never asserted on the wire -- which is what lets the pong self-identification message retire entirely; there's nothing left for it to prove that the connection itself hasn't already proven. connect_request's accept/reject flow maps onto sendManageRequest's own request/response round trip directly: the IncomingManageRequest's own respond callback is held open until acceptConnection/rejectConnection is actually called, since manage-request-frame already tolerates arbitrary latency between a request and its response -- no separate connect_accepted/connect_rejected messages needed.
Two real bugs found and fixed while building this against the actual mesh-formation protocol (not assumed correct from the design alone):
Test plan