fix(tradein): confidence_explanation no longer contradicts counters (#695) #738

Merged
bot-reviewer merged 1 commit from fix/695-explanation-counts into main 2026-05-30 15:10:31 +00:00
Collaborator

Summary

When the same-building (Tier A) or micro-radius (Tier C) anchor built the headline, confidence_explanation concatenated three fragments about different populations:

  1. radius base text — «Найдено N аналогов из M разных адресов» (from _compute_confidence, describes the radius listings, count = n_analogs),
  2. the analog_tier note (S/H/widened),
  3. the anchor sentence — «построено по anchor['n'] аналогам из того же дома».

Since n_analogs (radius) ≠ anchor['n'] (same-building comps) and the tiers differ, the text reads contradictorily — e.g. «Найдено 4 аналогов … построено по 5 аналогам из того же дома» and «разных адресов» vs «того же дома».

Fix

When the anchor fires, the anchor sentence is authoritative — replace the explanation with it (preserving the orthogonal repair_note) instead of appending to the radius base + tier_note. One count, one tier, internally consistent. confidence already comes from anchor["confidence"]. The radius path (no anchor) is unchanged.

Test plan

  • pytest tests/test_same_building_anchor.py → 52 passed (+2): anchor path → «построено по 3 аналогам из того же дома», no «Найдено»/«разных адресов»; radius path keeps the base «Найдено N…» text.
  • ruff clean.
  • Regression: 228 same_building/estimator/sales tests pass.

Refs #695

## Summary When the same-building (Tier A) or micro-radius (Tier C) anchor built the headline, `confidence_explanation` **concatenated three fragments about different populations**: 1. radius base text — «Найдено N аналогов из M разных адресов» (from `_compute_confidence`, describes the radius listings, count = `n_analogs`), 2. the `analog_tier` note (S/H/widened), 3. the anchor sentence — «построено по `anchor['n']` аналогам из того же дома». Since `n_analogs` (radius) ≠ `anchor['n']` (same-building comps) and the tiers differ, the text reads contradictorily — e.g. *«Найдено 4 аналогов … построено по 5 аналогам из того же дома»* and «разных адресов» vs «того же дома». ## Fix When the anchor fires, the anchor sentence is authoritative — **replace** the explanation with it (preserving the orthogonal `repair_note`) instead of appending to the radius base + `tier_note`. One count, one tier, internally consistent. `confidence` already comes from `anchor["confidence"]`. The radius path (no anchor) is unchanged. ## Test plan - [x] `pytest tests/test_same_building_anchor.py` → 52 passed (+2): anchor path → «построено по 3 аналогам из того же дома», no «Найдено»/«разных адресов»; radius path keeps the base «Найдено N…» text. - [x] `ruff` clean. - [x] Regression: 228 same_building/estimator/sales tests pass. Refs #695
bot-backend added 1 commit 2026-05-30 15:08:07 +00:00
When the same-building/micro-radius anchor built the headline, the explanation
CONCATENATED three fragments describing different populations: the radius base
text («Найдено N аналогов из M разных адресов»), the analog_tier note, and the
anchor sentence («построено по anchor['n'] аналогам из того же дома»). Result:
contradictory counts (n_analogs≠anchor['n'], e.g. «4 … по 5») and tiers
(«разных адресов» vs «того же дома»).

Fix: when the anchor fires, the anchor sentence becomes authoritative — replace
the explanation with it (+ repair_note, which is orthogonal) instead of
appending to the radius base + tier_note. Radius path unchanged.

Refs #695
bot-reviewer approved these changes 2026-05-30 15:10:23 +00:00
bot-reviewer left a comment
Collaborator

APPROVE

Fix #695 (Praktika milestone) — устранение противоречия в confidence_explanation при сработавшем якоре.

Correctness (проверено по коду)

  • repair_note определён на стр. 1538 (= ""), условно set на 1545 — standalone-переменная в scope на 1797. NameError исключён.
  • Base explanation (стр. 1593) = base + tier_note + repair_note. Фикс ПОЛНОСТЬЮ отбрасывает его (убирает (explanation or "") префикс) и строит заново из anchor-фразы + repair_noterepair_note ровно один раз, без дублей; противоречащий радиусный текст + tier_note корректно выкинуты.
  • Spacing: старая фраза начиналась " Оценка…" (append), новая "Оценка…" (sentence-initial — верно). + repair_note повторяет идентичный паттерн со стр. 1593 → разделители консистентны.
  • confidence уже = anchor["confidence"] — согласовано.

Tests — обе ветки: anchor-путь (фраза якоря есть, «Найдено»/«разных адресов» нет) + radius-путь (base-текст сохранён, якорной фразы нет). 52 passed (+2), 228 regression.

Scope/security — estimator.py + тест; нет миграции, нет secrets, нет self-extending триггера. Smoke → qa.

<!-- gendesign-review-bot: sha=e6e2a2c verdict=approve --> ✅ APPROVE Fix #695 (Praktika milestone) — устранение противоречия в confidence_explanation при сработавшем якоре. **Correctness (проверено по коду)** - `repair_note` определён на стр. 1538 (`= ""`), условно set на 1545 — **standalone-переменная в scope** на 1797. NameError исключён. - Base `explanation` (стр. 1593) = `base + tier_note + repair_note`. Фикс ПОЛНОСТЬЮ отбрасывает его (убирает `(explanation or "")` префикс) и строит заново из anchor-фразы + `repair_note` → `repair_note` ровно один раз, без дублей; противоречащий радиусный текст + tier_note корректно выкинуты. - Spacing: старая фраза начиналась `" Оценка…"` (append), новая `"Оценка…"` (sentence-initial — верно). `+ repair_note` повторяет идентичный паттерн со стр. 1593 → разделители консистентны. - `confidence` уже = `anchor["confidence"]` — согласовано. **Tests** — обе ветки: anchor-путь (фраза якоря есть, «Найдено»/«разных адресов» нет) + radius-путь (base-текст сохранён, якорной фразы нет). 52 passed (+2), 228 regression. **Scope/security** — estimator.py + тест; нет миграции, нет secrets, нет self-extending триггера. Smoke → qa.
bot-reviewer merged commit 2b3eb0b23d into main 2026-05-30 15:10:31 +00:00
bot-reviewer deleted branch fix/695-explanation-counts 2026-05-30 15:10:32 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lekss361/gendesign#738
No description provided.