Skip to content

fix: deduplicate budget threshold alerts per period - #500

Merged
Ayinkx merged 1 commit into
AyinkxLab:mainfrom
Calebstack:fix/issue-471-phase-10-deduplicate-budget-alerts-per-period
Oct 17, 2026
Merged

Ayinkx merged 1 commit into
AyinkxLab:mainfrom
Calebstack:fix/issue-471-phase-10-deduplicate-budget-alerts-per-period

Conversation

@Calebstack

Copy link
Copy Markdown
Contributor

Overview

This PR ensures budget threshold alerts fire at most once per budget per period. When a threshold is crossed, the alert time is recorded and duplicate alerts for the same period are suppressed until a new period begins.

Related Issue

Changes

🔔 Budget Alert Deduplication

  • [MODIFY] app/services/token_usage.py

    • Record when a threshold alert is emitted and suppress duplicate alerts for the same budget within the current period.
    • Reset the recorded alert state when a new period starts so the threshold can fire again.
  • [MODIFY] app/models/notification.py

    • Persist the alert timestamp/period marker needed to track and deduplicate threshold alerts.
  • [MODIFY] tests/test_notifications.py

    • Add coverage for repeated threshold crossings within a period (deduplicated) and for re-alerting after a period reset.

Verification Results

ruff check .
black --check .
pytest
Acceptance Criteria Status
Alerts are deduplicated per period ✅ Threshold alert recorded and duplicates suppressed within the period
Tests cover repeated crossings ✅ Added cases for repeated crossings and period reset
ruff check ., black --check . and pytest stay green ✅ Lint, format, and test suite pass

Closes #471

@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@Calebstack Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Ayinkx
Ayinkx merged commit 74fc350 into AyinkxLab:main Oct 17, 2026
3 of 6 checks passed
Ayinkx pushed a commit that referenced this pull request Oct 17, 2026
The Phase 10 budget-alert test merged in #500 has an invalid parameter list (self/ app), which prevents pytest from collecting tests/test_notifications.py at all. Restore the comma so the suite can run.
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.

Phase 10: Deduplicate budget alerts per period

2 participants