Skip to content

feat: implement alert dedup severity, price history, telegram role authz, and DEX XLM/USD#746

Merged
Mosas2000 merged 1 commit into
StellaBridge:mainfrom
Godbrand0:fix/alert-dedup-price-telegram-dex
Jun 27, 2026
Merged

feat: implement alert dedup severity, price history, telegram role authz, and DEX XLM/USD#746
Mosas2000 merged 1 commit into
StellaBridge:mainfrom
Godbrand0:fix/alert-dedup-price-telegram-dex

Conversation

@Godbrand0

Copy link
Copy Markdown
Contributor

Summary

  • Implements four placeholder/TODO resolutions across backend services with unit tests

Changes

closes #688 — Alert Deduplication Severity & Bridge Resolution

  • alertDeduplication.service.ts: Replace updateIncidentStatus("investigating") placeholder with a real updateIncidentSeverity call that escalates to the higher priority; status is then set to "investigating" afterward
  • alertDeduplication.service.ts: Replace hard-coded bridgeId: "unknown" with bridgeId: bridge-<assetCode> derived from the alert event (consistent with the pattern in alert.service.ts)
  • incident.service.ts: Add updateIncidentSeverity method used by the above

closes #685 — Historical Price Series TimescaleDB Query

  • price.service.ts: Implement getHistoricalPrices using PriceModel.getTimeBucketed with per-interval bucket widths (5 minutes / 1 hour / 6 hours / 1 day) and matching lookback windows

closes #686 — Telegram Bot Role-Based Authorization

  • telegram.bot.service.ts: Replace TODO in isAdminChat with a query against admin_accounts checking telegram_chat_id for operator or super_admin roles; fails closed on DB errors
  • migrations/042_admin_accounts_telegram_chat_id.ts: Adds telegram_chat_id (nullable, unique) column to admin_accounts

closes #687 — DEX XLM/USD Price Source

  • dex.source.ts: Remove misleading "placeholder" comment — fetchXlmUsd already does a live fetch
  • dex.source.ts: Add Binance public ticker as secondary fallback; also persist a 1-hour stale cache entry on successful fetches so the last-resort path can serve a recent value when both live sources are down, before falling back to the hardcoded 0.12 emergency value

Tests

Unit tests added for all four changes:

  • __tests__/alertDeduplication.service.unit.ts
  • __tests__/priceHistorical.service.unit.ts
  • __tests__/telegramRoleAuthz.service.unit.ts
  • __tests__/dexXlmUsd.source.unit.ts

Test plan

  • Run npm run test:unit — all new unit tests pass
  • Verify getHistoricalPrices returns correct shape against a TimescaleDB dev instance
  • Register a telegram_chat_id on an admin_accounts row with operator role and confirm the Telegram /pause command is now accessible
  • Confirm Stellar DEX and Binance XLM/USD fallback paths via log output in staging

Closes #685
Closes #686
Closes #687
Closes #688

🤖 Generated with Claude Code

…thz, and DEX XLM/USD

- StellaBridge#688: Replace severity/bridgeId placeholders in alertDeduplication.service.ts;
  escalate incident severity via new updateIncidentSeverity on IncidentService and
  derive bridgeId as bridge-<assetCode> instead of hard-coded "unknown"
- StellaBridge#685: Implement getHistoricalPrices in price.service.ts using PriceModel.getTimeBucketed
  with per-interval bucket sizes (5m/1h/6h/1d) and configurable lookback windows
- StellaBridge#686: Add migration 042 to store telegram_chat_id on admin_accounts; implement role
  check in isAdminChat querying admin_accounts for operator/super_admin roles
- StellaBridge#687: Remove stale placeholder comment in dex.source.ts; add Binance public API as
  secondary fallback in fetchXlmUsd with a 1-hour stale cache before the hardcoded emergency value
- Add unit tests for all four changes
@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@Godbrand0 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

@Mosas2000 Mosas2000 merged commit 3ff8392 into StellaBridge:main Jun 27, 2026
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants