From 01051be4ee54f2421ad3a971062ce51d893e5516 Mon Sep 17 00:00:00 2001 From: mj Date: Wed, 3 Jun 2026 20:42:47 -0600 Subject: [PATCH] navi-offroute: stub Valhalla bypass in _auto_router test helper (T3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #46-48 added a road↔road Valhalla bypass (router.py:847-862) that fires when both endpoints have "vehicle" in _auto_eligible_modes. Two synthetic-fixture tests in test_offroute.py — both passing elig = frozenset({"foot","2w","4w","vehicle"}) for all endpoints — unintentionally meet that condition. On matt-desktop the bypass is attempted but Valhalla is unreachable, so it falls through to the unified kernel and the synthetic fixtures route as expected. On the deploy VM Valhalla is healthy and returns real Utah forest-service road geometry that doesn't fit the in-memory 3×20 / 4×14 grid, so the trails[rr,cc] assertions blow up. Fix: monkeypatch _route_D_network_only to return {"status":"error"} inside the _auto_router test helper, forcing the bypass's existing fall-through to the unified kernel on both CPUs deterministically. Affected tests (both passing post-fix): test_route_auto_road_to_road test_route_auto_network_affinity_biases_path Test-only change; production router behaviour unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) --- backend/services/navi_offroute/tests/test_offroute.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/services/navi_offroute/tests/test_offroute.py b/backend/services/navi_offroute/tests/test_offroute.py index f25d367..c0bb323 100644 --- a/backend/services/navi_offroute/tests/test_offroute.py +++ b/backend/services/navi_offroute/tests/test_offroute.py @@ -1119,6 +1119,13 @@ def _auto_router(monkeypatch, elevation, friction_raw, trails, barriers, meta, e monkeypatch.setattr(_p4trans, "get_surface_change_candidates", lambda *a, **k: []) monkeypatch.setattr(_P4Router, "_spatial_eligible_modes", lambda self, lat, lon, cache: eligible(lat, lon)) + # Force the road↔road Valhalla bypass (router.py §847-862, PR #46-48) to fall through + # to the unified kernel: synthetic fixtures use vehicle-eligible endpoints, which would + # otherwise hand off to real Valhalla and produce real-OSM coords that don't match the + # in-memory grid (CI: matt-desktop's Valhalla is unreachable so falls through naturally; + # deploy VM's Valhalla is healthy and returns real Utah road data → assertions blow up). + monkeypatch.setattr(_P4Router, "_route_D_network_only", + lambda *a, **kw: {"status": "error", "reason": "synthetic-test stub"}) return r