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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Align resource staleness with poll cadence
rcourtman875e414b4b9f
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 187c50df79..1c5d449fd8 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -138,6 +138,12 @@ lifecycle authority. Native `pulse_patrol` starts, current paid`patrol_control` starts, legacy `patrol_autonomy` starts, and legacy`pulse_pro_activation` starts all contribute to Patrol control starter orientation;`proActivationOperationsLoopStarterCount` remains a legacy entry-point counter+for continuity. Router wiring that passes monitor-owned Proxmox/PBS/PMG source+freshness thresholds into unified-resource adapters is likewise adjacent API+plumbing: lifecycle surfaces may consume the resulting resource status, but+must not treat a between-poll stale/fresh decision as agent enrollment,+installer success, update liveness, command reachability, or fleet-control+authority.for the old alias only, while the legacy completed/resolved/value`proActivation*` fields are compatibility aliases for that same first-partyPatrol control proof while older commercial and telemetry consumers migrate.diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 44e54b5dab..2b1ae21faa 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -555,6 +555,13 @@ organization, range, metric set, and workload scope, but that cache istransport-only. It may amortize polling and remount cost, but it must notchange normalized response shape, bypass monitor or read-state availabilitychecks, merge tenants, or become the source of truth for telemetry freshness.+Router-owned unified-resource adapter construction is also transport wiring,+not an API-local health model. When `internal/api/router.go` creates default or+tenant monitor adapters, it must pass the effective monitor configuration into+monitoring-owned source freshness derivation so `/api/resources`, summaries,+and Assistant resource providers observe the same Proxmox/PBS/PMG stale+thresholds as the live monitor. API handlers must not hard-code source stale+windows or reinterpret between-poll source freshness as workload degradation.The `/api/resources` type filter is the REST contract boundary for platformpage native inventory. It must accept canonical Docker / Podman runtime tokensdiff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.mdindex b7c340a43f..e0aa7f6640 100644--- a/docs/release-control/v6/internal/subsystems/monitoring.md+++ b/docs/release-control/v6/internal/subsystems/monitoring.md@@ -23,6 +23,10 @@ Monitoring also owns the distinction between Proxmox VM power state and QEMUguest-agent reachability: fresh or never-healthy VMs with an enabled butunavailable guest agent stay `not-running`, while only VMs with recent healthyguest-agent evidence may become `expected-unreachable`.+Monitoring owns source freshness cadence for Proxmox, PBS, and PMG resources:+the stale threshold is derived from the configured polling interval with a+minimum floor, so API-facing resource status must not degrade merely because a+healthy source is between normal poll cycles.Removed host-agent reconnect blocks are identity-scoped: matching may use thecanonical host ID or token-qualified machine/hostname continuity, but must neverblock a distinct live host by hostname alone.@@ -83,6 +87,7 @@ block a distinct live host by hostname alone.52. `internal/monitoring/monitor_alert_sync.go`53. `internal/monitoring/platform_poller_shared.go`54. `internal/monitoring/monitor_backups.go`+55. `internal/monitoring/resource_stale_thresholds.go`## Shared Boundaries@@ -100,6 +105,11 @@ block a distinct live host by hostname alone.are built by `newPrefixedPollProvider` from a `prefixedPollProviderSpec`.New scheduler-backed platform providers extend those helpers instead ofre-rolling per-platform copies of the same loops.+ Source freshness thresholds for PVE/PBS/PMG resource ingestion are derived+ through `internal/monitoring/resource_stale_thresholds.go` from the active+ poll interval and passed into the unified-resource adapter. New pollers or+ config paths that change source cadence must update that derivation instead+ of hard-coding stale windows inside registry or API code.Periodic out-of-scheduler platform pollers (TrueNAS, VMware) share theirlifecycle and config-resolution scaffold through`internal/monitoring/platform_poller_shared.go`: `startPollerLoop` ownsdiff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.mdindex 98631dd4c9..812331949b 100644--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md@@ -254,6 +254,11 @@ regression protection.the same startup-only router rule: env opt-in may configure monitoring-ownedchecker/collector callbacks, but normal protected request setup must not run`pct`, scan LXC guests, or collect Docker inventory.+ Source freshness threshold wiring in `internal/api/router.go` follows the+ same bounded startup/config rule. Router construction may pass already-held+ monitor config into the unified-resource adapter, but it must not add+ per-request polling, registry rescans, persistence walks, or tenant-wide+ refreshes to decide whether Proxmox/PBS/PMG resources are stale.Global resource timeline routing follows the same protected-request hot-pathrule: `/api/resources/timeline` registration may wire the authenticatedhandler, but router setup and auth gating must not execute resource-changediff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.mdindex 0233a1579f..d370358d46 100644--- a/docs/release-control/v6/internal/subsystems/security-privacy.md+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md@@ -295,6 +295,11 @@ existing resource-policy redaction still governs any model-bound context.read-only Agent-context boundary. Router glue may connect providers, butit must not become an alternate command path, raw provider-command path,config path, environment path, or secret-bearing metadata path.+ Router glue may also pass monitor-owned source freshness thresholds into+ unified-resource adapters, but those thresholds are operational cadence+ metadata only. They must not disclose credentials, command output, raw+ provider payloads, tenant-crossing config, or any new resource-policy bypass+ through monitoring-readable API responses.Assistant session rename routing through `PATCH /api/ai/sessions/{id}`stays on that same auth/scope boundary: the route may accept only auser-visible title mutation, must not expose transcript contents,diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 42b3df239c..e61aeff4b4 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -234,6 +234,12 @@ The platform page embedding point may pass read-only Proxmox guest inventoryinto that backup surface solely for workload identity correlation; the backupsurface must still source restore evidence from the PVE/PBS backup APIs ratherthan treating the page shell as recovery state.+Shared router wiring may pass monitor-owned Proxmox/PBS/PMG source freshness+thresholds into unified-resource adapters so resource rows do not flap between+normal poll cycles, but storage/recovery consumers may use that only as+operational resource-status context. Backup freshness, restore coverage,+storage protection, and recovery authority remain sourced from the canonical+PVE/PBS backup and storage-health evidence.Storage/recovery auth-adjacent changes may consume SSO-authenticated sessions,but they must not reinterpret SAML or multi-provider SSO availability as adiff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex cdb2a9a126..45ab820411 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -419,6 +419,11 @@ When monitoring marks a running VM's expected QEMU guest agent as unreachable,the resource adapter must surface a Proxmox-authored `availability_unreachable``resource-incident` with source `qemu-guest-agent`; it must leave VM powerstatus online/warning rather than rewriting the VM to stopped/offline.+Source freshness is a separate unified-resource status input, not a fixed+global health timer. Snapshot rebuilds, resource seeding, supplemental record+overlays, and cloned read-state overlays must preserve the monitoring-provided+stale thresholds for Proxmox, PBS, and PMG sources so resources do not flap to+warning/degraded between successful configured poll cycles.Service-discovery readiness is a unified-resource payload contract, not adrawer-local decoration. Resource list/detail payloads that expose adiff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex eba9507409..0c2f23da70 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -8320,6 +8320,47 @@ func TestContract_TenantAIServiceAvoidsSnapshotProviderBridge(t *testing.T) {}}+func TestContract_TenantMonitorAdapterUsesMonitorPollingCadence(t *testing.T) {+ router := &Router{+ config: &config.Config{+ PVEPollingInterval: 15 * time.Second,+ },+ monitorResourceAdapters: make(map[string]*unifiedresources.MonitorAdapter),+ }+ tenantMonitor := &monitoring.Monitor{}+ tenantMonitor.SetOrgID("tenant-1")+ setUnexportedField(t, tenantMonitor, "config", &config.Config{+ PVEPollingInterval: 5 * time.Minute,+ })++ adapter := router.monitorAdapterForMonitor(tenantMonitor)+ if adapter == nil {+ t.Fatal("expected tenant monitor adapter")+ }++ seen := time.Now().UTC().Add(-90 * time.Second).Truncate(time.Millisecond)+ adapter.PopulateFromSnapshot(models.StateSnapshot{+ VMs: []models.VM{{+ ID: "cluster-a:pve-a:101",+ Name: "db",+ Node: "pve-a",+ Instance: "cluster-a",+ VMID: 101,+ Status: "running",+ Type: "qemu",+ LastSeen: seen,+ }},+ })++ vms := adapter.VMs()+ if len(vms) != 1 {+ t.Fatalf("VM count = %d, want 1", len(vms))+ }+ if vms[0].Status() != unifiedresources.StatusOnline {+ t.Fatalf("VM status = %q, want online", vms[0].Status())+ }+}+func TestContract_HandoffExchangeTargetPathIsSignedAndLocalOnly(t *testing.T) {source, err := os.ReadFile(filepath.Clean("cloud_handoff_handlers.go"))if err != nil {diff --git a/internal/api/router.go b/internal/api/router.goindex 84e7a686ee..e793c481b9 100644--- a/internal/api/router.go+++ b/internal/api/router.go@@ -305,7 +305,10 @@ func NewRouter(cfg *config.Config, monitor *monitoring.Monitor, mtMonitor *monitr.tenantRateLimiter = NewTenantRateLimiter(0, 0)}r.resourceRegistry = unifiedresources.NewRegistry(nil)- r.monitorResourceAdapter = unifiedresources.NewMonitorAdapter(r.resourceRegistry)+ r.monitorResourceAdapter = unifiedresources.NewMonitorAdapterWithStaleThresholds(+ r.resourceRegistry,+ monitoring.ResourceStaleThresholdsForConfig(cfg),+ )// Sync the configured admin user to the authorizer (if supported)if cfg.AuthUser != "" {@@ -535,7 +538,10 @@ func (r *Router) setupRoutes() {}if r.resourceHandlers != nil {if store, err := r.resourceHandlers.getStore("default"); err == nil && store != nil {- r.monitorResourceAdapter = unifiedresources.NewMonitorAdapter(unifiedresources.NewRegistry(store))+ r.monitorResourceAdapter = unifiedresources.NewMonitorAdapterWithStaleThresholds(+ unifiedresources.NewRegistry(store),+ monitoring.ResourceStaleThresholdsForConfig(r.config),+ )}}r.syncPlatformSupplementalProviders(mock.IsMockEnabled())@@ -1458,7 +1464,10 @@ func (r *Router) monitorAdapterForMonitor(m *monitoring.Monitor) *unifiedresourcstore = resolved}}- adapter := unifiedresources.NewMonitorAdapter(unifiedresources.NewRegistry(store))+ adapter := unifiedresources.NewMonitorAdapterWithStaleThresholds(+ unifiedresources.NewRegistry(store),+ monitoring.ResourceStaleThresholdsForConfig(m.GetConfig()),+ )r.monitorResourceAdapters[orgID] = adapterreturn adapter}diff --git a/internal/monitoring/canonical_guardrails_test.go b/internal/monitoring/canonical_guardrails_test.goindex fbfc0b0ee9..f9f820883b 100644--- a/internal/monitoring/canonical_guardrails_test.go+++ b/internal/monitoring/canonical_guardrails_test.go@@ -2482,3 +2482,35 @@ func TestStateBroadcastSignalsUseLazyCurrentState(t *testing.T) {t.Fatal("monitor_alerts.go must not build full frontend state for alert-driven broadcast signals")}}++func TestResourceStaleThresholdsFollowPollingCadence(t *testing.T) {+ thresholds := ResourceStaleThresholdsForConfig(&config.Config{+ PVEPollingInterval: 5 * time.Minute,+ PBSPollingInterval: 45 * time.Second,+ PMGPollingInterval: 3 * time.Minute,+ })++ if got := thresholds[unifiedresources.SourceProxmox]; got != 10*time.Minute {+ t.Fatalf("Proxmox threshold = %v, want %v", got, 10*time.Minute)+ }+ if got := thresholds[unifiedresources.SourcePBS]; got != 120*time.Second {+ t.Fatalf("PBS threshold = %v, want %v", got, 120*time.Second)+ }+ if got := thresholds[unifiedresources.SourcePMG]; got != 6*time.Minute {+ t.Fatalf("PMG threshold = %v, want %v", got, 6*time.Minute)+ }+}++func TestResourceStaleThresholdsPreserveDefaultFloors(t *testing.T) {+ thresholds := ResourceStaleThresholdsForConfig(nil)++ if got := thresholds[unifiedresources.SourceProxmox]; got != 60*time.Second {+ t.Fatalf("default Proxmox threshold = %v, want %v", got, 60*time.Second)+ }+ if got := thresholds[unifiedresources.SourcePBS]; got != 120*time.Second {+ t.Fatalf("default PBS threshold = %v, want %v", got, 120*time.Second)+ }+ if got := thresholds[unifiedresources.SourcePMG]; got != 120*time.Second {+ t.Fatalf("default PMG threshold = %v, want %v", got, 120*time.Second)+ }+}diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.goindex fc415c90f9..5a652aa7a8 100644--- a/internal/monitoring/monitor.go+++ b/internal/monitoring/monitor.go@@ -112,6 +112,12 @@ type ResourceStoreInterface interface {PopulateFromSnapshot(snapshot models.StateSnapshot)}+// StaleThresholdResourceStore is implemented by stores that evaluate source+// freshness while ingesting monitor snapshots.+type StaleThresholdResourceStore interface {+ SetStaleThresholds(thresholds map[unifiedresources.DataSource]time.Duration)+}+// SupplementalRecordStore is an optional extension for resource stores that can// ingest source-native unified records in addition to legacy snapshots.type SupplementalRecordStore interface {@@ -1713,20 +1719,10 @@ func clampInterval(value, min, max time.Duration) time.Duration {}func (m *Monitor) effectivePVEPollingInterval() time.Duration {- const minInterval = 10 * time.Second- const maxInterval = time.Hour-- interval := minInterval- if m != nil && m.config != nil && m.config.PVEPollingInterval > 0 {- interval = m.config.PVEPollingInterval- }- if interval < minInterval {- interval = minInterval- }- if interval > maxInterval {- interval = maxInterval+ if m == nil {+ return effectivePVEPollingIntervalForConfig(nil)}- return interval+ return effectivePVEPollingIntervalForConfig(m.config)}func (m *Monitor) baseIntervalForInstanceType(instanceType InstanceType) time.Duration {@@ -4134,6 +4130,10 @@ func (m *Monitor) DisableTemperatureMonitoring() {// When set, the monitor will check if it should reduce polling frequency// for nodes that have host agents providing data.func (m *Monitor) SetResourceStore(store ResourceStoreInterface) {+ if thresholdStore, ok := store.(StaleThresholdResourceStore); ok {+ thresholdStore.SetStaleThresholds(m.resourceStaleThresholds())+ }+m.mu.Lock()m.resourceStore = storeincidentStore := m.incidentStore@@ -4496,6 +4496,10 @@ func (m *Monitor) updateResourceStore(state models.StateSnapshot) {return}+ if thresholdStore, ok := store.(StaleThresholdResourceStore); ok {+ thresholdStore.SetStaleThresholds(m.resourceStaleThresholds())+ }+log.Debug().Int("nodes", len(state.Nodes)).Int("vms", len(state.VMs)).diff --git a/internal/monitoring/monitor_agents.go b/internal/monitoring/monitor_agents.goindex 001c3f185b..4b3d9e8c94 100644--- a/internal/monitoring/monitor_agents.go+++ b/internal/monitoring/monitor_agents.go@@ -758,8 +758,9 @@ func (m *Monitor) snapshotBackedUnifiedReadState() unifiedresources.ReadState {}registry := unifiedresources.NewRegistry(nil)- registry.IngestSnapshot(m.state.GetSnapshot())- return unifiedresources.NewMonitorAdapter(registry)+ thresholds := m.resourceStaleThresholds()+ registry.IngestSnapshotWithStaleThresholds(m.state.GetSnapshot(), thresholds)+ return unifiedresources.NewMonitorAdapterWithStaleThresholds(registry, thresholds)}func (m *Monitor) hostContinuitySince(now time.Time) time.Time {diff --git a/internal/monitoring/monitor_host_agents_test.go b/internal/monitoring/monitor_host_agents_test.goindex 771f7e87ee..7dcc373298 100644--- a/internal/monitoring/monitor_host_agents_test.go+++ b/internal/monitoring/monitor_host_agents_test.go@@ -129,6 +129,40 @@ func TestFindLinkedProxmoxEntity_MatchesCanonicalReadStateViews(t *testing.T) {}}+func TestSnapshotBackedUnifiedReadStateUsesConfiguredStaleThreshold(t *testing.T) {+ seen := time.Now().UTC().Add(-90 * time.Second).Truncate(time.Millisecond)+ state := models.NewState()+ state.UpdateVMs([]models.VM{{+ ID: "cluster-a:pve-a:101",+ Name: "db",+ Node: "pve-a",+ Instance: "cluster-a",+ VMID: 101,+ Status: "running",+ Type: "qemu",+ LastSeen: seen,+ }})++ monitor := &Monitor{+ config: &config.Config{+ PVEPollingInterval: 5 * time.Minute,+ },+ state: state,+ }++ readState := monitor.snapshotBackedUnifiedReadState()+ if readState == nil {+ t.Fatal("expected snapshot-backed read state")+ }+ vms := readState.VMs()+ if len(vms) != 1 {+ t.Fatalf("VM count = %d, want 1", len(vms))+ }+ if vms[0].Status() != unifiedresources.StatusOnline {+ t.Fatalf("VM status = %q, want online", vms[0].Status())+ }+}+func TestFindLinkedProxmoxEntity_AmbiguousNodeNameReturnsNoLink(t *testing.T) {monitor := &Monitor{state: models.NewState(),diff --git a/internal/monitoring/resource_stale_thresholds.go b/internal/monitoring/resource_stale_thresholds.gonew file mode 100644index 0000000000..b98c653691--- /dev/null+++ b/internal/monitoring/resource_stale_thresholds.go@@ -0,0 +1,79 @@+package monitoring++import (+ "time"++ "github.com/rcourtman/pulse-go-rewrite/internal/config"+ "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"+)++const (+ defaultProxmoxResourceStaleThreshold = 60 * time.Second+ defaultPlatformResourceStaleThreshold = 120 * time.Second+)++// ResourceStaleThresholdsForConfig derives canonical resource freshness from+// polling cadence. A source should not be considered stale until it has missed+// at least one expected poll cycle plus the normal interval.+func ResourceStaleThresholdsForConfig(cfg *config.Config) map[unifiedresources.DataSource]time.Duration {+ return map[unifiedresources.DataSource]time.Duration{+ unifiedresources.SourceProxmox: resourceStaleThresholdForPollInterval(+ effectivePVEPollingIntervalForConfig(cfg),+ defaultProxmoxResourceStaleThreshold,+ ),+ unifiedresources.SourcePBS: resourceStaleThresholdForPollInterval(+ effectivePlatformPollingIntervalForConfig(cfg, "pbs"),+ defaultPlatformResourceStaleThreshold,+ ),+ unifiedresources.SourcePMG: resourceStaleThresholdForPollInterval(+ effectivePlatformPollingIntervalForConfig(cfg, "pmg"),+ defaultPlatformResourceStaleThreshold,+ ),+ }+}++func (m *Monitor) resourceStaleThresholds() map[unifiedresources.DataSource]time.Duration {+ if m == nil {+ return ResourceStaleThresholdsForConfig(nil)+ }+ return ResourceStaleThresholdsForConfig(m.config)+}++func effectivePVEPollingIntervalForConfig(cfg *config.Config) time.Duration {+ const minInterval = 10 * time.Second+ const maxInterval = time.Hour++ interval := minInterval+ if cfg != nil && cfg.PVEPollingInterval > 0 {+ interval = cfg.PVEPollingInterval+ }+ return clampInterval(interval, minInterval, maxInterval)+}++func effectivePlatformPollingIntervalForConfig(cfg *config.Config, platform string) time.Duration {+ if cfg == nil {+ return 60 * time.Second+ }+ switch platform {+ case "pbs":+ return clampInterval(cfg.PBSPollingInterval, 10*time.Second, time.Hour)+ case "pmg":+ return clampInterval(cfg.PMGPollingInterval, 10*time.Second, time.Hour)+ default:+ return 60 * time.Second+ }+}++func resourceStaleThresholdForPollInterval(interval, minimum time.Duration) time.Duration {+ if minimum <= 0 {+ minimum = defaultPlatformResourceStaleThreshold+ }+ if interval <= 0 {+ return minimum+ }+ threshold := interval * 2+ if threshold < minimum {+ return minimum+ }+ return threshold+}diff --git a/internal/unifiedresources/adapter_coverage_test.go b/internal/unifiedresources/adapter_coverage_test.goindex 93644b02c6..4611e9cad5 100644--- a/internal/unifiedresources/adapter_coverage_test.go+++ b/internal/unifiedresources/adapter_coverage_test.go@@ -176,6 +176,52 @@ func TestResourceFromVMIgnoresNeverHealthyGuestAgent(t *testing.T) {}}+func TestMonitorAdapterUsesConfiguredProxmoxStaleThreshold(t *testing.T) {+ seen := time.Now().UTC().Add(-90 * time.Second).Truncate(time.Millisecond)+ snapshot := models.StateSnapshot{+ VMs: []models.VM{{+ ID: "cluster-a:pve-a:101",+ Name: "db",+ Node: "pve-a",+ Instance: "cluster-a",+ VMID: 101,+ Status: "running",+ Type: "qemu",+ LastSeen: seen,+ }},+ }++ defaultAdapter := NewMonitorAdapter(NewRegistry(nil))+ defaultAdapter.PopulateFromSnapshot(snapshot)+ defaultVMs := defaultAdapter.VMs()+ if len(defaultVMs) != 1 {+ t.Fatalf("expected one VM from default adapter, got %d", len(defaultVMs))+ }+ if defaultVMs[0].Status() != StatusWarning {+ t.Fatalf("default stale threshold status = %q, want warning", defaultVMs[0].Status())+ }++ adapter := NewMonitorAdapterWithStaleThresholds(NewRegistry(nil), map[DataSource]time.Duration{+ SourceProxmox: 10 * time.Minute,+ })+ adapter.PopulateFromSnapshot(snapshot)+ vms := adapter.VMs()+ if len(vms) != 1 {+ t.Fatalf("expected one VM, got %d", len(vms))+ }+ if vms[0].Status() != StatusOnline {+ t.Fatalf("configured stale threshold status = %q, want online", vms[0].Status())+ }++ resources := adapter.GetByType(ResourceTypeVM)+ if len(resources) != 1 {+ t.Fatal("expected VM resource to be available")+ }+ if status := resources[0].SourceStatus[SourceProxmox]; status.Status != "online" {+ t.Fatalf("SourceStatus[proxmox] = %+v, want online", status)+ }+}+func TestMonitorHostnamePriority(t *testing.T) {tests := []struct {name stringdiff --git a/internal/unifiedresources/monitor_adapter.go b/internal/unifiedresources/monitor_adapter.goindex 1b47d4d978..e71487993d 100644--- a/internal/unifiedresources/monitor_adapter.go+++ b/internal/unifiedresources/monitor_adapter.go@@ -13,21 +13,50 @@ import (type MonitorAdapter struct {registry *ResourceRegistry- mu sync.RWMutex- activeAlerts []models.Alert- lastRebuiltAt time.Time+ mu sync.RWMutex+ activeAlerts []models.Alert+ lastRebuiltAt time.Time+ staleThresholds map[DataSource]time.Duration}// NewMonitorAdapter creates a monitor-facing adapter around a registry.// If registry is nil, a new in-memory registry is created.func NewMonitorAdapter(registry *ResourceRegistry) *MonitorAdapter {+ return NewMonitorAdapterWithStaleThresholds(registry, nil)+}++// NewMonitorAdapterWithStaleThresholds creates a monitor-facing adapter using+// caller-owned source freshness thresholds.+func NewMonitorAdapterWithStaleThresholds(registry *ResourceRegistry, staleThresholds map[DataSource]time.Duration) *MonitorAdapter {if registry == nil {registry = NewRegistry(nil)}return &MonitorAdapter{- registry: registry,+ registry: registry,+ staleThresholds: cloneStaleThresholds(staleThresholds),+ }+}++// SetStaleThresholds updates the source freshness thresholds used on future+// snapshot rebuilds. Missing source entries keep the registry defaults.+func (a *MonitorAdapter) SetStaleThresholds(staleThresholds map[DataSource]time.Duration) {+ if a == nil {+ return+ }+ a.mu.Lock()+ a.staleThresholds = cloneStaleThresholds(staleThresholds)+ a.mu.Unlock()+}++func (a *MonitorAdapter) currentStaleThresholds() map[DataSource]time.Duration {+ if a == nil {+ return nil}+ a.mu.RLock()+ thresholds := cloneStaleThresholds(a.staleThresholds)+ a.mu.RUnlock()+ return thresholds}// ReadStateWithRecords clones a supported read state and overlays additional@@ -52,9 +81,10 @@ func ReadStateWithRecords(}cloned := NewRegistry(registry.store)- cloned.IngestResources(registry.List())+ thresholds := adapter.currentStaleThresholds()+ cloned.IngestResourcesWithStaleThresholds(registry.List(), thresholds)cloned.IngestRecords(source, records)- return NewMonitorAdapter(cloned)+ return NewMonitorAdapterWithStaleThresholds(cloned, thresholds)}func (a *MonitorAdapter) currentRegistry() *ResourceRegistry {@@ -96,7 +126,8 @@ func (a *MonitorAdapter) replaceRegistry(snapshot models.StateSnapshot, recordsBbefore := registry.List()rebuilt := NewRegistry(registry.store)- rebuilt.IngestSnapshot(snapshot)+ staleThresholds := a.currentStaleThresholds()+ rebuilt.IngestSnapshotWithStaleThresholds(snapshot, staleThresholds)for source, records := range recordsBySource {if len(records) == 0 || strings.TrimSpace(string(source)) == "" {continue@@ -107,7 +138,7 @@ func (a *MonitorAdapter) replaceRegistry(snapshot models.StateSnapshot, recordsB// ingested, so record-sourced resources would otherwise keep their// ingest-time "online" stamp regardless of how old their data is.// Re-evaluate staleness over the fully assembled registry.- rebuilt.MarkStale(time.Now().UTC(), nil)+ rebuilt.MarkStale(time.Now().UTC(), staleThresholds)rebuiltAt := time.Now().UTC()if !snapshot.LastUpdate.IsZero() && snapshot.LastUpdate.After(rebuiltAt) {rebuiltAt = snapshot.LastUpdatediff --git a/internal/unifiedresources/monitor_adapter_read_state_test.go b/internal/unifiedresources/monitor_adapter_read_state_test.goindex cf59f44e1d..7b4b0198b1 100644--- a/internal/unifiedresources/monitor_adapter_read_state_test.go+++ b/internal/unifiedresources/monitor_adapter_read_state_test.go@@ -219,6 +219,50 @@ func TestReadStateWithRecordsClonesMonitorAdapterAndOverlaysRecords(t *testing.T}}+func TestReadStateWithRecordsPreservesConfiguredStaleThresholds(t *testing.T) {+ seen := time.Now().UTC().Add(-90 * time.Second).Truncate(time.Millisecond)+ base := NewMonitorAdapterWithStaleThresholds(NewRegistry(nil), map[DataSource]time.Duration{+ SourceProxmox: 10 * time.Minute,+ })+ base.PopulateFromSnapshot(models.StateSnapshot{+ VMs: []models.VM{{+ ID: "cluster-a:pve-a:101",+ Name: "db",+ Node: "pve-a",+ Instance: "cluster-a",+ VMID: 101,+ Status: "running",+ Type: "qemu",+ LastSeen: seen,+ }},+ })++ baseVMs := base.VMs()+ if len(baseVMs) != 1 {+ t.Fatalf("base VM count = %d, want 1", len(baseVMs))+ }+ if baseVMs[0].Status() != StatusOnline {+ t.Fatalf("base VM status = %q, want online", baseVMs[0].Status())+ }++ overlay := ReadStateWithRecords(base, SourceAgent, []IngestRecord{+ HostIngestRecord(models.Host{+ ID: "host-1",+ Hostname: "host-1.local",+ Status: "online",+ LastSeen: time.Now().UTC(),+ }),+ })++ overlayVMs := overlay.VMs()+ if len(overlayVMs) != 1 {+ t.Fatalf("overlay VM count = %d, want 1", len(overlayVMs))+ }+ if overlayVMs[0].Status() != StatusOnline {+ t.Fatalf("overlay VM status = %q, want online", overlayVMs[0].Status())+ }+}+func TestMonitorAdapterRecordsSupplementalChangeTimeline(t *testing.T) {store := NewMemoryStore()adapter := NewMonitorAdapter(NewRegistry(store))diff --git a/internal/unifiedresources/registry.go b/internal/unifiedresources/registry.goindex 2d91d3cc77..d778d9e5fa 100644--- a/internal/unifiedresources/registry.go+++ b/internal/unifiedresources/registry.go@@ -30,6 +30,40 @@ var defaultStaleThresholds = map[DataSource]time.Duration{SourceAvailability: 120 * time.Second,}+func cloneStaleThresholds(thresholds map[DataSource]time.Duration) map[DataSource]time.Duration {+ if len(thresholds) == 0 {+ return nil+ }+ cloned := make(map[DataSource]time.Duration, len(thresholds))+ for source, threshold := range thresholds {+ if strings.TrimSpace(string(source)) == "" || threshold <= 0 {+ continue+ }+ cloned[source] = threshold+ }+ if len(cloned) == 0 {+ return nil+ }+ return cloned+}++func effectiveStaleThresholds(thresholds map[DataSource]time.Duration) map[DataSource]time.Duration {+ if len(thresholds) == 0 {+ return defaultStaleThresholds+ }+ effective := make(map[DataSource]time.Duration, len(defaultStaleThresholds)+len(thresholds))+ for source, threshold := range defaultStaleThresholds {+ effective[source] = threshold+ }+ for source, threshold := range thresholds {+ if strings.TrimSpace(string(source)) == "" || threshold <= 0 {+ continue+ }+ effective[source] = threshold+ }+ return effective+}+// IngestRecord is a source-native resource entry normalized for registry ingestion.type IngestRecord struct {SourceID string@@ -120,6 +154,16 @@ func (rr *ResourceRegistry) loadOverrides() {// IngestSnapshot ingests all resources from the current state snapshot.func (rr *ResourceRegistry) IngestSnapshot(snapshot models.StateSnapshot) {+ rr.ingestSnapshot(snapshot, nil)+}++// IngestSnapshotWithStaleThresholds ingests all resources from the current+// state snapshot and evaluates source freshness with caller-owned thresholds.+func (rr *ResourceRegistry) IngestSnapshotWithStaleThresholds(snapshot models.StateSnapshot, thresholds map[DataSource]time.Duration) {+ rr.ingestSnapshot(snapshot, thresholds)+}++func (rr *ResourceRegistry) ingestSnapshot(snapshot models.StateSnapshot, thresholds map[DataSource]time.Duration) {hostByID := make(map[string]*models.Host, len(snapshot.Hosts))for i := range snapshot.Hosts {host := snapshot.Hosts[i]@@ -452,7 +496,7 @@ func (rr *ResourceRegistry) IngestSnapshot(snapshot models.StateSnapshot) {rr.refreshStoragePostureLocked()rr.refreshIncidentRollupsLocked()rr.buildChildCounts()- rr.markStaleLocked(time.Now().UTC(), nil)+ rr.markStaleLocked(time.Now().UTC(), thresholds)rr.viewsDirty = truerr.mu.Unlock()}@@ -488,6 +532,16 @@ func (rr *ResourceRegistry) IngestRecords(source DataSource, records []IngestRec// This is used when a caller already has a canonical unified read model and// only needs store-backed manual links/exclusions applied on top.func (rr *ResourceRegistry) IngestResources(resources []Resource) {+ rr.ingestResources(resources, nil)+}++// IngestResourcesWithStaleThresholds seeds the registry from already-unified+// resources and evaluates source freshness with caller-owned thresholds.+func (rr *ResourceRegistry) IngestResourcesWithStaleThresholds(resources []Resource, thresholds map[DataSource]time.Duration) {+ rr.ingestResources(resources, thresholds)+}++func (rr *ResourceRegistry) ingestResources(resources []Resource, thresholds map[DataSource]time.Duration) {seededIDs := make([]string, 0, len(resources))for _, incoming := range resources {resource := cloneResourcePtr(&incoming)@@ -529,7 +583,7 @@ func (rr *ResourceRegistry) IngestResources(resources []Resource) {rr.refreshStoragePostureLocked()rr.refreshIncidentRollupsLocked()rr.buildChildCounts()- rr.markStaleLocked(time.Now().UTC(), nil)+ rr.markStaleLocked(time.Now().UTC(), thresholds)rr.viewsDirty = truerr.mu.Unlock()}@@ -1285,9 +1339,7 @@ func sourceSightingStatus(lastSeen time.Time) string {}func (rr *ResourceRegistry) markStaleLocked(now time.Time, thresholds map[DataSource]time.Duration) {- if thresholds == nil {- thresholds = defaultStaleThresholds- }+ thresholds = effectiveStaleThresholds(thresholds)for _, resource := range rr.resources {staleFound := falsediff --git a/internal/unifiedresources/registry_test.go b/internal/unifiedresources/registry_test.goindex 098f7319d6..29b34f2f24 100644--- a/internal/unifiedresources/registry_test.go+++ b/internal/unifiedresources/registry_test.go@@ -4776,3 +4776,55 @@ func TestMarkStaleRecomputesFromRemainingFreshSources(t *testing.T) {t.Fatalf("status should be recomputed from remaining fresh availability source; got %s, want online", got.Status)}}++func TestResourceRegistryUsesConfiguredProxmoxStaleThresholds(t *testing.T) {+ seen := time.Now().UTC().Add(-90 * time.Second).Truncate(time.Millisecond)+ snapshot := models.StateSnapshot{+ VMs: []models.VM{{+ ID: "cluster-a:pve-a:101",+ Name: "db",+ Node: "pve-a",+ Instance: "cluster-a",+ VMID: 101,+ Status: "running",+ Type: "qemu",+ LastSeen: seen,+ }},+ }++ defaultRegistry := NewRegistry(nil)+ defaultRegistry.IngestSnapshot(snapshot)+ defaultVMs := defaultRegistry.ListByType(ResourceTypeVM)+ if len(defaultVMs) != 1 {+ t.Fatalf("default VM count = %d, want 1", len(defaultVMs))+ }+ if defaultVMs[0].Status != StatusWarning {+ t.Fatalf("default VM status = %q, want warning", defaultVMs[0].Status)+ }++ thresholds := map[DataSource]time.Duration{+ SourceProxmox: 10 * time.Minute,+ }+ configuredRegistry := NewRegistry(nil)+ configuredRegistry.IngestSnapshotWithStaleThresholds(snapshot, thresholds)+ configuredVMs := configuredRegistry.ListByType(ResourceTypeVM)+ if len(configuredVMs) != 1 {+ t.Fatalf("configured VM count = %d, want 1", len(configuredVMs))+ }+ if configuredVMs[0].Status != StatusOnline {+ t.Fatalf("configured VM status = %q, want online", configuredVMs[0].Status)+ }++ clonedRegistry := NewRegistry(nil)+ clonedRegistry.IngestResourcesWithStaleThresholds(configuredRegistry.List(), thresholds)+ clonedVMs := clonedRegistry.ListByType(ResourceTypeVM)+ if len(clonedVMs) != 1 {+ t.Fatalf("cloned VM count = %d, want 1", len(clonedVMs))+ }+ if clonedVMs[0].Status != StatusOnline {+ t.Fatalf("cloned VM status = %q, want online", clonedVMs[0].Status)+ }+ if status := clonedVMs[0].SourceStatus[SourceProxmox]; status.Status != "online" {+ t.Fatalf("cloned SourceStatus[proxmox] = %+v, want online", status)+ }+}diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.pyindex 9f98e4e09f..c879950e94 100644--- a/scripts/release_control/subsystem_lookup_test.py+++ b/scripts/release_control/subsystem_lookup_test.py@@ -2917,7 +2917,7 @@ class SubsystemLookupTest(unittest.TestCase):{"heading": "## Shared Boundaries","path": "internal/api/access_control_handlers.go",- "line": 1139,+ "line": 1146,"heading_line": 137,}],