feat(cadastre): per-category NSPD snapshot — Phase 1.5 (ZOUIT/ENK) #180
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#180
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/cadastre-per-category-snapshot"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Increase cadastre coverage for ZOUIT/ENK categories which were 0% in full ЕКБ job #8.
search_by_quarterfromthematicSearchId=1tothematic=1(includes ZOUIT in features list).category_idparam routing ZOUIT (36940/469039/469040/469042) →thematicSearchId=5, ENK (39663) →thematicSearchId=15.harvest_quarter: per-category probe for eachPER_CATEGORY_PROBE_CATSwithmeta_total > 0. Skips if category ∈GRID_WALK_CATSANDbboxis valid (grid-walk has better 225-pt coverage).Why
Job #8 (full ЕКБ, 2408 quarters) results: parcels=353 (1.6%), buildings=10837, constructions=106, ОНС=5, ENK=0, ZOUIT=0.
Live
curlprobe againstnspd.gov.ru:thematicSearchId=1returns 20-per-category but excludes ZOUIT entirely.thematic=1strictly better — adds ZOUIT to base response.thematicSearchId=5→ ZOUIT-only (all 4 subtypes).thematicSearchId=15→ ENK-only.categoryIdparam is server-ignored (always returns 20 per cat mixed).Expected impact
search_by_quarter(quarter)(no category_id) works exactly as before but withthematic=1(richer response).Test plan
pytest tests/services/test_cadastre_bulk.py tests/scrapers/test_nspd_bulk_client.py(43 passed locally)SELECT COUNT(*) FROM cad_zouit(expect > 0),cad_enk(expect > 0).Relates to #168.
Review
CI зелёный (backend 1m51s + frontend 1m42s) + cross-check (agent):
✅ Backward compat
search_by_quarterединственный production caller —bulk_harvest.py:129(positionalquarteronly). Новыйcategory_id=Nonedefault — fully backward-compat.✅ Wire-protocol change
thematicSearchId=1→thematic=1Существующие unit-тесты (
test_nspd_bulk_client.py) мокают_get_jsonнапрямую черезpatch.object— param change невидим для фикстуры. Response shape{data: {features}, meta: [...]}сохраняется (mocked). Author подтвердил live-curl: оба эндпоинта возвращают identical shape,thematic=1строго богаче (включает ЗОУИТ).✅ Disjoint cat sets
GRID_WALK_CATS = {36368, 36369}(ЗУ/Здания) ∩PER_CATEGORY_PROBE_CATS = {36940, 469039, 469040, 469042, 39663}(ЗОУИТ/ЕНК) = ∅. Defensive guard на L170 unreachable, но author оставил для safety — норм.✅ Phase ordering + concurrency
Phase 1 → Phase 1.5 (serial for-loop) → Phase 2-3 (grid-walk). Global
_SEMAPHORE = asyncio.Semaphore(3)ограничивает concurrent NSPD calls. Per-cat probes serial — простой и читаемый, добавляет 0–5 calls/quarter. Можно параллелить черезasyncio.gatherпозже если нужно speed-up, но это nano-optimization.✅ Test coverage solid
3 asyncio теста:
test_harvest_quarter_calls_per_cat_probe_for_zouit_when_meta_nonzero— probe вызывается сcategory_id ∈ CAT_ZOUIT,result.zouit_upserted >= 1.test_harvest_quarter_skips_per_cat_probe_when_meta_zero—await_count == 1(только базовый),category_idis None.test_harvest_quarter_per_cat_probe_enk_called_when_meta_nonzero— probe сcategory_id=CAT_ENK.Покрывают main happy paths + skip-condition.
✅ Drift отсутствует
QuarterSnapshotpydantic schema без изменений. TS callers отсутствуют (scraper server-side only). Routingupsert_featuresуже умеет различать категории.✅ Risk profile
Default behavior строго richer (раньше ЗОУИТ был исключён, теперь включён в base snapshot). Per-cat probe — opt-in через meta_total > 0. Worst case — лишние 0–5 NSPD calls на quarter где есть ЗОУИТ/ЕНК. Pilot v7 покажет реальный delta coverage.
approve merge