feat(08.1-01): rebuild all fixtures and bot graph builders through the ARG3 path

- mini-graph-arg2.bin: the frozen ARG2-era bytes preserved once as the
  D-12 decode-rejection vector (never regenerated — the arg1 precedent)
- build-mini-graph.mjs: landmark stage out, CH stage in — contractGraph
  over the 25-node grid (41 shortcuts, 1.64/node, 0 budget hits) with
  fail-loud invariants: total-order rank, grid shortcut band, upward
  shortcuts, overlay-exact constituent weights (f64 replay, f32 compare),
  strong connectivity; deterministic ARG3 bytes
- graph.test.mjs: committed-fixture G4 added (ARG3 magic/version, 25
  nodes, 80 edges, rank 25, >=1 shortcut, ARG2 vector -> null); G7
  restored (full ARG3 pin)
- astar.test.mjs: A1-A6 restored — the 625-pair Dijkstra equivalence,
  oneway law, deriveSteps, depart/arrive, classifyTurn all green against
  the CH query on the committed ARG3 fixture
- snap.test.mjs: S1-S6 restored on the ARG3 fixture; S3's synthetic
  graph rebuilt as the ARG3 ch-block star
- webhook.test.mjs: landmarkBlock -> chBlock (contractGraph); corridor
  gains the fast nonstop chord (a pure line starves to zero shortcuts);
  sparse star keeps node ids 0-hub; RT9's split carrier is now two
  disconnected decodable stars (the honest A\* miss)
- guidance-cron.test.mjs: GC6b's 2-node graph becomes the lowest-id-mid
  3-node star (a 2-node graph cannot carry a valid shortcut)
- routing 87 passed / bot 126 passed; routing+bot+web typechecks green
This commit is contained in:
araharah-executor
2026-10-26 07:30:15 +08:00
parent 06624bb688
commit 4ca7a71d15
8 changed files with 524 additions and 132 deletions
+15 -12
View File
@@ -49,7 +49,7 @@ const { strings } = await import("../src/i18n/strings.ts");
const { encodePolyline6 } = await import("@araharah/routing/src/polyline.ts");
const { deriveCumulativeDistanceM, haversineM } = await import("@araharah/routing/src/geo.ts");
const { encodeGraph, decodeGraph } = await import("@araharah/routing/src/graph.ts");
const { LANDMARK_QUANTUM_S, landmarkTables } = await import("@araharah/routing/src/landmark.ts");
const { contractGraph } = await import("@araharah/routing/src/contraction.ts");
/* ————— geometry helpers (1e-6-grid-exact construction, the codec's grid law) ————— */
@@ -250,23 +250,26 @@ test("GC6b unnamed matched edge → cardStreetUnnamed ('UNNAMED ROAD') — still
// A purpose-built unnamed way through the same encodeGraph contract
// (names: [] → every edge carries the UNNAMED_NAME_ID sentinel).
const meters = haversineM({ lat: 3.15, lng: 101.69 }, { lat: 3.1505, lng: 101.69 });
const edges = [
// A 3-node star through the same encodeGraph contract (names: [] →
// every edge carries the UNNAMED_NAME_ID sentinel). ARG3 (Phase 08.1):
// the ch block comes from the ONE contraction core, and the MID owns
// the LOWEST id — the priority tie contracts lowest-id-first, so a mid
// with id 1 would starve to zero shortcuts and an ARG3 with no
// shortcuts is not a road graph. Geometry: north leg (0->1), east leg
// (0->2) — the turn at the shared mid vertex.
const starEdges = [
{ from: 0, to: 1, seconds: meters / (30 / 3.6) },
{ from: 1, to: 0, seconds: meters / (30 / 3.6) },
{ from: 0, to: 2, seconds: meters / (30 / 3.6) },
{ from: 2, to: 0, seconds: meters / (30 / 3.6) },
];
// A 2-node graph has no degree>=2 farthest-point candidate (the selection
// filter), so the anchor pins directly — the tables still come from the
// ONE integer-Dijkstra core (08-02), through the ONE encode authority.
const landmarkInput = { nodeCount: 2, edges, quantumS: LANDMARK_QUANTUM_S };
const anchors = Uint32Array.of(0);
const { to, from } = landmarkTables(landmarkInput, anchors);
const buf = encodeGraph({
lat: [3.15, 3.1505],
lng: [101.69, 101.69],
edges,
lat: [3.15, 3.1505, 3.15],
lng: [101.69, 101.69, 101.6905],
edges: starEdges,
names: [],
maxSpeedKmh: 30,
landmarks: { quantumS: LANDMARK_QUANTUM_S, nodes: anchors, to, from },
ch: contractGraph({ nodeCount: 3, edges: starEdges }),
});
const graph = decodeGraph(buf);
assert.notEqual(graph, null);