Skip to content

feat(core): wire core/data's sync protocol into WireMeshTransport's frame handling - #136

Merged
Mearman merged 1 commit into
mainfrom
feat/data-sync-wiring
Sep 16, 2026
Merged

Mearman merged 1 commit into
mainfrom
feat/data-sync-wiring

Conversation

@Mearman

@Mearman Mearman commented Sep 16, 2026

Copy link
Copy Markdown
Member

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.

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

chatgpt-codex-connector Bot commented Sep 16, 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-16T02:51:39.101947Z 1f39999 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 5b29146 into main Sep 16, 2026
6 checks passed
@Mearman
Mearman deleted the feat/data-sync-wiring branch September 16, 2026 02:52
@github-actions

Copy link
Copy Markdown

🎉 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.
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