Skip to content

Consensus Core

core/ConsensusCore.ts adapts Chronicle's Automerge sync protocol to an INetworkConnection. It listens for local state:changed events, tracks one sync state per peer, generates base64-encoded sync payloads, and sends them without echoing a change back to its source peer.

Inbound type: "sync" messages are decoded and passed to session.receiveSyncMessage(). The Chronicle applies the resulting document and emits a state change; ConsensusCore then sends the next message needed to acknowledge and converge the peer's sync state.

ConsensusCore does not interpret game actions or choose winners for domain conflicts. It provides transport-independent document synchronization. Authentication, room policy, relay behavior, and connection selection belong to the network layer.