Skip to content

NTF · Notifications

A notification is one row per event, raised by the function that does the action, in the same transaction, and seen by whoever holds its type's permission at its pool (D95). It closes itself when its condition ends. v1 has none, so nothing loads. The foundation comes first, in slice #584: the four tables, app.notify, resolving and acknowledging, receipts, preferences, row-level security and the two settings (R-SET-13 to R-SET-16). No type is a rule here: each module's DOC pack names its own types as rules, and its BE pack seeds them and calls app.notify. The bell, the page, the preferences page, the escalation job and the digest are M7's (#507). In-app only; email and WhatsApp are a later decision. Code NTF.

  • The default for info on a team's role: D95 gives the teams action and urgent live, and doesn't say whether their info notifications go to the digest or nowhere. R-NTF-04 leaves it open.
  • An organization's own roles: each type holds the system roles' default delivery (R-NTF-04); which default applies to a member who holds only an organization's own role isn't decided.
  • Choosing pools: D95 lets a member choose their pools, as well as modules and types; the preferences table holds a choice per module or type (R-NTF-21). Choosing pools waits for M7's preferences page (#507).
  • The digest (one notification per member each morning, its counts per type and pool computed when it is made, at R-SET-16's hour) is M7's, and gets its rules there.

R-NTF-01 · notification_types is a system catalogue: each type has a code, its module, a default severity, the permission that sees it and whether it escalates

Section titled “R-NTF-01 · notification_types is a system catalogue: each type has a code, its module, a default severity, the permission that sees it and whether it escalates”
  • Status: built
  • Example: given the slice's migration has run, when notification_types is read, then it has those columns and no row; the first type is seeded by its module's BE pack, such as M1's "you were given a role at a pool".
  • Refusal: none: this describes the table.
  • Who: the seed. Every type's permission is a code of the permission catalogue (foreign_key_violation, 23503).
  • Source: D95 (the tables; seeded like the permissions; no type seeded yet).

R-NTF-02 · App users can't change the notification type catalogue

Section titled “R-NTF-02 · App users can't change the notification type catalogue”
  • Status: built
  • Example: given a super_admin, when they add a notification type or change one's default severity, then nothing is saved.
  • Refusal: none: insufficient_privilege (42501) on insert; no effect on update or delete.
  • Who: every app user. Only a migration changes it, as R-ACC-26 for the permissions.
  • Source: D95 (a system catalogue, seeded like the permissions).

R-NTF-03 · Every signed-in user reads the notification type catalogue

Section titled “R-NTF-03 · Every signed-in user reads the notification type catalogue”
  • Status: built
  • Example: given a satpam, when they read notification_types, then every type comes back, with its code, module and severity, so the bell can label any notification they see; a signed-out request reads none (R-ACC-02).
  • Refusal: none.
  • Who: every signed-in user. The catalogue holds codes, not business rows.
  • Source: D95. That every signed-in user reads it is DOC's proposal in the session on #584.

R-NTF-04 · Each type holds each system role's default delivery: admin, super_admin and viewer get urgent live and the rest by digest; the other roles get action and urgent live

Section titled “R-NTF-04 · Each type holds each system role's default delivery: admin, super_admin and viewer get urgent live and the rest by digest; the other roles get action and urgent live”
  • Status: built
  • Example: given a type with default severity action, when an admin's and a checker's default delivery of it is read, then the admin gets it in the digest unless it becomes urgent (R-NTF-27), and the checker gets it live.
  • Refusal: none: this describes the seed of each type.
  • Who: every type's seed. A member's own preference replaces it (R-NTF-21, R-NTF-23). A team's info is open (Not yet a rule).
  • Source: D95 (the higher-ups' filter; each role's default delivery is on the type row).

R-NTF-05 · A notification holds its type, pool, subject table and id, severity, an optional recipient, when it opened, who acknowledged it and when, and when it was resolved

Section titled “R-NTF-05 · A notification holds its type, pool, subject table and id, severity, an optional recipient, when it opened, who acknowledged it and when, and when it was resolved”
  • Status: built
  • Example: given a work order at PML waiting for its route, when its notification is raised, then the row names its type, PML, work_orders and the work order's id, the type's default severity (R-NTF-06), no recipient and the time it opened; acknowledged and resolved are empty.
  • Refusal: none: this describes the table. Its pool and its recipient's membership belong to its organization (R-TEN-05).
  • Who: every writer.
  • Source: D95 (one row per event).

R-NTF-06 · A notification's severity is info, action or urgent, and starts at its type's default severity

Section titled “R-NTF-06 · A notification's severity is info, action or urgent, and starts at its type's default severity”
  • Status: built
  • Example: given a type whose default severity is action, when app.notify raises one, then its severity is action; a row saved with severity "high" is refused. It becomes urgent only by escalating (R-NTF-27).
  • Refusal: none: invalid_text_representation (22P02) for another value.
  • Who: every writer.
  • Source: D95 (severity: info, action or urgent).

R-NTF-07 · A notification holds ids, counts and times, never a name or other personal data

Section titled “R-NTF-07 · A notification holds ids, counts and times, never a name or other personal data”
  • Status: built
  • Example: given a notification about Deka's overdue checkpoint, when the row is read, then it holds the inspection's id, not Deka's name, phone or plate; the bell reads those under row-level security when it shows it.
  • Refusal: none: this describes the table.
  • Who: every writer.
  • Source: D95 (no personal data in a row); D15.

R-NTF-08 · At most one notification is open per type and subject

Section titled “R-NTF-08 · At most one notification is open per type and subject”
  • Status: built
  • Example: given an open notification that work order WO-0012 waits for its route, when a second open row of that type for WO-0012 is saved, then it is refused; once the first is resolved, a new one may open.
  • Refusal: none: unique_violation (23505).
  • Who: every writer. app.notify returns the open one instead (R-NTF-10).
  • Source: D95 (at most one is open per type and subject).

R-NTF-09 · app.notify() raises a notification in the caller's transaction, so an action that is refused raises none

Section titled “R-NTF-09 · app.notify() raises a notification in the caller's transaction, so an action that is refused raises none”
  • Status: built
  • Example: given a function that routes a work order and calls app.notify() before a later check refuses the routing, when it is refused, then no notification exists; when the routing goes through, the notification is there in the same commit.
  • Refusal: none.
  • Who: the business functions that raise one, and the pg_cron jobs that raise the ones a date triggers, such as an expiring STNK. App users never call it: it is in the app schema, which PostgREST doesn't expose.
  • Source: D95 (where one comes from); D3.

R-NTF-10 · app.notify() returns the id of the open notification of that type and subject when there is one, and raises no second

Section titled “R-NTF-10 · app.notify() returns the id of the open notification of that type and subject when there is one, and raises no second”
  • Status: built
  • Example: given an open notification that WO-0012 waits for its route, when app.notify() is called again for that type and WO-0012, then it returns that notification's id, and nothing is added or changed.
  • Refusal: none.
  • Who: every caller of app.notify().
  • Source: D95 (at most one open per type and subject); the lead in the session on #584 (it returns the open one's id).

R-NTF-11 · app.notify() is refused for a type code that isn't in the catalogue

Section titled “R-NTF-11 · app.notify() is refused for a type code that isn't in the catalogue”
  • Status: built
  • Example: given no type work_order.route_waiting is seeded, when a function calls app.notify() with it, then it is refused, and so is the action that called it (R-NTF-09).
  • Refusal: notification.type_not_found, with type_code.
  • Who: every caller of app.notify().
  • Source: D10 (a stable key, not the foreign key's 23503); the lead in the session on #584.

R-NTF-12 · App users can't insert, update or delete notifications, receipts or preferences directly

Section titled “R-NTF-12 · App users can't insert, update or delete notifications, receipts or preferences directly”
  • Status: built
  • Example: given a super_admin, when they insert a notification, set one's resolved_at, or insert a receipt for another member, then it is refused and nothing changes; the functions of R-NTF-15 to R-NTF-21 make the changes app users may make.
  • Refusal: none: insufficient_privilege (42501).
  • Who: every app user, super_admin included.
  • Source: D3; D95.

R-NTF-13 · A notification with no recipient is seen by a member holding its type's permission at its pool

Section titled “R-NTF-13 · A notification with no recipient is seen by a member holding its type's permission at its pool”
  • Status: built
  • Example: given a notification of a type seen with gate_team:approve at PML, when Rina, admin_fleet at PML, reads notifications, then it comes back; a checker at PML and an admin_fleet at SBY see none. Once Rina delegates gate_team:approve at PML to Deka (R-ACC-234), Deka sees it too, and stops seeing it when the delegation is revoked.
  • Refusal: none: hidden.
  • Who: every member, through their roles and overrides at the pool (R-ACC-09, R-ACC-49).
  • Source: D95 (who sees one; a role that changes changes what its holder sees).

R-NTF-14 · A notification with a recipient is seen only by that member

Section titled “R-NTF-14 · A notification with a recipient is seen only by that member”
  • Status: built
  • Example: given a notification that Deka is PIC of work order WO-0012 at PML, when Deka reads notifications, then it comes back; an admin at PML who holds its type's permission doesn't see it.
  • Refusal: none: hidden.
  • Who: every member.
  • Source: D95 (a notification with a recipient is seen only by that member).

R-NTF-15 · app.resolve_notification() sets resolved_at on the open notification of a type and subject; with none open it does nothing

Section titled “R-NTF-15 · app.resolve_notification() sets resolved_at on the open notification of a type and subject; with none open it does nothing”
  • Status: built
  • Example: given an open notification that WO-0012 waits for its route, when the function that routes WO-0012 calls app.resolve_notification() for that type and WO-0012, then it is resolved and leaves the bell; called again, or for a subject with none open, it changes nothing and raises nothing, so the routing still goes through.
  • Refusal: none.
  • Who: the business function that ends the condition, in its own transaction. App users never call it directly.
  • Source: D95 (a condition closes its own notification). That it does nothing with none open, so the action that ends a condition is never refused over its notification, is DOC's proposal in the session on #584.

R-NTF-16 · acknowledge_notification() records who acknowledged an open notification and when, once, for everyone who sees it

Section titled “R-NTF-16 · acknowledge_notification() records who acknowledged an open notification and when, once, for everyone who sees it”
  • Status: built
  • Example: given an open notification of a failed visit check at PML, seen by the background check team, when Sari acknowledges it, then it records Sari and the time, and every member who sees it sees that Sari has; it stays open until its condition ends (R-NTF-15).
  • Refusal: each has its own rule, checked in this order: notification.not_found (R-NTF-17), notification.already_resolved (R-NTF-19), then notification.already_acknowledged (R-NTF-18).
  • Who: every member who sees the notification (R-NTF-13, R-NTF-14).
  • Source: D95 (a team-owned notification can be acknowledged by one member for the team). The public function's name is DOC's proposal in the session on #584.

R-NTF-17 · acknowledge_notification(), mark_notification_read() and dismiss_notification() are refused for a notification the caller doesn't see or that doesn't exist

Section titled “R-NTF-17 · acknowledge_notification(), mark_notification_read() and dismiss_notification() are refused for a notification the caller doesn't see or that doesn't exist”
  • Status: built
  • Example: given a notification of PML that a checker at PML doesn't see (R-NTF-13), when the checker acknowledges it, marks it read or dismisses it, then it is refused, nothing changes, and the refusal says nothing of the notification; an id that names none gives the same refusal.
  • Refusal: notification.not_found, with notification_id.
  • Who: every caller of the three functions.
  • Source: D10; the lead in the session on #584.

R-NTF-18 · acknowledge_notification() is refused for a notification already acknowledged

Section titled “R-NTF-18 · acknowledge_notification() is refused for a notification already acknowledged”
  • Status: built
  • Example: given Sari acknowledged the failed visit check's notification, when Budi acknowledges it, then it is refused and it still names Sari.
  • Refusal: notification.already_acknowledged, with notification_id.
  • Who: every caller of acknowledge_notification().
  • Source: D95 (acknowledged once, for the team); D10.

R-NTF-19 · acknowledge_notification() is refused for a resolved notification

Section titled “R-NTF-19 · acknowledge_notification() is refused for a resolved notification”
  • Status: built
  • Example: given the checkpoint is done and its overdue notification resolved, when a checker acknowledges it, then it is refused and nothing changes.
  • Refusal: notification.already_resolved, with notification_id.
  • Who: every caller of acknowledge_notification().
  • Source: D95; D10.

R-NTF-20 · mark_notification_read() and dismiss_notification() make or update the caller's one receipt of a notification

Section titled “R-NTF-20 · mark_notification_read() and dismiss_notification() make or update the caller's one receipt of a notification”
  • Status: planned
  • Example: given Deka sees a notification and has no receipt of it, when Deka marks it read, then one receipt holds Deka and the time read; dismissing it later sets the time dismissed on the same receipt. Another member's receipt is untouched, and a member with no receipt has none until they act.
  • Refusal: notification.not_found (R-NTF-17).
  • Who: every member who sees the notification. A member reads only their own receipts (hidden).
  • Source: D95 (one row per member who read or dismissed it, made only when they do). The function names are DOC's proposal in the session on #584.

R-NTF-21 · set_notification_preference() saves the caller's delivery of a module or a type: live, digest or off, with the lowest severity they get live

Section titled “R-NTF-21 · set_notification_preference() saves the caller's delivery of a module or a type: live, digest or off, with the lowest severity they get live”
  • Status: planned
  • Example: given an admin, when they set module M5 to live from action, then M5's action and urgent notifications reach them live; a preference naming both a module and a type, or neither, is refused (check_violation, 23514). A member reads and changes only their own preferences.
  • Refusal: notification.type_not_found, with type_code, for a type that isn't in the catalogue.
  • Who: every member, for themselves.
  • Source: D95 (a member's choice per module or type: live, digest or off, and the lowest severity they get live). The function's name is DOC's proposal in the session on #584.

R-NTF-22 · A member's preference for a type wins over their preference for its module, which wins over their role's default

Section titled “R-NTF-22 · A member's preference for a type wins over their preference for its module, which wins over their role's default”
  • Status: planned
  • Example: given an admin who set module M5 to off and the type "a gate pass waiting for approval" to live, when one is raised, then it reaches them live, and M5's other types reach them not at all.
  • Refusal: none.
  • Who: every member.
  • Source: D95. The order is DOC's proposal in the session on #584.

R-NTF-23 · A member's off never applies to a notification sent to them by name

Section titled “R-NTF-23 · A member's off never applies to a notification sent to them by name”
  • Status: planned
  • Example: given Deka turned module M5 off, when a notification that Deka is PIC of WO-0012 names Deka as its recipient, then it still reaches Deka, by their role's default delivery of its type (R-NTF-04).
  • Refusal: none.
  • Who: every recipient.
  • Source: D95 (a member can't turn off one sent to them by name); the lead in the session on #584 (a rule with no key).

R-NTF-24 · A resolved notification and its receipts are deleted 90 days after it was resolved

Section titled “R-NTF-24 · A resolved notification and its receipts are deleted 90 days after it was resolved”
  • Status: planned
  • Example: given a notification resolved on 2026-12-01, when the daily clean-up runs on 2027-03-01, then it and its receipts are gone; an open notification is never deleted, however old.
  • Refusal: none.
  • Who: a pg_cron job. They aren't business rows, so the audit log doesn't keep them (P13).
  • Source: D95 (a resolved notification and its receipts are deleted after 90 days).

R-NTF-25 · notifications is in the Supabase Realtime publication

Section titled “R-NTF-25 · notifications is in the Supabase Realtime publication”
  • Status: built
  • Example: given the slice's migration has run, when the supabase_realtime publication's tables are listed, then notifications is one; a member listening receives only the rows row-level security lets them read (R-NTF-13, R-NTF-14). The local realtime service stays off (D58, OQ13); pgTAP proves the membership of the publication.
  • Refusal: none.
  • Who: the bell (M7).
  • Source: D95 (live through Supabase Realtime under RLS); the lead in the session on #584.

R-NTF-26 · Removing a membership deletes the notifications sent to it by name, its receipts and its preferences

Section titled “R-NTF-26 · Removing a membership deletes the notifications sent to it by name, its receipts and its preferences”
  • Status: built
  • Example: given an open notification names Deka's membership as its recipient, and Deka has receipts and preferences, when remove_member() removes Deka (R-ACC-189), then all three go with the membership, and the call is not refused; a notification with no recipient stays.
  • Refusal: none.
  • Who: every writer.
  • Source: D95 (they aren't business rows). DOC's proposal in the session on #584, so R-ACC-189 stays true.

R-NTF-27 · An open action notification of an escalating type becomes urgent once its organization's escalation time for that type has passed

Section titled “R-NTF-27 · An open action notification of an escalating type becomes urgent once its organization's escalation time for that type has passed”
  • Status: planned
  • Example: given a notification of type "a work order waiting for its route", which escalates, opened at 08:00 with severity action, and the organization's time for it is 24 hours (R-SET-13), when the escalation job runs after 08:00 the next day, then its severity is urgent and the admins get it live (R-NTF-04); a resolved one, or an info one, is left as it is.
  • Refusal: none.
  • Who: M7's escalation job (#507).
  • Source: D95 (severity; an unresolved action notification becomes urgent once its type's time has passed).