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
fix: restore Proxmox protection posture evidence
rcourtman10310348889c
diff --git a/internal/recovery/posture.go b/internal/recovery/posture.goindex f182849d4e..89abfa20cc 100644--- a/internal/recovery/posture.go+++ b/internal/recovery/posture.go@@ -148,6 +148,17 @@ func NewProtectionProviderObservation() (ProtectionProviderObservation, error) {source = strings.TrimSpace(source)scope = strings.TrimSpace(scope)+ if observedAt.IsZero() || ingestedAt.IsZero() {+ return ProtectionProviderObservation{}, fmt.Errorf(+ "protection provider observation times are required",+ )+ }+ // Provider observations are persisted in millisecond-precision SQLite+ // columns. Canonicalize the envelope and its identity to that precision so+ // a write/read round trip cannot make valid evidence fail exact timestamp+ // validation.+ observedAt = time.UnixMilli(observedAt.UTC().UnixMilli()).UTC()+ ingestedAt = time.UnixMilli(ingestedAt.UTC().UnixMilli()).UTC()evidenceSource := operationaltrust.EvidenceSource{Provider: strings.TrimSpace(string(provider)),Collector: source,diff --git a/internal/recovery/posture_test.go b/internal/recovery/posture_test.goindex efb5381a41..103f0ad17a 100644--- a/internal/recovery/posture_test.go+++ b/internal/recovery/posture_test.go@@ -374,6 +374,49 @@ func TestNewProtectionProviderObservationRequiresTypedLimitation(t *testing.T) {}}+func TestNewProtectionProviderObservationCanonicalizesPersistentTimestampPrecision(t *testing.T) {+ t.Parallel()++ observedAt := time.Date(2026, 8, 4, 22, 0, 1, 752103663, time.UTC)+ ingestedAt := observedAt.Add(321 * time.Microsecond)+ observation, err := NewProtectionProviderObservation(+ ProviderProxmoxPVE,+ "pve-backup-enumeration",+ "homelab",+ OutcomeSuccess,+ ProtectionHistoryComplete,+ operationaltrust.EvidencePermissionsSufficient,+ false,+ observedAt,+ ingestedAt,+ nil,+ )+ if err != nil {+ t.Fatalf("NewProtectionProviderObservation() error = %v", err)+ }++ wantObservedAt := time.UnixMilli(observedAt.UnixMilli()).UTC()+ wantIngestedAt := time.UnixMilli(ingestedAt.UnixMilli()).UTC()+ if !observation.ObservedAt.Equal(wantObservedAt) ||+ !observation.Evidence.ObservedAt.Equal(wantObservedAt) {+ t.Fatalf(+ "observed times = %s / %s, want %s",+ observation.ObservedAt,+ observation.Evidence.ObservedAt,+ wantObservedAt,+ )+ }+ if !observation.IngestedAt.Equal(wantIngestedAt) ||+ !observation.Evidence.IngestedAt.Equal(wantIngestedAt) {+ t.Fatalf(+ "ingested times = %s / %s, want %s",+ observation.IngestedAt,+ observation.Evidence.IngestedAt,+ wantIngestedAt,+ )+ }+}+func TestDeriveProtectionPostureFailsClosedToDefaultPolicy(t *testing.T) {t.Parallel()diff --git a/internal/recovery/store/store_posture.go b/internal/recovery/store/store_posture.goindex 62f249b1fe..db988ac197 100644--- a/internal/recovery/store/store_posture.go+++ b/internal/recovery/store/store_posture.go@@ -512,6 +512,17 @@ func (s *Store) listLatestProtectionProviderObservations(if err := json.Unmarshal([]byte(evidenceRaw), &observation.Evidence); err != nil {continue}+ // RC7 wrote the indexed timestamps at the schema's millisecond+ // precision while retaining nanoseconds in the evidence envelope. The+ // facts are the same when both representations fall in the same+ // millisecond; restore the envelope precision before exact validation so+ // those already-persisted observations remain usable after upgrade.+ if observation.Evidence.ObservedAt.UTC().UnixMilli() != observedAtMs ||+ observation.Evidence.IngestedAt.UTC().UnixMilli() != ingestedAtMs {+ continue+ }+ observation.ObservedAt = observation.Evidence.ObservedAt.UTC()+ observation.IngestedAt = observation.Evidence.IngestedAt.UTC()if err := observation.Validate(); err != nil {continue}diff --git a/internal/recovery/store/store_posture_test.go b/internal/recovery/store/store_posture_test.goindex a276b1e994..9ab682759e 100644--- a/internal/recovery/store/store_posture_test.go+++ b/internal/recovery/store/store_posture_test.go@@ -167,6 +167,105 @@ func TestStoreProtectionPosturePersistsProviderAwareTruth(t *testing.T) {}}+func TestStoreProtectionPostureLoadsRC7NanosecondObservationEvidence(t *testing.T) {+ t.Parallel()++ store, err := Open(filepath.Join(t.TempDir(), "recovery.db"))+ if err != nil {+ t.Fatalf("Open() error = %v", err)+ }+ defer store.Close()++ now := time.Now().UTC().Truncate(time.Millisecond)+ observation, err := recovery.NewProtectionProviderObservation(+ recovery.ProviderProxmoxPVE,+ "pve-backup-enumeration",+ "homelab",+ recovery.OutcomeSuccess,+ recovery.ProtectionHistoryComplete,+ operationaltrust.EvidencePermissionsSufficient,+ false,+ now,+ now,+ nil,+ )+ if err != nil {+ t.Fatalf("NewProtectionProviderObservation() error = %v", err)+ }+ if err := store.UpsertProtectionProviderObservations(+ context.Background(),+ []recovery.ProtectionProviderObservation{observation},+ ); err != nil {+ t.Fatalf("UpsertProtectionProviderObservations() error = %v", err)+ }++ // Reproduce the RC7 representation: millisecond index columns alongside+ // the original nanosecond evidence timestamps from time.Now().+ legacyTime := now.Add(103663 * time.Nanosecond)+ legacyEvidence := observation.Evidence.Clone()+ legacyEvidence.ObservedAt = legacyTime+ legacyEvidence.IngestedAt = legacyTime+ legacyJSON, err := json.Marshal(legacyEvidence)+ if err != nil {+ t.Fatalf("marshal legacy evidence: %v", err)+ }+ if _, err := store.db.Exec(+ `UPDATE protection_provider_observations SET evidence_json = ? WHERE id = ?`,+ string(legacyJSON),+ observation.ID,+ ); err != nil {+ t.Fatalf("write legacy observation representation: %v", err)+ }++ backupTime := now.Add(-time.Hour)+ point := recovery.RecoveryPoint{+ ID: "pve-backup:homelab:vm-100",+ Provider: recovery.ProviderProxmoxPVE,+ Kind: recovery.KindBackup,+ Mode: recovery.ModeLocal,+ Outcome: recovery.OutcomeSuccess,+ CompletedAt: &backupTime,+ SubjectResourceID: "resource:vm-100",+ ProviderScope: "homelab",+ }+ point.Evidence, err = recovery.NewRecoveryPointEvidence(+ point,+ "pve-backup-inventory",+ now,+ )+ if err != nil {+ t.Fatalf("NewRecoveryPointEvidence() error = %v", err)+ }+ if err := store.UpsertPoints(+ context.Background(),+ []recovery.RecoveryPoint{point},+ ); err != nil {+ t.Fatalf("UpsertPoints() error = %v", err)+ }++ postures, total, err := store.ListProtectionPostures(+ context.Background(),+ recovery.ProtectionPostureQuery{+ SubjectResourceIDs: []string{"resource:vm-100"},+ },+ )+ if err != nil {+ t.Fatalf("ListProtectionPostures() error = %v", err)+ }+ if total != 1 || len(postures) != 1 {+ t.Fatalf("postures total=%d len=%d, want 1/1", total, len(postures))+ }+ if postures[0].State != recovery.ProtectionStateProtected {+ t.Fatalf("state = %q, want protected; posture=%#v", postures[0].State, postures[0])+ }+ if len(postures[0].ProviderStates) != 1 ||+ postures[0].ProviderStates[0].Source != "pve-backup-enumeration" ||+ postures[0].ProviderStates[0].HistoryCompleteness != recovery.ProtectionHistoryComplete ||+ postures[0].ProviderStates[0].Permissions != operationaltrust.EvidencePermissionsSufficient {+ t.Fatalf("provider state = %#v, want complete PVE enumeration", postures[0].ProviderStates)+ }+}+func TestStoreProtectionPostureMovesWhenPointIdentityIsCorrected(t *testing.T) {t.Parallel()