From 14939afd8169cc595e8d3edea42721c5336c73e1 Mon Sep 17 00:00:00 2001 From: Davide Cappellini Date: Sun, 15 Nov 2026 12:52:23 +0100 Subject: [PATCH] design: record the finish line, the scene rules and the M3 acceptance checklist (#25) --- docs/DESIGN.md | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/docs/DESIGN.md b/docs/DESIGN.md index 0881b36..8fe64da 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -372,7 +372,7 @@ Conventions: - **Effects.** An intent's effects reach clients only as state messages, each built per recipient (3.1, 8) and sent only when that recipient's view changed (T11). "GM" below = every GM connection; "player X" = every connection of player X; "visible" = per the view rules in 3.1. - **Roles.** Sender column: P = player, G = GM. A P-sender intent from a connection whose player has no name yet is refused `not-allowed`, except `conn.ping` and `player.setname`. - **Not in M3:** `act.do` is reserved (v1 answers `no-rules`); server -> client `event` is reserved (9); GM `view.player` (7.3) is later; none is built in M3. Wire changes for M4/M5/M6 are limited to what 6.5 marks. -- **Slice-3 rollout note [FIXED (owner-delegated), #18].** The catalogue below is the contract; the handlers land slice by slice. Until a slice lands, its intents still get exactly one `ack` with the static code `unknown-type` and no state, so a half-built server never lies about having applied anything. Slice 3 builds the envelope, `hello`, `error`, `closing`, `conn.ping`, `act.do` (`no-rules`), and the three auth intents of slice 2 (`key.create`, `key.replace`, `player.remove`). Slice 4 (#19) builds `wall.add`, `wall.update`, `wall.remove` and `door.set`, plus the `walls` snapshot a GM gets on connect; everything else still answers `unknown-type`. +- **Slice-3 rollout note [FIXED (owner-delegated), #18].** The catalogue below is the contract; the handlers land slice by slice. Until a slice lands, its intents still get exactly one `ack` with the static code `unknown-type` and no state, so a half-built server never lies about having applied anything. Slice 3 builds the envelope, `hello`, `error`, `closing`, `conn.ping`, `act.do` (`no-rules`), and the three auth intents of slice 2 (`key.create`, `key.replace`, `player.remove`). Slice 4 (#19) builds `wall.add`, `wall.update`, `wall.remove` and `door.set`, plus the `walls` snapshot a GM gets on connect; everything else still answers `unknown-type`. Slice 10 (#25) builds `scene.set`: with it every one of the 29 catalogue intents has a handler, and `unknown-type` remains only the answer for a `t` outside the catalogue. ### 6.1 Catalogue @@ -422,6 +422,17 @@ Validation for `wall.*`: `a != b`, both in bounds, `kind` in `wall|door`, `flags - `wall.add` assigns the id from the scene's `next_wall_id`, which is monotonic and never reused (#3, 8; removal does not touch it, and a restart reloads it from the DB). - Every write is one transaction with `synchronous=FULL` around it (Q12: GM authoring is the data that is expensive to lose) and `NORMAL` again afterwards; the in-memory scene is updated only after COMMIT, so a failed write leaves memory and DB identical. +**Scene payload rules [FIXED (owner-delegated), 2026-11-15, #25)]** (6.1 was silent on these; slice 10 builds them): +- `scene` is an integer scene id; any value but the one v1 scene (id `1`) is `not-found`, a non-integer is `invalid` (the same split as `wall.*`). +- At least one of `name`, `grid_size`, `vision_radius_default`, `token_radius_default`, `extra` must be present. A declared field must have its own shape; a JSON `null` is a wrong type, not "absent": + - `name`: the 6.5 text rule, 1..64 code points, already trimmed, no control characters. + - `grid_size`: a finite number `>= 0` (0 = no grid; `classify` rejects NaN/Inf). + - `vision_radius_default`, `token_radius_default`: a finite number `> 0`, no upper cap (#4). + - `extra`: a JSON object, stored verbatim and never interpreted; the GM sees it in `hello`. +- `w`, `h`, `tile_size`, `cell` and `art_version` are **not** patch fields (import is the M6 CLI): they are unknown fields and ignored (6.2), so a patch carrying only one of them has no field at all and is `invalid`. +- Persistence: one `FULL` transaction writes the scene row and every token whose effective radius the new `token_radius_default` changed (its position and `walls`-sourced statuses too), then memory follows COMMIT. A token with its own radius is untouched (#4); a default-radius token follows the 5.6 grow/shrink rule: grow pushes or squeezes, shrink clears the `walls` entries only when the overlap ends. +- Effects: the ack, then `hello` plus the full 6.3 resync on **every** connection (unnamed players included: they get `hello` only). A `hello` also resets the server-side per-connection diff base, so a resync after it re-sends state the client just reset instead of treating it as unchanged. No `scene.activate` (Q3). + **Character and name payload rules [FIXED (owner-delegated), 2026-11-15, #23]** (6.1 was silent on these; slice 8 builds them, module `server/characters.nim`): - `character.create` takes `descriptive_name`, `actual_name` (the 6.5 text rule, 1..64 code points), an optional `owner` (a player id, default the GM's own) and optional `props`; a missing name, an unknown prop bucket or a mistyped field is `invalid`, an owner player that does not exist is `not-found`. - `character.update` patches `descriptive_name`/`actual_name` only, at least one of them; `props` is an unknown field there (6.2) and so cannot smuggle a bucket past `prop.*`. @@ -653,7 +664,7 @@ All ids are server-assigned. **Walls [FIXED, owner decision 2026-11-10, #3]**: p - **Entity (token and anything else) [PROPOSED, FFF seam]**: - `id` (random text, see above), `scene, kind` (free string: `pc`, `npc`, `item`...), `character_id` (NULL = plain token, e.g. monster or item; else the character it figures), `descriptive_name`, `actual_name` (plain tokens only; a character's tokens use the character's names), `pos`, `radius` (px, > 0, no upper cap; NULL = use scene `token_radius_default`; GM-only to set [FIXED, #4]; 5.6), `owner` = token controller (player id or null = GM-controlled; independent of the character's owner, 8), `gm_only`, `flags` (`vision`, `blocks_move`...), `vision_radius` (optional; per-entity numeric with scene default, Q7 FIXED; also the player step cap, 5.5), `statuses` (set of `(status, source)` entries; status `stuck`|`squeezed`, source `walls`|`GM`; locked while any entry exists; Q14, 5.5, #4). - `props`: three JSON objects by visibility bucket: `public` (anyone who sees the entity), `owner` (token controller + GM), `gm` (GM only). Keys are strings, values JSON scalars/arrays/objects with a size cap. No hidden state beyond these buckets and `gm_only` in v1 [FIXED, Q19]. - - The server never interprets props in v1 except via a registered property schema (type, bucket, writable-by) used for validation and for FFF later. + - The server never interprets props in v1 except via a registered property schema (`{kind, bucket}`) used for validation and, later, by FFF. Property writes are GM-only in v1 (6.1, #11); the writable-by role and a default value are deferred to the FFF seam (9, post-v1), not part of this registry. - **Character [FIXED, owner decision 2026-11-10, #14]**: own record, separate from tokens. Fields (indicative): `id` (random, same format as token ids), `owner` (exactly one player id; the GM is a player, so GM ownership = the GM's player id; the GM reassigns), `descriptive_name`, `actual_name` (names rule below), `reveal_all`, `props` (three buckets, identity/base values). A character has any number of tokens in any scene. A new token for a character starts controlled by the character's owner; the GM may change it. Changing a character's owner never changes its tokens' controllers (GM adjusts by hand). Rejected: token controller derived from character; auto-follow on reassignment; all data on the token (duplicated stats); all data on the character. - **Character props vs token props [FIXED, #14]**: the character holds who the figure is (identity, base values); the token holds what is happening to that figure (damage, conditions, scene effects). Plain tokens (monsters, items) keep their own data. Both use the three buckets: `owner` for a character = character owner + GM; for a token = token controller + GM. The server stores both and never interprets them; FFF decides the split (9). A recipient's view of a token is built from its own props and its character's props, each under its own bucket rule [PROPOSED]. - **Names [FIXED, #14]**: every character and every plain token has a `descriptive_name` (e.g. "a grumpy man") and an `actual_name` (e.g. "Lord Vex"). Players see the descriptive name until the GM reveals the actual name to that player; the GM can also reveal to all at once (`reveal_all`). The owner of a character always sees its actual name. A character's tokens use the character's names, so one reveal covers all of them. Applies to player characters too (introductions). A reveal cannot be undone in v1 (no un-reveal intent). Reveals are not revoked when ownership changes [PROPOSED]. Built in slice 8 (#23): a reveal is one `(player, subject)` row, and the subject is a character id **or a plain token id** — the two share one id namespace (4.4), so no column distinguishes them. `reveal_all` is a flag on the subject, not a fan-out of rows, so a player who joins later is covered. The one rule that turns a reveal, an owner or a flag into the name a recipient sees is `characters.knowsActual`/`visibleName`; no frame builder re-derives it. @@ -676,7 +687,7 @@ Principle: v1 has no rules, but every state change already flows through a valid - **Characters and tokens with properties**: FFF characters are character records (8); monsters and items are plain tokens. Both carry `props` in the three buckets. FFF decides which keys live where (token state vs character identity and base values); the VTT enforces the bucket on egress and never interprets the values. - **Action hook** (server side): the reserved `act` intent carries `actor, action, args`. Handling = `rules.handle(world, actor, action, args) -> list of mutations | error`. Mutations are the same primitive set the pipeline already validates (set prop, move, create/remove entity, emit event). Hook output is validated like any client intent; FFF cannot bypass the egress filter. - **Events**: `event{kind, data}` server->client messages with per-recipient filtering (e.g. roll results visible to all, GM-only whispers). Not implemented in v1; message type name reserved. -- **Schema registry**: `property schema` (key, type, bucket, writable-by role, default) registered by the rules module; v1 ships an empty/default registry. +- **Schema registry**: `property schema` (key, `{kind, bucket}`) registered by the rules module; v1 ships an empty registry with a permissive fallback (6.1). A writable-by role and a default value are not part of it: prop writes are GM-only in v1, and which role may write which key, plus any default, belongs to the FFF seam (post-v1). - **Where does FFF run?** Undecided. Q19 answered only the hidden-state question (no state beyond the buckets and `gm_only`, FIXED); engine language, runtime and location are not answered. Revisit when FFF starts (schema change accepted then). Options: (a) compile-time Nim module linked into the server (simplest, fastest, requires FFF in Nim or a Nim port); (b) out-of-process sidecar speaking a small request/response protocol over a Unix socket (language-agnostic, adds latency and a failure mode inside the global lock; must run outside the lock or be time-bounded); (c) WASM. No decision made. - Client side: a generic property panel driven by the schema registry; FFF-specific UI later as additional DOM panels (plain HTML overlay [FIXED] keeps this simple). - Non-goal now: any assumption about dice, turns, or stat names. @@ -713,6 +724,8 @@ Principles carried from the prototype: the checker must be independent of the co - **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 test extended to wall CRUD and entity props. **Slice 6 built** the explored half: `tests/texplored.nim` (chunk layout pinned, whole-chunk encoding, upsert replacement, per-player keying, restore, write cost) and `tools/persistence.test.mjs` (round trip through a fresh resync, per-player isolation, SIGTERM and SIGKILL restart equality, a wall removal's revealed cells after the wall returns, chunk rows decoded independently, move-ack timing, and a fixture schema-4 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. @@ -725,6 +738,7 @@ Principles carried from the prototype: the checker must be independent of the co - 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 (#8 had verified v24 only; the prototype's "Node 22" note is stale). - Root `devbox.json` pins `nodejs` 26 (port step) and, since slice 9 (#24), the `nginx` used only by the test harness (DESIGN 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 checklist of 14 (#12) cannot silently go stale. Slice-level 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. @@ -815,7 +829,7 @@ Each is small, ends with a green gate, and no milestone depends on browser UI be - Scope: scanline `cellsTouched`, differential + independent explored oracle tests, radius-bbox wall cull (spatial grid only if the 5k bench misses), capsule/swept move check and token-on-wall escape (5.5), step cap = effective vision radius (5.5), `blocked` flag with circle-overlap trigger and Set/Keep/Clear policy (5.5), GM moves ignore walls and step cap (and set/clear `blocked`), bench harness incl. 5k-wall scene, pure in-process move-rules module with unit tests. The WS/hostile-client harness is M3, not M2. - Accept: `visibilityPolygon` and `cellsTouched` equal the old implementation on the corpus (5.5); `moveBlocked` excluded (its results change on purpose); polygon+cells bench <= prototype (0.451 ms) on the prototype scene and polygon < 1 ms on the 5k-wall scene [targets PROPOSED]; in-process probing test passes; escape and capsule positive and negative unit tests pass; door-push tests pass (each side, centre on the line uses the previous side, other-side fallback for a blocking wall and for out of bounds, both invalid -> blocked and opening frees it, GM-owned token pushed, wall add still sticks); `blocked` tests pass (every Set/Keep/Clear rule of 5.5: overlap trigger, doorway, two overlapping walls, GM drop/move sets and clears, GM clear then escape, unrelated change does not re-block); mutations k (no Keep), l (GM moves do not set blocked), m (push to the wrong side), n (push skips the validity check) and o (previous side ignored) each fail >= 1 test; over-cap move gives the same nack as a blocked move; thresholds documented in the module header; oracle tolerance 0.5 px. The KNOWN LIMITATION test and the Q14 pin test are replaced with positive assertions and `blocked`-policy tests. - **M3 - Server core.** - - Scope: entities with bucketed props, characters with names, name reveal and encountered list (8, #14), players, player keys/sessions, scenes, chunked explored persistence, typed per-recipient views and single egress, per-connection counters, proto versioning, the wire catalogue of 6 (29 intents, 15 server messages), wall/token/character CRUD intents, Origin check, plaintext player keys and non-expiring sessions (Q10, Q11), SQLite schema + migrations. Tile gate `/tiles/` (3.3), fixture tiles at 32 px generated at test time by a helper (not committed), minimal local test nginx with internal `/_tiles/` (production vhost and tile import CLI stay M6) [FIXED, owner decision 2026-11-14, #7]. Black-box harnesses ported to `tools/` on Node 26; `devbox run test` runs Nim then Node (10.4) [FIXED, owner decision 2026-11-14, #9]. + - Scope: entities with bucketed props, characters with names, name reveal and encountered list (8, #14), players, player keys/sessions, scenes, chunked explored persistence, typed per-recipient views and single egress, per-connection counters, proto versioning, the wire catalogue of 6 (29 intents, 15 server messages), wall/token/character CRUD intents, Origin check, plaintext player keys and non-expiring sessions (Q10, Q11), SQLite schema + migrations. `scene.set` is the one scene-writing intent (6.1 payload rules) and completes the 29-intent catalogue (#25). Tile gate `/tiles/` (3.3), fixture tiles at 32 px generated at test time by a helper (not committed), minimal local test nginx with internal `/_tiles/` (production vhost and tile import CLI stay M6) [FIXED, owner decision 2026-11-14, #7]. Black-box harnesses ported to `tools/` on Node 26; `devbox run test` runs Nim then Node (10.4) [FIXED, owner decision 2026-11-14, #9]. - Accept: `devbox run test` green on a clean checkout, and that run includes the nine named groups below; details live at the § refs, not here. Out of M3 accept: concurrency (M5), 127.0.0.1 bind check (M6 deploy) [FIXED, owner decision 2026-11-14, #12]. 1. **leak+fault**: ported leak test A and B; fault test catches every class with exact class sets, incl. characters and names; clean build passes (10.1, 10.3). 2. **tiles**: Tile gate: leak test (d) and smoke tile-steal checks pass through the test nginx; gate decisions match the independent explored oracle (10.2); direct `/_tiles/` fetch -> 404; malformed or out-of-range path -> 404; unexplored -> 403 [FIXED, owner decision 2026-11-14, #7]. **Built by slice 9 (#24):** `tools/tiles.test.mjs` (three tests: the oracle sweep of 1024 tile requests through the test nginx, the full refusal/path matrix plus direct `/_tiles/`, and the generated-fixture/no-committed-PNG check), with `tools/nginx.mjs` and `tools/tilefixture.mjs`; the decided URL grammar and status split are in 3.3. @@ -823,9 +837,9 @@ Each is small, ends with a green gate, and no milestone depends on browser UI be 4. **protocol**: proto mismatch refused, unknown type rejected, oversized frame rejected, malformed flood closed, rate limit hit, connection cap enforced (10.3, T10, 6.2, 6.5; codes and close codes in 6.5; limits and numbers in 4.3 (connections) and 6.4 (frame, intent rate) [FIXED, owner-delegated, #15]). 5. **auth**: key create; key replace (old sessions and live connections closed); remove player; one key on several devices; Origin mismatch rejected; cookie flags present (T7, H9, 3.2, 10.3). 6. **characters and names**: as #14 (10.3). Built by slice 8 (#23): `tools/characters.test.mjs` (ten tests: `player.setname` + `roster`, `player.rename` + `key.show`, `character.create`, reveal per player and `reveal_all`, a plain token's own names and `cprops`, `reassign` leaving controllers alone, `update`/`remove` with `in-use`, the encountered list and `encountered.remove`, the status source, and a restart), plus the four new fault classes in group 1. - 7. **restart**: identical state after restart, incl. CRUD (10.1). + 7. **restart**: identical state after restart, incl. CRUD (10.1). **Built by slice 10 (#25):** `tools/restart.test.mjs` (two tests: full-state equality over SIGTERM and over SIGKILL, every CRUD path in one world; details in 10.3). 8. **persistence**: explored chunks round trip; old DB migrates to new (H13, 4.4, 10.3; migrations are PROPOSED in 4.4). - 9. **logs**: no secret in any log; the test greps the logs for every key and session value it used (T6, 11.3 PROPOSED). + 9. **logs**: no secret in any log; the test greps the logs for every key and session value it used (T6, 11.3 PROPOSED). **Built by slice 10 (#25):** `tools/logs.test.mjs` (two runs incl. a GM-key rotation, keys/sessions/hashes, and a `keylog` leak-fault negative control; details in 10.3). - **M4 - Client v1.** - Scope: new `client/` dir (first real client build): Vite + TS + Pixi v8 client: layers, tiles, grid, tokens (BitmapText), character list, encountered list (greyed), reveal buttons (#14 UI; server side in M3), fog textures, wall/door editor, token drag with prediction/rollback, DOM overlay, reconnect backoff, reducer tests; after the client port, archive `prototype-*` dirs (Q24). - 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, 16384 px map (tiled; PROPOSED test target, Q2), fog active. @@ -840,7 +854,7 @@ Each is small, ends with a green gate, and no milestone depends on browser UI be - Scope: real-network latency/throughput run, iOS/Safari check (if available), one real session with the owner's table, collect SLOW lines. - Accept: documented numbers; defects triaged to issues; go/no-go for v1. - **M3 build slices** [FIXED, owner decision 2026-11-14, #13]: vertical slices, each runnable end-to-end with its own test. Order and blocking: each slice blocked by the previous, except 9 (blocked by 5 only) and 10 (blocked by 1-9). Open technical details (DDL, property-schema registry format, config keys, redaction mechanism) are decided by the builder inside the slice that needs them and recorded here as FIXED (owner-delegated). - 1. Bare server (#16) 2. Getting in (#17) 3. Talking safely (#18) 4. Walls and doors (#19) 5. Tokens and sight (#20) 6. Explored persistence (#21) 7. Token details (#22) 8. Characters and names (#23, done) 9. Map tiles (#24, done) 10. Finish line (#25). + 1. Bare server (#16) 2. Getting in (#17) 3. Talking safely (#18) 4. Walls and doors (#19) 5. Tokens and sight (#20) 6. Explored persistence (#21) 7. Token details (#22) 8. Characters and names (#23, done) 9. Map tiles (#24, done) 10. Finish line (#25, done). - **Post-v1 candidates**: FFF seam implementation (section 9), drawings/pings/ruler, chat/dice (order decided at M7, Q8), light sources, browser upload UI (Q5), multi-scene (Q3), vision deltas/binary protocol (Q16). --- @@ -907,3 +921,19 @@ Owner also decided 2026-11-15 [FIXED (owner-delegated, 2026-11-15, #22)]: token Owner also decided 2026-11-15 [FIXED (owner-delegated, 2026-11-15, #23)]: characters and names (M3 slice 8). Schema is migration step 7 (`characters`, 4.4): `character`, `name_reveal`, `encountered`, plus `entity.character_id` and `entity.reveal_all`. The decisions 4.4 leaves open are recorded there and the wire rules in 6.1 ("Character and name payload rules"): one id namespace for tokens and characters, an owner that never dangles (`player.remove` transfers to the GM first), an encountered entry with no FK that outlives everything, a linked token that stores `''` names, and `character_id`/`cprops` on the token frame with the ownership rules of 6.1 leak notes 2-3. **Modules**: `server/characters.nim` (records, the name rule, the reveal set, the encountered snapshots, their rows), `server/views.nim` (the typed character and encountered views plus the token-frame additions), `server/tokens.nim` (`characterId`/`revealAll`, the linked-token validation and `sqlLitId`), `server/text.nim` (`normalizedPlayerName`, `validPlayerName`, `sameName`), `server/auth.nim` (`allPlayers`, `nameTaken`, `setName`, `renamePlayer`), `server/main.nim` (`recordEncounters` in every mutation path before the ack, the roster fan-out, `sendHello`/`resync` for `player.setname`). Also fixed here: `protocol.withN` deep-copies before stamping `n`, because the stored diff base was being mutated and every state frame was re-sent on every mutation. **Tests** (10.1, 10.3): `tests/tcharacters.nim` (the name rule, the reveal set, the encounter snapshot, validation, persistence incl. the GM transfer and the `in-use` count), `tests/tviews.nim` (character frames, the owner/non-owner split, `cprops`, `character_gone`, the encountered diff), `tools/characters.test.mjs` (the acceptance group of 13), the leak scenario's ten character/name/encountered groups and the `ACTUAL_NAME`, `CHAR_LIST`, `CONTROLLER_CHANGE`, `CHAR_OWNER_PROP` faults. Mutations av-b4 pin the name rule, the encountered snapshot, the linked-token validation, `in-use`, the GM transfer, the snapshot rename and the `cprops` bucket. See 3.1, 4.1, 4.4, 6.1, 6.3, 6.4, 6.5, 8, 10.3, 13. Owner also decided 2026-11-15 [FIXED (owner-delegated, 2026-11-15, #21)]: explored persistence (M3 slice 6). Schema is migration step 5 (`explored`): `explored_chunk` keyed by `(player_id, scene_id, cx, cy)` with a 512-byte blob, both FKs cascading (4.4). Chunk format and size are fixed at 64x64 cells = 512 B, row-major LSB-first bits, `(cx, cy)` = chunk coordinates; the layout is pinned by tests and re-read independently by the Node harness. **Write timing**: a mutation writes only the chunks its refresh dirtied, each encoded from the whole explored set, with `NORMAL` durability; a move writes position and chunks in one transaction, a GM authoring write adds a second `NORMAL` chunk transaction under the same lock, both before the ack — the two commits are deliberately not atomic with each other, and the only loss they can cause after a crash is cells no client was acked about, which the next refresh re-adds. Measured: 0.015 ms avg / 0.035 ms p99 per chunk write, 0.7 ms avg / 1-2 ms p99 per move ack (4.3's budget is untouched). **Load**: `explored.restore` fills every player's set at startup from the chunk rows and logs `explored_loaded players= chunks=`; polygons stay recomputed (8). **Tests** (10.1, 10.3): `tests/texplored.nim` (format, whole-chunk encoding, upsert replacement, per-player keying, restore, cost) and `tools/persistence.test.mjs` (fresh-resync round trip, per-player isolation, SIGTERM and SIGKILL restart equality, wall-removal cells surviving after the wall returns, chunk rows decoded independently, move-ack timing, and a schema-4 fixture DB migrated by the real binary). Mutations ag-al pin the bit layout, the chunk coordinate, the restore, the per-player key, the upsert and the dirty-chunk dedupe. See 4.4, 8, 10.3. + +Owner also decided 2026-11-15 [FIXED (owner-delegated, 2026-11-15, #25)]: the M3 finish line. `scene.set` is built as the 29th and last catalogue intent; its payload rules are in 6.1 ("Scene payload rules"), with the decision that `hello` also resets the server-side per-connection diff base (otherwise a resync after `hello` would skip state the client just reset). The two missing accept groups are built: **restart** = `tools/restart.test.mjs` (full 6.3 resync equality over SIGTERM and SIGKILL, every CRUD path) and **logs** = `tools/logs.test.mjs` (every key, session cookie and session hash absent from both runs' log, with a `LEAK_FAULT=keylog` negative control). `tools/groups.mjs` + `tools/groups.test.mjs` map the nine groups of 13 to their named proving tests, so the checklist cannot silently go stale. Fixture clean-up (acceptance 5): `tests/fixtures/scene.json` loses the stale `tileSize: 256`, the scene-wide `tokenRadius` (now a fixture constant, the server has per-token radius, #4) and its index token ids (`A`/`M1`); the geometry/corpus fixture keeps its walls, radii and positions. The `blocked` boolean is already gone from code (`stuck`/`squeezed`, #4). **M3 acceptance checklist (all nine groups, `devbox run test`, measured on the final tree):** + +| # | group (13 M3 Accept) | proving test | status | +|---|---|---|---| +| 1 | leak+fault | `tools/leak.test.mjs` (leak A/B), `tools/fault.test.mjs` (exact class sets incl. `ACTUAL_NAME`, `CHAR_LIST`, `CONTROLLER_CHANGE`, `CHAR_OWNER_PROP`) | pass | +| 2 | tiles | `tools/tiles.test.mjs` (oracle sweep through the test nginx, refusal/path matrix, no committed PNG) | pass | +| 3 | probing | `tools/probing.test.mjs` (hostile client over WS, bounded replies) | pass | +| 4 | protocol | `tools/protocol.test.mjs` (proto, unknown type, envelope, flood, rate limit, 64 KB, cap, closing) | pass | +| 5 | auth | `tools/auth.test.mjs` (cookie flags, Origin, devices, key replace, remove, gm-key) | pass | +| 6 | characters and names | `tools/characters.test.mjs` (names, reveals, reassign, in-use, encountered, status source) | pass | +| 7 | restart | `tools/restart.test.mjs` (full state, all CRUD, SIGTERM and SIGKILL) | pass | +| 8 | persistence | `tools/persistence.test.mjs` (chunk round trip, migration, restart, write cost) | pass | +| 9 | logs | `tools/logs.test.mjs` (keys/sessions/hashes across two runs, `keylog` control) | pass | + +Out of M3 accept, unchanged: concurrency (M5) and the 127.0.0.1 bind check (M6 deploy) [FIXED, #12]. The mutation gate runs the whole a-o + av-b4 + c1-c4 set: control passes and every mutation fails at least one test. See 6.1, 10.3, 10.4, 13.