feat(08.1-01): ARG3 codec + uphill CH query — ALT deleted, one search path (GREEN)

- graph.ts: ARG3 layout (magic 0x41524733, version 3, chShortcutCount
  u32 @60, reserved @64/@68) with the CH suffix chRank ++ shortcut CSR;
  fail-honest decode (ARG1/ARG2 -> null, chShortcutCount 0 -> null,
  exact-size before any allocation, 4-byte alignment load-bearing);
  loud ch-block encode validation
- ch-query.ts: routeCH — bidirectional uphill search (strict rank filter,
  forward originals+shortcuts, backward reverse views incl. shortcuts),
  edge-ref meet probe, iterative via-unpacking (edge-aware: a parallel
  original edge is never expanded as a shortcut; DERIVE prefers the
  cheaper of original/shortcut), seconds re-summed from the unpacked
  original-edge path. STOP RULE: min(topF, topB) >= mu — the classical
  sum rule is unsound under the rank filter (Q1 caught it: 36 vs 24)
- astar.ts: routeAstar validates + delegates every request to routeCH;
  ALT/BH internals, clean-column memo, landmark tokens DELETED (D-04);
  classifyTurn/deriveSteps untouched
- landmark.ts + landmark.test.mjs deleted (D-05); index.ts additively
  exports contractGraph + CH constants + routeCH
- snap.test.mjs: S3's encode moved to the ARG3 ch block (3-node star —
  a 2-node graph can carry no valid shortcut); committed-fixture S-cases
  suspended until task 3 (Rule 3: same pattern as G7/A1-A6)
- routing suite: 86 passed, 0 failed; typecheck clean
This commit is contained in:
araharah-executor
2026-10-26 07:15:28 +08:00
parent d3f0b4577f
commit 06624bb688
9 changed files with 726 additions and 1426 deletions
+13 -6
View File
@@ -242,18 +242,25 @@ async function buildIslandGraph() {
lng.push((101750000 + i * 500) / 1e6);
}
const edges = [];
const link = (u, v) => {
edges.push({ from: u, to: v, seconds: 10, flags: 0 });
edges.push({ from: v, to: u, seconds: 10, flags: 0 });
// Two weight classes (the committed fixture's speed-class law): a
// UNIFORM-weight graph ties every priority, contracts id-first from the
// endpoints, and starves to ZERO shortcuts — an ARG3 the decode law
// rightly refuses. Varied weights break the ties so the contraction
// builds a real hierarchy.
const link = (u, v, cheap) => {
const seconds = cheap ? 6 : 12;
edges.push({ from: u, to: v, seconds, flags: 0 });
edges.push({ from: v, to: u, seconds, flags: 0 });
};
for (let r = 0; r < 3; r++) {
for (let c = 0; c < 3; c++) {
if (c < 2) link(r * 3 + c, r * 3 + c + 1);
if (r < 2) link(r * 3 + c, (r + 1) * 3 + c);
if (c < 2) link(r * 3 + c, r * 3 + c + 1, r === 1);
if (r < 2) link(r * 3 + c, (r + 1) * 3 + c, c === 1);
}
}
for (let i = 0; i < 3; i++) link(9 + i, 10 + i);
for (let i = 0; i < 3; i++) link(9 + i, 10 + i, i === 1);
const ch = contractGraph({ nodeCount: 13, edges });
assert.ok(ch.stats.shortcutCount > 0, "the island contraction builds a hierarchy");
const g = decodeGraph(
encodeGraph({
lat,