gendesign/tradein-mvp/backend
Light1YT 99736b6e32
All checks were successful
CI / changes (pull_request) Successful in 6s
CI / backend-tests (pull_request) Has been skipped
CI / frontend-tests (pull_request) Has been skipped
CI / openapi-codegen-check (pull_request) Has been skipped
fix(estimator): ghost-anchor — confidence='low' when radius analogs empty (#1871)
#1871 P1 (Ghost-anchor) trust defect: when the same-building anchor
replaces the headline estimate, the code sets confidence = anchor["confidence"]
and overwrites n_analogs = anchor["n"] (>0). With ZERO radius analogs
(listings_clean == []) this yielded confidence='high'/'medium' on an
estimate built only on same-building comps (sometimes a single
yandex_valuation, e.g. median 38.4M) with no comparable nearby listings.

The defensive guard _enforce_zero_analog_low only fires on n_analogs == 0,
but n_analogs was already overwritten to anchor["n"] (>0) — so it never
caught this path. UI rendered "Высокая · 0 объектов" = fabricated confidence.

Fix: inline guard inside the `if anchor is not None:` block, right after
n_analogs = anchor["n"]. When listings_clean is empty and confidence != 'low',
downgrade to 'low', log a warning, and append an honest caveat to explanation.
Sits before _enforce_zero_analog_low and before the result is finalized, so the
downgraded confidence + caveat propagate to the response.

Test: tests/test_estimator_ghost_anchor_radius_empty_1871.py exercises the
full estimate path (via the test_same_building_anchor harness) with a
tight-spread anchor (n=5, would be 'high') and empty radius → asserts
confidence='low' + caveat present; plus a control that a non-empty radius is
not downgraded.
2026-06-26 21:01:34 +05:00
..
app fix(estimator): ghost-anchor — confidence='low' when radius analogs empty (#1871) 2026-06-26 21:01:34 +05:00
data/sql fix(migration-133): dedup via cascade-delete, not child re-point (prod hotfix) 2026-06-26 08:16:27 +00:00
scripts fix(backfill): drop nonexistent kadastr_num column from listings SELECT 2026-06-17 23:47:30 +03:00
tests fix(estimator): ghost-anchor — confidence='low' when radius analogs empty (#1871) 2026-06-26 21:01:34 +05:00
.dockerignore feat: add tradein-mvp subproject (Trade-In Estimator под /trade-in) 2026-05-21 00:25:39 +03:00
Dockerfile feat(browser): split camoufox into tradein-browser container, connect-mode (#905) 2026-05-31 17:24:35 +03:00
pyproject.toml fix(scrapers/backend): socks5 health-probe (httpx[socks]) + status Literal whitelist + #1820 ext_id=0 dedup-гард 2026-06-20 10:17:37 +03:00