feat(alerts): realtime alert notifications over SMTP + in-app (#25) - #144
Draft
Jovonni wants to merge 2 commits into
Draft
feat(alerts): realtime alert notifications over SMTP + in-app (#25)#144Jovonni wants to merge 2 commits into
Jovonni wants to merge 2 commits into
Conversation
Adds an SMTP email channel and in-app notifications for detections, wired through the existing rule engine, rule canvas, settings, and SDK — no new tables (reuses integration_settings + notifications). - notification_service: EmailService (config from integration_settings with SMTP_* env fallback, à la ChatService) + AlertNotifier (email + per-user in-app notification), best-effort so delivery never blocks alerting - rule_engine._fire_alert dispatches notifications when the alert node action is a notify action, threading the node's optional recipients - settings: register 'smtp' integration, mask the password, add a /test probe - rule canvas: 'fire alert + notify' action + optional recipients field - settings UI: Notifications section with an Email (SMTP) integration card - POST /api/v1/alerts to raise alerts directly (owns them under a system 'SDK Alerts' rule) with optional notify - SDK: openuba.send_alert(...) for models - dedicated test subsuite (28 unit tests, no container needed) Closes #25
Open
The workspace image build failed generating pyspark metadata ('setuptools is
not available in the build environment'). Upgrade build tooling right after the
base image so isolated sdist builds resolve setuptools. Unblocks the workspace
CI triggered by the sdk/ change in this branch.
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.
What
Delivers realtime alerts (requested in #25) as email (SMTP) + in-app notifications, wired end-to-end through the pieces we already have — no new tables.
How it reuses existing infrastructure
integration_settingstable (integration_type="smtp"), loaded with an env-var fallback exactly likeChatServicedoes for LLM providers.smtpis added to the settings whitelist, the password is masked on read, and there's a/testconnectivity probe.RuleEngine._fire_alert— the single choke point where every rule-fired alert is created. When the alert node's action is a notify action, it dispatches email + in-app. Best-effort: a mail outage can never block alert creation.notificationstable (typealert), so they surface in the notification center already wired into the frontend +notificationsrouter.flow_graph, read by the engine). No new node type.openuba.send_alert(...)lets Python models raise alerts (and optionally notify). Backed by a newPOST /api/v1/alertsthat owns SDK alerts under a systemSDK Alertsrule (alerts require arule_id).Tests (own subsuite, CI-wired)
core/tests/test_services/test_notification_service.py,test_rule_engine_notify.py, andcore/tests/test_api_routers/test_settings_smtp.py— 28 unit tests, all mocked (no SMTP server or DB container): recipient normalization, config load (DB + env), STARTTLS/SSL send paths, error-swallowing, notify-action gating, rule-engine dispatch wiring, and settings whitelist/masking/_test_smtp.Local: backend suite green,
tsc --noEmitclean,next lintclean,next buildgreen.Closes #25