feat: GM characters, reveals, who-sees-it and seen_by (#75)

Server: GM token frames gain the additive, GM-only seen_by:[player ids],
computed from each player's existing sight (PlayerVision.visibleTo) with
no extra polygon pass. Leakcheck BannedAlways bans seen_by; a seenBy
fault build is caught as exactly WALLDATA. proto stays 2 (6.2 additive).

Client: new cast slice parses character/character_gone/encountered frames
and seen_by; gmcast panel adds character create/rename/assign/remove,
reveal to one/all, encountered forget (grey entries only) and the
who-sees-it list (0/100 in M4). Mounted beside the #74 admin panel.

Docs: DESIGN 5.9/6.1/6.2/7.4 record the round-1 shape and the no-bump
call. Gates: devbox run test, client-test, e2e green; bench recorded.
This commit is contained in:
2026-11-21 01:04:10 +01:00
parent 429f023c62
commit 0323fbd2ae
12 changed files with 1234 additions and 16 deletions
+20 -10
View File
@@ -1196,10 +1196,10 @@ settled by #49 (6.1, 8). Answers #41's open question: the *target's* height matt
cover rules (a rules-engine judgement, non-goal 1).
- **GM-only who-sees-it view [FIXED (owner decision), in v1, #44].** The GM can see, per token,
which player(s)/characters see it and its **visible fraction**: the share of the token's height
above the highest blocking sight line, 100 % when nothing is crossed (definition below). GM-only,
derived from data the GM already receives (all walls, all tokens, the `gm` props), so no
player-visible field is added; never on a player wire in any form. The panel's shape is M4
editor/fog work (7.4).
above the highest blocking sight line, 100 % when nothing is crossed (definition below). GM-only
and never on a player wire in any form. M4 ships the round-1 binary answer (0/100 %, no heights
yet) as `seen_by` on GM `token` frames, computed from each player's existing sight; the graded
fraction and the client's own derivation arrive with the heights round (7.4, #75).
- **Delegated knobs [FIXED (owner-delegated), #44].**
- Comparison strict, equality hidden, evaluated at every face of the wall the line crosses — 5.10
fixes the thick case (with zero thickness the faces coincide with the wall line, so this is
@@ -1684,7 +1684,7 @@ only.
| `wall_gone` | `scene, id` | GM only |
| `vision` | `polys:[{id:<token id>, pts:[[x,y],...]}]` integer px, the full set for this player's controlled tokens with `vision` | player only; never GM |
| `explored` | `full:true, rle:[[cy, x0, len, x0, len, ...], ...]` on connect and resync; `full:false, cells:[[cx,cy],...]` afterwards (fresh cells) [format PROPOSED, 6.4] | player only; never GM |
| `token` | `id, scene, name, pos, radius, mine, statuses:[{status}], props`; `name` = the one name this recipient may see (8), no reveal state; `radius` = effective px; `props` = only the buckets this recipient may read (public; plus owner for the controller; all three for GM). More for specific recipients: `statuses[].source` (GM only); `character_id` (GM, and a player who owns that character); `cprops:{public:{}}` the character's public props (player who does not own the character; `{}` for a plain token); `kind, controller (id or null), gm_only, flags, vision_radius, radius_own (number or null)` (GM); `vision_radius` also for the controller (the step cap, 5.5); plain tokens, GM: `descriptive_name, actual_name, reveal_all, revealed:[player ids]` | GM: all tokens; player: tokens they control, plus tokens inside own LOS and not `gm_only` (3.1). Whole view of one token per message |
| `token` | `id, scene, name, pos, radius, mine, statuses:[{status}], props`; `name` = the one name this recipient may see (8), no reveal state; `radius` = effective px; `props` = only the buckets this recipient may read (public; plus owner for the controller; all three for GM). More for specific recipients: `statuses[].source` (GM only); `character_id` (GM, and a player who owns that character); `cprops:{public:{}}` the character's public props (player who does not own the character; `{}` for a plain token); `kind, controller (id or null), gm_only, flags, vision_radius, radius_own (number or null)` (GM); `vision_radius` also for the controller (the step cap, 5.5); plain tokens, GM: `descriptive_name, actual_name, reveal_all, revealed:[player ids]`; `seen_by:[player ids]` (GM only, ascending; M4 who-sees-it, 7.4) | GM: all tokens; player: tokens they control, plus tokens inside own LOS and not `gm_only` (3.1). Whole view of one token per message |
| `token_gone` | `id` | a recipient who had it in their `known` table and no longer may see it (left LOS, removed, `gm_only` set, controller lost it). Never sent for a token the recipient never saw |
| `character` | GM: `id, owner, descriptive_name, actual_name, reveal_all, revealed:[player ids], props:{public,owner,gm}`. Owner (P): `id, descriptive_name, actual_name, props:{public,owner}`; the owner is never sent `reveal_all` or `revealed` | GM: every character; player: only the characters they own. No other player ever gets a character record (no browsable list, T16) |
| `character_gone` | `id` | GM; and the previous owner on reassign |
@@ -1708,7 +1708,10 @@ action caused it. A `walls`-sourced status still tells a viewer that some blocki
token; **CLOSED as accepted [FIXED (owner decision), 2026-11-17, `docs/ANALYSIS-review.md` D4]**: a
refused move already reveals the same fact, so this is a documented, accepted effect, not a leak to
fix. (7) `encountered.grey` flipping and `token`/`token_gone` carry the same fact (the token left
view), so deletion and moving away look identical to the player.
view), so deletion and moving away look identical to the player. (8) `seen_by` is GM-only: it names
the players whose sight sees the token, which is exactly the who-sees-it view (7.4). It never
reaches a player frame in any form; the leak checker bans the key outright, with a positive-control
fault build (#75).
### 6.2 Versioning [PROPOSED]
- `proto` is an integer compiled into both client and server. `proto = 1` is M3 as shipped. **`proto
@@ -1734,7 +1737,9 @@ view), so deletion and moving away look identical to the player.
+ `open` + `flags`. `2` (#49, 2026-11-17): the wall record's typed fields (`thickness`,
`position`, `height`, `label`, `player_marker`, the eight switches), `kind` output-only, and the
player `marker` message; the same build ships migration step 8, so a `proto` 1 client and a
migrated DB cannot be paired by accident.
migrated DB cannot be paired by accident. **No version after 2:** `seen_by` (#75, 2026-11-21) is
an additive optional field on GM `token` frames only, so the "additive only" rule above applies
and `proto` stays `2` [FIXED (owner-delegated), 2026-11-21, spec #63 decision 10].
### 6.3 Reconnect and resync
- Reconnect = full resync. After `hello` the server sends, in this order: `roster`; GM: `walls`,
@@ -1981,9 +1986,14 @@ Prototype `client/src/main.ts`: explored rects appended to a `Graphics` mask for
- Grid snap on drop: client option, off by default [FIXED, Q18]. Server accepts any in-bounds
position within the step cap and clear of walls (5.5; step cap = effective vision radius, Q18
FIXED).
- Who-sees-it view (GM only) [FIXED (owner decision), 2026-11-15, #44]: for each token, which
player(s)/characters see it and its visible fraction (5.9, 100 % when unobstructed). GM-only and
never on a player wire; the panel's shape belongs to the M4 editor/fog work.
- Who-sees-it view (GM only) [FIXED (owner decision), 2026-11-15, #44; M4 shape FIXED
(owner-delegated), 2026-11-21, #75]: for each token, which player(s) see it and its visible
fraction (5.9, 100 % when unobstructed). **M4 ships the round-1 binary form:** a panel row per
token lists the seeing players, 0 % when nobody sees it and 100 % otherwise; the graded fraction
waits for wall heights (ADR-0012). The server computes the list from each player's existing sight
(`PlayerVision.visibleTo`, no extra polygon pass) and sends it as `seen_by:[player ids]` on GM
`token` frames only (6.1, 6.2). It is never on a player wire in any form; the leak checker bans
the key.
### 7.5 Prediction and rollback for own moves
- Players do **not** know the walls, so the client cannot predict collisions [INFERRED, consequence