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.

Dedupe policy postures, AI-safe summaries, and self-alias ids in the stream

rcourtman9e1b8bfa1adc
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index b9ba7e2fd9..b4dc13e48a 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -6780,7 +6780,12 @@ alert deltas immediately on arrival — alert lifecycle truth never waits for
the operator-input idle gate that defers resource work. An entry that cannot
key by id drops the whole field back to plain whole-payload diffing, and a
client without a baseline ignores the delta and heals on the next full
-payload, so the keyed path can never corrupt either array.
+payload, so the keyed path can never corrupt either array. Per-resource
+static metadata dedupes through state-level catalogs: `capabilityCatalog`,
+`policyCatalog`, and `aiSafeSummaryCatalog` hold the distinct blobs,
+resources carry `capabilitiesRef`/`policyRef`/`aiSafeSummaryRef`, and
+ingestion expands refs back to the inline shape so consumers never see the
+dedupe. Inline values remain valid from producers that carry no catalogs.
That same install-command payload continuity now also applies when auth is
optional: copied install and upgrade commands must omit token arguments
entirely on token-optional Pulse instances rather than serializing a fake
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index 6ad9e75dc4..f23ee3e894 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -248,10 +248,15 @@ clone-canonicalize-merge path, and the fast output must remain
content-equivalent to that path. The broadcast payload
itself is a scalability surface: duplicated capability blobs travel once
through the state-level `capabilityCatalog` and per-resource
-`capabilitiesRef`, default-posture policy and AI-safe prose are omitted and
-synthesized at ingestion, and superseded canonical ids are not duplicated
-into the alias list, so full snapshots, REST recovery, and reconnects do not
-re-ship static metadata per resource. The connected-infrastructure reporting
+`capabilitiesRef`, and non-default policy postures and AI-safe prose dedupe
+the same way through `policyCatalog`/`policyRef` and
+`aiSafeSummaryCatalog`/`aiSafeSummaryRef` (estates carry only a handful of
+distinct postures and templated summaries); default-posture policy is
+omitted and synthesized at ingestion, and neither superseded canonical ids
+nor the row's own wire id are duplicated into the alias list — the primary
+id stays so aliases remain the complete live vocabulary a host is reachable
+by — so full snapshots, REST recovery, and reconnects do not re-ship static
+metadata per resource. The connected-infrastructure reporting
projection rides the same per-client keyed delta engine: a broadcast carries
id-keyed merge patches for changed items only (at 50-node scale, timestamp
patches of a few hundred bytes instead of the full ~55KB projection every
diff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.json
index 1dfcd8cdd2..4bdc5b6584 100644
--- a/frontend-modern/browser-verification.json
+++ b/frontend-modern/browser-verification.json
@@ -1,13 +1,17 @@
{
"version": 1,
- "base_sha": "f3d34346528fb981631238a394672d375d7092e9",
- "verified_at": "2026-08-26T17:23:36Z",
+ "base_sha": "cba1e2abeb713c507f4d5d84a0b847177b298ac9",
+ "verified_at": "2026-08-26T17:45:01Z",
"result": "passed",
"changed_paths": [
- "frontend-modern/src/stores/websocket.ts"
+ "frontend-modern/src/stores/websocket.ts",
+ "frontend-modern/src/types/api.ts",
+ "frontend-modern/src/types/resource.ts"
],
"content_sha256": {
- "frontend-modern/src/stores/websocket.ts": "a1f05a8bbe44d9e99349d9f3651304823458a04fc20949ecc305f5bc22bab9af"
+ "frontend-modern/src/stores/websocket.ts": "6d8001a49231dba9646fdb53bd70ef29c005717c1cc119af0353cd9126d64e93",
+ "frontend-modern/src/types/api.ts": "f7c31896b70859c2ca77134c777fd6f0bdd99636253aaba7fb346f0231fdc96f",
+ "frontend-modern/src/types/resource.ts": "d61e61a0219bb38bd40b6b34f0f14313376c7f20031d022d5cbb41453a624f99"
},
"routes": [
"/proxmox/overview"
@@ -23,15 +27,14 @@
}
],
"states": [
- "isolated test backend built from this change serving the mock estate with churning alerts (13 active / 62 unacknowledged)",
- "fresh socket: initialState ships the full activeAlerts array once to establish the client baseline",
- "steady realtime ticks carrying activeAlertsDelta merge patches with zero full alert-array re-ships",
- "alert badge and estate rendering live throughout on desktop and narrow viewports"
+ "isolated test backend built from this change serving a large mock estate (1857 resources) over the state websocket",
+ "fresh socket snapshot carrying policyCatalog (5 entries, 1KB) and aiSafeSummaryCatalog (56 entries, 7KB) with per-resource refs",
+ "estate rendering live from catalog-expanded policies and summaries"
],
"interactions": [
- "raw websocket capture over 40s: 4 activeAlertsDelta payloads at 184-1981 bytes replacing the previous ~37-75KB whole-array re-ship whenever any alert changed; zero full re-ships after initialState",
- "client consumed all delta ticks with 140 workload rows mounted and no console errors",
- "unit-verified: alert level escalation, new-alert arrival, and resolution removal propagate to the store immediately even while operator input is active, encoding the alerts-subsystem immediacy boundary",
- "narrow 700px emulated viewport rendered the alerts badge and estate live"
+ "raw websocket snapshot capture: zero resources with inline policy or aiSafeSummary (previously ~150KB inline across 743 rows); 743 rows carry policyRef and aiSafeSummaryRef resolving into the state catalogs",
+ "alias audit across all 1857 resources: zero alias lists contain the row wire id (deduped), 1854 retain the primary id per the alias-vocabulary invariant",
+ "store-level expansion unit-verified: refs expand to inline policy/summary at ingestion, default posture still synthesized for ref-less rows, and a delta moving a policyRef re-expands from the catalog entry riding the same frame",
+ "client rendered 140 workload rows with zero console errors on desktop; narrow 700px emulated viewport rendered the estate live on the 36-row phone mounted-window budget"
]
}
diff --git a/frontend-modern/src/stores/__tests__/websocket-unified.test.ts b/frontend-modern/src/stores/__tests__/websocket-unified.test.ts
index 7055caf4a0..e3efcaec0f 100644
--- a/frontend-modern/src/stores/__tests__/websocket-unified.test.ts
+++ b/frontend-modern/src/stores/__tests__/websocket-unified.test.ts
@@ -1017,6 +1017,73 @@ describe('websocket store unified resource contract', () => {
}
});
+ it('expands policyRef and aiSafeSummaryRef from the state catalogs at ingestion', async () => {
+ const { store, dispose } = await createStoreHarness();
+ try {
+ await waitForOpenTick();
+ emitMessage({
+ type: 'initialState',
+ data: {
+ connectedInfrastructure: [],
+ policyCatalog: {
+ pol1: {
+ sensitivity: 'sensitive',
+ routing: { scope: 'local-first', redact: ['hostname'] },
+ },
+ },
+ aiSafeSummaryCatalog: {
+ sum1: 'storage resource; status online; redacted for cloud summary',
+ },
+ resources: [
+ {
+ id: 'storage-1',
+ type: 'storage',
+ name: 'tank',
+ status: 'online',
+ policyRef: 'pol1',
+ aiSafeSummaryRef: 'sum1',
+ },
+ { id: 'vm-1', type: 'vm', name: 'vm-1', status: 'running' },
+ ],
+ lastUpdate: 100,
+ activeAlerts: [],
+ recentlyResolved: [],
+ },
+ });
+
+ const storage = store.state.resources.find((resource) => resource.id === 'storage-1');
+ expect(storage?.policy?.sensitivity).toBe('sensitive');
+ expect(storage?.policy?.routing?.redact).toEqual(['hostname']);
+ expect(storage?.aiSafeSummary).toBe(
+ 'storage resource; status online; redacted for cloud summary',
+ );
+ // A row without refs still synthesizes the default posture.
+ const vm = store.state.resources.find((resource) => resource.id === 'vm-1');
+ expect(vm?.policy?.sensitivity).toBe('internal');
+
+ // A posture change moves the ref; the catalog change rides the same
+ // frame and the patched row re-expands from the new entry.
+ emitMessage({
+ type: 'rawData',
+ data: {
+ lastUpdate: 200,
+ policyCatalog: {
+ pol1: {
+ sensitivity: 'sensitive',
+ routing: { scope: 'local-first', redact: ['hostname'] },
+ },
+ pol2: { sensitivity: 'public', routing: { scope: 'cloud-summary' } },
+ },
+ resourceDelta: { upserts: [{ id: 'storage-1', policyRef: 'pol2' }] },
+ },
+ });
+ const storageAfter = store.state.resources.find((resource) => resource.id === 'storage-1');
+ expect(storageAfter?.policy?.sensitivity).toBe('public');
+ } finally {
+ dispose();
+ }
+ });
+
it('applies infrastructure merge-patch deltas touching only changed items', async () => {
const { store, dispose } = await createStoreHarness();
try {
diff --git a/frontend-modern/src/stores/websocket.ts b/frontend-modern/src/stores/websocket.ts
index 354a2425ef..979661dcdf 100644
--- a/frontend-modern/src/stores/websocket.ts
+++ b/frontend-modern/src/stores/websocket.ts
@@ -478,9 +478,13 @@ export function createWebSocketStore(url: string) {
// capabilitiesRef instead of inline capability blobs; ingestion expands the
// ref back into `capabilities` so consumers keep the inline shape.
let capabilityCatalog: Record<string, ResourceCapability[]> = {};
- // Records which catalog ref an expanded capabilities array was cloned from,
- // so a patched row re-expands only when its ref actually changed.
+ // Same dedupe contract for non-default policies and AI-safe summaries.
+ let policyCatalog: Record<string, Resource['policy']> = {};
+ let aiSafeSummaryCatalog: Record<string, string> = {};
+ // Records which catalog ref an expanded capabilities array or policy was
+ // cloned from, so a patched row re-expands only when its ref changed.
const capabilitiesExpandedFromRef = new WeakMap<object, string>();
+ const policyExpandedFromRef = new WeakMap<object, string>();
const hydrateSlimResource = (resource: Resource): void => {
if (!resource || typeof resource !== 'object') return;
@@ -498,6 +502,24 @@ export function createWebSocketStore(url: string) {
}
}
}
+ const policyRef = resource.policyRef;
+ if (policyRef) {
+ const currentPolicy = resource.policy as unknown as object | undefined;
+ if (!currentPolicy || policyExpandedFromRef.get(currentPolicy) !== policyRef) {
+ const policyEntry = policyCatalog[policyRef];
+ if (policyEntry) {
+ // Per-row clone: reconcile mutates adopted objects in place.
+ const expandedPolicy = structuredClone(policyEntry);
+ policyExpandedFromRef.set(expandedPolicy as unknown as object, policyRef);
+ resource.policy = expandedPolicy;
+ }
+ }
+ }
+ if (resource.aiSafeSummaryRef) {
+ const summary = aiSafeSummaryCatalog[resource.aiSafeSummaryRef];
+ // Strings are immutable; no clone needed.
+ if (summary) resource.aiSafeSummary = summary;
+ }
if (!resource.policy) {
resource.policy = createDefaultResourcePolicy();
}
@@ -985,6 +1007,12 @@ export function createWebSocketStore(url: string) {
if (message.data.capabilityCatalog !== undefined) {
capabilityCatalog = message.data.capabilityCatalog ?? {};
}
+ if (message.data.policyCatalog !== undefined) {
+ policyCatalog = message.data.policyCatalog ?? {};
+ }
+ if (message.data.aiSafeSummaryCatalog !== undefined) {
+ aiSafeSummaryCatalog = message.data.aiSafeSummaryCatalog ?? {};
+ }
// Canonical resource contract:
// `state.resources` is the authoritative frontend model.
diff --git a/frontend-modern/src/types/api.ts b/frontend-modern/src/types/api.ts
index acaccf131a..e057f0f6cc 100644
--- a/frontend-modern/src/types/api.ts
+++ b/frontend-modern/src/types/api.ts
@@ -1,6 +1,6 @@
// Properly typed TypeScript interfaces for Pulse API
-import type { Resource, ResourceCapability } from './resource';
+import type { Resource, ResourceCapability, ResourcePolicy } from './resource';
import type { EvidenceEnvelope, LifecycleTransition, OperationalRecord } from './operationalTrust';
export interface APITokenRecord {
@@ -34,6 +34,10 @@ export interface State {
// Distinct capability blobs referenced by Resource.capabilitiesRef; the
// websocket store expands refs into inline capabilities at ingestion.
capabilityCatalog?: Record<string, ResourceCapability[]> | null;
+ // Distinct non-default policy postures and templated AI-safe summaries
+ // referenced by Resource.policyRef / Resource.aiSafeSummaryRef.
+ policyCatalog?: Record<string, ResourcePolicy> | null;
+ aiSafeSummaryCatalog?: Record<string, string> | null;
}
export interface ResourceStateDelta {
diff --git a/frontend-modern/src/types/resource.ts b/frontend-modern/src/types/resource.ts
index 5408d9d6c8..73a6c24f03 100644
--- a/frontend-modern/src/types/resource.ts
+++ b/frontend-modern/src/types/resource.ts
@@ -1604,6 +1604,11 @@ export interface Resource {
// expands it into `capabilities` at ingestion so consumers keep reading the
// inline shape.
capabilitiesRef?: string;
+ // References into the state payload's policyCatalog / aiSafeSummaryCatalog;
+ // the websocket store expands them into `policy` / `aiSafeSummary` at
+ // ingestion under the same contract.
+ policyRef?: string;
+ aiSafeSummaryRef?: string;
actionReadiness?: ResourceActionReadiness[];
sourceStatus?: Record<string, ResourceSourceStatus>;
relationships?: ResourceRelationship[];
diff --git a/internal/models/converters.go b/internal/models/converters.go
index 1e9e32cd14..ea6c97a847 100644
--- a/internal/models/converters.go
+++ b/internal/models/converters.go
@@ -1190,6 +1190,8 @@ type ResourceConvertInput struct {
AISafeSummary string
Capabilities json.RawMessage
CapabilitiesRef string
+ PolicyRef string
+ AISafeSummaryRef string
Relationships json.RawMessage
RecentChanges json.RawMessage
FacetCounts json.RawMessage
@@ -1274,6 +1276,8 @@ func ConvertResourceToFrontend(input ResourceConvertInput) ResourceFrontend {
AISafeSummary: input.AISafeSummary,
Capabilities: input.Capabilities,
CapabilitiesRef: input.CapabilitiesRef,
+ PolicyRef: input.PolicyRef,
+ AISafeSummaryRef: input.AISafeSummaryRef,
Relationships: input.Relationships,
RecentChanges: input.RecentChanges,
FacetCounts: input.FacetCounts,
diff --git a/internal/models/models_frontend.go b/internal/models/models_frontend.go
index 41b762be47..74392ba718 100644
--- a/internal/models/models_frontend.go
+++ b/internal/models/models_frontend.go
@@ -971,6 +971,12 @@ type StateFrontend struct {
// top-level state fields generically, so catalog changes ride the same
// frame as the resource refs that need them.
CapabilityCatalog map[string]json.RawMessage `json:"capabilityCatalog,omitempty"`
+ // PolicyCatalog and AISafeSummaryCatalog dedupe the equally small sets of
+ // distinct non-default policy postures and templated AI-safe summaries the
+ // same way, referenced by ResourceFrontend.PolicyRef and
+ // ResourceFrontend.AISafeSummaryRef.
+ PolicyCatalog map[string]json.RawMessage `json:"policyCatalog,omitempty"`
+ AISafeSummaryCatalog map[string]string `json:"aiSafeSummaryCatalog,omitempty"`
}
// EmptyStateFrontend returns a canonical empty frontend state with stable
@@ -1082,7 +1088,13 @@ type ResourceFrontend struct {
// through the catalog instead of inlining ~3KB per resource; consumers
// resolve the ref at ingestion. Inline Capabilities remains valid for
// producers that do not carry a catalog.
- CapabilitiesRef string `json:"capabilitiesRef,omitempty"`
+ CapabilitiesRef string `json:"capabilitiesRef,omitempty"`
+ // PolicyRef and AISafeSummaryRef reference entries in
+ // StateFrontend.PolicyCatalog / AISafeSummaryCatalog under the same
+ // dedupe contract; inline Policy / AISafeSummary remain valid for
+ // producers that do not carry catalogs.
+ PolicyRef string `json:"policyRef,omitempty"`
+ AISafeSummaryRef string `json:"aiSafeSummaryRef,omitempty"`
Relationships json.RawMessage `json:"relationships,omitempty"`
RecentChanges json.RawMessage `json:"recentChanges,omitempty"`
FacetCounts json.RawMessage `json:"facetCounts,omitempty"`
diff --git a/internal/monitoring/canonical_guardrails_test.go b/internal/monitoring/canonical_guardrails_test.go
index 2e3380b9a1..2f232572d2 100644
--- a/internal/monitoring/canonical_guardrails_test.go
+++ b/internal/monitoring/canonical_guardrails_test.go
@@ -604,7 +604,10 @@ func TestBroadcastResourceProjectionCoalescesSplitHostIdentities(t *testing.T) {
for _, snippet := range []string{
"metricsTargetResolver := broadcastMetricsTargetResolver(unifiedView.readState)",
"broadcastResources := unifiedresources.CoalescePresentationHostResources(unifiedView.resources)",
- "frontendState.Resources, frontendState.CapabilityCatalog = convertResourcesForBroadcast(broadcastResources, metricsTargetResolver)",
+ "broadcastFrontendResources, broadcastCatalogs := convertResourcesForBroadcast(broadcastResources, metricsTargetResolver)",
+ "frontendState.CapabilityCatalog = broadcastCatalogs.capabilities",
+ "frontendState.PolicyCatalog = broadcastCatalogs.policies",
+ "frontendState.AISafeSummaryCatalog = broadcastCatalogs.aiSafeSummaries",
"frontendState.ConnectedInfrastructure = buildConnectedInfrastructure(broadcastResources, snapshot)",
"func attachBroadcastMetricsTargets(",
"allResources = unifiedresources.CoalescePresentationHostResources(allResources)",
diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.go
index c2e84e0201..357f5304d6 100644
--- a/internal/monitoring/monitor.go
+++ b/internal/monitoring/monitor.go
@@ -4171,7 +4171,11 @@ func (m *Monitor) buildBroadcastFrontendStateFromSnapshot(snapshot models.StateS
metricsTargetResolver := broadcastMetricsTargetResolver(unifiedView.readState)
broadcastResources := unifiedresources.CoalescePresentationHostResources(unifiedView.resources)
broadcastResources = m.applyPersistedMetadataToUnifiedResources(broadcastResources)
- frontendState.Resources, frontendState.CapabilityCatalog = convertResourcesForBroadcast(broadcastResources, metricsTargetResolver)
+ broadcastFrontendResources, broadcastCatalogs := convertResourcesForBroadcast(broadcastResources, metricsTargetResolver)
+ frontendState.Resources = broadcastFrontendResources
+ frontendState.CapabilityCatalog = broadcastCatalogs.capabilities
+ frontendState.PolicyCatalog = broadcastCatalogs.policies
+ frontendState.AISafeSummaryCatalog = broadcastCatalogs.aiSafeSummaries
frontendState.ConnectedInfrastructure = buildConnectedInfrastructure(broadcastResources, snapshot)
if !unifiedView.freshness.IsZero() {
frontendState.LastUpdate = unifiedView.freshness.UnixMilli()
@@ -5815,15 +5819,23 @@ func (m *Monitor) dockerAppContainerCustomURL(
return "", false
}
+// broadcastResourceCatalogs carries the content-addressed dedupe catalogs the
+// broadcast conversion extracts from per-resource static metadata.
+type broadcastResourceCatalogs struct {
+ capabilities map[string]json.RawMessage
+ policies map[string]json.RawMessage
+ aiSafeSummaries map[string]string
+}
+
// convertResourcesForBroadcast converts unified resources into the frontend
// payload shape. Distinct capability blobs are deduped into the returned
// catalog and referenced per resource via capabilitiesRef.
func convertResourcesForBroadcast(
allResources []unifiedresources.Resource,
metricsTargetResolvers ...MetricsTargetResourceStore,
-) ([]models.ResourceFrontend, map[string]json.RawMessage) {
+) ([]models.ResourceFrontend, broadcastResourceCatalogs) {
if len(allResources) == 0 {
- return []models.ResourceFrontend{}, nil
+ return []models.ResourceFrontend{}, broadcastResourceCatalogs{}
}
allResources = attachBroadcastMetricsTargets(
allResources,
@@ -5837,15 +5849,34 @@ func convertResourcesForBroadcast(
}
converted := make([]broadcastResource, 0, len(allResources))
- capabilityCatalog := make(map[string]json.RawMessage)
+ catalogs := broadcastResourceCatalogs{
+ capabilities: make(map[string]json.RawMessage),
+ policies: make(map[string]json.RawMessage),
+ aiSafeSummaries: make(map[string]string),
+ }
for _, r := range allResources {
input := monitorResourceToConvertInput(r)
if len(input.Capabilities) > 0 {
id := capabilityCatalogID(input.Capabilities)
- capabilityCatalog[id] = input.Capabilities
+ catalogs.capabilities[id] = input.Capabilities
input.CapabilitiesRef = id
input.Capabilities = nil
}
+ // Non-default policies and AI-safe summaries dedupe the same way:
+ // estates carry a handful of distinct postures and templated summary
+ // strings, so refs replace per-resource inline duplication.
+ if len(input.Policy) > 0 {
+ id := capabilityCatalogID(input.Policy)
+ catalogs.policies[id] = input.Policy
+ input.PolicyRef = id
+ input.Policy = nil
+ }
+ if input.AISafeSummary != "" {
+ id := capabilityCatalogID(json.RawMessage(input.AISafeSummary))
+ catalogs.aiSafeSummaries[id] = input.AISafeSummary
+ input.AISafeSummaryRef = id
+ input.AISafeSummary = ""
+ }
sortKey := strings.ToLower(input.DisplayName)
if sortKey == "" {
sortKey = strings.ToLower(input.Name)
@@ -5868,10 +5899,16 @@ func convertResourcesForBroadcast(
for i, resource := range converted {
result[i] = models.ConvertResourceToFrontend(resource.input)
}
- if len(capabilityCatalog) == 0 {
- capabilityCatalog = nil
+ if len(catalogs.capabilities) == 0 {
+ catalogs.capabilities = nil
}
- return result, capabilityCatalog
+ if len(catalogs.policies) == 0 {
+ catalogs.policies = nil
+ }
+ if len(catalogs.aiSafeSummaries) == 0 {
+ catalogs.aiSafeSummaries = nil
+ }
+ return result, catalogs
}
func broadcastMetricsTargetResolver(source interface{}) MetricsTargetResourceStore {
@@ -6040,15 +6077,22 @@ func slimResourceForBroadcast(resource *unifiedresources.Resource) {
if resource == nil {
return
}
- if canonical := resource.Canonical; canonical != nil && len(canonical.SupersededIDs) > 0 &&
- len(canonical.Aliases) > 0 {
- superseded := make(map[string]struct{}, len(canonical.SupersededIDs))
+ if canonical := resource.Canonical; canonical != nil && len(canonical.Aliases) > 0 {
+ duplicated := make(map[string]struct{}, len(canonical.SupersededIDs)+2)
for _, id := range canonical.SupersededIDs {
- superseded[strings.ToLower(strings.TrimSpace(id))] = struct{}{}
+ duplicated[strings.ToLower(strings.TrimSpace(id))] = struct{}{}
+ }
+ // The row's own wire id is a self-reference: every identity consumer
+ // unions resource.id beside the alias spread, so the wire never needs
+ // it inside aliases. The primary id stays: aliases remain the complete
+ // live vocabulary a host is reachable by (see
+ // TestBroadcastSlimmingKeepsHostAgentSupersededIdentityResolvable).
+ if resource.ID != "" {
+ duplicated[strings.ToLower(strings.TrimSpace(resource.ID))] = struct{}{}
}
aliases := make([]string, 0, len(canonical.Aliases))
for _, alias := range canonical.Aliases {
- if _, dup := superseded[strings.ToLower(strings.TrimSpace(alias))]; dup {
+ if _, dup := duplicated[strings.ToLower(strings.TrimSpace(alias))]; dup {
continue
}
aliases = append(aliases, alias)
diff --git a/internal/monitoring/monitor_host_agents_test.go b/internal/monitoring/monitor_host_agents_test.go
index fd5064b20c..c3d486abde 100644
--- a/internal/monitoring/monitor_host_agents_test.go
+++ b/internal/monitoring/monitor_host_agents_test.go
@@ -148,6 +148,11 @@ func TestBroadcastSlimmingKeepsHostAgentSupersededIdentityResolvable(t *testing.
t.Fatalf("aliases = %v, want %q retained", canonical.Aliases, required)
}
}
+ // The row's own wire id is a self-reference every consumer unions
+ // independently; it must not travel inside aliases.
+ if _, ok := aliasSet["agent-core2026"]; ok {
+ t.Fatalf("aliases = %v, must not duplicate the wire id", canonical.Aliases)
+ }
}
func TestHostAgentCorrelationKeepsSameNamedProxmoxProvidersDistinct(t *testing.T) {
diff --git a/internal/monitoring/monitor_unified_state_test.go b/internal/monitoring/monitor_unified_state_test.go
index 0be31b8cc4..9011a8e87d 100644
--- a/internal/monitoring/monitor_unified_state_test.go
+++ b/internal/monitoring/monitor_unified_state_test.go
@@ -1039,7 +1039,8 @@ func TestBroadcastPayloadSlimsStaticMetadata(t *testing.T) {
},
}
- frontend, catalog := convertResourcesForBroadcast(resources)
+ frontend, catalogs := convertResourcesForBroadcast(resources)
+ catalog := catalogs.capabilities
if len(frontend) != 3 {
t.Fatalf("expected 3 frontend resources, got %d", len(frontend))
}
@@ -1066,17 +1067,41 @@ func TestBroadcastPayloadSlimsStaticMetadata(t *testing.T) {
if _, ok := vm["aiSafeSummary"]; ok {
t.Fatalf("default-posture vm must omit aiSafeSummary, got %s", vm["aiSafeSummary"])
}
- // Sensitive storage keeps its governed posture inline.
+ // Sensitive storage keeps its governed posture, deduped through the
+ // policy catalog instead of inline duplication.
storage := byID["storage-1"]
+ if _, ok := storage["policy"]; ok {
+ t.Fatalf("catalog broadcast must not inline non-default policy, got %s", storage["policy"])
+ }
+ var storagePolicyRef string
+ if err := json.Unmarshal(storage["policyRef"], &storagePolicyRef); err != nil || storagePolicyRef == "" {
+ t.Fatalf("sensitive storage must carry policyRef: %v (payload %s)", err, storage["policyRef"])
+ }
+ policyEntry, ok := catalogs.policies[storagePolicyRef]
+ if !ok {
+ t.Fatalf("policy catalog missing ref %q (catalog %v)", storagePolicyRef, catalogs.policies)
+ }
var storagePolicy struct {
Sensitivity string `json:"sensitivity"`
}
- if err := json.Unmarshal(storage["policy"], &storagePolicy); err != nil {
- t.Fatalf("sensitive storage must keep policy inline: %v (payload %s)", err, storage["policy"])
+ if err := json.Unmarshal(policyEntry, &storagePolicy); err != nil {
+ t.Fatalf("decode policy catalog entry: %v", err)
}
if storagePolicy.Sensitivity != "sensitive" {
t.Fatalf("storage sensitivity = %q", storagePolicy.Sensitivity)
}
+ if summaryRefRaw, ok := storage["aiSafeSummaryRef"]; ok {
+ var summaryRef string
+ if err := json.Unmarshal(summaryRefRaw, &summaryRef); err != nil || summaryRef == "" {
+ t.Fatalf("aiSafeSummaryRef must be a non-empty string: %v", err)
+ }
+ if _, ok := catalogs.aiSafeSummaries[summaryRef]; !ok {
+ t.Fatalf("summary catalog missing ref %q", summaryRef)
+ }
+ }
+ if _, ok := storage["aiSafeSummary"]; ok {
+ t.Fatalf("catalog broadcast must not inline aiSafeSummary, got %s", storage["aiSafeSummary"])
+ }
// Superseded ids stay resolvable via supersededIds but are no longer
// duplicated into the alias list.