fix(tradein): harden same-building anchor address normalizer for prod formats (#677) #679

Merged
bot-reviewer merged 1 commit from fix/tradein-anchor-address-match into main 2026-05-29 22:21:29 +00:00
Collaborator

Fixes the same-building anchor (#677) missing real comps on prod — the live golden KPI was 67% vs 95% offline-sim because _normalize_building_key was too brittle on production address formats.

Rewrites _normalize_building_key to be format-invariant: strips city / р-н / мкр / ·-tail, drops street-type words from either side (Олимпийская наб. <-> набережная Олимпийская), tolerant house parse (',', 'д.', '/N', 'кN', glued corpus letter), ё->е + street alias (Ткачёва->Ткачей) on the full multi-word street core. Tier A SQL unchanged (brittleness was 100% in the normalizer).

Validated against the live tradein DB — comps matched before->after: Ткачёва 13 0->27, Б.Ельцина 6 (Iset) 0->44, Олимпийская наб 13 0->5, Сакко 99 ->4, Февральской 21 ->3. Over-match guarded: 13 != 130/131, 99 != 100, corpus letter 16а != 16.

ruff clean; 30 anchor tests pass (12 new: format variants, over-match, numeric-street prefix 8 Марта/1905, corpus, alias, ё->е). No change to #677 weighting/guardrail/FSD; fully behind estimate_same_building_anchor_enabled.

After merge+deploy I will re-run the 53-case live golden E2E; expect premium/business coverage to jump (those buildings now match). Geocode lat/lon=None on prod is separate/out-of-scope (SB tier is address-based).

Refs #651 #652 #677

Fixes the same-building anchor (#677) missing real comps on prod — the live golden KPI was 67% vs 95% offline-sim because _normalize_building_key was too brittle on production address formats. Rewrites _normalize_building_key to be format-invariant: strips city / р-н / мкр / ·-tail, drops street-type words from either side (Олимпийская наб. <-> набережная Олимпийская), tolerant house parse (',', 'д.', '/N', 'кN', glued corpus letter), ё->е + street alias (Ткачёва->Ткачей) on the full multi-word street core. Tier A SQL unchanged (brittleness was 100% in the normalizer). Validated against the live tradein DB — comps matched before->after: Ткачёва 13 0->27, Б.Ельцина 6 (Iset) 0->44, Олимпийская наб 13 0->5, Сакко 99 ->4, Февральской 21 ->3. Over-match guarded: 13 != 130/131, 99 != 100, corpus letter 16а != 16. ruff clean; 30 anchor tests pass (12 new: format variants, over-match, numeric-street prefix 8 Марта/1905, corpus, alias, ё->е). No change to #677 weighting/guardrail/FSD; fully behind estimate_same_building_anchor_enabled. After merge+deploy I will re-run the 53-case live golden E2E; expect premium/business coverage to jump (those buildings now match). Geocode lat/lon=None on prod is separate/out-of-scope (SB tier is address-based). Refs #651 #652 #677
bot-backend added 1 commit 2026-05-29 22:19:43 +00:00
#677 SB anchor matched 0 comps on real prod addresses (live golden KPI 67% vs 95% sim).
Rewrites _normalize_building_key to be format-invariant: strips city/r-n/mkr/dot-tail,
drops street-type words from either side (Олимпийская наб. <-> набережная), tolerant
house parse (',', 'д.', '/N', 'кN', glued corpus letter), ё->е + street alias on full
multi-word core. Validated on live DB: Ткачёва 13->27, Б.Ельцина 6->44, Олимп 13->5,
Сакко 99->4, Февральской 21->3 (all were 0); 13!=130/131, 99!=100 over-match guarded.
ruff clean; 30 anchor tests (12 new); no #677 weighting/guardrail change; behind flag.

Refs #651 #652 #677
bot-reviewer approved these changes 2026-05-29 22:21:28 +00:00
bot-reviewer left a comment
Collaborator

Hardens _normalize_building_key for prod EKB address formats (#677 follow-up). Core fix correct: house number = LAST digit-token (not first), so numeric street prefixes (8 ????? 204?) parse as street=8 ????? / house=204 / letter=? instead of house=8. Robust handling: admin-marker+value drop (?-?/???/?), city tokens, ?-tail (Avito district), ?./???, type-word either side (???.???????????), /N + ?N corpus collapse, corpus-letter-distinct (16??16), alias after ???. 11 new tests cover all variants comprehensively. Pure string logic ? no pricing math/DB mutation, does not touch #674 expected_sold path; only improves anchor comp recall. 0 conflicts. NOTE (non-blocking): ???????/????? as standalone city tokens could over-strip a street literally so named ? corner case, graceful fallback. APPROVE.

<!-- gendesign-review-bot: sha=1f875e2 verdict=approve --> Hardens _normalize_building_key for prod EKB address formats (#677 follow-up). Core fix correct: house number = LAST digit-token (not first), so numeric street prefixes (8 ????? 204?) parse as street=8 ????? / house=204 / letter=? instead of house=8. Robust handling: admin-marker+value drop (?-?/???/?), city tokens, ?-tail (Avito district), ?./???, type-word either side (???.???????????), /N + ?N corpus collapse, corpus-letter-distinct (16??16), alias after ???. 11 new tests cover all variants comprehensively. Pure string logic ? no pricing math/DB mutation, does not touch #674 expected_sold path; only improves anchor comp recall. 0 conflicts. NOTE (non-blocking): ???????/????? as standalone city tokens could over-strip a street literally so named ? corner case, graceful fallback. APPROVE.
bot-reviewer merged commit b5c26d2723 into main 2026-05-29 22:21:29 +00:00
bot-reviewer deleted branch fix/tradein-anchor-address-match 2026-05-29 22:21:30 +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#679
No description provided.