You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a budget notification system that triggers alerts at 50%, 80%, and 100% usage thresholds. It includes the new BudgetThreshold enum, a BudgetNotificationService to manage alert frequency, and updates to DefaultBudgetEvaluator to support these new levels. Feedback focuses on improving the robustness of the notification logic, specifically by including budget cycle information in the state store keys to prevent state carry-over between months. Additionally, it is recommended to avoid relying on Enum.ordinal() for threshold comparisons, pre-calculate threshold values to improve performance, and remove development-related comments from the production code.
The reason will be displayed to describe this comment to others. Learn more.
현재 알림 상태 저장소(NotificationStateStore)가 targetId만을 키로 사용하고 있어, 예산 주기가 바뀌어도(예: 다음 달) 이전 상태가 유지되는 문제가 있습니다. 주기가 바뀔 때 알림이 다시 발송될 수 있도록 키에 주기 정보(예: 연월)를 포함하거나 상태 초기화 메커니즘이 필요합니다.
The reason will be displayed to describe this comment to others. Learn more.
ordinal()을 직접 비교하는 대신 BudgetThreshold에 비교 로직을 캡슐화하여 사용하는 것이 좋습니다(제공된 BudgetThreshold 관련 제안 참고). 또한, 현재 로직은 임계치 확인과 상태 갱신 사이에 원자성이 보장되지 않아 동시성 환경에서 중복 알림이 발생할 수 있는 구조입니다.
Suggested change
if (current.ordinal() <= lastNotified.ordinal()) {
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
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.
📌 변경 요약
AI 호출 비용에 대해 예산 사용률 임계치(50% / 80% / 100%)를 기준으로
판단 및 알림을 처리하는 로직을 추가하고,
동일 임계치에 대해 알림이 중복 발송되지 않도록 개선했습니다.
✅ 주요 변경 사항
1. 예산 임계치 개념 도입 (budget 모듈)
BudgetDecision에 임계치(BudgetThreshold) 정보를 포함하도록 확장DefaultBudgetEvaluator에서 임계치 기반 상태 판단 로직 구현2. 알림 책임 분리 (notification 모듈)
BudgetDecision)를 기반으로 알림을 처리하는BudgetNotificationService를 추가했습니다.3. 알림 중복 방지 기능 구현
NotificationStateStore를 도입했습니다.InMemoryNotificationStateStore를 제공하여로컬/테스트 환경에서 사용 가능하도록 했습니다.
4. 단위 테스트 추가
DefaultBudgetEvaluatorTestBudgetNotificationServiceTest✅ 설계 의도
책임을 명확히 분리하여 확장성(이메일, Slack, Webhook 등)과 테스트 용이성을 고려했습니다.
🔍 테스트 방법