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:
2026-11-21 15:43:08 +01:00
parent fd711de152
commit fcd90529b6
142 changed files with 1111 additions and 242 deletions
+29 -10
View File
@@ -18,10 +18,10 @@ independent of the code under test where possible, and every check needs a negat
it can fail.
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 tables and the 2026-11-08 phone run)
- `docs/archive/prototypes/tile-leak/` (tile size vs leak; README tables and the 2026-11-08 phone run)
How to run: `devbox run test` = Nim in-process tests first, then the Node black-box harnesses;
`devbox run mutation` = the mutation suite. Run everything from the repo root through `devbox run`.
@@ -46,11 +46,11 @@ built against glibc 2.44 while this host (NixOS) runs 2.42, so a 2.44-built `lib
**Rule:** DESIGN §3.3.
- Direct hits on `/_tiles/` give 404 [MEASURED: `prototype-server-vision/results/smoke.log`, README
- Direct hits on `/_tiles/` give 404 [MEASURED: `docs/archive/prototypes/server-vision/results/smoke.log`, README
"Phase 2a"].
- 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`].
- The residual 32 px edge leak's sizing evidence: `prototype-tile-leak/README.md` (desktop numbers;
- The residual 32 px edge leak's sizing evidence: `docs/archive/prototypes/tile-leak/README.md` (desktop numbers;
phone run 2026-11-08). M4's tile-size gates are in §13 below.
- `Cache-Control: private` is set by the Nim gate and rides through nginx's internal redirect
unchanged; nginx adds nothing of its own there (the test vhost records this, §11.1).
@@ -552,7 +552,7 @@ from the prototype, what was missing, what the M3 build added, and the tools it
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.
- **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,
already drives devbox chromium, `docs/archive/prototypes/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. The harness is `client/e2e/` (the client package
@@ -571,13 +571,20 @@ from the prototype, what was missing, what the M3 build added, and the tools it
real Vite build (`client/e2e/run.sh` runs `npm run build` first):
`performance.getEntriesByType('navigation')[0].nextHopProtocol` is `h2` over TLS. The vhost group
keeps a local stub dist because `devbox run test` must not depend on the client's npm install.
- **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.
- **Independent traffic audit in e2e**: `client/e2e/audit.test.mjs` records every WS frame and every
HTTP response the *player browser* receives and judges them with its own catalogue and banned-key
list (never importing `tools/leakcheck.nim`): only the 13 player frame types; no wall geometry or
GM-only column at any depth; vision polygons only for the player's own tokens; no other player's
id or out-of-sight token id; explored cells only inside a historical own-vision bbox and never near
the other player; tiles only on `/tiles/`, only 200/403, every 200 covering an explored cell, and
`/_tiles/` unreachable (direct fetch 404). It runs in `devbox run e2e` beside the fog, drag and
reconnect files. A negative control runs the same rules against a `-d:leakfault` build with
`LEAK_FAULT=otherVision`, so the rule that rejects a foreign vision polygon is proven able to fail.
### 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`,
`docs/archive/prototypes/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. The harness lives in
@@ -594,7 +601,8 @@ from the prototype, what was missing, what the M3 build added, and the tools it
keeps holding.
- `devbox run test` = Nim tests first, then Node harnesses. `devbox run client-test` = the client's
Vitest seam (pure reducer, protocol client, envelope); `devbox run e2e` = the built client through
the real server and vhost. The finish gate runs all three.
the real server and vhost; `devbox run fogbench` = the 50-token 16384 px server measurement
(`results/m4-fog-bench.log`). The finish gate (#76) runs all of them plus `mutation` and `bench`.
- The nine M3 accept groups and their proving harness tests are mapped in `tools/groups.mjs`;
`tools/groups.test.mjs` fails if a group file or its named evidence test disappears, so the
acceptance checklist cannot silently go stale. Harnesses that are not an accept group (`smoke`,
@@ -657,6 +665,17 @@ from the prototype, what was missing, what the M3 build added, and the tools it
registered test ran and passed. The restart group takes its baseline from the as-built state on the
first server instance, before any restart, not from a state that has already been through one
(#36).
- **M4 accept result.** Measured 2026-11-21 at the finish commit (#76): `devbox run test` exit 0
(Nim suite all pass, 419 OK checks; 159 Node harness tests with the group evidence step),
`devbox run client-test` 164, `devbox run e2e` 27/27 (join, fog pixel probes, drag + rollback,
reconnect, the independent traffic audit and the 50-token measurement), `devbox run mutation`
control + 80 mutations each failing at least its expected test, `devbox run bench` PASS and
`devbox run fogbench` PASS. Evidence: `results/nimble-test.log`, `results/mutation.log`,
`results/bench.log`, `results/m4-fog-bench.md` (+ `.log`); the e2e/client logs are regenerated
per run and not committed. The manual Note 10 + laptop 60 fps run is **#77** and is the only
open M4 accept item. Mutation housekeeping found here: `c1`/`c2` still patched the pre-#65
tile-gate expression and had silently become `sed` no-ops; both now patch
`cy * sc.cols + cx in explored` and fail the tile gate group again.
- **M4 gate harness.** (a) automated headless-Chromium test with mobile emulation (viewport, dpr, CPU
and network throttle) against the real server path (nginx HTTP/2 + caching); (b) one manual run on
the owner's 5-year-old Android phone. The 2026-11-08 prototype phone run is evidence, not the gate