feat: session cache, explored bitmap and lock-free tile gate (#65)
The tile gate no longer takes dbLock or runs a SQL session JOIN per tile: a published in-memory view (server/sessions.nim) holds token hashes -> player/role and one explored bitmap per player. Sessions load from the DB at startup and are updated by join, key replacement and player removal in the same lock as the write; refreshed cells publish before the ack. The gate is one snapshot read (parse + session + bit test + redirect) over scalar data only, so a tile burst is answered while a mutation holds dbLock. Evidence: tests/tsessions.nim pins the cache/bitmap lifecycle and gate rule; tiles.test adds the lock-held burst and the revocation/restart seam; auth.test adds the LEAK_FAULT=sessioncache negative control (a stale entry makes the auth group fail); mutation c5 keeps the cache drop load-bearing. Explored wire and persistence untouched. Bench (devbox run bench, in-process): tile gate old 0.006 ms -> new 0.001 ms per request; incremental explored mark 0.001 ms; snapshot build 2.0 ms at 262144 cells (startup only).
This commit is contained in:
@@ -36,6 +36,13 @@ export const GROUPS = {
|
||||
{ file: 'tiles.test.mjs',
|
||||
test: 'tile gate: leak check (d) matches the independent explored oracle',
|
||||
minAsserts: 6, requires: ['oracle'] },
|
||||
// #65: off the global lock, and revocation/restart at the gate seam.
|
||||
{ file: 'tiles.test.mjs',
|
||||
test: 'tile gate: a burst is answered while a mutation holds the global lock (#65)',
|
||||
minAsserts: 4, requires: ['elapsed < 700'] },
|
||||
{ file: 'tiles.test.mjs',
|
||||
test: 'tile gate: revocation is immediate and sessions survive a restart (#65)',
|
||||
minAsserts: 6, requires: ['rawUpgrade'] },
|
||||
{ file: 'oneway.test.mjs',
|
||||
test: 'one-way sight: the blind side sees nothing across, the seeing side does (#58)',
|
||||
minAsserts: 12, requires: ['withOneWayStack'] },
|
||||
@@ -63,6 +70,11 @@ export const GROUPS = {
|
||||
{ file: 'auth.test.mjs',
|
||||
test: 'key.replace: old key and old sessions die, live connections close, the new key works',
|
||||
minAsserts: 6, requires: ['assert.notEqual'] },
|
||||
// #65: the session cache's negative control. A fault that keeps the revoked entry alive must
|
||||
// make the revocation assertion above fail (here: 101 where the clean build answers 401).
|
||||
{ file: 'auth.test.mjs',
|
||||
test: 'fault sessioncache: a revoked session kept alive fails the authentication group',
|
||||
minAsserts: 3, requires: ['rawUpgrade'] },
|
||||
],
|
||||
},
|
||||
'characters and names': {
|
||||
|
||||
Reference in New Issue
Block a user