test(spec): golden-fixture cross-runtime parity gate for the node picker

Replace the env-driven parity harness with a shared scenario module and a
committed golden the node picker asserts independently. The goja side asserts
the same golden, so neither runtime invokes the other at test time.
This commit is contained in:
pj committed 2026-06-01 17:27:14 +05:30
1 parent 0fa6968a5a
commit e3bb9aeeb2
3 files changed
+193 -27

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { test } from "node:test";
import { PARITY_STEPS, runParity } from "./parity-harness.ts";
const goldenPath = fileURLToPath(new URL("./fixtures/parity-golden.json", import.meta.url));
const golden = JSON.parse(readFileSync(goldenPath, "utf8"));
// The node side of the W2 acceptance gate: the shared picker's stream for the
// fixed parity scenario must match the committed golden byte-for-byte. The goja
// test asserts the SAME golden, so a match on both sides proves cross-runtime
// parity. A drift here means pick.ts, the corpus, or the Pcg changed.
test("node picker matches the cross-runtime golden", () => {
const stream = runParity();
assert.equal(stream.length, PARITY_STEPS);
assert.deepEqual(stream, golden);
});
// Determinism: a second run from the same seed yields the identical stream.
test("node picker is deterministic across repeated runs", () => {
assert.deepEqual(runParity(), runParity());
});