feat(core): wire core/data's sync protocol into WireMeshTransport's frame handling - #136
Merged
Merged
Conversation
…rame handling WireMeshTransport gains an optional dataStorage constructor parameter; when set, every session's own frame stream is observed via acceptMeshSession's onFrame hook (wire-mesh#102) and answers a data-have with a data-request, a data-request with a data-entries, and applies an incoming data-entries to local storage -- the mechanical responder half of a real data-have/data-request/ data-entries exchange, riding wire-mesh-core's own handleDataHave/handleDataRequest/handleDataEntries directly. sendDataFrame is the matching mechanical send primitive: send this exact data-have or data-request frame to this already-connected peer. Deciding when to call it -- the catch-up policy, which peers' logs to track, when to send an initial data-have -- stays entirely the caller's own business; nothing here decides that on its own. A new connectionsByPeer map tracks the raw wire-mesh-core Connection each frame arrives on, since neither AcceptedMeshSession nor MeshSession exposes a generic "send an arbitrary frame" method the way the raw Connection itself does. Registration is unconditional (even for a still-quarantined, pre-approval connection) so a later sendDataFrame call can reach it, but handleDataFrame's own dispatch only acts once peerSessions actually tracks that device -- an unapproved stranger's data-domain frames are observed, never acted on. Tested against two real WireMeshTransport instances proving the full three-hop exchange lands an entry in the peer's own storage, not just that each primitive is individually reachable.
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 2.25.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Mearman
added a commit
that referenced
this pull request
Sep 16, 2026
sendRoomMessage gains an optional durable parameter; when true, it also records the message as a room-notice in the sender's own oplog via recordRoomSendNotice (#135), alongside the existing wire- authenticated fan-out. Deliberately opt-in per call, not automatic -- a caller decides per message whether it should be catch-up-able, matching this codebase's own established design for the mechanism. MeshStoreIdentity gains a dataStorage field (a KeyValueStorage instance), the same one WireMeshTransport's own frame responder (#136) reads and writes, so a durable send and a peer's later data-request against this device's log operate on one shared oplog. bridge-mesh.ts constructs it once via createNodeFsStorage(oplogDirFor(slot)) and wires it to both the transport and the store's own identity. Every existing fake MeshStoreIdentity fixture across the test suite needed the new required field added -- an opaque placeholder for the many tests that never exercise durable sends, a real in-memory KeyValueStorage for the ones (room-messaging-durable-send.test.ts, test-transport.ts's shared harness) that do.
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.
Adds an optional dataStorage constructor parameter to WireMeshTransport; when set, every session's own frame stream is observed via acceptMeshSession's onFrame hook (wire-mesh#102, already used for RelayHub composition) and answers a data-have with a data-request, a data-request with a data-entries, and applies an incoming data-entries to local storage -- the mechanical responder half of a real exchange, riding wire-mesh-core's own handleDataHave/handleDataRequest/handleDataEntries directly.
sendDataFrame is the matching mechanical send primitive (send this exact data-have or data-request frame to this already-connected peer). Deciding when to call it -- the catch-up policy, which peers' logs to track, when to send an initial data-have after a #135-style recordRoomSendNotice append -- stays entirely the caller's own business; nothing here decides that.
A new connectionsByPeer map tracks the raw Connection each frame arrives on, since neither AcceptedMeshSession nor MeshSession exposes a generic "send an arbitrary frame" method the way the raw Connection itself does. Registration is unconditional (even for a still-quarantined connection) so a later sendDataFrame call can reach it, but the actual responder dispatch only acts once peerSessions tracks that device -- an unapproved stranger's data-domain frames are observed, never acted on.
Tested against two real WireMeshTransport instances proving the full three-hop exchange lands an entry in the peer's own storage, not just that each primitive is individually reachable in isolation.
Refs #50.