diff --git a/routing/test/maintainer-scripts.test.mjs b/routing/test/maintainer-scripts.test.mjs index 66733c6..17c7fb6 100644 --- a/routing/test/maintainer-scripts.test.mjs +++ b/routing/test/maintainer-scripts.test.mjs @@ -110,3 +110,54 @@ test("BS5 --check decodes the committed ARG3 fixture green and prints CH facts assert.match(out, /chRank length: \d+/, "the rank length must print"); assert.ok(!/landmark/i.test(out), "--check prints CH facts, never landmark facts"); }); + +/* ————— MG — the measurement gates: frozen constants + honest ARG3 wording ————— */ + +const OPTIMALITY_SCRIPT = path.join(here, "..", "scripts", "measure-optimality-gate.mjs"); +const SWEEP_SCRIPT = path.join(here, "..", "scripts", "measure-astar-oracle-sweep.mjs"); +const CPU_SCRIPT = path.join(here, "..", "scripts", "measure-route-cpu.mjs"); + +test("MG1 the optimality gate keeps the frozen D-03 constants and honestly names ARG3 when the binary does not decode", () => { + const src = readSrc(OPTIMALITY_SCRIPT); + assert.equal( + countOccurrences(src, "OPTIMALITY_EPSILON_PCT = 0.1"), + 1, + "the ±0.1% epsilon mirror must appear exactly once, unchanged", + ); + assert.equal( + countOccurrences(src, "REQUIRED_BASELINE_ARG_VERSION = 1"), + 1, + "the frozen pre-ALT record's argVersion pin must appear exactly once, unchanged", + ); + const code = stripCommentLines(src); + assert.ok(code.includes("ARG3"), "the decode-failure message must name ARG3 (the current binary's format)"); + assert.ok(code.includes("build-road-graph.mjs"), "the failure must name the rebuild command"); +}); + +test("MG2 the oracle sweep keeps the seeded 200-pair symmetric-compare constants and honestly names ARG3", () => { + const src = readSrc(SWEEP_SCRIPT); + for (const [constant, occurrences] of [ + ["SWEEP_PAIR_COUNT = 200", 1], + ["SWEEP_SEED = 0x08f1", 1], + ["SWEEP_OVERSAMPLE_FACTOR = 3", 1], + ["SWEEP_MIN_PAIR_KM = 12", 1], + ["ORACLE_EPSILON_S = 1e-6", 1], + ]) { + assert.equal(countOccurrences(src, constant), occurrences, `"${constant}" must appear exactly ${occurrences} time(s), unchanged`); + } + const code = stripCommentLines(src); + assert.ok(code.includes("ARG3"), "the decode-failure message must name ARG3 (the current binary's format)"); +}); + +test("MG3 the CPU gate keeps the budget and sample constants exactly once — the 8 ms product budget is the binding pass bar", () => { + const src = readSrc(CPU_SCRIPT); + for (const [constant, occurrences] of [ + ["P95_BUDGET_MS = 8", 1], + ["ROUTE_COUNT = 25", 1], + ["SAMPLE_SEED = 0x06d4", 1], + ["EXTENDED_PAIR_COUNT = 100", 1], + ["EXTENDED_SEED = 0x08a1", 1], + ]) { + assert.equal(countOccurrences(src, constant), occurrences, `"${constant}" must appear exactly ${occurrences} time(s), unchanged`); + } +});