feat(infra): per-event configurable notification thresholds (#6) - #18
Merged
Conversation
Adds a notification_settings table (migration 007) with one row per event type holding a configurable minimum severity threshold. Defaults are applied in code so upgrades are no-ops: - scan.complete: medium (approximates the prior any-finding rule) - scan.failed: info (always notify) - scanner.failed: info (always notify) The dispatcher now consults the threshold before persisting an in-app notification. Failure events are synthesized at critical severity so threshold up to and including critical fires; clean scans never notify regardless of threshold. Adds GET/PATCH /api/v1/settings/notifications (admin scope) and a matching /settings/notifications page in the dashboard. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Metbcy
force-pushed
the
feat/notification-thresholds
branch
from
June 3, 2026 15:14
0779c21 to
a30c9d9
Compare
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
Implements #6: per-event configurable notification thresholds.
The pre-#6 dispatcher had three hard-coded rules: notify on
scan.completeonly whenfindings_count > 0, always onscan.failed, always onscanner.failed. This PR replaces those with a per-event minimum severity threshold that admins can change at runtime.What's new
Backend
007_add_notification_settings.pycreatesnotification_settings(event_type PK, min_severity, updated_at). No rows are seeded; defaults live in code so existing deployments are no-ops.info < low < medium < high < critical.scan.complete: mediumscan.failed: info (always fires)scanner.failed: info (always fires)database.py:get_notification_settings,get_notification_threshold,upsert_notification_threshold,NOTIFICATION_THRESHOLD_DEFAULTS.api/settings.pyrouter:GET/PATCH /api/v1/settings/notifications(admin scope; legacy alias mounted via the existing versioning helper)._create_notification_for_eventnow consults the per-event threshold.scan.complete's effective severity is the highest finding severity in the run; the publish site in_run_scanwas extended to passmax_severity. Failure events synthesize as critical so any threshold up to and including critical still fires.max_severityare treated as worst-case so behavior matches the pre-feat(infra): per-finding configurable notification thresholds #6 hard-coded rules.Frontend
/settings/notificationspage in the keys/webhooks pattern: one card per event with a severity select and a Save button.Tests
cd backend && ruff check . && ruff format --check . && python -m pytest tests/ -x -q— 948 passed, 2 skipped (pre-existing semgrep + weasyprint env-only failures excluded; same as main).pnpm buildclean.pnpm lintadds 1 error to the 21 pre-existing baseline using the samevoid load()pattern other settings pages use.