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:
+10
-3
@@ -22,6 +22,10 @@
|
||||
# az: in-use not enforced | b1: player.remove forgets the characters | b2: an encountered rename
|
||||
# overwrites a name the player never knew | b3: cprops carries the character owner bucket |
|
||||
# b4: a player is sent every character
|
||||
# #27/#29/#30: the per-player reveal scope, the link patch's name handover and the live
|
||||
# snapshot update. e1: a reveal rewrites every player's snapshot (the old subject-only
|
||||
# SQL) | e2: the encountered rewrite updates the DB but not memory (live list stale) |
|
||||
# e3: a link patch keeps the plain token's own names (every link attempt is invalid)
|
||||
# slice 9 (#24): the canonical tile URL and the "any explored cell allows" gate
|
||||
# c1: a tile is allowed without any explored cell | c2: every overlapping cell is required
|
||||
# c3: an out-of-grid coordinate is accepted | c4: a leading-zero coordinate is canonical
|
||||
@@ -139,7 +143,7 @@ run y "wall endpoints unchecked against the world bounds" server/world.nim 's/p\
|
||||
run z "door.set accepted on a plain wall" server/world.nim '/if sc.walls\[idx.get\].kind != wkDoor: return waNotDoor/d' "wrong kinds are their own"
|
||||
run z2 "persisted open state loaded inverted" server/world.nim 's/open: row\[6\] == "1",/open: row[6] == "0",/' "round-trip through a reload"
|
||||
# slice 5 (#20): the view rule, the egress diff and the explored set
|
||||
run aa "the egress ignores LOS, gm_only and ownership" server/views.nim 's/^ if not pv\.visibleTo(t, playerId): continue$/ if false: continue/' "$AA"
|
||||
run aa "the egress ignores LOS, gm_only and ownership" server/views.nim 's/^ if not pv\[\]\.visibleTo(t, playerId): continue$/ if false: continue/' "$AA"
|
||||
run ab "gm_only ignored by the view rule" server/vision.nim '/^ if t\.gmOnly: return false$/d' "$AB"
|
||||
run ac "a controlled token is not always visible" server/vision.nim '/^ if t\.owner == playerId: return true$/d' "$AC"
|
||||
run ad "no token_gone when a token leaves the view" server/views.nim 's/^ result\.add tokenGoneFrame(id)$/ discard/' "$AD"
|
||||
@@ -170,9 +174,12 @@ run ax "a rename tells a player an actual name it never knew" server/characters.
|
||||
run ay "a linked token may keep its own names" server/tokens.nim 's/ if t\.characterId\.isSome: t\.descriptiveName\.len == 0/ if false: t.descriptiveName.len == 0/' "a linked token carries no names"
|
||||
run az "in-use is not enforced" server/characters.nim 's/^ if t\.characterId\.isSome and t\.characterId\.get == characterId: inc result$/ discard/' "a character still figured by a token is in use"
|
||||
run b1 "player.remove forgets the characters" server/characters.nim 's/WHERE owner_player_id = ?", gmId, playerId)/WHERE owner_player_id = ? AND 0", gmId, playerId)/' "hands the player"
|
||||
run b2 "an encountered rename overwrites a secret" server/characters.nim 's/AND actual_name <> .."""/AND 1 = 1"""/' "a character rename follows the snapshots"
|
||||
run b2 "an encountered rename overwrites a secret" server/characters.nim 's/actualName: (if knows: some(n\.actual) else: none(string))/actualName: some(n.actual)/' "a character rename"
|
||||
run b3 "cprops carries the character owner bucket" server/views.nim 's/cpropsPublic: objectOf(if ch\.isSome and not ownsCharacter: ch\.get\.props\[pbPublic\]/cpropsPublic: objectOf(if ch.isSome and not ownsCharacter: ch.get.props[pbOwner]/' "cprops carries the character"
|
||||
run b4 "a player is sent every character" server/views.nim 's/ if c\.owner != playerId: continue/ if false: continue/' "a player gets only its own characters"
|
||||
run e1 "an encountered rewrite ignores what the player knows" server/characters.nim 's/let updated = e\.refreshed(n, knowsActual(/let updated = e.refreshed(n, true or knowsActual(/' "a link change moves the snapshot"
|
||||
run e2 "an encountered rewrite updates the DB only" server/characters.nim 's/^ enc\[pid\]\[e\.entityId\] = e$/ discard/' "a character rename rewrites the live snapshots"
|
||||
run e3 "a link patch keeps the token's own names" server/tokens.nim 's/^ if result\.characterId\.isSome:$/ if false:/' "linking through a patch hands the names over"
|
||||
# slice 9 (#24): the tile URL grammar and the access rule (server/tiles.nim)
|
||||
TILE_GATE="an unexplored tile is refused|a tile is allowed when any overlapping cell"
|
||||
TILE_ZERO="leading zero tile coordinates"
|
||||
@@ -186,7 +193,7 @@ run d3 "scene.set accepts a patch with no field" server/world.nim 's/^ if not a
|
||||
wait
|
||||
|
||||
rc=0; : > "$LOG"
|
||||
for id in control a b c d1 d2 d3 e f g h i j k l m n o p q r s t u v w x y z z2 aa ab ac ad ae af ag ah ai aj ak al am an ao ap aq ar as at au av aw ax ay az b1 b2 b3 b4 c1 c2 c3 c4; do
|
||||
for id in control a b c d1 d2 d3 e e1 e2 e3 f g h i j k l m n o p q r s t u v w x y z z2 aa ab ac ad ae af ag ah ai aj ak al am an ao ap aq ar as at au av aw ax ay az b1 b2 b3 b4 c1 c2 c3 c4; do
|
||||
[ -f "$T/$id/res" ] && cat "$T/$id/res" >> "$LOG"
|
||||
if [ -f "$T/$id/verdict" ]; then tee -a "$LOG" < "$T/$id/verdict"; [ "$(cat "$T/$id/rc")" = 0 ] || rc=1
|
||||
else echo "$id: NO RESULT (job killed?)" | tee -a "$LOG"; rc=1; fi
|
||||
|
||||
Reference in New Issue
Block a user