test(parcels): integration EXPLAIN-gate для analyze hot-path SQL (#1198) #1200
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#1200
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/analyze-integration-test"
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
Closes #1198. Integration EXPLAIN-gate для SQL-уровневых регрессий в analyze hot-path. Расширение существующего
tests/integration/phantom-column gate.Зачем (incident #1195 → #1197)
PR #1195 (Phase B #1130) ввёл CTE alias
overlaps(PG keyword для time-period operator(s1,e1) OVERLAPS (s2,e2)). Парсер виделoverlaps AS (и ждал OVERLAPS operator →syntax error at or near "overlaps". Каждый POST /analyze падал ~10 часов до hotfix PR #1197 (фронт получал пустойneighbors_summary).Mock-БД не поймала.
tests/api/v1/test_*.pyпатчатdbчерезMagicMock→db.execute()не парсит SQL, никакого SQL-уровня не видно. Это второй такой случай — первый — recurring psycopg v3:x::typeantipattern (см..claude/rules/backend.md, vaultBug_SQLAlchemy_DoubleColon_Cast).Что в PR
1. Refactor
parcels.py_NEIGHBORS_SUMMARY_SQLвынесен из inlinetext("...")внутри функции в module-level constant (паттерн уже устоявшийся:best_layouts._PARCEL_CENTROID_SQL,ird_overlay_lookup._IRD_OVERLAP_SQL,krt_lookup._PLANNING_KRT_SQL). Делает его доступным для импорта в тестах.CAST(:wkt AS text)/CAST(:our_cad AS text)per.claude/rules/backend.md. Семантика идентична.2. Integration test (
tests/integration/test_analyze_parcels_sql.py, 169 строк)EXPLAIN-тесты (runtime, маркер
integration, skip безTEST_DATABASE_URL):test_explain_neighbors_summary— EXPLAIN над_NEIGHBORS_SUMMARY_SQLпротив реальной prod-PG schema. Был бы поймал #1195.test_explain_ird_overlap— то же для_IRD_OVERLAP_SQL.Compile-time guards (всегда работают, без БД):
test_neighbors_cte_aliases_not_pg_keywords— CTE-alias не должен быть PG-keyword (overlaps/user/current_date/select/where).test_no_bind_double_colon_cast(parametrized над обоими SQL) — запрет:bind::typeantipattern.Запуск EXPLAIN-тестов
Что НЕ в scope этого PR
Test plan
pytest tests/integration/test_analyze_parcels_sql.py→ 3 passed, 2 skipped.pytest tests/api/v1/ -k analyze→ 26 passed (refactor backward-compatible).ruff check+ruff format→ clean.Refs #1198