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 normalization

rcourtmane43f924c64b1
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index e3c6485807..3f1db8a57e 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -307,6 +307,10 @@ The governed query-fact and resource-context paths must also use the shared
unified-resource policy helpers for the `aiSafeSummary` decision and
redaction predicates, so the same local-only and redaction rules are applied
consistently instead of being reimplemented in chat-local helpers.
+The frontend unified-resource hook also normalizes `aiSafeSummary` through
+the shared policy normalization helper, so the canonical trimmed summary
+value stays aligned with the same resource-policy boundary that governs
+policy-aware routing and redaction.
The resource-intelligence payload used by the resource drawer also carries
the same canonical policy posture snapshot, so the detail surface can show
governed posture context without inventing a second posture contract.
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index f2df83c242..40b9a43f69 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -264,6 +264,10 @@ that route through `frontend-modern/src/hooks/useUnifiedResources.ts` must
preserve canonical `policy` and `aiSafeSummary` fields so storage-bearing
resources do not silently lose their routing or redaction posture when they
cross from unified-resource ownership into storage or recovery presentation.
+That same decode path also trims `aiSafeSummary` through the shared policy
+normalizer, so storage and recovery surfaces keep the canonical summary text
+aligned with the policy-aware resource contract instead of reformatting it
+locally.
That same decode path now delegates policy string and redaction normalization
to `frontend-modern/src/utils/resourcePolicyNormalization.ts`, so storage and
recovery surfaces do not reimplement sensitivity, routing, or redaction
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 2e5d8ab2f8..1d5fcb1b17 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -233,6 +233,10 @@ 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.
+The frontend unified-resource hook also trims `aiSafeSummary` through the
+shared policy normalization helper, so the canonical summary value stays
+aligned with the same policy-aware contract that governs sensitivity and
+routing metadata.
That same contract also owns the canonical resource display-name fallback, so
name-or-ID presentation stays consistent between the unified AI adapter, the
AI resource context, and the connected-infrastructure / monitored-system
diff --git a/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts b/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts
index b970fe554b..fd8361f9e8 100644
--- a/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts
+++ b/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts
@@ -280,7 +280,7 @@ describe('useUnifiedResources', () => {
redact: ['HOSTNAME', ' ip-address ', 'Platform-ID', 'ALIAS'],
},
},
- aiSafeSummary: 'resource summary safe for remote AI use',
+ aiSafeSummary: ' resource summary safe for remote AI use ',
},
],
}),
diff --git a/frontend-modern/src/hooks/useUnifiedResources.ts b/frontend-modern/src/hooks/useUnifiedResources.ts
index ec1cafc253..35812cce98 100644
--- a/frontend-modern/src/hooks/useUnifiedResources.ts
+++ b/frontend-modern/src/hooks/useUnifiedResources.ts
@@ -22,7 +22,10 @@ import { logger } from '@/utils/logger';
import { eventBus } from '@/stores/events';
import { canonicalDiscoveryResourceType } from '@/utils/discoveryTarget';
import { getPreferredNormalizedPlatformId } from '@/utils/resourceIdentity';
-import { normalizeResourcePolicy } from '@/utils/resourcePolicyNormalization';
+import {
+ normalizeResourcePolicy,
+ normalizeResourcePolicyAISafeSummary,
+} from '@/utils/resourcePolicyNormalization';
import {
resolvePlatformTypeFromSources,
resolveSourceTypeFromSources,
@@ -563,7 +566,7 @@ const toResource = (v2: APIResource): Resource => {
const metricsTarget = resolveMetricsTarget(v2.type, v2.metricsTarget);
const policy = normalizeResourcePolicy(v2.policy);
- const aiSafeSummary = asTrimmedString(v2.aiSafeSummary);
+ const aiSafeSummary = normalizeResourcePolicyAISafeSummary(v2.aiSafeSummary);
return {
id: v2.id,
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 09b68b8d67..a3d626f8a2 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -70,6 +70,7 @@ import resourceChangePresentationSource from '@/utils/resourceChangePresentation
import resourceRelationshipPresentationSource from '@/utils/resourceRelationshipPresentation.ts?raw';
import resourceCorrelationPresentationSource from '@/utils/resourceCorrelationPresentation.ts?raw';
import confidencePresentationSource from '@/utils/confidencePresentation.ts?raw';
+import resourcePolicyNormalizationSource from '@/utils/resourcePolicyNormalization.ts?raw';
import diskListSource from '@/components/Storage/DiskList.tsx?raw';
import useDiskListModelSource from '@/components/Storage/useDiskListModel.ts?raw';
import diskDetailSource from '@/components/Storage/DiskDetail.tsx?raw';
@@ -1860,6 +1861,10 @@ describe('frontend resource type boundaries', () => {
expect(resourceRelationshipPresentationSource).toContain('formatConfidencePercentage');
expect(resourceCorrelationPresentationSource).toContain('formatConfidencePercentage');
expect(confidencePresentationSource).toContain('formatConfidencePercentage');
+ expect(useUnifiedResourcesSource).toContain('normalizeResourcePolicyAISafeSummary(');
+ expect(resourcePolicyNormalizationSource).toContain(
+ 'normalizeResourcePolicyAISafeSummary',
+ );
expect(useUnifiedResourcesSource).toContain('normalizeResourcePolicy(');
expect(useUnifiedResourcesSource).not.toContain('const resolvePolicySensitivity =');
expect(useUnifiedResourcesSource).not.toContain('const resolvePolicyRoutingScope =');
diff --git a/frontend-modern/src/utils/__tests__/resourcePolicyNormalization.test.ts b/frontend-modern/src/utils/__tests__/resourcePolicyNormalization.test.ts
index 77e5315556..ad9bfbfc10 100644
--- a/frontend-modern/src/utils/__tests__/resourcePolicyNormalization.test.ts
+++ b/frontend-modern/src/utils/__tests__/resourcePolicyNormalization.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest';
import {
+ normalizeResourcePolicyAISafeSummary,
normalizeResourcePolicy,
normalizeResourcePolicyRedactionHints,
normalizeResourcePolicyRoutingScope,
@@ -42,4 +43,10 @@ describe('resourcePolicyNormalization', () => {
expect(normalizeResourcePolicyRedactionHints([])).toBeUndefined();
expect(normalizeResourcePolicy({ sensitivity: 'internal' })).toBeUndefined();
});
+
+ it('normalizes aiSafeSummary to a trimmed string', () => {
+ expect(normalizeResourcePolicyAISafeSummary(' safe summary ')).toBe('safe summary');
+ expect(normalizeResourcePolicyAISafeSummary(' ')).toBeUndefined();
+ expect(normalizeResourcePolicyAISafeSummary(undefined)).toBeUndefined();
+ });
});
diff --git a/frontend-modern/src/utils/resourcePolicyNormalization.ts b/frontend-modern/src/utils/resourcePolicyNormalization.ts
index 4d4e26a8b9..a4382a59b1 100644
--- a/frontend-modern/src/utils/resourcePolicyNormalization.ts
+++ b/frontend-modern/src/utils/resourcePolicyNormalization.ts
@@ -65,6 +65,12 @@ export const normalizeResourcePolicyRedactionHints = (
return hints.length > 0 ? hints : undefined;
};
+export const normalizeResourcePolicyAISafeSummary = (value?: unknown): string | undefined => {
+ if (typeof value !== 'string') return undefined;
+ const trimmed = value.trim();
+ return trimmed ? trimmed : undefined;
+};
+
export const normalizeResourcePolicy = (policy?: {
sensitivity?: unknown;
routing?: {