Negotiate wire-format version at connection start - #44
Merged
Conversation
Resolved via pnpm's git-dependency-with-subdirectory syntax against the ts/packages/core workspace member, mirroring the committed-dist/no-prepare-script pattern already proven for cddl.js, so the unpublished package installs cleanly without running any lifecycle script.
Fixes #31: a mixed fleet of old and new peers now negotiates down to what both actually support, or refuses loudly, instead of one side silently misinterpreting the other's state sync during a rolling upgrade. A client sends a small CBOR handshake frame as the very first bytes on a connection and does not wait; a server replies only in response to a received frame, so a legacy client never sees binary bytes at all. Version and shared-domain negotiation is wire-mesh-core's negotiate(), the same mechanism every wire-mesh consumer speaks. A peer that sends no frame is classified legacy and the connection proceeds exactly as before.
Wires attachSocketHandshake/attachWsHandshake into every client and server connection site across TCP, TLS, and WebSocket, each transport's write of its own first application message (introduce, connect_request, or pong) reordered to land after the handshake frame it was previously racing ahead of. Also updated package.json's test file list to include the new handshake suite (it lists tests explicitly rather than globbing).
A legacy peer's state_sync payload can genuinely be missing deliveryQueues (#30) or an entity's version field (#29), since nothing validates a state_sync message's shape beyond isMeshMessage's bare method check. normaliseWireState fills in the defaults (empty collections, version 1) before the payload reaches applyStateSync, so an old-build snapshot parses to a complete state instead of throwing. WireStateInput models exactly that tolerance as its own type rather than widening SerialisedState itself, so domain code elsewhere keeps working with the fully-populated type.
handshake.ts imports cbor2 directly for CDE frame encoding; it was only resolvable locally because @exadev/wire-mesh-core happens to pull it in transitively, which pnpm's strict install does not expose as an importable module for a package that never declared it. CI's fresh install surfaced this immediately.
Mearman
marked this pull request as ready for review
September 10, 2026 17:53
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.28.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Fixes #31
A mixed fleet of old and new peers now negotiates down to what both actually support, or refuses loudly, instead of one side silently misinterpreting the other's state sync during a rolling upgrade.
A client sends a small CBOR handshake frame as the very first bytes on a connection and does not wait; a server replies only in response to a received frame, so a legacy client never sees binary bytes at all. Version and shared-domain negotiation is
@exadev/wire-mesh-core'snegotiate(), the same mechanism every wire-mesh consumer speaks. A peer that sends no frame is classified legacy and the connection proceeds exactly as before.normaliseWireStatecovers the other direction: a legacy peer'sstate_syncpayload can genuinely be missingdeliveryQueues(#30) or an entity'sversionfield (#29), so it fills in the defaults before the payload reachesapplyStateSync.Depends on
@exadev/wire-mesh-core(ts/packages/corein ExaDev/wire-mesh) as a git-dependency-with-subdirectory workspace dependency.Test plan
normaliseWireState