Sync manager¶
The sync manager (core/ConsensusCore.ts) adapts the game document's Automerge sync protocol to the
core-owned typed SyncTransport port. It tracks one sync state per opaque,
transport-created peer reference and accepts only non-empty Uint8Array
frames. Wire envelopes, JSON/base64, MessagePack, and sender IDs are outside
the core boundary.
Inbound frames are validated for size, rate, and Automerge encoding before
session.receiveSyncMessage() is called. Peer-open and peer-close explicitly
create and remove sync state. Outbound state advances only when
sendSync() accepts the frame; backpressure is represented by one coalesced
pending bit rather than an unbounded queue.
The sync manager synchronizes documents independently of transport. It does not interpret game actions or decide whether the merged state is legal. Authentication, room policy, relay behavior, and connection selection belong to the network layer.