sync: capture the production server's code, which was never committed

/root/Routes-api on 31.97.228.132 is not a git repository. Work had been
done directly on the box and existed nowhere else -- a single rm -rf from
being lost, and impossible to review or roll back.

Deploying the previous HEAD over it would have silently reverted all of
this. Most visibly the Valhalla road-backend probe in main.py, whose own
comment explains why it exists: road sequencing degrades to aerial
silently by design, so an unreachable backend stays invisible, "which is
exactly how the expired Google key went unnoticed". Overwriting it would
have reintroduced precisely the failure it was written to catch, and the
service would have kept answering 200 throughout.

The server had also moved from Google Maps to Valhalla for road distance
(VALHALLA_URL, road_backend_status, +190 lines in route_optimizer),
extended docker-compose from 44 to 95 lines, and changed rider fetching,
health, dynamic config and the cache layer.

Only 10 files differ in substance. The other 27 that appeared to differ
were CRLF-vs-LF noise -- the server writes CRLF -- and are normalised to
LF here rather than committed as spurious whole-file rewrites.

Committed as-is, before any change of mine, so the diff that follows is
reviewable against what is actually running.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Suriya
2026-08-11 15:56:32 +05:30
parent f804791864
commit 9ef2f61870
10 changed files with 327 additions and 75 deletions

View File

@@ -38,6 +38,9 @@ DEFAULTS: Dict[str, Any] = {
"emergency_load_penalty": 3.0, # km penalty per order in emergency assign
# RouteOptimizer
"search_time_limit_seconds": 5,
# Active-rider roster cache. The upstream getriderlogs call measured ~6s on
# live traffic. Short TTL so on/off-duty changes surface quickly; 0 = off.
"rider_roster_cache_ttl_seconds": 30,
"avg_speed_kmh": 18.0,
"road_factor": 1.3,
# ClusteringService
@@ -56,12 +59,20 @@ DEFAULTS: Dict[str, Any] = {
"eta_history_days": 14, # rolling window pulled from nearledb
"eta_stat": "median", # "median" or "p75" (p75 = more conservative)
"eta_sync_interval_hours": 6, # autonomous background sync cadence
# Road-aware sequencing (Phase 2). OFF by default: enabling adds a Google
# Directions call (cost + latency) to the route hot path. Results are cached.
# Only the *visiting order* changes; step/ETA metrics stay aerial-based.
# Road-aware sequencing (Phase 2). Backed by self-hosted Valhalla, so there is
# no per-request cost — only local latency. Still OFF by default and left to
# the agent to enable on measured gain. Only the *visiting order* changes;
# step/ETA metrics stay aerial-based.
"routing_use_road_distance": False, # AGENT-MANAGED (see routing_auto_manage)
"routing_road_cache_ttl_seconds": 86400, # road geometry is stable; cache 24h
"routing_road_max_stops": 25, # Google distance-matrix practical cap
"routing_road_max_stops": 25, # beyond this the solver time outweighs
# the ordering gain (not a backend cap)
# Valhalla matrix backend. "motorcycle" models the lane access and one-way
# behaviour our riders actually have; "auto" would overstate their travel time.
"routing_valhalla_costing": "motorcycle",
"routing_matrix_timeout_seconds": 15.0,
"routing_matrix_max_unroutable_pct": 20.0, # above this -> tiles likely missing
# this region, fall back to aerial
# Autonomous road-sequencing decision agent: measures road-vs-aerial travel
# time on real batches and flips routing_use_road_distance on its own.
"routing_auto_manage": True, # False -> humans own the flag