- 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
25 lines
1.4 KiB
TypeScript
25 lines
1.4 KiB
TypeScript
// Typed Env contract for the araharah bot Worker (D-10/D-11).
|
|
// Secrets (D-15) are wrangler secrets / .dev.vars mirrors — never committed (D-17).
|
|
|
|
export interface Env {
|
|
BOT_TOKEN: string; // wrangler secret (D-15) — Telegram Bot API token from @BotFather
|
|
// WEBHOOK_SECRET MUST be a non-empty secret (D-15) — /telegram/webhook
|
|
// fails closed at request time when missing/empty (WR-02), refusing all
|
|
// deliveries rather than letting grammY's secret check degrade to
|
|
// accept-everything.
|
|
WEBHOOK_SECRET: string; // wrangler secret (D-15) — value Telegram echoes in X-Telegram-Bot-Api-Secret-Token
|
|
chat_sessions: KVNamespace; // TTL-only namespace — first durable KV namespace (PRIV-02)
|
|
// D-01 graph binary — the repo's FIRST R2 binding. A bucket, NEVER a KV
|
|
// namespace (GE5: exactly one kv_namespaces). worker-router's loadGraph
|
|
// memoizes the decoded graph per isolate; an absent/corrupt object
|
|
// degrades honest (null → router-pending, D-03), never a crash. The
|
|
// bucket itself (araharah-graphs) is fork provisioning, not a secret —
|
|
// docs/ROAD-GRAPH.md owns the fork contract.
|
|
ROAD_GRAPH: R2Bucket;
|
|
// The deployed Mini App ORIGIN (public, not a secret) — used to build the
|
|
// OPEN button's deep link. NOT derived from user input: the deep-link
|
|
// origin is a configured value (RESEARCH §Security V4 — an unvalidated
|
|
// origin would be an open redirect).
|
|
MINI_APP_URL: string;
|
|
}
|