Preview
@briven/realtime — reactive query WebSocket service
per CLAUDE.md §7.4:
- client calls
useQuery("getPosts", { userId }) - SDK sends query name + args to realtime over WebSocket
- realtime computes a query hash, checks cache
- on miss: invokes query via runtime, caches, returns
- realtime subscribes to Postgres
LISTENchannels for every table touched - on
NOTIFY(auto-generated triggers), recompute and push deltas to subscribed clients - subscriptions expire when client disconnects
status: Phase 1 complete (2026-05-09). wire protocol, refcounted LISTEN/UNLISTEN,
NOTIFY → re-invoke fan-out, channel diffing on touchedTables, postgres.js
v3 auto-reattach on reconnect. Caller auth is the runtime shared secret;
SDK-direct connection (per-project JWT) is a Phase 2 follow-up.
year-one scale target: 10,000 concurrent subscriptions. migrate to logical replication + WAL streaming if this becomes a bottleneck.