fix(tradein): feed raw payload.address to same-building anchor (geocode-independent)

The #677/#679 same-building anchor was fed geo.full_address (the GEOCODED
canonical address). On prod the geocoder frequently returns None (lat/lon/
canonical all None), so geo.full_address was empty → _normalize_building_key
got nothing → Tier A (same building) never fired → fell back to the radius
tier for every geocode-failing address. That is why live golden coverage was
67/58% (and flaky run-to-run) while the offline sim (which fed the raw address)
showed 95%: Ткачёва 13 / Хохрякова 48 etc. geocode-fail on prod.
Fix: pass payload.address (raw user input, always present, exactly what the
normalizer is validated on) with geo.full_address as fallback. Makes the
same-building anchor independent of geocode success. ruff clean; 30 anchor tests.

Refs #651 #677 #679
This commit is contained in:
lekss361 2026-05-30 02:07:38 +03:00
parent b5c26d2723
commit 3a25e2c4b8

View file

@ -1624,7 +1624,11 @@ async def estimate_quality(
comps, anchor_tier = _fetch_anchor_comps(
db,
address=geo.full_address,
# payload.address (сырой ввод) ПЕРВИЧЕН: на проде геокод часто
# возвращает None (lat/lon/canonical=None), и geo.full_address пуст —
# тогда same-building Tier A не находил дом и падал в радиус. Raw-адрес
# всегда есть и именно на нём валидирован нормализатор (#677/#679).
address=payload.address or geo.full_address,
target_house_id=target_house_id,
lat=geo.lat,
lon=geo.lon,