Context
Chatto's real-time signals span a wide spectrum of persistence and frequency requirements. Messages, joins, room lifecycle events, reactions, calls, and other durable room facts must be durably stored and replayable. Typing indicators, presence changes, and latest-value invalidations such as notification sync have no audit or replay value.
Publishing all events to JetStream would waste storage on high-frequency transient signals. Using only bare NATS pub/sub would lose ordering guarantees and replay for messages.
Decision
Split events into two channels based on persistence:
- JetStream events (messages, joins, leaves, room lifecycle, reactions): Originally published to
space.{id}.>subjects on a persisted per-space stream; currently published as durableEVTfacts and exposed internally throughlive.evt.>. - Pubsub events (typing indicators, presence, notification sync, session and config invalidations): Originally published to
live.space.{id}.>subjects via bare NATS Core pub/sub; currently published aspubsubv1.PubSubEventmessages underlive.sync.>. They are not stored. Plain NATS subscriptions consume them.
The realtime delivery layer merges both internal channels, then maps authorized input to the public protocol. Durable facts with a public meaning become semantic public events. Genuinely non-replayable activity, such as typing and presence transitions, becomes transient public events. Latest-value signals produce semantic public events; clients then use canonical snapshot resources or ConnectRPC reads to refresh current state. See ADR-076, ADR-077, ADR-091, ADR-093, and ADR-094.
Consequences
- Efficient storage: High-frequency transient events don't accumulate in JetStream streams. A busy space with constant typing indicators doesn't bloat its event stream.
- Appropriate delivery guarantees: Messages get ordered, durable delivery. Typing indicators get fire-and-forget delivery, which is correct — a missed typing indicator is harmless.
- Fan-in complexity: The realtime delivery layer merges durable committed facts and transient sync signals into one authorized stream. The process-wide hub consumes
live.evt.>andlive.sync.>and maps both to authorized public events. - Delivery mapping must stay explicit: Every new live signal must be registered in the hub/realtime mapping path so delivery can extract its authorization scope and decide whether it emits a durable or transient public event. Missing mappings can hide otherwise-valid changes from clients, so live-signal changes need tests at the delivery boundary.
- New event types require a channel decision: When adding a new event type, developers must decide whether it belongs in JetStream (persistent, ordered) or NATS Core (ephemeral, best-effort). This is an explicit architectural choice, not a default.