Skip to content

feat(alerts): add user-defined alert rules with scheduled evaluation and webhook/WhatsApp delivery - #298

Merged
robertocarlous merged 6 commits into
Neurowealth:mainfrom
B-Hands:main
Jul 24, 2026
Merged

feat(alerts): add user-defined alert rules with scheduled evaluation and webhook/WhatsApp delivery#298
robertocarlous merged 6 commits into
Neurowealth:mainfrom
B-Hands:main

Conversation

@Anuoluwapo25

Copy link
Copy Markdown
Contributor

PR Description
Summary

This PR introduces user-defined alert rules that allow users to receive proactive notifications when portfolio or protocol conditions they care about are met.

Unlike the existing Prometheus/Grafana monitoring—which is intended for platform operators, this feature enables end users to define custom thresholds
closes #289

Anuoluwapo25 and others added 6 commits July 21, 2026 08:09
Add user-defined alert rules that notify on portfolio/market conditions
(protocol APY, portfolio value, position drawdown) over webhook/WhatsApp.

- AlertRule model + migration; nullable unique User.phone for WhatsApp delivery
- CRUD API with owner-scoped access (POST/GET/PATCH/DELETE /api/alerts)
- Scheduled evaluator with atomic cooldown fire-claim (guards delete-mid-tick,
  concurrent runners, and threshold-sitting spam)
- Delisted PROTOCOL_APY protocols auto-deactivate rather than eval stale data
- Reuses HMAC-signed dispatchWebhookEvent (new alert_rule.triggered event) and
  WhatsApp formatter; no separate failed-delivery sweep (documented decision)
- NLP intents + WhatsApp CRUD for conversational rule management
- POSITION_DRAWDOWN measured against rolling 30-day portfolio peak
- Unit tests for evaluator logic and job behavior; docs/ALERTS.md; openapi.yaml
feat(alerts): custom price & yield alert rules (Neurowealth#289)
… gate

The "Merge branch 'main' into main" (d9fabff) dropped code while keeping its
usages, failing every CI check. Restore what the merge clobbered:

- schema.prisma: re-add PriceSource (Neurowealth#284) and GoalStatus (Neurowealth#281) enums, which
  the merge replaced with Neurowealth#289's alert enums instead of keeping both. Their
  usages (User.priceSource, SavingsGoal.status) remained, so `prisma generate`
  failed P1012 and blocked ci, build, and contract/migration smoke jobs.
- nlp/parser.ts: restore the 'goal' member of the Intent action union, dropped
  by the same merge while parser.ts and handler.ts still emit/switch on it,
  breaking `tsc` (TS2322/TS2678) and the production build.
- add rollback.sql for the Neurowealth#289 alert_rules migration so the rollback gate
  (scripts/check-migration-rollback.sh) passes.
The Neurowealth#289 alerts merge landed 11 files that Prettier had not been run
over, so `format:check` fails on main and blocks build/test for every
PR branched from it. Formatting only — no behaviour change.
@robertocarlous
robertocarlous merged commit a93717e into Neurowealth:main Jul 24, 2026
8 checks passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Jul 24, 2026
8 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.

Custom Price & Yield Alert Rules

2 participants