feat(tradein): cross-source matching service (3-tier: cadastr / fingerprint / geo / composite) #470

Merged
lekss361 merged 3 commits from feat/tradein-cross-source-matching into main 2026-05-23 14:12:17 +00:00

3 commits

Author SHA1 Message Date
lekss361
066312ff7c Merge remote-tracking branch 'forgejo/main' into feat/tradein-cross-source-matching
# Conflicts:
#	tradein-mvp/backend/app/services/matching/conflict_resolution.py
2026-05-23 17:09:01 +03:00
lekss361
4470b1a764 fix(tradein): cross-source matching — address PR #470 BLOCK verdict (NOT NULL / geom type / abbreviation order / determinism)
CRITICAL #1: houses INSERT now populates source, ext_house_id, url (NOT NULL cols) with
  ON CONFLICT (source, ext_house_id) upsert; source_url param added with synthetic fallback.
CRITICAL #2: geom removed from INSERT col list — houses_set_geom_trg trigger auto-populates.
CRITICAL #3: Tier 3 ST_DWithin/ST_Distance now cast geom::geography on both sides to avoid
  mixed geometry/geography function lookup failure.
CRITICAL #4: normalize.py _PUNCT now keeps hyphens ([^\w\s\-]); abbreviation expansion for
  пр-кт/б-р/пр-д runs before hyphen collapse, eliminating leftover кт token.
HIGH #5: Tier 0 cadastral queries add ORDER BY id ASC for deterministic results (houses + listings).
HIGH #6: match_or_create_house docstring documents race-condition known limitation + Stage 8.x plan.
Medium #7: no-op ('литер', 'литер') entry removed from _ABBREV.
Medium #9: update_canonical_fields raises NotImplementedError instead of silent pass.
Medium #11: price_rub bigint truncation comment added to _upsert_listing_source.
Medium #14: upsert_listing_source exported from __init__.py __all__.
Tests: 29/29 pass; prkT test asserts no leftover кт; update_canonical_fields test updated.
2026-05-23 17:01:24 +03:00
lekss361
185e7c2e26 feat(tradein): cross-source matching service (3-tier: cadastr / fingerprint / geo / composite)
- normalize.py: normalize_address() + address_fingerprint() (SHA-256, 4dp coords)
- houses.py: match_or_create_house() — tiers: cadastr(1.0) / source_exact(1.0) / fingerprint(0.9) / geo_proximity 30m(0.7) / new
- listings.py: match_or_create_listing() — tiers: cadastr(1.0) / source_exact(1.0) / minhash(0.85) / composite floor+area±2%+rooms(0.75) / new
- conflict_resolution.py: HOUSE/LISTING_FIELD_PRIORITY dicts + update_canonical_fields() stub (Stage 8 v1)
- tests/test_matching.py: 28 unit tests (all pass), mock-DB tier routing coverage
2026-05-23 16:45:25 +03:00