Dev's NoxDev's Nox
Protocol

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:

ChannelPeerTransportPage
WebSocketa browser / a relayws + Socket.IOWebSocket
Tunnelanother NOX nodePOST /api/tunnelTunnel

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:

KindSaysCarries an audience?
*.cwhat changed (the entity itself)no
*.relationwho 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" .-> B1

A 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 handlerBody
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 handlerBody
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:

ConstantValueWhere it bounds
AUDIENCE_PAGE1000relation rows per keyset page (from_ref > cursor)
WS_USER_BATCH250recipient ids per WebSocket bus message
PEER_BATCH8concurrent tunnel calls to distinct peers

Naming

TierConventionExample
in-process bus<Type>EventRelayCreatedEvent
WebSocket<domain>.<action>user.changed, world.updated
Tunnel<entity>.<scope>user.update, asset.relation
RESTApi<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.

On this page