fix(alerts): fire change_pct rules on spikes from a zero baseline (audit_28 §5)#105
Merged
Merged
Conversation
evaluate_rule reported a flat 100% change_pct whenever the previous-window value was 0, so an "above" change rule with threshold > 100 never fired on a spike from zero (e.g. revenue 0 -> 500 with a +200% rule stayed silent), and the sentinel was a misleading number for an undefined ratio. A change from a zero baseline is a mathematically undefined (unbounded) ratio: report change_pct as None and decide firing by direction — any rise satisfies an "above" rule (threshold >= 0), any fall a "below" rule. A flat 0 -> 0 still reports 0% and does not fire. Non-zero-baseline path is unchanged. Adds test_alert_evaluator.py (rise/fall-from-zero firing, no-change, and a non-zero-baseline regression guard). (audit_28_06_26.md §5) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
DORA Metrics
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes
audit_28_06_26.md§5: alertchange_pctrules did not fire on a spikefrom a zero baseline.
evaluate_rulereported a flat100%change whenever the previous-window valuewas
0. So an "above" change rule withthreshold > 100never fired on a spikefrom zero (e.g.
revenue0 → 500with a+200%rule stayed silent), and the100sentinel was a misleading number for what is an undefined ratio.Fix: a change from a zero baseline is a mathematically undefined (unbounded)
ratio. Report
change_pctasNoneand decide firing by direction — anyrise satisfies an "above" rule (
threshold >= 0), any fall a "below" rule. Aflat
0 → 0still reports0%and does not fire. The non-zero-baseline path isunchanged.
Tests
New
tests/unit/test_alert_evaluator.py:0 → 0does not fireVerification (no-Docker)
ruff / format / mypy clean; new unit tests pass; existing alert unit suite green;
diff LF-clean.
🤖 Generated with Claude Code