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.

Keep integration-monitored machines out of Agent Doctor and surface workload-only agents

rcourtman7354d8d19fcf
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 8370b01303..d7b46eb662 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -1955,6 +1955,25 @@ Agent` secondary handoff against the live setup wizard instead of relying
## Current State
+### Agent Doctor covers exactly the Pulse Agent fleet
+
+Agent Doctor target collection
+(`collectInfrastructureAgentDoctorTargets`) excludes ledger agent connections
+that carry `integrationSource` — integration-monitored machines (vSphere ESXi
+hosts, TrueNAS boxes) have no Pulse Agent to diagnose and previously rendered
+as permanent "Unknown / no structured reason" rows. In the other direction,
+structured fleet diagnostics that have no ledger binding (agents reporting
+only workload telemetry, e.g. Docker-only or Kubernetes-only agents) are now
+appended as diagnostics-only targets, honoring the scoped-agent filter, so a
+critical workload-only agent can no longer vanish from the fleet view.
+Diagnostics-only rows render the diagnostic's status, reasons, and evidence
+but offer no host-local command (there is no ledger connection to derive one
+from). Dialog presentation follows the same honesty rule: the
+"Supported target" cell renders only when a target version is actually
+published, the host-local command explainer renders only when at least one
+row offers a command, and the summary strip lists only non-zero status
+counts.
+
### Governed action readiness remains outside agent lifecycle authority
The canonical Actions lifecycle may ask an executor-owned
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 4a17fd301e..b1fd91f43e 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -3500,6 +3500,20 @@ returning prompts, tool transcripts, credentials, or infrastructure data.
## Current State
+### Connections ledger declares integration-monitored machines
+
+Agent-type rows in `GET /api/connections` carry an optional
+`integrationSource` string ("vmware", "truenas", ...) when the underlying
+unified host resource has no `SourceAgent` ingest — i.e. the machine's
+telemetry comes from a platform integration, not a Pulse Agent. The field is
+omitted (never empty-string) for real Pulse Agents, so existing agent payload
+shapes are unchanged. Agent-only client workflows (Agent Doctor target
+collection, host-local update commands) must skip rows with a value; ledger
+membership itself is unchanged so machine surfaces keep rendering these rows.
+Update readiness follows the same rule: the `agent-continuity`,
+`agent-migration-security`, and agent-token checks count only
+non-integration-backed hosts as registered agents.
+
### Action execution revalidates live readiness
`POST /api/actions/{actionId}/execute` routes through the transport-independent
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 2e4773b620..85ca5943d4 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -517,6 +517,23 @@ resource health.
## Current State
+### Host snapshots carry integration provenance; doctor copy is user-facing
+
+`models.Host.IntegrationSource` mirrors the unified fabric's
+`HostView.IntegrationSource()` discriminator on hosts produced by
+`hostFromReadStateView` (the source behind `Monitor.HostsSnapshot()`); hosts
+built from agent reports leave it empty by construction, so state-side host
+records never claim integration provenance. Agent fleet doctor reason
+messages are user-facing copy: stale detection now reads "No report has
+arrived for 10m 2s. Pulse marks an agent stale after 5m without a report."
+with durations humanized by `formatFleetDuration` ("45s", "5m", "10m 2s",
+"1h 3m", "2d 4h") instead of Go's `5m0s` form, and the non-online status
+reason quotes the reported status without leaking the internal
+online/running/healthy vocabulary. The diagnostics subject set is unchanged:
+`GetAgentFleetDiagnosticsForTarget` still derives subjects from the state
+snapshot (real agents), which now matches what agent-only surfaces show once
+integration-backed ledger rows are excluded.
+
Unified Agent host reports now make module readiness and updater/config
lifecycle evidence monitoring-owned observed state. Monitoring preserves the
last successful one-shot update transition across subsequent reports, forwards
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 386d85e4f3..d946aa3fca 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -1838,6 +1838,18 @@ that Safe auto-fix or Autopilot remediation is verified.
## Current State
+### Connection integration provenance is telemetry-only evidence
+
+The connections ledger's `integrationSource` field (set on agent-type rows
+whose host telemetry comes from a platform integration such as vSphere or
+TrueNAS rather than a Pulse Agent) is host-telemetry provenance only. Storage
+and recovery surfaces must not read it as evidence about backup coverage,
+protection posture, restore chains, or recoverability, and the update
+readiness change that excludes integration-backed machines from
+registered-agent counts does not alter any Recovery Assurance domain:
+recovery evidence still comes exclusively from its own deterministic
+verification paths.
+
### Recovery actions retain execution-time readiness checks
Recovery-oriented capabilities admitted to canonical Actions are subject to
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 59d74bce9d..01b6adb4cc 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -1538,6 +1538,23 @@ AI-only summary payloads, or page-local heuristics.
## Current State
+### Host views expose the integration-source discriminator
+
+`HostView.IntegrationSource()` names the platform integration ("vmware",
+"truenas", ...) that supplies a host resource's telemetry when the resource
+has never ingested under `SourceAgent`; it returns empty for Pulse-Agent-backed
+hosts. The check is deliberately source-set-based: integration providers
+(vSphere, TrueNAS) fabricate an `Agent` payload so machine surfaces can render
+host facts, so `Resource.Agent != nil` is not evidence of a real Pulse Agent —
+only `Sources` containing `SourceAgent` is. When multiple non-agent sources
+contribute, the accessor prefers vmware, then truenas, then the remaining
+platform sources in a fixed order, and falls back to the generic marker
+`"integration"` for a sourceless non-agent resource. Downstream fleet
+consumers (`hostFromReadStateView` → `models.Host.IntegrationSource` → the
+connections ledger's `integrationSource`) use this to keep
+integration-monitored machines out of agent-only workflows without changing
+fabric membership.
+
### Governed action live-readiness refusal
The unified action model owns `ErrActionExecutionUnavailable` as a permanent
diff --git a/frontend-modern/src/api/__tests__/connections.test.ts b/frontend-modern/src/api/__tests__/connections.test.ts
index 46eff9b320..a34bf34a38 100644
--- a/frontend-modern/src/api/__tests__/connections.test.ts
+++ b/frontend-modern/src/api/__tests__/connections.test.ts
@@ -104,6 +104,32 @@ describe('ConnectionsAPI', () => {
});
});
+ it('list() preserves integration provenance on integration-monitored machine rows', async () => {
+ const connections: Connection[] = [
+ {
+ id: 'agent:vc-1:host:host-101',
+ type: 'agent',
+ name: 'esxi-01.lab.local',
+ address: 'esxi-01.lab.local',
+ state: 'active',
+ stateReason: '',
+ enabled: true,
+ surfaces: ['host'],
+ scope: { host: true },
+ lastSeen: '2026-07-21T12:00:00Z',
+ lastError: null,
+ source: 'agent',
+ integrationSource: 'vmware',
+ capabilities: { supportsPause: false, supportsScope: false, supportsTest: false },
+ },
+ ];
+ mockedApiFetchJSON.mockResolvedValueOnce({ connections });
+
+ const result = await ConnectionsAPI.list();
+
+ expect(result.connections[0].integrationSource).toBe('vmware');
+ });
+
it('list() preserves fleet governance metadata on connection rows', async () => {
const connections: Connection[] = [
{
diff --git a/frontend-modern/src/api/connections.ts b/frontend-modern/src/api/connections.ts
index ff69fa819c..49fc40bb20 100644
--- a/frontend-modern/src/api/connections.ts
+++ b/frontend-modern/src/api/connections.ts
@@ -150,6 +150,12 @@ export interface Connection {
agentIdentity?: ConnectionAgentIdentity;
agentVersion?: string;
expectedAgentVersion?: string;
+ /**
+ * Platform integration ("vmware", "truenas", ...) that supplies this host's
+ * telemetry when no Pulse Agent reports for it. Empty/absent means the row
+ * is backed by a real Pulse Agent; agent-only workflows skip rows with a value.
+ */
+ integrationSource?: string;
agentUpdateAvailable?: boolean;
agentUpdate?: ConnectionAgentUpdateStatus;
agentModules?: ConnectionAgentModuleStatus[];
diff --git a/frontend-modern/src/components/Settings/InfrastructureAgentUpdatesDialog.tsx b/frontend-modern/src/components/Settings/InfrastructureAgentUpdatesDialog.tsx
index ade9f7ada9..36b13acab2 100644
--- a/frontend-modern/src/components/Settings/InfrastructureAgentUpdatesDialog.tsx
+++ b/frontend-modern/src/components/Settings/InfrastructureAgentUpdatesDialog.tsx
@@ -66,6 +66,19 @@ export const InfrastructureAgentUpdatesDialog: Component<InfrastructureAgentUpda
) => {
const operations = useInfrastructureOperationsContext();
const summary = createMemo(() => summarizeInfrastructureAgentDoctorTargets(props.targets));
+ const anyTargetNeedsUpdate = createMemo(() => props.targets.some((target) => target.needsUpdate));
+ const summaryChips = createMemo(() => {
+ const counts = summary();
+ const order: { status: InfrastructureAgentDoctorStatus; count: number }[] = [
+ { status: 'critical', count: counts.critical },
+ { status: 'warning', count: counts.warning },
+ { status: 'waiting', count: counts.waiting },
+ { status: 'unknown', count: counts.unknown },
+ { status: 'removed', count: counts.removed },
+ { status: 'healthy', count: counts.healthy },
+ ];
+ return order.filter((entry) => entry.count > 0);
+ });
const commandTargets = createMemo(() =>
props.targets.filter(
(target) =>
@@ -165,23 +178,26 @@ export const InfrastructureAgentUpdatesDialog: Component<InfrastructureAgentUpda
</Show>
}
>
- <section
- aria-label="Agent Doctor summary"
- class="grid grid-cols-2 gap-2 sm:grid-cols-6"
- >
- <SummaryItem label="Critical" value={summary().critical} tone="critical" />
- <SummaryItem label="Attention" value={summary().warning} tone="warning" />
- <SummaryItem label="Waiting" value={summary().waiting} />
- <SummaryItem label="Healthy" value={summary().healthy} tone="healthy" />
- <SummaryItem label="Unknown" value={summary().unknown} />
- <SummaryItem label="Removed" value={summary().removed} />
+ <section aria-label="Agent Doctor summary" class="flex flex-wrap items-center gap-2">
+ <For each={summaryChips()}>
+ {(chip) => (
+ <span
+ class={`inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium ${STATUS_PRESENTATION[chip.status].badgeClass}`}
+ >
+ <span class="font-semibold">{chip.count}</span>
+ {STATUS_PRESENTATION[chip.status].label}
+ </span>
+ )}
+ </For>
</section>
- <div class="rounded-md border border-blue-200 bg-blue-50 px-4 py-3 text-xs leading-5 text-blue-900 dark:border-blue-800 dark:bg-blue-950/30 dark:text-blue-100">
- Update commands are host-local: copy one to the affected machine to update its Pulse
- Agent from this server. They do not update the Pulse server runtime and Pulse does not
- run them remotely.
- </div>
+ <Show when={anyTargetNeedsUpdate()}>
+ <div class="rounded-md border border-blue-200 bg-blue-50 px-4 py-3 text-xs leading-5 text-blue-900 dark:border-blue-800 dark:bg-blue-950/30 dark:text-blue-100">
+ Update commands are host-local: copy one to the affected machine to update its Pulse
+ Agent from this server. They do not update the Pulse server runtime and Pulse does
+ not run them remotely.
+ </div>
+ </Show>
<Show
when={
@@ -288,14 +304,12 @@ export const InfrastructureAgentUpdatesDialog: Component<InfrastructureAgentUpda
<Show when={target.currentVersion || target.expectedVersion}>
<div class="grid gap-2 text-xs sm:grid-cols-2">
- <Detail
- label="Reported agent"
- value={target.currentVersion || 'Unknown'}
- />
- <Detail
- label="Supported target"
- value={target.expectedVersion || 'Unknown'}
- />
+ <Show when={target.currentVersion}>
+ <Detail label="Reported agent" value={target.currentVersion!} />
+ </Show>
+ <Show when={target.expectedVersion}>
+ <Detail label="Supported target" value={target.expectedVersion!} />
+ </Show>
</div>
</Show>
@@ -318,7 +332,7 @@ export const InfrastructureAgentUpdatesDialog: Component<InfrastructureAgentUpda
<p class="text-xs text-muted">
{target.status === 'healthy'
? 'No fleet-health issues detected.'
- : 'No structured reason is available for this connection yet.'}
+ : 'Pulse has not received a structured diagnostic for this agent yet. This usually clears after its next report.'}
</p>
}
>
@@ -407,26 +421,6 @@ export const InfrastructureAgentUpdatesDialog: Component<InfrastructureAgentUpda
);
};
-const SummaryItem: Component<{
- label: string;
- value: number;
- tone?: 'critical' | 'warning' | 'healthy';
-}> = (props) => {
- const toneClass = () => {
- if (props.tone === 'critical' && props.value > 0) return 'text-rose-700 dark:text-rose-300';
- if (props.tone === 'warning' && props.value > 0) return 'text-amber-700 dark:text-amber-300';
- if (props.tone === 'healthy' && props.value > 0)
- return 'text-emerald-700 dark:text-emerald-300';
- return 'text-base-content';
- };
- return (
- <div class="rounded-md border border-border bg-surface-alt px-3 py-2">
- <div class={`text-lg font-semibold ${toneClass()}`}>{props.value}</div>
- <div class="text-[11px] text-muted">{props.label}</div>
- </div>
- );
-};
-
const Detail: Component<{ label: string; value: string }> = (props) => (
<div class="rounded-md border border-border-subtle bg-surface-alt px-3 py-2">
<div class="text-[11px] text-muted">{props.label}</div>
diff --git a/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx b/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx
index fa9a89017c..7cd74c7fd7 100644
--- a/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx
@@ -490,8 +490,9 @@ describe('InfrastructureWorkspace', () => {
const dialog = await screen.findByRole('dialog');
expect(within(dialog).getByText('zeus')).toBeInTheDocument();
- expect(within(dialog).getByText('Supported target')).toBeInTheDocument();
- expect(within(dialog).getAllByText('Unknown').length).toBeGreaterThan(0);
+ expect(within(dialog).getByText('Reported agent')).toBeInTheDocument();
+ // With no published target there is no "Supported target" cell to guess at.
+ expect(within(dialog).queryByText('Supported target')).not.toBeInTheDocument();
expect(within(dialog).queryByText(/upgrade agent:agent-zeus/)).not.toBeInTheDocument();
});
diff --git a/frontend-modern/src/components/Settings/__tests__/infrastructureAgentDoctorModel.test.ts b/frontend-modern/src/components/Settings/__tests__/infrastructureAgentDoctorModel.test.ts
index e72ec9a1a9..29cafd40c3 100644
--- a/frontend-modern/src/components/Settings/__tests__/infrastructureAgentDoctorModel.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/infrastructureAgentDoctorModel.test.ts
@@ -276,6 +276,81 @@ describe('Agent Doctor model', () => {
).not.toContain('removed');
});
+ it('keeps integration-monitored machines out of the doctor', () => {
+ const agent = connectionFixture({ agentUpdateAvailable: false });
+ const esxi = connectionFixture({
+ id: 'agent:vc-1:host:host-101',
+ name: 'esxi-01.lab.local',
+ agentVersion: undefined,
+ expectedAgentVersion: undefined,
+ agentUpdateAvailable: false,
+ integrationSource: 'vmware',
+ agentIdentity: { hostname: 'esxi-01.lab.local', platform: 'vmware-vsphere' },
+ fleet: {} as Connection['fleet'],
+ });
+
+ const targets = collectInfrastructureAgentDoctorTargets({
+ rows: [rowFixture(agent), rowFixture(esxi)],
+ connections: [agent, esxi],
+ diagnostics: [diagnosticFixture()],
+ diagnosticsAvailable: true,
+ targetVersion: '6.2.0',
+ });
+
+ expect(targets.map((target) => target.connectionId)).toEqual(['agent:host-1']);
+ });
+
+ it('surfaces diagnostics-only agents the ledger does not carry', () => {
+ const connection = connectionFixture({ agentUpdateAvailable: false });
+ const dockerOnly = diagnosticFixture({
+ connectionId: 'agent:docker-edge-1',
+ rowKey: 'agent-docker-edge-1',
+ id: 'docker-edge-1',
+ agentId: 'docker-edge-1',
+ name: 'Edge Apps 01',
+ hostname: 'edge-apps-01',
+ types: ['docker'],
+ status: 'critical',
+ profileId: undefined,
+ profileName: undefined,
+ profileVersion: undefined,
+ deployedProfileVersion: undefined,
+ reasons: [
+ {
+ code: 'agent_module_failed',
+ severity: 'critical',
+ message: 'Enabled agent module "docker" failed.',
+ },
+ ],
+ repairActions: [],
+ });
+ const base = {
+ rows: [rowFixture(connection)],
+ connections: [connection],
+ diagnostics: [dockerOnly],
+ diagnosticsAvailable: true,
+ targetVersion: '6.2.0',
+ };
+
+ const targets = collectInfrastructureAgentDoctorTargets(base);
+ const surfaced = targets.find((target) => target.connectionId === 'agent:docker-edge-1');
+ expect(surfaced).toMatchObject({
+ status: 'critical',
+ source: 'diagnostics',
+ needsUpdate: false,
+ commandPlatform: null,
+ });
+ expect(surfaced?.reasons[0]?.code).toBe('agent_module_failed');
+
+ // Scoping still applies to diagnostics-only rows.
+ expect(
+ collectInfrastructureAgentDoctorTargets({
+ ...base,
+ scopedAgentIds: ['agent:host-1'],
+ }).map((target) => target.connectionId),
+ ).toEqual(['agent:host-1']);
+ });
+
it('canonicalizes compatibility diagnostics that predate connectionId', () => {
expect(
diagnosticConnectionID(
diff --git a/frontend-modern/src/components/Settings/__tests__/infrastructureAgentUpdateCommandsModel.branchcov0720pm.test.ts b/frontend-modern/src/components/Settings/__tests__/infrastructureAgentUpdateCommandsModel.branchcov0720pm.test.ts
index 8df506121f..c0b2bcc436 100644
--- a/frontend-modern/src/components/Settings/__tests__/infrastructureAgentUpdateCommandsModel.branchcov0720pm.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/infrastructureAgentUpdateCommandsModel.branchcov0720pm.test.ts
@@ -537,13 +537,15 @@ describe('collectInfrastructureAgentDoctorTargets (removed records)', () => {
expect(nothing.find((target) => target.status === 'removed')?.displayName).toBe('only-id');
});
- it('derives contextLabel from types joined by " + ", falling back to "Removed agent"', () => {
+ it('derives contextLabel from labelled types joined by " + ", falling back to "Removed agent"', () => {
const live = agentConnection({ agentUpdateAvailable: false });
const typed = runDoctor([live], {
diagnostics: [removedDiag({ types: ['host', 'docker'] })],
diagnosticsAvailable: true,
});
- expect(typed.find((target) => target.status === 'removed')?.contextLabel).toBe('host + docker');
+ expect(typed.find((target) => target.status === 'removed')?.contextLabel).toBe(
+ 'Host + Docker agent',
+ );
const untyped = runDoctor([live], {
diagnostics: [removedDiag({ types: [] })],
diff --git a/frontend-modern/src/components/Settings/infrastructureAgentUpdateCommandsModel.ts b/frontend-modern/src/components/Settings/infrastructureAgentUpdateCommandsModel.ts
index 9df3537291..e4531e6ceb 100644
--- a/frontend-modern/src/components/Settings/infrastructureAgentUpdateCommandsModel.ts
+++ b/frontend-modern/src/components/Settings/infrastructureAgentUpdateCommandsModel.ts
@@ -247,6 +247,10 @@ const collectAgentConnectionBindings = (
const bindings = new Map<string, AgentConnectionBinding>();
const add = (row: InfrastructureSystemRow | undefined, connection?: Connection) => {
if (!connection || connection.type !== 'agent' || bindings.has(connection.id)) return;
+ // Machines whose telemetry comes from a platform integration (vSphere,
+ // TrueNAS, ...) have no Pulse Agent to diagnose; keep them out of the
+ // doctor instead of rendering permanent "Unknown" rows.
+ if (connection.integrationSource) return;
bindings.set(connection.id, {
connection,
displayName: connectionDisplayName(connection),
@@ -550,28 +554,60 @@ const doctorTargetFromBinding = (
};
};
-const removedDoctorTarget = (
+const DIAGNOSTIC_ONLY_STATUSES = new Set<InfrastructureAgentDoctorStatus>([
+ 'healthy',
+ 'warning',
+ 'critical',
+ 'removed',
+]);
+
+const diagnosticDoctorStatus = (
diagnostic: AgentFleetAgentDiagnostic,
-): InfrastructureAgentDoctorTarget => ({
- key: `removed:${diagnostic.rowKey || diagnostic.id}`,
- connectionId: diagnosticConnectionID(diagnostic),
- diagnostic,
- displayName: diagnostic.name || diagnostic.hostname || diagnostic.id,
- contextLabel: diagnostic.types?.join(' + ') || 'Removed agent',
- currentVersion: diagnostic.version?.trim() || undefined,
- installFlags: [],
- status: 'removed',
- reasons: diagnostic.reasons ?? [],
- evidence: evidenceFor(undefined, diagnostic),
- needsUpdate: false,
- commandPlatform: null,
- profileLabel: diagnostic.profileName?.trim() || diagnostic.profileId?.trim() || undefined,
- profileVersionLabel: diagnostic.profileVersion
- ? `Expected v${diagnostic.profileVersion} · deployed v${diagnostic.deployedProfileVersion || 0}`
- : undefined,
- lastSeen: diagnostic.lastSeen,
- source: 'removed',
-});
+): InfrastructureAgentDoctorStatus =>
+ DIAGNOSTIC_ONLY_STATUSES.has(diagnostic.status as InfrastructureAgentDoctorStatus)
+ ? (diagnostic.status as InfrastructureAgentDoctorStatus)
+ : 'unknown';
+
+const DIAGNOSTIC_TYPE_LABELS: Record<string, string> = {
+ host: 'Host',
+ docker: 'Docker',
+ kubernetes: 'Kubernetes',
+};
+
+const diagnosticContextLabel = (
+ diagnostic: AgentFleetAgentDiagnostic,
+ removed: boolean,
+): string => {
+ const labels = (diagnostic.types ?? []).map((type) => DIAGNOSTIC_TYPE_LABELS[type] ?? type);
+ if (labels.length === 0) return removed ? 'Removed agent' : 'Agent';
+ return `${labels.join(' + ')} agent`;
+};
+
+const diagnosticOnlyDoctorTarget = (
+ diagnostic: AgentFleetAgentDiagnostic,
+): InfrastructureAgentDoctorTarget => {
+ const removed = diagnostic.status === 'removed';
+ return {
+ key: `${removed ? 'removed' : 'diagnostic'}:${diagnostic.rowKey || diagnostic.id}`,
+ connectionId: diagnosticConnectionID(diagnostic),
+ diagnostic,
+ displayName: diagnostic.name || diagnostic.hostname || diagnostic.id,
+ contextLabel: diagnosticContextLabel(diagnostic, removed),
+ currentVersion: diagnostic.version?.trim() || undefined,
+ installFlags: [],
+ status: removed ? 'removed' : diagnosticDoctorStatus(diagnostic),
+ reasons: diagnostic.reasons ?? [],
+ evidence: evidenceFor(undefined, diagnostic),
+ needsUpdate: false,
+ commandPlatform: null,
+ profileLabel: diagnostic.profileName?.trim() || diagnostic.profileId?.trim() || undefined,
+ profileVersionLabel: diagnostic.profileVersion
+ ? `Expected v${diagnostic.profileVersion} · deployed v${diagnostic.deployedProfileVersion || 0}`
+ : undefined,
+ lastSeen: diagnostic.lastSeen,
+ source: removed ? 'removed' : 'diagnostics',
+ };
+};
const DOCTOR_STATUS_RANK: Record<InfrastructureAgentDoctorStatus, number> = {
critical: 6,
@@ -613,9 +649,19 @@ export const collectInfrastructureAgentDoctorTargets = ({
),
);
- if (diagnosticsAvailable && scoped.size === 0) {
+ if (diagnosticsAvailable) {
+ // The ledger can miss agents that report only workload telemetry (for
+ // example Docker-only or Kubernetes-only agents). The fleet diagnostics
+ // endpoint still knows them, so surface every diagnostic that found no
+ // ledger binding instead of silently dropping it.
for (const diagnostic of diagnostics) {
- if (diagnostic.status === 'removed') targets.push(removedDoctorTarget(diagnostic));
+ if (diagnostic.status === 'removed') {
+ if (scoped.size === 0) targets.push(diagnosticOnlyDoctorTarget(diagnostic));
+ continue;
+ }
+ const connectionId = diagnosticConnectionID(diagnostic);
+ if (bindings.has(connectionId) || !inScope(connectionId)) continue;
+ targets.push(diagnosticOnlyDoctorTarget(diagnostic));
}
}
diff --git a/internal/api/connections_aggregator.go b/internal/api/connections_aggregator.go
index 1b30bfc809..7dfc62ac0a 100644
--- a/internal/api/connections_aggregator.go
+++ b/internal/api/connections_aggregator.go
@@ -531,6 +531,7 @@ func buildAgentConnection(host models.Host, expectedAgentVersion string, now tim
AgentIdentity: agentIdentity,
AgentVersion: currentAgentVersion,
ExpectedAgentVersion: expectedAgentVersion,
+ IntegrationSource: strings.TrimSpace(host.IntegrationSource),
AgentUpdateAvailable: updateAvailable,
AgentUpdate: connectionAgentUpdateStatus(host.AgentUpdate),
AgentModules: connectionAgentModuleStatuses(host.AgentModules),
diff --git a/internal/api/connections_types.go b/internal/api/connections_types.go
index a46ca2e44d..db66578527 100644
--- a/internal/api/connections_types.go
+++ b/internal/api/connections_types.go
@@ -155,22 +155,27 @@ type ConnectionAgentIdentity struct {
// per-type shapes that today require separate fetches and separate table
// renderers.
type Connection struct {
- ID string `json:"id"`
- Type ConnectionType `json:"type"`
- Name string `json:"name"`
- Address string `json:"address"`
- HostAliases []string `json:"hostAliases,omitempty"`
- State ConnectionState `json:"state"`
- StateReason string `json:"stateReason,omitempty"`
- Enabled bool `json:"enabled"`
- Surfaces []string `json:"surfaces"`
- Scope map[string]bool `json:"scope"`
- LastSeen *time.Time `json:"lastSeen,omitempty"`
- LastError *ConnectionError `json:"lastError,omitempty"`
- Source ConnectionSource `json:"source"`
- AgentIdentity *ConnectionAgentIdentity `json:"agentIdentity,omitempty"`
- AgentVersion string `json:"agentVersion,omitempty"`
- ExpectedAgentVersion string `json:"expectedAgentVersion,omitempty"`
+ ID string `json:"id"`
+ Type ConnectionType `json:"type"`
+ Name string `json:"name"`
+ Address string `json:"address"`
+ HostAliases []string `json:"hostAliases,omitempty"`
+ State ConnectionState `json:"state"`
+ StateReason string `json:"stateReason,omitempty"`
+ Enabled bool `json:"enabled"`
+ Surfaces []string `json:"surfaces"`
+ Scope map[string]bool `json:"scope"`
+ LastSeen *time.Time `json:"lastSeen,omitempty"`
+ LastError *ConnectionError `json:"lastError,omitempty"`
+ Source ConnectionSource `json:"source"`
+ AgentIdentity *ConnectionAgentIdentity `json:"agentIdentity,omitempty"`
+ AgentVersion string `json:"agentVersion,omitempty"`
+ ExpectedAgentVersion string `json:"expectedAgentVersion,omitempty"`
+ // IntegrationSource names the platform integration ("vmware", "truenas", ...)
+ // that supplies this host's telemetry when no Pulse Agent reports for it.
+ // Empty means the row is backed by a real Pulse Agent. Agent-only workflows
+ // (Agent Doctor, update commands) skip rows with a non-empty value.
+ IntegrationSource string `json:"integrationSource,omitempty"`
AgentUpdateAvailable bool `json:"agentUpdateAvailable,omitempty"`
AgentUpdate *ConnectionAgentUpdateStatus `json:"agentUpdate,omitempty"`
AgentModules []ConnectionAgentModuleStatus `json:"agentModules,omitempty"`
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index de698ff5b7..cafc31635b 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -15459,6 +15459,50 @@ func TestContract_AgentConnectionPayloadIncludesVersionFields(t *testing.T) {
assertJSONSnapshot(t, body, want)
}
+// integrationSource marks ledger agent rows whose telemetry comes from a
+// platform integration rather than a Pulse Agent. It must serialize when set
+// and stay entirely absent for real agents so existing payloads keep shape.
+func TestContract_AgentConnectionPayloadDeclaresIntegrationSource(t *testing.T) {
+ host := models.Host{
+ ID: "vc-1:host:host-101",
+ Hostname: "esxi-01.lab.local",
+ Platform: "vmware-vsphere",
+ Status: "online",
+ LastSeen: time.Date(2026, 7, 21, 12, 0, 0, 0, time.UTC),
+ IntervalSeconds: 60,
+ IntegrationSource: "vmware",
+ }
+ conn := buildAgentConnection(host, "6.1.0", host.LastSeen.Add(30*time.Second), nil)
+ if conn.IntegrationSource != "vmware" {
+ t.Fatalf("expected integration source %q on connection, got %q", "vmware", conn.IntegrationSource)
+ }
+ body, err := json.Marshal(conn)
+ if err != nil {
+ t.Fatalf("marshal integration-backed agent Connection: %v", err)
+ }
+ if !strings.Contains(string(body), `"integrationSource":"vmware"`) {
+ t.Fatalf("expected integrationSource in payload, got %s", body)
+ }
+
+ agentHost := models.Host{
+ ID: "host-linux-1",
+ Hostname: "apollo-114",
+ Platform: "linux",
+ Status: "online",
+ AgentVersion: "6.1.0",
+ LastSeen: time.Date(2026, 7, 21, 12, 0, 0, 0, time.UTC),
+ IntervalSeconds: 60,
+ }
+ agentConn := buildAgentConnection(agentHost, "6.1.0", agentHost.LastSeen.Add(30*time.Second), nil)
+ agentBody, err := json.Marshal(agentConn)
+ if err != nil {
+ t.Fatalf("marshal agent-backed Connection: %v", err)
+ }
+ if strings.Contains(string(agentBody), "integrationSource") {
+ t.Fatalf("expected integrationSource omitted for Pulse-Agent rows, got %s", agentBody)
+ }
+}
+
func TestContract_AgentDefaultDesiredConfigDoesNotCreateRolloutAttention(t *testing.T) {
now := time.Date(2026, 5, 14, 10, 30, 0, 0, time.UTC)
connections := buildConnections(aggregatorInputs{
diff --git a/internal/api/update_readiness.go b/internal/api/update_readiness.go
index 1e173b54da..694b2c5afb 100644
--- a/internal/api/update_readiness.go
+++ b/internal/api/update_readiness.go
@@ -48,11 +48,12 @@ func buildUpdateReadiness(in updateReadinessInputs) *updates.UpdateReadiness {
now = time.Now()
}
+ agentHosts := agentBackedHosts(in.hosts)
checks := []updates.UpdateReadinessCheck{
buildUpdatePathReadinessCheck(in.plan),
- buildAgentContinuityReadinessCheck(in.hosts, in.targetVersion, now),
- buildAgentMigrationSecurityReadinessCheck(in.hosts),
- buildAgentTokenReadinessCheck(in.cfg, len(in.hosts), now),
+ buildAgentContinuityReadinessCheck(agentHosts, in.targetVersion, now),
+ buildAgentMigrationSecurityReadinessCheck(agentHosts),
+ buildAgentTokenReadinessCheck(in.cfg, len(agentHosts), now),
}
status := updateReadinessReady
@@ -129,6 +130,20 @@ func buildUpdatePathReadinessCheck(plan updates.UpdatePlan) updates.UpdateReadin
}
}
+// agentBackedHosts drops unified-fabric host rows whose telemetry comes from a
+// platform integration (vSphere, TrueNAS, ...) rather than a Pulse Agent, so
+// agent readiness checks only count real agents.
+func agentBackedHosts(hosts []models.Host) []models.Host {
+ out := make([]models.Host, 0, len(hosts))
+ for _, host := range hosts {
+ if strings.TrimSpace(host.IntegrationSource) != "" {
+ continue
+ }
+ out = append(out, host)
+ }
+ return out
+}
+
func buildAgentContinuityReadinessCheck(hosts []models.Host, targetVersion string, now time.Time) updates.UpdateReadinessCheck {
if len(hosts) == 0 {
return updates.UpdateReadinessCheck{
diff --git a/internal/models/models.go b/internal/models/models.go
index 1525741c4a..4ecb59219d 100644
--- a/internal/models/models.go
+++ b/internal/models/models.go
@@ -248,46 +248,51 @@ func (c Container) NormalizeCollections() Container {
// Host represents a generic infrastructure host reporting via external agents.
type Host struct {
- ID string `json:"id"`
- Hostname string `json:"hostname"`
- DisplayName string `json:"displayName,omitempty"`
- Platform string `json:"platform,omitempty"`
- OSName string `json:"osName,omitempty"`
- OSVersion string `json:"osVersion,omitempty"`
- KernelVersion string `json:"kernelVersion,omitempty"`
- Architecture string `json:"architecture,omitempty"`
- CPUCount int `json:"cpuCount,omitempty"`
- CPUUsage float64 `json:"cpuUsage,omitempty"`
- Memory Memory `json:"memory"`
- LoadAverage []float64 `json:"loadAverage,omitempty"`
- Disks []Disk `json:"disks,omitempty"`
- DiskIO []DiskIO `json:"diskIO,omitempty"`
- NetworkInterfaces []HostNetworkInterface `json:"networkInterfaces,omitempty"`
- Sensors HostSensorSummary `json:"sensors,omitempty"`
- RAID []HostRAIDArray `json:"raid,omitempty"`
- Unraid *HostUnraidStorage `json:"unraid,omitempty"`
- Ceph *HostCephCluster `json:"ceph,omitempty"`
- Status string `json:"status"`
- UptimeSeconds int64 `json:"uptimeSeconds,omitempty"`
- IntervalSeconds int `json:"intervalSeconds,omitempty"`
- LastSeen time.Time `json:"lastSeen"`
- AgentVersion string `json:"agentVersion,omitempty"`
- MachineID string `json:"machineId,omitempty"`
- CommandsEnabled bool `json:"commandsEnabled,omitempty"` // Whether AI command execution is enabled
- OperationReceiptVersion int `json:"-"`
- ReportIP string `json:"reportIp,omitempty"` // User-specified IP for multi-NIC systems
- TokenID string `json:"tokenId,omitempty"`
- TokenName string `json:"tokenName,omitempty"`
- TokenHint string `json:"tokenHint,omitempty"`
- TokenLastUsedAt *time.Time `json:"tokenLastUsedAt,omitempty"`
- Tags []string `json:"tags,omitempty"`
- DiskExclude []string `json:"diskExclude,omitempty"` // Agent's --disk-exclude patterns
- AppliedConfig *AgentConfigFingerprint `json:"appliedConfig,omitempty"`
- AgentUpdate *AgentUpdateStatus `json:"agentUpdate,omitempty"`
- AgentModules []AgentModuleStatus `json:"agentModules,omitempty"`
- PackageUpdates *HostPackageUpdateStatus `json:"packageUpdates,omitempty"`
- StorageCleanup *HostStorageCleanupStatus `json:"storageCleanup,omitempty"`
- IsLegacy bool `json:"isLegacy,omitempty"`
+ ID string `json:"id"`
+ Hostname string `json:"hostname"`
+ DisplayName string `json:"displayName,omitempty"`
+ Platform string `json:"platform,omitempty"`
+ OSName string `json:"osName,omitempty"`
+ OSVersion string `json:"osVersion,omitempty"`
+ KernelVersion string `json:"kernelVersion,omitempty"`
+ Architecture string `json:"architecture,omitempty"`
+ CPUCount int `json:"cpuCount,omitempty"`
+ CPUUsage float64 `json:"cpuUsage,omitempty"`
+ Memory Memory `json:"memory"`
+ LoadAverage []float64 `json:"loadAverage,omitempty"`
+ Disks []Disk `json:"disks,omitempty"`
+ DiskIO []DiskIO `json:"diskIO,omitempty"`
+ NetworkInterfaces []HostNetworkInterface `json:"networkInterfaces,omitempty"`
+ Sensors HostSensorSummary `json:"sensors,omitempty"`
+ RAID []HostRAIDArray `json:"raid,omitempty"`
+ Unraid *HostUnraidStorage `json:"unraid,omitempty"`
+ Ceph *HostCephCluster `json:"ceph,omitempty"`
+ Status string `json:"status"`
+ UptimeSeconds int64 `json:"uptimeSeconds,omitempty"`
+ IntervalSeconds int `json:"intervalSeconds,omitempty"`
+ LastSeen time.Time `json:"lastSeen"`
+ AgentVersion string `json:"agentVersion,omitempty"`
+ MachineID string `json:"machineId,omitempty"`
+ CommandsEnabled bool `json:"commandsEnabled,omitempty"` // Whether AI command execution is enabled
+ OperationReceiptVersion int `json:"-"`
+ ReportIP string `json:"reportIp,omitempty"` // User-specified IP for multi-NIC systems
+ TokenID string `json:"tokenId,omitempty"`
+ TokenName string `json:"tokenName,omitempty"`
+ TokenHint string `json:"tokenHint,omitempty"`
+ TokenLastUsedAt *time.Time `json:"tokenLastUsedAt,omitempty"`
+ Tags []string `json:"tags,omitempty"`
+ DiskExclude []string `json:"diskExclude,omitempty"` // Agent's --disk-exclude patterns
+ AppliedConfig *AgentConfigFingerprint `json:"appliedConfig,omitempty"`
+ AgentUpdate *AgentUpdateStatus `json:"agentUpdate,omitempty"`
+ AgentModules []AgentModuleStatus `json:"agentModules,omitempty"`
+ // IntegrationSource names the platform integration ("vmware", "truenas", ...)
+ // that supplies this host's telemetry when no Pulse Agent reports for it.
+ // Empty means Pulse-Agent-backed. Only unified-fabric snapshots populate it;
+ // hosts built from agent reports leave it empty by construction.
+ IntegrationSource string `json:"integrationSource,omitempty"`
+ PackageUpdates *HostPackageUpdateStatus `json:"packageUpdates,omitempty"`
+ StorageCleanup *HostStorageCleanupStatus `json:"storageCleanup,omitempty"`
+ IsLegacy bool `json:"isLegacy,omitempty"`
// Computed I/O rates (bytes/sec), populated from cumulative counters by rate tracker
NetInRate float64 `json:"netInRate,omitempty"`
diff --git a/internal/models/state_host_test.go b/internal/models/state_host_test.go
index f4384391dc..5502c9fdd5 100644
--- a/internal/models/state_host_test.go
+++ b/internal/models/state_host_test.go
@@ -1,6 +1,8 @@
package models
import (
+ "encoding/json"
+ "strings"
"testing"
"time"
)
@@ -1381,3 +1383,45 @@ func TestUpdateStorageBackupsForInstance(t *testing.T) {
}
}
}
+
+// Host.IntegrationSource is fabric-only provenance: it must survive host
+// upserts, serialize when set, and stay entirely absent from JSON for real
+// agent-report hosts so existing payloads do not change shape.
+func TestHostIntegrationSourceRoundTrip(t *testing.T) {
+ state := NewState()
+ state.UpsertHost(Host{ID: "host-esxi", Hostname: "esxi-01", IntegrationSource: "vmware"})
+ state.UpsertHost(Host{ID: "host-agent", Hostname: "apollo-114"})
+
+ var esxi, agent *Host
+ hosts := state.GetHosts()
+ for i := range hosts {
+ switch hosts[i].ID {
+ case "host-esxi":
+ esxi = &hosts[i]
+ case "host-agent":
+ agent = &hosts[i]
+ }
+ }
+ if esxi == nil || esxi.IntegrationSource != "vmware" {
+ t.Fatalf("expected upserted host to preserve IntegrationSource %q, got %+v", "vmware", esxi)
+ }
+ if agent == nil || agent.IntegrationSource != "" {
+ t.Fatalf("expected agent host to keep empty IntegrationSource, got %+v", agent)
+ }
+
+ marked, err := json.Marshal(esxi)
+ if err != nil {
+ t.Fatalf("marshal integration host: %v", err)
+ }
+ if !strings.Contains(string(marked), `"integrationSource":"vmware"`) {
+ t.Fatalf("expected integrationSource in payload, got %s", marked)
+ }
+
+ unmarked, err := json.Marshal(agent)
+ if err != nil {
+ t.Fatalf("marshal agent host: %v", err)
+ }
+ if strings.Contains(string(unmarked), "integrationSource") {
+ t.Fatalf("expected integrationSource omitted for agent hosts, got %s", unmarked)
+ }
+}
diff --git a/internal/monitoring/agent_fleet_doctor.go b/internal/monitoring/agent_fleet_doctor.go
index 120aeb8ad4..4be8731342 100644
--- a/internal/monitoring/agent_fleet_doctor.go
+++ b/internal/monitoring/agent_fleet_doctor.go
@@ -493,7 +493,7 @@ func diagnoseAgentConnectivity(subject agentFleetSubject, now time.Time) []Agent
reasons = append(reasons, AgentFleetDiagnosticReason{
Code: "agent_disconnected",
Severity: AgentFleetStatusCritical,
- Message: fmt.Sprintf("No report has arrived for %s; this is beyond the canonical %s agent stale threshold.", roundDuration(age), roundDuration(staleThreshold)),
+ Message: fmt.Sprintf("No report has arrived for %s. Pulse marks an agent stale after %s without a report.", formatFleetDuration(age), formatFleetDuration(staleThreshold)),
Evidence: []string{
"Last seen: " + subject.lastSeen.UTC().Format(time.RFC3339),
fmt.Sprintf("Expected report interval: %ds", interval),
@@ -505,7 +505,7 @@ func diagnoseAgentConnectivity(subject agentFleetSubject, now time.Time) []Agent
reasons = append(reasons, AgentFleetDiagnosticReason{
Code: "agent_status_not_online",
Severity: AgentFleetStatusWarning,
- Message: fmt.Sprintf("The agent reports status %q instead of online/running/healthy.", subject.rawStatus),
+ Message: fmt.Sprintf("The agent's most recent report described it as %q rather than online.", subject.rawStatus),
})
}
@@ -1192,9 +1192,34 @@ func nonEmptyStrings(values ...string) []string {
return out
}
-func roundDuration(duration time.Duration) string {
- if duration < time.Second {
- return duration.String()
+// formatFleetDuration renders a duration the way a person would say it
+// ("45s", "5m", "10m 2s", "1h 3m", "2d 4h") instead of Go's "5m0s" form.
+func formatFleetDuration(duration time.Duration) string {
+ if duration < 0 {
+ duration = 0
+ }
+ duration = duration.Round(time.Second)
+ days := int(duration.Hours()) / 24
+ hours := int(duration.Hours()) % 24
+ minutes := int(duration.Minutes()) % 60
+ seconds := int(duration.Seconds()) % 60
+ switch {
+ case days > 0:
+ if hours == 0 {
+ return fmt.Sprintf("%dd", days)
+ }
+ return fmt.Sprintf("%dd %dh", days, hours)
+ case duration >= time.Hour:
+ if minutes == 0 {
+ return fmt.Sprintf("%dh", hours)
+ }
+ return fmt.Sprintf("%dh %dm", hours, minutes)
+ case duration >= time.Minute:
+ if seconds == 0 {
+ return fmt.Sprintf("%dm", minutes)
+ }
+ return fmt.Sprintf("%dm %ds", minutes, seconds)
+ default:
+ return fmt.Sprintf("%ds", seconds)
}
- return duration.Round(time.Second).String()
}
diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.go
index 425b3e8141..31ea0421a0 100644
--- a/internal/monitoring/monitor.go
+++ b/internal/monitoring/monitor.go
@@ -3265,6 +3265,7 @@ func hostFromReadStateView(view *unifiedresources.HostView) models.Host {
IntervalSeconds: view.IntervalSeconds(),
LastSeen: view.LastSeen(),
AgentVersion: view.AgentVersion(),
+ IntegrationSource: view.IntegrationSource(),
MachineID: view.MachineID(),
CommandsEnabled: view.CommandsEnabled(),
ReportIP: view.ReportIP(),
diff --git a/internal/monitoring/monitor_host_agents_test.go b/internal/monitoring/monitor_host_agents_test.go
index 20f068c1c8..bdbc6b941b 100644
--- a/internal/monitoring/monitor_host_agents_test.go
+++ b/internal/monitoring/monitor_host_agents_test.go
@@ -3826,3 +3826,35 @@ func TestApplyHostReportNormalizesLegacyAgentPlatformAcceptedIngestProof(t *test
})
}
}
+
+// hostFromReadStateView must carry the fabric's integration-source
+// discriminator onto models.Host so ledger consumers (connections aggregator,
+// update readiness) can tell real Pulse Agents from integration-monitored
+// machines, while agent-sourced hosts stay unmarked.
+func TestHostFromReadStateViewMapsIntegrationSource(t *testing.T) {
+ t.Parallel()
+
+ vmwareResource := unifiedresources.Resource{
+ ID: "vc-1:host:host-101",
+ Type: unifiedresources.ResourceTypeAgent,
+ Name: "esxi-01.lab.local",
+ Sources: []unifiedresources.DataSource{unifiedresources.SourceVMware},
+ Agent: &unifiedresources.AgentData{AgentID: "vc-1:host:host-101", Platform: "vmware-vsphere"},
+ }
+ vmwareView := unifiedresources.NewHostView(&vmwareResource)
+ if got := hostFromReadStateView(&vmwareView).IntegrationSource; got != "vmware" {
+ t.Fatalf("vSphere-only host must map IntegrationSource %q, got %q", "vmware", got)
+ }
+
+ agentResource := unifiedresources.Resource{
+ ID: "host-linux-1",
+ Type: unifiedresources.ResourceTypeAgent,
+ Name: "apollo-114",
+ Sources: []unifiedresources.DataSource{unifiedresources.SourceAgent},
+ Agent: &unifiedresources.AgentData{AgentID: "host-linux-1", AgentVersion: "6.1.0"},
+ }
+ agentView := unifiedresources.NewHostView(&agentResource)
+ if got := hostFromReadStateView(&agentView).IntegrationSource; got != "" {
+ t.Fatalf("agent-sourced host must map empty IntegrationSource, got %q", got)
+ }
+}
diff --git a/internal/monitoring/monitoring_fleet_doctor_helpers_branchcov0716_test.go b/internal/monitoring/monitoring_fleet_doctor_helpers_branchcov0716_test.go
index 4dff7ff9b0..ad6dfc064c 100644
--- a/internal/monitoring/monitoring_fleet_doctor_helpers_branchcov0716_test.go
+++ b/internal/monitoring/monitoring_fleet_doctor_helpers_branchcov0716_test.go
@@ -12,7 +12,7 @@ import (
// - sameAgentIdentity
// - hasType
// - nonEmptyStrings
-// - roundDuration
+// - formatFleetDuration
//
// It targets genuinely-uncovered branches (both sides of each conditional,
// short-circuit ordering, empty/nil/zero and boundary inputs) and asserts real
@@ -274,12 +274,11 @@ func TestBranchCovNonEmptyStrings(t *testing.T) {
}
}
-// roundDuration takes one of two formatting paths split at exactly one second.
-// Durations strictly below one second are stringified verbatim; durations of at
-// least one second are rounded to whole seconds first (Go rounds ties away from
-// zero). Negative durations are always less than time.Second and therefore take
-// the verbatim branch.
-func TestBranchCovRoundDuration(t *testing.T) {
+// formatFleetDuration renders human-friendly durations at four scales
+// (seconds, minutes, hours, days), dropping the smaller unit when it is zero
+// and clamping negative inputs to zero. Sub-second values round to whole
+// seconds first (Go rounds ties away from zero).
+func TestBranchCovFormatFleetDuration(t *testing.T) {
t.Parallel()
cases := []struct {
@@ -287,28 +286,25 @@ func TestBranchCovRoundDuration(t *testing.T) {
duration time.Duration
want string
}{
- // Sub-second branch (duration < time.Second): verbatim .String().
+ // Negative clamp and second-scale branch.
+ {name: "negative clamps to zero", duration: -2 * time.Second, want: "0s"},
{name: "zero", duration: 0, want: "0s"},
- {name: "one millisecond", duration: time.Millisecond, want: "1ms"},
- {name: "five hundred ms", duration: 500 * time.Millisecond, want: "500ms"},
- {name: "just under one second", duration: 999 * time.Millisecond, want: "999ms"},
-
- // Boundary: exactly one second is NOT < time.Second, so it takes the
- // rounding branch and stays "1s".
- {name: "exactly one second via round branch", duration: time.Second, want: "1s"},
-
- // Rounding branch (>= 1s): whole-second .String() after rounding.
- {name: "rounds down 1.4s", duration: 1400 * time.Millisecond, want: "1s"},
- {name: "rounds half away from zero 1.5s -> 2s", duration: 1500 * time.Millisecond, want: "2s"},
- {name: "rounds 2.6s -> 3s", duration: 2600 * time.Millisecond, want: "3s"},
- {name: "truncated sub-second over one second", duration: 2300 * time.Millisecond, want: "2s"},
- {name: "ninety seconds composes m+s", duration: 90 * time.Second, want: "1m30s"},
- {name: "compound h+m+s", duration: time.Hour + 2*time.Minute + 3*time.Second, want: "1h2m3s"},
-
- // Negative durations are always < time.Second (positive), so they take
- // the verbatim branch regardless of magnitude.
- {name: "negative sub-second verbatim", duration: -500 * time.Millisecond, want: "-500ms"},
- {name: "negative whole second still verbatim", duration: -2 * time.Second, want: "-2s"},
+ {name: "sub-second rounds down", duration: 400 * time.Millisecond, want: "0s"},
+ {name: "sub-second rounds half away from zero", duration: 500 * time.Millisecond, want: "1s"},
+ {name: "whole seconds", duration: 45 * time.Second, want: "45s"},
+
+ // Minute scale: seconds shown only when non-zero.
+ {name: "exact minutes drop seconds", duration: 5 * time.Minute, want: "5m"},
+ {name: "minutes and seconds compose", duration: 90 * time.Second, want: "1m 30s"},
+ {name: "ten minutes two seconds", duration: 10*time.Minute + 2*time.Second, want: "10m 2s"},
+
+ // Hour scale: minutes shown only when non-zero, seconds dropped.
+ {name: "exact hours drop minutes", duration: 2 * time.Hour, want: "2h"},
+ {name: "hours and minutes compose", duration: time.Hour + 2*time.Minute + 3*time.Second, want: "1h 2m"},
+
+ // Day scale: hours shown only when non-zero, minutes dropped.
+ {name: "exact days drop hours", duration: 48 * time.Hour, want: "2d"},
+ {name: "days and hours compose", duration: 52*time.Hour + 30*time.Minute, want: "2d 4h"},
}
for _, tc := range cases {
@@ -316,8 +312,8 @@ func TestBranchCovRoundDuration(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
- if got := roundDuration(tc.duration); got != tc.want {
- t.Fatalf("roundDuration(%v) = %q, want %q", tc.duration, got, tc.want)
+ if got := formatFleetDuration(tc.duration); got != tc.want {
+ t.Fatalf("formatFleetDuration(%v) = %q, want %q", tc.duration, got, tc.want)
}
})
}
diff --git a/internal/unifiedresources/views.go b/internal/unifiedresources/views.go
index e4ee316ec6..5b7c91f395 100644
--- a/internal/unifiedresources/views.go
+++ b/internal/unifiedresources/views.go
@@ -1027,6 +1027,31 @@ func (v HostView) AgentID() string {
return v.r.Agent.AgentID
}
+// IntegrationSource names the platform integration that supplies this host's
+// telemetry when no Pulse Agent reports for it (e.g. "vmware", "truenas").
+// Empty means the host is Pulse-Agent-backed. Agent-fleet surfaces use this
+// to keep integration-monitored machines out of agent-only workflows.
+// The check is source-based on purpose: integration providers (vSphere,
+// TrueNAS) fabricate an Agent payload so machine surfaces render host facts,
+// but only a real Pulse Agent ingests under SourceAgent.
+func (v HostView) IntegrationSource() string {
+ if v.r == nil {
+ return ""
+ }
+ if hasDataSource(v.r.Sources, SourceAgent) {
+ return ""
+ }
+ for _, source := range []DataSource{SourceVMware, SourceTrueNAS, SourceProxmox, SourceDocker, SourceK8s, SourcePBS, SourcePMG} {
+ if hasDataSource(v.r.Sources, source) {
+ return string(source)
+ }
+ }
+ if len(v.r.Sources) > 0 {
+ return string(v.r.Sources[0])
+ }
+ return "integration"
+}
+
func (v HostView) MetricsTarget() *MetricsTarget {
if v.r == nil {
return nil
diff --git a/internal/unifiedresources/views_test.go b/internal/unifiedresources/views_test.go
index 1d48858141..9d58bac937 100644
--- a/internal/unifiedresources/views_test.go
+++ b/internal/unifiedresources/views_test.go
@@ -812,6 +812,52 @@ func TestView_HostViewAccessors(t *testing.T) {
}
}
+func TestView_HostViewIntegrationSource(t *testing.T) {
+ agentBacked := NewHostView(&Resource{
+ ID: "host-agent",
+ Type: ResourceTypeAgent,
+ Name: "agent-host",
+ Sources: []DataSource{SourceAgent, SourceProxmox},
+ Agent: &AgentData{AgentID: "agent-1"},
+ })
+ if got := agentBacked.IntegrationSource(); got != "" {
+ t.Fatalf("agent-sourced host must report empty integration source, got %q", got)
+ }
+
+ // Integration providers fabricate an Agent payload so machine surfaces can
+ // render host facts; only the ingest source decides agent-backedness.
+ vmwareHost := NewHostView(&Resource{
+ ID: "host-esxi",
+ Type: ResourceTypeAgent,
+ Name: "esxi-01",
+ Sources: []DataSource{SourceVMware},
+ Agent: &AgentData{AgentID: "vc-1:host:host-101", Platform: "vmware-vsphere"},
+ })
+ if got := vmwareHost.IntegrationSource(); got != "vmware" {
+ t.Fatalf("vSphere-only host must report %q, got %q", "vmware", got)
+ }
+
+ truenasHost := NewHostView(&Resource{
+ ID: "host-truenas",
+ Type: ResourceTypeAgent,
+ Name: "truenas-main",
+ Sources: []DataSource{SourceTrueNAS},
+ })
+ if got := truenasHost.IntegrationSource(); got != "truenas" {
+ t.Fatalf("TrueNAS-only host must report %q, got %q", "truenas", got)
+ }
+
+ sourceless := NewHostView(&Resource{ID: "host-none", Type: ResourceTypeAgent})
+ if got := sourceless.IntegrationSource(); got != "integration" {
+ t.Fatalf("sourceless non-agent host must report the generic %q marker, got %q", "integration", got)
+ }
+
+ var nilView HostView
+ if got := nilView.IntegrationSource(); got != "" {
+ t.Fatalf("nil-backed view must report empty integration source, got %q", got)
+ }
+}
+
func TestView_HostViewMetricsTargetAccessor(t *testing.T) {
r := &Resource{
ID: "host-metrics",