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.

Broaden governed AI-safe summaries

rcourtman14f004c2ff0e
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 19ecae34aa..be64dabffd 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -262,11 +262,12 @@ helpers. Chat consumers now call `CloneResourcePolicy(...)` directly from the
shared unified-resource contract, and their governed labels now flow through
shared `ResourcePolicyLabel(...)` and `ResourcePolicyRedactedValue(...)`
helpers instead of through AI-local presentation shims, so policy copying and
-policy-bound labels both stay centralized in the resource model.
-If a governed resource reaches those callers without an AI-safe summary, the
-shared label helper now falls back to the canonical redacted label instead of
-the raw resource name, so missing summary data does not leak governed identity
-through a local fallback path.
+policy-bound labels both stay centralized in the resource model. When a
+policy requires governed handling, the shared label helper now prefers the
+canonical AI-safe summary for every redacted or local-only resource and only
+falls back to the canonical redacted label if that governed summary is
+missing, so path-only and IP-only redactions do not regress to raw identity
+leakage or over-redaction.
The frontend unified-resource hook now trusts backend canonical `policy` and
`aiSafeSummary` values directly, so the canonical summary value stays
aligned with the same policy-aware contract that governs sensitivity and
diff --git a/internal/ai/resource_context_test.go b/internal/ai/resource_context_test.go
index d17135e3bd..ef3927324a 100644
--- a/internal/ai/resource_context_test.go
+++ b/internal/ai/resource_context_test.go
@@ -373,6 +373,49 @@ func TestBuildUnifiedResourceContextUsesAISafeSummaryForSensitiveResources(t *te
}
}
+func TestBuildUnifiedResourceContextUsesAISafeSummaryForPathRedactedResources(t *testing.T) {
+ storage := unifiedresources.Resource{
+ ID: "storage-1",
+ Name: "backup-volume",
+ Type: unifiedresources.ResourceTypeStorage,
+ Status: unifiedresources.StatusOnline,
+ Storage: &unifiedresources.StorageMeta{
+ Path: "/mnt/pve/backups",
+ },
+ }
+ unifiedresources.RefreshCanonicalMetadata(&storage)
+
+ stats := unifiedresources.ResourceStats{
+ Total: 1,
+ ByType: map[unifiedresources.ResourceType]int{
+ unifiedresources.ResourceTypeStorage: 1,
+ },
+ ByStatus: map[unifiedresources.ResourceStatus]int{
+ unifiedresources.StatusOnline: 1,
+ },
+ }
+
+ mockURP := &mockUnifiedResourceProvider{
+ getStatsFunc: func() unifiedresources.ResourceStats { return stats },
+ getInfrastructureFunc: func() []unifiedresources.Resource {
+ return []unifiedresources.Resource{storage}
+ },
+ getAllFunc: func() []unifiedresources.Resource {
+ return []unifiedresources.Resource{storage}
+ },
+ }
+
+ s := &Service{unifiedResourceProvider: mockURP}
+ got := s.buildUnifiedResourceContext()
+
+ if !strings.Contains(got, "storage resource; status online; redacted for cloud summary") {
+ t.Fatalf("expected AI-safe summary for path-redacted resource, got %q", got)
+ }
+ if strings.Contains(got, "backup-volume") {
+ t.Fatalf("expected path-redacted resource name to be hidden, got %q", got)
+ }
+}
+
func TestResourcePolicyHelpersShareAISafeSummaryDecision(t *testing.T) {
policy := &unifiedresources.ResourcePolicy{
Sensitivity: unifiedresources.ResourceSensitivitySensitive,
diff --git a/internal/unifiedresources/code_standards_test.go b/internal/unifiedresources/code_standards_test.go
index 899bacd3a9..21a380c20e 100644
--- a/internal/unifiedresources/code_standards_test.go
+++ b/internal/unifiedresources/code_standards_test.go
@@ -458,6 +458,7 @@ func TestResourcePolicyLabelHelpersUsedByAIConsumers(t *testing.T) {
"func ResourcePolicyLabel(name, aiSafeSummary string, policy *ResourcePolicy) string",
"if ResourcePolicyRequiresGovernedSummary(policy) {",
"return ResourcePolicyRedactedLabel",
+ "return ResourcePolicyRequiresGovernedSummary(policy)",
"Policy: sensitivity=%s, routing=%s",
"func ResourcePolicyRedactedValue(value string, policy *ResourcePolicy, hints ...ResourceRedactionHint) string",
"const ResourcePolicyRedactedLabel = \"redacted by policy\"",
diff --git a/internal/unifiedresources/policy_metadata_test.go b/internal/unifiedresources/policy_metadata_test.go
index d06d323570..706cead014 100644
--- a/internal/unifiedresources/policy_metadata_test.go
+++ b/internal/unifiedresources/policy_metadata_test.go
@@ -332,6 +332,20 @@ func TestResourcePolicyRedactsAndUsesAISafeSummary(t *testing.T) {
if ResourcePolicyUsesAISafeSummary("resource summary safe for remote AI use", nil) {
t.Fatal("did not expect nil policy to use AI-safe summary")
}
+
+ pathOnlyPolicy := &ResourcePolicy{
+ Sensitivity: ResourceSensitivitySensitive,
+ Routing: ResourceRoutingPolicy{
+ Scope: ResourceRoutingScopeLocalFirst,
+ Redact: []ResourceRedactionHint{ResourceRedactionPath},
+ },
+ }
+ if !ResourcePolicyUsesAISafeSummary("storage resource; status online; redacted for cloud summary", pathOnlyPolicy) {
+ t.Fatal("expected AI-safe summary to be used for path-redacted policy")
+ }
+ if got := ResourcePolicyLabel(" backup-storage ", " storage resource; status online; redacted for cloud summary ", pathOnlyPolicy); got != "storage resource; status online; redacted for cloud summary" {
+ t.Fatalf("ResourcePolicyLabel() for path-redacted policy = %q, want governed summary", got)
+ }
}
func TestResourceAISafeSummaryPolicySuffix(t *testing.T) {
diff --git a/internal/unifiedresources/policy_presentation.go b/internal/unifiedresources/policy_presentation.go
index 1094dd1b27..8cef6ab20c 100644
--- a/internal/unifiedresources/policy_presentation.go
+++ b/internal/unifiedresources/policy_presentation.go
@@ -318,14 +318,7 @@ func ResourcePolicyUsesAISafeSummary(summary string, policy *ResourcePolicy) boo
if strings.TrimSpace(summary) == "" || policy == nil {
return false
}
- if policy.Routing.Scope == ResourceRoutingScopeLocalOnly {
- return true
- }
- return ResourcePolicyRedacts(policy,
- ResourceRedactionAlias,
- ResourceRedactionHostname,
- ResourceRedactionPlatformID,
- )
+ return ResourcePolicyRequiresGovernedSummary(policy)
}
// ResourcePolicyRequiresGovernedSummary reports whether the policy requires a