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 aiSafeSummary suffixes

rcourtmane5ddd18f5236
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index c1c09fdee2..89584f70c7 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -174,6 +174,10 @@ The export audit should also record canonical human-readable redaction labels
from the shared policy presentation helper, so the audit trail and the
resource-context surfaces speak the same governed redaction language instead
of reformatting hint names locally.
+The canonical AI-safe summary builder also owns the `sensitive` and
+`restricted` suffix phrases, so downstream AI consumers should treat those
+ending fragments as shared policy output instead of inventing their own
+wording.
The same AI runtime boundary now also consumes the canonical unified-resource
timeline when it assembles rich resource or incident context. Recent-change
context should come from the shared resource store first so AI prompts reflect
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 70938665f7..b5601fe35d 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -60,6 +60,11 @@ cross-source deduplication.
Resource detail mappers now reuse the shared
`frontend-modern/src/utils/textPresentation.ts` title-case helper for sensor
labels so the canonical unified-resource presentation layer owns the wording.
+
+The canonical AI-safe summary builder now owns the sensitivity-specific suffix
+phrases for `sensitive` and `restricted` resources, so the backend policy
+contract controls those strings instead of duplicating them inside the summary
+assembly branch.
4. Add metrics-target normalization or synthetic metrics support through `internal/unifiedresources/metrics_targets.go` and `internal/unifiedresources/metrics.go`
5. Add platform registry, resolution, or host-dedup behavior through `internal/unifiedresources/registry.go`, `internal/unifiedresources/resolve.go`, `internal/unifiedresources/resolved_host_set.go`, `internal/unifiedresources/snapshot_source_filter.go`, `internal/unifiedresources/store.go`, `internal/unifiedresources/kubernetes_capabilities.go`, and `internal/unifiedresources/pbs_rollups.go`
6. Add canonical governed name-resolution or policy-aware resource lookup behavior through `internal/unifiedresources/resolve.go` and `internal/unifiedresources/resolve_context.go`
diff --git a/internal/unifiedresources/code_standards_test.go b/internal/unifiedresources/code_standards_test.go
index 798f89faa5..609e848000 100644
--- a/internal/unifiedresources/code_standards_test.go
+++ b/internal/unifiedresources/code_standards_test.go
@@ -340,6 +340,24 @@ func TestResourcePolicyCloneHelperUsedByAIConsumers(t *testing.T) {
}
}
+func TestAISafeSummarySuffixHelperIsOwnedByUnifiedResources(t *testing.T) {
+ data, err := os.ReadFile(filepath.Join(".", "policy_metadata.go"))
+ if err != nil {
+ t.Fatalf("failed to read policy_metadata.go: %v", err)
+ }
+ source := string(data)
+ requiredSnippets := []string{
+ "func resourceAISafeSummaryPolicySuffix(sensitivity ResourceSensitivity) string",
+ "return \"redacted for cloud summary\"",
+ "return \"local-only context\"",
+ }
+ for _, snippet := range requiredSnippets {
+ if !strings.Contains(source, snippet) {
+ t.Fatalf("policy_metadata.go must contain %q", snippet)
+ }
+ }
+}
+
func TestCanonicalMetadataRefreshHelperUsedByConsumers(t *testing.T) {
requiredSnippets := map[string][]string{
filepath.Join(".", "policy_metadata.go"): {
diff --git a/internal/unifiedresources/policy_metadata.go b/internal/unifiedresources/policy_metadata.go
index 31f8ee6651..343ab39687 100644
--- a/internal/unifiedresources/policy_metadata.go
+++ b/internal/unifiedresources/policy_metadata.go
@@ -223,14 +223,25 @@ func buildAISafeSummary(resource Resource, sensitivity ResourceSensitivity) stri
switch sensitivity {
case ResourceSensitivitySensitive:
- parts = append(parts, "redacted for cloud summary")
+ parts = append(parts, resourceAISafeSummaryPolicySuffix(sensitivity))
case ResourceSensitivityRestricted:
- parts = append(parts, "local-only context")
+ parts = append(parts, resourceAISafeSummaryPolicySuffix(sensitivity))
}
return strings.Join(parts, "; ")
}
+func resourceAISafeSummaryPolicySuffix(sensitivity ResourceSensitivity) string {
+ switch sensitivity {
+ case ResourceSensitivitySensitive:
+ return "redacted for cloud summary"
+ case ResourceSensitivityRestricted:
+ return "local-only context"
+ default:
+ return ""
+ }
+}
+
func resourceSummaryType(resource Resource) string {
switch CanonicalResourceType(resource.Type) {
case ResourceTypeAgent:
diff --git a/internal/unifiedresources/policy_metadata_test.go b/internal/unifiedresources/policy_metadata_test.go
index 65dca3ac68..74feeadce7 100644
--- a/internal/unifiedresources/policy_metadata_test.go
+++ b/internal/unifiedresources/policy_metadata_test.go
@@ -344,6 +344,18 @@ func TestResourcePolicyRedactsAndUsesAISafeSummary(t *testing.T) {
}
}
+func TestResourceAISafeSummaryPolicySuffix(t *testing.T) {
+ if got := resourceAISafeSummaryPolicySuffix(ResourceSensitivitySensitive); got != "redacted for cloud summary" {
+ t.Fatalf("sensitive suffix = %q, want redacted for cloud summary", got)
+ }
+ if got := resourceAISafeSummaryPolicySuffix(ResourceSensitivityRestricted); got != "local-only context" {
+ t.Fatalf("restricted suffix = %q, want local-only context", got)
+ }
+ if got := resourceAISafeSummaryPolicySuffix(ResourceSensitivityInternal); got != "" {
+ t.Fatalf("internal suffix = %q, want empty", got)
+ }
+}
+
func TestResourcePolicyRequiresGovernedSummary(t *testing.T) {
if ResourcePolicyRequiresGovernedSummary(nil) {
t.Fatal("expected nil policy to not require governed summary")