streamgo (github.com/tutti-os/tutti/packages/events/stream-go)
Catalog-agnostic server-side core for the business event stream
(daemon ↔ renderer over WebSocket). The Go counterpart to
@tutti-os/event-stream-core.
It owns the in-memory pub/sub registry, scope routing and session fan-out:
Service[S comparable]— sessions, subscriptions, scoped publish/fan-outSession[S]— per-connection outbound event channel- the catalog contract (
Catalog,Direction,ValidationError, …)
Each Session has a bounded queue sized to absorb normal local producer bursts. The registry never blocks a business producer on a slow consumer and never grows the queue without bound. If the queue fills, the Session is closed; the product WebSocket adapter must surface that closure to its client so reconnect and authoritative reconciliation can recover any missed optimistic events.
It is generic over the scope type S and depends only on an injected Catalog
(minimal: TopicVersion / ValidatePublish / ValidateSubscription) plus a
ScopeNormalizer[S]. It contains no concrete topics. Each product binds its
own scope and catalog:
- tutti workspace →
Service[EventScope]whereEventScope = { WorkspaceID } - group chat →
Service[RoomScope]whereRoomScope = { RoomID }
The WS frame encode/decode (which is woven through the generated protocol types) stays in each product's API layer and calls this registry.