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.

Fix VMware assistant read-only guidance

rcourtmanc1509103f8a7
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 57b25ac5eb..c0d8420251 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -208,11 +208,14 @@ advertise action metadata that implies a supported VMware admin plane.
That same capability boundary also governs resolved-context enforcement inside
`internal/ai/chat/context_prefetch.go`, `internal/ai/tools/tools_query.go`, and
`internal/ai/tools/tools_control.go`. Once the shared runtime has resolved a
-canonical VMware-backed `vm` or `system-container`, Assistant summaries may not
-emit `pulse_control` guest instructions for it, shared resource registrations
-must stay limited to read-side actions, and any attempted `pulse_control`
-restart/stop/shutdown path must fail as a read-only denial instead of falling
-through to legacy guest resolution or provider-local control assumptions.
+canonical VMware-backed `agent`, `vm`, or `storage`, Assistant summaries may
+not emit `pulse_control` instructions for it. Phase-1 VMware host and
+datastore summaries without discovery must direct `pulse_query` or
+`pulse_read` only, VMware guest summaries must stay explicitly read-only, shared
+resource registrations must stay limited to read-side actions, and any
+attempted `pulse_control` restart/stop/shutdown path must fail as a read-only
+denial instead of falling through to legacy guest resolution or provider-local
+control assumptions.
That same boundary also governs shared Assistant wording in
`internal/ai/chat/service.go` and `internal/ai/tools/tools_control.go`: the
base system prompt and `pulse_control` schema/description must not claim that a
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
index 47f061c50f..45f6d5a542 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
@@ -620,8 +620,27 @@ describe('AIChat', () => {
);
});
- it('preserves canonical VMware vm and storage mention IDs in the shared payload', async () => {
+ it('preserves canonical VMware agent, vm, and storage mention IDs in the shared payload', async () => {
const vmwareResources = [
+ {
+ id: 'vmware-host-1',
+ type: 'agent' as const,
+ name: 'esxi-01.lab.local',
+ displayName: 'ESXi 01',
+ status: 'online',
+ platformType: 'vmware-vsphere',
+ sourceType: 'api',
+ agent: {
+ agentId: 'vc-1:host:host-101',
+ hostname: 'esxi-01.lab.local',
+ platform: 'VMware ESXi',
+ },
+ vmware: {
+ managedObjectId: 'host-101',
+ connectionName: 'Lab VC',
+ entityType: 'host',
+ },
+ },
{
id: 'vmware-vm-1',
type: 'vm' as const,
@@ -655,10 +674,12 @@ describe('AIChat', () => {
];
mockByType.mockImplementation((type: string) => {
switch (type) {
- case 'vm':
+ case 'agent':
return [vmwareResources[0]];
- case 'storage':
+ case 'vm':
return [vmwareResources[1]];
+ case 'storage':
+ return [vmwareResources[2]];
default:
return [];
}
@@ -670,6 +691,36 @@ describe('AIChat', () => {
'Ask about your infrastructure...',
) as HTMLTextAreaElement;
+ Object.defineProperty(textarea, 'selectionStart', { value: 5, writable: true });
+ fireEvent.input(textarea, { target: { value: '@esxi' } });
+
+ await waitFor(() => {
+ expect(screen.getByTestId('mention-autocomplete').getAttribute('data-resource-ids')).toContain(
+ 'agent:vc-1:host:host-101',
+ );
+ });
+
+ fireEvent.click(screen.getByTestId('mention-select-agent:vc-1:host:host-101'));
+ fireEvent.keyDown(textarea, { key: 'Enter' });
+
+ await waitFor(() => {
+ expect(mockChat.sendMessage).toHaveBeenCalledWith(
+ '@ESXi 01',
+ [
+ expect.objectContaining({
+ id: 'agent:vc-1:host:host-101',
+ name: 'ESXi 01',
+ type: 'agent',
+ }),
+ ],
+ undefined,
+ );
+ });
+
+ mockChat.sendMessage.mockClear();
+ await waitFor(() => {
+ expect(textarea.value).toBe('');
+ });
Object.defineProperty(textarea, 'selectionStart', { value: 4, writable: true });
fireEvent.input(textarea, { target: { value: '@app' } });
diff --git a/internal/ai/chat/context_prefetch.go b/internal/ai/chat/context_prefetch.go
index 695646f2b8..898b9dcf68 100644
--- a/internal/ai/chat/context_prefetch.go
+++ b/internal/ai/chat/context_prefetch.go
@@ -72,6 +72,17 @@ func resourceSupportsControl(resourceType string, resource *unifiedresources.Res
return false
}
return resource.Docker != nil || resource.TrueNAS != nil
+ case "agent":
+ return resource != nil && resource.Agent != nil && resource.Agent.CommandsEnabled
+ default:
+ return false
+ }
+}
+
+func resourceRequiresReadOnlyGuidance(resourceType string, supportsControl bool) bool {
+ switch tools.CanonicalDiscoveryResourceType(resourceType) {
+ case "vm", "system-container", "agent", "storage":
+ return !supportsControl
default:
return false
}
@@ -355,6 +366,7 @@ func (p *ContextPrefetcher) extractResourceMentions(message string) []ResourceMe
Policy: policy,
AISafeSummary: aiSafeSummary,
UnifiedResourceID: resolvedUnifiedResourceID(resolved.Resource),
+ SupportsControl: resourceSupportsControl("storage", resolved.Resource),
})
}
}
@@ -416,6 +428,7 @@ func (p *ContextPrefetcher) extractResourceMentions(message string) []ResourceMe
Policy: policy,
AISafeSummary: aiSafeSummary,
UnifiedResourceID: resolvedUnifiedResourceID(resolved.Resource),
+ SupportsControl: resourceSupportsControl("agent", resolved.Resource),
TargetHost: loc.TargetHost,
})
}
@@ -655,6 +668,7 @@ func (p *ContextPrefetcher) resolveStructuredMentions(structured []StructuredMen
Policy: policy,
AISafeSummary: aiSafeSummary,
UnifiedResourceID: resolvedStructuredUnifiedResourceID(sm.ID, resolved.Resource),
+ SupportsControl: resourceSupportsControl("storage", resolved.Resource),
TargetHost: firstNonEmptyTrimmed(loc.TargetHost, targetID),
})
@@ -685,6 +699,7 @@ func (p *ContextPrefetcher) resolveStructuredMentions(structured []StructuredMen
Policy: policy,
AISafeSummary: aiSafeSummary,
UnifiedResourceID: resolvedStructuredUnifiedResourceID(sm.ID, resolved.Resource),
+ SupportsControl: resourceSupportsControl("agent", resolved.Resource),
TargetHost: loc.TargetHost,
})
@@ -1156,10 +1171,8 @@ func (p *ContextPrefetcher) formatContextSummary(mentions []ResourceMention, dis
} else {
// No discovery - provide basic routing without suggesting discovery calls
sb.WriteString(fmt.Sprintf("target_host: \"%s\"\n", mention.Name))
- if (mention.ResourceType == "system-container" || mention.ResourceType == "vm") && !mention.SupportsControl {
+ if resourceRequiresReadOnlyGuidance(mention.ResourceType, mention.SupportsControl) {
sb.WriteString("Use pulse_query or pulse_read only — do NOT call pulse_control or pulse_discovery.\n")
- } else if mention.ResourceType == "system-container" || mention.ResourceType == "vm" {
- sb.WriteString("Proceed directly with pulse_control — do NOT call pulse_discovery.\n")
} else {
sb.WriteString("Proceed directly with pulse_control — do NOT call pulse_discovery.\n")
}
diff --git a/internal/ai/chat/context_prefetch_additional_test.go b/internal/ai/chat/context_prefetch_additional_test.go
index 7f4ace5948..b3aa1d6ba6 100644
--- a/internal/ai/chat/context_prefetch_additional_test.go
+++ b/internal/ai/chat/context_prefetch_additional_test.go
@@ -309,6 +309,12 @@ func TestContextPrefetcher_ResolveStructuredMentions_VMwareCanonicalIDs(t *testi
Status: unifiedresources.StatusOnline,
LastSeen: now,
UpdatedAt: now,
+ Agent: &unifiedresources.AgentData{
+ AgentID: "vc-1:host:host-101",
+ Hostname: "esxi-01.lab.local",
+ Platform: "VMware ESXi",
+ CommandsEnabled: false,
+ },
VMware: &unifiedresources.VMwareData{
ConnectionID: "vc-1",
ConnectionName: "Lab VC",
@@ -363,6 +369,10 @@ func TestContextPrefetcher_ResolveStructuredMentions_VMwareCanonicalIDs(t *testi
if len(vmResources) != 1 {
t.Fatalf("expected one VMware VM resource, got %d", len(vmResources))
}
+ agentResources := rr.ListByType(unifiedresources.ResourceTypeAgent)
+ if len(agentResources) != 1 {
+ t.Fatalf("expected one VMware agent resource, got %d", len(agentResources))
+ }
storageResources := rr.ListByType(unifiedresources.ResourceTypeStorage)
if len(storageResources) != 1 {
t.Fatalf("expected one VMware storage resource, got %d", len(storageResources))
@@ -372,26 +382,36 @@ func TestContextPrefetcher_ResolveStructuredMentions_VMwareCanonicalIDs(t *testi
prefetcher := NewContextPrefetcher(rr, nil)
mentions := prefetcher.resolveStructuredMentions([]StructuredMention{
+ {ID: "agent:vc-1:host:host-101", Name: "ESXi 01", Type: "agent"},
{ID: vmResourceID, Name: "app-01", Type: "vm"},
{ID: storageResourceID, Name: "nvme-primary", Type: "storage"},
})
- if len(mentions) != 2 {
- t.Fatalf("expected two mentions, got %#v", mentions)
+ if len(mentions) != 3 {
+ t.Fatalf("expected three mentions, got %#v", mentions)
}
- if mentions[0].ResourceType != "vm" || mentions[0].ResourceID != "vm-201" || mentions[0].TargetID != "esxi-01.lab.local" {
- t.Fatalf("expected VMware VM routing coordinates, got %+v", mentions[0])
+ if mentions[0].ResourceType != "agent" || mentions[0].ResourceID != "vc-1:host:host-101" || mentions[0].TargetID != "vc-1:host:host-101" {
+ t.Fatalf("expected VMware host routing coordinates, got %+v", mentions[0])
}
if mentions[0].SupportsControl {
- t.Fatalf("expected VMware VM mention to stay read-only, got %+v", mentions[0])
+ t.Fatalf("expected VMware host mention to stay read-only, got %+v", mentions[0])
+ }
+ if mentions[0].UnifiedResourceID != "agent:vc-1:host:host-101" {
+ t.Fatalf("expected VMware host unified resource id, got %+v", mentions[0])
}
- if mentions[0].UnifiedResourceID != vmResourceID {
- t.Fatalf("expected VMware VM unified resource id, got %+v", mentions[0])
+ if mentions[1].ResourceType != "vm" || mentions[1].ResourceID != "vm-201" || mentions[1].TargetID != "esxi-01.lab.local" {
+ t.Fatalf("expected VMware VM routing coordinates, got %+v", mentions[1])
}
- if mentions[1].ResourceType != "storage" || mentions[1].ResourceID != storageResourceID || mentions[1].TargetID != "Lab VC" {
- t.Fatalf("expected VMware datastore shared coordinates, got %+v", mentions[1])
+ if mentions[1].SupportsControl {
+ t.Fatalf("expected VMware VM mention to stay read-only, got %+v", mentions[1])
}
- if mentions[1].UnifiedResourceID != storageResourceID {
- t.Fatalf("expected VMware datastore unified resource id, got %+v", mentions[1])
+ if mentions[1].UnifiedResourceID != vmResourceID {
+ t.Fatalf("expected VMware VM unified resource id, got %+v", mentions[1])
+ }
+ if mentions[2].ResourceType != "storage" || mentions[2].ResourceID != storageResourceID || mentions[2].TargetID != "Lab VC" {
+ t.Fatalf("expected VMware datastore shared coordinates, got %+v", mentions[2])
+ }
+ if mentions[2].UnifiedResourceID != storageResourceID {
+ t.Fatalf("expected VMware datastore unified resource id, got %+v", mentions[2])
}
}
@@ -540,6 +560,36 @@ func TestContextPrefetcher_FormatContextSummary_VMwareGuestStaysReadOnly(t *test
}
}
+func TestContextPrefetcher_FormatContextSummary_VMwareHostAndStorageStayReadOnly(t *testing.T) {
+ prefetcher := NewContextPrefetcher(newTestReadState(models.StateSnapshot{}), nil)
+
+ summary := prefetcher.formatContextSummary([]ResourceMention{
+ {
+ Name: "esxi-01.lab.local",
+ ResourceType: "agent",
+ ResourceID: "vc-1:host:host-101",
+ TargetID: "vc-1:host:host-101",
+ UnifiedResourceID: "vmware-host-1",
+ SupportsControl: false,
+ },
+ {
+ Name: "nvme-primary",
+ ResourceType: "storage",
+ ResourceID: "vmware-datastore-1",
+ TargetID: "Lab VC",
+ UnifiedResourceID: "vmware-datastore-1",
+ SupportsControl: false,
+ },
+ }, nil)
+
+ if strings.Contains(summary, "Proceed directly with pulse_control") {
+ t.Fatalf("expected VMware host and datastore summary to avoid control instructions, got %q", summary)
+ }
+ if got := strings.Count(summary, "Use pulse_query or pulse_read only"); got != 2 {
+ t.Fatalf("expected read-only guidance for VMware host and datastore, got count=%d summary=%q", got, summary)
+ }
+}
+
func TestContextPrefetcher_ExtractHelpers(t *testing.T) {
words := extractWords("hello-123 world")
if len(words) != 3 {
diff --git a/tests/integration/tests/38-vmware-ai-chat-mentions.spec.ts b/tests/integration/tests/38-vmware-ai-chat-mentions.spec.ts
index 9cc889610b..32a87c2a7f 100644
--- a/tests/integration/tests/38-vmware-ai-chat-mentions.spec.ts
+++ b/tests/integration/tests/38-vmware-ai-chat-mentions.spec.ts
@@ -220,9 +220,19 @@ test.describe('VMware AI chat mentions', () => {
const textarea = page.getByPlaceholder('Ask about your infrastructure...');
await textarea.click();
- await textarea.pressSequentially('@app');
+ await textarea.pressSequentially('@esxi');
const mentionSurface = page.locator('[data-mention-autocomplete]');
+ const hostOption = mentionSurface.getByRole('button', { name: /ESXi 01 agent/ }).first();
+ await expect(mentionSurface.getByText('Resources')).toBeVisible();
+ await expect(hostOption).toBeVisible();
+ await expect(mentionSurface).toContainText('agent');
+ await hostOption.click();
+ await expect(textarea).toHaveValue('@ESXi 01 ');
+
+ await textarea.fill('');
+ await textarea.pressSequentially('@app');
+
await expect(mentionSurface.getByText('Resources')).toBeVisible();
await expect(mentionSurface.getByRole('button', { name: /App 01/ })).toBeVisible();
await expect(mentionSurface).toContainText('vm');