design: fix test tools (#9)

Node 26 black-box harnesses under tools/ (no Nim rewrite, no npm deps);
in-process tests stay Nim; devbox run test runs Nim then Node.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 19:35:54 +01:00
co-authored by Claude Haiku 5.5
parent 8c03224f2a
commit acc69c9fb6
+13 -3
View File
@@ -1,6 +1,6 @@
# FFF_vtt design
Status: draft v0.8, 2026-11-14 (owner decisions recorded in section 14; v0.4 records Q4 (tile_size 32 px), the outbox lock invariant (4.2, 4.3), and the follow-ups in 3.4, 8, 11.1, 12, 13; v0.5 records the M2 move-rule decisions in 5.5 and updates 3.4, 4.2, 5.1, 5.4, 6.1, 7.4, 8, 10.3, 12, 13; v0.6 records #14 (characters and player data) in 3.1, 3.4, 4.1, 4.4, 6.1, 8, 9, 10.3, 13, 14; v0.7 records #6 (players and invites) in 3.1, 3.2, 3.4, 4.4, 6.1, 8, 12, 13, 14; v0.8 records #7 (map tiles) in 3.3, 3.4, 11.1, 13, 14. All of Q1-Q24 are RESOLVED or DEFERRED; none OPEN). Audience: the owner and coding agents.
Status: draft v0.9, 2026-11-14 (owner decisions recorded in section 14; v0.4 records Q4 (tile_size 32 px), the outbox lock invariant (4.2, 4.3), and the follow-ups in 3.4, 8, 11.1, 12, 13; v0.5 records the M2 move-rule decisions in 5.5 and updates 3.4, 4.2, 5.1, 5.4, 6.1, 7.4, 8, 10.3, 12, 13; v0.6 records #14 (characters and player data) in 3.1, 3.4, 4.1, 4.4, 6.1, 8, 9, 10.3, 13, 14; v0.7 records #6 (players and invites) in 3.1, 3.2, 3.4, 4.4, 6.1, 8, 12, 13, 14; v0.8 records #7 (map tiles) in 3.3, 3.4, 11.1, 13, 14; v0.9 records #9 (test tools) in 2, 10.4, 13, 14. 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.
@@ -49,7 +49,7 @@ A browser virtual tabletop for one table (1 GM + up to 6 players [FIXED, Q1]), s
- 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.
- Dev env: NixOS, devbox per project for toolchains, nothing global.
- Dev env: NixOS, devbox per project for toolchains, nothing global. Node 26 (devbox) runs the black-box test harnesses only; in-process tests stay Nim [FIXED, owner decision 2026-11-14, #9] (10.4).
### Component diagram
```
@@ -522,6 +522,14 @@ Principles carried from the prototype: the checker must be independent of the co
- **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.
### 10.4 Test tools [FIXED, owner decision 2026-11-14, #9]
- Black-box (outside) WS/HTTP harnesses: Node 26 only, repo-root `tools/`, ported from `prototype-server-vision/tools/` (`smoke.mjs`, `leak.mjs`, `restart.mjs`, `concurrency.mjs`, `lib.mjs`, `withserver.sh` incl. the M3 test nginx). No Nim rewrite. Reason: Node is already required for the client (Vite/TS, playwright-core e2e, reducer tests); a harness in another language from the server cannot share its protocol bugs; zero deps; already measured. Fix the stale "Node 22" note in `lib.mjs` on port.
- Harness tooling: built-ins only, no npm deps. Global `WebSocket` with `{headers}` for Cookie/Origin; `node:net` for raw and malformed frames (oversize, bad opcode/rsv, unmasked, flood); `node:test` as runner. Node 26 header behaviour is not yet verified (#8 verified v24 only): the first harness re-verifies it.
- Root `devbox.json` pins `nodejs` 26 (port step).
- `devbox run test` = Nim tests first, then Node harnesses.
- In-process tests stay Nim (`nimble test`, unchanged).
- Browser e2e details: M4, not decided here.
---
## 11. Ops
@@ -604,7 +612,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, player keys/sessions, scenes, chunked explored persistence, typed per-recipient views and single egress, per-connection counters, proto versioning, wall/entity CRUD intents, Origin check, plaintext invite secrets and non-expiring sessions (Q10, Q11), SQLite schema + migrations. Tile gate `/tiles/` (3.3), fixture tiles at 32 px generated at test time by a helper (not committed), minimal local test nginx with internal `/_tiles/` (production vhost and tile import CLI stay M6) [FIXED, owner decision 2026-11-14, #7].
- Scope: entities with bucketed props, characters with names, name reveal and encountered list (8, #14), players, player keys/sessions, scenes, chunked explored persistence, typed per-recipient views and single egress, per-connection counters, proto versioning, wall/entity CRUD intents, Origin check, plaintext invite secrets and non-expiring sessions (Q10, Q11), SQLite schema + migrations. Tile gate `/tiles/` (3.3), fixture tiles at 32 px generated at test time by a helper (not committed), minimal local test nginx with internal `/_tiles/` (production vhost and tile import CLI stay M6) [FIXED, owner decision 2026-11-14, #7]. Black-box harnesses ported to `tools/` on Node 26; `devbox run test` runs Nim then Node (10.4) [FIXED, owner decision 2026-11-14, #9].
- 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). Tile gate: leak test (d) and smoke tile-steal checks pass through the test nginx; gate decisions match the independent explored oracle (10.2); direct `/_tiles/` fetch -> 404; malformed or out-of-range path -> 404; unexplored -> 403 [FIXED, owner decision 2026-11-14, #7].
- **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).
@@ -659,3 +667,5 @@ Owner also decided 2026-11-10 [FIXED (owner decision), #14]: characters are sepa
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.
Owner also decided 2026-11-14 [FIXED (owner decision), #7]: map tiles in M3. The tile gate (`/tiles/`, Nim, `X-Accel-Redirect`) and a minimal local test nginx with generated 32 px fixture tiles are M3 scope; tile import CLI and the production nginx vhost stay M6. Tile URLs carry `art_version` from M3 (always 1 in M3); responses are `Cache-Control: private`; malformed or out-of-range paths get 404, unexplored tiles 403. The gate reuses the server's explored-area logic, checked against the independent oracle (10.2). On-disk layout `<state>/tiles/<scene>/v<art_version>/` fixed in M3. See 3.3, 11.1, 13.
Owner also decided 2026-11-14 [FIXED (owner decision), #9]: test tools. Black-box WS/HTTP harnesses are Node 26 only (repo-root `tools/`, built-ins and `node:net` for raw frames, `node:test`, no npm deps), ported from the prototype; no Nim rewrite. In-process tests stay Nim. Root devbox pins nodejs 26; `devbox run test` runs Nim then Node. Browser e2e details stay open (M4). See 2, 10.4, 13.