feat(walls): door refusals and secret/locked equivalence gate (#56)

- door.set: opening a secret or locked door is invalid; closing either is
  allowed; a fixed window/non-door still has no open state.
- new tools/doors.test.mjs: two fresh servers, one identical script, three
  equivalence pairs (secret/wall, secret+locked/wall, locked/closed door),
  canonicalised frame + full per-player tile sweeps, an open-door positive
  control and a pinned zero-thickness close-push.
- secretgap fault hook (sight-only) makes the pair fail as exactly SECRETGAP;
  the clean pair passes and the shipped binary carries no fault hook.
- docs/TESTING.md T2/T17 and the door-equivalence/10.3 sections: built.

Ref #56
This commit is contained in:
2026-11-19 22:49:39 +01:00
parent 484275e8bb
commit 0f3aa2300f
6 changed files with 459 additions and 27 deletions
+25 -20
View File
@@ -60,7 +60,7 @@ How to run: `devbox run test` = Nim in-process tests first, then the Node black-
| # | Proving test |
|---|---|
| T1 | leak test + fault classes |
| T2 | fault `walls` [MEASURED caught]; `MARKER_EARLY`/`MARKER_EXTRA`/`MARKER_OFF` (§10.3) — planned: Walls r1 #59/#60; door-equivalence test (T17, §10.3) — planned: Walls r1 #56 |
| T2 | fault `walls` [MEASURED caught]; door-equivalence test (T17, §10.3) [MEASURED caught: fault `secretgap`]; `MARKER_EARLY`/`MARKER_EXTRA`/`MARKER_OFF` (§10.3) — planned: Walls r1 #59/#60 |
| T3 | faults `other-*` [MEASURED caught] |
| T4 | leak (d) against the independent oracle, smoke steal check, direct `/_tiles/` -> 404 (M3 test nginx) |
| T5 | documented, not testable as a leak; M4 timing gates (§13) |
@@ -75,7 +75,7 @@ How to run: `devbox run test` = Nim in-process tests first, then the Node black-
| T14 | leak test |
| T15 | deploy check |
| T16 | fault classes `ACTUAL_NAME`, `CHAR_LIST` (§10.3) |
| T17 | differential door-equivalence test `tools/doors.test.mjs` (§10.3, #46), positive control on an open door, fault `secretgap`, door-key scan in `tools/leakcheck.nim` -> `WALLDATA` — planned: Walls r1 #56 |
| T17 | differential door-equivalence test `tools/doors.test.mjs` (§10.3, #46), positive control on an open door [MEASURED], fault `secretgap` [MEASURED caught: `SECRETGAP`], door-key scan in `tools/leakcheck.nim` -> `WALLDATA` (Walls r1 #56) |
---
@@ -347,8 +347,10 @@ from the prototype, what was missing, what the M3 build added, and the tools it
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`, `KEY_IN_LOG`. Planned: Walls r1 — `ONEWAY` (#58),
`MARKER_EARLY`/`MARKER_EXTRA`/`MARKER_OFF` (#59/#60), `secretgap` (#56). `tools/leakcheck.nim`
`CONTROLLER_CHANGE`, `CHAR_OWNER_PROP`, `KEY_IN_LOG`. Walls r1 built: `secretgap` (#56), asserted
as exactly `SECRETGAP` by `tools/doors.test.mjs` (the differential group, not the transcript
checker). Planned: Walls r1 — `ONEWAY` (#58), `MARKER_EARLY`/`MARKER_EXTRA`/`MARKER_OFF`
(#59/#60). `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
@@ -379,10 +381,9 @@ from the prototype, what was missing, what the M3 build added, and the tools it
- **Probing test (T8)**: M2, in-process against the move-rules module (DESIGN §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)** — planned: Walls r1 #56; `tools/doors.test.mjs` is not built yet. It
will be the accept group for the "a player cannot
tell a secret or locked door from a wall" obligation DESIGN §5.8 states. Node harness, built-ins only
(10.4), shaped like `tools/probing.test.mjs`: two servers, fresh state, two scenes identical except
- **Door equivalence (#46, T17)** — built: Walls r1 #56, `tools/doors.test.mjs`. It is the accept
group for the "a player cannot tell a secret or locked door from a wall" obligation DESIGN §5.8
states. Node harness, built-ins only (10.4): 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
@@ -391,18 +392,22 @@ from the prototype, what was missing, what the M3 build added, and the tools it
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 (this file's first principles). **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:**
complete received frame sequence — `hello`, `roster`, `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:** the one run-local value a fresh two-server world forces is an opaque
token id (the server CSPRNG, DESIGN 8); the harness maps each run's ids to `TOK<n>` in creation order
and sorts an encountered list by that id before comparison. Nothing else is normalised: `n`, player
ids, positions, statuses, polygons, explored cells and tile statuses compare byte for byte.
**Tiles:** the same per-player tile sweep in both runs, through the test nginx
(`tools/nginx.mjs`, §11.1), must give the same status and body per tile. **Closing push:** the
script closes an ordinary door over a token and pins the resulting position (320,350), the
zero-thickness push gate unchanged. **Positive control:** the same script against a scene whose
segment is an open door must produce *different* transcripts, otherwise the harness cannot fail
(this file's first principles). **Negative control:** a `-d:leakfault` build with
`LEAK_FAULT=secretgap` makes a secret door not block sight in the player-facing computation; the
pair then fails as exactly `SECRETGAP`, the clean build passes, and the shipped binary carries 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 (DESIGN §6.5), so the player side has one code and no oracle. **Not covered:** timing
and size side channels (T11), accepted and unchanged.