Overview
The two channels a NOX node speaks — WebSocket to clients, tunnel to peers
A node has exactly two outbound channels, and they do not overlap:
| Channel | Peer | Transport | Page |
|---|---|---|---|
| WebSocket | a browser / a relay | ws + Socket.IO | WebSocket |
| Tunnel | another NOX node | POST /api/tunnel | Tunnel |
Everything a node announces goes through one of them: a domain service never writes to a socket directly, and never calls a peer's REST API for internal traffic.
Two kinds of message, on both channels
The same split exists in both directions, so a client and a peer receive the same events under the same names:
| Kind | Says | Carries an audience? |
|---|---|---|
*.c | what changed (the entity itself) | no |
*.relation | who the edges moved for (ids) | yes (batched ids) |
flowchart LR
subgraph "user.update"
A1["{ id, action, entity? }"] --> B1["receiver resolves<br/>its own audience"]
end
subgraph "user.relation"
A2["{ id, action, targets[] }"] --> B2["receiver mirrors<br/>the follow edge"]
end
B2 -. "what makes the update<br/>resolvable" .-> B1A follower never appears in an update: the receiving side recomputes who cares from its own copy of the follow graph. The relation message is what keeps that copy accurate.
Updates — the same shape for every entity
| Tunnel handler | Body |
|---|---|
user.update | { id, action, entity? } |
asset.update | { type, id, action, entity? } |
type is the only extra, because an asset is polymorphic (world, mod, avatar) and a
removed has no entity left to read it from. entity is always the public sanitised view,
built without a viewer — it never embeds relations, a following flag or a presence location
that depends on who is looking.
Relations — the same shape, with type for assets
| Tunnel handler | Body |
|---|---|
user.relation | { id, action, targets: number[] } |
asset.relation | { type, id, action, targets: number[] } |
id is the entity on the sending node, targets are the numeric ids on the receiving
node the edges moved for, and action says what happened (follow, unfollow,
unfollow_reverse, follow_accept, follow_refuse for users; follow / unfollow for assets).
Batching, everywhere
No fan-out ever materialises its audience. The constants are the contract:
| Constant | Value | Where it bounds |
|---|---|---|
AUDIENCE_PAGE | 1000 | relation rows per keyset page (from_ref > cursor) |
WS_USER_BATCH | 250 | recipient ids per WebSocket bus message |
PEER_BATCH | 8 | concurrent tunnel calls to distinct peers |
Naming
| Tier | Convention | Example |
|---|---|---|
| in-process bus | <Type>Event | RelayCreatedEvent |
| WebSocket | <domain>.<action> | user.changed, world.updated |
| Tunnel | <entity>.<scope> | user.update, asset.relation |
| REST | Api<Type> | ApiUser, ApiAsset |
The WebSocket catalogue lives in node/src/events/websocket-frames.ts and is mirrored in
front/src/lib/ws/events.ts; the tunnel bodies live in node/src/**/dto/. A frame or a handler
that is not declared there does not exist — the TypeScript types make it fail to compile rather
than leak on the wire.