refactor(alerts): add a notification dispatch seam - #2918
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThe PR extracts alert delivery behind an injectable notification dispatcher while preserving synchronous inline delivery as the default.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| packages/api/src/tasks/checkAlerts/notifications.ts | Introduces the notification job and dispatcher contracts plus a synchronous default implementation that delegates to the existing transport. |
| packages/api/src/tasks/checkAlerts/template.ts | Constructs notification jobs and dispatches them through an optional dispatcher while retaining the inline implementation by default. |
| packages/api/src/tasks/checkAlerts/tests/notifications.test.ts | Verifies that inline dispatch waits for delivery, propagates delivery errors, and has a no-op shutdown. |
Sequence Diagram
sequenceDiagram
participant Alert as Alert evaluation
participant Template as renderAlertTemplate
participant Dispatcher as NotificationDispatcher
participant Transport as deliverToChannel
Alert->>Template: Render notification
Template->>Dispatcher: dispatch(job)
alt Default inline dispatcher
Dispatcher->>Transport: Deliver message
Transport-->>Dispatcher: Success or error
Dispatcher-->>Template: Resolve after delivery
else Future queueing dispatcher
Dispatcher-->>Template: Resolve after enqueue
end
Reviews (2): Last reviewed commit: "refactor(alerts): add a notification dis..." | Re-trigger Greptile
Deep ReviewRefactor introducing a notification dispatch seam in the alerts task: a new ✅ No critical issues found. 🟡 P2 -- recommended
🔵 P3 nitpicks (4)
Pre-existing (not counted toward verdict)
Reviewers (9): correctness, adversarial, testing, maintainability, project-standards, api-contract, reliability, kieran-typescript, agent-native. Testing gaps:
Coverage: Two low-confidence single-reviewer findings were suppressed below the confidence gate — |
77ccf05 to
f17f741
Compare
c6bd23d to
50a5db0
Compare
6a4464b to
1cd58ad
Compare
522dada
into
jordansimonovski/alerts-notifications-module
Why
Alert notifications are delivered inline, on the evaluation tick. That is the right default, but it hardwires one delivery strategy into the render path: anything wanting to queue deliveries, bound concurrency, or survive across ticks has to edit
renderAlertTemplateitself.This adds the seam so delivery becomes swappable. No behaviour changes — the inline dispatcher is the default and does exactly what the code did before.
The contract worth reading
dispatch()has two legitimate implementations with different timing, and the difference matters to callers:executionErrors.Anything depending on synchronous error propagation from
dispatch()is depending on the inline implementation specifically. That is documented on the interface.Naming
NotificationJob.populatedChannelis deliberately not calledchannel. A job may carry both a serializable channel reference and the resolved document; reusing one name for both makes the two indistinguishable. Only the resolved form exists here today — the name is chosen so it stays correct when the other appears.Not a behaviour change
checkAlerts.int.test.ts(277) andrenderAlertTemplate.int.test.ts(74) pass unmodified — that is the gate. Thedispatcherparameter is optional and defaults to inline, so no existing caller changed.eventIdis byte-identical: same hash, same inputs, same place.