@@ -13,3 +13,4 @@ tools/mkcorpus
|
|||||||
run/
|
run/
|
||||||
# node-test.log carries per-run durations; regenerate it, do not commit it
|
# node-test.log carries per-run durations; regenerate it, do not commit it
|
||||||
results/node-test.log
|
results/node-test.log
|
||||||
|
.cache-nim*/
|
||||||
|
|||||||
+8
-3
@@ -464,7 +464,12 @@ from the prototype, what was missing, what the M3 build added, and the tools it
|
|||||||
switch, a lost `window` or a geometry move retract it (the oracle drops the entry when the GM's
|
switch, a lost `window` or a geometry move retract it (the oracle drops the entry when the GM's
|
||||||
wall frame shows the cause changed, mirroring the server). An extra marker at a candidate's anchor
|
wall frame shows the cause changed, mirroring the server). An extra marker at a candidate's anchor
|
||||||
before its extent was seen is `MARKER_EARLY`; an extra marker with no candidate wall is
|
before its extent was seen is `MARKER_EARLY`; an extra marker with no candidate wall is
|
||||||
`MARKER_EXTRA`; an expected marker never sent is `MARKER_OFF`. Faults `MARKER_EARLY`,
|
`MARKER_EXTRA`; an expected marker never sent is `MARKER_OFF`. The oracle keys a sent marker id by
|
||||||
|
the GM-truth wall it belongs to (resolved by anchor), never by the anchor alone, so two candidate
|
||||||
|
walls that share a midpoint remain two obligations. Marker ids are stable across refreshes: a
|
||||||
|
`set` that re-mints a wall's marker while its old id is still live is `PROTOCOL` — the four marker
|
||||||
|
classes describe the emission gate, while id stability is a frame invariant (5.8: minted once,
|
||||||
|
fresh only after a retraction). Faults `MARKER_EARLY`,
|
||||||
`MARKER_EXTRA`, `MARKER_OFF` (`markerEarly`/`markerExtra`/`markerOff`) are built and asserted as
|
`MARKER_EXTRA`, `MARKER_OFF` (`markerEarly`/`markerExtra`/`markerOff`) are built and asserted as
|
||||||
exactly their own class by `tools/fault.test.mjs`, with the scenario's far unseen marked window
|
exactly their own class by `tools/fault.test.mjs`, with the scenario's far unseen marked window
|
||||||
and marked solid wall as the negative controls. The WS group `tools/markers.test.mjs` proves the
|
and marked solid wall as the negative controls. The WS group `tools/markers.test.mjs` proves the
|
||||||
@@ -595,8 +600,8 @@ from the prototype, what was missing, what the M3 build added, and the tools it
|
|||||||
|
|
||||||
**Rule:** DESIGN §13 (milestones and their accept criteria).
|
**Rule:** DESIGN §13 (milestones and their accept criteria).
|
||||||
|
|
||||||
- **M3 accept result.** Measured 2026-11-15: `devbox run test` exit 0 (Nim suite all pass; 103 Node
|
- **M3 accept result.** Measured 2026-11-20: `devbox run test` exit 0 (Nim suite all pass; 142 Node
|
||||||
harness tests) and `devbox run mutation` exit 0 (control passes, all 63 mutations fail at least one
|
harness tests) and `devbox run mutation` exit 0 (control passes, all 73 mutations fail at least one
|
||||||
expected test). The nine groups map to their proving tests in `tools/groups.mjs`;
|
expected test). The nine groups map to their proving tests in `tools/groups.mjs`;
|
||||||
`tools/groups.test.mjs` fails if a group or its named evidence test disappears.
|
`tools/groups.test.mjs` fails if a group or its named evidence test disappears.
|
||||||
- **M4 gate harness.** (a) automated headless-Chromium test with mobile emulation (viewport, dpr, CPU
|
- **M4 gate harness.** (a) automated headless-Chromium test with mobile emulation (viewport, dpr, CPU
|
||||||
|
|||||||
@@ -88,6 +88,10 @@ suite "migrate":
|
|||||||
check db.getValue(sql"SELECT count(*) FROM marker_seen") == "0"
|
check db.getValue(sql"SELECT count(*) FROM marker_seen") == "0"
|
||||||
check db.getValue(sql"SELECT sql FROM sqlite_master WHERE name = 'marker_seen'")
|
check db.getValue(sql"SELECT sql FROM sqlite_master WHERE name = 'marker_seen'")
|
||||||
.contains("FOREIGN KEY (scene_id, wall_id) REFERENCES wall(scene_id, id) ON DELETE CASCADE")
|
.contains("FOREIGN KEY (scene_id, wall_id) REFERENCES wall(scene_id, id) ON DELETE CASCADE")
|
||||||
|
# The opaque marker id is per player, never shared: (player_id, marker_id) is UNIQUE, and the
|
||||||
|
# composite FK refuses a marker for a wall that does not exist.
|
||||||
|
check db.getValue(sql"SELECT sql FROM sqlite_master WHERE name = 'marker_seen'")
|
||||||
|
.contains("UNIQUE (player_id, marker_id)")
|
||||||
check db.getValue(sql"SELECT count(*) FROM sqlite_master WHERE name = 'wall_v1'") == "0"
|
check db.getValue(sql"SELECT count(*) FROM sqlite_master WHERE name = 'wall_v1'") == "0"
|
||||||
|
|
||||||
test "re-open is a no-op: no step applied, history and timestamps untouched":
|
test "re-open is a no-op: no step applied, history and timestamps untouched":
|
||||||
@@ -324,6 +328,22 @@ suite "step 8 wall CHECKs (DESIGN 4.4)":
|
|||||||
check insert(row(door = "1", open = "1")) # an open door is legal
|
check insert(row(door = "1", open = "1")) # an open door is legal
|
||||||
check db.getValue(sql"SELECT count(*) FROM wall") == "5"
|
check db.getValue(sql"SELECT count(*) FROM wall") == "5"
|
||||||
|
|
||||||
|
# marker_seen: a marker needs a player and an existing wall, and one player cannot hold the
|
||||||
|
# same opaque id twice (UNIQUE (player_id, marker_id)), even for a different wall.
|
||||||
|
db.exec(sql"INSERT INTO player (id, name, role, colour, created_at) VALUES (?, ?, ?, ?, ?)",
|
||||||
|
20, "Marker", "player", "#fff", "x")
|
||||||
|
proc marker(wall: int, mid: string): bool =
|
||||||
|
try:
|
||||||
|
db.exec(sql"INSERT INTO marker_seen (player_id, scene_id, wall_id, marker_id) VALUES (20, 1, ?, ?)",
|
||||||
|
wall, mid)
|
||||||
|
true
|
||||||
|
except CatchableError:
|
||||||
|
false
|
||||||
|
check marker(1, "AAAAAAAAAAAA")
|
||||||
|
check not marker(99, "BBBBBBBBBBBB") # no such wall: the composite FK refuses it
|
||||||
|
check not marker(2, "AAAAAAAAAAAA") # the same player's marker id, another wall: UNIQUE
|
||||||
|
check db.getValue(sql"SELECT count(*) FROM marker_seen") == "1"
|
||||||
|
|
||||||
test "a failing step 8 rolls back the rebuild, the history row and the version":
|
test "a failing step 8 rolls back the rebuild, the history row and the version":
|
||||||
let d = tmpDir()
|
let d = tmpDir()
|
||||||
let db = openFresh(d)
|
let db = openFresh(d)
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
## Player marker memory in process (DESIGN 5.8, 6.1, ADR-0015; #59/#60): the emission gate, the
|
||||||
|
## opaque per-player id, the fixed anchor, and the retraction rule. The wire, storage, resync and
|
||||||
|
## privacy are proven by tools/markers.test.mjs; this file pins the rule the mutation suite can
|
||||||
|
## mutate: a marker is memory, so only a cause change (wall gone, switch off, no longer a window,
|
||||||
|
## geometry moved) retracts it, and the signature is exactly those causes.
|
||||||
|
import std/[options, tables, unittest]
|
||||||
|
import geometry, markers, vision, world
|
||||||
|
|
||||||
|
proc sceneWith(walls: varargs[WallRec]): SceneRec =
|
||||||
|
SceneRec(id: 1, w: 4096, h: 4096, tileSize: 32, cell: 32, walls: @walls)
|
||||||
|
|
||||||
|
proc windowWall(id: int, a, b: Vec): WallRec =
|
||||||
|
## The `window` preset's switch set at the given geometry (an opening window, marker on).
|
||||||
|
result = defaultWall(a, b)
|
||||||
|
result.id = id
|
||||||
|
result.blocksSight = false
|
||||||
|
result.blocksMovement = true
|
||||||
|
result.door = true
|
||||||
|
result.playerMarker = true
|
||||||
|
|
||||||
|
proc poly(pts: varargs[Vec]): seq[Poly] =
|
||||||
|
@[Poly(tokenId: "tok000000001", pts: @pts)]
|
||||||
|
|
||||||
|
const Covered = @[(0.0, 0.0), (400.0, 0.0), (400.0, 400.0), (0.0, 400.0)]
|
||||||
|
|
||||||
|
suite "player markers (5.8, #59/#60)":
|
||||||
|
test "a marked window seen by any part of its extent mints one anchor marker":
|
||||||
|
var pv = PlayerVision(polys: poly(Covered))
|
||||||
|
let w = windowWall(1, (100.0, 100.0), (100.0, 300.0))
|
||||||
|
check syncMarkers(pv, sceneWith(w)) == 1
|
||||||
|
check pv.markers.len == 1
|
||||||
|
check pv.markers[1].id.len == 12
|
||||||
|
check (pv.markers[1].x, pv.markers[1].y) == (100, 200) # the drawn midpoint
|
||||||
|
check pv.markerFresh.len == 1 and pv.markerDead.len == 0
|
||||||
|
|
||||||
|
test "an untouched marker survives a refresh: it is memory, not current sight":
|
||||||
|
var pv = PlayerVision(polys: poly(Covered))
|
||||||
|
let sc = sceneWith(windowWall(1, (100.0, 100.0), (100.0, 300.0)))
|
||||||
|
check syncMarkers(pv, sc) == 1
|
||||||
|
let earned = pv.markers[1].id
|
||||||
|
pv.polys = poly(@[(2000.0, 2000.0), (2200.0, 2000.0), (2200.0, 2200.0)])
|
||||||
|
check syncMarkers(pv, sc) == 0 # walking away mints and retracts nothing
|
||||||
|
check pv.markers.hasKey(1) and pv.markers[1].id == earned
|
||||||
|
check pv.markerDead.len == 0
|
||||||
|
|
||||||
|
test "a geometry change retracts the marker and a re-earn gets a fresh id":
|
||||||
|
var pv = PlayerVision(polys: poly(Covered))
|
||||||
|
var w = windowWall(1, (100.0, 100.0), (100.0, 300.0))
|
||||||
|
check syncMarkers(pv, sceneWith(w)) == 1
|
||||||
|
let earned = pv.markers[1].id
|
||||||
|
w.thickness = 7 # thickness is a retraction cause
|
||||||
|
check syncMarkers(pv, sceneWith(w)) == 1
|
||||||
|
check pv.markerDead == @[earned]
|
||||||
|
check pv.markers[1].id != earned # a re-earned marker is a new id
|
||||||
|
check (pv.markers[1].x, pv.markers[1].y) == (100, 200)
|
||||||
|
|
||||||
|
test "a placement change retracts too; height and label never do":
|
||||||
|
var pv = PlayerVision(polys: poly(Covered))
|
||||||
|
var w = windowWall(1, (100.0, 100.0), (100.0, 300.0))
|
||||||
|
check syncMarkers(pv, sceneWith(w)) == 1
|
||||||
|
let earned = pv.markers[1].id
|
||||||
|
w.height = some(1.0) # no marker consequence
|
||||||
|
w.label = some("railing")
|
||||||
|
check syncMarkers(pv, sceneWith(w)) == 0
|
||||||
|
check pv.markers[1].id == earned
|
||||||
|
w.position = wpLeft # placement is a retraction cause
|
||||||
|
check syncMarkers(pv, sceneWith(w)) == 1
|
||||||
|
check pv.markerDead == @[earned]
|
||||||
|
|
||||||
|
test "a solid wall with the switch on mints nothing; clearing the switch retracts":
|
||||||
|
var pv = PlayerVision(polys: poly(Covered))
|
||||||
|
var solid = defaultWall((100.0, 100.0), (100.0, 300.0))
|
||||||
|
solid.id = 1
|
||||||
|
solid.playerMarker = true
|
||||||
|
check syncMarkers(pv, sceneWith(solid)) == 0 # a solid wall never qualifies as a window
|
||||||
|
var w = windowWall(2, (150.0, 100.0), (150.0, 300.0))
|
||||||
|
check syncMarkers(pv, sceneWith(solid, w)) == 1
|
||||||
|
let earned = pv.markers[2].id
|
||||||
|
w.playerMarker = false
|
||||||
|
check syncMarkers(pv, sceneWith(solid, w)) == 0
|
||||||
|
check pv.markerDead == @[earned]
|
||||||
@@ -347,6 +347,18 @@ suite "validation (DESIGN 6.1 `wall.*`)":
|
|||||||
check resolveWall(plain, none(Preset),
|
check resolveWall(plain, none(Preset),
|
||||||
WallSettings(blocksSight: some(false), sightDir: some(sdLeft))).isNone
|
WallSettings(blocksSight: some(false), sightDir: some(sdLeft))).isNone
|
||||||
|
|
||||||
|
test "storable is the last gate: a secret or locked non-door is refused":
|
||||||
|
# `resolveWall` already refuses a named door-only setting on a non-door; `storable` is the
|
||||||
|
# backstop for every other caller (the importer, a future entry point), so it must say no to a
|
||||||
|
# record no path could build.
|
||||||
|
var r = defaultWall((0.0, 0.0), (10.0, 0.0))
|
||||||
|
check storable(r)
|
||||||
|
r.secret = true
|
||||||
|
check not storable(r)
|
||||||
|
r.secret = false
|
||||||
|
r.locked = true
|
||||||
|
check not storable(r)
|
||||||
|
|
||||||
test "a label is 1..64 code points, trimmed and free of control characters (#55)":
|
test "a label is 1..64 code points, trimmed and free of control characters (#55)":
|
||||||
let (conn, d) = freshScene()
|
let (conn, d) = freshScene()
|
||||||
defer:
|
defer:
|
||||||
|
|||||||
+32
-3
@@ -106,8 +106,11 @@ async function runScript(ctx, variant, opts = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Common world: a far north wall, a door used for the close-push, and far walls the GM edits.
|
// Common world: a far north wall, a door used for the close-push, and far walls the GM edits.
|
||||||
|
// `opts.geometry` (stories 29/30, #52) stores non-default thickness/placement/height on the push
|
||||||
|
// door and on the segment under test; this round those fields are inert by contract.
|
||||||
|
const geometry = opts.geometry ?? {}
|
||||||
await add({ a: [0, 0], b: [4096, 0], flags: { note: 'north' } })
|
await add({ a: [0, 0], b: [4096, 0], flags: { note: 'north' } })
|
||||||
const pushDoor = await add({ a: [300, 300], b: [300, 400], door: true })
|
const pushDoor = await add({ a: [300, 300], b: [300, 400], door: true, ...geometry })
|
||||||
const farWall = await add({ a: [2000, 1000], b: [2500, 1000] })
|
const farWall = await add({ a: [2000, 1000], b: [2500, 1000] })
|
||||||
const farDoor = await add({ a: [2600, 1000], b: [2600, 1200], door: true })
|
const farDoor = await add({ a: [2600, 1000], b: [2600, 1200], door: true })
|
||||||
|
|
||||||
@@ -147,7 +150,7 @@ async function runScript(ctx, variant, opts = {}) {
|
|||||||
let b = await connect(bob.key)
|
let b = await connect(bob.key)
|
||||||
|
|
||||||
// The GM adds the segment under test over T3 (stuck). This is the only world difference.
|
// The GM adds the segment under test over T3 (stuck). This is the only world difference.
|
||||||
const segId = await add({ ...SEG, ...variant })
|
const segId = await add({ ...SEG, ...variant, ...geometry })
|
||||||
await sleep(60)
|
await sleep(60)
|
||||||
|
|
||||||
// An unrelated token move and unrelated wall/door edits: they must not perturb the player view.
|
// An unrelated token move and unrelated wall/door edits: they must not perturb the player view.
|
||||||
@@ -166,6 +169,7 @@ async function runScript(ctx, variant, opts = {}) {
|
|||||||
const pushed = gm.ws.messages.filter(m => m.t === 'token' && m.id === t4).pop()
|
const pushed = gm.ws.messages.filter(m => m.t === 'token' && m.id === t4).pop()
|
||||||
assert.ok(Math.abs(pushed.pos[0] - 320) < 1e-3 && pushed.pos[1] === 350,
|
assert.ok(Math.abs(pushed.pos[0] - 320) < 1e-3 && pushed.pos[1] === 350,
|
||||||
`closing a door over a token pushes it aside as today: ${JSON.stringify(pushed.pos)}`)
|
`closing a door over a token pushes it aside as today: ${JSON.stringify(pushed.pos)}`)
|
||||||
|
const gmWall = id => gm.ws.messages.filter(m => m.t === 'wall' && m.id === id).pop()
|
||||||
|
|
||||||
// The GM's door intent on the differing segment: refused `invalid` for a wall, a secret or a
|
// The GM's door intent on the differing segment: refused `invalid` for a wall, a secret or a
|
||||||
// locked door; an ordinary closed door opens. GM-side only, so no player frame changes with it.
|
// locked door; an ordinary closed door opens. GM-side only, so no player frame changes with it.
|
||||||
@@ -220,7 +224,8 @@ async function runScript(ctx, variant, opts = {}) {
|
|||||||
a.ws.close(); b.ws.close(); gm.ws.close()
|
a.ws.close(); b.ws.close(); gm.ws.close()
|
||||||
await Promise.all([a.ws.closed, b.ws.closed])
|
await Promise.all([a.ws.closed, b.ws.closed])
|
||||||
assert.equal(art, 1, 'the v1 art version is pinned (DESIGN 3.3)')
|
assert.equal(art, 1, 'the v1 art version is pinned (DESIGN 3.3)')
|
||||||
return { frames, cookies, scene, art }
|
return { frames, cookies, scene, art, pushed: pushed.pos,
|
||||||
|
stored: { pushDoor: gmWall(pushDoor), seg: gmWall(segId) } }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Every tile of the checked rectangle, as status + bytes. The fixture bytes are per-(x,y), so a
|
// Every tile of the checked rectangle, as status + bytes. The fixture bytes are per-(x,y), so a
|
||||||
@@ -263,6 +268,7 @@ async function runPair(aVariant, bVariant, opts = {}) {
|
|||||||
for (const [i, variant] of [aVariant, bVariant].entries()) {
|
for (const [i, variant] of [aVariant, bVariant].entries()) {
|
||||||
const run = await runScript(stacks[i], variant, {
|
const run = await runScript(stacks[i], variant, {
|
||||||
...opts,
|
...opts,
|
||||||
|
geometry: opts.geometry?.[i] ?? null,
|
||||||
segmentOpen: opts.segmentOpen?.[i] ?? null,
|
segmentOpen: opts.segmentOpen?.[i] ?? null,
|
||||||
crosses: opts.crosses?.[i] ?? false,
|
crosses: opts.crosses?.[i] ?? false,
|
||||||
})
|
})
|
||||||
@@ -301,6 +307,29 @@ for (const pair of PAIRS) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test('inert geometry: stored thickness, placement and height change neither the door push nor a player byte (#52)',
|
||||||
|
async () => {
|
||||||
|
// Stories 29/30: thickness, placement and height are accepted, stored and echoed by the GM's
|
||||||
|
// frames, but in this round every stored value behaves exactly like zero thickness / centre /
|
||||||
|
// full height. The defaults run and the geometry run play the same script; the push position
|
||||||
|
// and every player frame and tile must be identical.
|
||||||
|
const GEOMETRY = { thickness: 256, position: 'left', height: 1 }
|
||||||
|
const { a, b } = await runPair({}, {}, { geometry: [null, GEOMETRY] })
|
||||||
|
for (const [label, wall] of [['closed door', b.stored.pushDoor],
|
||||||
|
['wall segment', b.stored.seg]]) {
|
||||||
|
assert.deepEqual(
|
||||||
|
{ thickness: wall.thickness, position: wall.position, height: wall.height }, GEOMETRY,
|
||||||
|
`${label}: the non-default geometry is stored and echoed by the GM frame`)
|
||||||
|
}
|
||||||
|
assert.ok(Math.abs(a.pushed[0] - 320) < 1e-3 && a.pushed[1] === 350,
|
||||||
|
`the baseline close-push is the zero-thickness result: ${JSON.stringify(a.pushed)}`)
|
||||||
|
assert.deepEqual(b.pushed, a.pushed,
|
||||||
|
'stored thickness, placement and height change the door push by nothing')
|
||||||
|
assert.ok(b.tiles.alice.some(s => s.includes(':200:')), 'the sweep allowed some tiles')
|
||||||
|
assert.deepEqual(equivalenceClasses(a, b), [],
|
||||||
|
'the geometry run and the defaults run must give identical player frames and tile statuses')
|
||||||
|
})
|
||||||
|
|
||||||
test('door equivalence positive control: an open door produces a different transcript', async () => {
|
test('door equivalence positive control: an open door produces a different transcript', async () => {
|
||||||
const { a, b } = await runPair({}, { door: true, open: true },
|
const { a, b } = await runPair({}, { door: true, open: true },
|
||||||
{ segmentOpen: ['invalid', 'ok'], crosses: [false, true] })
|
{ segmentOpen: ['invalid', 'ok'], crosses: [false, true] })
|
||||||
|
|||||||
+6
-2
@@ -43,9 +43,13 @@ export const GROUPS = {
|
|||||||
['restart.test.mjs', 'restart: full state, all CRUD, before and after SIGKILL']],
|
['restart.test.mjs', 'restart: full state, all CRUD, before and after SIGKILL']],
|
||||||
},
|
},
|
||||||
persistence: {
|
persistence: {
|
||||||
files: ['persistence.test.mjs'],
|
// 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: [['persistence.test.mjs', 'explored round trip: a fresh connection gets the whole grid'],
|
evidence: [['persistence.test.mjs', 'explored round trip: a fresh connection gets the whole grid'],
|
||||||
['persistence.test.mjs', 'migration: a schema-4 DB (fixture) migrates under the real binary']],
|
['persistence.test.mjs', 'migration: a schema-4 DB (fixture) migrates under the real binary'],
|
||||||
|
['wallbehaviour.test.mjs', 'behaviour preservation: a migrated schema-7 scene and the same scene authored via raw switches are byte-identical to a player']],
|
||||||
},
|
},
|
||||||
logs: {
|
logs: {
|
||||||
files: ['logs.test.mjs'],
|
files: ['logs.test.mjs'],
|
||||||
|
|||||||
+17
-7
@@ -19,9 +19,10 @@
|
|||||||
// the subject, west of it, sees across to the sentry E2 (#58)
|
// the subject, west of it, sees across to the sentry E2 (#58)
|
||||||
// - markers a marked opening window in the room (seen: the positive control), the same
|
// - markers a marked opening window in the room (seen: the positive control), the same
|
||||||
// window's switch cleared and restored (the retraction/re-earn path, #60), a
|
// window's switch cleared and restored (the retraction/re-earn path, #60), a
|
||||||
// marked solid wall in the room (switch on, no marker: MARKER_EXTRA control)
|
// marked solid wall in the room (switch on, no marker: MARKER_EXTRA control),
|
||||||
// and a marked window far outside every scripted position (never seen:
|
// a marked window far outside every scripted position (never seen: MARKER_EARLY
|
||||||
// MARKER_EARLY control)
|
// control) and a marked window behind the far wall (occluded: "a wall behind a
|
||||||
|
// sight blocker yields none", TESTING 5.8)
|
||||||
// - the rest a token hidden behind the closed door and revealed by opening it, tokens
|
// - the rest a token hidden behind the closed door and revealed by opening it, tokens
|
||||||
// created/removed while watched, a `gm_only` token inside LOS, a controller
|
// created/removed while watched, a `gm_only` token inside LOS, a controller
|
||||||
// handed over and back, another player walking in and out, a wall added and
|
// handed over and back, another player walking in and out, a wall added and
|
||||||
@@ -33,10 +34,13 @@
|
|||||||
import fs from 'node:fs'
|
import fs from 'node:fs'
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
import { spawnSync } from 'node:child_process'
|
import { spawnSync } from 'node:child_process'
|
||||||
import { createPlayer, namePlayer, openWs, sleep, projectRoot } from './lib.mjs'
|
import { createPlayer, namePlayer, openWs, sleep, projectRoot, isWindow, anchorOf } from './lib.mjs'
|
||||||
import { signIn } from './withserver.mjs'
|
import { signIn } from './withserver.mjs'
|
||||||
|
|
||||||
const QUIET_MS = 60
|
const QUIET_MS = 60
|
||||||
|
// The far wall's x (the WORLD's `far-*` segments): east of it is behind a sight blocker at every
|
||||||
|
// scripted subject position. Scenario coverage reads this to prove the occluded marker control.
|
||||||
|
const FAR_WALL_X = 1400
|
||||||
const nimblePkgs = () => path.join(process.env.NIMBLE_DIR ?? path.join(projectRoot, '.devbox', 'nimble'), 'pkgs2')
|
const nimblePkgs = () => path.join(process.env.NIMBLE_DIR ?? path.join(projectRoot, '.devbox', 'nimble'), 'pkgs2')
|
||||||
|
|
||||||
// The checker is compiled once per process (it imports server/geometry.nim through --path in nim.cfg).
|
// The checker is compiled once per process (it imports server/geometry.nim through --path in nim.cfg).
|
||||||
@@ -96,11 +100,13 @@ const WORLD = [
|
|||||||
// Marked window far outside every scripted position: never seen, so never a marker (the
|
// Marked window far outside every scripted position: never seen, so never a marker (the
|
||||||
// MARKER_EARLY negative control, #60).
|
// MARKER_EARLY negative control, #60).
|
||||||
{ role: 'marked-unseen', preset: 'window', a: [3500, 2000], b: [3500, 2200] },
|
{ role: 'marked-unseen', preset: 'window', a: [3500, 2000], b: [3500, 2200] },
|
||||||
|
// A marked window behind the far wall (east of FAR_WALL_X): truly occluded, so it must yield no
|
||||||
|
// marker at all — TESTING 5.8 "a wall behind a sight blocker yields none". Unlike `marked-unseen`
|
||||||
|
// this is not merely out of range; a sight-blocking wall stands between it and every subject
|
||||||
|
// position, so even walking the whole room never earns it.
|
||||||
|
{ role: 'marked-occluded', preset: 'window', a: [1500, 700], b: [1500, 800] },
|
||||||
]
|
]
|
||||||
|
|
||||||
const isWindow = w => w.blocks_sight === false && w.blocks_movement === true
|
|
||||||
const anchorOf = w => [Math.round((w.a[0] + w.b[0]) / 2), Math.round((w.a[1] + w.b[1]) / 2)]
|
|
||||||
|
|
||||||
// The scenario's own coverage, read off the GM's wall frames and the subject's marker frames. The
|
// The scenario's own coverage, read off the GM's wall frames and the subject's marker frames. The
|
||||||
// acceptance contract of #61 is a world holding each of these elements, so the test proves the
|
// acceptance contract of #61 is a world holding each of these elements, so the test proves the
|
||||||
// scenario really has them instead of trusting the list above: a rewrite that silently drops the
|
// scenario really has them instead of trusting the list above: a rewrite that silently drops the
|
||||||
@@ -123,6 +129,7 @@ export function scenarioCoverage(gmMsgs, subjMsgs) {
|
|||||||
}
|
}
|
||||||
const marked = all.filter(w => w.player_marker)
|
const marked = all.filter(w => w.player_marker)
|
||||||
const windows = marked.filter(isWindow)
|
const windows = marked.filter(isWindow)
|
||||||
|
const occluded = windows.filter(w => anchorOf(w)[0] > FAR_WALL_X)
|
||||||
return {
|
return {
|
||||||
walls: all.length,
|
walls: all.length,
|
||||||
oneWay: all.filter(w => w.sight_dir !== 'both').length,
|
oneWay: all.filter(w => w.sight_dir !== 'both').length,
|
||||||
@@ -133,6 +140,9 @@ export function scenarioCoverage(gmMsgs, subjMsgs) {
|
|||||||
// "both sides of the sight test": a marked window the subject earned and one it did not.
|
// "both sides of the sight test": a marked window the subject earned and one it did not.
|
||||||
markedWindowsSeen: windows.filter(w => received.has(anchorOf(w).join(','))).length,
|
markedWindowsSeen: windows.filter(w => received.has(anchorOf(w).join(','))).length,
|
||||||
markedWindowsUnseen: windows.filter(w => !received.has(anchorOf(w).join(','))).length,
|
markedWindowsUnseen: windows.filter(w => !received.has(anchorOf(w).join(','))).length,
|
||||||
|
// A marked window behind the far wall: occluded, never earned, however far the subject walks.
|
||||||
|
markedWindowsOccluded: occluded.length,
|
||||||
|
markedWindowsOccludedSeen: occluded.filter(w => received.has(anchorOf(w).join(','))).length,
|
||||||
markers: received.size,
|
markers: received.size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ for (const subject of ['A', 'B']) {
|
|||||||
`the world needs a marked window the subject sees: ${JSON.stringify(cov)}`)
|
`the world needs a marked window the subject sees: ${JSON.stringify(cov)}`)
|
||||||
assert.ok(cov.markedWindowsUnseen >= 1,
|
assert.ok(cov.markedWindowsUnseen >= 1,
|
||||||
`the world needs a marked window the subject never sees (MARKER_EARLY control): ${JSON.stringify(cov)}`)
|
`the world needs a marked window the subject never sees (MARKER_EARLY control): ${JSON.stringify(cov)}`)
|
||||||
|
assert.ok(cov.markedWindowsOccluded >= 1,
|
||||||
|
`the world needs a marked window behind the far wall (TESTING 5.8): ${JSON.stringify(cov)}`)
|
||||||
|
assert.equal(cov.markedWindowsOccludedSeen, 0,
|
||||||
|
`a wall behind a sight blocker yields no marker: ${JSON.stringify(cov)}`)
|
||||||
}
|
}
|
||||||
const check = runChecker(transcript, subject)
|
const check = runChecker(transcript, subject)
|
||||||
fs.writeFileSync(path.join(results, `leak-${subject}.log`), check.output)
|
fs.writeFileSync(path.join(results, `leak-${subject}.log`), check.output)
|
||||||
|
|||||||
+64
-36
@@ -104,6 +104,13 @@ type
|
|||||||
anchor: (int, int)
|
anchor: (int, int)
|
||||||
sig: string
|
sig: string
|
||||||
|
|
||||||
|
MarkerSeen = object
|
||||||
|
## One marker id the subject was sent, resolved to the GM-truth wall it belongs to. Keying by
|
||||||
|
## wall (not by anchor) is what keeps two candidate walls that share a midpoint distinct. A
|
||||||
|
## `wall` of -1 means no candidate wall stands at that anchor (an extra marker).
|
||||||
|
wall: int
|
||||||
|
pos: (int, int)
|
||||||
|
|
||||||
Group = object
|
Group = object
|
||||||
label: string
|
label: string
|
||||||
gmMsgs: seq[JsonNode]
|
gmMsgs: seq[JsonNode]
|
||||||
@@ -466,7 +473,7 @@ proc main() =
|
|||||||
var encounterable: HashSet[string] # token ids the subject may have met (independent oracle)
|
var encounterable: HashSet[string] # token ids the subject may have met (independent oracle)
|
||||||
var viewCharacters: HashSet[string] # character ids the subject was sent
|
var viewCharacters: HashSet[string] # character ids the subject was sent
|
||||||
var prevController: Table[string, int] # controller of each token at the previous group
|
var prevController: Table[string, int] # controller of each token at the previous group
|
||||||
var markers: Table[string, (int, int)] # marker id -> anchor, what the subject was sent
|
var markers: Table[string, MarkerSeen] # marker id -> the GM-truth wall it was minted for
|
||||||
var expectedMarkers: Table[int, ExpectedMarker] # wall id -> accumulated memory (#59/#60)
|
var expectedMarkers: Table[int, ExpectedMarker] # wall id -> accumulated memory (#59/#60)
|
||||||
var markerPositive = false # the scenario exercised the oracle at least once
|
var markerPositive = false # the scenario exercised the oracle at least once
|
||||||
|
|
||||||
@@ -775,9 +782,43 @@ proc main() =
|
|||||||
if m["full"].getBool: markers.clear()
|
if m["full"].getBool: markers.clear()
|
||||||
for e in m["set"]:
|
for e in m["set"]:
|
||||||
let id = e["id"].getStr
|
let id = e["id"].getStr
|
||||||
|
let pos = (e["pos"][0].getInt, e["pos"][1].getInt)
|
||||||
if markers.hasKey(id):
|
if markers.hasKey(id):
|
||||||
fail "PROTOCOL", "duplicate marker id " & id & " (group " & g.label & ")"
|
fail "PROTOCOL", "duplicate marker id " & id & " (group " & g.label & ")"
|
||||||
markers[id] = (e["pos"][0].getInt, e["pos"][1].getInt)
|
continue
|
||||||
|
# Resolve the id to a GM-truth wall by anchor. Prefer the wall the oracle expects and
|
||||||
|
# that has no id yet, so two candidates sharing a midpoint each get their own id; then
|
||||||
|
# any free candidate; then the marker is extra (or a re-mint, below).
|
||||||
|
var cand: seq[int]
|
||||||
|
for mw in truth.markerWalls:
|
||||||
|
if anchorOf(mw) == pos: cand.add mw.id
|
||||||
|
var pick = -1
|
||||||
|
for c in cand:
|
||||||
|
var used = false
|
||||||
|
for _, seen in markers:
|
||||||
|
if seen.wall == c: used = true
|
||||||
|
if not used and expectedMarkers.hasKey(c):
|
||||||
|
pick = c
|
||||||
|
break
|
||||||
|
if pick < 0:
|
||||||
|
for c in cand:
|
||||||
|
var used = false
|
||||||
|
for _, seen in markers:
|
||||||
|
if seen.wall == c: used = true
|
||||||
|
if not used:
|
||||||
|
pick = c
|
||||||
|
break
|
||||||
|
if pick < 0 and cand.len == 1 and expectedMarkers.hasKey(cand[0]):
|
||||||
|
# The one wall this anchor belongs to already has a live id: the marker was re-minted
|
||||||
|
# without the old one dying. A marker id is minted once and stable across refreshes
|
||||||
|
# (5.8); only a re-earn after a retraction gets a fresh one. This is a protocol break,
|
||||||
|
# not one of the four marker fault classes (documented in TESTING 10.3).
|
||||||
|
fail "PROTOCOL", "marker for wall " & $cand[0] & " re-minted as " & id &
|
||||||
|
" while its old id is still live (group " & g.label & ")"
|
||||||
|
if pick < 0:
|
||||||
|
markers[id] = MarkerSeen(wall: -1, pos: pos) # extra: no free candidate at anchor
|
||||||
|
else:
|
||||||
|
markers[id] = MarkerSeen(wall: pick, pos: pos)
|
||||||
if m.hasKey("del"):
|
if m.hasKey("del"):
|
||||||
for d in m["del"]:
|
for d in m["del"]:
|
||||||
let id = d.getStr
|
let id = d.getStr
|
||||||
@@ -802,42 +843,29 @@ proc main() =
|
|||||||
if expectedMarkers.hasKey(mw.id): continue
|
if expectedMarkers.hasKey(mw.id): continue
|
||||||
if extentSeen(polysChecks, mw.a, mw.b):
|
if extentSeen(polysChecks, mw.a, mw.b):
|
||||||
expectedMarkers[mw.id] = ExpectedMarker(anchor: anchorOf(mw), sig: markerSig(mw))
|
expectedMarkers[mw.id] = ExpectedMarker(anchor: anchorOf(mw), sig: markerSig(mw))
|
||||||
var wantPos: seq[(int, int)]
|
var owned: HashSet[int]
|
||||||
for _, em in expectedMarkers: wantPos.add em.anchor
|
for _, seen in markers:
|
||||||
var gotPos: seq[(int, int)]
|
if seen.wall >= 0: owned.incl seen.wall
|
||||||
for _, pos in markers: gotPos.add pos
|
# Keyed by wall, not by anchor: two candidate walls sharing a midpoint stay two obligations,
|
||||||
wantPos.sort()
|
# and an id's stability is its wall's ownership (a re-mint is caught when the set arrives).
|
||||||
gotPos.sort()
|
var missingWalls: seq[int]
|
||||||
# Multiset difference: `missing` markers the memory expects, `extra` ones it does not. An
|
for wallId in expectedMarkers.keys:
|
||||||
# extra at a marker candidate's anchor was sent before its extent was seen (EARLY); an extra
|
if wallId notin owned: missingWalls.add wallId
|
||||||
# with no candidate wall at all must never exist (EXTRA).
|
if missingWalls.len > 0:
|
||||||
var missingMarkers, extraMarkers: seq[(int, int)]
|
missingWalls.sort()
|
||||||
var wi = 0
|
fail "MARKER_OFF", "marker for wall " & $missingWalls[0] & " was never sent (" &
|
||||||
var gi = 0
|
$missingWalls.len & " missing; group " & g.label & ")"
|
||||||
while wi < wantPos.len or gi < gotPos.len:
|
for _, seen in markers:
|
||||||
if wi >= wantPos.len:
|
if seen.wall < 0:
|
||||||
extraMarkers.add gotPos[gi]; inc gi
|
fail "MARKER_EXTRA", "marker " & $seen.pos & " has no marker candidate wall (group " &
|
||||||
elif gi >= gotPos.len:
|
|
||||||
missingMarkers.add wantPos[wi]; inc wi
|
|
||||||
elif wantPos[wi] == gotPos[gi]:
|
|
||||||
inc wi; inc gi
|
|
||||||
elif wantPos[wi] < gotPos[gi]:
|
|
||||||
missingMarkers.add wantPos[wi]; inc wi
|
|
||||||
else:
|
|
||||||
extraMarkers.add gotPos[gi]; inc gi
|
|
||||||
if missingMarkers.len > 0:
|
|
||||||
fail "MARKER_OFF", "marker " & $missingMarkers[0] & " was never sent (" &
|
|
||||||
$missingMarkers.len & " missing; group " & g.label & ")"
|
|
||||||
var candidateAnchors: seq[(int, int)]
|
|
||||||
for mw in truth.markerWalls: candidateAnchors.add anchorOf(mw)
|
|
||||||
for pos in extraMarkers:
|
|
||||||
if pos in candidateAnchors:
|
|
||||||
fail "MARKER_EARLY", "marker " & $pos & " sent before its wall was seen (group " &
|
|
||||||
g.label & ")"
|
g.label & ")"
|
||||||
else:
|
elif not expectedMarkers.hasKey(seen.wall):
|
||||||
fail "MARKER_EXTRA", "marker " & $pos & " has no marker candidate wall (group " &
|
# It maps to a current candidate wall the oracle does not expect: sent before that wall's
|
||||||
|
# extent was seen (MARKER_EARLY), or a cause change whose del never arrived. It is a marker
|
||||||
|
# at a candidate's anchor either way, which is the class TESTING 10.3 defines.
|
||||||
|
fail "MARKER_EARLY", "marker " & $seen.pos & " sent before its wall was seen (group " &
|
||||||
g.label & ")"
|
g.label & ")"
|
||||||
if wantPos.len > 0:
|
if expectedMarkers.len > 0:
|
||||||
markerPositive = true
|
markerPositive = true
|
||||||
|
|
||||||
# --- CONTROLLER_CHANGE (10.3) ----------------------------------------------------------------
|
# --- CONTROLLER_CHANGE (10.3) ----------------------------------------------------------------
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ export const sleep = ms => new Promise(r => setTimeout(r, ms))
|
|||||||
|
|
||||||
export const projectRoot = path.dirname(path.dirname(fileURLToPath(import.meta.url)))
|
export const projectRoot = path.dirname(path.dirname(fileURLToPath(import.meta.url)))
|
||||||
|
|
||||||
|
// Wall helpers shared by the harnesses (the leak driver's scenario coverage and any test that reads
|
||||||
|
// GM wall frames). The leak checker keeps its own copies on purpose: the oracle must be independent
|
||||||
|
// of the harness, not share code with it.
|
||||||
|
export const isWindow = w => w.blocks_sight === false && w.blocks_movement === true
|
||||||
|
export const anchorOf = w => [Math.round((w.a[0] + w.b[0]) / 2), Math.round((w.a[1] + w.b[1]) / 2)]
|
||||||
|
|
||||||
export const baseUrl = port => `http://127.0.0.1:${port}`
|
export const baseUrl = port => `http://127.0.0.1:${port}`
|
||||||
|
|
||||||
// Ports of a live dev session: never let a test stack touch them (prototype withserver.sh rule).
|
// Ports of a live dev session: never let a test stack touch them (prototype withserver.sh rule).
|
||||||
|
|||||||
+34
-10
@@ -14,6 +14,30 @@ import { createPlayer, namePlayer, sleep } from './lib.mjs'
|
|||||||
|
|
||||||
const ID_RE = /^[A-Za-z0-9_-]{12}$/
|
const ID_RE = /^[A-Za-z0-9_-]{12}$/
|
||||||
|
|
||||||
|
// A synchronising round-trip before an absence assertion (the leak driver's quiet-group rule): an
|
||||||
|
// ack'd GM action guarantees the server finished the earlier mutation under its lock, then the
|
||||||
|
// quiet window observes that no socket is still delivering frames. A fixed sleep would make
|
||||||
|
// "nothing arrived" a race; this makes it an observation.
|
||||||
|
const QUIET_MS = 60
|
||||||
|
async function quiet(clients, quietMs = QUIET_MS) {
|
||||||
|
const deadline = Date.now() + 5000
|
||||||
|
let last = -1
|
||||||
|
let since = Date.now()
|
||||||
|
for (;;) {
|
||||||
|
const n = clients.reduce((a, c) => a + c.ws.messages.length, 0)
|
||||||
|
if (n !== last) { last = n; since = Date.now() }
|
||||||
|
if (Date.now() - since >= quietMs) return
|
||||||
|
if (Date.now() > deadline) throw new Error('server never went quiet')
|
||||||
|
await sleep(10)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function settle(gm, clients) {
|
||||||
|
// The caller has already awaited the ack of the action under test, so the server has run the
|
||||||
|
// mutation (and is writing the derived frames right after the ack, under the same lock). Observe
|
||||||
|
// quiescence on every socket before asserting absence, exactly like the leak driver's group end.
|
||||||
|
await quiet([gm, ...clients])
|
||||||
|
}
|
||||||
|
|
||||||
async function gmConnect(origin, gmKey) {
|
async function gmConnect(origin, gmKey) {
|
||||||
const conn = await openAs(origin, gmKey)
|
const conn = await openAs(origin, gmKey)
|
||||||
await conn.ws.waitText('hello')
|
await conn.ws.waitText('hello')
|
||||||
@@ -84,7 +108,7 @@ test('marker emission: only a marked window, exact anchor and count, no wall fie
|
|||||||
// A solid wall with the switch on stores the switch and sends nothing (5.8 gate).
|
// A solid wall with the switch on stores the switch and sends nothing (5.8 gate).
|
||||||
let from = player.conn.ws.messages.length
|
let from = player.conn.ws.messages.length
|
||||||
await addWall(gm, { a: [100, 700], b: [400, 700], player_marker: true })
|
await addWall(gm, { a: [100, 700], b: [400, 700], player_marker: true })
|
||||||
await sleep(120)
|
await settle(gm, [player.conn])
|
||||||
assert.equal(markersAfter(player.conn.ws, from).length, 0,
|
assert.equal(markersAfter(player.conn.ws, from).length, 0,
|
||||||
'a solid wall with player_marker:true emits no marker')
|
'a solid wall with player_marker:true emits no marker')
|
||||||
|
|
||||||
@@ -92,7 +116,7 @@ test('marker emission: only a marked window, exact anchor and count, no wall fie
|
|||||||
from = player.conn.ws.messages.length
|
from = player.conn.ws.messages.length
|
||||||
await addWall(gm, { blocks_sight: false, blocks_movement: true, door: true,
|
await addWall(gm, { blocks_sight: false, blocks_movement: true, door: true,
|
||||||
player_marker: false, a: [500, 500], b: [500, 700] })
|
player_marker: false, a: [500, 500], b: [500, 700] })
|
||||||
await sleep(120)
|
await settle(gm, [player.conn])
|
||||||
assert.equal(markersAfter(player.conn.ws, from).length, 0,
|
assert.equal(markersAfter(player.conn.ws, from).length, 0,
|
||||||
'a window with its marker off emits nothing')
|
'a window with its marker off emits nothing')
|
||||||
|
|
||||||
@@ -129,7 +153,7 @@ test('marker lifetime and resync: survives walk-away and doors, full after explo
|
|||||||
let from = alice.conn.ws.messages.length
|
let from = alice.conn.ws.messages.length
|
||||||
assert.equal((await gm.ws.request({ t: 'token.move', id: aliceToken,
|
assert.equal((await gm.ws.request({ t: 'token.move', id: aliceToken,
|
||||||
pos: [2000, 2000] })).ok, true)
|
pos: [2000, 2000] })).ok, true)
|
||||||
await sleep(120)
|
await settle(gm, [alice.conn])
|
||||||
assert.equal(markersAfter(alice.conn.ws, from).length, 0,
|
assert.equal(markersAfter(alice.conn.ws, from).length, 0,
|
||||||
'walking away never retracts or re-sends a marker')
|
'walking away never retracts or re-sends a marker')
|
||||||
|
|
||||||
@@ -138,7 +162,7 @@ test('marker lifetime and resync: survives walk-away and doors, full after explo
|
|||||||
from = alice.conn.ws.messages.length
|
from = alice.conn.ws.messages.length
|
||||||
assert.equal((await gm.ws.request({ t: 'door.set', scene: gm.scene, id: window.id,
|
assert.equal((await gm.ws.request({ t: 'door.set', scene: gm.scene, id: window.id,
|
||||||
open })).ok, true)
|
open })).ok, true)
|
||||||
await sleep(80)
|
await settle(gm, [alice.conn])
|
||||||
assert.equal(markersAfter(alice.conn.ws, from).length, 0,
|
assert.equal(markersAfter(alice.conn.ws, from).length, 0,
|
||||||
`door.set open:${open} leaves the marker alone`)
|
`door.set open:${open} leaves the marker alone`)
|
||||||
}
|
}
|
||||||
@@ -173,7 +197,7 @@ test('marker lifetime and resync: survives walk-away and doors, full after explo
|
|||||||
player_marker: false })).ok, true)
|
player_marker: false })).ok, true)
|
||||||
const carol = await namedPlayer(gm, s.origin, 'Marker Carol')
|
const carol = await namedPlayer(gm, s.origin, 'Marker Carol')
|
||||||
await addSightToken(gm, carol, [300, 300])
|
await addSightToken(gm, carol, [300, 300])
|
||||||
await sleep(150)
|
await settle(gm, [carol.conn])
|
||||||
const carolMarkers = markerFrames(carol.conn.ws).flatMap(m => m.set)
|
const carolMarkers = markerFrames(carol.conn.ws).flatMap(m => m.set)
|
||||||
assert.equal(carolMarkers.length, 0, 'a window with the switch off is an invisible barrier')
|
assert.equal(carolMarkers.length, 0, 'a window with the switch off is an invisible barrier')
|
||||||
|
|
||||||
@@ -238,17 +262,17 @@ test('retraction: every cause sends del only, a re-earned marker gets a fresh id
|
|||||||
const away = async () => {
|
const away = async () => {
|
||||||
assert.equal((await gm.ws.request({ t: 'token.move', id: tokenId,
|
assert.equal((await gm.ws.request({ t: 'token.move', id: tokenId,
|
||||||
pos: [2000, 2000] })).ok, true)
|
pos: [2000, 2000] })).ok, true)
|
||||||
await sleep(100)
|
await quiet([gm, alice.conn])
|
||||||
}
|
}
|
||||||
const back = async () => {
|
const back = async () => {
|
||||||
assert.equal((await gm.ws.request({ t: 'token.move', id: tokenId,
|
assert.equal((await gm.ws.request({ t: 'token.move', id: tokenId,
|
||||||
pos: [300, 300] })).ok, true)
|
pos: [300, 300] })).ok, true)
|
||||||
await sleep(100)
|
await quiet([gm, alice.conn])
|
||||||
}
|
}
|
||||||
const retract = async action => {
|
const retract = async action => {
|
||||||
const from = alice.conn.ws.messages.length
|
const from = alice.conn.ws.messages.length
|
||||||
assert.equal((await action()).ok, true)
|
assert.equal((await action()).ok, true)
|
||||||
await sleep(100)
|
await settle(gm, [alice.conn])
|
||||||
return framesAfter(alice.conn.ws, from)
|
return framesAfter(alice.conn.ws, from)
|
||||||
}
|
}
|
||||||
const reEarn = async what => {
|
const reEarn = async what => {
|
||||||
@@ -370,12 +394,12 @@ test('marker retraction is durable: delete and cascade survive a restart (#60)',
|
|||||||
let from = alice.conn.ws.messages.length
|
let from = alice.conn.ws.messages.length
|
||||||
assert.equal((await gm.ws.request({ t: 'wall.update', scene: gm.scene, id: off.id,
|
assert.equal((await gm.ws.request({ t: 'wall.update', scene: gm.scene, id: off.id,
|
||||||
player_marker: false })).ok, true)
|
player_marker: false })).ok, true)
|
||||||
await sleep(100)
|
await settle(gm, [alice.conn])
|
||||||
assert.deepEqual(markersAfter(alice.conn.ws, from)[0].del, [offId])
|
assert.deepEqual(markersAfter(alice.conn.ws, from)[0].del, [offId])
|
||||||
from = alice.conn.ws.messages.length
|
from = alice.conn.ws.messages.length
|
||||||
assert.equal((await gm.ws.request({ t: 'wall.remove', scene: gm.scene,
|
assert.equal((await gm.ws.request({ t: 'wall.remove', scene: gm.scene,
|
||||||
id: gone.id })).ok, true)
|
id: gone.id })).ok, true)
|
||||||
await sleep(100)
|
await settle(gm, [alice.conn])
|
||||||
assert.deepEqual(markersAfter(alice.conn.ws, from)[0].del, [goneId])
|
assert.deepEqual(markersAfter(alice.conn.ws, from)[0].del, [goneId])
|
||||||
gm.ws.close(); alice.conn.ws.close()
|
gm.ws.close(); alice.conn.ws.close()
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
+26
-5
@@ -13,6 +13,9 @@
|
|||||||
# v: the id counter is never written to the DB | w: a wall may stay open | x: zero-length walls accepted
|
# v: the id counter is never written to the DB | w: a wall may stay open | x: zero-length walls accepted
|
||||||
# y: wall endpoints unchecked against the world bounds | z: door.set on a plain wall accepted | z2: persisted `open` loaded inverted
|
# y: wall endpoints unchecked against the world bounds | z: door.set on a plain wall accepted | z2: persisted `open` loaded inverted
|
||||||
# aa: the egress sends every token (LOS and gm_only ignored) | ab: gm_only ignored in the view rule
|
# aa: the egress sends every token (LOS and gm_only ignored) | ab: gm_only ignored in the view rule
|
||||||
|
# Walls r1 (#52): s1 preset xor raw switches | s2 a secret on a non-door is storable | s3 a window
|
||||||
|
# blocks sight | s4 the one-way blind side is flipped | s5 an opening secret/locked door is accepted
|
||||||
|
# | s6 the marker signature ignores thickness | s7 every refresh retracts the marker
|
||||||
# ac: a controlled token is not always visible | ad: no token_gone when a token leaves view
|
# ac: a controlled token is not always visible | ad: no token_gone when a token leaves view
|
||||||
# ae: a player token frame carries the GM-only `kind` | af: explored forgets the cells outside the current polygon
|
# ae: a player token frame carries the GM-only `kind` | af: explored forgets the cells outside the current polygon
|
||||||
# ag: the chunk row stride is dropped | ah: a cell coordinate used as a chunk coordinate | ai: restore forgets rows
|
# ag: the chunk row stride is dropped | ah: a cell coordinate used as a chunk coordinate | ai: restore forgets rows
|
||||||
@@ -137,11 +140,27 @@ TW="never reuses|id counter survives"
|
|||||||
run t "wall removal renumbers next_wall_id" server/world.nim 's/^ sc\.walls\.delete idx\.get$/ sc.walls.delete idx.get; sc.nextWallId = sc.walls.len + 1/' "$TW"
|
run t "wall removal renumbers next_wall_id" server/world.nim 's/^ sc\.walls\.delete idx\.get$/ sc.walls.delete idx.get; sc.nextWallId = sc.walls.len + 1/' "$TW"
|
||||||
run u "the id counter is not loaded from the DB" server/world.nim 's/nextWallId: parseInt(row\[10\])/nextWallId: 1/' "$TW"
|
run u "the id counter is not loaded from the DB" server/world.nim 's/nextWallId: parseInt(row\[10\])/nextWallId: 1/' "$TW"
|
||||||
run v "the id counter is never written to the DB" server/world.nim '/db.exec(sql"UPDATE scene SET next_wall_id/d' "$TW"
|
run v "the id counter is never written to the DB" server/world.nim '/db.exec(sql"UPDATE scene SET next_wall_id/d' "$TW"
|
||||||
run w "a wall may stay open" server/world.nim 's/^ if result\.kind == wkWall: result\.open = false$/ discard/' "a wall is never open"
|
run w "a wall may stay open" server/world.nim 's/^ if not result\.door:$/ if false:/' "a wall is never open"
|
||||||
run x "zero-length walls accepted" server/world.nim 's/ (rec\.a\.x != rec\.b\.x or rec\.a\.y != rec\.b\.y) and inBounds/ inBounds/' "zero-length wall"
|
run x "zero-length walls accepted" server/world.nim 's/ (rec\.a\.x != rec\.b\.x or rec\.a\.y != rec\.b\.y) and inBounds/ inBounds/' "zero-length wall"
|
||||||
run y "wall endpoints unchecked against the world bounds" server/world.nim 's/p\.x >= 0 and p\.y >= 0 and p\.x <= sc\.w and p\.y <= sc\.h/p.x >= 0 and p.y >= 0/' "both endpoints must be inside"
|
run y "wall endpoints unchecked against the world bounds" server/world.nim 's/p\.x >= 0 and p\.y >= 0 and p\.x <= sc\.w and p\.y <= sc\.h/p.x >= 0 and p.y >= 0/' "both endpoints must be inside"
|
||||||
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 z "door.set accepted on a plain wall" server/world.nim '/^ if current\.door == false: 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"
|
run z2 "persisted open state loaded inverted" server/world.nim 's/open: row\[12\] == "1",/open: row[12] == "0",/' "round-trip through a reload"
|
||||||
|
# Walls r1 (#52): the typed record's one resolve path, the switch-set invariants, the sight gates
|
||||||
|
# and the marker cause signature/retraction. Each is a clean in-process kill.
|
||||||
|
RS="presets expand to switches only through the one resolve path"
|
||||||
|
SS="the switch-set invariants reject door-only settings on a non-door"
|
||||||
|
SG="storable is the last gate"
|
||||||
|
OW="one-way: sight_dir names the blind side"
|
||||||
|
SD="door.set refuses to open a secret or locked door"
|
||||||
|
MR="a geometry change retracts"
|
||||||
|
MS="an untouched marker survives"
|
||||||
|
run s1 "a preset may ride along with raw switches" server/world.nim 's/if sw\.hasAny[A-Za-z]*: return none(WallRec)/discard/' "$RS"
|
||||||
|
run s2 "a secret on a non-door is storable" server/world.nim '/^ if rec\.secret and not rec\.door: return false$/d' "$SG"
|
||||||
|
run s3 "a window still blocks sight" server/world.nim 's/^ result\.blocksSight = false$/ result.blocksSight = true/' "$RS"
|
||||||
|
run s4 "the blind side becomes the seeing side" server/geometry.nim 's/^ of wdLeft: s >= -Eps$/ of wdLeft: s <= Eps/' "$OW"
|
||||||
|
run s5 "an opening secret or locked door is accepted" server/world.nim 's/if open and (current\.secret or current\.locked): return waInvalid/discard/' "$SD"
|
||||||
|
run s6 "the marker signature ignores thickness" server/world.nim 's/thickness: w\.thickness, //' "$MR"
|
||||||
|
run s7 "every refresh retracts the marker" server/markers.nim 's/if not byId\.hasKey(wallId) or pv\.markers\[wallId\]\.sig != markerSig(byId\[wallId\]):/if true:/' "$MS"
|
||||||
# slice 5 (#20): the view rule, the egress diff and the explored set
|
# 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 ab "gm_only ignored by the view rule" server/vision.nim '/^ if t\.gmOnly: return false$/d' "$AB"
|
||||||
@@ -163,7 +182,7 @@ run ao "a shrink never clears the walls entries" server/moverules.nim 's/^ sc
|
|||||||
run ap "the property cap is not enforced" server/props.nim '/and p\[bucket\]\.len >= MaxPropKeys/d' "64 keys per bucket|the 65th"
|
run ap "the property cap is not enforced" server/props.nim '/and p\[bucket\]\.len >= MaxPropKeys/d' "64 keys per bucket|the 65th"
|
||||||
run aq "the grow push is skipped" server/moverules.nim 's/^ if not grew:$/ if true:/' "grow inside r of a wall pushes it out"
|
run aq "the grow push is skipped" server/moverules.nim 's/^ if not grew:$/ if true:/' "grow inside r of a wall pushes it out"
|
||||||
run ar "a failed grow is not flagged squeezed" server/moverules.nim '/^ sc.tokens\[ti\]\.squeezedWalls = true$/d' "grow with no room on either side squeezes"
|
run ar "a failed grow is not flagged squeezed" server/moverules.nim '/^ sc.tokens\[ti\]\.squeezedWalls = true$/d' "grow with no room on either side squeezes"
|
||||||
run as "a failed door push sticks instead of squeezing" server/moverules.nim 's/^ sc.tokens\[i\]\.squeezedWalls = true$/ sc.tokens[i].stuckWalls = true/' "push: both sides invalid"
|
run as "a failed door push sticks instead of squeezing" server/moverules.nim 's/^ sc.tokens\[i\]\.squeezedWalls = true$/ sc.tokens[i].stuckWalls = true/' "push: both sides invalid"
|
||||||
run at "one bucket budget shared by all buckets" server/props.nim 's/and p\[bucket\]\.len >= MaxPropKeys/and p[pbPublic].len >= MaxPropKeys/' "64 keys per bucket"
|
run at "one bucket budget shared by all buckets" server/props.nim 's/and p\[bucket\]\.len >= MaxPropKeys/and p[pbPublic].len >= MaxPropKeys/' "64 keys per bucket"
|
||||||
run au "a grow that already fits still pushes" server/moverules.nim 's/^ if not overlapsAny(sc, sc.tokens\[ti\]):$/ if false:/' "a grow that already fits does not move the token"
|
run au "a grow that already fits still pushes" server/moverules.nim 's/^ if not overlapsAny(sc, sc.tokens\[ti\]):$/ if false:/' "a grow that already fits does not move the token"
|
||||||
# slice 8 (#23): the name rule, the encountered snapshot, the token link, in-use, the transfer and
|
# slice 8 (#23): the name rule, the encountered snapshot, the token link, in-use, the transfer and
|
||||||
@@ -193,7 +212,9 @@ run d3 "scene.set accepts a patch with no field" server/world.nim 's/^ if not a
|
|||||||
wait
|
wait
|
||||||
|
|
||||||
rc=0; : > "$LOG"
|
rc=0; : > "$LOG"
|
||||||
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
|
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 \
|
||||||
|
s1 s2 s3 s4 s5 s6 s7 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"
|
[ -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
|
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
|
else echo "$id: NO RESULT (job killed?)" | tee -a "$LOG"; rc=1; fi
|
||||||
|
|||||||
@@ -17,12 +17,17 @@ import { V7_DDL } from './schema7fixture.mjs'
|
|||||||
|
|
||||||
const ALICE = 'ALIC-ALIC-ALIC-ALIC-ALIC'
|
const ALICE = 'ALIC-ALIC-ALIC-ALIC-ALIC'
|
||||||
|
|
||||||
// The four walls the schema-7 fixture holds, as the proto-2 raw-switch create spells them.
|
// The four walls the schema-7 fixture holds, as the proto-2 raw-switch create spells them. Two of
|
||||||
|
// them (the north wall and the closed door) carry non-default but inert geometry: thickness 256,
|
||||||
|
// placement left, height 1. The migrated fixture has the defaults (0/center/null), so the
|
||||||
|
// byte-identical comparison below is also the proof that a stored thickness, placement or height
|
||||||
|
// changes no sight, movement, status or tile (stories 29/30, #52).
|
||||||
|
const INERT_GEOMETRY = { thickness: 256, position: 'left', height: 1 }
|
||||||
const AUTHORED_WALLS = [
|
const AUTHORED_WALLS = [
|
||||||
{ a: [0, 0], b: [4096, 0], flags: { note: 'north' } },
|
{ a: [0, 0], b: [4096, 0], flags: { note: 'north' }, ...INERT_GEOMETRY },
|
||||||
{ a: [10, 10], b: [100, 10] },
|
{ a: [10, 10], b: [100, 10] },
|
||||||
{ a: [100, 100], b: [400, 100], door: true, open: true, flags: { a: 1 } },
|
{ a: [100, 100], b: [400, 100], door: true, open: true, flags: { a: 1 } },
|
||||||
{ a: [500, 500], b: [900, 500], door: true },
|
{ a: [500, 500], b: [900, 500], door: true, ...INERT_GEOMETRY },
|
||||||
]
|
]
|
||||||
|
|
||||||
const canonical = value => {
|
const canonical = value => {
|
||||||
@@ -93,6 +98,16 @@ async function runScript(ctx) {
|
|||||||
|
|
||||||
const door = wallBySegment(gm, [500, 500], [900, 500])
|
const door = wallBySegment(gm, [500, 500], [900, 500])
|
||||||
assert.equal(door.kind, 'door')
|
assert.equal(door.kind, 'door')
|
||||||
|
if (ctx.author) {
|
||||||
|
// The authored stack really stored the non-default geometry (the migrated one keeps defaults),
|
||||||
|
// so the byte-identical player view below cannot pass by both runs having ignored the fields.
|
||||||
|
const north = wallBySegment(gm, [0, 0], [4096, 0])
|
||||||
|
for (const [label, wall] of [['closed door', door], ['north wall', north]]) {
|
||||||
|
assert.deepEqual(
|
||||||
|
{ thickness: wall.thickness, position: wall.position, height: wall.height },
|
||||||
|
INERT_GEOMETRY, `${label}: the non-default geometry is stored and echoed on the GM frame`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The player connects only after the wall set exists in both runs, so the compared sequence starts
|
// The player connects only after the wall set exists in both runs, so the compared sequence starts
|
||||||
// from the same resync.
|
// from the same resync.
|
||||||
|
|||||||
Reference in New Issue
Block a user