test: walls r1 review — tests and tools

Ref #52
This commit is contained in:
2026-11-20 08:59:24 +01:00
parent e1a5b297e4
commit 38941da003
14 changed files with 329 additions and 69 deletions
+32 -3
View File
@@ -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.
// `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' } })
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 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)
// 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)
// 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()
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)}`)
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
// 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()
await Promise.all([a.ws.closed, b.ws.closed])
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
@@ -263,6 +268,7 @@ async function runPair(aVariant, bVariant, opts = {}) {
for (const [i, variant] of [aVariant, bVariant].entries()) {
const run = await runScript(stacks[i], variant, {
...opts,
geometry: opts.geometry?.[i] ?? null,
segmentOpen: opts.segmentOpen?.[i] ?? null,
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 () => {
const { a, b } = await runPair({}, { door: true, open: true },
{ segmentOpen: ['invalid', 'ok'], crosses: [false, true] })
+6 -2
View File
@@ -43,9 +43,13 @@ export const GROUPS = {
['restart.test.mjs', 'restart: full state, all CRUD, before and after SIGKILL']],
},
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'],
['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: {
files: ['logs.test.mjs'],
+17 -7
View File
@@ -19,9 +19,10 @@
// 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
// 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)
// and a marked window far outside every scripted position (never seen:
// MARKER_EARLY control)
// marked solid wall in the room (switch on, no marker: MARKER_EXTRA control),
// a marked window far outside every scripted position (never seen: MARKER_EARLY
// 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
// 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
@@ -33,10 +34,13 @@
import fs from 'node:fs'
import path from 'node:path'
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'
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')
// 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
// MARKER_EARLY negative control, #60).
{ 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
// 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
@@ -123,6 +129,7 @@ export function scenarioCoverage(gmMsgs, subjMsgs) {
}
const marked = all.filter(w => w.player_marker)
const windows = marked.filter(isWindow)
const occluded = windows.filter(w => anchorOf(w)[0] > FAR_WALL_X)
return {
walls: all.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.
markedWindowsSeen: 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,
}
}
+4
View File
@@ -36,6 +36,10 @@ for (const subject of ['A', 'B']) {
`the world needs a marked window the subject sees: ${JSON.stringify(cov)}`)
assert.ok(cov.markedWindowsUnseen >= 1,
`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)
fs.writeFileSync(path.join(results, `leak-${subject}.log`), check.output)
+64 -36
View File
@@ -104,6 +104,13 @@ type
anchor: (int, int)
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
label: string
gmMsgs: seq[JsonNode]
@@ -466,7 +473,7 @@ proc main() =
var encounterable: HashSet[string] # token ids the subject may have met (independent oracle)
var viewCharacters: HashSet[string] # character ids the subject was sent
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 markerPositive = false # the scenario exercised the oracle at least once
@@ -775,9 +782,43 @@ proc main() =
if m["full"].getBool: markers.clear()
for e in m["set"]:
let id = e["id"].getStr
let pos = (e["pos"][0].getInt, e["pos"][1].getInt)
if markers.hasKey(id):
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"):
for d in m["del"]:
let id = d.getStr
@@ -802,42 +843,29 @@ proc main() =
if expectedMarkers.hasKey(mw.id): continue
if extentSeen(polysChecks, mw.a, mw.b):
expectedMarkers[mw.id] = ExpectedMarker(anchor: anchorOf(mw), sig: markerSig(mw))
var wantPos: seq[(int, int)]
for _, em in expectedMarkers: wantPos.add em.anchor
var gotPos: seq[(int, int)]
for _, pos in markers: gotPos.add pos
wantPos.sort()
gotPos.sort()
# Multiset difference: `missing` markers the memory expects, `extra` ones it does not. An
# extra at a marker candidate's anchor was sent before its extent was seen (EARLY); an extra
# with no candidate wall at all must never exist (EXTRA).
var missingMarkers, extraMarkers: seq[(int, int)]
var wi = 0
var gi = 0
while wi < wantPos.len or gi < gotPos.len:
if wi >= wantPos.len:
extraMarkers.add gotPos[gi]; inc gi
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 " &
var owned: HashSet[int]
for _, seen in markers:
if seen.wall >= 0: owned.incl seen.wall
# Keyed by wall, not by anchor: two candidate walls sharing a midpoint stay two obligations,
# and an id's stability is its wall's ownership (a re-mint is caught when the set arrives).
var missingWalls: seq[int]
for wallId in expectedMarkers.keys:
if wallId notin owned: missingWalls.add wallId
if missingWalls.len > 0:
missingWalls.sort()
fail "MARKER_OFF", "marker for wall " & $missingWalls[0] & " was never sent (" &
$missingWalls.len & " missing; group " & g.label & ")"
for _, seen in markers:
if seen.wall < 0:
fail "MARKER_EXTRA", "marker " & $seen.pos & " has no marker candidate wall (group " &
g.label & ")"
else:
fail "MARKER_EXTRA", "marker " & $pos & " has no marker candidate wall (group " &
elif not expectedMarkers.hasKey(seen.wall):
# 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 & ")"
if wantPos.len > 0:
if expectedMarkers.len > 0:
markerPositive = true
# --- CONTROLLER_CHANGE (10.3) ----------------------------------------------------------------
+6
View File
@@ -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)))
// 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}`
// Ports of a live dev session: never let a test stack touch them (prototype withserver.sh rule).
+34 -10
View File
@@ -14,6 +14,30 @@ import { createPlayer, namePlayer, sleep } from './lib.mjs'
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) {
const conn = await openAs(origin, gmKey)
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).
let from = player.conn.ws.messages.length
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,
'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
await addWall(gm, { blocks_sight: false, blocks_movement: true, door: true,
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,
'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
assert.equal((await gm.ws.request({ t: 'token.move', id: aliceToken,
pos: [2000, 2000] })).ok, true)
await sleep(120)
await settle(gm, [alice.conn])
assert.equal(markersAfter(alice.conn.ws, from).length, 0,
'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
assert.equal((await gm.ws.request({ t: 'door.set', scene: gm.scene, id: window.id,
open })).ok, true)
await sleep(80)
await settle(gm, [alice.conn])
assert.equal(markersAfter(alice.conn.ws, from).length, 0,
`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)
const carol = await namedPlayer(gm, s.origin, 'Marker Carol')
await addSightToken(gm, carol, [300, 300])
await sleep(150)
await settle(gm, [carol.conn])
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')
@@ -238,17 +262,17 @@ test('retraction: every cause sends del only, a re-earned marker gets a fresh id
const away = async () => {
assert.equal((await gm.ws.request({ t: 'token.move', id: tokenId,
pos: [2000, 2000] })).ok, true)
await sleep(100)
await quiet([gm, alice.conn])
}
const back = async () => {
assert.equal((await gm.ws.request({ t: 'token.move', id: tokenId,
pos: [300, 300] })).ok, true)
await sleep(100)
await quiet([gm, alice.conn])
}
const retract = async action => {
const from = alice.conn.ws.messages.length
assert.equal((await action()).ok, true)
await sleep(100)
await settle(gm, [alice.conn])
return framesAfter(alice.conn.ws, from)
}
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
assert.equal((await gm.ws.request({ t: 'wall.update', scene: gm.scene, id: off.id,
player_marker: false })).ok, true)
await sleep(100)
await settle(gm, [alice.conn])
assert.deepEqual(markersAfter(alice.conn.ws, from)[0].del, [offId])
from = alice.conn.ws.messages.length
assert.equal((await gm.ws.request({ t: 'wall.remove', scene: gm.scene,
id: gone.id })).ok, true)
await sleep(100)
await settle(gm, [alice.conn])
assert.deepEqual(markersAfter(alice.conn.ws, from)[0].del, [goneId])
gm.ws.close(); alice.conn.ws.close()
} finally {
+26 -5
View File
@@ -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
# 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
# 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
# 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
@@ -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 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 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 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 z2 "persisted open state loaded inverted" server/world.nim 's/open: row\[6\] == "1",/open: row[6] == "0",/' "round-trip through a reload"
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\[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
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"
@@ -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 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 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 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
@@ -193,7 +212,9 @@ 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 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"
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
+18 -3
View File
@@ -17,12 +17,17 @@ import { V7_DDL } from './schema7fixture.mjs'
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 = [
{ 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: [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 => {
@@ -93,6 +98,16 @@ async function runScript(ctx) {
const door = wallBySegment(gm, [500, 500], [900, 500])
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
// from the same resync.