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.

Resolve guest finding references before operator-state lookups

rcourtman3e3839022df4
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 681b27f85f..a3ae3366f9 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -4094,6 +4094,18 @@ the projection to the Finding before calling the orchestrator. This
is the one in-process write path that decides what the orchestrator
sees about operator commitments; all consumers (in-process Patrol,
external Claude Code, and MCP-speaking clients) read the same enriched shape.
+The provider closure must tolerate the findings runtime's mixed
+resource key spaces: unified-derived findings reference the hashed
+canonical resource ID, but Patrol guest inventory rows reference the
+node-scoped Proxmox source ID (`instance:node:vmid`). Operator state
+is keyed by canonical ID only, so a reference that misses the store
+directly resolves through the registry (`GetByReference`, which also
+covers retired canonical-ID eras and node-scoped guest references
+after #1669) before the provider reports no state — without that
+hop, maintenance windows and intentionally-offline intent silently
+never reach guest findings. Pinned by
+`TestContract_FindingsResourceOperatorStateProviderIsWired` in
+`internal/api/contract_test.go`.
`/api/agent/events` is the agent SSE stream — the substrate piece
that closes the agent-paradigm triangle (discovery + bundled reads +
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index 630e9067ad..25105878ff 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -21156,6 +21156,9 @@ func TestContract_FindingsResourceOperatorStateProviderIsWired(t *testing.T) {
if !strings.Contains(src, "GetResourceOperatorState(canonicalID)") {
t.Error("router.go must read state from the unified store's canonical accessor")
}
+ if !strings.Contains(src, "GetByReference(resourceRef)") {
+ t.Error("router.go must resolve non-canonical finding resource references (Patrol guest rows carry node-scoped source IDs) through the registry before reporting no operator state")
+ }
if !strings.Contains(src, "IntentionallyOffline: state.IntentionallyOffline") {
t.Error("router.go must propagate state.IntentionallyOffline through the projection so the findings runtime sees it")
}
diff --git a/internal/api/router.go b/internal/api/router.go
index 5ae3801524..85be27dd60 100644
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@ -2419,12 +2419,38 @@ func (r *Router) startPatrolForContext(ctx context.Context, orgID string) bool {
// `internal/unifiedresources` import.
patrol.GetFindings().SetResourceOperatorStateProvider(
ai.ResourceOperatorStateProviderFunc(
- func(canonicalID string, now time.Time) (ai.ResourceOperatorStateProjection, bool) {
+ func(resourceRef string, now time.Time) (ai.ResourceOperatorStateProjection, bool) {
orgStore, lookupErr := r.resourceHandlers.getStore(orgID)
if lookupErr != nil {
return ai.ResourceOperatorStateProjection{}, false
}
+ // Findings carry whatever resource ID their
+ // producer used: unified-derived findings hold
+ // the canonical hash, but Patrol guest inventory
+ // rows hold the node-scoped Proxmox source ID.
+ // Operator state is keyed by canonical ID only,
+ // so a reference that misses directly resolves
+ // through the registry before giving up —
+ // otherwise maintenance windows and
+ // intentionally-offline intent silently never
+ // reach guest findings.
+ canonicalID := resourceRef
state, found, fetchErr := orgStore.GetResourceOperatorState(canonicalID)
+ if fetchErr != nil {
+ return ai.ResourceOperatorStateProjection{}, false
+ }
+ if !found {
+ registry, registryErr := r.resourceHandlers.buildRegistry(orgID)
+ if registryErr != nil || registry == nil {
+ return ai.ResourceOperatorStateProjection{}, false
+ }
+ _, resolvedID, resolved := registry.GetByReference(resourceRef)
+ if !resolved || resolvedID == canonicalID {
+ return ai.ResourceOperatorStateProjection{}, false
+ }
+ canonicalID = resolvedID
+ state, found, fetchErr = orgStore.GetResourceOperatorState(canonicalID)
+ }
if fetchErr != nil || !found {
return ai.ResourceOperatorStateProjection{}, false
}