Commit c6585bb
feat(digest): per-recipient Slack delivery with UI prefs (PR3) (#105)
<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
## Summary
**Same Brain, different lens per role.**
This PR implements per-recipient Slack delivery for digests, consuming
the `DigestAssemblyResult` API from PR2. Two users with different
personas on the same connection now get different Slack digests for the
same time window.
### Honesty-gap fix (per-user cron)
UI schedule presets and `UserDigestPreference.cronExpression` (+
timezone) were stored but ignored: `SlackDailyDigestTaskConfig` only ran
the global `slack.daily-digest.cron` and then delivered to every
preference. Product Evangelist blocked marketing “your own schedule”
until this was fixed.
The scheduler now ticks every minute (`slack.daily-digest.tick-cron`,
default `0 * * * * *`) via `processDigestTick()`:
- **No enabled prefs** → legacy channel broadcast only when the global
cron is due (UTC)
- **Prefs exist** → each enabled `SLACK_DM` preference is evaluated with
Spring `CronExpression` in that user’s timezone; already-logged fire
windows are skipped (`SlackDigestLog` idempotency)
- Blank preference cron still falls back to `slack.daily-digest.cron`
- Manual/admin trigger still uses `sendDailyDigestHybrid()` (force all
recipients)
## Changes
### Backend
- **`SlackDailyDigestService`**: `sendPersonalizedDigests()` /
`sendDailyDigestHybrid()` / **`processDigestTick()`** — per-recipient
DMs, EXEC formatting, personalized logs, and per-user cron on the minute
tick
- **`DigestCronMatcher`**: Spring `CronExpression` due-window helper
(timezone-aware)
- **`DigestPreferenceSeedService`**: seed from singleton; persona
inference; skips inactive users
- **`SlackDailyDigestTaskConfig`**: minute tick → `processDigestTick()`
- **`DigestPreferenceController`**: seed/status; refuses EMAIL
### Frontend
- Digest preferences API + panel (persona, schedule presets, seed) +
DigestSection bell icon
### Documentation
- `docs/DIGEST_PREFERENCES.md` updated for tick vs global cron and
accurate “your own schedule”
## Acceptance Criteria
- [x] Two users, different roles/personas, same connection → different
Slack digests same window
- [x] Cron/config not singleton-only (**per-user cron honored on tick**)
- [x] Tests for per-recipient delivery + seed/legacy + due-cron /
timezone / idempotency
- [x] UI prefs for role/schedule/persona
- [x] Docs updated — “your own schedule” is accurate
- [x] No fake EMAIL / WhatsApp delivery advertised
## Out of Scope (Follow-ups)
1. Idle-in-transaction insight when Brain has data
2. `join_collapse_limit` cliffs under CONFIG_TUNING
3. DOCUMENTATION_GAPS miner
4. COST_CAPACITY dedicated cost miner for EXEC
5. Hermes/WhatsApp = PR4
## Dependencies
- PR1 #103: per-user digest prefs
- PR2 #104: role-aware insight assembler
## Testing
```bash
cd backend
./mvnw test -Dtest=PerRecipientDigestDeliveryTest,PerRecipientDigestCronSchedulingTest,DigestCronMatcherTest,DigestPreferenceSeedServiceTest,SlackDailyDigestServiceTest
```
Key scenarios: different crons → only due user; timezone
America/New_York 9AM = 13:00 UTC; idempotent window skip; EXEC 3
bullets; EMAIL skipped; seed idempotent; legacy when no enabled prefs.
<!-- CURSOR_AGENT_PR_BODY_END -->
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>1 parent efc7c32 commit c6585bb
21 files changed
Lines changed: 3472 additions & 134 deletions
File tree
- backend/src
- main
- java/com/dbaagent
- controller
- model
- repository
- service
- digest
- scheduler
- resources
- test/java/com/dbaagent/service
- digest
- docs
- src
- components/sections
- lib/api
Lines changed: 110 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
| 33 | + | |
| 34 | + | |
30 | 35 | | |
31 | 36 | | |
32 | 37 | | |
| |||
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
47 | | - | |
48 | | - | |
49 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
50 | 69 | | |
51 | 70 | | |
52 | 71 | | |
| |||
159 | 178 | | |
160 | 179 | | |
161 | 180 | | |
| 181 | + | |
162 | 182 | | |
163 | 183 | | |
164 | | - | |
165 | | - | |
| 184 | + | |
166 | 185 | | |
167 | 186 | | |
168 | 187 | | |
| |||
181 | 200 | | |
182 | 201 | | |
183 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
184 | 289 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| |||
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
94 | 119 | | |
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
11 | 27 | | |
0 commit comments