Notifications and messaging system
Status: proposed (2026-06-17) — stub; partially grilled 2026-10-01. The V1 minimal core below is provisional by the maintainer’s explicit marking; the rest of the grill questions remain open. The teaching-absorption build plan assigns implementation of that core to D1. Do not build beyond the minimal core against this record.
Context
Section titled “Context”Spun out of the Discussion-capability design session (ADR-0029). Several current and planned features need to tell a Person something happened, but emergent has no notification or messaging system today. Rather than grow a discussion-specific notifier, this records the block as cross-cutting, to be designed on its own merits.
Known consumers (the forcing contexts):
- Discussion subscriptions (v2) — “someone replied to your Post / posted in your Group / in a Discussion you follow.” The immediate trigger: ADR-0029 ships only a local last-seen “new posts” badge and defers all subscription/notification machinery here.
- Assessment due-date reminders —
assessment_definition.dueAt/assignAtexist with no reminder path. - Grade-posted — a
gradebook_entryreachinggraded(especially human-scored assignments, ADR-0027). - Moderation / safety alerts — a Report filed → notify moderators; a Post hidden or a posting restriction imposed → notify the affected Person (ADR-0029 moderation surface).
- Identity / invite delivery — Claim Tokens / invites (identity-linking).
- A future real-time Chat surface (ADR-0029 deferred seam B) would also consume it.
Questions to grill (not yet decided)
Section titled “Questions to grill (not yet decided)”- Channels: in-app only? email? web/native push? Which at v1?
- Subscription model: what is subscribable, opt-in vs opt-out defaults, per-Discussion “follow”.
- Per-person state & sync: do notifications ride the pgxsinkit rail owner-scoped (like Reports and the unread marker in ADR-0029) so they work offline, or are they server-pushed online-only? Likely hybrid.
- Preferences: immediate vs digest, quiet hours, per-channel / per-type toggles.
- Minors & consent: emailing/pushing to minors carries guardian-consent implications (ADR-0008); channel availability may be governed, not just preferenced.
- Delivery infra: email (provider/SMTP) and push (VAPID/web-push, native) are new k3s/Helm infrastructure with their own secrets and deploy weight.
- Erasure: notification rows are person-PII → an erasure class; pending deliveries to an erased Person must be cancelled.
- Neutral vocabulary: “Notification” vs “Message” vs “Alert” — settle against CONTEXT.md when designed.
V1 minimal core (provisional, 2026-10-01)
Section titled “V1 minimal core (provisional, 2026-10-01)”Grilled with the teaching-tools absorption (the calendar/tasks requirements there are this
block’s first real consumer). Terms are in CONTEXT.md: Task (a dated, completable piece of
teacher work, manual or generated from a declaration on the thing it concerns — a Survey declares
its open and close tasks, a Ritual its weekly ones — carrying optionally the Operation it exists
to perform), Reminder (a scheduled prompt that a Task or Meeting is approaching or due, fired
at a moment the Task declares), and Notification (the record a Person was told something
in-app, with read state).
- Audience: teachers only at v1. Students do not use emergent for this yet; learner-facing notification is not designed here.
- Channels at v1: in-app first, email second through the existing Mailgun infrastructure (the auth email path). Push, digests, quiet hours and per-channel preferences stay deferred — this settles the Channels question only to that depth.
- Survey open/close stays computed availability from
opens_at/closes_at(like the computed final grade, ADR-0044); no scheduled state flips, no cron. - Operations are performed by the teacher pushing the button on a Task; nothing fires by itself, which is also the Platform Bridge’s fence (ADR-0067).
- Still open from the list below: subscription model, sync posture for notification rows, preferences, minors/consent, push delivery infrastructure; Notification rows are person-PII and must declare an erasure class when built.
D1 implementation choices (2026-10-02)
Section titled “D1 implementation choices (2026-10-02)”These are bounded choices for implementing the provisional core, not additional maintainer policy or decisions about the deferred subscription and preference system.
- A declaration is a teacher-only child of the Survey, Ritual or Assessment Definition it concerns. Explicit recipient links use Person foreign keys. Keeping that configuration outside the shared learner-delivered source rows avoids exposing teacher workflow metadata and avoids embedding recipient identities in JSON that would need bespoke erasure scrubbing. Manual Tasks also retain their recipient configuration independently of previously emitted Reminders.
- Source dates and actual Meeting occurrences supply the time anchors. Offsets are elapsed minutes; a day is not silently assumed to mean 24 hours in a local calendar. A persistent source/declaration/ occurrence identity preserves terminal Task history, while open work and pending prompts follow re-timing or moves. Removing a declaration cancels its pending work rather than resurrecting or deleting completed work.
- Generated Tasks are visible to the Offering’s teaching set. Reminder and Notification reads require both the recipient Person and current teaching reach; administrator scope does not expose another teacher’s inbox. The learner registries do not expose these records. Server-owned generation, completion and delivery metadata is changed through freshly authorized Operations, not client rows.
- Task actions carry a catalogue name and validated input for their Offering or its Organization. Credential, Connection-session and Person/recipient identity fields are excluded from action JSON; recipient configuration uses the normalized links above. A deferred action is shown as unavailable; the teacher’s deliberate click is the only execution trigger. The reminder worker never invokes it.
- The reminder worker claims due prompts and records the in-app Notification atomically, with a natural identity that prevents duplicate local records. Email uses the existing Mailgun sender, independently of in-app success, after checking current reach and an active verified mailbox. Durable attempts and sanitized outcomes distinguish failed delivery from uncertain acceptance. A crash after provider acceptance does not justify blindly resending or claiming exactly-once email.
- Survey availability uses inclusive opening and exclusive closing times, with null endpoints unbounded. Response writes and native database policy enforce the window; client availability is computed against the clock. No scheduled status flip or automatic time-triggered shape refresh is required.
Status note
Section titled “Status note”The provisional v1 core is assigned to D1 and may be implemented within the scope above. The broader
system remains proposed: subscription policy, preferences, learner/minor flows and push delivery
still require design decisions before implementation. Tracked in TODO.md → Notifications & messaging.