navi/backend/services/navi_offroute
malice 4fdda175a3
navi-offroute: HPA tile DB manifest pattern (H6a-pre, unblocks continental rollout) (#53)
* navi-offroute: HPA tile DB manifest pattern (H6a-pre, unblocks continental rollout)

Replaces the single-file NAVI_OFFROUTE_HPA_DB env var with a directory-based
manifest layout (NAVI_OFFROUTE_HPA_DIR + manifest.json) so one deployment can
carry multiple regional tile DBs side by side and look up which one(s) cover
a route bbox. The two-level HPA* kernel (astar_hpa_multimode) is unchanged;
router.py asks the new hpa_manifest module for matching tile DBs and forwards
the path to the existing kernel.

Manifest schema (version 1):
  {"version": 1, "tile_dbs": [
    {"name": "idaho", "path": "idaho.db",
     "chunk_bounds": {"min_x": -8550, "max_x": -8430, "min_y": 3100, "max_y": 3260}}
  ]}

- path is relative to the manifest directory.
- chunk_bounds is inclusive in chunk-index space; null = covers everywhere.
- Multiple entries may overlap; v1 dispatch only handles single-region routes,
  multi-region falls through to the unified kernel (UNION across DBs is a
  future PR — needs astar_hpa_multimode signature change).

Backward-compat: if NAVI_OFFROUTE_HPA_DB is set and NAVI_OFFROUTE_HPA_DIR is
not, the loader synthesizes a single unbounded entry and warns (deprecation).
Current deploy keeps working byte-identically; env-file migration happens as
a separate follow-up step.

Touches:
  + hpa_manifest.py (new, 144 LOC) — schema, loaders, lookup, lazy conn cache
  ~ router.py (-24 +31) — _HPA_MANIFEST replaces HPA_TILE_DB; dispatch site
    consults manifest.dbs_for_route_bbox; _hpa_eligible uses manifest.enabled
  + tests/test_hpa_manifest.py (new, 117 LOC) — 8 tests covering all paths
  ~ tests/test_hpa_runtime.py (4 lines) — monkeypatch _HPA_MANIFEST instead

No touches to hpa_build, astar, transitions, cost, mvum. No schema change.
No service restart, no env-file edit (deploy migration happens after merge).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* navi-offroute: drop unused connection cache from HPAManifest (cleanup)

The connection cache field (_conns) and get_connection() method were
shipped in PR #53 "ready for future use" but never consumed by the v1
dispatch path: astar_hpa_multimode opens its own sqlite connection per
call (astar.py:752) and changing that signature was out of scope.

Per self-review of PR #53: shipping dead code in a PR is wrong even
when the rationale is "future PRs will use it." Removing it here keeps
the manifest module focused on lookup; whoever needs the cache later
can add it alongside the use site.

  - Drop _conns field, get_connection() method.
  - Drop sqlite3 + Dict imports (no longer referenced).
  - Drop test_get_connection_caches_per_path.

23 deletions, 2 insertions. No production behaviour change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Ubuntu <zvx@recon-vm.echo6.co>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-04 14:23:19 -06:00
..
tests navi-offroute: HPA tile DB manifest pattern (H6a-pre, unblocks continental rollout) (#53) 2026-06-04 14:23:19 -06:00
__init__.py Add navi-offroute service (extraction #8 — final) (#10) 2026-05-22 23:30:43 -06:00
admin.py navi-offroute: numpy-pack TrailheadIndex (memory opt #2) (#32) 2026-05-26 16:46:22 -06:00
app.py navi-offroute: enable INFO logging for per-stage timing (#35) 2026-05-26 22:02:13 -06:00
astar.py navi-offroute: HPA* runtime kernel + router dispatch (Phase H3) (#45) 2026-05-27 18:00:48 -06:00
barriers.py Add navi-offroute service (extraction #8 — final) (#10) 2026-05-22 23:30:43 -06:00
cost.py navi-offroute: corridor bbox + parallel cost layers (Phase 4.5 perf) (#42) 2026-05-27 14:56:11 -06:00
friction.py Add navi-offroute service (extraction #8 — final) (#10) 2026-05-22 23:30:43 -06:00
HPA-SPEC.md navi-offroute: HPA* perf refactor spec (Phase H1 — docs only) (#43) 2026-05-27 16:26:16 -06:00
hpa_build.py navi-offroute: HPA* precompute pipeline (Phase H2) (#44) 2026-05-27 17:07:09 -06:00
hpa_manifest.py navi-offroute: HPA tile DB manifest pattern (H6a-pre, unblocks continental rollout) (#53) 2026-06-04 14:23:19 -06:00
mvum.py navi-offroute: cache MVUM decoded features process-wide (O3a, perf) (#50) 2026-05-28 02:14:01 -06:00
mvum_annotate.py MVUM Layer 1: per-edge annotation + accurate closure counts (#23) 2026-05-25 19:32:43 -06:00
mvum_exclude.py MVUM Layer 2c: exclude_polygons for closure-avoiding routing (#24) 2026-05-25 19:54:28 -06:00
mvum_parking.py MVUM Layer 3b: OSM parking as multi-modal Auto transition candidates (#31) 2026-05-26 14:48:35 -06:00
mvum_surface_change.py MVUM Layer 3c: surface-change transition candidates (#27) 2026-05-25 23:52:08 -06:00
mvum_transitions.py navi-offroute: numpy-pack TrailheadIndex (memory opt #2) (#32) 2026-05-26 16:46:22 -06:00
offroute_route.py MVUM Layer 3b: OSM parking as multi-modal Auto transition candidates (#31) 2026-05-26 14:48:35 -06:00
router.py navi-offroute: HPA tile DB manifest pattern (H6a-pre, unblocks continental rollout) (#53) 2026-06-04 14:23:19 -06:00
trails.py Add navi-offroute service (extraction #8 — final) (#10) 2026-05-22 23:30:43 -06:00
transitions.py navi-offroute: vectorize road_terminus_transitions (O2b, perf) (#51) 2026-05-28 02:50:26 -06:00
UNIFIED-GRAPH-SPEC.md navi-offroute: unified-graph refactor spec (Phase 1 docs) (#37) 2026-05-27 08:08:15 -06:00