22 ADRs: server-authoritative sight and single egress, per-recipient views/diffs, uniform nack, opaque ids, 32 px tile unit, wall switches/presets, see-over, thick walls, open-door gap, typed wall columns, proto 2, build order, zoom clamp, accepted status leak, player marker, chunked explored, slow-client policy, session/key split, closing message, character records, global lock, synchronous choice. Each links its tickets and its spec section.
32 lines
1.5 KiB
Markdown
32 lines
1.5 KiB
Markdown
# Per-recipient typed views and state-based diffs
|
|
|
|
Each connection keeps a `known` table of the last view it was sent; the egress builds the current
|
|
view for that recipient, diffs it against `known`, and sends only what changed. Messages are built
|
|
from typed structures (`PlayerView`, `GmView`, per-token views), not from a shared JSON tree, and
|
|
every server frame carries a per-connection counter `n` rather than a global sequence number. We
|
|
chose this over broadcasting mutations and over a global counter because players must not learn that
|
|
a hidden mutation happened from a gap in a sequence, and because a full-state push per mutation is
|
|
too large (a player move's full polygon is ~3 KB).
|
|
|
|
## Status
|
|
accepted
|
|
|
|
## Alternatives
|
|
- Broadcast every mutation and let each client filter: rejected, leaks hidden entities and needs the
|
|
client to hold world state.
|
|
- Global `gseq` with per-recipient filtering: rejected, gaps reveal that something hidden changed
|
|
(the prototype did this).
|
|
- Full snapshot per mutation: rejected, the vision polygon alone is ~3 KB per move.
|
|
|
|
## Consequences
|
|
The diff base is the frame before `n` is stamped, so stamping must deep-copy; otherwise every frame
|
|
looks changed (a real bug fixed in slice 8). State messages can be coalesced per key at flush time
|
|
without desynchronising the client, which is what makes the bounded outbox (ADR-0017) safe. Ordering
|
|
between an ack and the state messages it caused is not guaranteed.
|
|
|
|
## Tickets
|
|
#11, #20; #28 (borrowed egress context), #31 (one scene read per request).
|
|
|
|
## Spec
|
|
Current §2, §3.1, §4.2, §6.4.
|