fix(3jane): dedupe threshold alerts via cached alerted value#316
Merged
Conversation
Junior buffer, USD3 OC, and withdraw liquidity alerts fired on every run while the condition persisted. Cache the value that triggered the alert and stay silent until the metric drops below it; recovering above the threshold clears the cache so the next breach alerts again. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ployed credit Review follow-ups: should_alert_value_drop() no longer writes the breach value, so a raised Telegram send retries the alert next run instead of being suppressed by the dedupe cache (callers mark_alerted_value() after send_alert returns). The deployed_credit <= 0 early-returns in the junior buffer and OC checks now clear dedupe state, since an unwound book counts as recovered. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
The 3Jane junior buffer, USD3 OC, and withdraw liquidity alerts fired on every run while the condition persisted, spamming Telegram. This applies the same cached-value pattern the other checks in this monitor use (debt cap, shutdown, pause):
-1sentinel) so the next breach alerts again.Implemented as one shared helper,
should_alert_value_drop(cache_key, value, threshold), since all three metrics are lower-is-worse. The fully-covered OC branch (senior_at_risk <= 0) also clears the cache so a stale alerted value can't suppress a future breach.Validation
uv run --extra dev pytest tests/test_3jane.py— 21 passed, including new tests for: same-value dedup, re-alert on further drop, re-arm after recovery, HIGH→CRITICAL escalation, and full-coverage re-arm.ruff format/ruff checkclean; mypy shows only pre-existing errors (untouchedhttp_json,utils/).🤖 Generated with Claude Code