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
refactor(ai): dedupe guest lifecycle snapshot loops and check the tool-loop helper return
rcourtmanb862723b93f0
diff --git a/internal/ai/findings_proxmox_lifecycle.go b/internal/ai/findings_proxmox_lifecycle.goindex 62d5c323a0..613fa06546 100644--- a/internal/ai/findings_proxmox_lifecycle.go+++ b/internal/ai/findings_proxmox_lifecycle.go@@ -215,32 +215,47 @@ func proxmoxGuestLifecycleSnapshots(readState unifiedresources.ReadState) map[streturn snapshots}for _, vm := range readState.VMs() {- if vm == nil || strings.TrimSpace(vm.ID()) == "" {- continue- }- freshness, ok := vm.SourceStatus(unifiedresources.SourceProxmox)- snapshots[strings.TrimSpace(vm.ID())] = proxmoxGuestLifecycleSnapshot{- id: strings.TrimSpace(vm.ID()), name: strings.TrimSpace(vm.Name()), resourceType: unifiedresources.ResourceTypeVM,- kind: "VM", status: vm.Status(), node: vm.Node(), instance: vm.Instance(), vmid: vm.VMID(), template: vm.Template(), lock: strings.TrimSpace(vm.Lock()),- observedAt: freshness.LastSeen.UTC(), sourceFresh: ok && strings.EqualFold(strings.TrimSpace(freshness.Status), "online") && !freshness.LastSeen.IsZero(),- capabilities: vm.Capabilities(),+ if vm != nil {+ recordProxmoxGuestLifecycleSnapshot(snapshots, vm, unifiedresources.ResourceTypeVM, "VM")}}for _, container := range readState.Containers() {- if container == nil || strings.TrimSpace(container.ID()) == "" {- continue- }- freshness, ok := container.SourceStatus(unifiedresources.SourceProxmox)- snapshots[strings.TrimSpace(container.ID())] = proxmoxGuestLifecycleSnapshot{- id: strings.TrimSpace(container.ID()), name: strings.TrimSpace(container.Name()), resourceType: unifiedresources.ResourceTypeSystemContainer,- kind: "LXC", status: container.Status(), node: container.Node(), instance: container.Instance(), vmid: container.VMID(), template: container.Template(), lock: strings.TrimSpace(container.Lock()),- observedAt: freshness.LastSeen.UTC(), sourceFresh: ok && strings.EqualFold(strings.TrimSpace(freshness.Status), "online") && !freshness.LastSeen.IsZero(),- capabilities: container.Capabilities(),+ if container != nil {+ recordProxmoxGuestLifecycleSnapshot(snapshots, container, unifiedresources.ResourceTypeSystemContainer, "LXC")}}return snapshots}+// proxmoxGuestView is the read surface shared by VM and LXC container views+// that guest lifecycle snapshots are built from.+type proxmoxGuestView interface {+ ID() string+ Name() string+ Status() unifiedresources.ResourceStatus+ Node() string+ Instance() string+ VMID() int+ Template() bool+ Lock() string+ Capabilities() []unifiedresources.ResourceCapability+ SourceStatus(unifiedresources.DataSource) (unifiedresources.SourceStatus, bool)+}++func recordProxmoxGuestLifecycleSnapshot(snapshots map[string]proxmoxGuestLifecycleSnapshot, guest proxmoxGuestView, resourceType unifiedresources.ResourceType, kind string) {+ id := strings.TrimSpace(guest.ID())+ if id == "" {+ return+ }+ freshness, ok := guest.SourceStatus(unifiedresources.SourceProxmox)+ snapshots[id] = proxmoxGuestLifecycleSnapshot{+ id: id, name: strings.TrimSpace(guest.Name()), resourceType: resourceType,+ kind: kind, status: guest.Status(), node: guest.Node(), instance: guest.Instance(), vmid: guest.VMID(), template: guest.Template(), lock: strings.TrimSpace(guest.Lock()),+ observedAt: freshness.LastSeen.UTC(), sourceFresh: ok && strings.EqualFold(strings.TrimSpace(freshness.Status), "online") && !freshness.LastSeen.IsZero(),+ capabilities: guest.Capabilities(),+ }+}+func sortedProxmoxGuestLifecycleIDs(snapshots map[string]proxmoxGuestLifecycleSnapshot) []string {ids := make([]string, 0, len(snapshots))for id := range snapshots {diff --git a/internal/ai/service_extended_test.go b/internal/ai/service_extended_test.goindex e4504ee539..dce243e564 100644--- a/internal/ai/service_extended_test.go+++ b/internal/ai/service_extended_test.go@@ -2098,7 +2098,7 @@ func TestService_ExecuteStream_AutonomousRawCommandRequiresApproval(t *testing.T}}})- requireServiceToolLoopFailure(t, err, ServiceToolLoopFailureRepeatedDenied)+ _ = requireServiceToolLoopFailure(t, err, ServiceToolLoopFailureRepeatedDenied)if dispatches != 0 {t.Fatalf("agent dispatches = %d, want 0", dispatches)}