Renaming a character or a plain token updates the persisted encountered snapshots in SQLite but not the in-memory ones. Every affected player's encountered list keeps serving the old name until the server restarts, at which point it jumps to the new one. That is the same snapshot the reveal path maintains, so the two handlers disagree about who owns the in-memory copy.
server/main.nim:1139-1140 — token.update calls renameEncounteredToken under the same conditions; same gap. Both go through server/characters.nimrenameEncountered*, which is DB-only.
server/characters.nimrenameEncountered / renameEncounteredToken — the unrevealed-actual rule is encoded as SQL (actual_name <> ''), so the in-memory path has no equivalent to mirror.
tools/leakcheck.nim:483-495 — the encountered check only rejects a name equal to an unrevealed actual name; it never asserts the entry carries the expected descriptive name, so a stale name passes.
Failure scenario
Verified on the real binary: a plain token is "a wolf" and Bob has met it. The GM renames it to "a huge wolf". Bob's live encountered list still shows "a wolf" (a stale descriptive name, which is exactly the leak the snapshot exists to prevent); after a restart it shows "a huge wolf". The inverse case matters too: rename to a name the player should not know, and the live wire keeps the old one until restart — so DB and memory disagree in both directions, and the leak check cannot tell.
Confidence
High — verified live vs after-restart; the DB-only writes are plain to see.
Fix direction
One rename path that updates both stores together: a helper that, given the subject's new names, rewrites the DB rows and every in-memory encountered entry for that subject, applying the "unrevealed actual stays unknown" rule in the same place for both. Called from character.update and token.update; the reveal path should use the same helper shape so the two can't drift again.
Acceptance
Renaming a character or plain token changes the affected players' encountered names on the wire immediately, with no restart, and the value equals what the DB holds after a restart.
A player who has not been told the actual name keeps the descriptive name through a rename.
Renaming to a longer/shorter name does not change which entries exist (no entry added or removed).
tools/leakcheck.nim pins the expected name for an encountered entry (not just "not the unrevealed actual"), so a stale name fails.
Regression test: a test that renames mid-session, asserts the live encountered frame, restarts, and asserts the same value; plus a leakcheck assertion for the expected name.
## Summary
Renaming a character or a plain token updates the persisted `encountered` snapshots in SQLite but not the in-memory ones. Every affected player's encountered list keeps serving the old name until the server restarts, at which point it jumps to the new one. That is the same snapshot the reveal path maintains, so the two handlers disagree about who owns the in-memory copy.
## Where
- `server/main.nim:1536-1537` — `character.update` calls `renameEncountered` inside a transaction; nothing touches `app.encountered`.
- `server/main.nim:1139-1140` — `token.update` calls `renameEncounteredToken` under the same conditions; same gap. Both go through `server/characters.nim` `renameEncountered*`, which is DB-only.
- `server/characters.nim` `renameEncountered` / `renameEncounteredToken` — the unrevealed-actual rule is encoded as SQL (`actual_name <> ''`), so the in-memory path has no equivalent to mirror.
- `tools/leakcheck.nim:483-495` — the encountered check only rejects a name equal to an *unrevealed* actual name; it never asserts the entry carries the expected descriptive name, so a stale name passes.
## Failure scenario
Verified on the real binary: a plain token is "a wolf" and Bob has met it. The GM renames it to "a huge wolf". Bob's live encountered list still shows "a wolf" (a stale descriptive name, which is exactly the leak the snapshot exists to prevent); after a restart it shows "a huge wolf". The inverse case matters too: rename to a name the player should not know, and the live wire keeps the old one until restart — so DB and memory disagree in both directions, and the leak check cannot tell.
## Confidence
High — verified live vs after-restart; the DB-only writes are plain to see.
## Fix direction
One rename path that updates both stores together: a helper that, given the subject's new names, rewrites the DB rows *and* every in-memory encountered entry for that subject, applying the "unrevealed actual stays unknown" rule in the same place for both. Called from `character.update` and `token.update`; the reveal path should use the same helper shape so the two can't drift again.
## Acceptance
- Renaming a character or plain token changes the affected players' encountered names on the wire immediately, with no restart, and the value equals what the DB holds after a restart.
- A player who has not been told the actual name keeps the descriptive name through a rename.
- Renaming to a longer/shorter name does not change which entries exist (no entry added or removed).
- `tools/leakcheck.nim` pins the expected name for an encountered entry (not just "not the unrevealed actual"), so a stale name fails.
- Regression test: a test that renames mid-session, asserts the live encountered frame, restarts, and asserts the same value; plus a leakcheck assertion for the expected name.
## Related
- #23 (slice 8: characters and names).
- #2 (M3 planning map).
Fix — one rename path that updates both stores: server/characters.nimrewriteEncountered recomputes each matching snapshot from the 8 name rule (SubjectNames + Reveals) and writes the SQLite row and the in-memory entry together. It is called from character.update, a plain-token rename in token.update, name.reveal/name.reveal_all, and also on a link change and a character.reassign (an owner change alters who is told the actual name). The DB-only renameEncountered*/revealEncountered* helpers are gone, so the two stores cannot drift again; a rename never adds or removes an entry, and a player who was not told the actual name keeps the descriptive one.
Regression test (red -> green) — tools/restart.test.mjs, new test "a mid-session rename reaches the live encountered list (#30)": two connected players, a plain token and a character-linked token; rename both mid-session.
old code: the token frame changes to a huge wolf, but no encountered frame arrives (live list keeps the old name) — the test times out waiting for it.
after: both players get encountered {set:[{name:"a huge wolf"}]} and Bob gets name:"a tall stranger" for the character (Alice owns it and keeps Lady Vex); after a restart the same names come back from disk, per player.
tools/leakcheck.nim now pins the expected name for every encountered entry instead of only rejecting an unrevealed actual: a stale descriptive name is a new STALE_NAME failure (old check could not see it). The leak scenario walks a second player into the room so both transcripts carry the snapshot across the rename/reveal groups.
Gates — devbox run test: 107/107 node tests + all Nim suites pass; devbox run mutation: exit 0, with e2 ("an encountered rewrite updates the DB only") failing exactly the new test and the repointed b2 ("an encountered rename overwrites a secret") still caught.
Fixed and pushed on `main`.
**Fix** — one rename path that updates both stores: `server/characters.nim` `rewriteEncountered` recomputes each matching snapshot from the 8 name rule (`SubjectNames` + `Reveals`) and writes the SQLite row **and** the in-memory entry together. It is called from `character.update`, a plain-token rename in `token.update`, `name.reveal`/`name.reveal_all`, and also on a link change and a `character.reassign` (an owner change alters who is told the actual name). The DB-only `renameEncountered*`/`revealEncountered*` helpers are gone, so the two stores cannot drift again; a rename never adds or removes an entry, and a player who was not told the actual name keeps the descriptive one.
**Regression test (red -> green)** — `tools/restart.test.mjs`, new test "a mid-session rename reaches the live encountered list (#30)": two connected players, a plain token and a character-linked token; rename both mid-session.
- old code: the `token` frame changes to `a huge wolf`, but **no `encountered` frame arrives** (live list keeps the old name) — the test times out waiting for it.
- after: both players get `encountered {set:[{name:"a huge wolf"}]}` and Bob gets `name:"a tall stranger"` for the character (Alice owns it and keeps `Lady Vex`); after a restart the same names come back from disk, per player.
`tools/leakcheck.nim` now pins the **expected** name for every encountered entry instead of only rejecting an unrevealed actual: a stale descriptive name is a new `STALE_NAME` failure (old check could not see it). The leak scenario walks a second player into the room so both transcripts carry the snapshot across the rename/reveal groups.
**Commits** — `8e045b0` (fix, tests, leakcheck); `b4bddf1` design (6.1: one rewrite path); `e13fa90` results.
**Gates** — `devbox run test`: 107/107 node tests + all Nim suites pass; `devbox run mutation`: exit 0, with `e2` ("an encountered rewrite updates the DB only") failing exactly the new test and the repointed `b2` ("an encountered rename overwrites a secret") still caught.
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
Renaming a character or a plain token updates the persisted
encounteredsnapshots in SQLite but not the in-memory ones. Every affected player's encountered list keeps serving the old name until the server restarts, at which point it jumps to the new one. That is the same snapshot the reveal path maintains, so the two handlers disagree about who owns the in-memory copy.Where
server/main.nim:1536-1537—character.updatecallsrenameEncounteredinside a transaction; nothing touchesapp.encountered.server/main.nim:1139-1140—token.updatecallsrenameEncounteredTokenunder the same conditions; same gap. Both go throughserver/characters.nimrenameEncountered*, which is DB-only.server/characters.nimrenameEncountered/renameEncounteredToken— the unrevealed-actual rule is encoded as SQL (actual_name <> ''), so the in-memory path has no equivalent to mirror.tools/leakcheck.nim:483-495— the encountered check only rejects a name equal to an unrevealed actual name; it never asserts the entry carries the expected descriptive name, so a stale name passes.Failure scenario
Verified on the real binary: a plain token is "a wolf" and Bob has met it. The GM renames it to "a huge wolf". Bob's live encountered list still shows "a wolf" (a stale descriptive name, which is exactly the leak the snapshot exists to prevent); after a restart it shows "a huge wolf". The inverse case matters too: rename to a name the player should not know, and the live wire keeps the old one until restart — so DB and memory disagree in both directions, and the leak check cannot tell.
Confidence
High — verified live vs after-restart; the DB-only writes are plain to see.
Fix direction
One rename path that updates both stores together: a helper that, given the subject's new names, rewrites the DB rows and every in-memory encountered entry for that subject, applying the "unrevealed actual stays unknown" rule in the same place for both. Called from
character.updateandtoken.update; the reveal path should use the same helper shape so the two can't drift again.Acceptance
tools/leakcheck.nimpins the expected name for an encountered entry (not just "not the unrevealed actual"), so a stale name fails.Related
Fixed and pushed on
main.Fix — one rename path that updates both stores:
server/characters.nimrewriteEncounteredrecomputes each matching snapshot from the 8 name rule (SubjectNames+Reveals) and writes the SQLite row and the in-memory entry together. It is called fromcharacter.update, a plain-token rename intoken.update,name.reveal/name.reveal_all, and also on a link change and acharacter.reassign(an owner change alters who is told the actual name). The DB-onlyrenameEncountered*/revealEncountered*helpers are gone, so the two stores cannot drift again; a rename never adds or removes an entry, and a player who was not told the actual name keeps the descriptive one.Regression test (red -> green) —
tools/restart.test.mjs, new test "a mid-session rename reaches the live encountered list (#30)": two connected players, a plain token and a character-linked token; rename both mid-session.tokenframe changes toa huge wolf, but noencounteredframe arrives (live list keeps the old name) — the test times out waiting for it.encountered {set:[{name:"a huge wolf"}]}and Bob getsname:"a tall stranger"for the character (Alice owns it and keepsLady Vex); after a restart the same names come back from disk, per player.tools/leakcheck.nimnow pins the expected name for every encountered entry instead of only rejecting an unrevealed actual: a stale descriptive name is a newSTALE_NAMEfailure (old check could not see it). The leak scenario walks a second player into the room so both transcripts carry the snapshot across the rename/reveal groups.Commits —
8e045b0(fix, tests, leakcheck);b4bddf1design (6.1: one rewrite path);e13fa90results.Gates —
devbox run test: 107/107 node tests + all Nim suites pass;devbox run mutation: exit 0, withe2("an encountered rewrite updates the DB only") failing exactly the new test and the repointedb2("an encountered rename overwrites a secret") still caught.