The Walls r1 scenario had grown appendages: a marked window bolted on in the room, a one-way wall tacked onto the southern walk, and no secret or locked door at all. #61 makes it one coherent world and proves the world itself. The world now holds a room entered through an opening door, a far wall with a solid stretch, a secret door and a locked door (a token behind each, so their absence from the transcript is the leak proof), a one-way screen the subject sees across, a marked window in the room, the same window's switch cleared and restored (retraction and re-earn end to end), a marked solid wall, and a marked window the subject never sees. - tools/leak.mjs: declarative WORLD with role handles (no wallIds[1] indexing), narrative groups, and a scenarioCoverage() reading the GM's wall frames and the subject's marker frames. - tools/leak.test.mjs: asserts the coverage on subject A: one-way wall, secret door, locked door, a marked window on each side of the sight gate and a marked non-window. - tools/groups.mjs: the leak+fault group lists doors.test.mjs (#56) and markers.test.mjs (#59/#60) with their proving tests. - docs/TESTING.md: the scenario, the coverage gate and the marker retraction exercise are recorded as built. Fault matrix: all 21 fault classes still caught as exactly their own class (oneWay, markerEarly/Extra/Off included); 22 tests with the clean-build gate. That build passes and its bytes carry no LEAK_FAULT. nimble test and the 136-test node suite green. Ref #61
50 lines
2.6 KiB
JavaScript
50 lines
2.6 KiB
JavaScript
// M3 slice 5 (#20), leak test A and B (DESIGN 10.1 "leak test", 10.3): the driver builds a scene
|
|
// over the real wire and records every frame each socket saw; tools/leakcheck.nim then verifies the
|
|
// subject's whole view against the GM socket (ground truth) and its own geometry. One run per
|
|
// subject on its own server; logs land in results/leak-<subject>.{jsonl,log}.
|
|
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import fs from 'node:fs'
|
|
import path from 'node:path'
|
|
import { runLeak, runChecker } from './leak.mjs'
|
|
import { gmKeyOf, makeStateDir, startServer, stopServer } from './withserver.mjs'
|
|
import { projectRoot } from './lib.mjs'
|
|
|
|
const results = path.join(projectRoot, 'results')
|
|
|
|
for (const subject of ['A', 'B']) {
|
|
test(`leak test ${subject}: the subject's whole view matches the GM's truth`, async () => {
|
|
fs.mkdirSync(results, { recursive: true })
|
|
const stateDir = makeStateDir()
|
|
const gmKey = gmKeyOf(stateDir)
|
|
const s = await startServer({ stateDir })
|
|
const transcript = path.join(results, `leak-${subject}.jsonl`)
|
|
try {
|
|
const run = await runLeak({ origin: s.origin, gmKey, stateDir, transcript })
|
|
assert.ok(run.groups > 15, `the scenario must have real coverage, got ${run.groups} groups`)
|
|
if (subject === 'A') {
|
|
// #61: the world's own contract, read off the GM's wall frames and the subject's markers.
|
|
// A rewrite that drops an element (or a side of the marker sight test) fails here, not in
|
|
// a fault that happens to stop firing.
|
|
const cov = run.coverage
|
|
assert.ok(cov.oneWay >= 1, `the world needs a one-way wall: ${JSON.stringify(cov)}`)
|
|
assert.ok(cov.secretDoors >= 1, `the world needs a secret door: ${JSON.stringify(cov)}`)
|
|
assert.ok(cov.lockedDoors >= 1, `the world needs a locked door: ${JSON.stringify(cov)}`)
|
|
assert.ok(cov.markedNonWindows >= 1,
|
|
`the world needs a marked non-window wall (MARKER_EXTRA control): ${JSON.stringify(cov)}`)
|
|
assert.ok(cov.markedWindowsSeen >= 1,
|
|
`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)}`)
|
|
}
|
|
const check = runChecker(transcript, subject)
|
|
fs.writeFileSync(path.join(results, `leak-${subject}.log`), check.output)
|
|
assert.equal(check.status, 0, `${check.output}\n--- server log ---\n${s.log()}`)
|
|
assert.match(check.output, / 0 failures/)
|
|
} finally {
|
|
await stopServer(s)
|
|
fs.rmSync(stateDir, { recursive: true, force: true })
|
|
}
|
|
})
|
|
}
|