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
+55
View File
@@ -0,0 +1,55 @@
# M4 fog measurement: 50 tokens on a 16384 px map (#76)
Recorded 2026-11-21 on the M4 finish tree. Command: `devbox run fogbench` (server half,
`tools/fogbench.nim`, raw log `results/m4-fog-bench.log`) and
`client/e2e/fogbench.test.mjs` (headless client half, `devbox run e2e`).
The question this answers (spec #63, Testing notes): **does M4 need the per-token polygon cache
(build item 3) or incremental wall-edit refresh (build item 4) before the phone run?** The answer is
no: the measured move path is two orders of magnitude inside one 60 fps frame.
## Server recompute (real modules, release build)
Scene: 16384 x 16384 px, cell 32 (512 x 512 cells = 262 144), 4 979 sparse walls
(`genScene(16384, 5000, 1)` with the 50-token cluster box cleared), 50 tokens, one controlled token
with `vision` and radius 300. This is what `main.refreshPlayer` runs for one `token.move`, plus the
egress that follows it for that player.
| Measurement | n | avg | worst |
|---|---:|---:|---:|
| vision refresh: polygon + `cellsTouched` + explored fold (1 token, 5k walls) | 500 | **0.044-0.054 ms** | 0.132 ms |
| player egress, 50 visible tokens (`token` frames, fresh `Known` = reconnect) | 300 | **0.075-0.089 ms** | 0.167 ms |
| player egress, warm `Known` (no changes) | 2000 | 0.084-0.094 ms | 0.261 ms |
| move path total (refresh + 50-token egress) | | **0.119-0.143 ms** | |
(Brackets are run-to-run spread across the finish runs; the raw last run is in
`results/m4-fog-bench.log`.)
Budget: one 60 fps frame is 16.7 ms. The move path uses ~1 % of it. Cached per-token polygons
would save ~0.05 ms while adding an invalidation surface; **not built** (ticket AC: no
polygon-cache work unless the measurement says so). `results/bench.log` holds the M1-M3 baselines
(polygon 0.041 ms sparse, 0.73 ms dense 5k) and the explored/tile-gate numbers.
## Headless client frame cadence (correctness floor only)
Scene: the real server on the prepared 16384 px scene (scene row patched before boot; only the M6
importer owns `w`/`h`), 50 tokens inside the sight, fog active, first viewport filled. Emulation:
412 x 869 CSS px, DPR 2.625, touch, mobile, then CDP 4x CPU throttle for the second sample.
| Measurement | value |
|---|---:|
| fog explored snapshot at connect (512 x 512 cells) | **2.0-2.2 ms** |
| explored cells in the sight | 540 |
| rAF cadence, real CPU (120 frames) | median **70-78 ms**, p95 81-166 ms |
| rAF cadence, 4x CPU (90 frames) | median **77-83 ms**, p95 83-167 ms |
**These are SwiftShader numbers, not phone numbers.** Headless Chromium in this repo renders with
the software rasteriser (no GPU), so its cadence is a floor for correctness and regression work. It
is deliberately **not a gate** (spec #63: no timing gate in the client suite). The 4096 px/50-token
run in `client/e2e/fog.test.mjs` records the same order (median 72-98 ms) and is also recorded only.
The real 60 fps pass on the Note 10 and the laptop is **#77** and is the authority for the M4 accept.
## What was not measured here
- The actual phone GPU, thermal throttling, LAN latency and real map art: #77.
- 2000-token or 500-wall-dense scenes: outside the M4 accept target (DESIGN §13, Q2).