feat: client shell, sign-in and protocol client (#67)

New `client/` package (Vite + TypeScript + PixiJS v8, plain DOM overlay):
the pure reducer seam (no Pixi import), an append-only slice registry
build-time glob, the `proto` 2 WS client with envelope/ack/closing mapping,
the sign-in door (`POST /join`, one "Key not recognised." for wrong and
unknown), the DOM shell/HUD and a minimal Pixi stage created only after a
live `hello`. `hello` resets every slice so a reconnect cannot show stale
state; `proto-mismatch` shows reload; `revoked` returns to the sign-in page
and stops.

The browser e2e moves into the client package (`client/e2e/`, owning
playwright-core) and runs the real Vite build through the TLS/HTTP2 test
nginx: join -> canvas -> hello/roster for GM and player, no data before
join, identical wrong/unknown key refusal, proto mismatch, revoked.
`devbox run client-test` adds the Vitest seam; `devbox run e2e` builds the
client first. The #66 stub dist stays local to `tools/vhost.test.mjs`, so
`devbox run test` still needs no npm install.

Refs #67
This commit is contained in:
2026-11-20 23:57:16 +01:00
parent 97f618c5ad
commit 3c0258ea31
37 changed files with 3439 additions and 178 deletions
+21 -11
View File
@@ -344,7 +344,7 @@ from the prototype, what was missing, what the M3 build added, and the tools it
| Negative control / fault injection | `tools/faulttest.sh`, `-d:leakfault` build | 8 faults, exact failure-class set each, clean build passes, `LEAK_FAULT` string asserted absent from clean binary [MEASURED 8/8]. Port and extend. |
| Restart | `tools/restart.mjs` | SIGTERM + SIGKILL, identical player keys/positions/doors/vision/explored/hello+state. |
| Concurrency | `tools/concurrency.mjs` | 60 s, 3 clients, gseq monotonic, every intent acked, quiesced views == fresh connection. **M5 port [FIXED, #15]:** 6 walkers on one GM socket (~200/s) exceeds the 30/s per-connection rate (DESIGN §6.4); spread walkers across connections (4 per player, 16 total; DESIGN §4.3). |
| Client reducer tests | `client/src/state.test.ts` | Incl. reconnect reset. |
| Client reducer tests | `client/test/*.test.ts` (Vitest) | Pure frame/ack -> state; `hello` resets every slice. No Pixi or DOM import at the seam. |
| Smoke | `tools/smoke.mjs` | auth/cookie/tile/steal/garbage. |
| Isolation harness | `tools/withserver.sh` | own DB/ports (`run/test/`), never touch a live session. |
@@ -555,16 +555,22 @@ from the prototype, what was missing, what the M3 build added, and the tools it
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. The harness is `e2e/` and the gate is
`devbox run e2e`, separate from `devbox run test` (§11.1).
restores view; drag moves token and rollback works. The harness is `client/e2e/` (the client package
owns `playwright-core`, outside `tools/`; TESTING 10.4 keeps the black-box harnesses npm-free) and the
gate is `devbox run e2e`, which builds the real client and is separate from `devbox run test` (§11.1).
T4's slice of it (`client/e2e/shell.test.mjs`, `mismatch.test.mjs`): no session shows only the
sign-in door and no canvas; a wrong and an unknown key give the same `401` and the same
"Key not recognised." text; GM and player join, get the canvas and the `hello`/`roster` HUD; a
server `closing{proto-mismatch}` shows reload and stops; a revoked key returns the page to sign-in
with no reconnection.
- **TLS/HTTP2 vhost (#66)**: `tools/vhost.test.mjs` (built-ins, `node:http2`) is the independent
client for the vhost itself: the generated certificate is self-signed and names loopback, ALPN
selects `h2`, `/` serves the client `dist` with index `no-cache`, `/assets/` with a year-immutable
cache and no SPA fallback for a missing hash, a client route falls back to `index.html`, and direct
`/_tiles/` is still 404. `e2e/h2.test.mjs` proves the same from real Chromium: it loads the dist and
`performance.getEntriesByType('navigation')[0].nextHopProtocol` is `h2` over TLS. Before the client
exists the served `dist` is the throwaway fixture of `tools/distfixture.mjs`; T4 replaces it with
the real Vite build and extends the same gate.
`/_tiles/` is still 404. `client/e2e/h2.test.mjs` proves the same from real Chromium against the
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.
@@ -583,15 +589,19 @@ from the prototype, what was missing, what the M3 build added, and the tools it
`tools/wsheaders.test.mjs` so a Node upgrade that drops the option fails loudly.
- Root `devbox.json` pins `nodejs` 26 and the `nginx` used only by the test harness (DESIGN §11.1); no
global tooling. M4 (#66) adds `chromium` (the browser e2e) and `openssl` (generating the test
certificate); the e2e's only npm dependency, `playwright-core`, is pinned by `e2e/package-lock.json`
and lives outside `tools/`, so this built-ins-only rule keeps holding.
- `devbox run test` = Nim tests first, then Node harnesses.
certificate); the e2e's only npm dependency, `playwright-core`, is pinned by
`client/package-lock.json` and lives with the client, outside `tools/`, so this built-ins-only rule
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 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`,
`walls`, `tokens`, `details`, `scene`, `wsheaders`) run in the same pass.
- In-process tests stay Nim (`nimble test`, unchanged).
- Browser e2e details: M4, not decided here.
- Browser e2e details and the client-side extension rules (append-only reducer slices and render
modules): `client/README.md`.
---