docs: record owner decisions on §14 open questions
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
+93
-89
@@ -1,6 +1,6 @@
|
||||
# FFF_vtt design
|
||||
|
||||
Status: draft v0.1, 2026-11-07. Audience: the owner and coding agents.
|
||||
Status: draft v0.2, 2026-11-08 (owner decisions recorded in section 14). Audience: the owner and coding agents.
|
||||
|
||||
Legend:
|
||||
- **[FIXED]** owner decision, not up for debate here.
|
||||
@@ -12,7 +12,7 @@ Evidence roots (relative to repo root):
|
||||
- `prototype-pixi-perf/` (client perf; README holds all tables)
|
||||
- `prototype-server-vision/` (server + vision; `README.md`, `HANDOFF.md`, `NOTES.md`, `results/`, `results/spike/investigation.md`)
|
||||
- `docs/prototype.md` is only the original brief for the perf prototype.
|
||||
- No FFF engine notes exist in the repo. `GLOSSARY.md` and `docs/adr/` do not exist yet (AGENTS.md references them). Nothing here is FFF-specific beyond the seam in section 9.
|
||||
- No FFF engine notes exist in the repo. `GLOSSARY.md` and `docs/adr/` do not exist yet; AGENTS.md requires them (Q24, FIXED). `prototype-*` dirs stay in-tree until the M4 client port, then are archived (Q24, FIXED). Nothing here is FFF-specific beyond the seam in section 9.
|
||||
|
||||
---
|
||||
|
||||
@@ -22,9 +22,9 @@ Evidence roots (relative to repo root):
|
||||
A browser virtual tabletop for one table (1 GM + a few players), 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 + N players (N small, target <= 6), invite links, no accounts.
|
||||
- Scenes: large tiled map image, optional visual grid, walls and doors, tokens.
|
||||
- GM tools: author walls/doors on the map, create/move/delete tokens, toggle doors, edit token properties, manage invites, switch active scene (see Q3 on multi-scene).
|
||||
- One table, 1 GM + N players (N small; target <= 6 is a PROPOSED assumption, max players unanswered, Q1), invite links, 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.
|
||||
- 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.
|
||||
@@ -34,9 +34,10 @@ A browser virtual tabletop for one table (1 GM + a few players), self-hosted, wh
|
||||
- RPG rules, dice, character sheets, initiative. FFF engine plug-in: seam only (section 9).
|
||||
- Dynamic lighting, light sources, darkvision tiers, per-token vision radius beyond one numeric property, windows/transparent walls, one-way walls.
|
||||
- Accounts, passwords, OAuth, multiple tables/campaigns per server, public hosting.
|
||||
- Feeding from the owner's map generator [FIXED: does not feed in]. Map import is a manual/CLI step.
|
||||
- Freehand drawing, rulers, pings, chat, audio, video (see Q8 for which come first).
|
||||
- Mobile-first UI polish (the client must work on a phone [MEASURED render], but layout is not a v1 goal).
|
||||
- Feeding from the owner's map generator [FIXED: does not feed in]. Map import is a CLI step in v1; browser upload is post-v1 (Q5, FIXED).
|
||||
- Freehand drawing, rulers, pings, chat, audio, video (order decided at M7, Q8).
|
||||
- Mobile-first UI polish (the client must work on a phone [MEASURED render], but layout is not a v1 goal). Devices in scope: phones, tablets, laptops (Q1, FIXED).
|
||||
- Network exposure and reachability: owner's concern (Q23, FIXED). Built-in protections stay (127.0.0.1 bind, connection cap, frame/rate limits, Origin check); internet-only hardening (fail2ban etc.) is not in scope.
|
||||
- Horizontal scaling, multi-process server.
|
||||
|
||||
---
|
||||
@@ -102,8 +103,8 @@ A browser virtual tabletop for one table (1 GM + a few players), self-hosted, wh
|
||||
| Vision polygons | none needed (GM sees all) | own tokens' polygons only | never |
|
||||
| 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 only (open: Q9) | -- |
|
||||
| Invites/sessions | GM only (secrets shown once) | own session cookie only | never |
|
||||
| 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 |
|
||||
| Global activity counters (`gseq`) | yes | **no**: per-connection counter only | -- |
|
||||
|
||||
Notes:
|
||||
@@ -113,17 +114,17 @@ Notes:
|
||||
|
||||
### 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; session expiry/rotation policy in Q10.
|
||||
- **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.
|
||||
- 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 stored as hash vs plaintext (GM can re-copy the link) is Q11.
|
||||
- Invite secrets are stored plaintext so the GM can re-copy the link [FIXED, Q11].
|
||||
|
||||
### 3.3 Tiles
|
||||
- Browser asks `GET /tiles/<scene>/<x>_<y>.png` (Nim path). Nim parses strictly (digits only, length-bounded, range-checked against scene size), checks the session's explored grid, and answers `200` with `X-Accel-Redirect: /_tiles/...` or `403`. nginx serves the bytes from an `internal` location; direct hits on `/_tiles/` give 404 [MEASURED: `prototype-server-vision/results/smoke.log`, README "Phase 2a"].
|
||||
- GM is always allowed.
|
||||
- Rule: a tile is allowed iff at least one explored cell of that player overlaps it [MEASURED semantics: leak test (d), 9984 + 7424 requests, 0 failures, `results/leak-A.log`, `results/leak-B.log`].
|
||||
- **Known tile-edge leak (accepted for v1, documented) [MEASURED design limit]:** a tile is the unit of disclosure. With 256 px tiles and 32 px explored cells, up to one tile (256 px) around any explored cell is revealed, including art outside the explored cells. Once revealed it is never revoked. Static art only: door state is never in tiles. Consequences for map authors: do not paint secrets (secret doors, hidden traps, notes) in map art within ~256 px of areas players can reach; keep secrets as GM-only entities. Mitigations and their cost are Q4.
|
||||
- **Known tile-edge leak (accepted for v1, documented) [MEASURED design limit]:** a tile is the unit of disclosure. With 256 px tiles and 32 px explored cells, up to one tile (256 px) around any explored cell is revealed, including art outside the explored cells. Once revealed it is never revoked. Static art only: door state is never in tiles. Consequences for map authors: do not paint secrets (secret doors, hidden traps, notes) in map art within ~256 px of areas players can reach; keep secrets as GM-only entities. Mitigations and their cost: Q4, still open. Prototyping server-masked tiles vs cell-size tiles in `prototype-tile-leak/`.
|
||||
- A second consequence: map art itself may depict walls/doors. Art is "what players see once there", walls data is "what physics/vision uses". Authoring must keep them consistent; mismatch is GM error, not a leak.
|
||||
- Tile URLs include a scene version so that re-imported art does not hit stale caches [PROPOSED]; response `Cache-Control: private`.
|
||||
|
||||
@@ -138,7 +139,7 @@ Notes:
|
||||
| T5 | Tile-edge over-disclosure (up to 1 tile) | accepted v1; authoring rule; Q4 | documented, not testable as a leak |
|
||||
| T6 | Invite/session theft via logs, referrer, history | session != invite, log redaction, no-referrer, 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 (<= vision radius or smaller), rate limit intents per connection, uniform nack that carries only the old position | new probing test: 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 vision radius, Q18 FIXED), rate limit intents per connection, uniform nack that carries only the old position | new probing test: 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) |
|
||||
| T10 | Message-size or rate DoS, slow client memory growth | max frame size, per-connection rate limit, connection cap; mummy queue is unbounded [MEASURED finding, README mummy caveats] | new tests |
|
||||
| T11 | Timing/size side channels (message bytes reveal hidden activity) | accepted; only deliver messages when state visible to that recipient changes | not tested |
|
||||
@@ -182,14 +183,14 @@ Invariants (carry from prototype):
|
||||
|
||||
Known limitation [PROPOSED fix]: prototype checks only the centre path a->b and the destination circle, not the swept circle (corner clipping possible, `HANDOFF.md`). With step cap the exposure is bounded; M2 decides swept-circle check (capsule vs wall distance).
|
||||
|
||||
Second limitation [INFERRED]: a fast drag sampled at ~50 ms can produce a straight segment that cuts a corner the pointer path did not, causing a nack and a snap-back. Mitigation: client sends intermediate points when the step would exceed the cap; server clamps nothing silently (clamping would leak the hit distance, T8).
|
||||
Second limitation [INFERRED]: a fast drag sampled at ~50 ms can produce a straight segment that cuts a corner the pointer path did not, causing a nack and a snap-back. Mitigation: client sends intermediate points when the step would exceed the cap (token vision radius, Q18); server clamps nothing silently (clamping would leak the hit distance, T8).
|
||||
|
||||
### 4.3 Locking and threading
|
||||
- mummy: `WebSocket.send` appends the encoded frame to one server-wide deque under `sendQueueLock` and wakes the IO thread; worker threads handle events; per-socket events are serialized [MEASURED reading, `prototype-server-vision/README.md` "mummy suitability", mummy.nim ~L262-311].
|
||||
- **One global lock** around intent handling and send. [MEASURED] 13748 mutations / ~36k messages in 60 s with 3 clients (~223 intents/s): no crash, no reorder, no loss, consistent final views (`results/concurrency-final{1,2,3}.log`); intent->ack avg 1.40 ms, p99 4.58 ms, worst 20.31 ms.
|
||||
- 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].
|
||||
- Slow client: mummy's send queue is one unbounded deque, no per-socket depth available to us [MEASURED finding]. Mitigations [PROPOSED]: max connections (8), tiny messages, WS ping/pong timeout, per-connection byte counter we maintain ourselves and close when `sent - acked-by-pong` exceeds a bound (needs ping with counters; feasibility to be confirmed in M5, Q13).
|
||||
- Slow client: mummy's send queue is one unbounded deque, no per-socket depth available to us [MEASURED finding]. Mitigations [PROPOSED]: max connections (8, PROPOSED assumption, Q1), tiny messages, WS ping/pong timeout, per-connection byte counter we maintain ourselves and close when `sent - acked-by-pong` exceeds a bound (needs ping with counters; feasibility to be confirmed in M5). Q13 still open: owner leans to queued channels (MQTT-like) for slow clients; research pending on mummy capabilities.
|
||||
- `WebSocket` has no `==`/hash; prototype keys connections by the raw bytes of the ref (`key(ws)`), flagged as shortcut. Real build: assign a connection id at upgrade and keep it in a table indexed by the ws via a documented wrapper; add a test that fails if mummy's layout changes (pinned commit makes this stable but the test makes it explicit) [PROPOSED].
|
||||
- Handler discipline: no blocking I/O under the lock except the one SQLite COMMIT; no logging formatting of large structures under the lock; metrics are O(1) updates (section 11).
|
||||
- SQLite tail: server worst ~20 ms is the COMMIT (WAL autocheckpoint / OS scheduling [INFERRED]) and every other mutation queues behind it as `lock_wait` (`results/spike/investigation.md`). Accepted for v1. Moving persist out of the lock breaks ack-after-commit and order; not done.
|
||||
@@ -198,18 +199,18 @@ Second limitation [INFERRED]: a fast drag sampled at ~50 ms can produce a straig
|
||||
### 4.4 Persistence
|
||||
Engine: SQLite via `db_connector/db_sqlite`, `journal_mode=WAL`, one connection used under the global lock.
|
||||
|
||||
**synchronous choice [PROPOSED, confirm Q12]: `NORMAL`.**
|
||||
**synchronous choice [FIXED, Q12]: `NORMAL`; `FULL` around GM authoring transactions.**
|
||||
- [MEASURED] avg commit 0.60 -> 0.17 ms, server total avg 1.16 -> 0.74 ms; tail unchanged (~20 ms worst) (`results/spike/investigation.md`).
|
||||
- Process kill (SIGKILL) loses nothing [MEASURED: `results/final-restart.log`, SIGTERM and SIGKILL, same DB, identical state].
|
||||
- OS crash/power loss can drop the last few commits; never corrupts. For a VTT (positions, explored cells) that is acceptable; GM-authored content (walls, scenes) is the expensive loss, so authoring mutations may use an explicit `PRAGMA wal_checkpoint(FULL)` or a `synchronous=FULL` toggle around authoring transactions [PROPOSED, optional].
|
||||
- OS crash/power loss can drop the last few commits; never corrupts. For a VTT (positions, explored cells) that is acceptable; GM-authored content (walls, scenes) is the expensive loss, so GM authoring transactions run with `synchronous=FULL` [FIXED, Q12].
|
||||
- Acceptance of ack-before-durable on power loss is stated, not hidden.
|
||||
|
||||
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_hash|secret, created_at, revoked_at, used_at)
|
||||
session(id PK, player_id FK, token_hash, created_at, last_seen, expires_at)
|
||||
invite(id PK, player_id FK, secret, created_at, revoked_at, used_at) -- secret plaintext (Q11)
|
||||
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,
|
||||
art_version, active, extra_json)
|
||||
wall(id PK, scene_id FK, ax, ay, bx, by, kind, open, flags) -- kind: wall|door|(later: window, one-way)
|
||||
@@ -217,6 +218,7 @@ entity(id PK, scene_id FK, kind, name, x, y, owner_player_id NULL,
|
||||
gm_only, flags, props_public JSON, props_owner JSON, props_gm JSON)
|
||||
explored_chunk(player_id, scene_id, cx, cy, bits BLOB, PRIMARY KEY(player_id, scene_id, cx, cy))
|
||||
```
|
||||
- Exactly one scene in v1 (Q3): `scene_id` keys stay in the schema.
|
||||
- Prototype stores one row per explored cell (`exp(role, c)`, one INSERT per new cell, `HANDOFF.md`); real build stores **chunked bitmaps**: a chunk is e.g. 64x64 cells = 512 B; dirty chunks upserted per mutation [PROPOSED]. Sizes [INFERRED]: 4096 px map / 32 px cell = 16 384 cells = 2 KB bitmap; 16384 px map = 262 144 cells = 32 KB.
|
||||
- Entity move = one UPSERT of x,y (prototype: `INSERT OR REPLACE INTO tok`).
|
||||
- Migrations: `PRAGMA user_version` + forward-only migration list; startup refuses to run on a newer DB [PROPOSED].
|
||||
@@ -252,16 +254,16 @@ explored_chunk(player_id, scene_id, cx, cy, bits BLOB, PRIMARY KEY(player_id, sc
|
||||
|
||||
Conclusions:
|
||||
- `cellsTouched` is ~12x the polygon itself and dominates [MEASURED]. M2 target: replace per-cell polygon tests with scanline rasterization of the polygon over the explored grid, differential-tested against the ported implementation [PROPOSED].
|
||||
- Polygon cost is O(rays x walls in bbox) [MEASURED code reading, `server/geometry.nim` `visibilityPolygon` (ported unchanged from prototype)]. Prototype scene has 60 walls and 8 tokens, so this says nothing about big maps. With radius-bbox culling the cost scales with local wall density, not total walls [INFERRED]; a uniform spatial grid over walls is needed when scenes reach thousands of walls (M2 gate: bench with a synthetic 5k-wall scene, target polygon < 1 ms [PROPOSED target]).
|
||||
- Polygon cost is O(rays x walls in bbox) [MEASURED code reading, `server/geometry.nim` `visibilityPolygon` (ported unchanged from prototype)]. Prototype scene has 60 walls and 8 tokens, so this says nothing about big maps. With radius-bbox culling the cost scales with local wall density, not total walls [INFERRED]; a uniform spatial grid over walls is needed when scenes reach thousands of walls (M2 gate: bench with a synthetic 5k-wall scene, target polygon < 1 ms [PROPOSED test target, Q2: owner has no map size yet; revisit with real maps]).
|
||||
- Skip recompute when the token moved but its polygon is unchanged (prototype already compares `np == r.polys`).
|
||||
|
||||
### 5.4 Known limitations (carry forward)
|
||||
- Token exactly on a wall cannot move off it: `moveBlocked` counts any touch as a hit, so every move from that point is blocked, even a perpendicular step to the open side [MEASURED limit, `tests/tgeometry.nim` test "KNOWN LIMITATION: token exactly on a wall cannot move off it"; also in the `server/geometry.nim` header]. Known limitation, not a policy. Fix proposed in 13 M2 [PROPOSED]. A validated move cannot reach this state (a destination within r of a wall is rejected) [INFERRED from `moveBlocked`]; it can arise from a wall/door edit landing on a token, or from a placement intent (6.1 does not say whether placements are collision-checked).
|
||||
- Closing a door (or editing a wall) on a token: policy open, see Q14; no decision here. Current behaviour is pinned by `tests/tgeometry.nim`, suite "door/wall closing on a token", test "door closed on a token: Q14 undecided, DESIGN 5.4 vs 12 H2 conflict": a token whose centre is 10 px off a closed door may move to a clear spot, may not stay overlapped, and may not cross the door. That test pins `moveBlocked` only; what the server does on a door edit under a token is not pinned here.
|
||||
- Token exactly on a wall cannot move off it: `moveBlocked` counts any touch as a hit, so every move from that point is blocked, even a perpendicular step to the open side [MEASURED limit, `tests/tgeometry.nim` test "KNOWN LIMITATION: token exactly on a wall cannot move off it"; also in the `server/geometry.nim` header]. Known limitation, not a policy. Fix: escape rule in M2 (section 13). The escape is required by Q14 so the GM can move such a token: mechanism [PROPOSED], requirement [FIXED]. A validated move cannot reach this state (a destination within r of a wall is rejected) [INFERRED from `moveBlocked`]; it can arise from a wall/door edit landing on a token (Q14: status `blocked`), or from a placement intent (6.1 does not say whether placements are collision-checked).
|
||||
- Closing a door (or editing a wall) on a token [FIXED, Q14]: the token gets status `blocked`. The server refuses that token's player moves; the GM can still move it; status clears when the wall is removed or the door opened, or when the GM clears it. Current pin: `tests/tgeometry.nim`, suite "door/wall closing on a token", test "door closed on a token: Q14 undecided, DESIGN 5.4 vs 12 H2 conflict": a token whose centre is 10 px off a closed door may move to a clear spot, may not stay overlapped, and may not cross the door. It pins `moveBlocked` only; it is replaced in M2 by tests of the policy above.
|
||||
- Boundary epsilon ambiguity (RayEps 1e-4, inclusive tolerances).
|
||||
- Explored and tile checks in the leak test recompute with the server's own `cellsTouched`: self-consistency only (caveat in 10.2). New independent oracle in section 10.
|
||||
- Doors/walls changing does not un-explore anything; explored only grows [MEASURED behaviour].
|
||||
- Single uniform vision radius in prototype; v1 uses a per-entity numeric property (`vision_radius`) with scene default; no light model.
|
||||
- Single uniform vision radius in prototype; v1 uses a per-entity numeric property (`vision_radius`) with scene default; no light/darkvision [FIXED, Q7].
|
||||
- Vision origin = token centre, radius is not clipped by the token's own size.
|
||||
|
||||
---
|
||||
@@ -276,13 +278,13 @@ Client -> server (intents). Authority column: P = player, G = GM.
|
||||
|
||||
| t | fields (contract) | who | server behaviour |
|
||||
|---|---|---|---|
|
||||
| `move` | `reqId:int, id, pos:[x,y]` | P (owned) / G (any) | validate; reply `moveAck` (+ `token` diffs); non-owned -> `error` |
|
||||
| `door` | `id, open:bool` | G | toggle; recompute all players |
|
||||
| `wall.add` / `wall.update` / `wall.remove` | wall fields / `id` | G | validate geometry; recompute all players; GM-only broadcast of wall delta |
|
||||
| `move` | `reqId:int, id, pos:[x,y]` | P (owned) / G (any) | validate; reply `moveAck` (+ `token` diffs); non-owned -> `error`; P move of a token with status `blocked` -> `moveAck{ok:false}` (Q14) |
|
||||
| `door` | `id, open:bool` | G | toggle; recompute all players; sets/clears `blocked` on tokens under it (Q14) |
|
||||
| `wall.add` / `wall.update` / `wall.remove` | wall fields / `id` | G | validate geometry; recompute all players; GM-only broadcast of wall delta; sets/clears `blocked` on tokens under it (Q14) |
|
||||
| `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.activate` | scene meta / id | G | broadcasts new `hello`-equivalent reset to all |
|
||||
| `invite.create` / `invite.revoke` | player id | G | returns link once (HTTP alternative: Q11) |
|
||||
| `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) |
|
||||
| `ping` | `ts` | any | `pong` (also feeds slow-client detection) |
|
||||
| `act` | `actor, action, args` | P/G | **reserved**: v1 replies `error: no-rules` (section 9) |
|
||||
|
||||
@@ -295,11 +297,11 @@ Server -> client.
|
||||
| `door` | `id, open` | GM only (players learn only via LOS changes) |
|
||||
| `vision` | `polys` (integer px, owned tokens only) | player |
|
||||
| `explored` | `cells` (full on connect, fresh cells after) | player |
|
||||
| `token` | `id, name, kind, pos, mine`, visible props | per visibility |
|
||||
| `token` | `id, name, kind, pos, mine, status` (e.g. `blocked`, Q14), visible props | per visibility |
|
||||
| `remove` | `id` (left LOS / deleted) | per visibility |
|
||||
| `moveAck` | `reqId, ok, pos` | sender only |
|
||||
| `error` | static `msg` code | sender only |
|
||||
| `presence` | who is connected | GM (players: Q9) |
|
||||
| `presence` | who is connected | all: names (Q9, FIXED) |
|
||||
| `pong` | echo | sender |
|
||||
|
||||
### 6.2 Versioning [PROPOSED]
|
||||
@@ -309,14 +311,14 @@ Server -> client.
|
||||
|
||||
### 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].
|
||||
- No gap detection and no `resume(since)`: WS over TCP is ordered and lossless while connected, and a reconnect restarts from a full snapshot. Revisit when explored grid or entity count makes the snapshot large (>~100 KB [INFERRED threshold]); options in Q15.
|
||||
- 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].
|
||||
- Same player on two connections: both synced; each has its own `known` table.
|
||||
- Same player on two connections: both synced; each has its own `known` table. Multiple devices per player allowed (Q10, FIXED).
|
||||
|
||||
### 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)].
|
||||
- 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.
|
||||
- v1 decisions [PROPOSED]: quantize polygon vertices to integer px (halves the text size [INFERRED]); polygon only to its owner; send `vision` only when changed; defer polygon delta/binary encoding until a measured need (Q16). Explored on connect as run-length rows, later diffs as cell lists.
|
||||
- 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: client sends at most ~20 Hz while dragging (prototype 50 ms) plus a final position; server caps intents per second per connection.
|
||||
|
||||
---
|
||||
@@ -334,7 +336,7 @@ Server -> client.
|
||||
### 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.
|
||||
- **Update only changed entities**, never all per frame (chaos worst case is not a workload here).
|
||||
- **BitmapText** with a pre-installed `BitmapFont` for labels (no raster/upload on change); limit: single font size blurs on zoom, glyph set Latin/digits only. Decision [PROPOSED]: names via BitmapText with a wider glyph set in v1; HTMLText/Text only for non-Latin fallback (Q17).
|
||||
- **BitmapText** with a pre-installed `BitmapFont` for labels (no raster/upload on change); limit: single font size blurs on zoom. Decision [FIXED, Q17]: names via BitmapText; glyph set = Latin incl. accented characters + Nerd Font icon glyphs. No non-Latin or emoji requirement, so no HTMLText/Text fallback in v1.
|
||||
- **Shared GraphicsContext** per colour, tessellated once; pooled tokens.
|
||||
- **Culling**: map tiles/baked sprites `cullable`; tokens fixed `cullArea`.
|
||||
- **Map larger than max texture -> tiles**; WebGPU maxTex 8192 vs WebGL 16384 on the same GPU; phone maxTex 4096. A single 16384 texture ~1 GB VRAM: never upload big single textures, always tiles.
|
||||
@@ -355,8 +357,8 @@ Prototype `client/src/main.ts`: explored rects appended to a `Graphics` mask for
|
||||
|
||||
### 7.4 Input and UI
|
||||
- Mouse: wheel zoom, drag pan, drag token. Touch: one finger drag/pan, two-finger pinch/pan [MEASURED works on Note 10].
|
||||
- Wall editor (GM): click-click segments, snap to grid/endpoints optional, door tool, delete, undo of last edit [PROPOSED]; submits `wall.*` intents; server is the validator.
|
||||
- Optional grid snap on drag end (client-side convenience; server still accepts any in-bounds free position) [PROPOSED, Q18].
|
||||
- Wall editor (GM) [FIXED, Q6: in v1, kinds `wall`|`door` only]: click-click segments, snap to grid/endpoints optional, door tool, delete, undo of last edit [PROPOSED]; submits `wall.*` intents; server is the validator.
|
||||
- Grid snap on drop: client option, off by default [FIXED, Q18]. Server accepts any in-bounds free position within the step cap (token vision radius, Q18 FIXED).
|
||||
|
||||
### 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.
|
||||
@@ -372,16 +374,16 @@ Prototype `client/src/main.ts`: explored rects appended to a `Graphics` mask for
|
||||
|
||||
All ids are server-assigned, opaque, non-guessable where they are exposed to players (entities); walls use dense integers GM-side only.
|
||||
|
||||
- **Scene**: `id, name, w, h` (px), `tile_size` (256 default), `explored_cell` (32 default; `tile_size % cell == 0` required, prototype assumes it silently), `grid_size`, `vision_radius_default`, `art_version`, `active`, free-form `extra`.
|
||||
- **Scene** (exactly one in v1, Q3): `id, name, w, h` (px), `tile_size` (256 default), `explored_cell` (32 default; `tile_size % cell == 0` required, prototype assumes it silently), `grid_size`, `vision_radius_default`, `art_version`, `active`, free-form `extra`.
|
||||
- **Wall/Door**: `id, scene, a:[x,y], b:[x,y], kind ('wall'|'door'), open:bool, flags`. `blocks = not (door and open)`. GM-only everywhere. Later kinds (window, one-way, secret door) are extra `kind`/`flags` values; v1 geometry treats any non-open blocker identically.
|
||||
- **Entity (token and anything else) [PROPOSED, FFF seam]**:
|
||||
- `id, scene, kind` (free string: `pc`, `npc`, `item`...), `name`, `pos`, `radius`, `owner` (player id or null = GM-controlled), `gm_only`, `flags` (`vision`, `blocks_move`...), `vision_radius` (optional).
|
||||
- `props`: three JSON objects by visibility bucket: `public` (anyone who sees the entity), `owner` (owner + GM), `gm` (GM only). Keys are strings, values JSON scalars/arrays/objects with a size cap.
|
||||
- `id, scene, kind` (free string: `pc`, `npc`, `item`...), `name`, `pos`, `radius`, `owner` (player id or null = GM-controlled), `gm_only`, `flags` (`vision`, `blocks_move`...), `vision_radius` (optional; per-entity numeric with scene default, Q7 FIXED), `status` (e.g. `blocked`, Q14).
|
||||
- `props`: three JSON objects by visibility bucket: `public` (anyone who sees the entity), `owner` (owner + GM), `gm` (GM only). Keys are strings, values JSON scalars/arrays/objects with a size cap. No hidden state beyond these buckets and `gm_only` in v1 [FIXED, Q19].
|
||||
- The server never interprets props in v1 except via a registered property schema (type, bucket, writable-by) used for validation and for FFF later.
|
||||
- **Player**: `id, name, role (gm|player), colour`. Exactly one GM.
|
||||
- **Invite**: `id, player_id, secret (hashed or not, Q11), created, revoked, used`.
|
||||
- **Session**: `id, player_id, token_hash, created, last_seen, expires`.
|
||||
- **Explored grid**: per `(player, scene)`: 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.
|
||||
- **Invite**: `id, player_id, secret (plaintext, re-copyable by GM, Q11 FIXED), created, revoked, used`.
|
||||
- **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).
|
||||
- **Connection (runtime)**: id, player, `known` map, last vision ver, counter.
|
||||
|
||||
@@ -397,7 +399,7 @@ Principle: v1 has no rules, but every state change already flows through a valid
|
||||
- **Action hook** (server side): the reserved `act` intent carries `actor, action, args`. Handling = `rules.handle(world, actor, action, args) -> list of mutations | error`. Mutations are the same primitive set the pipeline already validates (set prop, move, create/remove entity, emit event). Hook output is validated like any client intent; FFF cannot bypass the egress filter.
|
||||
- **Events**: `event{kind, data}` server->client messages with per-recipient filtering (e.g. roll results visible to all, GM-only whispers). Not implemented in v1; message type name reserved.
|
||||
- **Schema registry**: `property schema` (key, type, bucket, writable-by role, default) registered by the rules module; v1 ships an empty/default registry.
|
||||
- **Where does FFF run?** Depends on its implementation language and runtime, which I do not know (Q19). Options: (a) compile-time Nim module linked into the server (simplest, fastest, requires FFF in Nim or a Nim port); (b) out-of-process sidecar speaking a small request/response protocol over a Unix socket (language-agnostic, adds latency and a failure mode inside the global lock; must run outside the lock or be time-bounded); (c) WASM. No decision made.
|
||||
- **Where does FFF run?** Undecided. Q19 answered only the hidden-state question (no state beyond the buckets and `gm_only`, FIXED); engine language, runtime and location are not answered. Revisit when FFF starts (schema change accepted then). Options: (a) compile-time Nim module linked into the server (simplest, fastest, requires FFF in Nim or a Nim port); (b) out-of-process sidecar speaking a small request/response protocol over a Unix socket (language-agnostic, adds latency and a failure mode inside the global lock; must run outside the lock or be time-bounded); (c) WASM. No decision made.
|
||||
- Client side: a generic property panel driven by the schema registry; FFF-specific UI later as additional DOM panels (plain HTML overlay [FIXED] keeps this simple).
|
||||
- Non-goal now: any assumption about dice, turns, or stat names.
|
||||
|
||||
@@ -428,14 +430,14 @@ Principles carried from the prototype: the checker must be independent of the co
|
||||
### 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`. Each with an injected fault and exact-class assertion, same as existing.
|
||||
- **Probing test (T8)**: a hostile client issues arbitrary far moves; assertion: facts about walls/doors beyond LOS recoverable from replies <= a bounded amount (step cap), and uniform error shape.
|
||||
- **Auth tests**: invite revoke, session expiry, replay of invite after rotation, Origin mismatch rejected, cookie flags present.
|
||||
- **Auth tests**: invite revoke, one invite 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**: a client that stops reading; server memory bounded / connection closed (depends on Q13 outcome).
|
||||
- **Browser e2e (new, none in prototype)**: headless Chromium via playwright-core (the perf prototype already drives devbox chromium, `prototype-pixi-perf/bench.mjs`; SwiftShader is fine for correctness, not for perf). Checks: join -> canvas renders; pixel probe shows unexplored area black, visible area map-coloured, dimmed explored area; GM sees walls, player DOM/network contains none; reconnect restores view; drag moves token and rollback works.
|
||||
- **Independent traffic audit in e2e**: record all WS frames and HTTP responses seen by a player browser and run the leak checker's (a)(e) assertions over them.
|
||||
- **Load/perf regression gate**: `bench` + concurrency numbers (section 5.3 and 4.3) compared with committed baselines; fail on > 2x regression [PROPOSED].
|
||||
- **Wall-count scaling bench**: 5k-wall synthetic scene (section 5.3).
|
||||
- **Wall-count scaling bench**: 5k-wall synthetic scene (section 5.3; PROPOSED test target, Q2).
|
||||
- Timings from the prototype are single machine loopback power-save CPU; no real network, no client render [MEASURED caveat]. A real-network run (laptop over the intended HTTPS path, phone on LAN) is an M7 item.
|
||||
|
||||
---
|
||||
@@ -456,21 +458,21 @@ Principles carried from the prototype: the checker must be independent of the co
|
||||
- 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).
|
||||
- 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). Upload-in-browser is later (Q5).
|
||||
- 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).
|
||||
|
||||
### 11.2 Backups [PROPOSED]
|
||||
- SQLite: systemd timer running an online backup (`.backup` or `VACUUM INTO`) to a dated file, keep N; WAL means a plain file copy is unsafe.
|
||||
- SQLite: systemd timer running an online backup (`.backup` or `VACUUM INTO`) to a dated file in a backup folder the server creates under its data root (Q21 FIXED), keep N; WAL means a plain file copy is unsafe.
|
||||
- Tiles: immutable after import, include in the normal file backup, or regenerate from source art (keep the source image).
|
||||
- Restore drill documented and tested once (M7): restore into a temp dir, start server, run the restart-equivalence assertions.
|
||||
- Off-box copy destination: Q21.
|
||||
- Restore drill documented and tested once (M6): restore into a temp dir, start server, run the restart-equivalence assertions.
|
||||
- Off-box copy: out of v1 scope (Q21 FIXED).
|
||||
|
||||
### 11.3 Logging and metrics (bounded, outside the lock) [PROPOSED]
|
||||
- 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).
|
||||
- Metrics exposure: journald lines only in v1; optional internal-only `/metrics` is Q22.
|
||||
- Health: `GET /healthz` internal-only returning 200 when the lock can be acquired within a bound.
|
||||
- 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).
|
||||
|
||||
---
|
||||
|
||||
@@ -481,26 +483,26 @@ Source: `prototype-server-vision/HANDOFF.md` (and README/NOTES worries).
|
||||
| # | Item | Decision / open | Milestone |
|
||||
|---|---|---|---|
|
||||
| H1 | Port geometry + tests as-is | Decision: port `geometry.nim`, `tgeometry.nim`, mutation check, leak harness first | M1 |
|
||||
| H2 | Token on a wall can't leave (inclusive `segsCross`); closing a door or editing a wall on a token | Open Q14: no decision here. Today: token exactly on a wall is blocked from any move (`tests/tgeometry.nim`, test "KNOWN LIMITATION: token exactly on a wall cannot move off it"); token overlapping a closed door may walk to a clear spot, may not stay overlapped, may not cross (`tests/tgeometry.nim`, suite "door/wall closing on a token", test "door closed on a token: Q14 undecided, DESIGN 5.4 vs 12 H2 conflict"). Escape fix for the on-wall case: PROPOSED, see 13 M2. Edit policy under a token: open, Q14. | M2 |
|
||||
| H2 | Token on a wall can't leave (inclusive `segsCross`); closing a door or editing a wall on a token | Decision [FIXED, Q14]: token gets status `blocked` (player moves refused, GM moves allowed, clears on wall removal, door open, or GM clear). Escape fix for the on-wall case is required so GM can move it; mechanism PROPOSED, see 13 M2. Existing pin test replaced in M2. | M2 |
|
||||
| H3 | O(rays x walls) vision | Decision: radius-bbox cull now, uniform spatial grid over walls when bench shows need; 5k-wall bench gate | M2 |
|
||||
| H4 | `cellsTouched` ~12x polygon | Decision: scanline rasterization, differential test vs ported version | M2 |
|
||||
| H5 | Shared-endpoint test gap | Decision: port with a test that fails if either arm is removed; new mutation (d) | M1 |
|
||||
| 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: accept for v1 + authoring rule; Open Q4 for mitigations | M3 (documented), later |
|
||||
| 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; Open Q10 (expiry), Q11 (hash vs plaintext) | M3 |
|
||||
| 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 |
|
||||
| H10 | Move collision: centre path + dest circle, not swept circle | Decision: add swept-circle check; add step cap (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: integer quantization + only-on-change now; delta/binary deferred; Open Q16 | M3 |
|
||||
| H12 | Full vision polygon (~3 KB) per player move | Decision [FIXED, Q16]: full polygon, integer px, only on change; delta/binary post-v1 | M3 |
|
||||
| H13 | Explored sent whole + one SQLite row per cell | Decision: chunked bitmaps in DB; RLE on connect | M3 |
|
||||
| H14 | No SIGTERM handler | Decision: add; durability independent of it | M5 |
|
||||
| H15 | `synchronous=NORMAL` vs FULL | Decision proposed: NORMAL (+ optional FULL around authoring); confirm Q12 | M3 |
|
||||
| H15 | `synchronous=NORMAL` vs FULL | Decision [FIXED, Q12]: NORMAL; FULL around GM authoring transactions | M3 |
|
||||
| H16 | Timing instrumentation unbounded and under lock | Decision: do not port; ring buffer/histogram, snapshot outside lock | M5 |
|
||||
| H17 | 583 ms spike unexplained | Open: not reproduced; production SLOW logging to catch recurrence | M5/M7 |
|
||||
| H18 | mummy: unbounded send queue, no backpressure | Open Q13; v1 mitigations: connection cap, ping timeout, size limits | M5 |
|
||||
| H19 | `WebSocket` keyed by raw bytes | Decision: documented wrapper + test | M3 |
|
||||
| H20 | Fog masks Graphics grow unbounded | Decision: fixed-size baked fog texture (7.3) | M4 |
|
||||
| H21 | Pixi `Text` per token heavy | Decision: BitmapText (Q17 glyph coverage) | M4 |
|
||||
| H21 | Pixi `Text` per token heavy | Decision: BitmapText; glyph set Latin incl. accents + Nerd Font icons (Q17 FIXED) | M4 |
|
||||
| H22 | Browser rendering never verified | Decision: headless browser e2e | M4 |
|
||||
| H23 | Tiles don't update on door change | Decision: by design (static art); doors never part of art | -- |
|
||||
| H24 | Prototype `gmOnly` unused (my finding, not in HANDOFF) | Decision: enforce + fault class | M3 |
|
||||
@@ -517,51 +519,53 @@ Each is small, ends with a green gate, and no milestone depends on browser UI be
|
||||
- Scope: new repo layout (`server/`, `tools/`, `tests/`), devbox config, `geometry.nim` + `tgeometry.nim`, mutation script, add mutation (d) and the shared-endpoint arm test.
|
||||
- Accept: `nimble test` green: 33 test blocks / 98 checks ported, none dropped (plus new tests on top); mutations a-d each fail >= 1 test, control passes; repo builds with devbox only.
|
||||
- **M2 - Vision engine v2.**
|
||||
- Scope: scanline `cellsTouched`, differential + independent explored oracle tests, spatial grid for walls, swept-circle move check, step cap, bench harness incl. 5k-wall scene.
|
||||
- Token-on-wall escape [PROPOSED fix for 5.4 / H2]: in `moveBlocked`, ignore the t=0 hit of a wall the token stands on when the segment does not cross that wall at t>eps and the destination is >= r from it. Moves through the wall stay blocked; moves along it stay blocked (collinear overlap is not an escape). Replace the KNOWN LIMITATION test with positive assertions.
|
||||
- Accept: results equal old implementation on the corpus; polygon+cells bench <= prototype (0.451 ms) on the prototype scene and polygon < 1 ms on the 5k-wall scene [targets PROPOSED]; probing test passes; token-on-wall escape positive tests pass.
|
||||
- Scope: scanline `cellsTouched`, differential + independent explored oracle tests, spatial grid for walls, swept-circle move check, step cap (= token vision radius, Q18), bench harness incl. 5k-wall scene, `blocked` token status (Q14) and its tests.
|
||||
- Token-on-wall escape [requirement FIXED by Q14; mechanism PROPOSED, 5.4 / H2]: in `moveBlocked`, ignore the t=0 hit of a wall the token stands on when the segment does not cross that wall at t>eps and the destination is >= r from it. Moves through the wall stay blocked; moves along it stay blocked (collinear overlap is not an escape). Replace the KNOWN LIMITATION test with positive assertions. Replace the Q14 pin test ("door closed on a token") with tests of the `blocked` policy.
|
||||
- Accept: results equal old implementation on the corpus; polygon+cells bench <= prototype (0.451 ms) on the prototype scene and polygon < 1 ms on the 5k-wall scene [targets PROPOSED]; probing test passes; token-on-wall escape positive tests pass; `blocked`-status tests pass (player move refused, GM move allowed, status cleared on wall removal / door open / GM clear).
|
||||
- **M3 - Server core.**
|
||||
- Scope: entities with bucketed props, 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, SQLite schema + migrations.
|
||||
- Scope: entities with bucketed props, 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.
|
||||
- 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.
|
||||
- **M4 - Client v1.**
|
||||
- Scope: new `client/` dir (first real client build): Vite + TS + Pixi v8 client: layers, tiles, grid, tokens (BitmapText), fog textures, wall/door editor, token drag with prediction/rollback, DOM overlay, reconnect backoff, reducer tests.
|
||||
- Accept: headless e2e: fog pixel checks, player traffic audit clean, reconnect restores; manual run on laptop and Note 10 at 60 fps with 50 tokens, 16384 px map (tiled), fog active.
|
||||
- Scope: new `client/` dir (first real client build): Vite + TS + Pixi v8 client: layers, tiles, grid, tokens (BitmapText), fog textures, wall/door editor, token drag with prediction/rollback, DOM overlay, reconnect backoff, reducer tests; after the client port, archive `prototype-*` dirs (Q24).
|
||||
- Accept: headless e2e: fog pixel checks, player traffic audit clean, reconnect restores; manual run on laptop and Note 10 at 60 fps with 50 tokens, 16384 px map (tiled; PROPOSED test target, Q2), fog active.
|
||||
- **M5 - Robustness and observability.**
|
||||
- Scope: SIGTERM handler, bounded metrics + SLOW lines, connection cap, frame/rate limits, slow-client handling per Q13, healthz.
|
||||
- Accept: concurrency 60 s x3 pass with p99 <= prototype (4.98 ms) +50%; slow-client test bounded; stats computation shown outside the lock (lock hold time unchanged with metrics on, measured).
|
||||
- **M6 - NixOS deployment.**
|
||||
- Scope: `nix/` dir (Nix packaging of the Nim server and client build; method per Q20), NixOS module, nginx vhost, systemd hardening, backups timer, import CLI for maps.
|
||||
- Scope: `nix/` dir (Nix packaging of the Nim server and client build; method per Q20), NixOS module, nginx vhost, systemd hardening, backups timer (Q21), restore drill, import CLI for maps.
|
||||
- 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.
|
||||
- **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.
|
||||
- **Post-v1 candidates**: FFF seam implementation (section 9), drawings/pings/ruler, chat/dice, light sources, upload UI, multi-scene polish, vision deltas/binary protocol.
|
||||
- **Post-v1 candidates**: FFF seam implementation (section 9), drawings/pings/ruler, chat/dice (order decided at M7, Q8), light sources, browser upload UI (Q5), multi-scene (Q3), vision deltas/binary protocol (Q16).
|
||||
|
||||
---
|
||||
|
||||
## 14. Open questions for the owner
|
||||
|
||||
1. Q1 - Table size and device mix: how many players max, and which devices (phones, tablets, iOS)? Drives iOS testing priority and token/message budgets.
|
||||
2. Q2 - Largest map you plan to use (px), and typical wall count per scene? Drives tile size, spatial grid priority and explored chunking.
|
||||
3. Q3 - Multiple scenes in v1 (GM switches the active scene, per-scene explored grids), or exactly one scene per table to start?
|
||||
4. Q4 - Tile-edge leak: accept as documented, or reduce it (smaller tiles = more requests; gate tiles only when explored cells cover a minimum fraction; or server-side masked tiles at the cost of image processing in Nim)? What detail do you paint in map art that must stay secret?
|
||||
5. Q5 - Map import: CLI-only for v1, or upload + tiling from the browser (GM) from the start?
|
||||
6. Q6 - Wall/door authoring: is an in-browser GM wall editor required in v1 (no generator feeds in), or is hand-edited/imported wall data acceptable at first? What other wall kinds are needed soon (windows, one-way, secret doors, locked doors)?
|
||||
7. Q7 - Vision model: single radius per token or per-token property from day one? Is any "darkvision/light" concept needed before FFF?
|
||||
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?
|
||||
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?
|
||||
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?
|
||||
11. Q11 - Invite secrets: stored hashed (shown once, GM regenerates to re-share) or stored plaintext so the GM can re-copy a link?
|
||||
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?
|
||||
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?
|
||||
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?
|
||||
15. Q15 - Reconnect: is a full resync on every reconnect fine up to what explored/state size, or do you want `resume since N` later?
|
||||
16. Q16 - Vision payload: OK with full polygon per move (~3.4-3.7 KB per mover delivery, measured on loopback) for v1, or do you want deltas/binary earlier (e.g. for mobile data plans)?
|
||||
17. Q17 - Names/labels: which character sets must labels support (Latin only, accents, non-Latin, emoji)? Affects BitmapText glyph atlas vs Text/HTMLText.
|
||||
18. Q18 - Grid and movement: snap to grid on drop? Any server-side speed/distance limit per move, given there are no rules yet?
|
||||
19. Q19 - FFF engine: implementation language/runtime, current maturity, and whether it should run inside the VTT server process, as a sidecar, or in the browser for display only? Does it need hidden/secret state beyond the three property buckets (public / owner / GM)?
|
||||
20. Q20 - Nix packaging: how do you want the Nim server built (nimble lock + `buildNimPackage` or a vendored deps approach), and which repo hosts the NixOS module (this repo or your nixos-configuration repo)?
|
||||
21. Q21 - Backups: where should off-box backups go (existing mechanism on the server?), and how many dated copies to keep?
|
||||
22. Q22 - Observability: journald lines only, or also an internal metrics endpoint scraped by something you run?
|
||||
23. Q23 - Public exposure: reachable from the internet (domain, rate-limiting, fail2ban expectations) or LAN/VPN only?
|
||||
24. Q24 - Repo conventions: should this design live in `docs/DESIGN.md` plus ADRs under `docs/adr/` and a `GLOSSARY.md` (AGENTS.md references both, neither exists yet)? Should prototypes remain in-tree or move to an archive branch once ported?
|
||||
1. Q1 - Table size and device mix: how many players max, and which devices (phones, tablets, iOS)? Drives iOS testing priority and token/message budgets. **RESOLVED [FIXED (owner decision), 2026-11-08]:** devices are phones, tablets and laptops. Max players not answered: target <= 6 and connection cap 8 stay [PROPOSED] assumptions (sections 1, 4.3).
|
||||
2. Q2 - Largest map you plan to use (px), and typical wall count per scene? Drives tile size, spatial grid priority and explored chunking. **DEFERRED [FIXED (owner decision), 2026-11-08]:** owner does not know yet. 16384 px map and 5k walls stay [PROPOSED] test targets; revisit with real maps.
|
||||
3. Q3 - Multiple scenes in v1 (GM switches the active scene, per-scene explored grids), or exactly one scene per table to start? **RESOLVED [FIXED (owner decision), 2026-11-08]:** exactly one scene in v1; schema may stay `scene_id`-keyed.
|
||||
4. Q4 - Tile-edge leak: accept as documented, or reduce it (smaller tiles = more requests; gate tiles only when explored cells cover a minimum fraction; or server-side masked tiles at the cost of image processing in Nim)? What detail do you paint in map art that must stay secret? **OPEN (owner, 2026-11-08):** still open. Prototyping server-masked tiles vs cell-size tiles in `prototype-tile-leak/`.
|
||||
5. Q5 - Map import: CLI-only for v1, or upload + tiling from the browser (GM) from the start? **RESOLVED [FIXED (owner decision), 2026-11-08]:** map import is CLI-only in v1; browser upload is post-v1.
|
||||
6. Q6 - Wall/door authoring: is an in-browser GM wall editor required in v1 (no generator feeds in), or is hand-edited/imported wall data acceptable at first? What other wall kinds are needed soon (windows, one-way, secret doors, locked doors)? **RESOLVED [FIXED (owner decision), 2026-11-08]:** in-browser GM wall editor in v1; wall kinds `wall` and `door` only.
|
||||
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.
|
||||
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? **OPEN (owner, 2026-11-08):** still open. Research pending on mummy capabilities; owner leans to queued channels (MQTT-like) for slow clients.
|
||||
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.
|
||||
15. Q15 - Reconnect: is a full resync on every reconnect fine up to what explored/state size, or do you want `resume since N` later? **RESOLVED [FIXED (owner decision), 2026-11-08]:** full resync on every reconnect; revisit if a measured snapshot exceeds ~100 KB.
|
||||
16. Q16 - Vision payload: OK with full polygon per move (~3.4-3.7 KB per mover delivery, measured on loopback) for v1, or do you want deltas/binary earlier (e.g. for mobile data plans)? **RESOLVED [FIXED (owner decision), 2026-11-08]:** full vision polygon, integer px, sent only on change; deltas post-v1.
|
||||
17. Q17 - Names/labels: which character sets must labels support (Latin only, accents, non-Latin, emoji)? Affects BitmapText glyph atlas vs Text/HTMLText. **RESOLVED [FIXED (owner decision), 2026-11-08]:** labels in Latin incl. accented characters plus Nerd Font icon glyphs.
|
||||
18. Q18 - Grid and movement: snap to grid on drop? Any server-side speed/distance limit per move, given there are no rules yet? **RESOLVED [FIXED (owner decision), 2026-11-08]:** grid snap off by default (client option); server step cap = token vision radius.
|
||||
19. Q19 - FFF engine: implementation language/runtime, current maturity, and whether it should run inside the VTT server process, as a sidecar, or in the browser for display only? Does it need hidden/secret state beyond the three property buckets (public / owner / GM)? **PARTLY RESOLVED [FIXED (owner decision), 2026-11-08]:** no hidden state beyond the `public`/`owner`/`gm` buckets and `gm_only` flag in v1; revisit when FFF starts (schema change accepted then). Engine language, runtime and location: not answered, still open.
|
||||
20. Q20 - Nix packaging: how do you want the Nim server built (nimble lock + `buildNimPackage` or a vendored deps approach), and which repo hosts the NixOS module (this repo or your nixos-configuration repo)? **OPEN (owner, 2026-11-08):** still open. Research pending (buildNimPackage + pinned mummy).
|
||||
21. Q21 - Backups: where should off-box backups go (existing mechanism on the server?), and how many dated copies to keep? **RESOLVED [FIXED (owner decision), 2026-11-08]:** v1 backups go to a backup folder the server creates under its data root; off-box backups out of v1 scope.
|
||||
22. Q22 - Observability: journald lines only, or also an internal metrics endpoint scraped by something you run? **RESOLVED [FIXED (owner decision), 2026-11-08]:** journald lines only; `/healthz` stays.
|
||||
23. Q23 - Public exposure: reachable from the internet (domain, rate-limiting, fail2ban expectations) or LAN/VPN only? **RESOLVED [FIXED (owner decision), 2026-11-08]:** network exposure and access are out of project scope (owner handles reachability). Built-in protections stay (127.0.0.1 bind, connection cap, frame/rate limits, Origin check); internet-only hardening (fail2ban etc.) not in scope.
|
||||
24. Q24 - Repo conventions: should this design live in `docs/DESIGN.md` plus ADRs under `docs/adr/` and a `GLOSSARY.md` (AGENTS.md references both, neither exists yet)? Should prototypes remain in-tree or move to an archive branch once ported? **RESOLVED [FIXED (owner decision), 2026-11-08]:** `GLOSSARY.md` and `docs/adr/` per AGENTS.md; prototypes stay in-tree until the M4 client port, then archived.
|
||||
|
||||
Owner also decided 2026-11-08 [FIXED (owner decision)]: restore drill belongs in M6 (sections 11.2, 13).
|
||||
|
||||
Reference in New Issue
Block a user