test(m4): finish audit, measurement and archive (#76)
- client/e2e/audit.test.mjs: independent player-browser traffic audit (own frame catalogue and banned-key list, never leakcheck.nim), with a -d:leakfault/otherVision negative control. - client/e2e/fogbench.test.mjs + tools/fogbench.nim: 50 tokens on a 16384 px map (server move path and headless SwiftShader cadence); results/m4-fog-bench.md records both honestly (SW is not the phone gate). - Archive prototype-* under docs/archive/prototypes (Q24); DESIGN 13 M4 done, TESTING 13 M4 accept result, HANDOFF-M4 close-out. - mutation.sh c1/c2 patch the post-#65 tile-gate line again (they had silently become sed no-ops).
This commit is contained in:
+31
-24
@@ -19,15 +19,16 @@ Legend:
|
||||
- **[PROPOSED]** design choice made in this doc; the owner may overturn it.
|
||||
|
||||
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/`,
|
||||
- `docs/archive/prototypes/pixi-perf/` (client perf; README holds all tables)
|
||||
- `docs/archive/prototypes/server-vision/` (server + vision; `README.md`, `HANDOFF.md`, `NOTES.md`, `results/`,
|
||||
`results/spike/investigation.md`)
|
||||
- `prototype-tile-leak/` (tile size vs leak; `README.md` holds desktop tables and the 2026-11-08
|
||||
- `docs/archive/prototypes/tile-leak/` (tile size vs leak; `README.md` holds desktop tables and the 2026-11-08
|
||||
phone run; `results/phone-20261108T113701.jsonl`)
|
||||
- `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/` exist per AGENTS.md (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.
|
||||
FIXED). `prototype-*` trees are archived at `docs/archive/prototypes/` from the M4 finish (#76;
|
||||
Q24, FIXED): frozen history, never built or maintained, with the maintained code in `/server` and
|
||||
`/client`. Nothing here is FFF-specific beyond the seam in section 9.
|
||||
|
||||
---
|
||||
|
||||
@@ -107,7 +108,7 @@ entitled to.
|
||||
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
|
||||
0.4.6-0.4.8 exist]. `docs/archive/prototypes/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.
|
||||
@@ -157,7 +158,7 @@ entitled to.
|
||||
- **Single egress rule [PROPOSED]:** all bytes to a player leave through one egress module that
|
||||
takes a recipient and a typed per-recipient view. Raw world state (walls, hidden entities, other
|
||||
players' explored grids) has no code path into that module. The prototype enforces this by
|
||||
discipline in `sync()` (`prototype-server-vision/src/server.nim`); the real build should enforce
|
||||
discipline in `sync()` (`docs/archive/prototypes/server-vision/src/server.nim`); the real build should enforce
|
||||
it by types (distinct `PlayerView` and `GmView` structures, no `JsonNode` of world state passed
|
||||
around).
|
||||
- Client-side fog is cosmetic. Security never depends on the client hiding anything (section 7).
|
||||
@@ -420,7 +421,7 @@ 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].
|
||||
reading, `docs/archive/prototypes/server-vision/README.md` "mummy suitability", mummy.nim ~L262-311].
|
||||
- **One global lock** around intent handling and outbox enqueue; network sends happen outside it
|
||||
(flush, see 4.2). [MEASURED] order, loss and final-view consistency over 3 x 60 s runs, and the
|
||||
latency figures: TESTING §4.3.
|
||||
@@ -691,7 +692,7 @@ explored_chunk(player_id, scene_id, cx, cy, bits BLOB, PRIMARY KEY(player_id, sc
|
||||
|
||||
## 5. Vision and explored
|
||||
|
||||
### 5.1 Algorithm (ported from `prototype-server-vision/src/geometry.nim`)
|
||||
### 5.1 Algorithm (ported from `docs/archive/prototypes/server-vision/src/geometry.nim`)
|
||||
- **Visibility polygon** from token centre: cast rays to every blocking wall endpoint (for a thick
|
||||
wall, every corner of its body quad, 5.10) at angle -eps, 0, +eps (`RayEps` = 1e-4 rad), plus an
|
||||
inscribed 64-gon of radius R as range limit; sort by angle; each ray returns nearest hit among
|
||||
@@ -1900,7 +1901,7 @@ they are not fed until resync, and nginx closes dead peers (M5).
|
||||
### 7.1 Layers (bottom to top, one Pixi stage under a world container with pan/zoom)
|
||||
1. **Map tiles**: sprites per tile, loaded lazily for tiles the server allows.
|
||||
2. **Grid**: one `TilingSprite` over a small cell texture, toggleable [MEASURED technique,
|
||||
`prototype-pixi-perf/README.md` Techniques].
|
||||
`docs/archive/prototypes/pixi-perf/README.md` Techniques].
|
||||
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
|
||||
@@ -1911,7 +1912,7 @@ they are not fed until resync, and nginx closes dead peers (M5).
|
||||
The module layout and the append-only extension rules (one reducer slice file, one render module
|
||||
file per feature; no shared registry edit) are written in `client/README.md` [T4, #67].
|
||||
|
||||
### 7.2 Rendering techniques kept from the perf prototype [MEASURED, `prototype-pixi-perf/README.md`]
|
||||
### 7.2 Rendering techniques kept from the perf prototype [MEASURED, `docs/archive/prototypes/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.
|
||||
@@ -2144,7 +2145,7 @@ copy/export stable).
|
||||
- **Connection (runtime)**: id, player, `known` map, last vision ver, counter.
|
||||
|
||||
Prototype entity (for mapping): `Tok{id,name,kind,pos,gmOnly}` + `tokenRadius` global in scene
|
||||
(`prototype-server-vision/data/scene.json`: 4096 px world, 256 px tiles, radius 400, token radius
|
||||
(`docs/archive/prototypes/server-vision/data/scene.json`: 4096 px world, 256 px tiles, radius 400, token radius
|
||||
20, cell 32, 60 walls, 8 tokens).
|
||||
|
||||
---
|
||||
@@ -2256,7 +2257,7 @@ See TESTING §10.4 (Node 26 black-box harnesses, built-ins only, `devbox run tes
|
||||
- Response headers: HSTS, CSP (no inline scripts, `connect-src 'self'` wss),
|
||||
`X-Content-Type-Options`, `Referrer-Policy`.
|
||||
- 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;
|
||||
- Prototype nginx config (`docs/archive/prototypes/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>/v<art_version>/` and registers/updates the scene (prototype:
|
||||
@@ -2327,18 +2328,24 @@ columns with today's defaults) lands complete now, so the later build needs no m
|
||||
green on a clean checkout with the nine groups: leak+fault, tiles, probing, protocol, auth,
|
||||
characters and names, restart, persistence, logs. Gate mechanics and the measured result: TESTING
|
||||
§13. Out of M3 accept: concurrency (M5), the 127.0.0.1 bind check (M6).
|
||||
- **M4 - Client v1.** Vite + TS + Pixi v8 client: layers, tiles, grid, tokens (BitmapText),
|
||||
character and encountered lists, reveal controls, fog textures, the wall editor (four presets,
|
||||
switches, marker, label, one-way arrow and flips), token drag with prediction/rollback, DOM
|
||||
overlay, reconnect backoff, reducer tests; then archive `prototype-*` (Q24). Thickness and height
|
||||
controls are not in M4 (build order above; 5.7, 5.10).
|
||||
- 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 on a 16384 px tiled map (test target
|
||||
PROPOSED, Q2), fog active.
|
||||
- **M4 - Client v1.** Done (2026-11-21, #76). Vite + TS + Pixi v8 client: layers, tiles, grid,
|
||||
tokens (BitmapText), character and encountered lists, reveal controls, fog textures, the wall
|
||||
editor (four presets, switches, marker, label, one-way arrow and flips), token drag with
|
||||
prediction/rollback, DOM overlay, reconnect backoff, reducer tests; `prototype-*` archived under
|
||||
`docs/archive/prototypes/` (Q24). Thickness and height controls are not in M4 (build order above;
|
||||
5.7, 5.10).
|
||||
- Accept: headless e2e (fog pixel checks, player traffic audit clean, reconnect restores) - met by
|
||||
`devbox run e2e` including `client/e2e/audit.test.mjs`; the manual run on laptop and Note 10 at
|
||||
60 fps with 50 tokens on a 16384 px tiled map (test target PROPOSED, Q2) with fog active is
|
||||
#77, the one `ready-for-human` step, and remains open by design.
|
||||
- Tile-size gates [FIXED, Q4]: (a) automated headless-Chromium test (mobile emulation, real server
|
||||
path): viewport fills in < 1 s at zoom 1; (b) one manual run on the owner's 5-year-old Android
|
||||
phone. If either fails: `tile_size` 64 px (per-scene config, no code change). Harness detail and
|
||||
the prototype-run caveat: TESTING §13.
|
||||
path): viewport fills in < 1 s at zoom 1 - met in `client/e2e/map.test.mjs`; (b) one manual run
|
||||
on the owner's 5-year-old Android phone - #77. If either fails: `tile_size` 64 px (per-scene
|
||||
config, no code change). Harness detail and the prototype-run caveat: TESTING §13.
|
||||
- Finish evidence (#76): `results/m4-fog-bench.md` (50 tokens / 16384 px: server move path
|
||||
0.119 ms; headless SwiftShader cadence recorded, explicitly not a phone number),
|
||||
`results/bench.log`, `results/mutation.log`, `results/nimble-test.log`, and the
|
||||
`devbox run test | client-test | e2e` logs (regenerated, not committed).
|
||||
- **M5 - Robustness and observability.** SIGTERM handler, bounded metrics and SLOW lines, per-client
|
||||
bounded outbox with coalescing and Ping/Pong lag tracking (4.3), verify `/ws` goes through nginx
|
||||
and which timeout closes a dead peer, healthz lock check. Accept: concurrency 60 s x3 with p99 <=
|
||||
|
||||
Reference in New Issue
Block a user