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.

fix(relay): bind push notifications to instance id

rcourtman547708cf8f42
diff --git a/docs/release-control/v6/internal/subsystems/relay-runtime.md b/docs/release-control/v6/internal/subsystems/relay-runtime.md
index 7a6722090a..af3b21bf75 100644
--- a/docs/release-control/v6/internal/subsystems/relay-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/relay-runtime.md
@@ -22,7 +22,8 @@ bridging.
## Canonical Files
1. `internal/relay/client.go`
-2. `internal/config/persistence_relay.go`
+2. `internal/relay/protocol.go`
+3. `internal/config/persistence_relay.go`
## Shared Boundaries
@@ -31,8 +32,9 @@ bridging.
## Extension Points
1. Add or change desktop relay reconnect, registration, drain, proxy-stream, or encrypted channel behavior through `internal/relay/`
-2. Add or change persisted relay enablement, server URL, or reconnect-safe default loading through `internal/config/persistence_relay.go`
-3. Keep desktop relay changes aligned with the governed mobile and server relay surfaces represented by the L7 lane evidence
+2. Add or change relay control payload schemas, including mobile-visible push notification metadata, through `internal/relay/protocol.go`
+3. Add or change persisted relay enablement, server URL, or reconnect-safe default loading through `internal/config/persistence_relay.go`
+4. Keep desktop relay changes aligned with the governed mobile and server relay surfaces represented by the L7 lane evidence
## Forbidden Paths
@@ -62,6 +64,11 @@ Relay status truthfulness is part of the same contract. If the client is in a
governed reconnect or license-pause window, `ClientStatus.reconnect_in` must
reflect that delay instead of silently presenting a disconnected state with no
retry timing.
+Relay push notification identity is part of this same owned contract. The
+canonical `PUSH_NOTIFICATION` payload must carry the authoritative
+`instance_id` when the desktop relay client serializes it so multi-pairing
+mobile routing and repair flows cannot reinterpret a queued approval or
+finding against whichever instance happens to be active later.
The relay HTTP proxy boundary is also part of this owned surface. Relay DATA
requests must normalize outer method/path whitespace before building the local
Pulse API request so trivial spacing drift does not cause a valid proxied
diff --git a/internal/relay/client.go b/internal/relay/client.go
index 9f8c05d06b..9277046e25 100644
--- a/internal/relay/client.go
+++ b/internal/relay/client.go
@@ -301,6 +301,16 @@ func (c *Client) Status() ClientStatus {
// Returns ErrNotConnected if the client has not completed registration
// with the relay server.
func (c *Client) SendPushNotification(notification PushNotificationPayload) error {
+ c.mu.RLock()
+ instanceID := c.instanceID
+ ch := c.sendCh
+ connected := c.connected
+ c.mu.RUnlock()
+
+ if notification.InstanceID == "" {
+ notification.InstanceID = instanceID
+ }
+
frame, err := NewControlFrame(FramePushNotification, 0, notification)
if err != nil {
return fmt.Errorf("build push frame: %w", err)
@@ -310,11 +320,6 @@ func (c *Client) SendPushNotification(notification PushNotificationPayload) erro
return fmt.Errorf("encode push frame: %w", err)
}
- c.mu.RLock()
- ch := c.sendCh
- connected := c.connected
- c.mu.RUnlock()
-
if ch == nil || !connected {
return ErrNotConnected
}
diff --git a/internal/relay/client_test.go b/internal/relay/client_test.go
index 740ed0d3b7..bbb5632537 100644
--- a/internal/relay/client_test.go
+++ b/internal/relay/client_test.go
@@ -1502,6 +1502,9 @@ func TestClient_SendPushNotification(t *testing.T) {
if payload.Title != "Test Push" {
t.Errorf("payload title: got %q, want %q", payload.Title, "Test Push")
}
+ if payload.InstanceID != "inst_push" {
+ t.Errorf("payload instance_id: got %q, want %q", payload.InstanceID, "inst_push")
+ }
case <-time.After(3 * time.Second):
t.Fatal("timed out waiting for PUSH_NOTIFICATION frame")
}
diff --git a/internal/relay/protocol.go b/internal/relay/protocol.go
index c398478930..3b4c993b1d 100644
--- a/internal/relay/protocol.go
+++ b/internal/relay/protocol.go
@@ -194,6 +194,7 @@ type PushNotificationPayload struct {
Priority string `json:"priority"` // "normal", "high"
Title string `json:"title"` // Short title (≤100 chars)
Body string `json:"body"` // Body text (≤200 chars)
+ InstanceID string `json:"instance_id,omitempty"` // Canonical relay instance identifier for mobile routing/repair
ActionType string `json:"action_type,omitempty"` // "view_finding", "approve_fix", "view_fix_result"
ActionID string `json:"action_id,omitempty"` // Finding ID or Approval ID
Category string `json:"category,omitempty"` // Finding category (performance, capacity, etc.)