Repository navigation
fix(alerts): v2 rules report last_evaluated_at for healthy rules - #2326
Merged
Merged
Maple Review Bot / Maple / review
succeeded
Nov 7, 2026 in 1m 17s
Confidence 10/10 · No issues found
🟢 Confidence 10/10 · safe to merge. Aggregation, both callers and the GET route that reads it, plus the new tests, all check out; nothing to fix.
no findings · tests covered · risk medium · 1/1 new units observable
Makes last_evaluated_at the newest evaluation across a rule's state rows instead of only error rows, and gives the PATCH response the same state list and GET already had. A contained read-path fix with tests on both the service and the wire.
evaluationStatesByRuletakesevaluatedAtfrom the newest state row and the error from the newest row carrying oneloadEvaluationStatesreplaces the inline list query and filters byruleIdfor the edit pathupsertRuleRownow loads evaluation state, so the v2 PATCH response reportslast_evaluated_at
Production impact
Telemetry this change adds and removes (1)
- ➕ span name
AlertRulesService.loadEvaluationStates·packages/backend/src/services/alerts/AlertRulesService.ts:460
What was checked
- A successful tick does clear the row's error (
last_error = excluded.last_error,AlertsService.ts:847), so keeping the newest error row does not pin stale errors on fresh rows - GET
/v2/alerts/rules/{id}resolves throughlistRules(alert-rules.http.ts:480), so retrieve and list cannot disagree - The new
org_id = ? and rule_id = ?read is served by thealert_rule_statesprimary key(orgId, ruleId, groupKey); the state map is still filtered byOrgId
Observability coverage: 1 of 1 changes observable
| Change | Kind | Observable | Evidence |
|---|---|---|---|
| alert_rule_states read (loadEvaluationStates) | db query | yes | Wrapped in Effect.fn("AlertRulesService.loadEvaluationStates"); dbExecute logs failures with the ambient span name |
72a6dd9 · Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.
Loading