How does hAPI send notifications through ntfy? #69

Closed
opened 2026-11-27 14:38:42 -05:00 by bobby · 1 comment
Owner

Part of #44

Question

Which notifications ship in v1, who sends each (hAPI, CI, Flux, vmalert, Kuma), how they're routed to Persons or the Household (topics, priorities), how hAPI authenticates to ntfy, and whether Persons can opt out or choose where notifications go?

Context carried from the map: a shared notification capability; topics, per-Person routing, auth to ntfy (hAPI's ntfy token is its own narrow credential delivered through SOPS, separate from CI's publish-only token, per ADR-0008). Depends on domain MVPs and data ownership. Candidates: alert the Household when hapi db breakglass is used; warn Principals about Tokens nearing expiry (ADR-0005); notify the Household when a Job fails or expires (ADR-0006); notify the Owner of CI workflow failures (an if: failure() step) and of Flux reconcile or rollout failures (ADR-0007). vmalert is a sender too (ADR-0009), and Kuma's down and degraded monitors want different priorities. Maintenance: notify the Household when a Task becomes due or overdue, honouring per-Task lead_days; the trigger must be event-driven as well as scheduled, since a new Reading can make a usage-based Task due. Finance: a month-end nudge when a Budget can be rebalanced (a Category in the red while another has money left), and a warning when an importer Bot's Transactions stop arriving.

From How do scheduled and background jobs run? (ADR-0012): checks are CronJobs running hapi notify <check> (pool 1, run as the scheduler Bot for Household data or per Person read-only for Personal data). They write durable Notification records (glossary: Notification) that also serve as the dedupe ledger. Undelivered ones are retried on the next run. Event-triggered cases (a new Reading) are caught by the next check. Decide here: the Notification's fields and recipients, channels and per-recipient channel preferences (ntfy now, a frontend inbox later, or both), whether v1 stores read state, check intervals, and whether delivery runs inside each check or in its own CronJob.

Part of #44 ## Question Which notifications ship in v1, who sends each (hAPI, CI, Flux, vmalert, Kuma), how they're routed to Persons or the Household (topics, priorities), how hAPI authenticates to ntfy, and whether Persons can opt out or choose where notifications go? **Context carried from the map:** a shared notification capability; topics, per-Person routing, auth to ntfy (hAPI's ntfy token is its own narrow credential delivered through SOPS, separate from CI's publish-only token, per ADR-0008). Depends on domain MVPs and data ownership. Candidates: alert the Household when `hapi db breakglass` is used; warn Principals about Tokens nearing expiry (ADR-0005); notify the Household when a Job fails or expires (ADR-0006); notify the Owner of CI workflow failures (an `if: failure()` step) and of Flux reconcile or rollout failures (ADR-0007). vmalert is a sender too (ADR-0009), and Kuma's *down* and *degraded* monitors want different priorities. Maintenance: notify the Household when a Task becomes due or overdue, honouring per-Task `lead_days`; the trigger must be event-driven as well as scheduled, since a new Reading can make a usage-based Task due. Finance: a month-end nudge when a Budget can be rebalanced (a Category in the red while another has money left), and a warning when an importer Bot's Transactions stop arriving. **From *How do scheduled and background jobs run?* (ADR-0012):** checks are CronJobs running `hapi notify <check>` (pool 1, run as the `scheduler` Bot for Household data or per Person read-only for Personal data). They write **durable Notification records** (glossary: *Notification*) that also serve as the dedupe ledger. Undelivered ones are retried on the next run. Event-triggered cases (a new Reading) are caught by the next check. Decide here: the Notification's fields and recipients, channels and per-recipient channel preferences (ntfy now, a frontend inbox later, or both), whether v1 stores read state, check intervals, and whether delivery runs inside each check or in its own CronJob.
bobby added the wayfinder:grilling label 2026-11-27 14:38:42 -05:00
bobby added a new dependency 2026-11-27 14:38:50 -05:00
bobby self-assigned this 2026-11-27 14:53:40 -05:00
Author
Owner

Resolution

