Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

docs(governance): record notification tag routing contract

[email protected]9245da363f0b
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 7ae5f3392f..ed2572a373 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -4114,6 +4114,11 @@ accept compatibility keys like Pushover `app_token` / `user_token`, but it
must return and forward only canonical `token` / `user` fields so agent-
adjacent shared `internal/api/` surfaces do not inherit a second live alias
contract.
+That notification boundary also carries resource-tag routing configuration.
+`internal/api/notifications.go` may preserve and normalize `tagFilter` plus
+`tagFilterMode` for email and webhook destinations, but those fields remain
+notifications/alerts-owned delivery policy. They do not change agent
+enrollment, command targeting, lifecycle authority, or host identity.
That same shared `internal/api/` dependency now also assumes recovery-token
persistence follows the same rule: raw recovery secrets may be minted for
immediate operator use, but `recovery_tokens.go` must persist only token hashes
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.md
index ed0d42421c..89be41f62f 100644
--- a/docs/release-control/v6/internal/subsystems/alerts.md
+++ b/docs/release-control/v6/internal/subsystems/alerts.md
@@ -550,6 +550,13 @@ The alert webhook editor now mirrors that canonical Pushover field rule through
`frontend-modern/src/utils/alertWebhookPresentation.ts`, so the UI shares the
same alias, preset, and custom-field input mapping instead of carrying its own
local webhook-field normalization fork.
+The destination editor also exposes resource-tag routing for email and each
+alert webhook. Alert producers must carry canonical resource tags into alert
+metadata: Proxmox VM/container tags remain literal, Docker container/service
+labels become `key:value` tags (or `key` for empty values), host-agent tags
+remain literal, and unified resources forward their canonical `Tags`. The
+alerts surface owns this producer metadata and routing UX; destination
+matching, persistence, and receipt-aware delivery remain notifications-owned.
The alert manager callback layer now also has to stay fan-out-safe. Monitor
delivery, the unified alert bridge, and Patrol-adjacent AI listeners must
compose through additive fired/resolved subscriptions instead of overwriting a
@@ -882,6 +889,10 @@ initial raised notification. Resolved notifications must not fan out when the
alert was never notified or was already acknowledged, and monitoring-driven
escalation delivery must consult the same quiet-hours suppression path while
still letting canonical escalation state reach websocket consumers.
+Resource-tag filtering must not re-evaluate mutable tags for a resolved event.
+The notification owner uses the firing delivery receipt to select recovery
+destinations, so a tag change between firing and recovery cannot suppress a
+clear from a destination that received the original alert.
That schedule surface now also follows the same shell/runtime split as the
other feature tabs: `frontend-modern/src/features/alerts/tabs/ScheduleTab.tsx`
stays the render shell, while
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 0ae59d23fd..ce76519ddf 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -6241,6 +6241,13 @@ input aliases at ingress instead of leaving them as a live runtime contract:
Pushover `app_token` / `user_token` may be accepted only at config/API/UI input
boundaries, and API responses plus live notification runtime state must carry
only canonical `token` / `user` fields.
+Email and webhook notification payloads also carry optional `tagFilter` and
+`tagFilterMode` (`all` or `any`). Omitted routing fields on update preserve
+saved values for mixed-version clients; an explicit empty `tagFilter` clears
+routing. Webhook list/create/update responses must return the normalized
+routing state without exposing masked headers, custom fields, or signing
+secrets, and the frontend client must retain the old payload shape when older
+servers omit these optional fields.
`GET /api/notifications/health` must fail closed around the persistent queue.
Its queue object reports `healthy`, `degraded`, or `unavailable`; includes
retained status counts, `attention_required`, fixed `reason_codes`, and the
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index c30f49f224..b26166cb05 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -4763,6 +4763,11 @@ controls in `ThresholdsTableDockerTab.tsx` remain gated to real
`docker-host` resources instead of leaking onto platform-managed runtimes.
`frontend-modern/src/features/alerts/useAlertWebhookDestinationsState.ts` now
owns webhook runtime, and
+the email and webhook destination forms compose the shared `TagInput` for
+resource-tag routing. Their feature state owns `tagFilter` plus the `all`/`any`
+mode, an empty filter presents global delivery, and webhook list cards render
+the saved tags without creating a second tag-input primitive or destination-
+local normalization contract.
`frontend-modern/src/components/Alerts/ResourceTable.tsx` now follows the same
shell rule: the shell only picks desktop vs mobile render ownership and bulk-edit
composition, while
diff --git a/docs/release-control/v6/internal/subsystems/notifications.md b/docs/release-control/v6/internal/subsystems/notifications.md
index 34c37eb11a..f64b7d7c2d 100644
--- a/docs/release-control/v6/internal/subsystems/notifications.md
+++ b/docs/release-control/v6/internal/subsystems/notifications.md
@@ -28,6 +28,7 @@ notification-management API surfaces.
6. `frontend-modern/src/api/notifications.ts`
7. `internal/operationaltrust/contracts.go`
8. `internal/api/notification_queue.go`
+9. `internal/notifications/tag_routing.go`
## Shared Boundaries
@@ -303,6 +304,22 @@ received that exact firing occurrence. Successful recovery delivery deletes
the receipt; persistent receipts survive restart and are retention-bounded.
Receipt read failure suppresses recovery rather than inventing prior delivery.
+### Resource-tag destination routing
+
+Email and every enabled alert webhook may define a normalized resource-tag
+filter and an `all` or `any` match mode. Empty filters preserve global
+delivery. Matching is exact after trimming and case folding, and grouped
+firing alerts are filtered independently for each destination; Apprise remains
+global. Tags may arrive through the canonical `tags`, `resourceTags`,
+`hostTags`, or `serviceTags` alert metadata keys.
+
+Resolved delivery deliberately bypasses current tag matching and is filtered
+by occurrence-bound delivery receipts instead. This guarantees that a
+destination which received a firing occurrence can receive its recovery even
+if resource tags change. Configuration copies must isolate filter slices,
+mixed-version updates must preserve omitted routing fields, and explicit empty
+filters must remain the supported clear operation.
+
Cooldown state is published only after firing receipts are recorded. Persistent
workers atomically claim a still-pending row after taking per-alert delivery
gates, and resolution cancellation takes the corresponding exclusive gates.
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index d215042404..7afb879b0b 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -2211,6 +2211,10 @@ Notification webhook management changes on shared `internal/api/` handlers are
likewise adjacent only: the webhook `signingSecret` payload field and its
masking semantics are notifications/API-contract owned and create no storage,
recovery-point, or backup-surface semantics.
+Resource-tag routing fields on email and webhook configuration are likewise
+notifications/alerts-owned. They may select delivery destinations from
+canonical alert metadata, but they do not alter storage health, protection
+posture, backup verification, recovery-point validity, or restore readiness.
Persistent notification queue-health changes on that same shared boundary
remain notifications/API-contract owned. Retained failed/dead-letter counts,
their seven-day/30-day retention metadata, and fail-closed unavailable state
diff --git a/internal/alerts/alerts_test.go b/internal/alerts/alerts_test.go
index 7245c35f35..f82a26c35d 100644
--- a/internal/alerts/alerts_test.go
+++ b/internal/alerts/alerts_test.go
@@ -31,6 +31,35 @@ func ptrTime(t time.Time) *time.Time {
return &tt
}
+func TestGuestAlertIncludesTagsForNotificationRouting(t *testing.T) {
+ m := newTestManager(t)
+ m.ClearActiveAlerts()
+
+ m.mu.Lock()
+ m.config.GuestDefaults = ThresholdConfig{
+ CPU: &HysteresisThreshold{Trigger: 80, Clear: 70},
+ }
+ m.config.TimeThresholds = map[string]int{}
+ m.mu.Unlock()
+
+ guest := models.VM{
+ ID: "qemu/route-100",
+ Name: "customer-alpha",
+ Status: "running",
+ CPU: 0.95,
+ Tags: []string{"customer:alpha", "critical"},
+ }
+ m.CheckGuest(guest, "pve-prod")
+
+ m.mu.RLock()
+ alert := testRequireActiveAlert(t, m, canonicalMetricStateID(guest.ID, "cpu"))
+ m.mu.RUnlock()
+ tags, ok := alert.Metadata["tags"].([]string)
+ if !ok || len(tags) != 2 || tags[0] != "customer:alpha" || tags[1] != "critical" {
+ t.Fatalf("guest routing tags = %#v", alert.Metadata["tags"])
+ }
+}
+
func TestPBSOfflineNormalizesStatusAndConnectionHealth(t *testing.T) {
tests := []struct {
name string
diff --git a/internal/alerts/guest_tags_test.go b/internal/alerts/guest_tags_test.go
index f7da837195..34cb1b9e7a 100644
--- a/internal/alerts/guest_tags_test.go
+++ b/internal/alerts/guest_tags_test.go
@@ -6,35 +6,6 @@ import (
"github.com/rcourtman/pulse-go-rewrite/internal/models"
)
-func TestGuestAlertIncludesTagsForNotificationRouting(t *testing.T) {
- m := newTestManager(t)
- m.ClearActiveAlerts()
-
- m.mu.Lock()
- m.config.GuestDefaults = ThresholdConfig{
- CPU: &HysteresisThreshold{Trigger: 80, Clear: 70},
- }
- m.config.TimeThresholds = map[string]int{}
- m.mu.Unlock()
-
- guest := models.VM{
- ID: "qemu/route-100",
- Name: "customer-alpha",
- Status: "running",
- CPU: 0.95,
- Tags: []string{"customer:alpha", "critical"},
- }
- m.CheckGuest(guest, "pve-prod")
-
- m.mu.RLock()
- alert := testRequireActiveAlert(t, m, canonicalMetricStateID(guest.ID, "cpu"))
- m.mu.RUnlock()
- tags, ok := alert.Metadata["tags"].([]string)
- if !ok || len(tags) != 2 || tags[0] != "customer:alpha" || tags[1] != "critical" {
- t.Fatalf("guest routing tags = %#v", alert.Metadata["tags"])
- }
-}
-
func TestGuestPoweredOffAlertIncludesTagsForNotificationRouting(t *testing.T) {
m := newTestManager(t)
tags := []string{"customer:alpha", "critical"}