test: tie group evidence to passing tests and baseline restart on the as-built server (#36)

- tools/groups.mjs evidence entries now name the exact test, a minimum assertion
  count and the calls its body must keep; groups.test.mjs checks all three.
- tools/evidence.mjs parses the spec reporter log and fails the gate unless every
  registered evidence test ran and passed; test.sh runs it after the Node suite.
- restart.test.mjs snapshots the live as-built world on the first server, then
  compares it to the post-SIGTERM/SIGKILL state (players connect before the GM, so
  the GM's derived encountered grey is computed on both sides).
- Negative controls: a hollowed auth test fails the new evidence check; a planted
  first-load drop of a token's gm prop bucket fails the new restart baseline while
  the old restart-to-restart test passed.
- Refresh the gate evidence (control + 73 mutations incl. s1-s7, 142 node tests).
This commit is contained in:
2026-11-20 21:55:50 +01:00
parent b0e1633aa9
commit 1f11779658
10 changed files with 816 additions and 216 deletions
+22 -6
View File
@@ -1,12 +1,14 @@
// The M3 acceptance checklist as a test: the nine groups of DESIGN 13 exist, each points at a real
// harness in tools/, and each carries the named test that proves it (DESIGN 14, #12 / #25). This
// fails if someone renames a group test or deletes a group file, so `devbox run test` cannot go
// green with a group silently unproven.
// harness in tools/, and each carries the exact test that proves it (DESIGN 14, #12 / #25). #36:
// "proves it" is not a substring — the declaration and its body must still hold the assertions and
// the call the group claims, and `tools/test.sh` separately requires the reporter to show every one
// of these tests passing (tools/evidence.mjs), so a hollowed or unrun test cannot count.
import test from 'node:test'
import assert from 'node:assert/strict'
import fs from 'node:fs'
import path from 'node:path'
import { GROUP_COUNT, GROUPS } from './groups.mjs'
import { findTestBody } from './evidence.mjs'
import { projectRoot } from './lib.mjs'
const tools = path.join(projectRoot, 'tools')
@@ -24,9 +26,23 @@ test('M3 accept: the nine groups of DESIGN 13 are mapped to named harness tests'
assert.ok(fs.statSync(full).size > 0, `${group}: ${file} is not empty`)
}
assert.ok(spec.evidence.length >= 1, `${group}: names its proving test`)
for (const [file, needle] of spec.evidence) {
const text = fs.readFileSync(path.join(tools, file), 'utf8')
assert.ok(text.includes(needle), `${group}: ${file} contains the test "${needle}"`)
for (const ev of spec.evidence) {
assert.ok(spec.files.includes(ev.file), `${group}: evidence file ${ev.file} is one of the group files`)
assert.equal(typeof ev.test, 'string', `${group}: evidence names an exact test title`)
assert.ok(!ev.test.includes('*'), `${group}: the evidence title is exact, not a glob`)
const text = fs.readFileSync(path.join(tools, ev.file), 'utf8')
const found = findTestBody(text, ev.test)
assert.ok(found,
`${group}: ${ev.file} declares exactly one test with the title "${ev.test}" ` +
'(a renamed, duplicated or absent evidence test fails the group)')
const asserts = (found.body.match(/\bassert\.[A-Za-z]+/g) ?? []).length
const min = ev.minAsserts ?? 1
assert.ok(asserts >= min,
`${group}: "${ev.test}" keeps its assertions (${asserts} found, at least ${min} required)`)
for (const needle of ev.requires ?? []) {
assert.ok(found.body.includes(needle),
`${group}: "${ev.test}" still executes \`${needle}\``)
}
}
}
// Every *group* harness is run by `tools/test.sh` (one glob over tools/*.test.mjs).