test(08.1-02): add failing maintainer-build CH pins (RED)
BS1-BS5 pin plan 02 task 1's behavior before it exists: the build script must be landmark-free in stripped code, run ONE contractGraph stage into the ch: encode input, print the full measured CH stats block (D-08/D-09), keep the 1-80 MB D-01 envelope single and unchanged, and decode the committed ARG3 fixture green via --check with CH facts. BS1/BS2/BS3/BS5 fail against the current landmark-era script (which cannot even load — landmark.ts was deleted in 08.1-01).
This commit is contained in:
@@ -0,0 +1,112 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
/*
|
||||||
|
* maintainer-scripts.test.mjs — structural + offline behavioral pins for the
|
||||||
|
* routing maintainer toolchain (Phase 08.1 plan 02).
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* The build and measurement scripts are MAINTAINER-TIME tools — the full
|
||||||
|
* build needs the Overpass network and minutes of compute (D-09), so this
|
||||||
|
* suite pins them the way rollout.test.mjs pins the upload/Worker pair:
|
||||||
|
* mechanically, from source shape plus the ONE offline surface (--check on
|
||||||
|
* the committed ARG3 fixture). A pin here is enforced, not customary.
|
||||||
|
*
|
||||||
|
* BS* build-road-graph.mjs — the CH preprocessing stage (plan 02 task 1):
|
||||||
|
* zero landmark/ALT tokens in code, ONE contractGraph call feeding
|
||||||
|
* the `ch:` encode input, the full measured-stats print block
|
||||||
|
* (D-08/D-09: bytes, witness counts, wall-clock — never a payload
|
||||||
|
* ceiling), the unchanged 1-80 MB D-01 envelope, and `--check`
|
||||||
|
* decoding the committed fixture green with CH facts.
|
||||||
|
* MG* the measurement gates (plan 02 task 2): the frozen constants stay
|
||||||
|
* pinned exactly once each (the constant-mirror law) and the
|
||||||
|
* decode-failure wording honestly names ARG3.
|
||||||
|
*
|
||||||
|
* Comment-strip shape = the plan's own verify gate: drop block-comment
|
||||||
|
* CONTINUATION lines (leading `*`) and whole-line `//` comments; anything
|
||||||
|
* else — code, string literals, block-comment OPENING lines — counts.
|
||||||
|
*/
|
||||||
|
import { strict as assert } from "node:assert";
|
||||||
|
import { spawnSync } from "node:child_process";
|
||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import path from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
import { test } from "./harness.mjs";
|
||||||
|
|
||||||
|
const here = path.dirname(fileURLToPath(import.meta.url)); // routing/test
|
||||||
|
const BUILD_SCRIPT = path.join(here, "..", "scripts", "build-road-graph.mjs");
|
||||||
|
const FIXTURE_BIN = path.join(here, "fixtures", "mini-graph.bin");
|
||||||
|
|
||||||
|
function readSrc(file) {
|
||||||
|
return readFileSync(file, "utf8");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The plan-verify comment-strip shape (see the header): a token on a code
|
||||||
|
* line, a string literal, or a block-comment OPENING line counts. */
|
||||||
|
function stripCommentLines(src) {
|
||||||
|
return src
|
||||||
|
.split("\n")
|
||||||
|
.filter((line) => !/^\s*\*/.test(line) && !/^\s*\/\//.test(line))
|
||||||
|
.join("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
function countOccurrences(haystack, needle) {
|
||||||
|
return haystack.split(needle).length - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ————— BS — build-road-graph.mjs: the CH preprocessing stage ————— */
|
||||||
|
|
||||||
|
test("BS1 the build is landmark-free — no landmark/ALT-stage tokens survive comment stripping", () => {
|
||||||
|
const code = stripCommentLines(readSrc(BUILD_SCRIPT));
|
||||||
|
const hits = code.split("\n").filter((line) => line.includes("landmark"));
|
||||||
|
assert.equal(hits.length, 0, `landmark tokens must be gone entirely, found ${hits.length}:\n${hits.join("\n")}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("BS2 the build runs ONE contractGraph stage and encodes the ch block — never a landmarks field", () => {
|
||||||
|
const code = stripCommentLines(readSrc(BUILD_SCRIPT));
|
||||||
|
assert.ok(
|
||||||
|
countOccurrences(code, "contractGraph(") >= 1,
|
||||||
|
"the build must call contractGraph (the ONE CH construction authority)",
|
||||||
|
);
|
||||||
|
assert.ok(!code.includes("landmarks:"), "the encode input must carry ch:, never landmarks:");
|
||||||
|
assert.ok(!code.includes("--landmarks"), "the --landmarks knob is deleted (D-05: no ALT preprocessing)");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("BS3 the build prints the measured CH stats block — counts, witness numbers, CH bytes, wall-clock, total bytes", () => {
|
||||||
|
const src = readSrc(BUILD_SCRIPT);
|
||||||
|
for (const label of [
|
||||||
|
"contracted nodes:",
|
||||||
|
"shortcuts:",
|
||||||
|
"witness searches:",
|
||||||
|
"chRank bytes:",
|
||||||
|
"shortcut bytes:",
|
||||||
|
"build wall-clock:",
|
||||||
|
"total binary:",
|
||||||
|
]) {
|
||||||
|
assert.ok(src.includes(label), `the CH stats block must print "${label}" (D-08/D-09: measured, never hoped)`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test("BS4 the D-01 envelope constants are unchanged and single — the 1-80 MB gate stays, no new payload ceiling", () => {
|
||||||
|
const src = readSrc(BUILD_SCRIPT);
|
||||||
|
assert.equal(
|
||||||
|
countOccurrences(src, "MIN_BINARY_BYTES = 1 * 1024 * 1024"),
|
||||||
|
1,
|
||||||
|
"the enforced 1 MB floor must appear exactly once, unchanged",
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
countOccurrences(src, "MAX_BINARY_BYTES = 80 * 1024 * 1024"),
|
||||||
|
1,
|
||||||
|
"the enforced 80 MB ceiling must appear exactly once, unchanged",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("BS5 --check decodes the committed ARG3 fixture green and prints CH facts — no landmark facts, no network", () => {
|
||||||
|
const res = spawnSync(process.execPath, [BUILD_SCRIPT, "--check", FIXTURE_BIN], {
|
||||||
|
encoding: "utf8",
|
||||||
|
timeout: 30000,
|
||||||
|
});
|
||||||
|
assert.equal(res.status, 0, `--check on the committed fixture must exit 0 (stderr: ${res.stderr})`);
|
||||||
|
const out = res.stdout ?? "";
|
||||||
|
assert.match(out, /chShortcutCount: \d+/, "the ARG3 header field must print");
|
||||||
|
assert.match(out, /shortcut ratio: [\d.]+ per node/, "the shortcut count/ratio must print");
|
||||||
|
assert.match(out, /chRank length: \d+/, "the rank length must print");
|
||||||
|
assert.ok(!/landmark/i.test(out), "--check prints CH facts, never landmark facts");
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user