mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
The `recommendation` table (~26m rows) has no index on `plan_id`, so any query reaching it via `plan_id` — including the audit's own rollup — seq-scans the whole table and saturates the shared DB (it blocked the DB during the portfolio-796 audit). Make the audit safe-by-default: - statement_timeout (120s) on the audit connection — a hard ceiling so a bad plan aborts instead of hammering the DB. - The recommendation rollup (the two solar checks) is now opt-in via --with-recommendations, and EXPLAIN-gated: it refuses to run (raising RecommendationScanError) when the plan contains a Seq Scan on recommendation, which it does on any large portfolio until idx_recommendation_plan_id exists. - SKILL.md documents the plan_id-no-index trap, the reach-via-property_id / EXPLAIN-first / confirm-with-user rules, and the index as the real fix. Verified on 796/1268: default run is bounded and completes (2,952 anomalies over 31,919 properties); --with-recommendations aborts pre-scan portfolio-wide but is allowed for a single property. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| anomalies.py | ||