docs: finish the DESIGN/TESTING split (§6-§13)
Protocol, client, ops and milestone sections keep their rules and gate criteria; message-size measurements, close-assertion detail, the test nginx, the restore drill, the slow-log provenance and the M3/M4 gate mechanics move to TESTING. DESIGN §10 becomes a pointer section that keeps 10.1-10.4 so existing refs resolve.
This commit is contained in:
+40
-248
@@ -113,7 +113,7 @@ entitled to.
|
||||
internal location for tile bytes.
|
||||
- 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). devbox also carries `sqlite` (output `out` + `bin`): `db_connector` dlopens
|
||||
(TESTING §10.4). devbox also carries `sqlite` (output `out` + `bin`): `db_connector` dlopens
|
||||
`libsqlite3.so`, so the devbox env sets `LD_LIBRARY_PATH=$DEVBOX_PACKAGES_DIR/lib`.
|
||||
|
||||
### Component diagram
|
||||
@@ -1723,8 +1723,8 @@ view), so deletion and moving away look identical to the player.
|
||||
recorded before the list is built, so a token that walked into an offline player's sight is in
|
||||
their `encountered` list on the next connect. An unnamed player gets only `hello` until
|
||||
`player.setname` succeeds, which triggers the same sequence on that connection. The client reducer
|
||||
resets everything on `hello` (reconnect-reset bug fixed in prototype, test in
|
||||
`client/src/state.test.ts`, 4/4 pass) [MEASURED]. Clients must tolerate any order after `hello`.
|
||||
resets everything on `hello` (the reconnect reset is proven by the client reducer tests, TESTING
|
||||
§6.3). Clients must tolerate any order after `hello`.
|
||||
- No gap detection and no `resume(since)`: WS over TCP is ordered and lossless while connected, and
|
||||
a reconnect restarts from a full snapshot. Full resync on every reconnect [FIXED, Q15]. Revisit if
|
||||
a measured snapshot exceeds ~100 KB.
|
||||
@@ -1737,14 +1737,10 @@ view), so deletion and moving away look identical to the player.
|
||||
|
||||
### 6.4 Deltas and size
|
||||
- Tokens: `token` only when the recipient's view of it changed; `token_gone` on leaving view;
|
||||
per-connection `known` table gives correct enter/leave [MEASURED, leak test (c)]. The stored diff
|
||||
base is the frame **before** the per-connection `n` is stamped: `protocol.withN` deep-copies, so
|
||||
stamping cannot make the next comparison see a different frame and re-send unchanged state (this
|
||||
was a live bug until slice 8; the leak checker now sees a genuinely sparse stream).
|
||||
- Bytes [MEASURED, `results/concurrency-final1-server.log`]: monster move 145 B to a seeing player,
|
||||
244 B to GM; player move: mover 3359-3653 B (worst 4.9 KB, dominated by the full `vision` polygon
|
||||
+ `explored` diff), GM 145 B; door toggle 45 B (prototype `door` message; the M3 `wall` upsert is
|
||||
a little larger).
|
||||
per-connection `known` table gives correct enter/leave. The stored diff base is the frame **before**
|
||||
the per-connection `n` is stamped: `protocol.withN` deep-copies, so stamping cannot make the next
|
||||
comparison see a different frame and re-send unchanged state. Proven by: TESTING §6.4.
|
||||
- Per-frame sizes are measured for each message type: TESTING §6.4.
|
||||
- v1 decisions [FIXED, Q16]: full vision polygon, integer px (halves the text size [INFERRED]),
|
||||
owner only, sent only on change; deltas/binary post-v1. Explored on connect as run-length rows,
|
||||
later diffs as cell lists [PROPOSED].
|
||||
@@ -1835,9 +1831,8 @@ outcome. Rows 1-4 refuse before the upgrade, so they are plain HTTP statuses wit
|
||||
(M5) is the same two-step shape with `reason:"server-shutdown"`, `code:1001`, and is not built yet.
|
||||
|
||||
Why not the alternatives: patching/forking mummy is fallback only (4.3), and a client-side heuristic
|
||||
on 1005 alone cannot tell eviction from revocation from a proto mismatch. Consequence for tests:
|
||||
every close assertion is "the last message is `closing` with this reason and code, then the close
|
||||
event reports 1005".
|
||||
on 1005 alone cannot tell eviction from revocation from a proto mismatch. What every close assertion
|
||||
checks: TESTING §6.5.
|
||||
|
||||
WS close reasons are the static strings in bold above. Close codes 4001-4003 are the app's range;
|
||||
1008 and 1001 are the RFC 6455 standard codes. Lagging clients (M5, 4.3) get no close and no frame:
|
||||
@@ -1854,9 +1849,8 @@ they are not fed until resync, and nginx closes dead peers (M5).
|
||||
(T6). Cookie name `fff_session` [FIXED (owner-delegated, 2026-11-14, #17)].
|
||||
- `GET /ws`: 6.5 (rows 1-4).
|
||||
- `GET /tiles/<scene>/v<art_version>/<x>_<y>.png`: 3.3 (`200` with `X-Accel-Redirect`, `403`
|
||||
unexplored, `404` malformed/out of range). Slice 9 (#24) pins the full status split in 3.3: `404`
|
||||
also for another scene or a stale art version, `403` also for a missing or unknown session (one
|
||||
response with "unexplored"), and `Cache-Control: private`.
|
||||
unexplored, `404` malformed/out of range, and the rest of the split stated there). Proven by:
|
||||
TESTING §3.3 (slice 9 / #24).
|
||||
- `GET /healthz`: 200 `{"status":"ok"}` [FIXED (owner-delegated, 2026-11-14, #16)]; M5 makes it
|
||||
report whether the global lock can be acquired within a bound (11.3).
|
||||
|
||||
@@ -1909,8 +1903,8 @@ Prototype `client/src/main.ts`: explored rects appended to a `Graphics` mask for
|
||||
- **Explored layer [PROPOSED]**: keep explored as a bitmap/RenderTexture at cell resolution
|
||||
(map/cell, e.g. 128x128 for 4096/32), updated by writing new cells; display scaled with smoothing.
|
||||
Memory fixed regardless of exploration; no unbounded Graphics. Exact Pixi mechanism (RenderTexture
|
||||
draw vs Uint8 texture resource) to be chosen in M4 with the pixijs skills; acceptance criterion is
|
||||
below.
|
||||
draw vs Uint8 texture resource) to be chosen in M4 with the pixijs skills; the acceptance criterion
|
||||
is the pixel check in TESTING §7.3.
|
||||
- **Vision layer [PROPOSED]**: polygons (few, ~64-300 vertices each) drawn into a mask only when a
|
||||
`vision` message arrives; cut-out through a mask/erase blend.
|
||||
- Soft edges: optional blur filter on the fog texture at cell scale; measure on Note 10 before
|
||||
@@ -1918,8 +1912,6 @@ Prototype `client/src/main.ts`: explored rects appended to a `Graphics` mask for
|
||||
- GM view: fog disabled by default; optional "preview as player X" is a GM-side toggle that must not
|
||||
require extra data (GM client would need the player's polygons: it can request them as GM-only
|
||||
message `view.player` computed server-side) [PROPOSED, later].
|
||||
- Browser rendering of fog/drag/reconnect is unverified in prototype (no browser in build env). M4
|
||||
adds a headless-browser pixel check.
|
||||
|
||||
### 7.4 Input and UI
|
||||
- Mouse: wheel zoom, drag pan, drag token. Touch: one finger drag/pan, two-finger pinch/pan
|
||||
@@ -2144,216 +2136,25 @@ recipient-aware view, and entities already carry bucketed properties. FFF later
|
||||
|
||||
## 10. Testing strategy
|
||||
|
||||
Principles carried from the prototype: the checker must be independent of the code under test where
|
||||
possible, and every check needs a negative control that proves it can fail.
|
||||
How each rule is proven lives in [`docs/TESTING.md`](TESTING.md), organised by this spec's section
|
||||
numbers: the carry-over acceptance gates, the known gaps, the fault classes and oracles, the
|
||||
per-section proofs, the harness tools and the measured gate results. Two principles hold there and
|
||||
are restated once: the checker is independent of the code under test where possible, and every check
|
||||
has a negative control that proves it can fail.
|
||||
|
||||
Section 10 keeps its numbers as pointers, so every `DESIGN 10.x` reference still resolves:
|
||||
|
||||
### 10.1 Carry over (port, keep as acceptance gates)
|
||||
| Test | From | Notes |
|
||||
|---|---|---|
|
||||
| Geometry unit tests (M1 port baseline: 33 test blocks / 98 checks, none dropped; current count in `results/nimble-test.log`) | `tests/tgeometry.nim`, `results/nimble-test.log` | Port with `geometry.nim`. |
|
||||
| Geometry mutation check | `tools/mutation.sh` (a: no +-RayEps rays, b/c: upper/lower segment end exclusive) | Control passes, each mutation fails >= 1 test [MEASURED 1, 2, 2]. Port. |
|
||||
| Leak test | `tools/leak.mjs`, `leakcheck.nim`, `leaktest.sh` | Subject A and B, fresh DB, ~240 steps; asserts (a)-(e) in README. Independent LOS oracle for token visibility (added after the bow-tie bug). |
|
||||
| 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 (6.4); spread walkers across connections (4 per player, 16 total; 4.3). |
|
||||
| Client reducer tests | `client/src/state.test.ts` | Incl. reconnect reset. |
|
||||
| Smoke | `tools/smoke.mjs` | auth/cookie/tile/steal/garbage. |
|
||||
| Isolation harness | `tools/withserver.sh` | own DB/ports (`run/test/`), never touch a live session. |
|
||||
See TESTING §10.1.
|
||||
|
||||
### 10.2 Known test gaps to fix while porting
|
||||
- Shared-endpoint test passes with the horizontal arm removed [MEASURED, `HANDOFF.md`]: port a test
|
||||
that fails if either arm is missing, verified by a new mutation (d) in the mutation script.
|
||||
- Explored/tile checks use the server's own `cellsTouched` (self-consistency). New **independent
|
||||
explored oracle**: brute-force per-cell sampling with the clear-LOS segment test over cell
|
||||
centres/corners; compare as superset/subset with a stated tolerance [PROPOSED]. Differential test
|
||||
old `cellsTouched` vs scanline version (M2).
|
||||
- Leak checker oracle initially only checked "nothing extra", not "everything visible shows";
|
||||
completeness check is kept (assert (b)).
|
||||
See TESTING §10.2.
|
||||
|
||||
### 10.3 New
|
||||
- **Fault classes.** Each class has an injected fault (`-d:leakfault`, `LEAK_FAULT=<name>`) and an
|
||||
exact-class assertion; the shipped binary must contain no `LEAK_FAULT`. Built: `HIDDEN_TOKEN`,
|
||||
`GMONLY_TOKEN`, `WALLDATA`, `WITHHELD`, `NO_REMOVE`, `OWN_VIEW`, `OTHER_PLAYER`, `EXPLORED`,
|
||||
`OWNER_PROP`, `GM_PROP`, `STATUS_SOURCE`, `ACTUAL_NAME`, `STALE_NAME`, `CHAR_LIST`,
|
||||
`CONTROLLER_CHANGE`, `CHAR_OWNER_PROP`, `MARKER_EARLY`, `MARKER_EXTRA`, `MARKER_OFF`, `ONEWAY`,
|
||||
`KEY_IN_LOG`, `secretgap`. `tools/leakcheck.nim` refuses the `gm` bucket, the `owner` bucket on a
|
||||
non-controller and any `source` on a player status entry. Two consequences: the `hidden` and
|
||||
`gmOnly` faults also produce `NO_REMOVE` (a leaked token whose frame never changes leaves the
|
||||
client holding it with no correcting message, indistinguishable from a withheld `token_gone`; both
|
||||
invariants are broken), and the tile gate is HTTP-plane, so `tools/tiles.test.mjs` proves it (10.3
|
||||
Tiles), not the WS transcript checker. `GLOBAL_COUNTER` is structurally impossible (per-connection
|
||||
`n`).
|
||||
- **Characters and names (#14)**: tests for reveal per player and reveal to all; owner sees own
|
||||
actual name; a character owner change leaves token controllers unchanged; encountered entries
|
||||
survive token removal and a `gm_only` flip (greyed) and are removed only by the GM; `gm_only`
|
||||
tokens never enter an encountered list. Group: `tools/characters.test.mjs`, including "a status
|
||||
source is not shown to a non-GM" (the controller included). Fault classes: `ACTUAL_NAME`,
|
||||
`CHAR_LIST`, `CONTROLLER_CHANGE`, `CHAR_OWNER_PROP`.
|
||||
- **Tiles (#24)**: `tools/tiles.test.mjs` is the group's leak check (d) and the smoke tile-steal
|
||||
checks, through the real binary and a test nginx (`tools/nginx.mjs`, nginx from devbox; config
|
||||
generated per run in the state dir). An **independent explored oracle** (born in 10.2) recomputes
|
||||
visibility per cell from the GM's walls and the token's vision radius with its own clear-segment
|
||||
maths (inscribed 64-gon radius - 0.5 px for "sure", radius + 0.5 px and proper crossings for
|
||||
"maybe"): a `200` must be oracle-maybe (no invented disclosure) and oracle-sure must be `200` (no
|
||||
withheld tile). The 32x32-tile sweep is 1024 requests; slice 9's scene allows 283, all 283
|
||||
oracle-sure, 0 maybe-refused. Also checked: a player with no sight state gets `403`; another
|
||||
player gets `403` on a tile its neighbour sees; direct `/_tiles/` is `404` (the file exists) for
|
||||
every identity; malformed/canonical/out-of-range/stale-version/scene paths are `404` (with and
|
||||
without a session, including the GM); traversal and encoded shapes never reach a file; the
|
||||
direct-from-Nim answer carries `X-Accel-Redirect: /_tiles/1/v1/<x>_<y>.png`, `Cache-Control:
|
||||
private` and an empty body. Fixture tiles are 32 px PNGs written by `tools/tilefixture.mjs` under
|
||||
the state dir at test time; the test asserts the repo tracks no `.png` at all.
|
||||
- **Probing test (T8)**: M2, in-process against the move-rules module (5.5): arbitrary far moves;
|
||||
assertion: facts about walls/doors beyond LOS recoverable from replies <= a bounded amount (step
|
||||
cap), and uniform nack shape. M3: same test over WS with a hostile client (moved from M2).
|
||||
- **Door equivalence (#46, T17)**: `tools/doors.test.mjs` is the accept group for the "a player
|
||||
cannot tell a secret or locked door from a wall" obligation 5.8 states. Node harness, built-ins
|
||||
only (10.4), shaped like `tools/probing.test.mjs`: two servers, fresh state, two scenes identical
|
||||
except one segment, one identical scripted sequence. Pairs: (i) solid `wall` vs a closed `door`
|
||||
with `secret`; (ii) solid wall vs a closed door with `secret` and `locked`; (iii) closed `door` vs
|
||||
a closed `door` with `locked` (since #48 there are no `secret_door`/`locked_door` presets: the
|
||||
switches are the same, only the name changed). Script, run against both servers in lockstep:
|
||||
player tokens with vision near and around the segment; player moves along, into and across it
|
||||
(accepted, collision nacks, over-cap nacks); the GM adds the segment over a player token
|
||||
(`stuck`); the GM edits and toggles unrelated walls and doors elsewhere and moves tokens; a
|
||||
resync/reconnect; a GM `door.set open` on the secret/locked segment, refused `invalid` and GM-side
|
||||
only. **Assertion:** each player's complete received frame sequence — `hello`, `vision`,
|
||||
`explored` (full and delta), `token` (statuses included), `encountered`, and every `ack`/nack with
|
||||
its `code` and `pos` — is identical between the two runs after JSON canonicalisation (keys sorted,
|
||||
no numeric reformatting). **Normalisation allowed: none**; `n` is per connection and wall ids
|
||||
never reach a player, so nothing run-local leaks into the comparison. If the build ever forces a
|
||||
run-local difference it must be named in the test header with the reason. **Tiles:** the same
|
||||
per-player tile sweep in both runs, through the test nginx (`tools/nginx.mjs`, 11.1), must give
|
||||
the same status per tile. **Positive control:** the same script against a third scene whose
|
||||
segment is an open door (or absent) must produce *different* transcripts, otherwise the harness
|
||||
cannot fail (10, first paragraph). **Negative control:** a `-d:leakfault` build with
|
||||
`LEAK_FAULT=secretgap` makes a secret door not block sight (or movement) in the player-facing
|
||||
computation; the doors group must fail with that build, pass on a clean one, and the shipped
|
||||
binary must carry no fault hook (10.1, `tools/fault.test.mjs`). **Refusal codes:** `door.set` on a
|
||||
secret or locked door is `invalid` for the GM; a player `door.set` is `not-allowed` for every door
|
||||
(6.5), so the player side has one code and no oracle. **Not covered:** timing and size side
|
||||
channels (T11), accepted and unchanged.
|
||||
- **Door push with thickness (#50).** In-process pins in `tests/tmoverules.nim` (5.5).
|
||||
**Zero-thickness regression gate:** the existing push tests run unchanged and keep their exact
|
||||
positions (including "past the end", where the along-axis coordinate does not move). **Thick
|
||||
cases:** face push by `r` with the along-axis coordinate kept; past an end, push to `r` around the
|
||||
nearest end corner; inside the body, out of the `prev` side (left with no history); first side
|
||||
invalid (another blocking body or out of bounds) falls back to the other; both invalid leaves the
|
||||
token and `squeezed` while the door closes; `position` `left`/`right` moves the body and the
|
||||
target by the thickness. **Equivalence:** the #46 two-server test gains thick pairs (thick secret
|
||||
door vs thick solid wall; thick locked door vs thick plain door), byte-identical. Also pinned: a
|
||||
fixed window and an open door never push, and no wall edit pushes. **Mutations:** push from the
|
||||
drawn line; push ignoring the normal span; ambiguous side ignoring `prev`; validity check on the
|
||||
door only — each fails at least one test.
|
||||
- **One-way direction (#47)**: `tools/leakcheck.nim` and the independent explored/tile oracle apply
|
||||
**their own** side test — sign of the cross product of `viewer - a` with the `(-dy, dx)` normal of
|
||||
`a -> b`, positive = left — never by calling `vision.nim`: a sight-blocking one-way wall is
|
||||
dropped from the oracle's wall list for a viewer on its blind side, and a wall that is
|
||||
`blocks_sight:false` is dropped for everyone. Assertions: a token on the blind side gets no
|
||||
polygon point, explored cell or tile beyond the wall, and a token across it gives no `token`
|
||||
frame, no name and no encountered entry; a viewer on the seeing side does see across (the positive
|
||||
control, so the oracle can fail). Tolerances as elsewhere: the 0.5 px boundary band along the
|
||||
blind side is oracle-*maybe* (a `200` there is legitimate, but never *sure*), and anything clearly
|
||||
behind the blind wall is oracle-refused (a withheld proof cell still fails). New fault class
|
||||
`ONEWAY` — the player-facing computation drops `sight_dir` and lets the blind side see across —
|
||||
with its injected fault and exact-class assertion, shaped like the existing classes.
|
||||
- **Player marker (#48; shape fixed by #49).** `leakcheck.nim` allows the `marker` type and, with
|
||||
its own code (never calling `vision.nim`), checks that a marker exists for a player exactly when
|
||||
some point of the wall's visible extent has entered that player's polygon **and** the wall is
|
||||
`player_marker:true` and derives `window`, and that the frame carries only the opaque marker id
|
||||
and the anchor: anything else is `WALLDATA`/`MARKER_EXTRA`. Positive control: a window in the open
|
||||
yields exactly one marker once its anchor is seen; a wall behind a sight blocker,
|
||||
`player_marker:false`, or a solid wall with the switch on yields none. Faults: `MARKER_EARLY`,
|
||||
`MARKER_EXTRA`, `MARKER_OFF`. Retraction is checked GM-side: removing the wall, clearing the
|
||||
switch or moving the geometry retracts the marker, never sends the new position early, and writes
|
||||
no explored cell or tile.
|
||||
- **Wall fields, storage and migration (#49).** Three gates. **Leak:** `BannedAlways` contains every
|
||||
wall field name (`thickness`, `position`, `height`, `blocks_sight`, `blocks_movement`,
|
||||
`sight_dir`, `player_marker`, `door`, `open`, `secret`, `locked`, `label`, `a`, `b`), so any of
|
||||
them in a player frame is `WALLDATA`; `marker` is an allowed server type with its own oracle;
|
||||
positive control: a wall `height` injected into a player `token` frame fails with exactly
|
||||
`WALLDATA`. **Migration:** a schema-7 fixture (both wall kinds, an open door, non-empty `flags`,
|
||||
tokens and a character with props) migrates under the real binary, every decoded row equals the
|
||||
4.4 mapping, `props_gm.height` is `1.8` on every token and character and `eye_height` untouched; a
|
||||
second run is a no-op and a failing step rolls back. **Behaviour:** one scene built through
|
||||
`wall.add` with today's switch set and one migrated schema-7 scene holding the same walls produce
|
||||
byte-identical player frames, refusals and per-tile statuses for the same script; the #50
|
||||
zero-thickness push tests pass unchanged against migrated rows. Fixture churn: `tests/tdb.nim`
|
||||
`LatestVersion` 8, `tools/persistence.test.mjs` schema-8 assertions and the schema-7 fixture, and
|
||||
every hand-built `wall` row gains the columns.
|
||||
- **Auth tests**: key replace (old key invalid, sessions revoked, live connections closed), remove
|
||||
player (key invalid, characters and tokens pass to GM), one key reused on several devices (Q10
|
||||
FIXED), Origin mismatch rejected, cookie flags present.
|
||||
- **Protocol tests** (#18, `tools/protocol.test.mjs`): proto missing/non-integer (HTTP 400) and
|
||||
mismatch (`closing` 4003, no `hello`); unknown intent type (`unknown-type`) with unknown fields
|
||||
ignored; exactly one `ack` per `reqId` (reqId 0 and 2^31-1 included); `hello` first with `n = 1`
|
||||
and a per-connection `n` thereafter; `error malformed` for unreadable frames; the malformed flood
|
||||
(nine tolerated, the tenth closes 1008); the intent bucket (burst then `rate-limited`, connection
|
||||
stays open, a refused intent applies nothing, `error rate-limited` for an unreadable frame on an
|
||||
empty bucket); the 64 KB inbound boundary (exactly 64 KB is a message, 64 KB + 1 drops the TCP
|
||||
connection with no close frame); unmasked and bad-opcode frames; the server Ping and the Pong
|
||||
answer to a client Ping; the connection cap (503 + `Retry-After: 5`); and every server-initiated
|
||||
close as `closing` then 1005.
|
||||
- **Persistence**: migration tests (old DB -> new), chunked explored round trip, restart extended to
|
||||
wall CRUD and entity props. `tests/texplored.nim` pins the chunk layout, whole-chunk encoding,
|
||||
upsert replacement, per-player keying, restore and write cost; `tools/persistence.test.mjs` covers
|
||||
the fresh-resync round trip, per-player isolation, SIGTERM/SIGKILL equality, a wall removal's
|
||||
revealed cells after the wall returns, independently decoded chunk rows, move-ack timing, and a
|
||||
fixture DB migrated by the real binary.
|
||||
- **Restart (#25)**: `tools/restart.test.mjs` is the "restart" accept group. It builds one world
|
||||
that exercises every CRUD path (walls and an open door, plain/monster/player/linked tokens, a
|
||||
resize and a GM status, props in three buckets with a `prop.unset`, a character with props, a
|
||||
per-player reveal and a token `reveal_all`, a sighting in the encountered list, players and a
|
||||
name) and compares the complete 6.3 resync of a fresh GM connection and a fresh player connection
|
||||
before and after the restart: hello scene block, roster, walls, characters, tokens, encountered,
|
||||
vision and the full explored RLE, all normalized (only the per-connection `n` is dropped) and
|
||||
deep-equal. Both SIGTERM and SIGKILL are checked, because every ack follows its COMMIT (4.2).
|
||||
- **Logs (#25)**: `tools/logs.test.mjs` is the "logs" accept group. It records every GM key (the CLI
|
||||
key, a `--new` rotation, an old key after rotation), every player key (`key.create`, `key.show`,
|
||||
`key.replace`), every session cookie from `/join` (several devices) and its SHA-256 hash, plus a
|
||||
wrong key, a refused tile, a proto mismatch and a malformed frame, across two server runs on the
|
||||
same state dir, then greps the whole `server.log` for every value: none may appear. The second
|
||||
test is the negative control: a `-d:leakfault` build with `LEAK_FAULT=keylog` writes a raw key to
|
||||
stdout past `eventlog`, and the same grep must find it (so a log that was never captured cannot
|
||||
pass).
|
||||
- **Slow client** (Q13, 4.3): a client that stops reading; outbox stays under cap, no further 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, 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.
|
||||
- **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.
|
||||
- **Load/perf regression gate**: `bench` + concurrency numbers (section 5.3 and 4.3) compared with
|
||||
committed baselines; fail on > 2x regression [PROPOSED].
|
||||
- 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.
|
||||
See TESTING §10.3 (fault classes, oracles, differential tests, accept groups).
|
||||
|
||||
### 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. The harness
|
||||
lives in `tools/withserver.mjs`; the test nginx is `tools/nginx.mjs`.
|
||||
- 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 [MEASURED, 2026-11-14, #16, node
|
||||
v26.11.1]: `{headers}` still puts `Cookie` and `Origin` on the wire, and without `{headers}` no
|
||||
`Origin` is sent; pinned by `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 (11.1); no
|
||||
global tooling.
|
||||
- `devbox run test` = Nim tests first, then Node harnesses.
|
||||
- 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.
|
||||
See TESTING §10.4 (Node 26 black-box harnesses, built-ins only, `devbox run test`, `tools/groups.mjs`).
|
||||
|
||||
---
|
||||
|
||||
@@ -2401,12 +2202,8 @@ possible, and every check needs a negative control that proves it can fail.
|
||||
the state dir otherwise. [FIXED (owner-delegated), #24] The `Cache-Control: private` on a served
|
||||
tile comes from the Nim gate (3.3) and nginx passes it through the internal redirect; the
|
||||
location adds no header of its own, so the header is not duplicated.
|
||||
- Test nginx [FIXED (owner-delegated), #24]: `tools/nginx.mjs` starts the devbox `nginx` package
|
||||
on a free loopback port in front of the harness server, with a config generated per run under
|
||||
the server's state dir (ports and state paths never committed). It mirrors this vhost shape:
|
||||
`/join` (`access_log off`), `/tiles/` proxy, `/ws` upgrade, `/healthz` readiness, and `location
|
||||
/_tiles/ { internal; alias <state>/tiles/; }`. Tile bytes are 32 px fixture PNGs from
|
||||
`tools/tilefixture.mjs`, written under `<state>/tiles/`; none is committed.
|
||||
- Test nginx [FIXED (owner-delegated), #24]: a devbox `nginx` in front of the harness mirrors this
|
||||
vhost shape; details in TESTING §11.1.
|
||||
- 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).
|
||||
@@ -2423,8 +2220,8 @@ possible, and every check needs a negative control that proves it can fail.
|
||||
copy is unsafe.
|
||||
- Tiles: immutable after import, include in the normal file backup, or regenerate from source art
|
||||
(keep the source image).
|
||||
- Restore drill documented and tested once (M6): restore into a temp dir, start server, run the
|
||||
restart-equivalence assertions.
|
||||
- Restore drill documented and tested once (M6); the procedure and its assertions are in TESTING
|
||||
§11.2.
|
||||
- Off-box copy: out of v1 scope (Q21 FIXED).
|
||||
|
||||
### 11.3 Logging and metrics (bounded, outside the lock) [PROPOSED]
|
||||
@@ -2436,9 +2233,8 @@ possible, and every check needs a negative control that proves it can fail.
|
||||
connections, bytes). A separate timer thread (not holding the lock) snapshots and computes
|
||||
percentiles every N s and logs one line.
|
||||
- Keep the `SLOW` line (total > `SLOW_MS`, default 50) with breakdown `lock_wait / vision / sqlite /
|
||||
send / other` and intent type: it is what diagnosed the SQLite COMMIT tail [MEASURED,
|
||||
`results/spike/investigation.md`]. Formatting of the line happens after releasing the lock; at
|
||||
most O(1) rate-limited lines per second.
|
||||
send / other` and intent type: it is what diagnosed the SQLite COMMIT tail (TESTING §11.3).
|
||||
Formatting of the line happens after releasing the lock; at most O(1) rate-limited lines per second.
|
||||
- Log to stdout -> journald; levels; never log player key/session secrets, token positions of hidden
|
||||
entities are fine in server logs (server is trusted) but logs are GM-readable only (file perms).
|
||||
- Redaction mechanism [FIXED (owner-delegated, 2026-11-14, #16)]: the logger (`server/eventlog.nim`)
|
||||
@@ -2457,8 +2253,8 @@ possible, and every check needs a negative control that proves it can fail.
|
||||
## 12. HANDOFF traceability
|
||||
|
||||
Every item of the prototype's `HANDOFF.md` (H1-H26) is resolved; each decision is stated once in the
|
||||
section it belongs to (geometry and move rules in 5, persistence in 4.4, protocol in 6, tests in 10,
|
||||
deployment in 11). The old item-by-item table is preserved verbatim in
|
||||
section it belongs to (geometry and move rules in 5, persistence in 4.4, protocol in 6, tests in
|
||||
`TESTING.md`, deployment in 11). The old item-by-item table is preserved verbatim in
|
||||
[`docs/DESIGN-history.md`](DESIGN-history.md) §B. The one open item from it (the unexplained 583 ms
|
||||
spike) is in §14.
|
||||
|
||||
@@ -2480,11 +2276,8 @@ columns with today's defaults) lands complete now, so the later build needs no m
|
||||
- **M3 - Server core.** Done. 29 intents and 15 server messages, characters/names, chunked explored,
|
||||
typed views and single egress, auth, tile gate, schema and migrations. Accept = `devbox run test`
|
||||
green on a clean checkout with the nine groups: leak+fault, tiles, probing, protocol, auth,
|
||||
characters and names, restart, persistence, logs. Measured 2026-11-15: `devbox run test` exit 0
|
||||
(Nim suite all pass; 103 Node harness tests) and `devbox run mutation` exit 0 (control passes, all
|
||||
63 mutations fail at least one expected test). The nine groups map to their proving tests in
|
||||
`tools/groups.mjs`; `tools/groups.test.mjs` fails if a group or its named evidence test
|
||||
disappears. Out of M3 accept: concurrency (M5), the 127.0.0.1 bind check (M6).
|
||||
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
|
||||
@@ -2493,12 +2286,10 @@ columns with today's defaults) lands complete now, so the later build needs no m
|
||||
- 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.
|
||||
- Tile-size gates [FIXED, Q4]: (a) automated headless-Chromium test with mobile emulation
|
||||
(viewport, dpr, CPU and network throttle) against the real server path (nginx HTTP/2 + caching):
|
||||
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). The 2026-11-08 prototype
|
||||
phone run is evidence, not the gate (HTTP/1.1, no-store, zoom 0.5 only, first cold load up to
|
||||
3.3 s).
|
||||
- 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.
|
||||
- **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 <=
|
||||
@@ -2549,7 +2340,8 @@ owner may overturn. The full Q1-Q24 decision log is in [`docs/DESIGN-history.md`
|
||||
- `wall.update` counts as remove + add for the status rule (5.5).
|
||||
- The nginx directive that closes a dead peer; verified in M5 (4.3).
|
||||
- The uniform spatial grid, only if the 5k-wall bench misses its target (5.3, 5.5).
|
||||
- Client-side interpolation of others' token moves (7.5); load/perf regression gate at 2x (10.3);
|
||||
- Client-side interpolation of others' token moves (7.5); load/perf regression gate at 2x
|
||||
(TESTING §5.3);
|
||||
backup mechanism detail (11.2).
|
||||
|
||||
### Decisions recorded as ADRs
|
||||
|
||||
+8
-9
@@ -553,19 +553,18 @@ from the prototype, what was missing, what the M3 build added, and the tools it
|
||||
|
||||
## 13. Build status and milestones
|
||||
|
||||
**Rule:** DESIGN §13 (milestones and their accept criteria). Gate mechanics and measured results:
|
||||
**Rule:** DESIGN §13 (milestones and their accept criteria).
|
||||
|
||||
- **M1.** `geometry.nim`, `tgeometry.nim`, the mutation script and the shared-endpoint arm test.
|
||||
- **M3 accept result.** Measured 2026-11-15: `devbox run test` exit 0 (Nim suite all pass; 103 Node
|
||||
harness tests) and `devbox run mutation` exit 0 (control passes, all 63 mutations fail at least one
|
||||
expected test). The nine groups map to their proving tests in `tools/groups.mjs`;
|
||||
`tools/groups.test.mjs` fails if a group or its named evidence test disappears.
|
||||
- **M4 client gates.** (a) automated headless-Chromium test with mobile emulation (viewport, dpr, CPU
|
||||
- **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
|
||||
(HTTP/1.1, no-store, zoom 0.5 only, first cold load up to 3.3 s). If either fails, the fallback in
|
||||
DESIGN §13 applies.
|
||||
- **M5 accept.** Concurrency 60 s x3 with p99 <= the prototype's 4.98 ms + 50%; the slow-client test
|
||||
(§10.3); nginx closes a dead `/ws` within its configured timeout; stats computed outside the lock.
|
||||
- **M6 accept.** Deployed behind HTTPS; direct `/_tiles/` 404; WS upgrade works; phone sign-in works;
|
||||
no secret in the access log; backup and restore drill passes.
|
||||
(HTTP/1.1, no-store, zoom 0.5 only, first cold load up to 3.3 s).
|
||||
- **M4/M5 proving harnesses.** Headless e2e (§10.3 Browser e2e), the independent traffic audit
|
||||
(§10.3) and the slow-client test (§10.3) are the gates' harnesses; the pass criteria stay in DESIGN
|
||||
§13.
|
||||
- **M6 proof.** `/_tiles/` 404 and the log grep (§10.3 Logs), the WS upgrade (§10.3 Protocol), and the
|
||||
restore drill (§11.2).
|
||||
|
||||
Reference in New Issue
Block a user