design: fix players and player keys (#6)
One shared site link; each player signs in with a personal player key generated by the GM. GM signs in the same way with a GM key from `fff-vtt gm-key` (replaces gm-link, #5). GM can replace a key live (old key invalid, sessions and connections revoked). Removing a player passes characters and tokens to the GM. No rate limit on key entry (owner decision: ~100-bit key space). Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
+8
-4
@@ -22,12 +22,16 @@ Neither term names its cause. Stuck and squeezed both lock a token for its playe
|
||||
The one person who runs the table and sees everything: all walls, all tokens, all hidden state. A player can never become the GM.
|
||||
_Avoid_: DM, admin, host
|
||||
|
||||
**Invite link**:
|
||||
A secret link that admits one person to the table, with no password.
|
||||
_Avoid_: invite code, join key, password
|
||||
**Player key**:
|
||||
A personal secret the GM gives one player. It signs that player in from the shared site link and identifies them; the GM can show it again or replace it.
|
||||
_Avoid_: token, invite link, password
|
||||
|
||||
**GM key**:
|
||||
The secret that signs the GM in from the shared site link. It is made by the server's command line, not in the browser.
|
||||
_Avoid_: token, invite link, password
|
||||
|
||||
**Player**:
|
||||
A real person at the table who joins through an invite link. A player is not a character; one player may own several characters.
|
||||
A real person at the table who signs in with a player key. A player is not a character; one player may own several characters.
|
||||
_Avoid_: user, account, member
|
||||
|
||||
**Character**:
|
||||
|
||||
+40
-31
@@ -1,6 +1,6 @@
|
||||
# FFF_vtt design
|
||||
|
||||
Status: draft v0.6, 2026-11-10 (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. All of Q1-Q24 are RESOLVED or DEFERRED; none OPEN). Audience: the owner and coding agents.
|
||||
Status: draft v0.7, 2026-11-10 (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. All of Q1-Q24 are RESOLVED or DEFERRED; none OPEN). Audience: the owner and coding agents.
|
||||
|
||||
Legend:
|
||||
- **[FIXED]** owner decision, not up for debate here.
|
||||
@@ -23,9 +23,9 @@ Evidence roots (relative to repo root):
|
||||
A browser virtual tabletop for one table (1 GM + up to 6 players [FIXED, Q1]), self-hosted, where the **server alone decides what each player sees**. A modified client must learn nothing it is not entitled to.
|
||||
|
||||
### v1 scope [PROPOSED, trimmed to what the prototypes proved plus the minimum to be usable]
|
||||
- One table, 1 GM + up to 6 players (max 6 [FIXED, owner decision 2026-11-08, Q1]), invite links, no accounts.
|
||||
- One table, 1 GM + up to 6 players (max 6 [FIXED, owner decision 2026-11-08, Q1]), a shared site link and per-player keys, no accounts.
|
||||
- Exactly one scene in v1 (Q3, FIXED): large tiled map image, optional visual grid, walls and doors (kinds `wall`|`door` only, Q6), tokens.
|
||||
- GM tools: author walls/doors in the browser (Q6, FIXED), create/move/delete tokens, toggle doors, edit token properties, manage invites.
|
||||
- GM tools: author walls/doors in the browser (Q6, FIXED), create/move/delete tokens, toggle doors, edit token properties, manage players and player keys.
|
||||
- Player: move owned tokens; see only line-of-sight area, previously explored area (dimmed), and tokens inside LOS.
|
||||
- Automatic LOS from owned tokens against walls/doors, server-side. Explored area = per-player cell grid, persisted.
|
||||
- Persistence across restarts; reconnect resync; backups.
|
||||
@@ -48,7 +48,7 @@ A browser virtual tabletop for one table (1 GM + up to 6 players [FIXED, Q1]), s
|
||||
### Fixed stack [FIXED]
|
||||
- Client: TypeScript + PixiJS v8 + Vite; plain HTML/DOM overlay for UI (no UI framework). Agents use the official pixijs-skills (already in `.agents/skills/pixijs*`).
|
||||
- Server: Nim 2.x; `mummy` pinned to tag `0.4.8` (commit `77a7563e`; `src/` identical to the former pin `01deb1ff694988635c7bf0f24f6088a0bdf6db5d`) [FIXED (owner decision), 2026-11-08; tags 0.4.6-0.4.8 exist]. `prototype-server-vision/servervision.nimble` still pins the commit until ported; `db_connector/db_sqlite`, WAL. No Nim in the browser.
|
||||
- nginx (existing, HTTPS) in front: static client, reverse proxy for `/ws`, `/join/`, `/tiles/`; internal location for tile bytes.
|
||||
- nginx (existing, HTTPS) in front: static client, reverse proxy for `/ws`, `/join`, `/tiles/`; internal location for tile bytes.
|
||||
- Dev env: NixOS, devbox per project for toolchains, nothing global.
|
||||
|
||||
### Component diagram
|
||||
@@ -58,7 +58,7 @@ A browser virtual tabletop for one table (1 GM + up to 6 players [FIXED, Q1]), s
|
||||
| Vite bundle (TS + Pixi v8) | <-------------> | nginx (existing, TLS) |
|
||||
| - renderer, fog, input | static, /ws, | / -> client/dist (store) |
|
||||
| - DOM overlay UI | /tiles/,/join | /ws -> proxy, Upgrade |
|
||||
| - reducer (protocol state) | | /join/ /tiles/ -> proxy to Nim |
|
||||
| - reducer (protocol state) | | /join /tiles/ -> proxy to Nim |
|
||||
+-----------------------------+ | /_tiles/ -> internal alias, bytes |
|
||||
+-------------------+------------------------+
|
||||
127.0.0.1 only | X-Accel-Redirect
|
||||
@@ -111,7 +111,7 @@ A browser virtual tabletop for one table (1 GM + up to 6 players [FIXED, Q1]), s
|
||||
| Explored grid | none | own grid only | never other players' |
|
||||
| Map tiles | all | only tiles touching own explored cells (403 otherwise) | -- |
|
||||
| Player roster | all (names, connected) | names of all players (Q9, FIXED) | names of all players (Q9, FIXED) |
|
||||
| Invites/sessions | GM only (invite links re-copyable, Q11 FIXED) | own session cookie only | never |
|
||||
| Player keys, sessions | GM only (keys re-showable, Q11 FIXED) | own session cookie only | never |
|
||||
| Global activity counters (`gseq`) | yes | **no**: per-connection counter only | -- |
|
||||
|
||||
Notes:
|
||||
@@ -121,14 +121,21 @@ Notes:
|
||||
- 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.
|
||||
|
||||
### 3.2 Authentication and invite secrets
|
||||
- Invite = 128-bit random secret from the OS CSPRNG (prototype: `urandom(16)`, hex). Link `https://host/join/<secret>`.
|
||||
- **Session separate from invite [PROPOSED].** Prototype uses the secret itself as cookie `sid` (HttpOnly, SameSite=Strict); that makes the invite a permanent bearer token that also sits in access logs and browser history. Real build: `/join/<secret>` validates the invite and issues a fresh random session token cookie (`HttpOnly; Secure; SameSite=Strict; Path=/`), stores only its hash server-side, then 302s to `/`. Invites are revocable and regenerable by the GM. Sessions never expire; one invite link is reusable on multiple devices [FIXED, Q10].
|
||||
- `/join/` location in nginx: `access_log off` (or redacted `$uri`), `Referrer-Policy: no-referrer` on the redirect. Never log secrets from Nim either.
|
||||
### 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.
|
||||
- **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].
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **Cap [FIXED, #6].** Max 6 players; unused keys count toward the cap.
|
||||
- Keys are stored plaintext so the GM can re-show them [FIXED, Q11]. Key and session are separate: the cookie is never the key. Never log keys or session tokens (Nim or nginx).
|
||||
- Session separate from key: the prototype's secret-as-cookie design is dropped (permanent bearer, sits in access logs and history).
|
||||
- One cookie jar = one identity; same cookie in two tabs = same player, shared vision, both connections synced [MEASURED, prototype README].
|
||||
- WS upgrade: authenticate by cookie **and** verify the `Origin` header equals the configured public origin [PROPOSED; mitigates cross-site WebSocket hijack, SameSite=Strict is the first line].
|
||||
- Invite secrets are stored plaintext so the GM can re-copy the link [FIXED, Q11].
|
||||
- **First GM login [FIXED, owner decision 2026-11-10, #5].** Only the server CLI creates the GM: `fff-vtt gm-link` creates the single GM player (role `gm`, display name `GM`) and a GM invite if none exists, and prints the full join URL (public origin from the same config the server reads). Re-running prints the same link; existing GM sessions are unaffected. `fff-vtt gm-link --new` rotates: new GM invite secret, old one invalid, all GM sessions revoked. `--new` refuses while the running server holds its lock on the data dir; the read-only print works at any time. Access control is filesystem permissions on the data files; no extra password. A visitor without an invite never becomes GM (no first-visitor claim); they see only a "need an invite" page. Renaming the GM is deferred to #6 (Players and invites).
|
||||
- **Rejected [FIXED, #6]:** per-person invite links; GM types the name at key creation; delete-and-reinvite only; deleting a player's characters with the player; a shared-link visit creating a player; a separate GM link path.
|
||||
- **First GM login [FIXED, owner decision 2026-11-10, #5; amended #6].** Only the server CLI creates the GM: `fff-vtt gm-key` creates the single GM player (role `gm`, display name `GM`) if none exists, and prints the GM key. Re-running prints the same key; existing GM sessions are unaffected. `fff-vtt gm-key --new` rotates: new GM key, old one invalid, all GM sessions revoked. `--new` refuses while the running server holds its lock on the data dir; the read-only print works at any time. The GM's own key rotates only this way (no live replace). The GM signs in like a player: shared link, then GM key. Access control is filesystem permissions on the data files; no extra password. A visitor without a key never becomes GM (no first-visitor claim); they see only a "need a key" page. The GM may rename.
|
||||
- Rejected: env/config seed (secret leaks via config, repo, backups); auto-print at startup (secrets in logs); first visitor claims GM (takeover); rotate on every lookup (logs out GM devices); live rotation while the server runs (needs an admin channel to the running server).
|
||||
|
||||
### 3.3 Tiles
|
||||
@@ -148,7 +155,7 @@ Notes:
|
||||
| T3 | Player reads other player's vision/explored/ownership | per-player view only | faults `other-*` [MEASURED caught] |
|
||||
| T4 | Player fetches unexplored tiles | Nim gate + internal nginx location | leak (d), smoke steal check |
|
||||
| T5 | Tile-edge over-disclosure: one 32 px cell grazed by vision, never revoked | tile_size = explored cell = 32 px, no server masking, authoring rule ~32 px (Q4 FIXED) | documented, not testable as a leak; M4 timing gates (13) |
|
||||
| T6 | Invite/session theft via logs, referrer, history | session != invite, log redaction, no-referrer, 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 |
|
||||
| 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, 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) |
|
||||
@@ -226,8 +233,8 @@ Engine: SQLite via `db_connector/db_sqlite`, `journal_mode=WAL`, one connection
|
||||
Schema sketch (columns indicative, not final DDL):
|
||||
```
|
||||
meta(k PRIMARY KEY, v) -- schema_version also via PRAGMA user_version
|
||||
player(id PK, name, role, colour, created_at)
|
||||
invite(id PK, player_id FK, secret, created_at, revoked_at, used_at) -- secret plaintext (Q11)
|
||||
player(id PK, name NULL, role, colour, created_at) -- name NULL until first sign-in; unique among players [FIXED, #6]
|
||||
player_key(player_id PK FK, secret, created_at) -- indicative; one current key per player; secret plaintext (Q11); replace overwrites [FIXED, #6]
|
||||
session(id PK, player_id FK, token_hash, created_at, last_seen) -- never expires (Q10)
|
||||
scene(id PK, name, w, h, tile_size, cell, grid_size, vision_radius_default, token_radius_default,
|
||||
art_version, active, next_wall_id, extra_json) -- next_wall_id: monotonic, §8 [FIXED, #3]; token_radius_default [FIXED, #4]
|
||||
@@ -342,7 +349,7 @@ Transport: one WebSocket per client at `/ws`, JSON text frames (prototype). Enve
|
||||
|
||||
### 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.
|
||||
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].
|
||||
|
||||
Client -> server (intents). Authority column: P = player, G = GM.
|
||||
|
||||
@@ -354,7 +361,7 @@ Client -> server (intents). Authority column: P = player, G = GM.
|
||||
| `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) |
|
||||
| `invite.create` / `invite.revoke` | player id | G | returns link; secret stored plaintext, re-copyable by GM (Q11, FIXED) |
|
||||
| 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) |
|
||||
|
||||
@@ -401,7 +408,7 @@ Server -> client.
|
||||
3. **Entities/tokens**: pooled containers, shared `GraphicsContext` per colour, `BitmapText` labels.
|
||||
4. **Fog (players)**: explored dim layer + vision cut-out (7.3).
|
||||
5. **GM overlay (GM only)**: walls/doors Graphics, wall editor handles; hidden from players by never receiving the data.
|
||||
6. **DOM overlay**: toolbars, token panel, invites dialog, connection status; plain HTML on top of the canvas (no framework) [FIXED].
|
||||
6. **DOM overlay**: toolbars, token panel, player keys dialog, connection status; plain HTML on top of the canvas (no framework) [FIXED].
|
||||
|
||||
### 7.2 Rendering techniques kept from the perf prototype [MEASURED, `prototype-pixi-perf/README.md`]
|
||||
- Verdict: Pixi v8 renders a VTT scene at 60 fps on Radeon 780M (WebGL and WebGPU) and Galaxy Note 10 (WebGL) up to 1000 tokens (Note 10 js ~14 ms, 2000 tokens -> 32-36 fps, CPU-bound; laptop js 9-12 ms at 2000). Only per-frame token JS scales; a table needs tens of tokens.
|
||||
@@ -454,8 +461,8 @@ All ids are server-assigned. **Walls [FIXED, owner decision 2026-11-10, #3]**: p
|
||||
- **Character props vs token props [FIXED, #14]**: the character holds who the figure is (identity, base values); the token holds what is happening to that figure (damage, conditions, scene effects). Plain tokens (monsters, items) keep their own data. Both use the three buckets: `owner` for a character = character owner + GM; for a token = token controller + GM. The server stores both and never interprets them; FFF decides the split (9). A recipient's view of a token is built from its own props and its character's props, each under its own bucket rule [PROPOSED].
|
||||
- **Names [FIXED, #14]**: every character and every plain token has a `descriptive_name` (e.g. "a grumpy man") and an `actual_name` (e.g. "Lord Vex"). Players see the descriptive name until the GM reveals the actual name to that player; the GM can also reveal to all at once (`reveal_all`). The owner of a character always sees its actual name. A character's tokens use the character's names, so one reveal covers all of them. Applies to player characters too (introductions). Reveals are not revoked when ownership changes [PROPOSED].
|
||||
- **Encountered list [FIXED, #14]**: per player, every token that the player's controlled tokens have ever seen, shown under the name that player knows. Out of sight: greyed ("met before, whereabouts unknown"). `gm_only` tokens never enter it. Entries are never removed automatically (not on token removal or scene change); only the GM removes an entry for a player. Server tracks and persists it. No browsable list of all characters for players. Not the player roster (Q9 lists players only).
|
||||
- **Player**: `id, name, role (gm|player), colour`. Exactly one GM. A player is a real person who joins via an invite link; not a character. A player may own several characters.
|
||||
- **Invite**: `id, player_id, secret (plaintext, re-copyable by GM, Q11 FIXED), created, revoked, used`.
|
||||
- **Player**: `id, name (NULL until first sign-in; unique among players), role (gm|player), colour`. Exactly one GM. A player is a real person who signs in with a player key; not a character. A player may own several characters. Max 6 players; unused keys count toward the cap. GM can rename. Remove: see 3.2 [FIXED, #6].
|
||||
- **Player key**: `player_id, secret (plaintext, re-showable by GM, Q11 FIXED), created`; one current key per player; replace overwrites. The GM's key is the GM player's key (3.2). Not a session [FIXED, #6].
|
||||
- **Session**: `id, player_id, token_hash, created, last_seen`; never expires (Q10 FIXED).
|
||||
- **Explored grid**: per `(player, scene)`, strictly per player (Q9 FIXED): bitset over `ceil(w/cell) x ceil(h/cell)` cells; persisted as chunked bitmaps (4.4). Only grows. Players with no vision-enabled entity have an empty grid.
|
||||
- **Vision polygons**: runtime only, never persisted (recomputed at start).
|
||||
@@ -490,7 +497,7 @@ Principles carried from the prototype: the checker must be independent of the co
|
||||
| Geometry mutation check | `tools/mutation.sh` (a: no +-RayEps rays, b/c: upper/lower segment end exclusive) | Control passes, each mutation fails >= 1 test [MEASURED 1, 2, 2]. Port. |
|
||||
| Leak test | `tools/leak.mjs`, `leakcheck.nim`, `leaktest.sh` | Subject A and B, fresh DB, ~240 steps; asserts (a)-(e) in README. Independent LOS oracle for token visibility (added after the bow-tie bug). |
|
||||
| Negative control / fault injection | `tools/faulttest.sh`, `-d:leakfault` build | 8 faults, exact failure-class set each, clean build passes, `LEAK_FAULT` string asserted absent from clean binary [MEASURED 8/8]. Port and extend. |
|
||||
| Restart | `tools/restart.mjs` | SIGTERM + SIGKILL, identical invites/positions/doors/vision/explored/hello+state. |
|
||||
| Restart | `tools/restart.mjs` | SIGTERM + SIGKILL, identical player keys/positions/doors/vision/explored/hello+state. |
|
||||
| Concurrency | `tools/concurrency.mjs` | 60 s, 3 clients, gseq monotonic, every intent acked, quiesced views == fresh connection. |
|
||||
| Client reducer tests | `client/src/state.test.ts` | Incl. reconnect reset. |
|
||||
| Smoke | `tools/smoke.mjs` | auth/cookie/tile/steal/garbage. |
|
||||
@@ -502,10 +509,10 @@ Principles carried from the prototype: the checker must be independent of the co
|
||||
- Leak checker oracle initially only checked "nothing extra", not "everything visible shows"; completeness check is kept (assert (b)).
|
||||
|
||||
### 10.3 New
|
||||
- **Fault classes** for new data: `GMONLY_TOKEN`, `OWNER_PROP`, `GM_PROP`, `GLOBAL_COUNTER` (gseq side channel), `WALL_DELTA` (wall.add reaches player), `INVITE_IN_LOG`, `CHAR_OWNER_PROP`, `ACTUAL_NAME`, `CHAR_LIST`, `CONTROLLER_CHANGE` (#14). Each with an injected fault and exact-class assertion, same as existing.
|
||||
- **Fault classes** for new data: `GMONLY_TOKEN`, `OWNER_PROP`, `GM_PROP`, `GLOBAL_COUNTER` (gseq side channel), `WALL_DELTA` (wall.add reaches player), `KEY_IN_LOG`, `CHAR_OWNER_PROP`, `ACTUAL_NAME`, `CHAR_LIST`, `CONTROLLER_CHANGE` (#14). Each with an injected fault and exact-class assertion, same as existing.
|
||||
- **Characters and names (#14)**: tests for reveal per player and reveal to all; owner sees own actual name; character owner change leaves token controllers unchanged; encountered entries survive token removal and scene change and are removed only by the GM; `gm_only` tokens never enter an encountered list. Fault classes: `ACTUAL_NAME` = unrevealed actual name sent to a player; `CHAR_LIST` = another player's character or encountered entry sent; `CONTROLLER_CHANGE` = owner change altering controllers; `CHAR_OWNER_PROP` = character owner-bucket prop sent to a non-owner.
|
||||
- **Probing test (T8)**: M2, in-process against the move-rules module (5.5): arbitrary far moves; assertion: facts about walls/doors beyond LOS recoverable from replies <= a bounded amount (step cap), and uniform nack shape. M3: same test over WS with a hostile client (moved from M2).
|
||||
- **Auth tests**: invite revoke, one invite reused on several devices (Q10 FIXED), Origin mismatch rejected, cookie flags present.
|
||||
- **Auth tests**: key replace (old key invalid, sessions revoked, live connections closed), remove player (key invalid, characters and tokens pass to GM), one key reused on several devices (Q10 FIXED), Origin mismatch rejected, cookie flags present.
|
||||
- **Protocol tests**: proto mismatch, unknown message type both directions, oversized frame, malformed JSON flood, rate limit.
|
||||
- **Persistence**: migration tests (old DB -> new), chunked explored round trip, restart test extended to wall CRUD and entity props.
|
||||
- **Slow client** (Q13, 4.3): a client that stops reading; outbox stays under cap, no further state is queued to it, RSS flat, full resync on recovery equals a fresh connection; nginx closes the dead `/ws` socket within its configured timeout.
|
||||
@@ -527,11 +534,11 @@ Principles carried from the prototype: the checker must be independent of the co
|
||||
- **nginx** (shape of the vhost, adapt to the existing server config; reference only, I did not read the owner's NixOS repo for this doc):
|
||||
- `location /` -> static client `dist`, SPA fallback to `index.html`.
|
||||
- `location = /ws` (prototype uses `/ws`) -> `proxy_pass` to backend, `proxy_http_version 1.1`, `Upgrade`/`Connection` via the `$http_upgrade` -> `$conn_up` map as in the prototype, `proxy_read_timeout` long (prototype 1 h; app-level ping makes this robust), `proxy_buffering off`. The map must be declared at `http{}` level.
|
||||
- `location /join/` -> proxy, **`access_log off`**, `add_header Referrer-Policy no-referrer`.
|
||||
- `location = /join` -> proxy, **`access_log off`**, `add_header Referrer-Policy no-referrer`.
|
||||
- `location /tiles/` -> proxy (Nim decides, returns `X-Accel-Redirect`).
|
||||
- `location /_tiles/` -> `internal; alias <state dir>/tiles/;` `Cache-Control private`. Must be readable by the nginx user (group read on the tiles dir) [INFERRED NixOS gotcha]; do not expose the state dir otherwise.
|
||||
- Response headers: HSTS, CSP (no inline scripts, `connect-src 'self'` wss), `X-Content-Type-Options`, `Referrer-Policy`.
|
||||
- Rate limit `limit_req` on `/join/` (brute-force of 128-bit secrets is infeasible, this is about noise).
|
||||
- No `limit_req` on `/join` (owner, #6: no rate limit on key entry; ~100-bit key space).
|
||||
- Prototype nginx config (`prototype-server-vision/nginx/nginx.conf`) is the functional reference; its `listen` has no address (binds all) and its temp/log paths are dev-only.
|
||||
- Map import: offline CLI that slices an image into `tile_size` PNG/WebP tiles into `<state>/tiles/<scene>/<ver>/` and registers/updates the scene (prototype: `tools/genmap.mjs`, deterministic, hand-authored, not reusable as the importer). Browser upload is post-v1; CLI-only import in v1 (Q5 FIXED).
|
||||
|
||||
@@ -545,7 +552,7 @@ Principles carried from the prototype: the checker must be independent of the co
|
||||
- Prototype's instrumentation is prototype-only: it appends every sample to unbounded arrays, and `printStats` copies and sorts all of them inside `finish()` under the global lock; **do not port** [MEASURED/HANDOFF].
|
||||
- Real: under the lock only O(1) updates: a fixed-size ring buffer or fixed-bucket histogram per metric (lock_wait, vision, sqlite, send, total) and atomic counters (mutations, errors, nacks, connections, bytes). A separate timer thread (not holding the lock) snapshots and computes percentiles every N s and logs one line.
|
||||
- Keep the `SLOW` line (total > `SLOW_MS`, default 50) with breakdown `lock_wait / vision / sqlite / send / other` and intent type: it is what diagnosed the SQLite COMMIT tail [MEASURED, `results/spike/investigation.md`]. Formatting of the line happens after releasing the lock; at most O(1) rate-limited lines per second.
|
||||
- Log to stdout -> journald; levels; never log invite/session secrets, token positions of hidden entities are fine in server logs (server is trusted) but logs are GM-readable only (file perms).
|
||||
- Log to stdout -> journald; levels; never log player key/session secrets, token positions of hidden entities are fine in server logs (server is trusted) but logs are GM-readable only (file perms).
|
||||
- Metrics exposure: journald lines only in v1, no `/metrics` endpoint (Q22 FIXED).
|
||||
- Health: `GET /healthz` internal-only returning 200 when the lock can be acquired within a bound. `/healthz` stays (Q22 FIXED).
|
||||
|
||||
@@ -565,7 +572,7 @@ Source: `prototype-server-vision/HANDOFF.md` (and README/NOTES worries).
|
||||
| H6 | Single machine, loopback, power-save timings | Decision: keep as baseline only; real-network run required | M7 |
|
||||
| H7 | Boundary epsilon ambiguity | Decision: keep `RayEps`, 0.5 px tolerance in checkers; documented | M1 |
|
||||
| H8 | Tile leak: whole 256 px tile | Decision [FIXED, Q4]: `tile_size` = explored cell = 32 px; residual leak <= one cell, never revoked; no server masking; M4 gates (headless mobile-emulation + phone run); fallback 64 px per-scene config | M4 |
|
||||
| H9 | Invite = cookie = permanent bearer, no expiry, binds 0.0.0.0, needs HTTPS | Decision: session != invite, revoke/regenerate, log redaction, bind 127.0.0.1, HTTPS via nginx. Sessions never expire; one invite reusable across devices (Q10 FIXED); invite secrets plaintext (Q11 FIXED) | M3 |
|
||||
| H9 | Prototype secret = cookie = permanent bearer, no expiry, binds 0.0.0.0, needs HTTPS | Decision: session != key, key replace (GM, live), remove player, log redaction, bind 127.0.0.1, HTTPS via nginx. Sessions never expire; one player key usable across devices (Q10 FIXED); keys plaintext (Q11 FIXED); no key-entry rate limit (owner, #6) | M3 |
|
||||
| H10 | Move collision: centre path + dest circle, not swept circle | Decision: capsule (swept-circle) check + escape rule, 5.5; step cap = effective vision radius, 5.5 (T8) | M2 |
|
||||
| H11 | Leak test explored/tile checks self-consistent | Decision: add independent explored oracle | M2 |
|
||||
| H12 | Full vision polygon (~3 KB) per player move | Decision [FIXED, Q16]: full polygon, integer px, only on change; delta/binary post-v1 | M3 |
|
||||
@@ -597,7 +604,7 @@ 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.
|
||||
- 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.**
|
||||
- Scope: entities with bucketed props, characters with names, name reveal and encountered list (8, #14), players, invites/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.
|
||||
- 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.
|
||||
- Accept: ported leak test (A and B) + fault test with the extended fault classes: all caught with exact class sets, clean build passes; restart test passes incl. CRUD; auth tests pass; no secrets in logs; character and name tests pass (10.3, #14).
|
||||
- **M4 - Client v1.**
|
||||
- Scope: new `client/` dir (first real client build): Vite + TS + Pixi v8 client: layers, tiles, grid, tokens (BitmapText), character list, encountered list (greyed), reveal buttons (#14 UI; server side in M3), fog textures, wall/door editor, token drag with prediction/rollback, DOM overlay, reconnect backoff, reducer tests; after the client port, archive `prototype-*` dirs (Q24).
|
||||
@@ -608,7 +615,7 @@ Each is small, ends with a green gate, and no milestone depends on browser UI be
|
||||
- Accept: concurrency 60 s x3 pass with p99 <= prototype (4.98 ms) +50%; slow-client test: client that stops reading -> outbox stays under cap, RSS flat, no further state queued to it, full resync on recovery equals a fresh connection; nginx closes a dead `/ws` within its configured timeout (measured); stats computation shown outside the lock (lock hold time unchanged with metrics on, measured).
|
||||
- **M6 - NixOS deployment.**
|
||||
- Scope: `nix/` dir per Q20: un-ignore `nix/` in `.gitignore`; `lock.json` (nim_lk), `package.nix` (buildNimPackage, nixpkgs pinned to devbox Nim 2.2.12, mummy tag 0.4.8), `module.nix` (`services.fffVtt`); declare a nimble `bin` in `fff_vtt.nimble` (nim_builder builds only `bin` entries, so the package is empty without it); client build; nginx vhost; systemd hardening; backups timer (Q21), restore drill, import CLI for maps (slices at `tile_size`, Q4).
|
||||
- Accept: deployed behind HTTPS on the owner's server; `/_tiles/` 404 directly; WS upgrade works; invite join works from phone; access log has no secret; backup + restore drill passes.
|
||||
- Accept: deployed behind HTTPS on the owner's server; `/_tiles/` 404 directly; WS upgrade works; player key sign-in works from phone; access log has no secret; backup + restore drill passes.
|
||||
- **M7 - Real-world pass.**
|
||||
- Scope: real-network latency/throughput run, iOS/Safari check (if available), one real session with the owner's table, collect SLOW lines.
|
||||
- Accept: documented numbers; defects triaged to issues; go/no-go for v1.
|
||||
@@ -627,8 +634,8 @@ Each is small, ends with a green gate, and no milestone depends on browser UI be
|
||||
7. Q7 - Vision model: single radius per token or per-token property from day one? Is any "darkvision/light" concept needed before FFF? **RESOLVED [FIXED (owner decision), 2026-11-08]:** per-entity numeric `vision_radius` plus scene default; no light sources or darkvision.
|
||||
8. Q8 - Which "table convenience" features come first after v1, if any: freehand drawing (exists in the perf prototype), pings, ruler, chat, dice, token images/portraits, initiative tracker? **DEFERRED [FIXED (owner decision), 2026-11-08]:** decided at M7.
|
||||
9. Q9 - Should players see each other's names/presence, and should party members share vision (shared explored/LOS) or is it strictly per player? **RESOLVED [FIXED (owner decision), 2026-11-08]:** vision and explored strictly per player; player names visible to all.
|
||||
10. Q10 - Session lifetime and invite policy: session expiry, how often invites rotate, single-use vs reusable invite links, can one player use multiple devices at once? **RESOLVED [FIXED (owner decision), 2026-11-08]:** sessions never expire; one invite link is reusable on multiple devices.
|
||||
11. Q11 - Invite secrets: stored hashed (shown once, GM regenerates to re-share) or stored plaintext so the GM can re-copy a link? **RESOLVED [FIXED (owner decision), 2026-11-08]:** invite secrets stored plaintext so the GM can re-copy the link.
|
||||
10. Q10 - Session lifetime and invite policy: session expiry, how often invites rotate, single-use vs reusable invite links, can one player use multiple devices at once? **RESOLVED [FIXED (owner decision), 2026-11-08]:** sessions never expire; one player key is usable on multiple devices (wording amended #6: was invite link).
|
||||
11. Q11 - Invite secrets: stored hashed (shown once, GM regenerates to re-share) or stored plaintext so the GM can re-copy a link? **RESOLVED [FIXED (owner decision), 2026-11-08]:** player and GM key secrets stored plaintext so the GM can re-show them (wording amended #6: was invite secrets).
|
||||
12. Q12 - Durability: is `synchronous=NORMAL` (can lose the last few commits on power loss/OS crash, never corrupts) acceptable, or should it be FULL for some or all writes? **RESOLVED [FIXED (owner decision), 2026-11-08]:** `synchronous=NORMAL`; `FULL` around GM authoring transactions.
|
||||
13. Q13 - Slow/dead client policy: acceptable to disconnect clients that fall behind? Willing to patch/fork the pinned mummy commit if per-socket queue depth cannot be read from outside? **RESOLVED [FIXED (owner decision), 2026-11-08]:** option A: app-level bounded per-client outbox, latest-state-wins coalescing per key (MQTT-retained-like), diff at flush time, server Ping(seq)/Pong ack tracking for lag, stop feeding lagging clients + full resync on recovery; no mummy patch. Dead/stuck peers closed by nginx proxy timeouts (mechanism PROPOSED; verify WS goes through nginx in M5). Fork of mummy (option B) is fallback only, not planned. Research: `docs/research/q13-mummy-slow-clients.md`; detail in 4.3.
|
||||
14. Q14 - Moving tokens when walls change: what should happen if the GM closes a door (or edits a wall) on top of a token? Allow the token to walk out, auto-nudge it, or refuse the edit? **RESOLVED [FIXED (owner decision), 2026-11-08]:** a GM edit that lands on a token gives it status `blocked`: server refuses that token's player moves; GM can still move it; status clears when the wall is removed or the door opened, or when the GM clears it. **Door case revised [FIXED (owner decision), 2026-11-08]:** spell walls and wall edits stay stuck; a door closing on a token pushes the token aside (5.5), stuck only if neither side is valid. Status names superseded by #4 (2026-11-10): `blocked` is now `stuck`/`squeezed` (5.5); door-push failure is `squeezed`.
|
||||
@@ -648,3 +655,5 @@ Owner also decided 2026-11-08 [FIXED (owner decision)]: restore drill belongs in
|
||||
Owner also decided 2026-11-08 (M2): move rules, `blocked` trigger and GM move bypass are recorded in 5.5; M2 scope and accept criteria in 13.
|
||||
|
||||
Owner also decided 2026-11-10 [FIXED (owner decision), #14]: characters are separate records from tokens (one owner: a player or the GM; a token may link to one character; token controller is independent of the character owner); character holds identity, token holds the state of the figure; descriptive and actual names, revealed per player or to all; per-player encountered list, persisted, removed only by the GM; storage on the server only (SQLite). Character export/import as a file is future, not M3. See 3.1, 4.4, 8.
|
||||
|
||||
Owner also decided 2026-11-10 [FIXED (owner decision), #6]: one shared site link (alone it shows only the sign-in page); each player has a personal player key, generated by the GM with no name, identifying the player and granting access to their data. The player types their display name at first sign-in; names are unique among players; the GM can rename. The GM signs in the same way with a GM key printed by `fff-vtt gm-key` (replaces `gm-link`, #5; rest of #5 unchanged). The GM can replace a player's key at any time while the server runs: old key invalid, all that player's sessions revoked, live connections closed; identity, characters and encountered list kept; no name re-prompt. Removing a player: key invalid, sessions revoked, connections closed; their characters and controlled tokens pass to the GM; name and slot freed; encountered list deleted. Defaults accepted: one key on many devices; sessions never expire; keys stored plaintext; 20-character key in groups of 4 with dashes, no look-alikes, CSPRNG (~100 bits); 6-player cap counts unused keys; sign-in sets the session cookie as in 3.2. No rate limit or lockout on key entry (owner rejected guessing protection). Rejected: per-person invite links; GM types the name at key creation; delete-and-reinvite only; deleting characters with the player; shared-link visit creates a player; separate GM link path. Terms: "player key" and "GM key"; "token" stays reserved for map figures. Message names: #11.
|
||||
|
||||
Reference in New Issue
Block a user