Files
arah2/routing/src/index.ts
T
araharah-executor 020eb92058 feat(06-04): /api/route engine-A arm + http-source backend #2 — Bearer-gated, honest-null, RP re-pinned (GREEN)
- bot/src/routing/worker-router.ts: module-scope per-env graph memo (1 R2 GET per
  cold isolate, shared with the 06-07 cron arm via loadGraph), snap+A*+deriveSteps,
  claim-gated 401 / 4096-cap 413 / V5 bbox 400, 200-null on every miss class,
  ONE best route (no alternatives), category-only logs
- webhook.ts: /api/route arm delegating to handleRoute (405 non-POST)
- config.ts: ROAD_GRAPH: R2Bucket — first R2 binding (never a KV namespace, GE5)
- wrangler.jsonc: r2_buckets ROAD_GRAPH -> araharah-graphs with the fork law comment
- routing/src/http-source.ts: createHttpRoutingSource — slug-guard-first, fail-honest
  (throw/non-200/malformed/null-body -> null), defensive RouteResult validation;
  exported from index.ts; ladder note: backend #2 LIVE
- A7 re-pinned (06-01 named 06-04 as the owner of createHttpRoutingSource)
- test-side fix during GREEN: the R2 fake hands decodeGraph an exact ArrayBuffer
  (Node Buffers are views; encodeGraph output is already an ArrayBuffer)
- bot 103 passed / routing 65 passed; both typechecks clean
2026-10-24 13:27:02 +08:00

68 lines
3.0 KiB
TypeScript

/*
* index.ts — the public API surface of @araharah/routing (D-01, D-03, D-07).
* ---------------------------------------------------------------------------
* Named exports ONLY (no default export). The package has NO exports /
* main field (the @araharah/theme + @araharah/search precedent), so
* consumers import the EXPLICIT SUBPATH WITH EXTENSION —
* import { snapToGraph } from "@araharah/routing/src/index.ts";
* (both tsconfigs carry allowImportingTsExtensions + bundler resolution;
* esbuild and Vite compile the .ts source; Node 24 type-stripping handles
* the corpus runner's relative form). A bare "@araharah/routing" specifier
* resolves to NOTHING — never use it.
*
* THE BACKEND LADDER (D-01 supersedes the phase-5 "wasm-router" note):
* #1 "fixture" — createFixtureRoutingSource: the golden-pairs demo
* corpus (15 committed KL pairs).
* #2 "engine-a" — LIVE (plan 06-04): the Worker-side router built on
* THIS package's data plane (decodeGraph + snapToGraph +
* routeAstar over an R2-hosted CSR graph), consumed
* client-side through createHttpRoutingSource (the
* Bearer-gated POST /api/route seam). Engine B (a fully
* client-side webview router — graph on the phone) is
* engine A's documented post-v1 evolution (D-02). The
* Valhalla-to-JS port was ruled infeasible and
* geojson-path-finder rejected (demo-grade: no
* alternatives/one-ways) — recorded so neither is ever
* re-proposed (D-02).
* Engine B remains the documented future rung; nothing else is planned.
*
* The module reads NO environment, NO secrets, and NO network (D-05/D-12):
* the whole routing stack is V8-native and dependency-free — fixtures ride
* the bundle, requests never leave the caller's frame.
*/
export type {
RoutePoint, RouteRequest, RouteSummary, RouteStep,
RouteGeometry, RouteOption, RouteResult, RoutingSource,
FixturePair, FixtureRoute,
} from "./types.ts";
export { decodePolyline6, encodePolyline6 } from "./polyline.ts";
export { haversineM, deriveCumulativeDistanceM } from "./geo.ts";
export {
ORIGIN_TOLERANCE_M,
createFixtureRoutingSource,
getPairOrigin,
getPairs,
} from "./fixture-source.ts";
export { createHttpRoutingSource } from "./http-source.ts";
export type { HttpRoutingSourceOptions } from "./http-source.ts";
export type { RoadGraph, GraphEdgeInput, GraphInput } from "./graph.ts";
export {
decodeGraph,
encodeGraph,
GRAPH_MAGIC,
GRAPH_VERSION,
UNNAMED_NAME_ID,
} from "./graph.ts";
export type { SnapResult } from "./snap.ts";
export { snapToGraph, SNAP_BBOX_MARGIN_DEG } from "./snap.ts";
export type { AstarResult, GuidanceTurnKind } from "./astar.ts";
export {
routeAstar,
deriveSteps,
classifyTurn,
TURN_STRAIGHT_MAX_DEG,
TURN_SLIGHT_MAX_DEG,
TURN_UTURN_MIN_DEG,
} from "./astar.ts";