Skip to content
MSO CloudDocumentation

ADR 0046 — Notification delivery posture, Phase 0

On this page
  • Status: Accepted. Phase 0 shipped 2026-09-07, commit b173de2b.
  • Owners: Platform (alerts / decision-intelligence).
  • Extends: §79 (rate-limit/audience/dedupe), ADR 0035 (Morning Brief per org type) D5 (in-app is canonical, email/Zalo is a pointer, never a duplicate), ADR 0038 (tenant dataset semantic layer).

Context#

A post-mortem on the HR dataset alert pack, installed 2026-09-05, found the delivery posture itself was the bug, not one pack: an absent alert_rule_user_states row was read as "send everything" (['in-app', 'email', 'zalo']), so every person who had never opened /settings/alerts was mailed regardless. packages/alerts/src/delivery-posture.ts records the count: in 14 days, 18 alert events produced roughly 50 emails to people who had never stored a preference at all. A second, independent bug compounded it — a monthly finding deduped on message text inside a rolling 12-hour window, so the same monthly fact re-fired twice a day.

Decisions#

D1 — Absent preference means in-app only, and this is the product's own posture

DEFAULT_USER_ALERT_CHANNELS = ['in-app']. A person who has never set a preference for a rule receives that rule's findings in-app only — never email, never Zalo. This is not a per-org setting and not a knob an org admin or a super admin can widen for a tenant: only the person's own opt-in at /settings/alerts can add a channel for themselves.

D2 — A rule's channels is a ceiling on what a person may opt into, never a delivery list

NEW_ALERT_RULE_CHANNELS = ['in-app'] — every rule an org receives, from any pack (eCom or tenant dataset) or the authoring form, is created in-app only, regardless of what an earlier version of that pack shipped. Delivery is capped twice: datasetRuleAllowedChannels() caps a rule's declared channels by the platform ceiling (D3); resolveUserAlertChannels() caps the result again by the person's own stored preference, defaulting per D1 when none exists. A channel is only ever added at the narrowest end of that chain — the person — never by a pack, a rule default, or an admin console.

D3 — Dataset-rule findings honour the same platform ceiling eCom rules honour

Tenant-dataset rules (ADR 0038, ADR 0035 D7) previously had no platform-level gate at all. resolveDatasetNotificationCeiling() now reads the same notification_settings table the eCom rules read, keyed under one shared type (DATASET_RULE_NOTIFICATION_KEY = 'dataset.rule_fired') rather than one row per rule — a dataset rule is authored per tenant, so no per-rule platform row could exist; the ceiling is a statement about the KIND of notification, not the individual rule. Editable only at /admin/notifications, super admin only.

D4 — A dataset finding dedupes on the period it is about, not on a rolling time window

A dataset rule is stated at month grain, so "overtime per head rose in 2026-08" is one fact that stays true for the rest of that month. datasetFindingDedupeCondition() matches on (orgId, ruleId, bucket, periodMonth) with no time window, so the same finding is recorded at most once per period instead of re-alerting on every evaluation run.

D5 — Dead settings toggles are removed, not left as decoration; the surviving one is a veto only

/settings/notifications shipped four toggles (email alerts, daily briefing, sync failures, security alerts); only one was ever read anywhere. The other three are removed rather than kept as inert decoration. The surviving "receive alerts by email" toggle is wired at delivery (resolveUserAlertChannels's emailOptOut) as a veto only: turning it off removes email from every rule at once; turning it on grants nothing by itself — email for a given rule still has to be opted into at /settings/alerts.

Consequences#

  • An org that wants a rule delivered by email has no org-wide or admin path to it: every recipient opts in for themselves, per rule, at /settings/alerts. There is no bulk "turn on email for this rule for the whole org" action in Phase 0.
  • A pack upgrade never re-widens a channel on an already-installed rule, and a new rule from a new pack version installs in-app only even if an older version of that same pack once shipped with email.
  • Infrastructure notices stay super-admin only — unchanged by this decision.

Named follow-up (not built)#

Phase 0 is delivery posture only. A notification inbox (bell, unread tab badge) and additional outbound channels (web push, Telegram) are a later, separately-scoped phase.