name.reveal wrote the subject's actual name into the encountered row of every player who had met it: the SQL had no player predicate, so the leak was silent live and visible only after a restart. rewriteEncountered is now the one path that keeps a snapshot in step with its subject: it rewrites the SQLite row and the live in-memory entry together from the name rule, takes onlyPlayer for name.reveal (every player for reveal_all), and also runs on a rename, a link change and an owner change, so the wire and a post-restart reload cannot disagree (#30). The DB-only renameEncountered*/revealEncountered* helpers are gone, which is what let the two stores drift. token.update {character_id} now drops the token's own two names as part of the link patch (#29): a plain token can be linked, names supplied with a link stay invalid and unlinking still needs both names. Tests: tcharacters covers the per-player row, the DB/memory equality, the link handover; restart.test.mjs builds three named players, reveals to one of them and asserts the rows directly and the whole resync over SIGTERM/SIGKILL, plus a mid-session rename; leak.mjs/leakcheck.nim pit two players on the same subject and pin each entry's expected name (STALE_NAME). Mutations e1-e3 and the repointed b2 pin the three rules.
This commit is contained in:
+13
-5
@@ -20,6 +20,8 @@
|
||||
## GM_PROP the `gm` property bucket reached a player at all
|
||||
## STATUS_SOURCE a player frame carried the `source` of a status (5.5, 6.1 note 6)
|
||||
## ACTUAL_NAME an actual name the subject was never told reached it (8)
|
||||
## STALE_NAME an encountered entry names a subject something other than the name that player
|
||||
## knows (8): a stale snapshot the old "not the unrevealed actual" check let pass
|
||||
## CHAR_LIST another player's character record or encountered entry reached the subject
|
||||
## CONTROLLER_CHANGE a token changed controller in a group that asked for no such thing (8)
|
||||
## CHAR_OWNER_PROP a character's owner bucket reached a player who does not own it (8)
|
||||
@@ -487,11 +489,17 @@ proc main() =
|
||||
fail "CHAR_LIST", "encountered entry the subject never saw: " & id
|
||||
elif truth.tokens.hasKey(id):
|
||||
let (dname, aname) = subjectNames(truth, truth.tokens[id])
|
||||
# Only a *different* name leaks: a subject whose two names are the same string has no
|
||||
# secret to keep.
|
||||
if aname != dname and e["name"].getStr == aname and
|
||||
not subjectKnewActual(truth, truth.tokens[id], me):
|
||||
fail "ACTUAL_NAME", "encountered " & id & " carries an unrevealed actual name"
|
||||
let knows = subjectKnewActual(truth, truth.tokens[id], me)
|
||||
# The expected name, not merely "not the unrevealed actual": a stale snapshot that still
|
||||
# carries an old descriptive name is a bug the old check could not see (#30).
|
||||
let want = if knows: aname else: dname
|
||||
let got = e["name"].getStr
|
||||
if got != want:
|
||||
if aname != dname and got == aname:
|
||||
fail "ACTUAL_NAME", "encountered " & id & " carries an unrevealed actual name"
|
||||
else:
|
||||
fail "STALE_NAME", "encountered " & id & " has name " & got & " not " & want &
|
||||
" (group " & g.label & ")"
|
||||
if m.hasKey("del"):
|
||||
for d in m["del"]:
|
||||
if d.getStr notin encounterable:
|
||||
|
||||
Reference in New Issue
Block a user