Skip to content

fix(alerts): fire change_pct rules on spikes from a zero baseline (audit_28 §5)#105

Merged
brownjuly2003-code merged 1 commit into
mainfrom
fix/change-pct-zero-baseline
Jun 29, 2026
Merged

fix(alerts): fire change_pct rules on spikes from a zero baseline (audit_28 §5)#105
brownjuly2003-code merged 1 commit into
mainfrom
fix/change-pct-zero-baseline

Conversation

@brownjuly2003-code

Copy link
Copy Markdown
Owner

Summary

Closes audit_28_06_26.md §5: alert change_pct rules did not fire on a spike
from a zero baseline.

evaluate_rule reported a flat 100% change 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
100 sentinel 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_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. The non-zero-baseline path is
unchanged.

Tests

New tests/unit/test_alert_evaluator.py:

  • rise from zero fires an "above" rule even past 100% (the bug)
  • no-change 0 → 0 does not fire
  • fall from zero fires a "below" rule
  • non-zero baseline still computes a numeric pct (regression guard)

Verification (no-Docker)

ruff / format / mypy clean; new unit tests pass; existing alert unit suite green;
diff LF-clean.

🤖 Generated with Claude Code

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>
@github-actions

Copy link
Copy Markdown

DORA Metrics

  • Window: last 30 days
  • Branch: main
  • Deployment frequency: 167 total / 38.97 per week
  • Lead time for changes: avg 0.27h / median 0.0h
  • Change failure rate: 59.28% (99/167)
  • MTTR: 0.23h across 4 incident(s)

@brownjuly2003-code brownjuly2003-code merged commit 838bfab into main Jun 29, 2026
22 of 23 checks passed
@brownjuly2003-code brownjuly2003-code deleted the fix/change-pct-zero-baseline branch June 29, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants