Skip to content

refactor(core): delete TlsTransport, step 6 of P2's substrate-swap sequencing - #61

Merged
Mearman merged 2 commits into
mainfrom
feat/p2-remove-legacy-transport
Sep 11, 2026
Merged

refactor(core): delete TlsTransport, step 6 of P2's substrate-swap sequencing#61
Mearman merged 2 commits into
mainfrom
feat/p2-remove-legacy-transport

Conversation

@Mearman

@Mearman Mearman commented Sep 11, 2026

Copy link
Copy Markdown
Member

Step 6 of #47's sequencing: deletes TlsTransport and the fingerprint-based identity path now that every bridge runs on WireMeshTransport (steps 4/5, #58/#59, plus the connection-approval quarantine fix in #60).

Two commits:

  1. A real bug found while auditing wire-mesh-transport.ts for this deletion: becomeCoordinator/addListener never got the same "report the OS-assigned port, not the literal 0 requested" fix TlsTransport already had (3876df5). Fixed both, extended the existing regression test to cover both, and dropped connect_accepted/connect_rejected/pong from the wire protocol union now that nothing constructs them any more.
  2. The deletion itself: tls-transport.ts removed; test-transport.ts's two wiring helpers collapse into one (wireTestTransport, now wiring WireMeshTransport); every test that built a peer directly against TlsTransport (broadcast-window, downtime-replay.integration, identity-restart) migrated to WireMeshTransport with device-id identity comparisons; listener-policy.integration.test.ts's one raw-TLS-wire-format probe rewritten against a real WireMeshTransport client session, dropping an unsafe cast into MeshStore's internals along the way; peer-id-verification.integration.test.ts deleted outright since the vulnerability class it guarded against can't occur under WireMeshTransport by construction (peer identity is never self-reported); wire-mesh-transport.integration.test.ts and wire-mesh-transport-approval.integration.test.ts deleted as fully redundant with mesh-e2e.integration.test.ts/approval.integration.test.ts now that there's only one substrate to test, after moving the one genuinely unique test (the quarantine-gate regression check) into approval.integration.test.ts.

Also fixed while verifying: approval.integration.test.ts's "mesh_pending lists pending connections" test shut down storeB immediately once its own assertions passed, without waiting for storeB's own fire-and-forget connectToRemote continuation to actually settle -- under WireMeshTransport's real round-trip timing this let shutdown race ahead of it, tracking a session into an already-shut-down transport that never got closed and hung the test runner. Fixed with the same convergence wait "accept establishes the peer connection" already uses.

85/85 tests pass, plus test:smoke and test:delivery, typecheck and lint clean.

…Listener

Both stored the literal port argument they were called with rather than
reading the actual bound port back from the listener, exactly the bug
already fixed for TlsTransport (3876df5) but never carried over to
WireMeshTransport's own independent implementation. Only matters when
called with port 0 for an OS-assigned free port -- listListeners() would
silently report 0 instead of the real port.

Added a shared listenerPort() helper (mirroring startDataServer's own
already-correct pattern) and used it in both places. Migrated
become-coordinator-actual-port.integration.test.ts's own regression test
onto WireMeshTransport and extended it to cover addListener too.

Also drops connect_accepted, connect_rejected, and pong from the
MeshMessage union: none has had a real constructor since the substrate
swap (connect_request's own accept/reject rides sendManageRequest's
request/response round trip directly, and peer identity now comes from
the TLS-authenticated connection itself, never a self-reported pong), so
route()'s own defensive drop case for them is now just dead cases for
variants that no longer exist.
…eMeshTransport

TlsTransport was agent-comms' own hand-rolled MeshTransport implementation
over X.509 certificates and newline-delimited JSON framing -- the
substrate every bridge ran on before the P2 migration. With all six
bridges cut over to WireMeshTransport (over @exadev/wire-mesh-core) and
its own connection-approval quarantine gate closing the security gap that
substrate swap introduced, nothing constructs a TlsTransport any more.

test-transport.ts's wireTestTransport and wireWireMeshTestTransport
wired two different transports onto a test MeshStore for exactly this
migration period; with only one transport left, they collapse into one
function (kept the wireTestTransport name, the one every existing test
already called). Every test that built its own peer directly against
TlsTransport (broadcast-window, downtime-replay.integration,
identity-restart) now does the same against WireMeshTransport, with
fingerprint-based identity comparisons swapped for deviceId, matching the
canonical identity createBridgeMesh already uses in production.

listener-policy.integration.test.ts's one test that spoke TlsTransport's
own wire format directly (a raw tls.connect() writing newline-delimited
JSON) is rewritten against a real WireMeshTransport client session
instead, and no longer reaches into MeshStore's internals through an
unsafe cast to observe the result -- it constructs its own transport
directly with a hand-rolled TransportEvents object instead, the same
pattern become-coordinator-actual-port.integration.test.ts already used.

peer-id-verification.integration.test.ts is deleted outright rather than
migrated: the vulnerability class it guarded against (a peer's
self-reported peerId not matching the certificate it authenticated with)
cannot occur under WireMeshTransport by construction, since peer identity
is never self-reported in the first place -- it's read directly from the
TLS-authenticated connection's own peerDeviceId.

wire-mesh-transport.integration.test.ts and
wire-mesh-transport-approval.integration.test.ts were written during the
migration specifically to prove WireMeshTransport reached parity with
TlsTransport's own behaviour. Now that wireTestTransport wires
WireMeshTransport for every test, they duplicate mesh-e2e.integration.test.ts
and approval.integration.test.ts/listener-policy.integration.test.ts
scenario-for-scenario. Deleted, after moving the one genuinely unique
test in the approval file over: the quarantine-gate regression test
proving a forged state_update from an unapproved connection is refused.

Fixed along the way: approval.integration.test.ts's own "mesh_pending
lists pending connections" test shut down storeB immediately once its
own assertions were satisfied, without waiting for storeB's own
fire-and-forget connectToRemote continuation (the mesh-formation
handshake) to actually settle. Under WireMeshTransport's real round-trip
timing this let the test's own shutdown race ahead of that continuation,
which then tried to track a session into an already-shut-down transport
and never closed it -- the same convergence wait "accept establishes the
peer connection" already uses fixes it.
@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-11T19:56:53.869589Z 1ec34c7 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 2a8d759 into main Sep 11, 2026
5 checks passed
@Mearman
Mearman deleted the feat/p2-remove-legacy-transport branch September 11, 2026 19:57
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.33.1 🎉

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