P2P Sync
Cortex embeds native peer-to-peer synchronization via QUIC transport and bloom-filter gossip. Multiple Mayros instances can share knowledge graphs, memory, and trace data automatically.
Dual sync modes
Mayros supports two synchronization modes:
| Mode | Transport | Latency | Mechanism |
|---|---|---|---|
| Native | QUIC gossip | Near-zero | Bloom-filter set reconciliation |
| Polled | REST HTTP | Interval-based | Delta sync polling |
On startup, Mayros probes the Cortex P2P API (/api/v1/p2p/status). If the sidecar has P2P enabled, sync automatically uses native mode. Otherwise, it falls back to polled mode.
Seed-based authentication
Nodes authenticate using a shared seed:
- Both nodes are configured with the same
cortex.p2p.seedvalue - Cortex derives a handshake key via
blake3(seed) - Only nodes with a matching seed can connect and exchange data
Bloom-filter gossip
In native mode, nodes synchronize through gossip rounds:
- Announce — each node broadcasts a bloom filter of its known triple IDs
- Request — receiving nodes identify IDs they're missing (false-positive-aware)
- Send — the announcing node sends the missing triples
- Tombstones — deleted triples propagate as tombstone markers with a 24-hour TTL
Gossip stats (round number, pending announcements, known IDs, bloom FPR) are visible via mayros sync status.
Peer discovery
- Manual peers: configure
cortex.p2p.manualPeersor usemayros sync pair - mDNS: enable
cortex.p2p.mdnsfor local network auto-discovery (service type:_mayros-cortex._tcp)
Pairing walkthrough
Enable P2P in config
On both machines, set a shared seed:
json5{ cortex: { p2p: { enabled: true, port: 19091, seed: "my-shared-secret", }, }, }
Start Machine A
bashmayros # starts normally with P2P enabled
Connect Machine B
Either configure the peer in config:
json5{ cortex: { p2p: { enabled: true, seed: "my-shared-secret", manualPeers: ["10.0.0.5:19091"], }, }, }
Or pair at runtime:
bashmayros sync pair machine-a http://10.0.0.5:8080
Verify connection
bashmayros sync status
In native mode, this shows connected peers, gossip round, known IDs, and sync statistics.
Graceful degradation
When Cortex lacks the P2P feature or p2p.enabled is false, Mayros transparently falls back to polled REST sync. The cortex.sync.nativeP2pPreferred option (default: true) controls whether native mode is preferred when available.
Configuration reference
| Key | Default | Description |
|---|---|---|
cortex.p2p.enabled | false | Enable native P2P |
cortex.p2p.port | 19091 | QUIC gossip port (1024–65535) |
cortex.p2p.seed | — | Shared secret for peer authentication (alphanumeric) |
cortex.p2p.manualPeers | [] | List of peer addresses (host:port) |
cortex.p2p.mdns | false | Enable mDNS local discovery |
Related
- Sync Modes — detailed comparison of native vs polled
- Cortex (AIngle) — sidecar overview
- sync CLI — command reference