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.

Centralize governed mention policy summaries

rcourtmanb321170da1f4
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 5916af61d4..973e880711 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -115,6 +115,10 @@ unified-resource policy metadata, skip discovery fan-out when governed
redaction already blocks cloud-safe raw context, and withhold routing
coordinates, bind-mount paths, hostnames, and discovery file paths whenever
resource policy marks those identifiers as redacted.
+The governed mention formatter must also render the policy line and redaction
+list through the shared unified-resource policy presentation helper so the
+chat prefetch path stays aligned with the same canonical sensitivity, routing,
+and redaction labels used by the AI summary and resource drawer.
The same governed-context rule also applies to the main unified AI resource
overview: infrastructure, workload, alert-label, and top-consumer summaries
must not leak raw resource names, cluster labels, IP addresses, or unresolved
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 5fda9d6ce0..d4beb14e1d 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -161,6 +161,10 @@ The same unified resource model now also feeds the canonical AI policy
posture summary, so sensitivity, routing, and redaction distributions stay
derived from the shared resource view instead of being rebuilt as a
page-local governance rollup.
+The same shared policy presentation helper now also formats governed mention
+policy lines and redaction lists for AI chat prefetch, so prompt context
+stays aligned with the canonical sensitivity, routing, and redaction labels
+instead of rebuilding them in lane-local helpers.
That same shared store now also persists append-only action lifecycle, action
audit, and export audit records, giving the control-plane verbs a durable home
diff --git a/internal/ai/chat/context_prefetch.go b/internal/ai/chat/context_prefetch.go
index 3ea0e8d9c5..581465c683 100644
--- a/internal/ai/chat/context_prefetch.go
+++ b/internal/ai/chat/context_prefetch.go
@@ -930,20 +930,9 @@ func formatGovernedMentionSummary(sb *strings.Builder, mention ResourceMention)
sb.WriteString(summary)
sb.WriteString("\n")
}
- if mention.Policy != nil {
- sb.WriteString(fmt.Sprintf("Policy: sensitivity=%s, routing=%s, cloud_summary=%t, cloud_raw_signals=%t\n",
- mention.Policy.Sensitivity,
- mention.Policy.Routing.Scope,
- mention.Policy.Routing.AllowCloudSummary,
- mention.Policy.Routing.AllowCloudRawSignals,
- ))
- if len(mention.Policy.Routing.Redact) > 0 {
- redactions := make([]string, 0, len(mention.Policy.Routing.Redact))
- for _, hint := range mention.Policy.Routing.Redact {
- redactions = append(redactions, string(hint))
- }
- sb.WriteString(fmt.Sprintf("Redactions: %s\n", strings.Join(redactions, ", ")))
- }
+ for _, line := range unifiedresources.ResourcePolicySummaryLines(mention.Policy) {
+ sb.WriteString(line)
+ sb.WriteString("\n")
}
sb.WriteString("Raw routing coordinates, bind mounts, hostnames, and discovery file paths withheld by canonical resource policy.\n\n")
}
diff --git a/internal/ai/chat/context_prefetch_additional_test.go b/internal/ai/chat/context_prefetch_additional_test.go
index 7cf23833f6..b97039180e 100644
--- a/internal/ai/chat/context_prefetch_additional_test.go
+++ b/internal/ai/chat/context_prefetch_additional_test.go
@@ -448,8 +448,11 @@ func TestContextPrefetcher_FormatContextSummary_GovernedMention(t *testing.T) {
if !strings.Contains(summary, "Governed resource") {
t.Fatalf("expected governed heading, got %q", summary)
}
- if !strings.Contains(summary, "Redactions: alias, hostname, path") {
- t.Fatalf("expected redaction list, got %q", summary)
+ if !strings.Contains(summary, "Policy: sensitivity=Restricted, routing=Local Only, cloud_summary=false, cloud_raw_signals=false") {
+ t.Fatalf("expected canonical policy line, got %q", summary)
+ }
+ if !strings.Contains(summary, "Redactions: Hostname, Alias, Path") {
+ t.Fatalf("expected canonical redaction list, got %q", summary)
}
if strings.Contains(summary, "customer-db") {
t.Fatalf("expected governed formatter to avoid raw name, got %q", summary)
diff --git a/internal/unifiedresources/code_standards_test.go b/internal/unifiedresources/code_standards_test.go
index 219ebbaeb6..c524643359 100644
--- a/internal/unifiedresources/code_standards_test.go
+++ b/internal/unifiedresources/code_standards_test.go
@@ -282,6 +282,7 @@ func TestResourcePolicyPresentationUsesCanonicalLabels(t *testing.T) {
"ResourcePolicyRedactionLabelsFromCounts(",
"ResourcePolicySensitivitySummaryFromCounts(",
"ResourcePolicyRoutingSummaryFromCounts(",
+ "ResourcePolicySummaryLines(",
}
for _, snippet := range requiredSnippets {
if !strings.Contains(source, snippet) {
diff --git a/internal/unifiedresources/policy_metadata_test.go b/internal/unifiedresources/policy_metadata_test.go
index bda401a766..4ff600eedc 100644
--- a/internal/unifiedresources/policy_metadata_test.go
+++ b/internal/unifiedresources/policy_metadata_test.go
@@ -149,6 +149,36 @@ func TestResourcePolicyCountSummariesUseCanonicalOrder(t *testing.T) {
}
}
+func TestResourcePolicySummaryLines(t *testing.T) {
+ policy := &ResourcePolicy{
+ Sensitivity: ResourceSensitivityRestricted,
+ Routing: ResourceRoutingPolicy{
+ Scope: ResourceRoutingScopeLocalOnly,
+ AllowCloudSummary: false,
+ AllowCloudRawSignals: false,
+ Redact: []ResourceRedactionHint{
+ ResourceRedactionAlias,
+ ResourceRedactionHostname,
+ ResourceRedactionPath,
+ },
+ },
+ }
+
+ got := ResourcePolicySummaryLines(policy)
+ want := []string{
+ "Policy: sensitivity=Restricted, routing=Local Only, cloud_summary=false, cloud_raw_signals=false",
+ "Redactions: Hostname, Alias, Path",
+ }
+ if len(got) != len(want) {
+ t.Fatalf("summary lines = %#v, want %#v", got, want)
+ }
+ for i := range want {
+ if got[i] != want[i] {
+ t.Fatalf("summary line[%d] = %q, want %q", i, got[i], want[i])
+ }
+ }
+}
+
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.go
index bf1ecff3bc..0c6698add9 100644
--- a/internal/unifiedresources/policy_presentation.go
+++ b/internal/unifiedresources/policy_presentation.go
@@ -3,6 +3,7 @@ package unifiedresources
import (
"fmt"
"sort"
+ "strings"
)
// ResourceSensitivityOrder captures the canonical presentation order for
@@ -161,3 +162,26 @@ func ResourcePolicyRoutingSummaryFromCounts(counts map[ResourceRoutingScope]int)
}
return parts
}
+
+// ResourcePolicySummaryLines returns the canonical human-readable summary lines
+// for a single resource policy.
+func ResourcePolicySummaryLines(policy *ResourcePolicy) []string {
+ if policy == nil {
+ return nil
+ }
+
+ lines := []string{
+ fmt.Sprintf("Policy: sensitivity=%s, routing=%s, cloud_summary=%t, cloud_raw_signals=%t",
+ ResourceSensitivityLabel(policy.Sensitivity),
+ ResourceRoutingScopeLabel(policy.Routing.Scope),
+ policy.Routing.AllowCloudSummary,
+ policy.Routing.AllowCloudRawSignals,
+ ),
+ }
+
+ if redactions := ResourcePolicyRedactionLabels(policy); len(redactions) > 0 {
+ lines = append(lines, fmt.Sprintf("Redactions: %s", strings.Join(redactions, ", ")))
+ }
+
+ return lines
+}