Files
FFF_vtt_frozen/tools/groups.mjs
T
SirStone 2727617db9 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).
2026-11-21 00:10:39 +01:00

129 lines
6.1 KiB
JavaScript

// The nine M3 acceptance groups of DESIGN 13 (FIXED by owner decision #12) and the test that proves
// each one. `devbox run test` runs every `tools/*.test.mjs`; this map is the checklist the finish
// line (#25) records in DESIGN 14.
//
// #36: an evidence entry is not a title substring. It names the test's exact title (a `${...}`
// placeholder marks a title the file builds per case), the minimum number of `assert.*` calls its
// body must keep, and any distinctive call the body must keep executing. `tools/groups.test.mjs`
// checks those against the source statically; the final step of `tools/test.sh` parses the Node
// test runner's reporter output and fails unless every registered title actually ran and passed
// (tools/evidence.mjs). A test hollowed out to its title, or one that is registered but never runs,
// therefore fails the gate.
export const GROUPS = {
'leak+fault': {
// The transcript checker and its negative controls, plus the two Walls r1 harnesses whose
// guarantees ride the same seam: the differential door equivalence (the `secretgap` control,
// #56) and the player marker group (#59/#60). #61's scenario rewrite keeps all of them green.
files: ['leak.test.mjs', 'fault.test.mjs', 'doors.test.mjs', 'markers.test.mjs'],
evidence: [
{ file: 'leak.test.mjs',
test: "leak test ${subject}: the subject's whole view matches the GM's truth",
minTests: 2, minAsserts: 8, requires: ['runChecker(transcript, subject)'] },
{ file: 'fault.test.mjs',
test: "fault ${fault}: caught as exactly ${expected.join(' ')}",
minAsserts: 2, requires: ['classesOf(check.output)'] },
{ file: 'doors.test.mjs',
test: 'fault secretgap: the equivalence group fails as exactly SECRETGAP',
minAsserts: 1, requires: ["equivalenceClasses(a, b), ['SECRETGAP']"] },
{ file: 'markers.test.mjs',
test: 'retraction: every cause sends del only, a re-earned marker gets a fresh id (#60)',
minAsserts: 12, requires: ['assertMarkerShape(seen)'] },
],
},
tiles: {
files: ['tiles.test.mjs', 'oneway.test.mjs'],
evidence: [
{ 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'] },
],
},
probing: {
files: ['probing.test.mjs'],
evidence: [
{ file: 'probing.test.mjs',
test: 'probing over WS: walls beyond cap + radius change no reply',
minAsserts: 3, requires: ['assert.deepEqual(shape(ra), shape(rb)'] },
],
},
protocol: {
files: ['protocol.test.mjs'],
evidence: [
{ file: 'protocol.test.mjs',
test: 'an unknown type is refused, unknown fields are ignored, and every intent gets one ack',
minAsserts: 6, requires: ['assert.equal'] },
],
},
auth: {
files: ['auth.test.mjs'],
evidence: [
{ 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': {
files: ['characters.test.mjs'],
evidence: [
{ file: 'characters.test.mjs',
test: 'encountered: a sighting is kept under the name the player knows, and survives everything',
minAsserts: 8, requires: ['encountered'] },
],
},
restart: {
files: ['restart.test.mjs'],
evidence: [
// #36: both variants take the baseline from the first (as-built) server, before the signal;
// the thin wrappers must keep calling the only code path that can prove it.
{ file: 'restart.test.mjs',
test: 'restart: full state, all CRUD, before and after SIGTERM',
minAsserts: 0, requires: ['restartGroup(false)'] },
{ file: 'restart.test.mjs',
test: 'restart: full state, all CRUD, before and after SIGKILL',
minAsserts: 0, requires: ['restartGroup(true)'] },
],
},
persistence: {
// The schema-7 fixture driven through the real binary (migration mapping, explored round trip)
// plus the behaviour-preservation pair: migrated walls vs the same walls authored through
// `wall.add`, byte-identical to a player (stories 29/30/77, #52).
files: ['persistence.test.mjs', 'wallbehaviour.test.mjs'],
evidence: [
{ file: 'persistence.test.mjs',
test: 'explored round trip: a fresh connection gets the whole grid the server accumulated',
minAsserts: 3, requires: ['exploredSnapshot(s.origin, alice)'] },
{ file: 'persistence.test.mjs',
test: 'migration: a schema-4 DB (fixture) migrates under the real binary to the latest schema',
minAsserts: 6, requires: ['assert.equal'] },
{ file: 'wallbehaviour.test.mjs',
test: 'behaviour preservation: a migrated schema-7 scene and the same scene authored via raw switches are byte-identical to a player',
minAsserts: 2, requires: ['assert.deepEqual'] },
],
},
logs: {
files: ['logs.test.mjs'],
evidence: [
{ file: 'logs.test.mjs',
test: 'logs: no key, session cookie or session hash reaches the log',
minAsserts: 8, requires: ['assert.equal'] },
],
},
}
export const GROUP_COUNT = 9