Skip to content

feat: implement WireMeshTransport over wire-mesh-core - #57

Merged
Mearman merged 1 commit into
mainfrom
feat/p2-wire-mesh-transport-impl
Sep 11, 2026
Merged

feat: implement WireMeshTransport over wire-mesh-core#57
Mearman merged 1 commit into
mainfrom
feat/p2-wire-mesh-transport-impl

Conversation

@Mearman

@Mearman Mearman commented Sep 11, 2026

Copy link
Copy Markdown
Member

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):

  • 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 (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.
  • peerSessions is a single-slot-per-peer map by construction, so when a peer legitimately has two simultaneous sessions, the second silently overwrote the first as far as shutdown's own cleanup could see -- leaving one connection never closed, which made its own listener's close() wait forever. A separate allSessions registry, used only for shutdown, now closes every live session regardless of how many share a peer id.

Test plan

  • New parity test mirroring mesh-e2e.integration.test.ts's own scenario (coordinator discovery, rooms, messaging, delivery) against WireMeshTransport instead of TlsTransport
  • New parity tests mirroring approval.integration.test.ts's own accept/reject scenarios, plus addListener/removeListener/listListeners
  • Full existing suite (74 tests total) including state-sync-convergence.test.ts/downtime-replay.test.ts (transport-free, unmodified) plus federation/delivery/visibility all still pass

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review Completed 2026-09-11T18:19:10.500483Z 9c95bee PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Mearman
Mearman merged commit ba21335 into main Sep 11, 2026
5 checks passed
@Mearman
Mearman deleted the feat/p2-wire-mesh-transport-impl branch September 11, 2026 18:09
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.31.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant