name.reveal reveals a subject's actual name to one player, but its SQLite snapshot write updates the encountered row of every player who has met that subject. The in-memory snapshot update is correctly per player, so the bug is invisible until a restart reloads encountered from disk. Afterwards every other player's encountered list carries the subject's actual name, which they were never given: the descriptive name / actual name split and the encountered-list rule ("under the name that player knows") both break.
Where
server/main.nim:1667-1669 — the reveal path calls revealEncountered / revealEncounteredToken with no player id.
server/characters.nim:282-286 — UPDATE encountered SET actual_name = ? WHERE character_id = ? and ... WHERE entity_id = ?: the row is selected by subject only, never by player.
server/main.nim:1670-1674 — the in-memory path, which is correctly keyed by player. The two paths disagree, and the leaking one persists.
server/main.nim:1682+ — name.reveal_all shares the same helpers, so the fix must keep its all-players semantics.
Failure scenario
Reproduced on the real binary: Bob's encountered list shows "a cloaked figure". The GM runs name.reveal for Alice only. Both live views are correct (Alice: "Lady Vex", Bob: "a cloaked figure"). After a server restart, Bob's encountered entry reads "Lady Vex". Restarting again does not undo it. Bob never triggered anything; the leak is persistent and silent.
Missed by tests because tools/leakcheck.nim only inspects the live transcript, and the restart group has a single named player, so no second encountered list exists to be wrong.
Confidence
High — reproduces deterministically on the real binary; the SQL has no player predicate.
Fix direction
The persisted reveal must be scoped to the revealing player: the encountered write takes the player id as well as the subject, or the DB update is derived from the already-correct in-memory per-player snapshot instead of recomputing from the subject alone. Keep a separate all-players write for name.reveal_all so neither call silently inherits the other's scope.
Acceptance
After name.reveal to one player and a restart, that player's encountered entry shows the actual name and every other player's entry still shows the descriptive name.
name.reveal_all still reveals to every player who has an entry, before and after a restart.
With three players who have met the same token, exactly one encountered row changes (asserted directly against the DB, and via restart).
Regression test: extend tools/restart.test.mjs (and the leak-test restart group) so at least two named players meet the same character or plain token, one player is revealed to, then the server restarts and both players' encountered lists are compared. Extend tools/leakcheck.nim so a restart group with more than one player compares each subject's encountered names against truth.
Related
#23 (slice 8: characters and names), where reveal landed.
## Summary
`name.reveal` reveals a subject's actual name to **one** player, but its SQLite snapshot write updates the `encountered` row of **every** player who has met that subject. The in-memory snapshot update is correctly per player, so the bug is invisible until a restart reloads `encountered` from disk. Afterwards every other player's encountered list carries the subject's actual name, which they were never given: the descriptive name / actual name split and the encountered-list rule ("under the name that player knows") both break.
## Where
- `server/main.nim:1667-1669` — the reveal path calls `revealEncountered` / `revealEncounteredToken` with no player id.
- `server/characters.nim:282-286` — `UPDATE encountered SET actual_name = ? WHERE character_id = ?` and `... WHERE entity_id = ?`: the row is selected by subject only, never by player.
- `server/main.nim:1670-1674` — the in-memory path, which *is* correctly keyed by `player`. The two paths disagree, and the leaking one persists.
- `server/main.nim:1682+` — `name.reveal_all` shares the same helpers, so the fix must keep its all-players semantics.
## Failure scenario
Reproduced on the real binary: Bob's encountered list shows "a cloaked figure". The GM runs `name.reveal` for Alice only. Both live views are correct (Alice: "Lady Vex", Bob: "a cloaked figure"). After a server restart, Bob's encountered entry reads "Lady Vex". Restarting again does not undo it. Bob never triggered anything; the leak is persistent and silent.
Missed by tests because `tools/leakcheck.nim` only inspects the live transcript, and the restart group has a single named player, so no second encountered list exists to be wrong.
## Confidence
High — reproduces deterministically on the real binary; the SQL has no player predicate.
## Fix direction
The persisted reveal must be scoped to the revealing player: the encountered write takes the player id as well as the subject, or the DB update is derived from the already-correct in-memory per-player snapshot instead of recomputing from the subject alone. Keep a separate all-players write for `name.reveal_all` so neither call silently inherits the other's scope.
## Acceptance
- After `name.reveal` to one player and a restart, that player's encountered entry shows the actual name and every other player's entry still shows the descriptive name.
- `name.reveal_all` still reveals to every player who has an entry, before and after a restart.
- With three players who have met the same token, exactly one `encountered` row changes (asserted directly against the DB, and via restart).
- Regression test: extend `tools/restart.test.mjs` (and the leak-test restart group) so at least two named players meet the same character or plain token, one player is revealed to, then the server restarts and both players' encountered lists are compared. Extend `tools/leakcheck.nim` so a restart group with more than one player compares each subject's encountered names against truth.
## Related
- #23 (slice 8: characters and names), where reveal landed.
- #2 (M3 planning map).
Fix — server/characters.nim: rewriteEncountered is now the single path that keeps an encountered snapshot in step with its subject. It takes the subject's SubjectNames plus the reveal set, applies the 8 name rule per player, and rewrites the SQLite row and the in-memory entry together; onlyPlayer scopes the whole rewrite, so name.reveal writes exactly one player's row and name.reveal_all every player's. server/main.nim: name.reveal calls it with onlyPlayer = player inside one lock hold; name.reveal_all keeps all-players scope. The old subject-only revealEncountered* SQL is gone.
Regression test (red -> green) — tools/restart.test.mjs now builds three named players who all meet the same monster and the same character-linked token, reveals the character's actual name to Alice only and the monster's to Bob only, and asserts directly against the DB while the server runs:
AssertionError: 'Grib' !== '' // Alice's encountered row for the monster, OLD code
After the fix the three rows are bob=Grib, alice='', carol='' (and the mirrored character case). Every player's whole 6.3 resync is then compared over SIGTERM and SIGKILL against both the pre-restart value and an independent expected-name oracle, so a leak cannot hide behind two equally wrong snapshots. tools/leakcheck.nim gained STALE_NAME (an entry must carry the name that player knows) and tools/leak.mjs now walks a second player into the room so two encountered lists are checked per transcript.
Commits — 8e045b0 names: per-player reveal, one encountered write path, link by update (#27, #29, #30); b4bddf1 design: record the #27-#31 rules (6.1/4.3/10.3/14); e13fa90 results: rerun the gates.
Gates — devbox run test: all Nim suites + 107 node tests pass. devbox run mutation: exit 0, control and every mutation pass (new e1 pins the per-player knowledge scope, e2 the live snapshot write, plus repointed b2).
Fixed and pushed on `main`.
**Fix** — `server/characters.nim`: `rewriteEncountered` is now the single path that keeps an `encountered` snapshot in step with its subject. It takes the subject's `SubjectNames` plus the reveal set, applies the 8 name rule per player, and rewrites the SQLite row **and** the in-memory entry together; `onlyPlayer` scopes the whole rewrite, so `name.reveal` writes exactly one player's row and `name.reveal_all` every player's. `server/main.nim`: `name.reveal` calls it with `onlyPlayer = player` inside one lock hold; `name.reveal_all` keeps all-players scope. The old subject-only `revealEncountered*` SQL is gone.
**Regression test (red -> green)** — `tools/restart.test.mjs` now builds **three named players** who all meet the same monster and the same character-linked token, reveals the character's actual name to Alice only and the monster's to Bob only, and asserts directly against the DB while the server runs:
```
AssertionError: 'Grib' !== '' // Alice's encountered row for the monster, OLD code
```
After the fix the three rows are `bob=Grib`, `alice=''`, `carol=''` (and the mirrored character case). Every player's whole 6.3 resync is then compared over SIGTERM and SIGKILL against both the pre-restart value and an independent expected-name oracle, so a leak cannot hide behind two equally wrong snapshots. `tools/leakcheck.nim` gained `STALE_NAME` (an entry must carry the name that player knows) and `tools/leak.mjs` now walks a second player into the room so two encountered lists are checked per transcript.
**Commits** — `8e045b0` names: per-player reveal, one encountered write path, link by update (#27, #29, #30); `b4bddf1` design: record the #27-#31 rules (6.1/4.3/10.3/14); `e13fa90` results: rerun the gates.
**Gates** — `devbox run test`: all Nim suites + 107 node tests pass. `devbox run mutation`: exit 0, control and every mutation pass (new `e1` pins the per-player knowledge scope, `e2` the live snapshot write, plus repointed `b2`).
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
name.revealreveals a subject's actual name to one player, but its SQLite snapshot write updates theencounteredrow of every player who has met that subject. The in-memory snapshot update is correctly per player, so the bug is invisible until a restart reloadsencounteredfrom disk. Afterwards every other player's encountered list carries the subject's actual name, which they were never given: the descriptive name / actual name split and the encountered-list rule ("under the name that player knows") both break.Where
server/main.nim:1667-1669— the reveal path callsrevealEncountered/revealEncounteredTokenwith no player id.server/characters.nim:282-286—UPDATE encountered SET actual_name = ? WHERE character_id = ?and... WHERE entity_id = ?: the row is selected by subject only, never by player.server/main.nim:1670-1674— the in-memory path, which is correctly keyed byplayer. The two paths disagree, and the leaking one persists.server/main.nim:1682+—name.reveal_allshares the same helpers, so the fix must keep its all-players semantics.Failure scenario
Reproduced on the real binary: Bob's encountered list shows "a cloaked figure". The GM runs
name.revealfor Alice only. Both live views are correct (Alice: "Lady Vex", Bob: "a cloaked figure"). After a server restart, Bob's encountered entry reads "Lady Vex". Restarting again does not undo it. Bob never triggered anything; the leak is persistent and silent.Missed by tests because
tools/leakcheck.nimonly inspects the live transcript, and the restart group has a single named player, so no second encountered list exists to be wrong.Confidence
High — reproduces deterministically on the real binary; the SQL has no player predicate.
Fix direction
The persisted reveal must be scoped to the revealing player: the encountered write takes the player id as well as the subject, or the DB update is derived from the already-correct in-memory per-player snapshot instead of recomputing from the subject alone. Keep a separate all-players write for
name.reveal_allso neither call silently inherits the other's scope.Acceptance
name.revealto one player and a restart, that player's encountered entry shows the actual name and every other player's entry still shows the descriptive name.name.reveal_allstill reveals to every player who has an entry, before and after a restart.encounteredrow changes (asserted directly against the DB, and via restart).tools/restart.test.mjs(and the leak-test restart group) so at least two named players meet the same character or plain token, one player is revealed to, then the server restarts and both players' encountered lists are compared. Extendtools/leakcheck.nimso a restart group with more than one player compares each subject's encountered names against truth.Related
Fixed and pushed on
main.Fix —
server/characters.nim:rewriteEncounteredis now the single path that keeps anencounteredsnapshot in step with its subject. It takes the subject'sSubjectNamesplus the reveal set, applies the 8 name rule per player, and rewrites the SQLite row and the in-memory entry together;onlyPlayerscopes the whole rewrite, soname.revealwrites exactly one player's row andname.reveal_allevery player's.server/main.nim:name.revealcalls it withonlyPlayer = playerinside one lock hold;name.reveal_allkeeps all-players scope. The old subject-onlyrevealEncountered*SQL is gone.Regression test (red -> green) —
tools/restart.test.mjsnow builds three named players who all meet the same monster and the same character-linked token, reveals the character's actual name to Alice only and the monster's to Bob only, and asserts directly against the DB while the server runs:After the fix the three rows are
bob=Grib,alice='',carol=''(and the mirrored character case). Every player's whole 6.3 resync is then compared over SIGTERM and SIGKILL against both the pre-restart value and an independent expected-name oracle, so a leak cannot hide behind two equally wrong snapshots.tools/leakcheck.nimgainedSTALE_NAME(an entry must carry the name that player knows) andtools/leak.mjsnow walks a second player into the room so two encountered lists are checked per transcript.Commits —
8e045b0names: per-player reveal, one encountered write path, link by update (#27, #29, #30);b4bddf1design: record the #27-#31 rules (6.1/4.3/10.3/14);e13fa90results: rerun the gates.Gates —
devbox run test: all Nim suites + 107 node tests pass.devbox run mutation: exit 0, control and every mutation pass (newe1pins the per-player knowledge scope,e2the live snapshot write, plus repointedb2).