[!WARNING] Experimental research software. APIs and wire protocols may change without notice. Production quality is targeted for
v1.0.
What is mosaik?
Mosaik provides primitives for peer discovery, typed pub/sub streams, Raft consensus groups, and replicated data structures. Nodes deployed on plain VMs self-organize into a functioning topology using only a secret key, a gossip seed, and role tags — no orchestration, configuration templates, or DevOps glue required.
All resource identifiers are intent-addressed: derived from human-readable strings via blake3 hashing. Two nodes that independently declare the same name converge on the same identifier without prior coordination.
Mosaik has first-class support for Trusted Execution Environments — nodes inside Intel TDX enclaves can generate hardware-attested identity tickets, and peers can require valid attestation before accepting connections.
┌────────────────────────────────────────────────────────┐
│ Network │
│ │
│ ┌────────────┐ ┌───────────┐ ┌───────────┐ │
│ │ Discovery │ │ Streams │ │ Groups │ │
│ │ │ │ │ │ │ │
│ │ Announce │ │ Producer │ │ Bonds │ │
│ │ Catalog │ │ Consumer │ │ Raft │ │
│ │ Sync │ │ Status │ │ RSM │ │
│ └────────────┘ └───────────┘ └───────────┘ │
│ │
│ ┌─────────────────┐ ┌──────────┐ ┌───────────────┐ │
│ │ Collections │ │ Tickets │ │Transport │ │
│ │ │ │ │ │ │ │
│ │ Map · Vec · Set │ │ JWT │ │ QUIC · Relay │ │
│ │ Cell · Once │ │ TDX │ │ mDNS · pkarr │ │
│ │ PriorityQueue │ │ │ │ │ │
│ └─────────────────┘ └──────────┘ └───────────────┘ │
└────────────────────────────────────────────────────────┘
Quick taste
use *;
let network_id = from;
// Node 0: produce a typed stream
let n0 = new.await?;
let mut producer = n0.streams.;
producer.when.subscribed.minimum_of.await;
producer.send.await?;
// Node 1: consume the same stream — discovered automatically
let n1 = new.await?;
let mut consumer = n1.streams.;
let reading = consumer.next.await.unwrap;
// Replicated collections — same ergonomics as std types
let map = new;
map.when.online.await;
map.insert.await?;
// Read-only replica on another node
let reader = reader;
reader.when.online.await;
assert_eq!;
See the documentation for the full API guide covering streams, groups, collections, tickets, and TEE support.
Getting started
Prerequisites: Rust toolchain >= 1.93
Examples
# P2P group chat — start several instances to chat
# Distributed order-matching engine
# DHT bootstrap discovery
# Distributed rate limiter
Running tests
# All integration tests (single-threaded required)
TEST_TRACE=on
# A specific module
TEST_TRACE=on
# Verbose tracing
TEST_TRACE=trace
# Extend timeouts for slow networks
TIME_FACTOR=3 TEST_TRACE=on
Observability
Every subsystem emits metrics via the metrics facade. Enable the built-in Prometheus exporter:
let network = builder
.with_prometheus_addr
.build
.await?;
See the Metrics reference for the full catalog.
Roadmap
Stage 1: Primitives
- Discovery — gossip announcements, catalog sync, DHT bootstrap, tags
- Streams — producers, consumers, predicates, limits, online conditions, stats
- Groups — Raft consensus, membership, shared state, failover
- Collections — Map, Vec, Set, Cell, Once, PriorityQueue
- Tickets — JWT and TDX-based peer authentication with expiration-aware disconnect
- TEE — Intel TDX support for hardware-attested identity and access control
- Metrics — built-in observability via
metricswith optional Prometheus exporter - Preferences — ranking producers by latency, geo-proximity
- Diagnostics — network inspection, developer debug tools
Stage 2: Trust & Privacy
- TEE-based authorization — gate access to streams, groups, and collections to hardware-attested peers
- Privacy Corridors — end-to-end data isolation across chains of nodes and services
- Trust zones — network partitions enforcing integrity and privacy guarantees, backed by TEE attestation
Stage 3: Decentralization & Permissionlessness
Contributing
- Commits: concise, imperative subjects referencing the component (e.g., "Groups: Support for user-provided encoding")
- PRs: include a summary, linked issues/RFCs, and a checklist confirming
cargo build,cargo test,cargo clippy, andcargo +nightly fmtpass. - Tests: add or extend integration coverage for behavioral changes.
License
MIT — see LICENSE for details.