mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-11 14:00:29 +00:00
2f967406df
Production telemetry (30d) shows Patrol averaging ~9.4 billed AI calls per run while only ~1-2 come from the analysis passes. The remainder is the alert auto-resolve review: one QuickAnalysis call per active alert (>=10min old) on every run, re-asking the model about the same standing alert every interval even when the trigger condition demonstrably still holds. Two structural changes, both resolution-neutral: - Still-firing gate: skip the model review for alerts whose current snapshot still shows the trigger condition (metric at/above threshold, offline resource still offline). A correct review could only answer KEEP, so the question is not worth a billed call. The gate never resolves anything locally - uncertain cases (unknown types, missing resources, unmapped metrics) still go to the model, which retains sole authority over resolution. - Batched review: the remaining candidates are reviewed in one model call per 20 alerts (numbered verdict lines, unparseable -> KEEP, bare-RESOLVE fallback for single-alert batches) instead of one call per alert. Steady-state runs with standing alerts drop from N review calls to 0; runs where conditions may have cleared pay ceil(K/20) instead of K. QuickAnalysisRequest gains a TargetType tag (recorded on the usage event) so cost telemetry can decompose alert-review spend from the main patrol pass going forward. Contract updated in-commit (ai-runtime: model-owned resolve direction, cost-gated keep direction, batched review, fail-safe parsing, alert_autoresolve usage tagging).