Recorded in ADR-0013; glossary Notification sharpened.

  • Two lanes. Platform alerts (CI, Flux, vmalert → ops; Kuma down + Watchdog → ops-urgent) publish straight to ntfy, Owner-only, never via hAPI. hAPI Notifications are records addressed to one Person or the Household.
  • ntfy = notify.bobbypalko.com, already deny-all (anonymous read/publish → 403). Owner-managed users per a runbook: read-only per Person (hapi-p-<id>, hapi-household), one publish-only user per sender. upstream-base-url → ntfy.sh (iOS), 12 h cache, no attachments. Content = short title + link, no amounts or Personal data.
  • v1 checks (scheduler Bot, Household + platform data only; no Personal-domain checks until v2): tasks daily 08:00 (due-soon, overdue, once per occurrence); jobs every 15 min (failed/expired); budget hourly (Household Category goes into the red; refires only after recovering; replaces the month-end nudge); tokens daily (30/7 days, to the Person or to the Owner for Bot Tokens). No importer-staleness check: ADR-0011 failure on errors + Kuma cover it.
  • Delivery: checks only write; hapi notify deliver every 2 min is the sole publisher, idempotent on Notification id, gives up at 24 h (vmalert rule). Breakglass publishes synchronously and refuses to start if that fails.
  • Record: recipient, kind, dedupe_key (unique with kind), title, body, priority, link, delivered_at, attempts; delivered rows purged after 180 d. No preferences, read state or API in v1; opt out by muting in ntfy.
  • Priorities: 5 Kuma down, breakglass · 4 vmalert critical, Flux failure, Task overdue · 3 CI failure, Kuma degraded, Job failed/expired, Token 7 d · 2 Task due soon, budget overspend, Token 30 d.
  • For Which cluster hardening ships in v1? (#71): egress to notify.bobbypalko.com:443 from hAPI CronJobs and Flux notification-controller.
## Resolution Recorded in [ADR-0013](https://git.bobbypalko.com/bobby/hapi/src/branch/main/docs/adr/0013-ntfy-notifications.md); glossary *Notification* sharpened. - **Two lanes.** Platform alerts (CI, Flux, vmalert → `ops`; Kuma down + Watchdog → `ops-urgent`) publish straight to ntfy, Owner-only, never via hAPI. hAPI **Notifications** are records addressed to one Person or the Household. - **ntfy** = notify.bobbypalko.com, already deny-all (anonymous read/publish → 403). Owner-managed users per a runbook: read-only per Person (`hapi-p-<id>`, `hapi-household`), one publish-only user per sender. `upstream-base-url` → ntfy.sh (iOS), 12 h cache, no attachments. Content = short title + link, no amounts or Personal data. - **v1 checks** (scheduler Bot, Household + platform data only; no Personal-domain checks until v2): `tasks` daily 08:00 (due-soon, overdue, once per occurrence); `jobs` every 15 min (failed/expired); `budget` hourly (Household Category goes into the red; refires only after recovering; replaces the month-end nudge); `tokens` daily (30/7 days, to the Person or to the Owner for Bot Tokens). No importer-staleness check: ADR-0011 failure on `errors` + Kuma cover it. - **Delivery:** checks only write; `hapi notify deliver` every 2 min is the sole publisher, idempotent on Notification id, gives up at 24 h (vmalert rule). Breakglass publishes synchronously and **refuses to start** if that fails. - **Record:** recipient, `kind`, `dedupe_key` (unique with kind), title, body, priority, link, `delivered_at`, `attempts`; delivered rows purged after 180 d. No preferences, read state or API in v1; opt out by muting in ntfy. - **Priorities:** 5 Kuma down, breakglass · 4 vmalert critical, Flux failure, Task overdue · 3 CI failure, Kuma degraded, Job failed/expired, Token 7 d · 2 Task due soon, budget overspend, Token 30 d. - **For *Which cluster hardening ships in v1?* (#71):** egress to notify.bobbypalko.com:443 from hAPI CronJobs and Flux notification-controller.
bobby closed this issue 2026-11-27 15:19:43 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: bobby/hapi#69