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
Canonicalize policy redaction order
rcourtmanbc99a27fd3e7
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 526a04b574..6985bdafc0 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -184,6 +184,9 @@ The same unified intelligence summary now also surfaces a canonical policyposture snapshot derived from unified resources, so sensitivity, routing, andredaction counts stay aligned with the governed resource model that theruntime uses for prompt export and context rendering.+That posture snapshot must render redaction labels through the canonical+unified-resource hint order, not alphabetically, so the AI summary, drawer,+and any future policy surfaces all present the same redaction precedence.The resource-intelligence payload used by the resource drawer also carriesthe same canonical policy posture snapshot, so the detail surface can showgoverned posture context without inventing a second posture contract.diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex 41f4756962..5e7b9cf2ae 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -401,6 +401,9 @@ The AI runtime now also uses the canonical policy presentation helpers tosurface those routing and redaction labels in shared context output, so thesame policy model is reflected in prompt summaries instead of beingre-described independently per surface.+Those helpers now own the canonical redaction-hint order and count-to-label+projection, so the AI summary and any other backend policy posture surface do+not re-sort redaction labels locally.Canonical resources now carry first-class graph-expansion fields: `Capabilities`(bounded action definitions with approval levels), `Relationships` (typedinter-resource links with direction and confidence), and `RecentChanges` (typeddiff --git a/internal/ai/intelligence_coverage_test.go b/internal/ai/intelligence_coverage_test.goindex a22b519ace..dcc7dfa0d1 100644--- a/internal/ai/intelligence_coverage_test.go+++ b/internal/ai/intelligence_coverage_test.go@@ -279,8 +279,8 @@ func TestIntelligence_summarizePolicyPosture(t *testing.T) {}labels := policyPostureRedactionLabels(summary)- if !reflect.DeepEqual(labels, []string{"Alias", "Hostname", "IP Address", "Platform ID"}) {- t.Fatalf("redaction labels = %#v, want %#v", labels, []string{"Alias", "Hostname", "IP Address", "Platform ID"})+ if !reflect.DeepEqual(labels, []string{"Hostname", "IP Address", "Platform ID", "Alias"}) {+ t.Fatalf("redaction labels = %#v, want %#v", labels, []string{"Hostname", "IP Address", "Platform ID", "Alias"})}}diff --git a/internal/ai/policy_posture.go b/internal/ai/policy_posture.goindex 04af9eabd4..6c5a13a0e6 100644--- a/internal/ai/policy_posture.go+++ b/internal/ai/policy_posture.go@@ -1,10 +1,6 @@package ai-import (- "sort"-- unifiedresources "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"-)+import unifiedresources "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"// PolicyPostureSummary captures the canonical data-governance posture derived// from the unified resource registry.@@ -55,15 +51,5 @@ func policyPostureRedactionLabels(summary *PolicyPostureSummary) []string {if summary == nil || len(summary.RedactionCounts) == 0 {return nil}-- labels := make([]string, 0, len(summary.RedactionCounts))- for hint := range summary.RedactionCounts {- label := unifiedresources.ResourceRedactionHintLabel(hint)- if label == "" {- continue- }- labels = append(labels, label)- }- sort.Strings(labels)- return labels+ return unifiedresources.ResourcePolicyRedactionLabelsFromCounts(summary.RedactionCounts)}diff --git a/internal/unifiedresources/code_standards_test.go b/internal/unifiedresources/code_standards_test.goindex 34388f8eb9..fc670dce5b 100644--- a/internal/unifiedresources/code_standards_test.go+++ b/internal/unifiedresources/code_standards_test.go@@ -272,10 +272,12 @@ func TestResourcePolicyPresentationUsesCanonicalLabels(t *testing.T) {source := string(data)requiredSnippets := []string{+ "ResourceRedactionHintOrder","ResourceSensitivityLabel(","ResourceRoutingScopeLabel(","ResourceRedactionHintLabel(","ResourcePolicyRedactionLabels(",+ "ResourcePolicyRedactionLabelsFromCounts(",}for _, snippet := range requiredSnippets {if !strings.Contains(source, snippet) {diff --git a/internal/unifiedresources/policy_metadata_test.go b/internal/unifiedresources/policy_metadata_test.goindex 043f0e7a8f..999e14c3e0 100644--- a/internal/unifiedresources/policy_metadata_test.go+++ b/internal/unifiedresources/policy_metadata_test.go@@ -104,6 +104,30 @@ func TestResourcePolicyPresentationLabels(t *testing.T) {}}+func TestResourcePolicyRedactionLabelsUseCanonicalOrder(t *testing.T) {+ policy := &ResourcePolicy{+ Routing: ResourceRoutingPolicy{+ Redact: []ResourceRedactionHint{+ ResourceRedactionAlias,+ ResourceRedactionPath,+ ResourceRedactionHostname,+ ResourceRedactionPlatformID,+ },+ },+ }++ got := ResourcePolicyRedactionLabels(policy)+ want := []string{"Hostname", "Platform ID", "Alias", "Path"}+ if len(got) != len(want) {+ t.Fatalf("redaction labels = %#v, want %#v", got, want)+ }+ for i := range want {+ if got[i] != want[i] {+ t.Fatalf("redaction labels = %#v, want %#v", got, want)+ }+ }+}+func containsRedactionHint(hints []ResourceRedactionHint, want ResourceRedactionHint) bool {for _, hint := range hints {if hint == want {diff --git a/internal/unifiedresources/policy_presentation.go b/internal/unifiedresources/policy_presentation.goindex c17889d915..64bab12f4f 100644--- a/internal/unifiedresources/policy_presentation.go+++ b/internal/unifiedresources/policy_presentation.go@@ -2,6 +2,16 @@ package unifiedresourcesimport "sort"+// ResourceRedactionHintOrder captures the canonical presentation order for+// redaction hints across backend and frontend policy surfaces.+var ResourceRedactionHintOrder = []ResourceRedactionHint{+ ResourceRedactionHostname,+ ResourceRedactionIPAddress,+ ResourceRedactionPlatformID,+ ResourceRedactionAlias,+ ResourceRedactionPath,+}+// ResourceSensitivityLabel returns the canonical human-readable sensitivity label.func ResourceSensitivityLabel(sensitivity ResourceSensitivity) string {switch sensitivity {@@ -55,14 +65,49 @@ func ResourcePolicyRedactionLabels(policy *ResourcePolicy) []string {if policy == nil || len(policy.Routing.Redact) == 0 {return nil}- labels := make([]string, 0, len(policy.Routing.Redact))+ counts := make(map[ResourceRedactionHint]int, len(policy.Routing.Redact))for _, hint := range policy.Routing.Redact {+ counts[hint]+++ }+ return ResourcePolicyRedactionLabelsFromCounts(counts)+}++// ResourcePolicyRedactionLabelsFromCounts returns the canonical labels for the+// redaction hints present in the provided count map.+func ResourcePolicyRedactionLabelsFromCounts(counts map[ResourceRedactionHint]int) []string {+ if len(counts) == 0 {+ return nil+ }++ labels := make([]string, 0, len(counts))+ seen := make(map[ResourceRedactionHint]struct{}, len(counts))++ for _, hint := range ResourceRedactionHintOrder {+ if counts[hint] <= 0 {+ continue+ }label := ResourceRedactionHintLabel(hint)if label == "" {continue}labels = append(labels, label)+ seen[hint] = struct{}{}+ }++ remaining := make([]string, 0, len(counts))+ for hint, count := range counts {+ if count <= 0 {+ continue+ }+ if _, ok := seen[hint]; ok {+ continue+ }+ label := ResourceRedactionHintLabel(hint)+ if label == "" {+ continue+ }+ remaining = append(remaining, label)}- sort.Strings(labels)- return labels+ sort.Strings(remaining)+ return append(labels, remaining...)}