Skip to content

Notification scope

SupaCloud pushes three families of chat message to a person’s linked Telegram or Discord account. A per-project preference can silence two of them. The third can never be silenced, because it exists to reach a person the work is waiting on. This page explains where that decision is made and which seam a new notification must use.

Every chat notification belongs to one NotifyClass (sc_persistence::models::notify_prefs, reachable as db::models::NotifyClass):

Class Members Governed by the preference?
TaskTerminal { failure } The Telegram terminal report (Completed, Error, SystemStopped) and the Discord TL;DR Yes
Progress PR created, git result, pipeline result, intervention delivered; the Discord harness-memory note Yes
HumanAction Questions, visual approvals, tool approvals, model-class changes (task_tool_approvals), an expiring OAuth credential Never

failure is the terminal contract’s own answer, not a reading of the error text: an Error or a failed status is a failure, and a system stop is one unless its reason is the person’s own Cancelled. A budget hard stop is therefore a failure; a cancel is not.

NotifyClass::permitted_by(prefs) is the one decision point. Every surface classifies its message and asks it once, so a new event type cannot pick up a different rule by being added to a list somewhere else. On Telegram the classification is notify_class in sc-iface-telegram’s notifications_classify.rs; its match is exhaustive, so a new EventNotification variant does not compile until it names its class.

The preference is TaskNotifyPrefs { task_messages, progress_cards }, keyed by (user, platform, project). It follows the first-non-null rule of ADR 0061 §1b:

chat_notification_prefs (user x platform x PROJECT)
?? chat_platform_accounts.notify_task_tldr (user x platform)
?? deliver everything
task_messages Terminal message Progress
all Delivered Delivered when progress_cards is true
failures_only Delivered only when failure Never
none Never Never

chat_notification_prefs holds project overrides only; its project_id is NOT NULL. The user x platform tier stays on chat_platform_accounts. A task without a project skips the override tier.

The resolution read is queries::chat_platform_accounts::task_message_target_for_user: it returns the chat id and the resolved preference from one statement, for the reason #1232 fused the chat id and the toggle in task_chat_info. A target resolved from one row and judged against a second, separately tie-broken row lets two readers of one decision disagree. tldr_target_for_user is the project_id = None case of the same query, so the platform tier has one SQL definition.

Parsing fails open: an unknown task_messages token resolves to all. For a mute, the strict direction is to deliver. Silence is the failure nobody reports.

A human-action notification never reads the task-message preference. The Telegram and Discord approval pushes (tool_approval_actions.rs in each interface crate) resolve their chat through the ungated identity lookups. The one thing a project may steer is the channel: projects.notify_config.human_action_channel is telegram, discord or inbox_only, and services::notify_config::human_action_allows answers whether a given platform may carry it. With no configuration every linked platform receives it.

inbox_only is a routing choice, not a hazard. A human gate parks its run for as long as the decision takes. Waiting costs nothing, and the decision is always listed in the inbox and by approvals.

projects.notify_config is a sparse JSONB override on the precedent of closeout_config: NULL inherits everything.

{
"human_action_channel": "telegram | discord | inbox_only",
"project_channel": {
"platform": "telegram | discord",
"external_id": "<chat id>",
"consented_by": "<user id>",
"consented_at": "<timestamp>"
}
}

It is validated on write (an unknown key or token is refused, naming it), written by a workspace owner or admin only, and read per workspace.

project_channel is where a project-scoped report goes when its schedule’s recipient_mode is project_channel. Its chat id is never written directly: a write that carries project_channel.external_id is refused with a 422 naming notify_config.project_channel. The id comes only from a consumed code:

  1. An owner or admin calls POST /api/projects/{id}/notify-config/project-channel/link-token, which mints a one-time, short-lived code for (project, platform) in the /link token store with the purpose project_channel.
  2. Someone posts /link <code> in the target group or channel. The chat /link handler recognises the purpose, stores project_channel = { platform, external_id: <that chat's id>, consented_by, consented_at } through services::notify_config, audits project.notify_channel_linked, and answers in that chat.

consented_by is the SupaCloud user the posting chat account belongs to. Platform membership alone is not an authorization record and leaves no consent trail, and chat_platform_accounts is the user identity home, so the consent is recorded on the project. The owner/admin gate, write-time validation and the per-send exfil guard stay in place on top of the handshake.

A project_channel delivery replaces the chat target and drops the personal channels (email, in-app): both belong to a person. With no channel configured the report is not delivered and a warning is logged; it never falls back to someone’s direct message.

report_kind = 'loop_digest' (report_schedules::loop_digest) assembles, for the schedule’s project and window: merged PRs (from reports::report_task_list), backlog state counts, items in the stalled states with their last_error, question and visual approvals pending for more than 24 hours, rework rounds (backlog_items.convergence_round), the task count and spend against the project’s caps. Every query groups by the stored state string and never matches BacklogState exhaustively, so a new state joins by being added to STALLED_STATES.

Money follows the recipient: a person always sees spend against the budget, and a project_channel delivery carries money only when the project’s expose_cost_in_comment opt-in is on. The money fields are Option and serialize away otherwise. The trust and runners sections are Option fields that the trust snapshot and the runner-availability data fill; until then they are absent from the wire.

report_kind = 'engine_digest' honours the schedule’s project_id in the same way: a project-scoped engine digest counts only that project’s runs, so its projects_touched is 0 or 1.

The digest <project> command renders the same render_text on demand into the invoking chat, and notify <project> <mode> (alias mute) writes the same chat_notification_prefs row as the settings table. Both are seeded once in the command registry and carried by every surface.

sc_kernel::chat_limits is the one place the platform limits live:

Item Meaning
TELEGRAM_MESSAGE_LIMIT = 4096 Telegram’s sendMessage text limit
DISCORD_CONTENT_LIMIT = 2000 Discord’s message content limit; notify::send_discord reads it for its last-resort truncation
chunk_for_limit(body, limit) Splits a body into messages at line boundaries; a single overlong line is hard-split at a character boundary; nothing is dropped or reordered
with_trailer(body, trailer, limit) Fits body + blank line + trailer into one message, shortening the body so the trailer (the report link) survives

Both count characters, not bytes. A byte-oriented split panics on a multi-byte boundary. Report delivery chunks Telegram bodies and uses with_trailer for Discord, so a long report arrives whole on Telegram and keeps its link on Discord.

Test What it proves
sc-kernel/tests/chat_message_limits.rs A 12 000-character digest is three Telegram messages split on lines; the Discord link survives truncation
sc-persistence/src/models/notify_prefs_tests.rs The full truth table of permitted_by; HumanAction is permitted under every preference
server/tests/notification_scope.rs Precedence, the fail-open parse, project-scoped engine and loop digests, money hidden from an un-opted project channel, project-channel delivery, notify_config validation
server/tests/chat_platform_accounts_test.rs The caller inventory: exactly the documented deliveries read the gated target