feat: stagger approval email behind push by default (#119) - #147
Conversation
Send push immediately and delay email 60s for dual-channel users with stagger_email enabled, falling back to immediate email when push cannot deliver. Deletes the dormant NotificationService in favor of the live ApprovalService path. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
💬 Preloop has suggestions for this PR.
The stagger implementation is well-structured overall — the partition logic is clean, the behavior spec is comprehensive, and the 17 test cases cover the decision matrix thoroughly. A few improvements are recommended below.
See the summary comment for details.
🔍 Preloop Code ReviewLast Updated: 2026-08-01 📝 SummaryThe stagger implementation continues to be well-structured — the partition logic is clean and the behavior spec is comprehensive. The 17 ✅ What Looks Good
|
There was a problem hiding this comment.
Preloop has reviewed this PR.
See the summary comment below for the full review details and issue tracker.
This re-review confirms the previous MEDIUM finding (redundant status check) persists. One new MEDIUM finding on the unbounded task set under load. Otherwise the implementation remains solid with excellent test coverage.
There was a problem hiding this comment.
💬 Preloop has suggestions for this PR.
All 4 non-blocking MEDIUM/LOW issues from the initial review persist unchanged. The implementation remains well-structured with excellent test coverage — these are code quality and resource cleanup improvements worth addressing before merge.
See the summary comment below for the full issue tracker.
Summary
stagger_email(default true) waits 60s and only sends if the approval is still pending (fresh DB session + CRUD re-check at fire time).no_devicesfalls back to immediate email so stagger never degrades delivery.stagger_emailonNotificationPreferences(conductor decision a) with preferences UI toggle when both channels are enabled; deletes dormantNotificationServiceand its tests (conductor decision b).Fixes #119
Conductor decisions
stagger_emailon NotificationPreferences, default true), not account-wide.NotificationServiceis deleted in this PR; its partition/delay pattern is ported into the liveApprovalService.send_notificationspath.Behavior
Scheduling is in-process
asyncio.create_task+ sleep with a module-level task set (no new infra). Slack/mattermost/webhook and escalations are out of scope / unchanged.Migration note
Alembic revision
20260801_stagger_emailparents on currentmainhead (20260730_webauthn_credentials). Open PRs #137, #141, and possibly #136 also add migrations off the same head; this PR may need a re-parent after those land.Test plan
TestNotificationStagger(17 cases covering the spec list)TestSendNotifications, mute path, push suite, notification-preferences endpointsMade with Cursor
Note
Medium Risk
4 non-blocking MEDIUM/LOW issues persist from the last review (second pass: no code changes since initial review). The implementation remains well-structured with excellent test coverage.