design: record the token details decisions (#22)

Migration step 6, the status/source payload rules, the prop caps and the
property-schema registry (empty at start with a permissive fallback, because
8 says v1 never interprets props), and the grow-push search that 5.6 left
PROPOSED are all FIXED owner-delegated in 5.6/6.1 and summarised in 14. The
token payload rules now say `radius`/`props` are accepted on create from
slice 7 and refused nowhere else. 10.3 lists the three new fault classes,
and the glossary gains property, bucket and registry.
This commit is contained in:
2026-11-15 11:02:43 +01:00
parent e103c3ed5c
commit 3c6e926122
+26 -5
View File
@@ -260,6 +260,7 @@ explored_chunk(player_id, scene_id, cx, cy, bits BLOB, PRIMARY KEY(player_id, sc
- Step 3 (M3 slice 4, `world`) [FIXED (owner-delegated, 2026-11-15, #19)]: creates `scene` and `wall` and seeds the single v1 scene. `scene(id PK, name, w REAL, h REAL, tile_size INT, cell INT, grid_size REAL, vision_radius_default REAL, token_radius_default REAL, art_version INT, active INT, next_wall_id INT, extra TEXT)`; the seeded row is `id 1, name 'Scene', 4096x4096, tile_size 32, cell 32, grid_size 0 (no grid), vision_radius_default 400, token_radius_default 20, art_version 1, active 1, next_wall_id 1, extra '{}'` (the prototype's world and radii, Q4's 32 px cell). `wall(scene_id FK ON DELETE CASCADE, id, ax, ay, bx, by REAL, kind TEXT CHECK (kind IN ('wall','door')), open INT CHECK (open IN (0,1)), flags TEXT JSON DEFAULT '{}', PRIMARY KEY (scene_id, id))`. Two consequences: (a) M3 has a scene without waiting for the M6 import CLI, so `wall.*` and `door.set` work in slice 4; `w, h, tile_size, cell, art_version` stay off the wire (6.1 `scene.set`). (b) The scene row carries `next_wall_id`, so wall ids survive restarts, removals and re-imports of the same scene (#3). Seeding in the migration rather than at startup keeps the scene identical on every start and lets the migration test assert it (10.3). - Step 3 (M3 slice 4, `world`) [FIXED (owner-delegated, 2026-11-15, #19)]: creates `scene` and `wall` and seeds the single v1 scene. `scene(id PK, name, w REAL, h REAL, tile_size INT, cell INT, grid_size REAL, vision_radius_default REAL, token_radius_default REAL, art_version INT, active INT, next_wall_id INT, extra TEXT)`; the seeded row is `id 1, name 'Scene', 4096x4096, tile_size 32, cell 32, grid_size 0 (no grid), vision_radius_default 400, token_radius_default 20, art_version 1, active 1, next_wall_id 1, extra '{}'` (the prototype's world and radii, Q4's 32 px cell). `wall(scene_id FK ON DELETE CASCADE, id, ax, ay, bx, by REAL, kind TEXT CHECK (kind IN ('wall','door')), open INT CHECK (open IN (0,1)), flags TEXT JSON DEFAULT '{}', PRIMARY KEY (scene_id, id))`. Two consequences: (a) M3 has a scene without waiting for the M6 import CLI, so `wall.*` and `door.set` work in slice 4; `w, h, tile_size, cell, art_version` stay off the wire (6.1 `scene.set`). (b) The scene row carries `next_wall_id`, so wall ids survive restarts, removals and re-imports of the same scene (#3). Seeding in the migration rather than at startup keeps the scene identical on every start and lets the migration test assert it (10.3).
- Step 4 (M3 slice 5, `tokens`) [FIXED (owner-delegated, 2026-11-15, #20)]: creates `entity`, the map figures (`id TEXT PK`, `scene_id FK ON DELETE CASCADE`, `kind`, `descriptive_name`, `actual_name`, `x`, `y`, `radius REAL NULL`, `owner_player_id INTEGER REFERENCES player(id) ON DELETE SET NULL`, `gm_only`, `vision_radius REAL NULL`, `flags TEXT` default `'{}'`, `created_at`). `owner_player_id` NULL is GM-controlled, so `player.remove` hands that player's tokens to the GM through the FK alone (3.2) and memory (`0` = GM-controlled) mirrors it. `radius`, the three property buckets, `character_id` and `reveal_all` are NOT columns yet: slices 7 (#22, `token.resize` and props) and 8 (#23, characters and names) own them, and `entity_status` / `explored_chunk` arrive with slice 7 and slice 6. Ids are 12 random characters, so no counter column is needed (8). - Step 4 (M3 slice 5, `tokens`) [FIXED (owner-delegated, 2026-11-15, #20)]: creates `entity`, the map figures (`id TEXT PK`, `scene_id FK ON DELETE CASCADE`, `kind`, `descriptive_name`, `actual_name`, `x`, `y`, `radius REAL NULL`, `owner_player_id INTEGER REFERENCES player(id) ON DELETE SET NULL`, `gm_only`, `vision_radius REAL NULL`, `flags TEXT` default `'{}'`, `created_at`). `owner_player_id` NULL is GM-controlled, so `player.remove` hands that player's tokens to the GM through the FK alone (3.2) and memory (`0` = GM-controlled) mirrors it. `radius`, the three property buckets, `character_id` and `reveal_all` are NOT columns yet: slices 7 (#22, `token.resize` and props) and 8 (#23, characters and names) own them, and `entity_status` / `explored_chunk` arrive with slice 7 and slice 6. Ids are 12 random characters, so no counter column is needed (8).
- Step 5 (M3 slice 6, `explored`) [FIXED (owner-delegated, 2026-11-15, #21)]: creates `explored_chunk(player_id INTEGER NOT NULL REFERENCES player(id) ON DELETE CASCADE, scene_id INTEGER NOT NULL REFERENCES scene(id) ON DELETE CASCADE, cx INTEGER NOT NULL, cy INTEGER NOT NULL, bits BLOB NOT NULL CHECK (length(bits) = 512), PRIMARY KEY (player_id, scene_id, cx, cy))`. `(cx, cy)` are **chunk** coordinates (`cell div 64`), not cell coordinates; `bits` is a 512-byte bitmap of 64x64 cells, row-major inside the chunk, least-significant bit first (cell `(cx, cy)` is bit `(cy mod 64) * 64 + (cx mod 64)`, byte `bit div 8`, mask `1 shl (bit mod 8)`). Cells outside the scene stay 0, so a map whose cell count is not a multiple of 64 needs no special case; the v1 scene is 128x128 cells = 2x2 chunks, a 16384 px map 8x8. Both FKs cascade, so `player.remove` and a scene delete take the explored rows with them. The layout is pinned by `tests/texplored.nim` (exact byte/bit positions) and re-read independently by `tools/persistence.test.mjs`, so a refactor cannot silently swap axes or bit order. - Step 5 (M3 slice 6, `explored`) [FIXED (owner-delegated, 2026-11-15, #21)]: creates `explored_chunk(player_id INTEGER NOT NULL REFERENCES player(id) ON DELETE CASCADE, scene_id INTEGER NOT NULL REFERENCES scene(id) ON DELETE CASCADE, cx INTEGER NOT NULL, cy INTEGER NOT NULL, bits BLOB NOT NULL CHECK (length(bits) = 512), PRIMARY KEY (player_id, scene_id, cx, cy))`. `(cx, cy)` are **chunk** coordinates (`cell div 64`), not cell coordinates; `bits` is a 512-byte bitmap of 64x64 cells, row-major inside the chunk, least-significant bit first (cell `(cx, cy)` is bit `(cy mod 64) * 64 + (cx mod 64)`, byte `bit div 8`, mask `1 shl (bit mod 8)`). Cells outside the scene stay 0, so a map whose cell count is not a multiple of 64 needs no special case; the v1 scene is 128x128 cells = 2x2 chunks, a 16384 px map 8x8. Both FKs cascade, so `player.remove` and a scene delete take the explored rows with them. The layout is pinned by `tests/texplored.nim` (exact byte/bit positions) and re-read independently by `tools/persistence.test.mjs`, so a refactor cannot silently swap axes or bit order.
- Step 6 (M3 slice 7, `token details`) [FIXED (owner-delegated, 2026-11-15, #22)]: adds `entity.props_public`, `props_owner`, `props_gm` (`TEXT NOT NULL DEFAULT '{}'`: one JSON object per visibility bucket) and creates `entity_status(entity_id TEXT REFERENCES entity(id) ON DELETE CASCADE, status TEXT CHECK (status IN ('stuck','squeezed')), source TEXT CHECK (source IN ('walls','GM')), PRIMARY KEY (entity_id, status, source))` - the `(status, source)` set of 5.5. `radius` was already a column from step 4; step 6 is what makes the buckets and the statuses persistent. A token's status rows are rewritten with its row (one transaction), so a status change and the `token` frame that reports it can never disagree after a crash; a wall-derived status change (no row write) rewrites them in the mutation's `NORMAL` transaction. Both FKs cascade, so removing a token removes its entries.
- Step 5 write policy [FIXED (owner-delegated), #21]: a mutation persists **only the chunks its refresh dirtied**, and each of those is encoded from the **whole** explored set (a bitmap is a value, not a delta; writing just the new cells would erase the rest). Durability is `NORMAL` (Q12): explored is derived and monotone, unlike GM-authored content. A `token.move` writes the position and its chunks in **one** transaction (both NORMAL); a GM authoring write (`wall.*`, `door.set`, `token.create`/`update`/`remove`) keeps its own `FULL` row transaction and writes the chunks in a second `NORMAL` transaction, both inside the global lock and before the ack, so no ack precedes the cells it reports and no lock hold grows beyond one extra 512 B upsert. Those two commits are not atomic with each other; a crash between them loses explored cells the client was never told about, and the next refresh re-adds any the token can still see (explored never un-explores). - Step 5 write policy [FIXED (owner-delegated), #21]: a mutation persists **only the chunks its refresh dirtied**, and each of those is encoded from the **whole** explored set (a bitmap is a value, not a delta; writing just the new cells would erase the rest). Durability is `NORMAL` (Q12): explored is derived and monotone, unlike GM-authored content. A `token.move` writes the position and its chunks in **one** transaction (both NORMAL); a GM authoring write (`wall.*`, `door.set`, `token.create`/`update`/`remove`) keeps its own `FULL` row transaction and writes the chunks in a second `NORMAL` transaction, both inside the global lock and before the ack, so no ack precedes the cells it reports and no lock hold grows beyond one extra 512 B upsert. Those two commits are not atomic with each other; a crash between them loses explored cells the client was never told about, and the next refresh re-adds any the token can still see (explored never un-explores).
- Startup: load everything into memory, recompute vision for all players (prototype does, in one transaction) so `vision` is never stale vs walls. Slice 5 loads the scene and its tokens; a player's sight state (`PlayerVision`) is created on that player's first connection and recomputed from the current walls, so nothing is stale after a restart. Slice 6 (#21) restores every stored `explored_chunk` row into that player's set before the first connection (`explored.restore`), so a reloaded grid is the grid the player had; polygons are never stored (they are recomputed, 8). - Startup: load everything into memory, recompute vision for all players (prototype does, in one transaction) so `vision` is never stale vs walls. Slice 5 loads the scene and its tokens; a player's sight state (`PlayerVision`) is created on that player's first connection and recomputed from the current walls, so nothing is stale after a restart. Slice 6 (#21) restores every stored `explored_chunk` row into that player's set before the first connection (`explored.restore`), so a reloaded grid is the grid the player had; polygons are never stored (they are recomputed, 8).
- Shutdown: install a SIGTERM handler [prototype has only SIGINT, `HANDOFF.md`]: stop accepting, close sockets, final `wal_checkpoint(TRUNCATE)`, exit. Durability does not depend on it (WAL commit before ack). - Shutdown: install a SIGTERM handler [prototype has only SIGINT, `HANDOFF.md`]: stop accepting, close sockets, final `wal_checkpoint(TRUNCATE)`, exit. Durability does not depend on it (WAL commit before ack).
@@ -344,7 +345,7 @@ Notation: token centre `c`, radius `r` (entity `radius` if set, else scene `toke
- **Size:** `r` = entity `radius` if set, else scene `token_radius_default`. Units: px (map units). Client size presets (S/M/L, squares) are UI convenience only. Validation: `radius > 0`; no upper cap. Only the GM sets a radius; anyone who sees a token sees its radius. - **Size:** `r` = entity `radius` if set, else scene `token_radius_default`. Units: px (map units). Client size presets (S/M/L, squares) are UI convenience only. Validation: `radius > 0`; no upper cap. Only the GM sets a radius; anyone who sees a token sees its radius.
- **Scene default change:** every token using the default is resized by the same rule, per token. - **Scene default change:** every token using the default is resized by the same rule, per token.
- **Shrink** never pushes. It can clear `walls`-sourced entries (5.5 Clear). - **Shrink** never pushes. It can clear `walls`-sourced entries (5.5 Clear).
- **Grow push:** GM grows a token -> the server pushes it away from every blocking wall it overlaps, by the minimal displacement that ends `>= r` from every blocking wall, stays in bounds, and does not enter any other wall. No step cap. Deterministic; the tie-break is fixed and documented in the module header [PROPOSED]. Each token is pushed independently (tokens do not block tokens). The position change is server-originated: broadcast like the door push, vision recomputed for affected players. - **Grow push:** GM grows a token -> the server pushes it away from every blocking wall it overlaps, by a displacement that ends `>= r` from every blocking wall, stays in bounds, and does not enter any other wall. No step cap. Deterministic; the search and its tie-break are fixed and documented in the module header [FIXED (owner-delegated), #22]: a greedy relaxation, one wall per round in scene order, radial from that wall's closest point, at most 16 rounds, plus one flipped-side pass; a step whose centre path would cross a wall is refused, so the push never carries a token through a wall. Each token is pushed independently (tokens do not block tokens). The position change is server-originated: broadcast like the door push, vision recomputed for affected players.
- **Grow fails** (no valid position): the token stays (its graphic may overlap walls) and gets `squeezed` (source `walls`). - **Grow fails** (no valid position): the token stays (its graphic may overlap walls) and gets `squeezed` (source `walls`).
- Wire intents: `token.resize`, `status.set`, `status.clear` (6.1) [FIXED (owner-delegated, 2026-11-14, #11)]. - Wire intents: `token.resize`, `status.set`, `status.clear` (6.1) [FIXED (owner-delegated, 2026-11-14, #11)].
@@ -414,9 +415,27 @@ 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). - `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. - 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.
**Token payload rules [FIXED (owner-delegated, 2026-11-15, #20)]** (6.1 was silent on these; slice 5 builds them): **Token payload rules [FIXED (owner-delegated), #20 and #22]** (6.1 was silent on these; slices 5 and 7 build them):
- Slice 5 is plain tokens only: `token.create` requires `kind`, `pos`, `descriptive_name` and `actual_name`. `radius`, `props` and `character_id` are *known* fields this slice cannot honour and answer `invalid` (silently dropping a GM's field would lose data); `token.update` does the same for `character_id`. `token.resize`, `status.*`, `prop.*` and the character link land in slices 7-8. - `token.create` requires `kind`, `pos`, `descriptive_name` and `actual_name` for a plain token, and accepts `radius` (px > 0; null or absent = the scene default) and `props` (the three buckets, validated below) from slice 7 on. `character_id` is a *known* field no slice can honour yet: it answers `invalid` (silently dropping a GM's field would lose data), and `token.update` does the same for it. The character link lands in slice 8.
- A token's effective `radius` is the scene's `token_radius_default` for everyone (5.6/#4 is `token.resize`, slice 7). Per-token size does not exist yet, so the move rules keep their single scene radius. - A token's effective `radius` is its own `radius` when set, else the scene's `token_radius_default` (5.6). Both the wire `radius` and the move rules use the effective value, so a resize changes the escape/capsule/push geometry immediately (`worldmap.ruleToken`).
- `token.update` does not take `radius` or `props`: `token.resize` and `prop.set`/`prop.unset` own them (6.1's field list), so both are unknown fields there and are ignored (6.2).
**Status payload rules [FIXED (owner-delegated, 2026-11-15, #22)]** (slice 7):
- A token holds a set of `(status, source)` entries: status `stuck`|`squeezed`, source `walls`|`GM` (5.5). Stored order is by status (`stuck` before `squeezed`) then source (`walls` before `GM`), so the frames are deterministic and the diff never churns.
- `statuses:[{status, source}]` to the GM; `statuses:[{status}]` to everyone else, controller included (6.1 leak note 6). `status.set {id, status}` adds `(status, GM)`; adding an existing entry is `ok` and changes nothing. `status.clear {id, status, source}` removes exactly that entry: a missing token **or a missing entry** is `not-found` (6.1). After clearing the `walls` source the player escape rule of 5.5 applies unchanged, so no extra intent is needed.
- `source` is a stored wire word, not an enum index: `walls` and `GM` verbatim (`GM` is capitalised in the catalogue, so the check is exact).
**Property payload rules [FIXED (owner-delegated, 2026-11-15, #22)]** (6.1 delegated the numbers to #11, #22 fixes them; module `server/props.nim`):
- Buckets `public`|`owner`|`gm`; caps **64 keys per bucket**, key **1..64 code points** trimmed with no control characters (the name rule of 6.5), value **serialized JSON <= 8 KB**; a `null` value is not a value. Caps are per bucket: a full `public` bucket still leaves `owner` and `gm` writable.
- `prop.set {target, id, bucket, key, value}` / `prop.unset {target, id, bucket, key}`; `target` is `token` or `character`; a bad target, bucket, key, value or cap is `invalid`, a missing token is `not-found`; `prop.unset` of an absent key is `ok`. `target:"character"` is `not-found` in M3 because characters do not exist before slice 8.
- The **property-schema registry** (8, 9) is `key -> PropSchema{kind, bucket}` plus a fallback rule, shipped **empty with a permissive fallback** (`pkAny`, any bucket). DESIGN 8 says the server never interprets props in v1, so an unregistered key is accepted in any bucket; a key the rules module registers is enforced (JSON kind, bucket), and a write that disagrees is `invalid`. Flipping the fallback to strict is a one-line change when FFF lands.
- Egress: the `public` bucket to everyone who sees the token, `owner` additionally to the controller, all three to the GM (6.1). The filter lives in the typed view: `PlayerTokenView` has no field for the `gm` bucket, so a later frame change cannot leak it.
**Grow push and squeeze [FIXED (owner-delegated, 2026-11-15, #22)]** (5.6's tie-break, now decided):
- `token.resize {id, radius: number>0 | null}`; `radius` is required (absent is `invalid`), `null` returns the token to the scene default. The resize and its position/status outcome are one `FULL` transaction.
- Shrink never pushes and clears the `walls`-sourced entries only when the overlap actually ends.
- Grow: if the circle overlaps no blocking wall, nothing moves. Otherwise the server displaces the centre by a **deterministic greedy relaxation**: repeat at most 16 times "take the first blocking wall (scene order) the circle overlaps and move radially away from its closest point by the distance that ends at `r + 1e-6`", stopping as soon as the circle is clear and in bounds; a centre exactly on a wall takes the wall normal on the side of `prev` (no history: the left normal of `a->b`), and a second pass tries the flipped side once. A step whose own centre path crosses a blocking wall is refused, so the push never carries a token through a wall; if neither pass ends clear the token stays where it was and gets `squeezed` (source `walls`). The gate is one transaction: size, position and statuses.
- `token.resize` is GM-only (5.6: only the GM sets a size); the ack is `{}` with `not-found`/`invalid`.
- Names: both names are stored, the wire `name` of a `token` frame is always the descriptive name; the actual name has no egress path to a player until slice 8 provides the reveal rules. `token.update` on the names is a rename and reaches whoever may see the token. - Names: both names are stored, the wire `name` of a `token` frame is always the descriptive name; the actual name has no egress path to a player until slice 8 provides the reveal rules. `token.update` on the names is a rename and reaches whoever may see the token.
- `controller` is a player id, or `null` = the GM. The GM's own player id is stored as GM-controlled, so `controller: null` is the only GM spelling on the wire. In a patch, `controller: null` and `vision_radius: null` are real patch fields (they mean "the GM" and "the scene default"); an absent field means "keep the stored value". - `controller` is a player id, or `null` = the GM. The GM's own player id is stored as GM-controlled, so `controller: null` is the only GM spelling on the wire. In a patch, `controller: null` and `vision_radius: null` are real patch fields (they mean "the GM" and "the scene default"); an absent field means "keep the stored value".
- `flags` carries the `vision` flag (DESIGN 8); `vision_radius` is the token's own range and the player step cap (5.5). - `flags` carries the `vision` flag (DESIGN 8); `vision_radius` is the token's own range and the player step cap (5.5).
@@ -666,7 +685,7 @@ Principles carried from the prototype: the checker must be independent of the co
- Leak checker oracle initially only checked "nothing extra", not "everything visible shows"; completeness check is kept (assert (b)). - Leak checker oracle initially only checked "nothing extra", not "everything visible shows"; completeness check is kept (assert (b)).
### 10.3 New ### 10.3 New
- **Fault classes** for new data: `GMONLY_TOKEN`, `OWNER_PROP`, `GM_PROP`, `GLOBAL_COUNTER` (gseq side channel), `WALL_DELTA` (wall.add reaches player), `KEY_IN_LOG`, `CHAR_OWNER_PROP`, `ACTUAL_NAME`, `CHAR_LIST`, `CONTROLLER_CHANGE` (#14). Each with an injected fault and exact-class assertion, same as existing. **Slice 5 built** the classes that exist at this slice: `HIDDEN_TOKEN`, `GMONLY_TOKEN`, `WALLDATA`, `WITHHELD`, `NO_REMOVE`, `OWN_VIEW`, `OTHER_PLAYER`, `EXPLORED` (`-d:leakfault` + `LEAK_FAULT=<name>`, `tools/fault.test.mjs`, exact class set per fault, and the shipped binary asserted to contain no `LEAK_FAULT`). `OWNER_PROP`, `GM_PROP`, `ACTUAL_NAME`, `CHAR_LIST`, `CONTROLLER_CHANGE` arrive with slices 7-8; `TILE` with slice 9; `GLOBAL_COUNTER` is already structurally impossible (per-connection `n`). - **Fault classes** for new data: `GMONLY_TOKEN`, `OWNER_PROP`, `GM_PROP`, `GLOBAL_COUNTER` (gseq side channel), `WALL_DELTA` (wall.add reaches player), `KEY_IN_LOG`, `CHAR_OWNER_PROP`, `ACTUAL_NAME`, `CHAR_LIST`, `CONTROLLER_CHANGE` (#14). Each with an injected fault and exact-class assertion, same as existing. **Slice 5 built** the classes that exist at this slice: `HIDDEN_TOKEN`, `GMONLY_TOKEN`, `WALLDATA`, `WITHHELD`, `NO_REMOVE`, `OWN_VIEW`, `OTHER_PLAYER`, `EXPLORED` (`-d:leakfault` + `LEAK_FAULT=<name>`, `tools/fault.test.mjs`, exact class set per fault, and the shipped binary asserted to contain no `LEAK_FAULT`). `OWNER_PROP`, `GM_PROP` and the new `STATUS_SOURCE` arrive with slice 7 (#22): the leak scenario writes props into all three buckets and sets a GM-sourced status on a token the subject can see, and `tools/leakcheck.nim` refuses the `gm` bucket, the `owner` bucket on a non-controller and any `source` on a player status entry. `ACTUAL_NAME`, `CHAR_LIST`, `CONTROLLER_CHANGE` and `CHAR_OWNER_PROP` stay with slice 8; `TILE` with slice 9; `GLOBAL_COUNTER` is already structurally impossible (per-connection `n`).
- **Characters and names (#14)**: tests for reveal per player and reveal to all; owner sees own actual name; character owner change leaves token controllers unchanged; encountered entries survive token removal and scene change and are removed only by the GM; `gm_only` tokens never enter an encountered list. Fault classes: `ACTUAL_NAME` = unrevealed actual name sent to a player; `CHAR_LIST` = another player's character or encountered entry sent; `CONTROLLER_CHANGE` = owner change altering controllers; `CHAR_OWNER_PROP` = character owner-bucket prop sent to a non-owner. - **Characters and names (#14)**: tests for reveal per player and reveal to all; owner sees own actual name; character owner change leaves token controllers unchanged; encountered entries survive token removal and scene change and are removed only by the GM; `gm_only` tokens never enter an encountered list. Fault classes: `ACTUAL_NAME` = unrevealed actual name sent to a player; `CHAR_LIST` = another player's character or encountered entry sent; `CONTROLLER_CHANGE` = owner change altering controllers; `CHAR_OWNER_PROP` = character owner-bucket prop sent to a non-owner.
- **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). - **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).
- **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. - **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.
@@ -860,4 +879,6 @@ Owner also decided 2026-11-14 [FIXED (owner-delegated, 2026-11-14, #16)]: M3 sli
Owner also decided 2026-11-15 [FIXED (owner-delegated, 2026-11-15, #20)]: tokens and sight (M3 slice 5). Schema is migration step 4 (`tokens`): `entity` as listed in 4.4, no `radius`/props/`character_id` columns yet (slices 7-8 add them, `entity_status` with slice 7, `explored_chunk` with slice 6). Token ids are 12 random characters from `[A-Za-z0-9_-]` (a 64-symbol alphabet, so 6 uniform bits per character, 72 bits) from `std/sysrand`, collision-checked against every loaded token. The token payload rules 6.1 left open are fixed in 6.1 ("Token payload rules"); the load-bearing ones are: plain tokens only, `radius`/`props`/`character_id` refused `invalid` rather than dropped, effective radius = the scene default, the wire `name` is always the descriptive name, `controller: null` is the only GM spelling, and `explored` on connect is RLE rows. **Modules**: `server/tokens.nim` (records, validation, write-through persistence with FULL for GM authoring and NORMAL for moves), `server/vision.nim` (per-player polygons, explored set, the one copy of the visibility rule), `server/views.nim` (the single egress: typed `GmView`/`PlayerView`, then frames, then the per-connection diff), `server/worldmap.nim` (records -> geometry/move-rule inputs), `server/faults.nim` (test-only hook). `main.nim` holds the state (`tokens`, `visions` per player, `known` per connection keyed by app connId) and never builds a state frame itself, so raw world state has no path to a socket outside the egress (2, 10.1). **Egress timing**: a mutation's ack and its per-recipient diffs are enqueued under the global lock, in that order, and every frame is built from the state at enqueue time (mummy's `send` only appends to its deque, 4.3). Exact per-connection ordering between two concurrent mutations, and the coalescing that keeps that cheap, stay the M5 outbox. **Runtime rules**: polygons exist only for tokens a player controls that carry the `vision` flag, with the token's `vision_radius` or the scene default; only their token centres count for visibility; explored is the union of `cellsTouched` over history, only grows, drops cells outside the world, and the `fresh` set is cleared after one egress fan-out. A door closing pushes tokens aside (5.5) and persists the new positions; `stuck`/`squeezed` are slice 7's status model, so a failed push leaves the token overlapped and unflagged for now. `token.move` maps the move rules to the wire exactly: `ack {pos}`, the uniform nack for locked/over-cap/collision and for an out-of-bounds GM move, and `not-allowed` (players, one code for unknown and not-yours) or `not-found` (GM) before any geometry runs; accepted moves are persisted with NORMAL durability. `hello` carries the scene block for every named recipient and `extra` for the GM; an unnamed player still gets only `proto, role, me` and is not fed any state at all (6.3), so slice 5's player-side acceptance is reached through a harness fixture that writes the name into the DB before connecting: `player.setname` is slice 8 (#23) and the unnamed gate itself is pinned by `tools/tokens.test.mjs`. **Tests** (10.1, 10.3): `tools/leak.mjs` builds a 27-group scene over the real wire (enter/leave by movement, a closed door, create/remove, `gm_only`, a controller hand-over, another player walking in and out, a wall added and removed, a door push) and records every frame; `tools/leakcheck.nim` replays it with the GM socket as truth, recomputes polygons from `geometry.nim`, and checks explored against both that recomputation and an independent clear-segment sampler; A and B both pass with zero failures. `tools/fault.test.mjs` catches `hidden`, `gmOnly`, `walls`, `withhold`, `otherOwner`, `otherVision`, `otherExplored`, `noremove` and `explored` under their exact class sets and asserts the shipped binary contains no `LEAK_FAULT` string. `tools/probing.test.mjs` re-runs T8/H26 over WS: over-cap probes give the one uniform nack, two scenes differing only beyond cap + token radius produce identical reply sequences over 90 hostile probes inside the 6.4 burst, and a wall inside that bound does change the replies. Nim units: `tests/ttokens.nim`, `tests/tvision.nim`, `tests/tviews.nim`. Mutations aa-af pin the view rule, the egress `token_gone`, the absence of GM-only fields in a player frame and the "explored only grows" rule. Owner also decided 2026-11-15 [FIXED (owner-delegated, 2026-11-15, #20)]: tokens and sight (M3 slice 5). Schema is migration step 4 (`tokens`): `entity` as listed in 4.4, no `radius`/props/`character_id` columns yet (slices 7-8 add them, `entity_status` with slice 7, `explored_chunk` with slice 6). Token ids are 12 random characters from `[A-Za-z0-9_-]` (a 64-symbol alphabet, so 6 uniform bits per character, 72 bits) from `std/sysrand`, collision-checked against every loaded token. The token payload rules 6.1 left open are fixed in 6.1 ("Token payload rules"); the load-bearing ones are: plain tokens only, `radius`/`props`/`character_id` refused `invalid` rather than dropped, effective radius = the scene default, the wire `name` is always the descriptive name, `controller: null` is the only GM spelling, and `explored` on connect is RLE rows. **Modules**: `server/tokens.nim` (records, validation, write-through persistence with FULL for GM authoring and NORMAL for moves), `server/vision.nim` (per-player polygons, explored set, the one copy of the visibility rule), `server/views.nim` (the single egress: typed `GmView`/`PlayerView`, then frames, then the per-connection diff), `server/worldmap.nim` (records -> geometry/move-rule inputs), `server/faults.nim` (test-only hook). `main.nim` holds the state (`tokens`, `visions` per player, `known` per connection keyed by app connId) and never builds a state frame itself, so raw world state has no path to a socket outside the egress (2, 10.1). **Egress timing**: a mutation's ack and its per-recipient diffs are enqueued under the global lock, in that order, and every frame is built from the state at enqueue time (mummy's `send` only appends to its deque, 4.3). Exact per-connection ordering between two concurrent mutations, and the coalescing that keeps that cheap, stay the M5 outbox. **Runtime rules**: polygons exist only for tokens a player controls that carry the `vision` flag, with the token's `vision_radius` or the scene default; only their token centres count for visibility; explored is the union of `cellsTouched` over history, only grows, drops cells outside the world, and the `fresh` set is cleared after one egress fan-out. A door closing pushes tokens aside (5.5) and persists the new positions; `stuck`/`squeezed` are slice 7's status model, so a failed push leaves the token overlapped and unflagged for now. `token.move` maps the move rules to the wire exactly: `ack {pos}`, the uniform nack for locked/over-cap/collision and for an out-of-bounds GM move, and `not-allowed` (players, one code for unknown and not-yours) or `not-found` (GM) before any geometry runs; accepted moves are persisted with NORMAL durability. `hello` carries the scene block for every named recipient and `extra` for the GM; an unnamed player still gets only `proto, role, me` and is not fed any state at all (6.3), so slice 5's player-side acceptance is reached through a harness fixture that writes the name into the DB before connecting: `player.setname` is slice 8 (#23) and the unnamed gate itself is pinned by `tools/tokens.test.mjs`. **Tests** (10.1, 10.3): `tools/leak.mjs` builds a 27-group scene over the real wire (enter/leave by movement, a closed door, create/remove, `gm_only`, a controller hand-over, another player walking in and out, a wall added and removed, a door push) and records every frame; `tools/leakcheck.nim` replays it with the GM socket as truth, recomputes polygons from `geometry.nim`, and checks explored against both that recomputation and an independent clear-segment sampler; A and B both pass with zero failures. `tools/fault.test.mjs` catches `hidden`, `gmOnly`, `walls`, `withhold`, `otherOwner`, `otherVision`, `otherExplored`, `noremove` and `explored` under their exact class sets and asserts the shipped binary contains no `LEAK_FAULT` string. `tools/probing.test.mjs` re-runs T8/H26 over WS: over-cap probes give the one uniform nack, two scenes differing only beyond cap + token radius produce identical reply sequences over 90 hostile probes inside the 6.4 burst, and a wall inside that bound does change the replies. Nim units: `tests/ttokens.nim`, `tests/tvision.nim`, `tests/tviews.nim`. Mutations aa-af pin the view rule, the egress `token_gone`, the absence of GM-only fields in a player frame and the "explored only grows" rule.
Owner also decided 2026-11-15 [FIXED (owner-delegated, 2026-11-15, #22)]: token details (M3 slice 7). Schema is migration step 6 (`token details`): the three prop buckets on `entity` and `entity_status` (4.4). Intents: `token.resize`, `status.set`, `status.clear`, `prop.set`, `prop.unset`, all GM-only in v1 (6.1; owner-bucket writes by players come with FFF actions, 9, and are a permission change, not a redesign). The payload rules 6.1 left open are fixed in 6.1: the status set and its `source`, the three-bucket caps (64 keys, 1..64-char keys, 8 KB values, per bucket), the property-schema registry (empty at start with a permissive fallback, so v1 accepts any key in any bucket because 8 says the server never interprets props; a registered key is enforced) and the grow-push search. **Modules**: `server/props.nim` (buckets, caps, registry, parsing), `server/moverules.nim` (the status model replaces the M2 `blocked` bool: `stuckWalls`/`squeezedWalls` are the `walls` source, `locked` is the caller's "any entry" bit, per-token radius everywhere, `resizeToken` with the grow search, `placeToken` for GM placement/move), `server/text.nim` (the one copy of the 6.5 text rule, shared by names and prop keys), `server/tokens.nim` (statuses and props on the record and in the row), `server/worldmap.nim` (`ruleToken`/`ruleWall`/`applyOutcome`/`wallsStatuses`: the bridge between the record's entry set and the rules' two booleans), `server/views.nim` (typed per-recipient statuses and buckets). **One rule, one place**: every wall/door edit and every resize runs the pure rules on a snapshot taken *before* the write, then the write, then `applyRuleOutcome` (positions and `walls` statuses in one `NORMAL` transaction, memory after COMMIT); `token.create` computes the placement status before writing the row, so a new token is born with `stuck` if it lands on a wall. Status sources are owned by different layers on purpose: the rules never see `GM` entries, the record never derives `walls` entries. **Tests** (10.1, 10.3): `tests/tprops.nim` (caps, key/value rules, registry enforcement, set/unset, clone isolation), `tests/ttokens.nim` (radius, buckets, statuses round trip, the FK cascade), `tests/tmoverules.nim` (per-token radius, shrink/grow/squeeze, the no-crossing rule, the source independence), `tests/tviews.nim` (bucket and source filtering, one `token` frame per change), `tools/details.test.mjs` (the five intents' acks and codes, grow push and squeeze, stuck/clear, prop caps, who reads which bucket, restart equality), plus the leak scenario's prop/status groups and the `OWNER_PROP`, `GM_PROP`, `STATUS_SOURCE` faults. Mutations am-au pin the bucket filter, the per-bucket cap, the status set/clear, the shrink/grow rules and the push. See 4.4, 5.5, 5.6, 6.1, 8, 10.3.
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, #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.