mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 23:12:04 +00:00
fix(02-11): release guardian lock before provider egress
- Commit a final authorization claim under the lifecycle lock\n- Keep provider calls and retry outcomes outside database transactions\n- Retain authorization claims with notification delivery diagnostics
This commit is contained in:
1 parent
1818bd874b
commit
4b79f83cf7
9 files changed
+560
-110
No files matched your search
@@ -863,6 +863,8 @@ model User {
|
||||
pushAttemptsForRecord PushAttempt[] @relation("PushAttemptRecordUser")
|
||||
pushAttemptsReceived PushAttempt[] @relation("PushAttemptRecipientUser")
|
||||
notificationEvents NotificationEvent[]
|
||||
notificationEgressAuthorizationsForRecord NotificationEgressAuthorization[] @relation("NotificationEgressAuthorizationRecordUser")
|
||||
notificationEgressAuthorizationsReceived NotificationEgressAuthorization[] @relation("NotificationEgressAuthorizationRecipientUser")
|
||||
telegramReminderMessages TelegramReminderMessage[]
|
||||
// v1.10.3 — per-(user, day) Strain personal-anchor cache (day-total
|
||||
// TRIMP + running EWMA reference) so the nightly Strain engine anchors
|
||||
@@ -5825,6 +5827,32 @@ model NotificationEvent {
|
||||
@@map("notification_events")
|
||||
}
|
||||
|
||||
// A managed Guardian channel send crosses a revocable authorization boundary.
|
||||
// The dispatcher creates this claim while it holds the managed-profile
|
||||
// lifecycle lock, then commits before starting provider I/O. That committed
|
||||
// claim is the linearization point: a revocation that commits first prevents
|
||||
// the send, while a revocation that commits later does not cancel the one
|
||||
// already-authorized provider operation. No notification content, channel
|
||||
// credentials, or event deduplication keys are retained here. Completion is
|
||||
// observational only; authorization and retry decisions never read it.
|
||||
model NotificationEgressAuthorization {
|
||||
id String @id @default(cuid())
|
||||
recordUserId String @map("record_user_id")
|
||||
recipientUserId String @map("recipient_user_id")
|
||||
channel String
|
||||
eventType String @map("event_type")
|
||||
authorizedAt DateTime @default(now()) @map("authorized_at")
|
||||
completedAt DateTime? @map("completed_at")
|
||||
outcome String?
|
||||
|
||||
recordUser User @relation("NotificationEgressAuthorizationRecordUser", fields: [recordUserId], references: [id], onDelete: Cascade)
|
||||
recipientUser User @relation("NotificationEgressAuthorizationRecipientUser", fields: [recipientUserId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([authorizedAt], map: "notification_egress_authorizations_authorized_at_idx")
|
||||
@@index([recordUserId, recipientUserId, authorizedAt(sort: Desc)])
|
||||
@@map("notification_egress_authorizations")
|
||||
}
|
||||
|
||||
// `result` is one of `"ok"` | `"error"` | `"skipped"` — `skipped`
|
||||
// covers the "no recipient" / "config missing" soft cases.
|
||||
//
|
||||
|
||||
Reference in new issue
Block a user