Skip to content

Alert rules foundation: Condition[] + opaque destinationIds (#532) - #531

Merged
unjica merged 7 commits into
developfrom
feature/493-alert-rules
Jul 17, 2026
Merged

unjica merged 7 commits into
developfrom
feature/493-alert-rules

Conversation

@unjica

@unjica unjica commented Jul 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Foundation for v1.15 Alert Rules: AlertRule with conditions[] (AND) + opaque destinationIds, MVP Alerts UI, and ingest evaluation for ERROR_COUNT with cooldown dedupe.
  • Separation of concerns: rules decide conditions → trigger → destination bindings only; Notifications owns delivery. Matching rules call fireProjectAlert after resolveDestinationIds (project-email + ProjectWebhook uuids — not email/slack/… provider enums on the rule).
  • Parent vision #493; this PR implements child #532. Follow-ups: #533–#536.

Architecture (review alignment)

Layer Responsibility
Alert Rules Condition[] AND, thresholds/windows, cooldown, opaque destinationIds
Notifications (v1.14) Email / Slack / Discord / Teams / Telegram / webhook send paths

Deferred (child issues — not blocking #532)

  • Multi-condition / edit UX — #533
  • Additional condition evaluators + scheduled job — #534
  • Migrating built-in spike/quota into AlertRule — #535
  • Release v1.15.0 — #536

Test plan

  • Apply migrations; create a custom ERROR_COUNT rule bound to project-email + one Delivery destination id
  • Ingest enough errors to cross the threshold; confirm Notification Center + channel delivery and cooldown dedupe
  • Scope by environment and confirm only matching occurrence env fires
  • Soft-delete a bound webhook; confirm rule destinationIds prune and UI no longer claims that channel
  • Viewer cannot mutate rules; editor/owner can

Closes #532
Related #493

Made with Cursor

unjica and others added 3 commits July 17, 2026 22:09
Ship #493 MVP: AlertRule model/CRUD, destination binding into fireProjectAlert,
Alerts dashboard UI, and ingest-time evaluation with cooldown dedupe.

Co-authored-by: Cursor <[email protected]>
Filter ERROR_COUNT by per-occurrence environment written at ingest, not the
mutable last-seen tag on ErrorGroup.

Co-authored-by: Cursor <[email protected]>
Keep rule bindings honest when a Delivery channel is soft-deleted, and show
inactive vs live channel counts in the Alerts UI.

Co-authored-by: Cursor <[email protected]>
@unjica unjica added this to the v1.15.x — Alert Rules milestone Jul 17, 2026
Comment thread apps/api/src/routes/ingest.ts Resolved
Rules decide AND conditions and destination bindings only; Notifications
resolves project-email / ProjectWebhook ids via fireProjectAlert.

Co-authored-by: Cursor <[email protected]>
@unjica unjica changed the title Alert rules: configurable conditions and destinations (#493) Alert rules foundation: Condition[] + opaque destinationIds (#532) Jul 17, 2026
@unjica

unjica commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator Author

Alignment with architectural review

Thanks for the guidance — this PR (and the v1.15.x milestone) are updated to match.

Code (pushed)

  1. Capability split — Alert Rules only evaluate conditions (AND) + cooldown, then call fireProjectAlert. No provider-specific send logic beyond resolving opaque ids at the Notifications boundary (resolveDestinationIds).
  2. Flexible model — condition_type + single condition + { email, webhookIds } replaced with conditions[] (AND) and destinationIds[].
  3. Opaque destinations — rules store project-email and/or ProjectWebhook uuids. Slack/Discord/Teams/Telegram/webhook providers stay on Delivery/Notifications, not as rule enums.

Docs: docs/ALERT-RULES.md states the separation clearly.

Process / milestone

Not merging; not closing #492; not starting release.

Comment thread apps/api/src/lib/alert-rules.ts Resolved
Normalize ingest environment to match ERROR_COUNT filters, and never evaluate corrupt condition JSON as a default spike.

Co-authored-by: Cursor <[email protected]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cf87be6. Configure here.

Comment thread apps/api/src/lib/alert-rules.ts Resolved
Empty conditions from API toPublic were filtered by isAlertRuleRow, hiding rules editors still need to disable or remove.

Co-authored-by: Cursor <[email protected]>
@unjica
unjica merged commit 08f92f9 into develop Jul 17, 2026
6 of 8 checks passed
@unjica
unjica deleted the feature/493-alert-rules branch July 17, 2026 20:47
@unjica unjica mentioned this pull request Jul 17, 2026
1 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alert Rules: condition model + ERROR_COUNT evaluator + opaque destinationIds (foundation)

1 participant