gendesign/backend/tests/services/forecasting
Light1YT dcccebf2c2
All checks were successful
CI / changes (pull_request) Successful in 7s
CI / frontend-tests (pull_request) Successful in 1m17s
CI / openapi-codegen-check (pull_request) Successful in 2m11s
CI / backend-tests (pull_request) Successful in 10m19s
fix(forecasting): honest scenarios collapse when β rate-sensitivity gate fails (audit #1871 P1)
Когда demand_normalization honesty-gate отбивает β rate-sensitivity
(`sensitivity.confidence=='low'`, ЕКБ-регрессия не проходит n≥30/R²≥0.1/slope<0),
все 393 прод-отчёта получают coefficient=1.0 для всех трёх сценариев
conservative/base/aggressive. По дизайну backend честно деградирует, но фронт
рисует 3 разноцветные карточки/линии одинаковых чисел без caveat.

Backend (scenarios.py, report.py, report_assembler.py, orchestrator.py):
- compute_scenarios теперь возвращает (list, collapsed: bool, reason: str|None)
- _detect_collapsed(): math.isclose(rel_tol=1e-9, abs_tol=1e-6) сравнивает
  projected_demand_units И deficit_index на всех горизонтах между
  conservative и aggressive — расхождение в любой метрике на любом h → False
- _COLLAPSE_REASON_LOW_BETA — единственный источник истины каноничного
  русского предложения
- ReportScenarios получает поля scenarios_collapsed + scenarios_collapse_reason
- demand_normalization.py НЕ ТРОНУТ — поведение корректно по контракту

Backend экспортёры (report_pdf.py, excel.py):
- PDF: при collapse — тёмная плашка-параграф вместо таблицы трёх столбцов
- Excel: ОДНА строка «base» + caveat-ячейка вместо трёх идентичных столбцов

Frontend (forecast.ts, ScenariosBlock, ScenarioCards, ScenarioCompareTable,
ForecastChart, Section6Forecast, ptica.module.css):
- Тип ReportScenarios расширен двумя optional-полями
- ScenariosBlock (light): headline-bar + одна grid-карточка base + caveat
- ScenarioCards (ptica dark): sub-component ScenarioBaseCard, одна карточка
  + collapse-note, ScenarioCompareTable return null
- ForecastChart: effectiveScenarios filter — одна линия viz-1 «Базовый»
  вместо трёх перекрывающихся
- Section6Forecast: caveat выше графика, читается ТОЛЬКО из
  scenarios_collapse_reason (источник истины — backend constant)

Тесты: +18 новых (TestMetricsEqual×6, TestDetectCollapsed×7,
TestComputeScenariosCollapseDetection×4 + 1 проверка graceful + corner).
102 forecasting passed, 88 cross-module passed.

Refs #1871
2026-06-22 19:06:22 +05:00
..
__init__.py feat(forecasting): monthly macro series + regime classifier (#951b) (#1007) 2026-06-03 05:37:43 +00:00
test_affordability.py fix(week-review): backend-аудит v2 — 82 фиксов (#1660) 2026-06-17 17:13:38 +00:00
test_confidence_engine.py fix(forecasting): deal_count confidence note carries «за N мес» window (#1637) 2026-06-17 20:38:00 +03:00
test_demand_normalization.py feat(forecasting): wire Almon-ADL rate estimator into §9.6 consumers (#978) 2026-06-04 10:33:31 +00:00
test_demand_supply_forecast.py feat(forecast): расширить горизонт прогноза до 24 мес (ТЗ §12.1) 2026-06-13 17:27:35 +05:00
test_macro_coefficient.py feat(macro): CBR inflation (ИПЦ YoY) -> macro_indicator + activate §9.5 channel (#946) 2026-06-08 11:41:14 +05:00
test_macro_series.py feat(macro): CBR inflation (ИПЦ YoY) -> macro_indicator + activate §9.5 channel (#946) 2026-06-08 11:41:14 +05:00
test_normalize.py fix(forecasting): count non-zero observations in normalize guard, not zero-filled buckets (#1638) 2026-06-17 20:39:00 +03:00
test_orchestrator.py fix(forecasting): honest scenarios collapse when β rate-sensitivity gate fails (audit #1871 P1) 2026-06-22 19:06:22 +05:00
test_product_scoring.py refactor(forecasting): rename commercial_share_pct → commercial_sell_through_pct (#1635) 2026-06-17 13:32:03 +05:00
test_rate_sensitivity.py feat(forecasting): §9.6 key-rate sensitivity module (#951d, advisory) (#1009) 2026-06-03 06:06:16 +00:00
test_recommendation.py fix(forecasting): thread room_bucket into base_pace/compute_market_metrics for real format ranking (#1593) 2026-06-17 20:55:34 +03:00
test_regression.py feat(forecasting): wire Almon-ADL rate estimator into §9.6 consumers (#978) 2026-06-04 10:33:31 +00:00
test_report.py feat(forecasting): §13 SiteFinderReport object (#987, 955-A1) (#1019) 2026-06-03 08:33:01 +00:00
test_report_assembler.py fix(forecasting): propagate confounded flag DemandSupplyForecast → §15 (#1222) 2026-06-13 15:02:50 +05:00
test_sales_series.py feat(forecast): resolve admin district -> micro set in §9.x market/supply/sales filters 2026-06-05 07:03:37 +05:00
test_scenarios.py fix(forecasting): honest scenarios collapse when β rate-sensitivity gate fails (audit #1871 P1) 2026-06-22 19:06:22 +05:00
test_special_indices.py fix(forecasting): correct _geo_weight decay/floor so far projects get low weight (#1633) 2026-06-17 20:44:00 +03:00
test_what_to_build.py feat(forecasting): what-to-build ranker + MAI proxy (#981, 952-B) (#1013) 2026-06-03 07:07:17 +00:00