design: fix M3 message list (#11)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 20:42:16 +01:00
co-authored by Claude Sonnet 5.5
parent 2801fbcca5
commit 277cb5f896
+179 -55
View File
@@ -1,6 +1,6 @@
# FFF_vtt design # FFF_vtt design
Status: draft v0.11, 2026-11-14 (owner decisions recorded in section 14; v0.4 records Q4 (tile_size 32 px), the outbox lock invariant (4.2, 4.3), and the follow-ups in 3.4, 8, 11.1, 12, 13; v0.5 records the M2 move-rule decisions in 5.5 and updates 3.4, 4.2, 5.1, 5.4, 6.1, 7.4, 8, 10.3, 12, 13; v0.6 records #14 (characters and player data) in 3.1, 3.4, 4.1, 4.4, 6.1, 8, 9, 10.3, 13, 14; v0.7 records #6 (players and invites) in 3.1, 3.2, 3.4, 4.4, 6.1, 8, 12, 13, 14; v0.8 records #7 (map tiles) in 3.3, 3.4, 11.1, 13, 14; v0.9 records #9 (test tools) in 2, 10.4, 13, 14; v0.10 records #12 (what M3 done means) in 13, 14; v0.11 records #15 (M3 limits) in 4.3, 6.4, 10.1, 13, 14. All of Q1-Q24 are RESOLVED or DEFERRED; none OPEN). Audience: the owner and coding agents. Status: draft v0.12, 2026-11-14 (owner decisions recorded in section 14; v0.4 records Q4 (tile_size 32 px), the outbox lock invariant (4.2, 4.3), and the follow-ups in 3.4, 8, 11.1, 12, 13; v0.5 records the M2 move-rule decisions in 5.5 and updates 3.4, 4.2, 5.1, 5.4, 6.1, 7.4, 8, 10.3, 12, 13; v0.6 records #14 (characters and player data) in 3.1, 3.4, 4.1, 4.4, 6.1, 8, 9, 10.3, 13, 14; v0.7 records #6 (players and invites) in 3.1, 3.2, 3.4, 4.4, 6.1, 8, 12, 13, 14; v0.8 records #7 (map tiles) in 3.3, 3.4, 11.1, 13, 14; v0.9 records #9 (test tools) in 2, 10.4, 13, 14; v0.10 records #12 (what M3 done means) in 13, 14; v0.11 records #15 (M3 limits) in 4.3, 6.4, 10.1, 13, 14; v0.12 records #11 (M3 message list) in 3.1, 3.2, 3.4, 4.2, 4.3, 5.5, 5.6, 6, 7.5, 13, 14. All of Q1-Q24 are RESOLVED or DEFERRED; none OPEN). Audience: the owner and coding agents.
Legend: Legend:
- **[FIXED]** owner decision, not up for debate here. - **[FIXED]** owner decision, not up for debate here.
@@ -76,7 +76,7 @@ A browser virtual tabletop for one table (1 GM + up to 6 players [FIXED, Q1]), s
``` ```
### Data flow (one move) ### Data flow (one move)
1. Client sends intent `move` over WS. 1. Client sends intent `token.move` over WS.
2. Ingress: authenticate (connection already bound to a player at upgrade), parse, authorize (owns token), validate (shape, bounds, step cap, collision). 2. Ingress: authenticate (connection already bound to a player at upgrade), parse, authorize (owns token), validate (shape, bounds, step cap, collision).
3. Core: apply to in-memory state, recompute vision for affected players, update explored grids. 3. Core: apply to in-memory state, recompute vision for affected players, update explored grids.
4. Persist in one SQLite transaction (inside the lock, ack after commit). 4. Persist in one SQLite transaction (inside the lock, ack after commit).
@@ -117,15 +117,15 @@ A browser virtual tabletop for one table (1 GM + up to 6 players [FIXED, Q1]), s
Notes: Notes:
- Prototype gap [INFERRED from code reading]: `Tok.gmOnly` is loaded from `scene.json` but never consulted in `sync()`; a GM-only token inside a player's LOS would be sent. Real build must enforce `gm_only` in the view builder and test it (new fault class, section 10). - Prototype gap [INFERRED from code reading]: `Tok.gmOnly` is loaded from `scene.json` but never consulted in `sync()`; a GM-only token inside a player's LOS would be sent. Real build must enforce `gm_only` in the view builder and test it (new fault class, section 10).
- Prototype gap [INFERRED]: every message carries the global `gseq`; player-visible gaps in `gseq` reveal that hidden mutations occurred. Real build: players get a per-connection monotonic counter. - Prototype gap [INFERRED]: every message carries the global `gseq`; player-visible gaps in `gseq` reveal that hidden mutations occurred. Real build: players get a per-connection monotonic counter.
- `hello` to a player carries world size, tile size, explored cell size, scene default token radius, owned ids. None of these is secret. It must not carry scene/entity counts or wall counts. - `hello` to a player carries world size, tile size, explored cell size, scene default token and vision radius, art version, own player id and name. None of these is secret (owned token ids travel as `mine` on `token`, 6.1). It must not carry scene/entity counts or wall counts.
- A token's radius and status entries (5.5, 5.6) go to every recipient who sees the token [FIXED, owner decision 2026-11-10, #4]. - A token's radius and status entries (5.5, 5.6) go to every recipient who sees the token [FIXED, owner decision 2026-11-10, #4].
- [FIXED, #14] Names and lists: no code path sends an actual name, a reveal state, or another player's character or encountered entry to a player, unless the rules in 8 allow it. Players learn a character only through a token they saw or controlled, or through their own encountered list. A character owner change never changes token controllers. - [FIXED, #14] Names and lists: no code path sends an actual name, a reveal state, or another player's character or encountered entry to a player, unless the rules in 8 allow it. Players learn a character only through a token they saw or controlled, or through their own encountered list. A character owner change never changes token controllers.
### 3.2 Authentication: shared link, player keys, GM key ### 3.2 Authentication: shared link, player keys, GM key
- **Shared site link [FIXED, #6].** One link for everyone: `https://host/`. Without a session it shows only the sign-in page, no data. - **Shared site link [FIXED, #6].** One link for everyone: `https://host/`. Without a session it shows only the sign-in page, no data.
- **Player key [FIXED, #6].** Each player has a personal secret, the **player key**, generated by the GM (no name at creation). It identifies the player and grants access to their data. Format: 20 characters in groups of 4 with dashes, alphabet without look-alikes (no 0/O, 1/I/L), from the OS CSPRNG (~100 bits) [FIXED, owner accepted default, #6]. - **Player key [FIXED, #6].** Each player has a personal secret, the **player key**, generated by the GM (no name at creation). It identifies the player and grants access to their data. Format: 20 characters in groups of 4 with dashes, alphabet without look-alikes (no 0/O, 1/I/L), from the OS CSPRNG (~100 bits) [FIXED, owner accepted default, #6].
- **Sign-in [PROPOSED path; behaviour FIXED].** The sign-in page POSTs the key to `/join` (HTTP; key in the body, never in the URL). Valid key: the server issues a fresh random session token cookie (`HttpOnly; Secure; SameSite=Strict; Path=/`), stores only its hash server-side, then redirects to `/`. Message shape: #11. Sessions never expire (Q10); one key works on many devices [FIXED, Q10]. - **Sign-in [PROPOSED path; behaviour FIXED].** The sign-in page POSTs the key to `/join` (HTTP; key in the body, never in the URL). Valid key: the server issues a fresh random session token cookie (`HttpOnly; Secure; SameSite=Strict; Path=/`), stores only its hash server-side, then redirects to `/`. Request and response: 6.6. Sessions never expire (Q10); one key works on many devices [FIXED, Q10].
- **First-sign-in name [FIXED, #6].** A player with no name is asked once for a display name. Names are unique among players. Renames: GM only. - **First-sign-in name [FIXED, #6].** A player with no name is asked once for a display name (`player.setname`, 6.1). Names are unique among players. Renames: GM only (`player.rename`).
- **No rate limit on key entry [FIXED, owner, #6].** The ~100-bit key space makes guessing infeasible; no lockout, no `limit_req` on sign-in. Owner explicitly rejected guessing protection. - **No rate limit on key entry [FIXED, owner, #6].** The ~100-bit key space makes guessing infeasible; no lockout, no `limit_req` on sign-in. Owner explicitly rejected guessing protection.
- **Replace a key [FIXED, #6].** GM can do this any time while the server runs: old key invalid, all that player's sessions revoked, live connections closed at once. Identity, characters and encountered list kept; no name re-prompt. - **Replace a key [FIXED, #6].** GM can do this any time while the server runs: old key invalid, all that player's sessions revoked, live connections closed at once. Identity, characters and encountered list kept; no name re-prompt.
- **Remove a player [FIXED, #6].** Key invalid, sessions revoked, connections closed. Their characters and controlled tokens pass to the GM (character owner and token controller set to GM). Name leaves the roster; slot freed; their encountered list deleted. - **Remove a player [FIXED, #6].** Key invalid, sessions revoked, connections closed. Their characters and controlled tokens pass to the GM (character owner and token controller set to GM). Name leaves the roster; slot freed; their encountered list deleted.
@@ -158,7 +158,7 @@ Notes:
| T6 | Player key / session theft via logs, referrer, history | key in POST body, never in URL; session != key (hash stored); log redaction; no-referrer on sign-in; HTTPS only | config test (grep logs for secret) [new] | | T6 | Player key / session theft via logs, referrer, history | key in POST body, never in URL; session != key (hash stored); log redaction; no-referrer on sign-in; HTTPS only | config test (grep logs for secret) [new] |
| T7 | Cross-site WS hijack | Origin check + SameSite=Strict | new test | | T7 | Cross-site WS hijack | Origin check + SameSite=Strict | new test |
| T8 | **Wall-probing oracle via move validation** [INFERRED, not in prototype tests]: `moveBlocked` answers `ok:false` for any chosen segment, with unlimited length; binary searching lets a player map walls beyond LOS and tell open from closed doors | cap step length per intent (= token's effective vision radius, scene default if no vision; 5.5, Q18 FIXED), rate limit intents per connection (6.4), uniform nack that carries only the old position (5.5) | M2 in-process probing test (5.5, 13); WS version in M3 (10.3): count wall/door facts recoverable from nacks beyond LOS | | T8 | **Wall-probing oracle via move validation** [INFERRED, not in prototype tests]: `moveBlocked` answers `ok:false` for any chosen segment, with unlimited length; binary searching lets a player map walls beyond LOS and tell open from closed doors | cap step length per intent (= token's effective vision radius, scene default if no vision; 5.5, Q18 FIXED), rate limit intents per connection (6.4), uniform nack that carries only the old position (5.5) | M2 in-process probing test (5.5, 13); WS version in M3 (10.3): count wall/door facts recoverable from nacks beyond LOS |
| T9 | Info via error replies (`not yours` echoing a position) | errors are static strings, never state; move of non-owned token gives `error` without position [MEASURED rule, README Findings] | leak test (e) | | T9 | Info via error replies (`not yours` echoing a position) | refusals are static codes, never state (6.5); a move of a non-controlled or unknown token gives `ack {ok:false, code:"not-allowed"}` without position, one code for both [MEASURED rule, README Findings] | leak test (e) |
| T10 | Message-size or rate DoS, slow client memory growth | max frame size (6.4), per-connection rate limit (6.4), connection cap (4.3); **bounded per-connection outbox** (byte/message caps, state coalescing), lagging clients stopped and resynced (4.3, Q13); mummy queue is unbounded [MEASURED finding, README mummy caveats] | new tests (10.3 slow client, protocol) | | T10 | Message-size or rate DoS, slow client memory growth | max frame size (6.4), per-connection rate limit (6.4), connection cap (4.3); **bounded per-connection outbox** (byte/message caps, state coalescing), lagging clients stopped and resynced (4.3, Q13); mummy queue is unbounded [MEASURED finding, README mummy caveats] | new tests (10.3 slow client, protocol) |
| T11 | Timing/size side channels (message bytes reveal hidden activity) | accepted; only deliver messages when state visible to that recipient changes | not tested | | T11 | Timing/size side channels (message bytes reveal hidden activity) | accepted; only deliver messages when state visible to that recipient changes | not tested |
| T12 | Path tricks on static/tile routes | strict parsing; webby rejected `%2f`/`%00` [MEASURED, NOTES Phase 2a] | smoke | | T12 | Path tricks on static/tile routes | strict parsing; webby rejected `%2f`/`%00` [MEASURED, NOTES Phase 2a] | smoke |
@@ -185,20 +185,20 @@ Single process, in-memory authoritative state, SQLite as write-through persisten
`intent -> validate -> apply -> per-player visibility -> diff -> persist -> ack -> send` `intent -> validate -> apply -> per-player visibility -> diff -> persist -> ack -> send`
Under the single global lock (as prototype, order proven correct by 3 x 60 s runs): Under the single global lock (as prototype, order proven correct by 3 x 60 s runs):
1. **Parse** with strict type checks (prototype pattern: kind checks per field). Unknown `t` -> `error`. 1. **Parse** with strict type checks (prototype pattern: kind checks per field). Unknown `t` -> `ack unknown-type` (`error malformed` if the envelope is unreadable; 6.5).
2. **Authorize**: role/ownership. 2. **Authorize**: role/ownership.
3. **Validate**: bounds, step cap (T8), collision (player moves: 5.5; GM moves skip walls and step cap), referential integrity, property schema. 3. **Validate**: bounds, step cap (T8), collision (player moves: 5.5; GM moves skip walls and step cap), referential integrity, property schema.
4. **Apply** to memory. 4. **Apply** to memory.
5. **Recompute** vision only for players whose input changed (mover's owner; all players for door/wall changes). Update explored; collect `fresh`. 5. **Recompute** vision only for players whose input changed (mover's owner; all players for door/wall changes). Update explored; collect `fresh`.
6. **Persist**: `BEGIN; ...; COMMIT` including dirty explored chunks. 6. **Persist**: `BEGIN; ...; COMMIT` including dirty explored chunks.
7. **Ack** to sender, then **egress**: for each connection compute the recipient view and enqueue it in that connection's bounded outbox (4.3; state keys coalesced). The diff against `known` happens at flush time; only changed items (`token`/`remove`/`vision`/`explored`/`door`/...) get bytes. 7. **Ack** to sender, then **egress**: for each connection compute the recipient view and enqueue it in that connection's bounded outbox (4.3; state keys coalesced). The diff against `known` happens at flush time; only changed items (`token`/`token_gone`/`vision`/`explored`/`wall`/...) get bytes.
8. Clear `fresh`. 8. Clear `fresh`.
Invariants (carry from prototype): Invariants (carry from prototype):
- Enqueue order per connection == mutation order: messages are appended to the connection's outbox **while holding the lock**; network sends happen **outside** the lock, at flush. Non-state messages are FIFO. State messages are coalesced per key (latest wins, 4.3), so their position relative to other messages is flush order, not mutation order. - Enqueue order per connection == mutation order: messages are appended to the connection's outbox **while holding the lock**; network sends happen **outside** the lock, at flush. Non-state messages are FIFO. State messages are coalesced per key (latest wins, 4.3), so their position relative to other messages is flush order, not mutation order.
- Ack after COMMIT (a client never sees a state that a crash can undo, except under `synchronous=NORMAL` power loss, 4.4). - Ack after COMMIT (a client never sees a state that a crash can undo, except under `synchronous=NORMAL` power loss, 4.4).
- A failed validation mutates nothing, bumps nothing, persists nothing. - A failed validation mutates nothing, bumps nothing, persists nothing.
- Non-owned/malformed requests get `error`, never an ack (an ack would echo an unseen position). - Refusals never echo state: only a refused move of a controlled token acks with its old position (uniform nack, 5.5); every other refusal is an `ack` with a static `code` and no position (6.5). Each intent gets exactly one `ack` (6).
Known limitation of the prototype, fixed in M2 [FIXED, accepted default; 5.5]: it checks only the centre path a->b and the destination circle, not the swept circle (corner clipping possible, `HANDOFF.md`). M2 adds the capsule (swept-circle) check and the step cap. Known limitation of the prototype, fixed in M2 [FIXED, accepted default; 5.5]: it checks only the centre path a->b and the destination circle, not the swept circle (corner clipping possible, `HANDOFF.md`). M2 adds the capsule (swept-circle) check and the step cap.
@@ -210,7 +210,7 @@ Second limitation [INFERRED]: a fast drag sampled at ~50 ms can produce a straig
- Decision [PROPOSED]: keep the global lock in v1. A table of <= ~10 clients is 2 orders of magnitude below the single-core limit (server total per mutation avg 0.70 ms [MEASURED]). Revisit only if a measured p99 > 50 ms appears in production logs. - Decision [PROPOSED]: keep the global lock in v1. A table of <= ~10 clients is 2 orders of magnitude below the single-core limit (server total per mutation avg 0.70 ms [MEASURED]). Revisit only if a measured p99 > 50 ms appears in production logs.
- Worker threads: prototype uses 8; one table needs 2-4 [INFERRED]. - Worker threads: prototype uses 8; one table needs 2-4 [INFERRED].
- **Slow client [FIXED (owner decision), 2026-11-08, Q13 option A]**. mummy's send queue is one unbounded deque and per-socket backlog is invisible to app code (no forced close, no depth API at this pin). No mummy patch. Research: `docs/research/q13-mummy-slow-clients.md`. - **Slow client [FIXED (owner decision), 2026-11-08, Q13 option A]**. mummy's send queue is one unbounded deque and per-socket backlog is invisible to app code (no forced close, no depth API at this pin). No mummy patch. Research: `docs/research/q13-mummy-slow-clients.md`.
- **Bounded outbox per connection** (keyed by app `connId`), with byte and message caps. State messages (vision, token, explored, door) are **latest-state-wins coalesced per key** (MQTT-retained-like). The diff against `known` is computed at **flush time**, not enqueue time, so a dropped intermediate state cannot desynchronise the client. - **Bounded outbox per connection** (keyed by app `connId`), with byte and message caps. State messages (vision, token, explored, wall) are **latest-state-wins coalesced per key** (MQTT-retained-like). The diff against `known` is computed at **flush time**, not enqueue time, so a dropped intermediate state cannot desynchronise the client.
- **Ack by Ping/Pong**: server sends WS `Ping(seq)` (payload <= 125 B) on a timer; the client's Pong echoes `seq` (RFC 6455 §5.5.2-5.5.3; browsers answer without JS). Acks give bytes in flight and lag per connection. - **Ack by Ping/Pong**: server sends WS `Ping(seq)` (payload <= 125 B) on a timer; the client's Pong echoes `seq` (RFC 6455 §5.5.2-5.5.3; browsers answer without JS). Acks give bytes in flight and lag per connection.
- **Lagging client** (outbox over cap, or no Pong within a bound): stop feeding it, keep the connection. On recovery, full resync (6.3). - **Lagging client** (outbox over cap, or no Pong within a bound): stop feeding it, keep the connection. On recovery, full resync (6.3).
- **Dead or stuck peers**: closed by nginx proxy timeouts [PROPOSED mechanism; verify in M5 that `/ws` goes through nginx and which directive fires, `send_timeout` is the candidate]. `close(ws)` cannot force-close at this pin (it queues behind the backlog). - **Dead or stuck peers**: closed by nginx proxy timeouts [PROPOSED mechanism; verify in M5 that `/ws` goes through nginx and which directive fires, `send_timeout` is the candidate]. `close(ws)` cannot force-close at this pin (it queues behind the backlog).
@@ -299,7 +299,7 @@ Conclusions:
- Vision origin = token centre, radius is not clipped by the token's own size. - Vision origin = token centre, radius is not clipped by the token's own size.
### 5.5 Move rules and statuses (M2 decisions, 2026-11-08; status model 2026-11-10, #4) ### 5.5 Move rules and statuses (M2 decisions, 2026-11-08; status model 2026-11-10, #4)
Normative for M2. Replaces the prototype move validation (5.1) and the move-related limitations in 4.2 and 5.4. Implemented as a pure in-process module with unit tests; the WebSocket layer only maps its result to `moveAck`. The WebSocket probing test is M3. Normative for M2. Replaces the prototype move validation (5.1) and the move-related limitations in 4.2 and 5.4. Implemented as a pure in-process module with unit tests; the WebSocket layer only maps its result to `ack` (6.1). The WebSocket probing test is M3.
Notation: token centre `c`, radius `r` (entity `radius` if set, else scene `token_radius_default`; 5.6), start `s`, destination `d`. Blocking wall: segment with `kind=wall`, or `kind=door` with `open=false`; open doors do not block. `dist(X, W)` = distance from point or segment `X` to segment `W`. "Overlaps" = `dist < r` (strict; touching at exactly r is clear). Notation: token centre `c`, radius `r` (entity `radius` if set, else scene `token_radius_default`; 5.6), start `s`, destination `d`. Blocking wall: segment with `kind=wall`, or `kind=door` with `open=false`; open doors do not block. `dist(X, W)` = distance from point or segment `X` to segment `W`. "Overlaps" = `dist < r` (strict; touching at exactly r is clear).
@@ -308,7 +308,7 @@ Notation: token centre `c`, radius `r` (entity `radius` if set, else scene `toke
- Overlap: `dist(c, W) < r` for a blocking wall `W`. An open door stops blocking, so opening = removing that wall for this rule; closing = adding it. Centre-on-wall is not required. - Overlap: `dist(c, W) < r` for a blocking wall `W`. An open door stops blocking, so opening = removing that wall for this rule; closing = adding it. Centre-on-wall is not required.
- Set (source `walls`): a wall is added or updated -> every token overlapping that wall gets `stuck`. (A door CLOSING on a token does not set it: push rule below.) The GM places or moves a token to a position overlapping any blocking wall -> `stuck`. - Set (source `walls`): a wall is added or updated -> every token overlapping that wall gets `stuck`. (A door CLOSING on a token does not set it: push rule below.) The GM places or moves a token to a position overlapping any blocking wall -> `stuck`.
- Keep: while any blocking wall still overlaps the token, its `walls`-sourced entries stay (opening a door does not free it if another wall overlaps). - Keep: while any blocking wall still overlaps the token, its `walls`-sourced entries stay (opening a door does not free it if another wall overlaps).
- Clear: a wall is removed or a door opened -> each token that overlapped that wall keeps its `walls`-sourced entries only if it still overlaps a remaining blocking wall; otherwise they clear. A shrink (5.6) that ends the overlap clears them likewise. The GM moves the token to a position overlapping no blocking wall -> `walls`-sourced entries cleared. `GM`-sourced entries clear only by GM action (any single `(status, source)` entry; wire intent in #11). - Clear: a wall is removed or a door opened -> each token that overlapped that wall keeps its `walls`-sourced entries only if it still overlaps a remaining blocking wall; otherwise they clear. A shrink (5.6) that ends the overlap clears them likewise. The GM moves the token to a position overlapping no blocking wall -> `walls`-sourced entries cleared. `GM`-sourced entries clear only by GM action (any single `(status, source)` entry; wire intent `status.clear`, 6.1).
- **Door closing on a token = push aside, not stuck** [FIXED, owner, 2026-11-08; changes the door case only]: each token (player or GM-owned) with `dist(c, door) < r` is moved perpendicular to the door segment, to the side its centre is already on, by the minimal distance that ends `>= r` from the door (+ `PushEps` = 1e-6 px; past the door's end the offset is `sqrt(r^2 - e^2)`, `e` = along-axis overshoot). Centre exactly on the door line: side of the token's previous position (position before its most recent move or push; `prev`/`hasPrev` on the token); no history, or previous also on the line: left of the door's a->b direction (deterministic default). The pushed position must be in bounds and `>= r` from every blocking wall (the closed door included); else the opposite side is tried; if neither is valid the token stays and gets `squeezed` (source `walls`), and opening that door later clears it per the Clear rule. A pushed token is clear of walls, so its `walls`-sourced entries clear. The push is a server-originated position change returned by the move-rules module (list of token index + new position) so M3 can broadcast it and recompute vision; no step cap applies. Each token is pushed independently; tokens do not block tokens (no token-token collision; the `blocks_move` flag is not modelled in M2), so pushed tokens may overlap each other. Wall add / wall update / GM placement or move inside a wall are unchanged (stuck). Door open is unchanged. - **Door closing on a token = push aside, not stuck** [FIXED, owner, 2026-11-08; changes the door case only]: each token (player or GM-owned) with `dist(c, door) < r` is moved perpendicular to the door segment, to the side its centre is already on, by the minimal distance that ends `>= r` from the door (+ `PushEps` = 1e-6 px; past the door's end the offset is `sqrt(r^2 - e^2)`, `e` = along-axis overshoot). Centre exactly on the door line: side of the token's previous position (position before its most recent move or push; `prev`/`hasPrev` on the token); no history, or previous also on the line: left of the door's a->b direction (deterministic default). The pushed position must be in bounds and `>= r` from every blocking wall (the closed door included); else the opposite side is tried; if neither is valid the token stays and gets `squeezed` (source `walls`), and opening that door later clears it per the Clear rule. A pushed token is clear of walls, so its `walls`-sourced entries clear. The push is a server-originated position change returned by the move-rules module (list of token index + new position) so M3 can broadcast it and recompute vision; no step cap applies. Each token is pushed independently; tokens do not block tokens (no token-token collision; the `blocks_move` flag is not modelled in M2), so pushed tokens may overlap each other. Wall add / wall update / GM placement or move inside a wall are unchanged (stuck). Door open is unchanged.
- An event changes only the tokens it touches (those overlapping the changed wall, or the moved token). An unrelated wall change elsewhere never re-sets a GM-cleared token. - An event changes only the tokens it touches (those overlapping the changed wall, or the moved token). An unrelated wall change elsewhere never re-sets a GM-cleared token.
- After the GM clears the `walls`-sourced entries while a wall still overlaps and no other entry remains, the player escape rule (step 3 below) applies unchanged: the token may step out without crossing, destination >= r from every blocking wall. - After the GM clears the `walls`-sourced entries while a wall still overlaps and no other entry remains, the player escape rule (step 3 below) applies unchanged: the token may step out without crossing, destination >= r from every blocking wall.
@@ -316,14 +316,14 @@ Notation: token centre `c`, radius `r` (entity `radius` if set, else scene `toke
- Player moves while locked (any entry): the uniform nack (unchanged). - Player moves while locked (any entry): the uniform nack (unchanged).
**Player move `s -> d`** [FIXED, accepted default]. Checks in order; any failure gives the uniform nack. **Player move `s -> d`** [FIXED, accepted default]. Checks in order; any failure gives the uniform nack.
1. Owner check (non-owned -> `error`, as now) and token not locked (no status entry). 1. Controller check (not controlled -> `ack{ok:false, code:"not-allowed"}`, no position; 6.5) and token not locked (no status entry).
2. Step cap [FIXED, owner]: `|d - s| <= cap`, where `cap` = the token's `vision_radius` if the token has `vision` and sets it, else the scene's `vision_radius_default`. 2. Step cap [FIXED, owner]: `|d - s| <= cap`, where `cap` = the token's `vision_radius` if the token has `vision` and sets it, else the scene's `vision_radius_default`.
3. For each blocking wall `W`: 3. For each blocking wall `W`:
- if `dist(s, W) < r` (start overlaps `W`, escape case): allowed only if the path `s->d` does not cross `W` (crossing at parameter t > eps; collinear overlap counts as crossing) AND `dist(d, W) >= r`; - if `dist(s, W) < r` (start overlaps `W`, escape case): allowed only if the path `s->d` does not cross `W` (crossing at parameter t > eps; collinear overlap counts as crossing) AND `dist(d, W) >= r`;
- otherwise (swept/capsule check): allowed only if `dist(segment s->d, W) >= r`, which also gives `dist(d, W) >= r`. - otherwise (swept/capsule check): allowed only if `dist(segment s->d, W) >= r`, which also gives `dist(d, W) >= r`.
4. Accept: `moveAck{ok:true, pos:d}`. Nack: `moveAck{ok:false, pos:s}` for locked, over-cap and collision alike. No reason field. 4. Accept: `ack{ok:true, pos:d}`. Nack: `ack{ok:false, pos:s}` for locked, over-cap and collision alike. No reason field, no `code`.
**GM move** [FIXED, owner (D)]: no wall check, no step cap, ignores locks. Bounds and referential checks still apply; after the move its `walls`-sourced entries are recomputed (set/clear rules above). A GM move out of bounds gets the same uniform nack as a player move (`moveAck{ok:false, pos:old}`) [RECORDED, as implemented]. **GM move** [FIXED, owner (D)]: no wall check, no step cap, ignores locks. Bounds and referential checks still apply; after the move its `walls`-sourced entries are recomputed (set/clear rules above). A GM move out of bounds gets the same uniform nack as a player move (`ack{ok:false, pos:old}`) [RECORDED, as implemented].
**Wall index** [FIXED, accepted default, H3]: radius-bbox cull first; uniform spatial grid over walls only if the 5k-wall bench misses target (13, M2). **Wall index** [FIXED, accepted default, H3]: radius-bbox cull first; uniform spatial grid over walls only if the 5k-wall bench misses target (13, M2).
@@ -339,66 +339,188 @@ Notation: token centre `c`, radius `r` (entity `radius` if set, else scene `toke
- **Shrink** never pushes. It can clear `walls`-sourced entries (5.5 Clear). - **Shrink** never pushes. It can clear `walls`-sourced entries (5.5 Clear).
- **Grow push:** GM grows a token -> the server pushes it away from every blocking wall it overlaps, by the minimal displacement that ends `>= r` from every blocking wall, stays in bounds, and does not enter any other wall. No step cap. Deterministic; the tie-break is fixed and documented in the module header [PROPOSED]. Each token is pushed independently (tokens do not block tokens). The position change is server-originated: broadcast like the door push, vision recomputed for affected players. - **Grow push:** GM grows a token -> the server pushes it away from every blocking wall it overlaps, by the minimal displacement that ends `>= r` from every blocking wall, stays in bounds, and does not enter any other wall. No step cap. Deterministic; the tie-break is fixed and documented in the module header [PROPOSED]. Each token is pushed independently (tokens do not block tokens). The position change is server-originated: broadcast like the door push, vision recomputed for affected players.
- **Grow fails** (no valid position): the token stays (its graphic may overlap walls) and gets `squeezed` (source `walls`). - **Grow fails** (no valid position): the token stays (its graphic may overlap walls) and gets `squeezed` (source `walls`).
- Wire intent names (resize, set status, clear entry) deferred to #11 ("Message list"). - Wire intents: `token.resize`, `status.set`, `status.clear` (6.1) [FIXED (owner-delegated, 2026-11-14, #11)].
--- ---
## 6. Protocol ## 6. Protocol
Transport: one WebSocket per client at `/ws`, JSON text frames (prototype). Envelope: `{t: string, ...fields}`; server frames add a per-connection counter `n` (replaces the global `gseq` for players, section 3.1). Transport: one WebSocket per client at `/ws`, JSON text frames (a binary frame counts as malformed, 6.5). Envelope: `{t: string, ...fields}`; every server frame adds a per-connection counter `n` (starts at 1 on the connection's first frame; replaces the global `gseq` for everyone, section 3.1).
The whole of 6 is [FIXED (owner-delegated, 2026-11-14, #11)] unless a line says otherwise: the owner delegated the wire shapes and accepted the set. It is the complete M3 wire catalogue (29 intents, 14 server messages); nothing outside it exists in M3.
Conventions:
- **Naming.** Client -> server `t` is `<noun>.<verb>`: lowercase ASCII, exactly one dot. Nouns follow GLOSSARY.md: `token` (the map figure; the word "entity" never appears on the wire), `character`, `player`, `key` (a player key), `status`, `name`, `encountered`, plus `wall`, `door`, `scene`, `prop`, `conn`, `act`. Server -> client `t` is a bare state or event noun, snake_case, **no dot** (`token`, `token_gone`). A server `t` therefore never equals a client `t`.
- **Correlation.** Every intent carries `reqId` (client-chosen integer, 0 <= reqId < 2^31, unique among that connection's pending intents; the server echoes it and never interprets it). The server sends **exactly one** `ack` per intent, whatever the outcome. Frames whose envelope cannot be read (not a JSON object, no string `t`, no integer `reqId`) cannot be acked and get `error` instead (6.5).
- **Ack.** `ack {reqId, ok:bool, code?, id?, pos?, key?, ts?}`. `ok:true` carries only the result fields listed per intent (`id` of a created thing, `pos` of a move, `key`, `ts`). `ok:false` carries a static `code` from 6.5, except the uniform move refusal (T9, next bullet). An ack means "decided". It is enqueued after COMMIT and before the effect messages (4.2), but state messages are coalesced (4.3), so a client must not rely on any order between an ack and the state messages it caused.
- **Uniform move refusal (T9).** A refused move by a controller (locked, over step cap, wall collision; 5.5) and a GM move out of bounds both give `ack {ok:false, pos:<old position>}` with **no `code`**: one shape, no reason. Every other refusal carries a `code` and never carries a position.
- **Effects.** An intent's effects reach clients only as state messages, each built per recipient (3.1, 8) and sent only when that recipient's view changed (T11). "GM" below = every GM connection; "player X" = every connection of player X; "visible" = per the view rules in 3.1.
- **Roles.** Sender column: P = player, G = GM. A P-sender intent from a connection whose player has no name yet is refused `not-allowed`, except `conn.ping` and `player.setname`.
- **Not in M3:** `act.do` is reserved (v1 answers `no-rules`); server -> client `event` is reserved (9); GM `view.player` (7.3) is later; none is built in M3. Wire changes for M4/M5/M6 are limited to what 6.5 marks.
### 6.1 Catalogue ### 6.1 Catalogue
Message names and fields for character CRUD, owner reassignment, token controller change, name reveals, the encountered list and its GM removal, and character data edits are deferred to "Message list" (#11) [FIXED, #14]. The rules they carry are in 3.1 and 8. Player key and player messages (key create/replace/show, rename, remove, sign-in, first-sign-in name prompt) are deferred to "Message list" (#11) [FIXED, #6]. Field notes shared by all rows: `pos:[x,y]` px floats, in bounds `0 <= x <= w`, `0 <= y <= h`; `scene` = the one scene's id (kept on the wire per 8); ids are the server-assigned ids of 8; `props` = `{public?:{}, owner?:{}, gm?:{}}`; a prop key is a string of 1..64 chars, a value is any JSON whose serialized size is <= 8 KB, at most 64 keys per bucket [numbers delegated, #11]. Unknown fields in an intent are ignored (6.2); a missing or wrongly typed field is `invalid`.
Client -> server (intents). Authority column: P = player, G = GM. #### Client -> server (intents)
| t | fields (contract) | who | server behaviour | Every row also carries `reqId` (omitted below). Codes are those of 6.5; `not-allowed` for a P sender on any G-only intent is implied and not repeated.
|---|---|---|---|
| `move` | `reqId:int, id, pos:[x,y]` | P (owned) / G (any) | validate; reply `moveAck` (+ `token` diffs); non-owned -> `error`; P move refused (locked: any status entry, over step cap, or wall collision; 5.5) -> `moveAck{ok:false, pos:old}`, one uniform nack; G move ignores walls, step cap and locks, then recomputes its `walls`-sourced entries by overlap; out-of-bounds G move gets the same nack (5.5) |
| `door` | `scene, id, open:bool` | G | toggle; recompute all players; close pushes tokens whose circle overlaps the door aside (perpendicular, valid side; server-originated position change to broadcast, vision recomputed; `squeezed` only if no side is valid; Q14, 5.5), open recomputes `walls`-sourced entries for those tokens (still stuck if another wall overlaps) |
| `wall.add` / `wall.update` / `wall.remove` | wall fields (add: server assigns `id`) / `scene, id` | G | validate geometry; recompute all players; GM-only broadcast of wall delta; add sets `stuck` (source `walls`) on tokens whose circle overlaps the wall, remove recomputes `walls`-sourced entries for those tokens (Keep rule), update = remove + add (Q14, 5.5; update PROPOSED) |
| `entity.create` / `entity.update` / `entity.remove` | kind, name, pos, owner, props buckets | G | validate against property schema; view diff |
| `prop.set` | `id, bucket, key, value` | G (v1) | owner-bucket writes by players come with FFF actions (section 9) |
| `scene.set` | scene meta | G | broadcasts new `hello`-equivalent reset to all; no `scene.activate` (one scene, Q3) |
| working names, final in #11: `key.create` / `key.replace` / `key.show` / `player.rename` / `player.remove` | see #11 | G | key stored plaintext, re-showable by GM (Q11, FIXED); replace or remove closes that player's connections (3.2) |
| `ping` | `ts` | any | `pong` (liveness only; lag is measured with WS Ping/Pong, 4.3) |
| `act` | `actor, action, args` | P/G | **reserved**: v1 replies `error: no-rules` (section 9) |
Server -> client. **Connection and reserved (2)**
| t | fields | who | ack ok `{...}` / extra codes | effects and recipients |
|---|---|---|---|---|
| `conn.ping` | `ts:int` | P, G | `{ts}` (echo) | none; liveness only, lag is measured with WS Ping/Pong (4.3) |
| `act.do` | `actor, action, args` | P, G | never ok: `no-rules` | none; **reserved** for the FFF hook (9) |
**Players and keys (6)**
| t | fields | who | ack ok / extra codes | effects and recipients |
|---|---|---|---|---|
| `player.setname` | `name` | P, only while own name is null | `{}`; `invalid`, `name-taken`, `not-allowed` (already named, or GM) | every connection of that player gets `hello` with `me.name` set, then the full resync (6.3); `roster` to all [FIXED, #6: asked once; GM-only renames after] |
| `player.rename` | `id, name` | G | `{}`; `not-found`, `invalid`, `name-taken` | `roster` to all connections of named players and to GM |
| `player.remove` | `id` | G | `{}`; `not-found`, `not-allowed` (the GM) | key and sessions invalidated; that player's connections closed with WS 4001 (6.5); characters and controlled tokens pass to the GM (`character` with owner GM to the GM; `token` updates per view); their encountered list and name reveals deleted (GM gets `encountered {player, full:true, set:[]}`); `roster` to all (3.2) |
| `key.create` | none | G | `{id:<new player id>, key}`; `cap-reached` (6 players incl. unused keys) | `roster` to GM (the new entry has `name:null`; players do not see unnamed players) |
| `key.replace` | `id` | G | `{key}`; `not-found`, `not-allowed` (the GM's own key rotates only by CLI, 3.2) | old key invalid, all sessions of that player revoked, all its connections closed with WS 4001; identity, characters, encountered list kept; `roster` (connected flags) |
| `key.show` | `id` | G | `{key}`; `not-found`, `not-allowed` (GM key: CLI only) | none |
**Scene, walls, doors (5)**
| t | fields | who | ack ok / extra codes | effects and recipients |
|---|---|---|---|---|
| `scene.set` | `scene`; any of `name, grid_size, vision_radius_default, token_radius_default, extra` (at least one) | G | `{}`; `invalid`, `not-found` | `hello` plus full resync to **every** connection (hello-equivalent reset; no `scene.activate`, Q3). `token_radius_default` change resizes tokens using the default with grow push (5.6): `token` updates per view, `vision`/`explored` as needed. `w, h, tile_size, cell, art_version` are not settable on the wire (import is M6 CLI) |
| `wall.add` | `scene, a:[x,y], b:[x,y], kind:"wall"|"door", open?:bool (default false), flags?` | G | `{id}`; `invalid`, `not-found` | `wall` to GM; vision recompute for all players (`vision`, `explored`, `token` as their views change); tokens whose circle overlaps get `stuck` source `walls` (5.5): `token` per view |
| `wall.update` | `scene, id`; any of `a, b, kind, flags` | G | `{}`; `not-found`, `invalid` | as `wall.add` (update = remove + add for the status rules, 5.5; PROPOSED there) |
| `wall.remove` | `scene, id` | G | `{}`; `not-found` | `wall_gone` to GM; recompute; `walls`-sourced entries re-evaluated (Keep/Clear, 5.5) |
| `door.set` | `scene, id, open:bool` | G | `{}`; `not-found`, `invalid` (wall is not a door) | `wall` to GM (a door is a wall); recompute all players; close pushes overlapped tokens aside (server-originated position change: `token` per view; `squeezed` only if no side is valid), open re-evaluates `walls`-sourced entries (5.5). Players learn only through LOS changes |
Validation for `wall.*`: `a != b`, both in bounds, `kind` in `wall|door`, `flags` an object or absent.
**Tokens, statuses, props (9)**
| t | fields | who | ack ok / extra codes | effects and recipients |
|---|---|---|---|---|
| `token.create` | `scene, kind, pos`; plain token (no `character_id`): `descriptive_name, actual_name` required; linked: `character_id` and **no** names; optional `controller` (player id or null = GM; default: the character's owner if linked, else GM), `radius` (px > 0), `vision_radius`, `gm_only`, `flags`, `props` | G | `{id}`; `invalid`, `not-found` (scene, character or controller) | `token` to the GM and to each recipient who sees it (the controller always); vision recompute; GM placement ignores walls, `stuck` if it overlaps one (5.5); a new `encountered` entry for a player who sees it (diff) |
| `token.update` | `id`; any of `kind, descriptive_name, actual_name, character_id (string = link, null = unlink), controller (player id or null), gm_only, flags, vision_radius (number or null)` | G | `{}`; `not-found`, `invalid` (links with names; unlinking without both names) | `token` per view. Controller change: `mine` flips, the old controller loses the token unless it is in their LOS (`token_gone` by diff), vision recomputed for both; **never** changes the character owner. `gm_only` set: players lose it (`token_gone`) |
| `token.move` | `id, pos` | P (controlled) / G (any) | `{pos}` (accepted position); P refused: uniform `{ok:false, pos:old}` (5.5); non-controlled or unknown id for P: `not-allowed` (one code for both, no existence oracle); G unknown id: `not-found`; G out of bounds: uniform nack | `token` per view; vision for the mover's player; `explored` fresh cells; pushes/status changes as server-originated `token` updates |
| `token.resize` | `id, radius:number>0 or null` (null = back to the scene default) | G | `{}`; `not-found`, `invalid` | `token` per view (effective `radius`); grow pushes or sets `squeezed`, shrink may clear `walls`-sourced entries (5.6) |
| `token.remove` | `id` | G | `{}`; `not-found` | `token_gone` to every recipient who knew it; its `encountered` entries stay and turn grey (never auto-removed, 8) |
| `status.set` | `id, status:"stuck"|"squeezed"` | G | `{}`; `not-found`, `invalid` | adds entry `(status, source GM)`; `token` per view (#4) |
| `status.clear` | `id, status, source:"walls"|"GM"` | G | `{}`; `not-found` (token or entry) | removes that single entry; `token` per view; then the escape rule (5.5) |
| `prop.set` | `target:"token"|"character", id, bucket:"public"|"owner"|"gm", key, value` | G (v1; owner-bucket writes by players come with FFF actions, 9) | `{}`; `not-found`, `invalid` | token target: `token` per view (bucket filtered). Character target: `character` to GM and to the owner (public/owner buckets only), and `token` updates (`cprops`, public bucket) to recipients who see a token of that character |
| `prop.unset` | `target, id, bucket, key` | G | `{}`; `not-found`, `invalid` | as `prop.set`; unsetting an absent key is ok |
**Characters, names, encountered (7)**
| t | fields | who | ack ok / extra codes | effects and recipients |
|---|---|---|---|---|
| `character.create` | `descriptive_name, actual_name, owner?:player id (default: the GM), props?` | G | `{id}`; `invalid`, `not-found` (owner) | `character` to GM and to the owner |
| `character.update` | `id`; any of `descriptive_name, actual_name` (props go through `prop.set`) | G | `{}`; `not-found`, `invalid` | `character` to GM and owner; `token` names per view for its tokens; `encountered` upserts for players who met it |
| `character.remove` | `id` | G | `{}`; `not-found`, `in-use` (any token still links it; GM removes or unlinks the tokens first) | `character_gone` to GM and owner |
| `character.reassign` | `id, owner:player id` | G | `{}`; `not-found`, `invalid` | `character` to GM and the new owner, `character_gone` to the old owner; **no** token controller changes (3.1); reveals kept [PROPOSED, 8]; `token` per view (`character_id` and actual name visibility follow the owner) |
| `name.reveal` | `subject:"character"|"token", id, player` (the player's id) | G | `{}`; `not-found`, `invalid` (a token that has a character: reveal through the character) | to that player only: `token`, `character`, `encountered` updated with the actual name; to GM: the updated `revealed` list. Reveals never revoke (3.1); there is no un-reveal intent in M3 |
| `name.reveal_all` | `subject, id` | G | `{}`; `not-found`, `invalid` | sets `reveal_all`; as `name.reveal` for every player. Idempotent |
| `encountered.remove` | `player, id` (token id) | G | `{}`; `not-found` (player or entry) | `encountered {del:[id]}` to that player, same to GM |
Count: 29 intents (2 + 6 + 5 + 9 + 7).
#### Server -> client
All are built per recipient at egress (single egress rule, 2). "Sent" always means: only when that recipient's view changed. Fields marked (GM) go to GM connections only; (P) to player connections only.
| t | content | recipient | | t | content | recipient |
|---|---|---| |---|---|---|
| `hello` | `proto`, role, owned ids, world size, tile size, explored cell, scene default token radius, scene meta | all; client resets state on receipt | | `hello` | `proto:int, role:"gm"|"player", me:{id, name|null}`; unless the player is unnamed: `scene:{id, name, w, h, tile_size, cell, grid_size, vision_radius_default, token_radius_default, art_version}` plus `extra` (GM). No counts, no wall data, no owned ids (`mine` is on `token`) | the connecting connection, first frame; again on `scene.set` (all connections) and after `player.setname` (that player's connections). The client resets all state on receipt. An unnamed player gets only `proto, role, me` and nothing else until named |
| `walls` / `wall` | full list / delta incl. doors with `open` | **GM only** | | `ack` | see Conventions | sender connection only |
| `door` | `id, open` | GM only (players learn only via LOS changes) | | `error` | `code` (`malformed` or `rate-limited`; 6.5) | sender connection only; only for frames that cannot be acked |
| `vision` | `polys` (integer px, owned tokens only) | player | | `roster` | `players:[{id, name, role, colour, connected}]`, always the full list | everyone (Q9). Players receive named players only (an unused key is not visible); GM receives all, `name:null` for unnamed |
| `explored` | `cells` (full on connect, fresh cells after) | player | | `walls` | `scene, walls:[{id, a, b, kind, open, flags}]` | GM, on connect and resync (6.3) |
| `token` | `id, name` (the name this recipient may see, 8), `kind, pos, radius, mine, statuses` (list of `{status, source}`; 5.5, 5.6 [FIXED, #4]), visible props | per visibility | | `wall` | `scene, id, a, b, kind, open, flags` (upsert; doors included; this replaces the old `door` message) | GM only |
| `remove` | `id` (left LOS / deleted) | per visibility | | `wall_gone` | `scene, id` | GM only |
| `moveAck` | `reqId, ok, pos` | sender only | | `vision` | `polys:[{id:<token id>, pts:[[x,y],...]}]` integer px, the full set for this player's controlled tokens with `vision` | player only; never GM |
| `error` | static `msg` code | sender only | | `explored` | `full:true, rle:[[cy, x0, len, x0, len, ...], ...]` on connect and resync; `full:false, cells:[[cx,cy],...]` afterwards (fresh cells) [format PROPOSED, 6.4] | player only; never GM |
| `presence` | who is connected | all: names (Q9, FIXED) | | `token` | `id, scene, name, pos, radius, mine, statuses:[{status, source}], props`; `name` = the one name this recipient may see (8), no reveal state; `radius` = effective px; `props` = only the buckets this recipient may read (public; plus owner for the controller; all three for GM). More for specific recipients: `character_id` (GM, and a player who owns that character); `cprops:{public:{}}` the character's public props (player who does not own the character; `{}` for a plain token); `kind, controller (id or null), gm_only, flags, vision_radius, radius_own (number or null)` (GM); `vision_radius` also for the controller (the step cap, 5.5); plain tokens, GM: `descriptive_name, actual_name, reveal_all, revealed:[player ids]` | GM: all tokens; player: tokens they control, plus tokens inside own LOS and not `gm_only` (3.1). Whole view of one token per message |
| `pong` | echo | sender | | `token_gone` | `id` | a recipient who had it in their `known` table and no longer may see it (left LOS, removed, `gm_only` set, controller lost it). Never sent for a token the recipient never saw |
| `character` | GM: `id, owner, descriptive_name, actual_name, reveal_all, revealed:[player ids], props:{public,owner,gm}`. Owner (P): `id, descriptive_name, actual_name, props:{public,owner}`; the owner is never sent `reveal_all` or `revealed` | GM: every character; player: only the characters they own. No other player ever gets a character record (no browsable list, T16) |
| `character_gone` | `id` | GM; and the previous owner on reassign |
| `encountered` | `full:bool, set:[{id:<token id>, name, grey:bool}], del:[id]`; `full:true` replaces the whole list (on connect, resync); (GM) adds `player:<id>` | player: own list only; GM: one message per player and list. `name` = the name that recipient's player knows (8); `grey` = no longer in that player's view ("met before, whereabouts unknown"); no position, no `character_id` for players |
Count: 14 server messages. Reserved, not built: `event` (9).
Leak notes (R5 review, #11): (1) `kind` is GM-only because a value like `npc` would tell a player what a visible token is; the client names tokens from `name` and `props`. (2) `character_id` goes only to the character's owner and the GM; showing it to others would link two tokens of one character and mark a token as "a character, not a monster". (3) `cprops` is public bucket only and always present (even empty) for non-owners so presence does not mark a token as character-linked. (4) The roster omits unnamed players for players so an unused key (or the number of keys) is not visible. (5) `hello` carries `vision_radius_default` so the client can respect the step cap (5.5); it states a distance only, no wall fact. (6) `statuses[].source` (`walls`) goes to everyone who sees the token (#4, FIXED); for a token the recipient sees, this reveals at most that a wall overlaps that spot, which the recipient's LOS covers. (7) `encountered.grey` flipping and `token`/`token_gone` carry the same fact (the token left view), so deletion and moving away look identical to the player.
### 6.2 Versioning [PROPOSED] ### 6.2 Versioning [PROPOSED]
- `hello.proto` integer, compiled into the client. Mismatch -> client shows "reload" (assets are content-hashed by Vite so reload fetches the matching client). Server also refuses clients announcing an older proto (`/ws?proto=N`). - `proto` is an integer compiled into both client and server; M3 ships `proto = 1`. The client announces it in the upgrade request (`/ws?proto=N`). Any mismatch, older or newer, is refused (6.5): the upgrade completes and the server closes with WS code 4003, because a browser `WebSocket` cannot read an HTTP status, only a close code. The client then shows "reload" (assets are content-hashed by Vite, so a reload fetches the matching client). `hello.proto` is checked again on receipt as a backstop.
- Within one proto version: additive only (new optional fields, new message types). Client ignores unknown server message types and unknown fields. Server answers unknown client types with `error` (as prototype). - Within one proto version: additive only (new optional fields, new message types). The client ignores unknown server message types and unknown fields; the server ignores unknown fields in intents and answers an unknown `t` with `ack {ok:false, code:"unknown-type"}` (or `error {code:"malformed"}` if there is no `reqId`).
- Breaking change -> bump `proto`, document in `docs/` changelog. - Breaking change -> bump `proto`, document in `docs/` changelog.
### 6.3 Reconnect and resync ### 6.3 Reconnect and resync
- Reconnect = full resync. Server sends `hello` then full state for that recipient (`walls` if GM, `vision`, `explored` whole, `token` for all visible); client reducer resets everything on `hello` (reconnect-reset bug fixed in prototype, test in `client/src/state.test.ts`, 4/4 pass) [MEASURED]. - Reconnect = full resync. After `hello` the server sends, in this order [PROPOSED]: `roster`; GM: `walls`, `character` for all, `encountered` per player (full), then `token` for all; player: `character` for owned, `encountered` (full), `vision`, `explored` (full), then `token` for all visible and controlled. An unnamed player gets only `hello` until `player.setname` succeeds, which triggers the same sequence on that connection. The client reducer resets everything on `hello` (reconnect-reset bug fixed in prototype, test in `client/src/state.test.ts`, 4/4 pass) [MEASURED]. Clients must tolerate any order after `hello`.
- No gap detection and no `resume(since)`: WS over TCP is ordered and lossless while connected, and a reconnect restarts from a full snapshot. Full resync on every reconnect [FIXED, Q15]. Revisit if a measured snapshot exceeds ~100 KB. - No gap detection and no `resume(since)`: WS over TCP is ordered and lossless while connected, and a reconnect restarts from a full snapshot. Full resync on every reconnect [FIXED, Q15]. Revisit if a measured snapshot exceeds ~100 KB.
- Client reconnect: exponential backoff with jitter, cap ~10 s (prototype: fixed 2 s). Pending `reqId`s cleared on hello. Assets (tiles) are kept across reconnect because explored only grows [MEASURED prototype behaviour]. - Client reconnect: exponential backoff with jitter, cap ~10 s (prototype: fixed 2 s). Pending `reqId`s are dropped with the old connection (client-side, M4); a `hello` on a live connection (`scene.set`, first name) does **not** drop them: their acks still arrive. Assets (tiles) are kept across reconnect because explored only grows [MEASURED prototype behaviour].
- Same player on two connections: both synced; each has its own `known` table. Multiple devices per player allowed (Q10, FIXED). - Same player on two connections: both synced; each has its own `known` table. Multiple devices per player allowed (Q10, FIXED), up to 4 (4.3).
### 6.4 Deltas and size ### 6.4 Deltas and size
- Entities: `token` only when the recipient's view of it changed; `remove` on leaving view; per-connection `known` table gives correct enter/leave [MEASURED, leak test (c)]. - Tokens: `token` only when the recipient's view of it changed; `token_gone` on leaving view; per-connection `known` table gives correct enter/leave [MEASURED, leak test (c)].
- Bytes [MEASURED, `results/concurrency-final1-server.log`]: monster move 145 B to a seeing player, 244 B to GM; player move: mover 3359-3653 B (worst 4.9 KB, dominated by the full `vision` polygon + `explored` diff), GM 145 B; door toggle 45 B. - Bytes [MEASURED, `results/concurrency-final1-server.log`]: monster move 145 B to a seeing player, 244 B to GM; player move: mover 3359-3653 B (worst 4.9 KB, dominated by the full `vision` polygon + `explored` diff), GM 145 B; door toggle 45 B (prototype `door` message; the M3 `wall` upsert is a little larger).
- v1 decisions [FIXED, Q16]: full vision polygon, integer px (halves the text size [INFERRED]), owner only, sent only on change; deltas/binary post-v1. Explored on connect as run-length rows, later diffs as cell lists [PROPOSED]. - v1 decisions [FIXED, Q16]: full vision polygon, integer px (halves the text size [INFERRED]), owner only, sent only on change; deltas/binary post-v1. Explored on connect as run-length rows, later diffs as cell lists [PROPOSED].
- Move rate [FIXED (owner-delegated, 2026-11-14, #15)]: client sends at most ~20 Hz while dragging (prototype 50 ms) plus a final position. Server: token bucket per connection, 30 intents/s sustained, burst 100, same for GM and players. Excess intents are rejected with error `rate limited`; no rollback: each intent is atomic (accepted ones stay, rejected ones are never applied); the connection stays open. Reconciling refused optimistic edits is client behaviour (M4). - Move rate [FIXED (owner-delegated, 2026-11-14, #15)]: client sends at most ~20 Hz while dragging (prototype 50 ms) plus a final position. Server: token bucket per connection, 30 intents/s sustained, burst 100, same for GM and players. Excess intents are refused with `ack {ok:false, code:"rate-limited"}`; no rollback: each intent is atomic (accepted ones stay, rejected ones are never applied); the connection stays open. Reconciling refused optimistic edits is client behaviour (M4).
- Max inbound WS message [FIXED (owner-delegated, 2026-11-14, #15)]: 64 KB = mummy 0.4.8 default `maxMessageLen` (inbound only, cumulative across fragments). Over the limit mummy closes TCP without a close frame (mummy.nim :658-660). No config; outbound unaffected. - Max inbound WS message [FIXED (owner-delegated, 2026-11-14, #15)]: 64 KB = mummy 0.4.8 default `maxMessageLen` (inbound only, cumulative across fragments). Over the limit mummy closes TCP without a close frame (mummy.nim :658-660). No config; outbound unaffected.
### 6.5 Refusals, errors and connection outcomes [FIXED (owner-delegated, 2026-11-14, #11)]
**Intent pipeline (order of checks).** The first failing step decides the reply; nothing is applied on any failure.
1. Frame over 64 KB: mummy closes TCP, no reply (6.4).
2. Not a UTF-8 text frame holding a JSON object with string `t` and integer `reqId` in range: `error {code:"malformed"}`, and it counts toward the malformed flood limit.
3. Rate limit (token bucket, 6.4): empty bucket -> `ack rate-limited` (or `error rate-limited` if step 2 failed).
4. Unknown `t` -> `ack unknown-type`.
5. P sender without a name, other than `conn.ping` and `player.setname` -> `not-allowed`.
6. Role: a G-only intent from a player -> `not-allowed`.
7. Field types and ranges -> `invalid`.
8. Target lookup. Player senders: a target that is not theirs or does not exist is one and the same `not-allowed` (no existence oracle, T9). GM senders: missing target -> `not-found`.
9. Semantic validation (GM: `invalid`; player move: the uniform nack, 5.5).
**Ack codes (static strings, never carry state).**
| code | meaning |
|---|---|
| `rate-limited` | token bucket empty (6.4); nothing applied |
| `unknown-type` | `t` is not in 6.1 |
| `not-allowed` | wrong role, not the controller, unknown or not-theirs target (players), unnamed player, GM key via the wire, `player.setname` when already named |
| `not-found` | GM-only: scene, wall, token, character, player or entry does not exist |
| `invalid` | missing or mistyped field, out of bounds, bad geometry, names/links inconsistent, bad name text |
| `name-taken` | player name already used (case-insensitive, includes `GM`) |
| `cap-reached` | `key.create` would exceed 6 players (3.2) |
| `in-use` | `character.remove` while a token links the character |
| `no-rules` | `act.do` (reserved, 9) |
Player name text: trimmed, NFC, 1 to 32 code points, no control characters. Character and plain-token names: 1 to 64 code points, same rules. All are rendered with `textContent` (T13).
**`error` frame (no `reqId`).** Codes `malformed`, `rate-limited` only; connection stays open unless the flood rule fires.
**Connection-level outcomes.** Order of checks on a `GET /ws` request, then on the open socket:
| # | condition | outcome | stage |
|---|---|---|---|
| 1 | `Origin` header missing or not equal to the configured public origin (T7) | HTTP 403, no upgrade | before upgrade |
| 2 | no session cookie, or its hash is unknown or revoked | HTTP 401, no upgrade | before upgrade |
| 3 | `proto` query missing or not an integer; request is not a WebSocket upgrade | HTTP 400 | before upgrade |
| 4 | total connections would exceed 16 after the player's own oldest is evicted (#15): the 17th | HTTP 503 with `Retry-After: 5`, no upgrade | before upgrade |
| 5 | `proto` differs from the server's (6.2) | upgrade completes, then WS close **4003** `proto-mismatch`; no `hello`, no state | open |
| 6 | the player already has 4 connections (#15): the 5th | the oldest of that player stops receiving at once and is closed with WS **4002** `evicted` (the close frame queues behind its backlog, 4.3); the new one proceeds | open |
| 7 | key replaced, player removed, or GM key rotated: the session is revoked (3.2) | WS **4001** `revoked` on every affected connection (client must not auto-reconnect: it goes to the sign-in page) | open |
| 8 | 10 `malformed` frames within any 10 s on one connection [numbers delegated, #11] | WS **1008** `malformed-flood` | open |
| 9 | inbound message over 64 KB, bad opcode/rsv, unmasked or oversized control frame | mummy closes TCP with **no close frame** (client sees 1006); not catchable by app code | open |
| 10 | server shutdown (SIGTERM) | WS **1001** (going away) [M5, 4.4 handler] | M5 |
WS close reasons are the static strings in bold above. Close codes 4001-4003 are the app's range; 1008 and 1001 are the RFC 6455 standard codes. Lagging clients (M5, 4.3) get no close and no frame: they are not fed until resync, and nginx closes dead peers (M5).
### 6.6 HTTP surface in M3
- `POST /join` (the sign-in page; HTTP, not WS; 3.2). Body `application/x-www-form-urlencoded`, one field `key`, at most 1 KB (mummy closes the connection above its limit). Key comparison ignores case, dashes and spaces and is constant-time. Valid key (player or GM): `303` to `/` with `Set-Cookie: fff_session=<random>; HttpOnly; Secure; SameSite=Strict; Path=/` [name PROPOSED]. Invalid key: `401`, no body detail, no cookie. Wrong method `405`; missing `key` or wrong content type `400`. No rate limit (owner, #6). The body is never logged (T6).
- `GET /ws`: 6.5 (rows 1-4).
- `GET /tiles/<scene>/v<art_version>/<x>_<y>.png`: 3.3 (`200` with `X-Accel-Redirect`, `403` unexplored, `404` malformed/out of range).
- `GET /healthz`: M5 (11.3).
--- ---
## 7. Client ## 7. Client
@@ -439,11 +561,11 @@ Prototype `client/src/main.ts`: explored rects appended to a `Graphics` mask for
- Grid snap on drop: client option, off by default [FIXED, Q18]. Server accepts any in-bounds position within the step cap and clear of walls (5.5; step cap = effective vision radius, Q18 FIXED). - Grid snap on drop: client option, off by default [FIXED, Q18]. Server accepts any in-bounds position within the step cap and clear of walls (5.5; step cap = effective vision radius, Q18 FIXED).
### 7.5 Prediction and rollback for own moves ### 7.5 Prediction and rollback for own moves
- Players do **not** know the walls, so the client cannot predict collisions [INFERRED, consequence of strict model]. Prediction = optimistic placement of the dragged sprite, send `move` with `reqId` at <= 20 Hz, and a final send on release. - Players do **not** know the walls, so the client cannot predict collisions [INFERRED, consequence of strict model]. Prediction = optimistic placement of the dragged sprite, send `token.move` with `reqId` at <= 20 Hz, and a final send on release.
- While dragging, incoming authoritative positions for that token are ignored (prototype behaviour) so the sprite does not fight the pointer. - While dragging, incoming authoritative positions for that token are ignored (prototype behaviour) so the sprite does not fight the pointer.
- `moveAck{ok:true,pos}` -> nothing to do (server pos == requested). `moveAck{ok:false,pos}` -> snap to `pos` if not dragging; if dragging, snap on release (do not teleport under the finger). - `ack{ok:true,pos}` -> nothing to do (server pos == requested). `ack{ok:false,pos}` (no `code`) -> snap to `pos` if not dragging; if dragging, snap on release (do not teleport under the finger).
- Rollback visual: short tween back to `pos` (cosmetic). - Rollback visual: short tween back to `pos` (cosmetic).
- Pending request map keyed by `reqId`; cleared on hello. - Pending request map keyed by `reqId`; dropped when the connection closes (6.3).
- Others' tokens: render the latest `token` message; interpolate between updates (client-side only, <= 100 ms) [PROPOSED]. - Others' tokens: render the latest `token` message; interpolate between updates (client-side only, <= 100 ms) [PROPOSED].
--- ---
@@ -613,12 +735,12 @@ Each is small, ends with a green gate, and no milestone depends on browser UI be
- Scope: scanline `cellsTouched`, differential + independent explored oracle tests, radius-bbox wall cull (spatial grid only if the 5k bench misses), capsule/swept move check and token-on-wall escape (5.5), step cap = effective vision radius (5.5), `blocked` flag with circle-overlap trigger and Set/Keep/Clear policy (5.5), GM moves ignore walls and step cap (and set/clear `blocked`), bench harness incl. 5k-wall scene, pure in-process move-rules module with unit tests. The WS/hostile-client harness is M3, not M2. - Scope: scanline `cellsTouched`, differential + independent explored oracle tests, radius-bbox wall cull (spatial grid only if the 5k bench misses), capsule/swept move check and token-on-wall escape (5.5), step cap = effective vision radius (5.5), `blocked` flag with circle-overlap trigger and Set/Keep/Clear policy (5.5), GM moves ignore walls and step cap (and set/clear `blocked`), bench harness incl. 5k-wall scene, pure in-process move-rules module with unit tests. The WS/hostile-client harness is M3, not M2.
- Accept: `visibilityPolygon` and `cellsTouched` equal the old implementation on the corpus (5.5); `moveBlocked` excluded (its results change on purpose); polygon+cells bench <= prototype (0.451 ms) on the prototype scene and polygon < 1 ms on the 5k-wall scene [targets PROPOSED]; in-process probing test passes; escape and capsule positive and negative unit tests pass; door-push tests pass (each side, centre on the line uses the previous side, other-side fallback for a blocking wall and for out of bounds, both invalid -> blocked and opening frees it, GM-owned token pushed, wall add still sticks); `blocked` tests pass (every Set/Keep/Clear rule of 5.5: overlap trigger, doorway, two overlapping walls, GM drop/move sets and clears, GM clear then escape, unrelated change does not re-block); mutations k (no Keep), l (GM moves do not set blocked), m (push to the wrong side), n (push skips the validity check) and o (previous side ignored) each fail >= 1 test; over-cap move gives the same nack as a blocked move; thresholds documented in the module header; oracle tolerance 0.5 px. The KNOWN LIMITATION test and the Q14 pin test are replaced with positive assertions and `blocked`-policy tests. - Accept: `visibilityPolygon` and `cellsTouched` equal the old implementation on the corpus (5.5); `moveBlocked` excluded (its results change on purpose); polygon+cells bench <= prototype (0.451 ms) on the prototype scene and polygon < 1 ms on the 5k-wall scene [targets PROPOSED]; in-process probing test passes; escape and capsule positive and negative unit tests pass; door-push tests pass (each side, centre on the line uses the previous side, other-side fallback for a blocking wall and for out of bounds, both invalid -> blocked and opening frees it, GM-owned token pushed, wall add still sticks); `blocked` tests pass (every Set/Keep/Clear rule of 5.5: overlap trigger, doorway, two overlapping walls, GM drop/move sets and clears, GM clear then escape, unrelated change does not re-block); mutations k (no Keep), l (GM moves do not set blocked), m (push to the wrong side), n (push skips the validity check) and o (previous side ignored) each fail >= 1 test; over-cap move gives the same nack as a blocked move; thresholds documented in the module header; oracle tolerance 0.5 px. The KNOWN LIMITATION test and the Q14 pin test are replaced with positive assertions and `blocked`-policy tests.
- **M3 - Server core.** - **M3 - Server core.**
- Scope: entities with bucketed props, characters with names, name reveal and encountered list (8, #14), players, player keys/sessions, scenes, chunked explored persistence, typed per-recipient views and single egress, per-connection counters, proto versioning, wall/entity CRUD intents, Origin check, plaintext invite secrets and non-expiring sessions (Q10, Q11), SQLite schema + migrations. Tile gate `/tiles/` (3.3), fixture tiles at 32 px generated at test time by a helper (not committed), minimal local test nginx with internal `/_tiles/` (production vhost and tile import CLI stay M6) [FIXED, owner decision 2026-11-14, #7]. Black-box harnesses ported to `tools/` on Node 26; `devbox run test` runs Nim then Node (10.4) [FIXED, owner decision 2026-11-14, #9]. - Scope: entities with bucketed props, characters with names, name reveal and encountered list (8, #14), players, player keys/sessions, scenes, chunked explored persistence, typed per-recipient views and single egress, per-connection counters, proto versioning, the wire catalogue of 6 (29 intents, 14 server messages), wall/token/character CRUD intents, Origin check, plaintext player keys and non-expiring sessions (Q10, Q11), SQLite schema + migrations. Tile gate `/tiles/` (3.3), fixture tiles at 32 px generated at test time by a helper (not committed), minimal local test nginx with internal `/_tiles/` (production vhost and tile import CLI stay M6) [FIXED, owner decision 2026-11-14, #7]. Black-box harnesses ported to `tools/` on Node 26; `devbox run test` runs Nim then Node (10.4) [FIXED, owner decision 2026-11-14, #9].
- Accept: `devbox run test` green on a clean checkout, and that run includes the nine named groups below; details live at the § refs, not here. Out of M3 accept: concurrency (M5), 127.0.0.1 bind check (M6 deploy) [FIXED, owner decision 2026-11-14, #12]. - Accept: `devbox run test` green on a clean checkout, and that run includes the nine named groups below; details live at the § refs, not here. Out of M3 accept: concurrency (M5), 127.0.0.1 bind check (M6 deploy) [FIXED, owner decision 2026-11-14, #12].
1. **leak+fault**: ported leak test A and B; fault test catches every class with exact class sets, incl. characters and names; clean build passes (10.1, 10.3). 1. **leak+fault**: ported leak test A and B; fault test catches every class with exact class sets, incl. characters and names; clean build passes (10.1, 10.3).
2. **tiles**: Tile gate: leak test (d) and smoke tile-steal checks pass through the test nginx; gate decisions match the independent explored oracle (10.2); direct `/_tiles/` fetch -> 404; malformed or out-of-range path -> 404; unexplored -> 403 [FIXED, owner decision 2026-11-14, #7]. 2. **tiles**: Tile gate: leak test (d) and smoke tile-steal checks pass through the test nginx; gate decisions match the independent explored oracle (10.2); direct `/_tiles/` fetch -> 404; malformed or out-of-range path -> 404; unexplored -> 403 [FIXED, owner decision 2026-11-14, #7].
3. **probing**: M2 in-process probing test (T8, H26) re-run over WS with a hostile client (10.3, 5.5). 3. **probing**: M2 in-process probing test (T8, H26) re-run over WS with a hostile client (10.3, 5.5).
4. **protocol**: proto mismatch refused, unknown type rejected, oversized frame rejected, malformed flood closed, rate limit hit, connection cap enforced (10.3, T10, 6.2; limits and numbers in 4.3 (connections) and 6.4 (frame, intent rate) [FIXED, owner-delegated, #15]). 4. **protocol**: proto mismatch refused, unknown type rejected, oversized frame rejected, malformed flood closed, rate limit hit, connection cap enforced (10.3, T10, 6.2, 6.5; codes and close codes in 6.5; limits and numbers in 4.3 (connections) and 6.4 (frame, intent rate) [FIXED, owner-delegated, #15]).
5. **auth**: key create; key replace (old sessions and live connections closed); remove player; one key on several devices; Origin mismatch rejected; cookie flags present (T7, H9, 3.2, 10.3). 5. **auth**: key create; key replace (old sessions and live connections closed); remove player; one key on several devices; Origin mismatch rejected; cookie flags present (T7, H9, 3.2, 10.3).
6. **characters and names**: as #14 (10.3). 6. **characters and names**: as #14 (10.3).
7. **restart**: identical state after restart, incl. CRUD (10.1). 7. **restart**: identical state after restart, incl. CRUD (10.1).
@@ -683,3 +805,5 @@ Owner also decided 2026-11-14 [FIXED (owner decision), #9]: test tools. Black-bo
Owner also decided 2026-11-14 [FIXED (owner decision), #12]: what M3 done means. Done = `devbox run test` green on a clean checkout, with the nine named groups in 13 (M3 Accept), each pointing to its details in 10.3, 3.4, 5.5 and 6. Concurrency moves to M5 and the 127.0.0.1 bind check to M6 deploy. Protocol limits (frame size, intent rate, connection caps) are a separate open card, "M3 limits", not decided here. See 10.3, 13. Owner also decided 2026-11-14 [FIXED (owner decision), #12]: what M3 done means. Done = `devbox run test` green on a clean checkout, with the nine named groups in 13 (M3 Accept), each pointing to its details in 10.3, 3.4, 5.5 and 6. Concurrency moves to M5 and the 127.0.0.1 bind check to M6 deploy. Protocol limits (frame size, intent rate, connection caps) are a separate open card, "M3 limits", not decided here. See 10.3, 13.
Owner also decided 2026-11-14 [FIXED (owner-delegated, 2026-11-14, #15)]: M3 limits. The owner delegated the numbers to the agent and accepted the set. Max inbound WS message 64 KB (mummy default; inbound only; no config). Intent rate: token bucket per connection, 30/s sustained, burst 100, same for GM and players; excess refused with `rate limited`, no rollback (each intent atomic), connection stays open. Connections: 4 per player (a 5th closes the oldest), 16 total (the 17th is refused); replaces the PROPOSED cap of 8. Consequence: the M5 concurrency port spreads load across connections (10.1). See 4.3, 6.4, 10.1, 13. Owner also decided 2026-11-14 [FIXED (owner-delegated, 2026-11-14, #15)]: M3 limits. The owner delegated the numbers to the agent and accepted the set. Max inbound WS message 64 KB (mummy default; inbound only; no config). Intent rate: token bucket per connection, 30/s sustained, burst 100, same for GM and players; excess refused with `rate limited`, no rollback (each intent atomic), connection stays open. Connections: 4 per player (a 5th closes the oldest), 16 total (the 17th is refused); replaces the PROPOSED cap of 8. Consequence: the M5 concurrency port spreads load across connections (10.1). See 4.3, 6.4, 10.1, 13.
Owner also decided 2026-11-14 [FIXED (owner-delegated, 2026-11-14, #11)]: M3 message list. The owner delegated the wire shapes; the set is the complete M3 catalogue in 6 (29 client intents, 14 server messages). Client `t` is `<noun>.<verb>` (GLOSSARY nouns: `token`, never "entity"), server `t` is a dotless state noun, so they never collide. Every intent carries `reqId` and gets exactly one `ack` (`ok`, new `id`, `pos` for moves); a refused player move stays the uniform nack (old position, no code), every other refusal has a static code (`rate-limited`, `not-allowed`, `not-found`, `invalid`, `name-taken`, `cap-reached`, `in-use`, `no-rules`, `unknown-type`); frames without a readable `reqId` get `error` (`malformed`, `rate-limited`). `invite.*`, `gmClearBlocked` and `blocked` are retired: `key.*`/`player.*` for player keys and players, `status.set`/`status.clear` and `token.resize` for #4. Connection outcomes: HTTP 403 (Origin), 401 (no session), 400, 503 (17th connection); WS close 4001 revoked, 4002 evicted (5th connection), 4003 proto mismatch, 1008 malformed flood; oversize closes TCP with no frame. `POST /join` is HTTP (6.6). Server `door` is folded into `wall`; `presence` into `roster`; `pong` into the ping `ack`. See 3.1, 3.2, 3.4, 4.2, 4.3, 5.5, 5.6, 6, 7.5, 13.