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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Surface monitored-system ledger explanations
rcourtman4cb630f0a6bb
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.mdindex 98e3b2c78a..747c992f0e 100644--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md@@ -654,6 +654,19 @@ That same helper now also owns the row-status fallback summaries used whenmixed-version payloads omit `status_explanation.summary`. The API client andsettings panel must derive online/warning/offline/unknown fallback text fromthat shared owner instead of keeping separate local defaults that can drift.+That same customer/support-facing ledger surface must consume the canonical+`/api/license/monitored-system-ledger/explain` model when showing counted+systems. Rows must expose backend-authored `explanation.summary`, reasons, and+grouped source surfaces through helper-owned labels so customers can see why a+system counts once without the panel inventing a second counting model.+When canonical usage is not safe to read yet and the backend returns+`monitored_system_usage_unavailable` or entitlements mark the monitored-system+current count unavailable, the usage surface must render helper-owned+verification copy instead of a synthetic `0 / limit` ledger total.+The same usage view must also render monitored-system continuity context from+the entitlement payload, including the base plan limit, effective limit,+grandfathered floor, and capture state, so migration protection is visible+beside the canonical count explanation.That same settings owner split now also requires`frontend-modern/src/components/Settings/MonitoredSystemLedgerPanel.tsx` toconsume the normalized ledger client contract directly. Panel-local fallbackdiff --git a/frontend-modern/src/components/Settings/MonitoredSystemLedgerPanel.tsx b/frontend-modern/src/components/Settings/MonitoredSystemLedgerPanel.tsxindex 18f5bcefc0..1612827f4d 100644--- a/frontend-modern/src/components/Settings/MonitoredSystemLedgerPanel.tsx+++ b/frontend-modern/src/components/Settings/MonitoredSystemLedgerPanel.tsx@@ -1,4 +1,4 @@-import { createResource, createSignal, For, Show } from 'solid-js';+import { createMemo, createResource, createSignal, For, Show } from 'solid-js';import SettingsPanel from '@/components/shared/SettingsPanel';import { StatusDot } from '@/components/shared/StatusDot';import {@@ -11,15 +11,23 @@ import {} from '@/components/shared/Table';import { formatRelativeTime } from '@/utils/format';import { MonitoredSystemLedgerAPI } from '@/api/monitoredSystemLedger';-import type { MonitoredSystemLedgerEntry } from '@/api/monitoredSystemLedger';+import type {+ MonitoredSystemLedgerEntry,+ MonitoredSystemLedgerExplanationSurface,+} from '@/api/monitoredSystemLedger';+import type { EntitlementLimitStatus, MonitoredSystemContinuityStatus } from '@/api/license';+import { apiErrorCode, apiErrorDetailField } from '@/api/responseUtils';import { getSimpleStatusIndicator } from '@/utils/status';import { PulseLogoIcon } from '@/components/icons/PulseLogoIcon';import {+ formatMonitoredSystemGroupedSourcesLabel,+ formatMonitoredSystemLedgerUnavailableMessage,formatMonitoredSystemLatestIncludedSignalSentence,formatMonitoredSystemSurfaceAttribution,getMonitoredSystemLedgerErrorState,getMonitoredSystemLedgerDescription,getMonitoredSystemLedgerLoadingState,+ getMonitoredSystemLedgerUnavailableState,getMonitoredSystemCountingDetailsToggleLabel,getMonitoredSystemLedgerPresentation,} from '@/utils/monitoredSystemPresentation';@@ -27,6 +35,8 @@ import { MonitoredSystemDefinitionDisclosure } from '@/components/Commercial/Moninterface MonitoredSystemLedgerPanelProps {embedded?: boolean;+ monitoredSystemContinuity?: MonitoredSystemContinuityStatus | null;+ monitoredSystemLimit?: EntitlementLimitStatus | null;showCountingRulesByDefault?: boolean;}@@ -48,17 +58,81 @@ function latestIncludedSignalSummary(system: MonitoredSystemLedgerEntry): {};}+function includedSurfaces(+ system: MonitoredSystemLedgerEntry,+): MonitoredSystemLedgerExplanationSurface[] {+ if (system.explanation.surfaces.length > 0) {+ return system.explanation.surfaces;+ }++ return [+ {+ name: system.name,+ type: system.type,+ source: system.source,+ },+ ];+}++function formatLimitValue(value: number | undefined): string {+ if (typeof value !== 'number' || value <= 0) {+ return getMonitoredSystemLedgerPresentation().unlimitedLimitLabel;+ }+ return String(value);+}++function formatCapturedAt(value: number | undefined): string | null {+ if (typeof value !== 'number' || value <= 0) {+ return null;+ }+ const date = new Date(value * 1000);+ if (Number.isNaN(date.getTime())) {+ return null;+ }+ return date.toLocaleDateString();+}+export function MonitoredSystemLedgerPanel(props: MonitoredSystemLedgerPanelProps = {}) {- const [ledger, { refetch }] = createResource(() => MonitoredSystemLedgerAPI.getLedger());+ const [explanation, { refetch }] = createResource(() => MonitoredSystemLedgerAPI.explain());const [expandedSystemKey, setExpandedSystemKey] = createSignal<string | null>(null);const presentation = getMonitoredSystemLedgerPresentation();+ const ledger = createMemo(() =>+ explanation.state === 'errored' ? undefined : explanation()?.ledger,+ );const total = () => ledger()?.total ?? 0;- const limit = () => ledger()?.limit ?? 0;+ const limit = () => ledger()?.limit ?? props.monitoredSystemLimit?.limit ?? 0;const systems = () => ledger()?.systems ?? [];const hasLimit = () => limit() > 0;const overLimit = () => hasLimit() && total() > limit();const pct = () => usagePercent(total(), limit());+ const usageUnavailableReason = () => {+ if (apiErrorCode(explanation.error) === 'monitored_system_usage_unavailable') {+ return apiErrorDetailField(explanation.error, 'reason') ?? undefined;+ }+ if (!ledger() && props.monitoredSystemLimit?.current_available === false) {+ return props.monitoredSystemLimit.current_unavailable_reason;+ }+ return undefined;+ };+ const usageUnavailable = () =>+ !ledger() &&+ (apiErrorCode(explanation.error) === 'monitored_system_usage_unavailable' ||+ props.monitoredSystemLimit?.current_available === false);+ const genericError = () => Boolean(explanation.error) && !usageUnavailable();+ const continuity = () => props.monitoredSystemContinuity ?? null;+ const hasContinuityContext = () => {+ const current = continuity();+ if (!current) {+ return false;+ }+ return (+ current.capture_pending ||+ current.effective_limit !== current.plan_limit ||+ (typeof current.grandfathered_floor === 'number' && current.grandfathered_floor > 0)+ );+ };+ const continuityForDisplay = createMemo(() => (hasContinuityContext() ? continuity() : null));const systemKey = (system: MonitoredSystemLedgerEntry, index: number) =>`${system.name}:${system.type}:${index}`;const toggleSystemExplanation = (key: string) => {@@ -78,7 +152,7 @@ export function MonitoredSystemLedgerPanel(props: MonitoredSystemLedgerPanelPropdetailClass="max-w-xl text-xs text-muted"/></div>- <Show when={!ledger.error && ledger()}>+ <Show when={ledger()}><spanclass="text-sm font-medium"classList={{@@ -90,25 +164,97 @@ export function MonitoredSystemLedgerPanel(props: MonitoredSystemLedgerPanelProp<Show when={hasLimit()}>{` / ${limit()}`}</Show></span></Show>+ <Show when={!ledger() && usageUnavailable()}>+ <span class="text-sm font-medium text-amber-700 dark:text-amber-300">+ {presentation.usageVerifyingLabel}+ </span>+ </Show></div></div>+ <Show when={continuityForDisplay()}>+ {(current) => (+ <div+ class="rounded-lg border px-3 py-3 text-xs"+ classList={{+ 'border-amber-200 bg-amber-50 text-amber-900 dark:border-amber-900 dark:bg-amber-950/40 dark:text-amber-100':+ current().capture_pending,+ 'border-green-200 bg-green-50 text-green-900 dark:border-green-900 dark:bg-green-950/40 dark:text-green-100':+ !current().capture_pending,+ }}+ >+ <p class="font-semibold">{presentation.continuityHeading}</p>+ <dl class="mt-2 grid gap-2 sm:grid-cols-4">+ <div>+ <dt class="text-[11px] opacity-75">{presentation.continuityPlanLimitLabel}</dt>+ <dd class="font-medium">{formatLimitValue(current().plan_limit)}</dd>+ </div>+ <div>+ <dt class="text-[11px] opacity-75">{presentation.continuityEffectiveLimitLabel}</dt>+ <dd class="font-medium">{formatLimitValue(current().effective_limit)}</dd>+ </div>+ <Show when={current().grandfathered_floor}>+ {(floor) => (+ <div>+ <dt class="text-[11px] opacity-75">+ {presentation.continuityGrandfatheredFloorLabel}+ </dt>+ <dd class="font-medium">{floor()}</dd>+ </div>+ )}+ </Show>+ <div>+ <dt class="text-[11px] opacity-75">{presentation.continuityCaptureLabel}</dt>+ <dd class="font-medium">+ {current().capture_pending+ ? presentation.continuityCapturePendingLabel+ : (formatCapturedAt(current().captured_at) ??+ presentation.continuityCaptureCapturedLabel)}+ </dd>+ </div>+ </dl>+ </div>+ )}+ </Show>+{/* Loading state */}- <Show when={ledger.loading}>- <p class="text-sm text-muted py-4 text-center">{getMonitoredSystemLedgerLoadingState().text}</p>+ <Show when={explanation.loading && !usageUnavailable()}>+ <p class="text-sm text-muted py-4 text-center">+ {getMonitoredSystemLedgerLoadingState().text}+ </p>+ </Show>++ {/* Usage-unavailable state */}+ <Show when={usageUnavailable()}>+ <div class="rounded-lg border border-amber-200 bg-amber-50 px-4 py-4 text-sm text-amber-900 dark:border-amber-900 dark:bg-amber-950/40 dark:text-amber-100">+ <p class="font-semibold">{getMonitoredSystemLedgerUnavailableState().title}</p>+ <p class="mt-1">+ {formatMonitoredSystemLedgerUnavailableMessage(usageUnavailableReason())}+ </p>+ <button+ type="button"+ class="mt-3 text-xs font-medium underline-offset-2 transition-colors hover:underline disabled:opacity-50"+ disabled={explanation.loading}+ onClick={() => refetch()}+ >+ {explanation.loading+ ? getMonitoredSystemLedgerErrorState().retryingLabel+ : getMonitoredSystemLedgerErrorState().retryLabel}+ </button>+ </div></Show>{/* Error state */}- <Show when={ledger.error}>+ <Show when={genericError()}><div class="text-sm text-red-600 dark:text-red-400 py-4 text-center"><p>{getMonitoredSystemLedgerErrorState().title}</p><buttontype="button"class="mt-2 text-xs text-primary hover:underline disabled:opacity-50"- disabled={ledger.loading}+ disabled={explanation.loading}onClick={() => refetch()}>- {ledger.loading+ {explanation.loading? getMonitoredSystemLedgerErrorState().retryingLabel: getMonitoredSystemLedgerErrorState().retryLabel}</button>@@ -116,7 +262,7 @@ export function MonitoredSystemLedgerPanel(props: MonitoredSystemLedgerPanelProp</Show>{/* Loaded content */}- <Show when={!ledger.loading && !ledger.error && ledger()}>+ <Show when={!explanation.loading && !genericError() && ledger()}><Show when={hasLimit()}><div class="h-2 w-full rounded-full bg-surface-alt overflow-hidden"><div@@ -155,6 +301,28 @@ export function MonitoredSystemLedgerPanel(props: MonitoredSystemLedgerPanelProp<TableCell><div class="space-y-1 whitespace-normal"><span class="text-sm font-medium text-base-content">{system.name}</span>+ <div class="flex flex-wrap items-center gap-1.5">+ <span class="rounded-full border border-border bg-surface px-2 py-0.5 text-[11px] font-medium text-base-content">+ {presentation.countedSystemBadgeLabel}+ </span>+ <span class="text-[11px] text-muted">+ {formatMonitoredSystemGroupedSourcesLabel(+ includedSurfaces(system).length,+ )}+ </span>+ </div>+ <p class="max-w-xl text-xs text-muted">{system.explanation.summary}</p>+ <Show when={includedSurfaces(system).length > 0}>+ <div class="flex flex-wrap gap-1">+ <For each={includedSurfaces(system)}>+ {(surface) => (+ <span class="rounded-full bg-surface-alt px-2 py-0.5 text-[11px] text-muted">+ {formatMonitoredSystemSurfaceAttribution(surface)}+ </span>+ )}+ </For>+ </div>+ </Show><buttontype="button"class="block text-[11px] font-medium text-muted underline-offset-2 transition-colors hover:text-base-content hover:underline"@@ -169,6 +337,21 @@ export function MonitoredSystemLedgerPanel(props: MonitoredSystemLedgerPanelPropid={explanationID}class="space-y-2 rounded-md border border-border bg-surface px-3 py-2 text-xs text-muted">+ <div class="space-y-1">+ <p class="font-medium text-base-content">+ {presentation.countingExplanationHeading}+ </p>+ <p class="whitespace-normal text-base-content">+ {system.explanation.summary}+ </p>+ <Show when={system.explanation.reasons.length > 0}>+ <ul class="space-y-1 whitespace-normal">+ <For each={system.explanation.reasons}>+ {(reason) => <li>{reason.summary}</li>}+ </For>+ </ul>+ </Show>+ </div><div class="space-y-1"><p class="font-medium text-base-content">{presentation.currentStatusHeading}@@ -179,9 +362,7 @@ export function MonitoredSystemLedgerPanel(props: MonitoredSystemLedgerPanelProp<Show when={latestSignal}>{(signal) => (<p class="whitespace-normal text-base-content">- {formatMonitoredSystemLatestIncludedSignalSentence(- signal(),- )}+ {formatMonitoredSystemLatestIncludedSignalSentence(signal())}</p>)}</Show>@@ -193,20 +374,10 @@ export function MonitoredSystemLedgerPanel(props: MonitoredSystemLedgerPanelProp</ul></Show></div>- <p class="whitespace-normal text-base-content">- {system.explanation.summary}- </p>- <Show when={system.explanation.reasons.length > 0}>- <ul class="space-y-1 whitespace-normal">- <For each={system.explanation.reasons}>- {(reason) => <li>{reason.summary}</li>}- </For>- </ul>- </Show><Show when={system.explanation.surfaces.length > 0}><div class="space-y-1"><p class="font-medium text-base-content">- {presentation.includedCollectionPathsHeading}+ {presentation.groupedSourcesHeading}</p><ul class="space-y-1 whitespace-normal"><For each={system.explanation.surfaces}>diff --git a/frontend-modern/src/components/Settings/ProLicensePanel.tsx b/frontend-modern/src/components/Settings/ProLicensePanel.tsxindex a5711016cc..a2aaf9db18 100644--- a/frontend-modern/src/components/Settings/ProLicensePanel.tsx+++ b/frontend-modern/src/components/Settings/ProLicensePanel.tsx@@ -107,6 +107,12 @@ export const ProLicensePanel: Component = () => {><MonitoredSystemLedgerPanelembedded+ monitoredSystemContinuity={state.entitlements()?.monitored_system_continuity}+ monitoredSystemLimit={+ state+ .entitlements()+ ?.limits?.find((entry) => entry.key === 'max_monitored_systems') ?? null+ }showCountingRulesByDefault={state.showCountingRulesByDefault()}/></CommercialSection>diff --git a/frontend-modern/src/components/Settings/__tests__/MonitoredSystemLedgerPanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/MonitoredSystemLedgerPanel.test.tsxindex 6766d4d4e0..42352ddc34 100644--- a/frontend-modern/src/components/Settings/__tests__/MonitoredSystemLedgerPanel.test.tsx+++ b/frontend-modern/src/components/Settings/__tests__/MonitoredSystemLedgerPanel.test.tsx@@ -2,13 +2,23 @@ import { afterEach, describe, expect, it, vi } from 'vitest';import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';import type { JSX } from 'solid-js';-import type { MonitoredSystemLedgerResponse } from '@/api/monitoredSystemLedger';--const getLedgerMock = vi.fn<() => Promise<MonitoredSystemLedgerResponse>>();+import type {+ MonitoredSystemLedgerExplainResponse,+ MonitoredSystemLedgerResponse,+} from '@/api/monitoredSystemLedger';++const explainMock = vi.fn<() => Promise<MonitoredSystemLedgerExplainResponse>>();++const explainResponse = (+ ledger: MonitoredSystemLedgerResponse,+): MonitoredSystemLedgerExplainResponse => ({+ ledger,+ preview: null,+});vi.mock('@/api/monitoredSystemLedger', () => ({MonitoredSystemLedgerAPI: {- getLedger: () => getLedgerMock(),+ explain: () => explainMock(),},}));@@ -44,11 +54,11 @@ import { MonitoredSystemLedgerPanel } from '../MonitoredSystemLedgerPanel';describe('MonitoredSystemLedgerPanel', () => {afterEach(() => {cleanup();- getLedgerMock.mockReset();+ explainMock.mockReset();});it('shows monitored-system loading copy while the ledger request is pending', () => {- getLedgerMock.mockReturnValue(new Promise<MonitoredSystemLedgerResponse>(() => {}));+ explainMock.mockReturnValue(new Promise<MonitoredSystemLedgerExplainResponse>(() => {}));render(() => <MonitoredSystemLedgerPanel />);@@ -56,61 +66,66 @@ describe('MonitoredSystemLedgerPanel', () => {});it('shows error message with Retry button when API fails', async () => {- getLedgerMock.mockRejectedValue(new Error('network error'));+ explainMock.mockRejectedValue(new Error('network error'));render(() => <MonitoredSystemLedgerPanel />);await waitFor(() => {- expect(screen.getByText('Monitored system usage is temporarily unavailable.')).toBeInTheDocument();+ expect(+ screen.getByText('Monitored system usage is temporarily unavailable.'),+ ).toBeInTheDocument();});expect(screen.getByRole('button', { name: 'Try again' })).toBeInTheDocument();});it('recovers from error when Retry is clicked and API succeeds', async () => {- getLedgerMock.mockRejectedValue(new Error('network error'));+ explainMock.mockRejectedValue(new Error('network error'));render(() => <MonitoredSystemLedgerPanel />);await waitFor(() => {- expect(screen.getByText('Monitored system usage is temporarily unavailable.')).toBeInTheDocument();+ expect(+ screen.getByText('Monitored system usage is temporarily unavailable.'),+ ).toBeInTheDocument();});- // Now make API succeed on retry- getLedgerMock.mockResolvedValue({- systems: [- {- name: 'host-1',- type: 'host',- status: 'online',- status_explanation: {- summary: 'All included top-level collection paths currently report online status.',- reasons: [],- },- latest_included_signal: {+ explainMock.mockResolvedValue(+ explainResponse({+ systems: [+ {name: 'host-1',type: 'host',+ status: 'online',+ status_explanation: {+ summary: 'All included top-level collection paths currently report online status.',+ reasons: [],+ },+ latest_included_signal: {+ name: 'host-1',+ type: 'host',+ source: 'agent',+ at: '2026-01-01T00:00:00Z',+ },source: 'agent',- at: '2026-01-01T00:00:00Z',- },- source: 'agent',- explanation: {- summary:- 'Counts as one monitored system because Pulse sees one top-level host view from agent.',- reasons: [- {- kind: 'standalone',- signal: 'single-top-level-view',- summary: 'No overlapping top-level source matched this system.',- },- ],- surfaces: [{ name: 'host-1', type: 'host', source: 'agent' }],+ explanation: {+ summary:+ 'Counts as one monitored system because Pulse sees one top-level host view from agent.',+ reasons: [+ {+ kind: 'standalone',+ signal: 'single-top-level-view',+ summary: 'No overlapping top-level source matched this system.',+ },+ ],+ surfaces: [{ name: 'host-1', type: 'host', source: 'agent' }],+ },},- },- ],- total: 1,- limit: 5,- });+ ],+ total: 1,+ limit: 5,+ }),+ );fireEvent.click(screen.getByRole('button', { name: 'Try again' }));@@ -124,104 +139,181 @@ describe('MonitoredSystemLedgerPanel', () => {});it('keeps Retry button visible on repeated failures', async () => {- getLedgerMock.mockRejectedValue(new Error('network error'));+ explainMock.mockRejectedValue(new Error('network error'));render(() => <MonitoredSystemLedgerPanel />);await waitFor(() => {- expect(screen.getByText('Monitored system usage is temporarily unavailable.')).toBeInTheDocument();+ expect(+ screen.getByText('Monitored system usage is temporarily unavailable.'),+ ).toBeInTheDocument();});- const callsBefore = getLedgerMock.mock.calls.length;+ const callsBefore = explainMock.mock.calls.length;fireEvent.click(screen.getByRole('button', { name: 'Try again' }));await waitFor(() => {- expect(screen.getByText('Monitored system usage is temporarily unavailable.')).toBeInTheDocument();+ expect(+ screen.getByText('Monitored system usage is temporarily unavailable.'),+ ).toBeInTheDocument();});- expect(getLedgerMock.mock.calls.length).toBeGreaterThan(callsBefore);+ expect(explainMock.mock.calls.length).toBeGreaterThan(callsBefore);expect(screen.getByRole('button', { name: 'Try again' })).toBeInTheDocument();});+ it('shows a verification state when canonical monitored-system usage is not settled', async () => {+ explainMock.mockRejectedValue(+ Object.assign(new Error('usage unavailable'), {+ code: 'monitored_system_usage_unavailable',+ details: { reason: 'supplemental_inventory_unsettled' },+ }),+ );++ render(() => (+ <MonitoredSystemLedgerPanel+ monitoredSystemLimit={{+ key: 'max_monitored_systems',+ limit: 5,+ current: 16,+ current_available: false,+ current_unavailable_reason: 'supplemental_inventory_unsettled',+ state: 'enforced',+ }}+ />+ ));++ await waitFor(() => {+ expect(screen.getByText('Verifying monitored-system inventory')).toBeInTheDocument();+ });++ expect(screen.getByText('Verifying…')).toBeInTheDocument();+ expect(+ screen.getByText(+ 'Pulse is still collecting the first provider-owned inventory baseline. The monitored-system ledger will appear after that baseline completes.',+ ),+ ).toBeInTheDocument();+ expect(screen.queryByText('0 / 5')).not.toBeInTheDocument();+ expect(+ screen.queryByText('Monitored system usage is temporarily unavailable.'),+ ).not.toBeInTheDocument();+ });++ it('surfaces monitored-system continuity context from entitlements', async () => {+ explainMock.mockResolvedValue(+ explainResponse({+ systems: [],+ total: 7,+ limit: 12,+ }),+ );++ render(() => (+ <MonitoredSystemLedgerPanel+ monitoredSystemContinuity={{+ plan_limit: 5,+ grandfathered_floor: 12,+ effective_limit: 12,+ capture_pending: true,+ }}+ />+ ));++ await waitFor(() => {+ expect(screen.getByText('7 / 12')).toBeInTheDocument();+ });++ expect(screen.getByText('Plan continuity')).toBeInTheDocument();+ expect(screen.getByText('Plan limit')).toBeInTheDocument();+ expect(screen.getByText('Effective limit')).toBeInTheDocument();+ expect(screen.getByText('Grandfathered floor')).toBeInTheDocument();+ expect(screen.getByText('Continuity capture')).toBeInTheDocument();+ expect(screen.getByText('5')).toBeInTheDocument();+ expect(screen.getAllByText('12')).toHaveLength(2);+ expect(screen.getByText('Pending')).toBeInTheDocument();+ });+it('renders ledger data on successful load', async () => {- getLedgerMock.mockResolvedValue({- systems: [- {- name: 'server-a',- type: 'host',- status: 'online',- status_explanation: {- summary: 'All included top-level collection paths currently report online status.',- reasons: [],- },- latest_included_signal: {+ explainMock.mockResolvedValue(+ explainResponse({+ systems: [+ {name: 'server-a',type: 'host',+ status: 'online',+ status_explanation: {+ summary: 'All included top-level collection paths currently report online status.',+ reasons: [],+ },+ latest_included_signal: {+ name: 'server-a',+ type: 'host',+ source: 'agent',+ at: '2026-01-01T00:00:00Z',+ },source: 'agent',- at: '2026-01-01T00:00:00Z',+ explanation: {+ summary:+ 'Counts as one monitored system because Pulse sees one top-level host view from agent.',+ reasons: [+ {+ kind: 'standalone',+ signal: 'single-top-level-view',+ summary: 'No overlapping top-level source matched this system.',+ },+ ],+ surfaces: [{ name: 'server-a', type: 'host', source: 'agent' }],+ },},- source: 'agent',- explanation: {- summary:- 'Counts as one monitored system because Pulse sees one top-level host view from agent.',- reasons: [- {- kind: 'standalone',- signal: 'single-top-level-view',- summary: 'No overlapping top-level source matched this system.',- },- ],- surfaces: [{ name: 'server-a', type: 'host', source: 'agent' }],- },- },- {- name: 'server-b',- type: 'pbs-server',- status: 'offline',- status_explanation: {- summary:- 'At least one included source is offline or disconnected, so Pulse marks this monitored system as offline.',- reasons: [- {- kind: 'source-offline',- name: 'server-b',- type: 'pbs-server',- source: 'pbs',- status: 'offline',- reported_at: '2026-01-01T23:55:00Z',- summary:- 'PBS data for server-b is offline or disconnected (last reported 2026-01-01T23:55:00Z).',- },- ],- },- latest_included_signal: {+ {name: 'server-b',type: 'pbs-server',+ status: 'offline',+ status_explanation: {+ summary:+ 'At least one included source is offline or disconnected, so Pulse marks this monitored system as offline.',+ reasons: [+ {+ kind: 'source-offline',+ name: 'server-b',+ type: 'pbs-server',+ source: 'pbs',+ status: 'offline',+ reported_at: '2026-01-01T23:55:00Z',+ summary:+ 'PBS data for server-b is offline or disconnected (last reported 2026-01-01T23:55:00Z).',+ },+ ],+ },+ latest_included_signal: {+ name: 'server-b',+ type: 'pbs-server',+ source: 'pbs',+ at: '2026-01-02T00:00:00Z',+ },source: 'pbs',- at: '2026-01-02T00:00:00Z',- },- source: 'pbs',- explanation: {- summary:- 'Counts as one monitored system because Pulse merged 2 top-level views into one canonical system using shared machine identity.',- reasons: [- {- kind: 'shared-identity',- signal: 'machine-id',- summary: 'Merged host and PBS server views using shared machine identity.',- },- ],- surfaces: [- { name: 'server-b', type: 'pbs-server', source: 'pbs' },- { name: 'server-b host', type: 'host', source: 'agent' },- ],+ explanation: {+ summary:+ 'Counts as one monitored system because Pulse merged 2 top-level views into one canonical system using shared machine identity.',+ reasons: [+ {+ kind: 'shared-identity',+ signal: 'machine-id',+ summary: 'Merged host and PBS server views using shared machine identity.',+ },+ ],+ surfaces: [+ { name: 'server-b', type: 'pbs-server', source: 'pbs' },+ { name: 'server-b host', type: 'host', source: 'agent' },+ ],+ },},- },- ],- total: 2,- limit: 10,- });+ ],+ total: 2,+ limit: 10,+ }),+ );render(() => <MonitoredSystemLedgerPanel />);@@ -232,7 +324,7 @@ describe('MonitoredSystemLedgerPanel', () => {expect(screen.getByText('Monitored System Ledger')).toBeInTheDocument();expect(screen.getByText('Latest Included Signal')).toBeInTheDocument();expect(screen.getByText('2026-01-02T00:00:00Z')).toBeInTheDocument();- expect(screen.getByText('server-b (PBS Server via PBS)')).toBeInTheDocument();+ expect(screen.getAllByText('server-b (PBS Server via PBS)').length).toBeGreaterThan(0);expect(screen.getByText('Review the monitored systems currently counted against your Pulse Pro plan limit.',@@ -240,23 +332,29 @@ describe('MonitoredSystemLedgerPanel', () => {).toBeInTheDocument();expect(screen.getByRole('button', { name: 'View counting rules' })).toBeInTheDocument();expect(- screen.queryByText(/a monitored system is a top-level machine or cluster pulse actively monitors/i),+ screen.queryByText(+ /a monitored system is a top-level machine or cluster pulse actively monitors/i,+ ),).not.toBeInTheDocument();fireEvent.click(screen.getByRole('button', { name: 'View counting rules' }));expect(- screen.getByText(/a monitored system is a top-level machine or cluster pulse actively monitors/i),+ screen.getByText(+ /a monitored system is a top-level machine or cluster pulse actively monitors/i,+ ),).toBeInTheDocument();expect(screen.getByText('server-b')).toBeInTheDocument();expect(screen.getByText('2 / 10')).toBeInTheDocument();expect(screen.getAllByRole('button', { name: 'View counting details' })).toHaveLength(2);fireEvent.click(screen.getAllByRole('button', { name: 'View counting details' })[1]!);expect(- screen.getByText(+ screen.getAllByText('Counts as one monitored system because Pulse merged 2 top-level views into one canonical system using shared machine identity.',),- ).toBeInTheDocument();+ ).toHaveLength(2);+ expect(screen.getAllByText('Counts as 1 monitored system')).toHaveLength(2);+ expect(screen.getByText('2 grouped sources')).toBeInTheDocument();expect(screen.getByText('Current status')).toBeInTheDocument();expect(screen.getByText(@@ -273,41 +371,44 @@ describe('MonitoredSystemLedgerPanel', () => {'PBS data for server-b is offline or disconnected (last reported 2026-01-01T23:55:00Z).',),).toBeInTheDocument();- expect(screen.getByText('Included collection paths')).toBeInTheDocument();- expect(screen.getByText('server-b host (Host via Agent)')).toBeInTheDocument();+ expect(screen.getByText('Why this counts')).toBeInTheDocument();+ expect(screen.getByText('Grouped sources')).toBeInTheDocument();+ expect(screen.getAllByText('server-b host (Host via Agent)').length).toBeGreaterThan(0);expect(screen.queryByText('Monitored system usage is temporarily unavailable.'),).not.toBeInTheDocument();});it('does not crash when explanation payload is missing', async () => {- getLedgerMock.mockResolvedValue({- systems: [- {- name: 'server-a',- type: 'host',- status: 'online',- status_explanation: {- summary: 'All included top-level collection paths currently report online status.',- reasons: [],- },- explanation: {- summary: 'Pulse counts this top-level collection path as one monitored system.',- reasons: [],- surfaces: [],- },- latest_included_signal: {+ explainMock.mockResolvedValue(+ explainResponse({+ systems: [+ {name: 'server-a',type: 'host',+ status: 'online',+ status_explanation: {+ summary: 'All included top-level collection paths currently report online status.',+ reasons: [],+ },+ explanation: {+ summary: 'Pulse counts this top-level collection path as one monitored system.',+ reasons: [],+ surfaces: [],+ },+ latest_included_signal: {+ name: 'server-a',+ type: 'host',+ source: 'agent',+ at: '2026-01-01T00:00:00Z',+ },source: 'agent',- at: '2026-01-01T00:00:00Z',},- source: 'agent',- },- ],- total: 1,- limit: 10,- } as MonitoredSystemLedgerResponse);+ ],+ total: 1,+ limit: 10,+ }),+ );render(() => <MonitoredSystemLedgerPanel />);@@ -318,42 +419,45 @@ describe('MonitoredSystemLedgerPanel', () => {fireEvent.click(screen.getByRole('button', { name: 'View counting details' }));expect(- screen.getByText('Pulse counts this top-level collection path as one monitored system.'),- ).toBeInTheDocument();+ screen.getAllByText('Pulse counts this top-level collection path as one monitored system.'),+ ).toHaveLength(2);expect(screen.getByText('All included top-level collection paths currently report online status.'),).toBeInTheDocument();- expect(screen.queryByText('Included collection paths')).not.toBeInTheDocument();+ expect(screen.queryByText('Grouped sources')).not.toBeInTheDocument();});it('shows a customer-facing fallback when no included signal is available', async () => {- getLedgerMock.mockResolvedValue({- systems: [- {- name: 'server-c',- type: 'host',- status: 'unknown',- status_explanation: {- summary: 'Pulse cannot determine a canonical runtime status for this monitored system yet.',- reasons: [],- },- explanation: {- summary: 'Pulse counts this top-level collection path as one monitored system.',- reasons: [],- surfaces: [],- },- latest_included_signal: {+ explainMock.mockResolvedValue(+ explainResponse({+ systems: [+ {name: 'server-c',type: 'host',+ status: 'unknown',+ status_explanation: {+ summary:+ 'Pulse cannot determine a canonical runtime status for this monitored system yet.',+ reasons: [],+ },+ explanation: {+ summary: 'Pulse counts this top-level collection path as one monitored system.',+ reasons: [],+ surfaces: [],+ },+ latest_included_signal: {+ name: 'server-c',+ type: 'host',+ source: 'agent',+ at: '',+ },source: 'agent',- at: '',},- source: 'agent',- },- ],- total: 1,- limit: 10,- } as MonitoredSystemLedgerResponse);+ ],+ total: 1,+ limit: 10,+ }),+ );render(() => <MonitoredSystemLedgerPanel />);@@ -365,34 +469,36 @@ describe('MonitoredSystemLedgerPanel', () => {});it('falls back to the canonical status summary for the row status when status explanation is missing', async () => {- getLedgerMock.mockResolvedValue({- systems: [- {- name: 'server-d',- type: 'host',- status: 'offline',- status_explanation: {- summary:- 'At least one included source is offline or disconnected, so Pulse marks this monitored system as offline.',- reasons: [],- },- explanation: {- summary: 'Pulse counts this top-level collection path as one monitored system.',- reasons: [],- surfaces: [],- },- latest_included_signal: {+ explainMock.mockResolvedValue(+ explainResponse({+ systems: [+ {name: 'server-d',type: 'host',+ status: 'offline',+ status_explanation: {+ summary:+ 'At least one included source is offline or disconnected, so Pulse marks this monitored system as offline.',+ reasons: [],+ },+ explanation: {+ summary: 'Pulse counts this top-level collection path as one monitored system.',+ reasons: [],+ surfaces: [],+ },+ latest_included_signal: {+ name: 'server-d',+ type: 'host',+ source: 'agent',+ at: '2026-01-01T00:00:00Z',+ },source: 'agent',- at: '2026-01-01T00:00:00Z',},- source: 'agent',- },- ],- total: 1,- limit: 10,- } as MonitoredSystemLedgerResponse);+ ],+ total: 1,+ limit: 10,+ }),+ );render(() => <MonitoredSystemLedgerPanel />);@@ -410,11 +516,13 @@ describe('MonitoredSystemLedgerPanel', () => {});it('opens counting rules by default for usage-focused billing arrivals', async () => {- getLedgerMock.mockResolvedValue({- systems: [],- total: 2,- limit: 5,- } as MonitoredSystemLedgerResponse);+ explainMock.mockResolvedValue(+ explainResponse({+ systems: [],+ total: 2,+ limit: 5,+ }),+ );render(() => <MonitoredSystemLedgerPanel showCountingRulesByDefault />);diff --git a/frontend-modern/src/utils/__tests__/monitoredSystemPresentation.test.ts b/frontend-modern/src/utils/__tests__/monitoredSystemPresentation.test.tsindex ce263c60bc..b0ea727a50 100644--- a/frontend-modern/src/utils/__tests__/monitoredSystemPresentation.test.ts+++ b/frontend-modern/src/utils/__tests__/monitoredSystemPresentation.test.ts@@ -2,9 +2,11 @@ import { describe, expect, it } from 'vitest';import {formatMonitoredSystemAdmissionPreviewUnavailableMessage,+ formatMonitoredSystemGroupedSourcesLabel,formatMonitoredSystemLegacyConnectionBreakdown,getMonitoredSystemBriefSummary,formatMonitoredSystemLimitSummary,+ formatMonitoredSystemLedgerUnavailableMessage,formatMonitoredSystemLatestIncludedSignalSentence,formatMonitoredSystemMigrationMessage,formatMonitoredSystemOverflowSummary,@@ -18,6 +20,7 @@ import {getMonitoredSystemLedgerErrorState,getMonitoredSystemLedgerLoadingState,getMonitoredSystemLedgerPresentation,+ getMonitoredSystemLedgerUnavailableState,getMonitoredSystemLimitInstallCollectorsLabel,getMonitoredSystemLimitLearnMoreLabel,getMonitoredSystemLimitUpgradeLabel,@@ -41,6 +44,18 @@ describe('monitoredSystemPresentation', () => {tableNameLabel: 'Name',tableStatusLabel: 'Status',tableLatestIncludedSignalLabel: 'Latest Included Signal',+ countedSystemBadgeLabel: 'Counts as 1 monitored system',+ groupedSourcesHeading: 'Grouped sources',+ countingExplanationHeading: 'Why this counts',+ continuityHeading: 'Plan continuity',+ continuityPlanLimitLabel: 'Plan limit',+ continuityEffectiveLimitLabel: 'Effective limit',+ continuityGrandfatheredFloorLabel: 'Grandfathered floor',+ continuityCaptureLabel: 'Continuity capture',+ continuityCapturePendingLabel: 'Pending',+ continuityCaptureCapturedLabel: 'Captured',+ usageVerifyingLabel: 'Verifying…',+ unlimitedLimitLabel: 'Unlimited',loadingState: {text: 'Loading monitored system usage…',},@@ -49,6 +64,15 @@ describe('monitoredSystemPresentation', () => {retryingLabel: 'Trying again…',retryLabel: 'Try again',},+ unavailableState: {+ title: 'Verifying monitored-system inventory',+ fallbackMessage:+ 'Pulse cannot currently verify monitored-system usage for this installation. Refresh after the monitoring runtime settles.',+ unsettledMessage:+ 'Pulse is still collecting the first provider-owned inventory baseline. The monitored-system ledger will appear after that baseline completes.',+ rebuildPendingMessage:+ 'Pulse has collected provider-owned inventory and is rebuilding the canonical monitored-system ledger. Usage will appear when that rebuild finishes.',+ },countingDetailsCollapsedLabel: 'View counting details',countingDetailsExpandedLabel: 'Hide counting details',currentStatusHeading: 'Current status',@@ -101,6 +125,15 @@ describe('monitoredSystemPresentation', () => {retryingLabel: 'Trying again…',retryLabel: 'Try again',});+ expect(getMonitoredSystemLedgerUnavailableState()).toEqual({+ title: 'Verifying monitored-system inventory',+ fallbackMessage:+ 'Pulse cannot currently verify monitored-system usage for this installation. Refresh after the monitoring runtime settles.',+ unsettledMessage:+ 'Pulse is still collecting the first provider-owned inventory baseline. The monitored-system ledger will appear after that baseline completes.',+ rebuildPendingMessage:+ 'Pulse has collected provider-owned inventory and is rebuilding the canonical monitored-system ledger. Usage will appear when that rebuild finishes.',+ });expect(getMonitoredSystemCountingDetailsToggleLabel(false)).toBe('View counting details');expect(getMonitoredSystemCountingDetailsToggleLabel(true)).toBe('Hide counting details');expect(getMonitoredSystemExplanationFallbackSummary()).toBe(@@ -172,6 +205,20 @@ describe('monitoredSystemPresentation', () => {);});+ it('returns canonical monitored-system ledger unavailable copy', () => {+ expect(formatMonitoredSystemLedgerUnavailableMessage('supplemental_inventory_unsettled')).toBe(+ 'Pulse is still collecting the first provider-owned inventory baseline. The monitored-system ledger will appear after that baseline completes.',+ );+ expect(+ formatMonitoredSystemLedgerUnavailableMessage('supplemental_inventory_rebuild_pending'),+ ).toBe(+ 'Pulse has collected provider-owned inventory and is rebuilding the canonical monitored-system ledger. Usage will appear when that rebuild finishes.',+ );+ expect(formatMonitoredSystemLedgerUnavailableMessage('monitor_state_unavailable')).toBe(+ 'Pulse cannot currently verify monitored-system usage for this installation. Refresh after the monitoring runtime settles.',+ );+ });+it('returns customer-facing source and type labels', () => {expect(getMonitoredSystemSourceLabel('agent')).toBe('Agent');expect(getMonitoredSystemSourceLabel('multiple')).toBe('Multiple Sources');@@ -186,6 +233,8 @@ describe('monitoredSystemPresentation', () => {});it('formats included signal attribution and summary sentences', () => {+ expect(formatMonitoredSystemGroupedSourcesLabel(1)).toBe('1 grouped source');+ expect(formatMonitoredSystemGroupedSourcesLabel(2)).toBe('2 grouped sources');expect(formatMonitoredSystemSurfaceAttribution({name: 'tower',diff --git a/frontend-modern/src/utils/monitoredSystemPresentation.ts b/frontend-modern/src/utils/monitoredSystemPresentation.tsindex 6f0551d284..8816f722df 100644--- a/frontend-modern/src/utils/monitoredSystemPresentation.ts+++ b/frontend-modern/src/utils/monitoredSystemPresentation.ts@@ -21,6 +21,18 @@ const MONITORED_SYSTEM_LEDGER_PRESENTATION = {tableNameLabel: 'Name',tableStatusLabel: 'Status',tableLatestIncludedSignalLabel: 'Latest Included Signal',+ countedSystemBadgeLabel: 'Counts as 1 monitored system',+ groupedSourcesHeading: 'Grouped sources',+ countingExplanationHeading: 'Why this counts',+ continuityHeading: 'Plan continuity',+ continuityPlanLimitLabel: 'Plan limit',+ continuityEffectiveLimitLabel: 'Effective limit',+ continuityGrandfatheredFloorLabel: 'Grandfathered floor',+ continuityCaptureLabel: 'Continuity capture',+ continuityCapturePendingLabel: 'Pending',+ continuityCaptureCapturedLabel: 'Captured',+ usageVerifyingLabel: 'Verifying…',+ unlimitedLimitLabel: 'Unlimited',loadingState: {text: 'Loading monitored system usage…',},@@ -29,6 +41,15 @@ const MONITORED_SYSTEM_LEDGER_PRESENTATION = {retryingLabel: 'Trying again…',retryLabel: 'Try again',},+ unavailableState: {+ title: 'Verifying monitored-system inventory',+ fallbackMessage:+ 'Pulse cannot currently verify monitored-system usage for this installation. Refresh after the monitoring runtime settles.',+ unsettledMessage:+ 'Pulse is still collecting the first provider-owned inventory baseline. The monitored-system ledger will appear after that baseline completes.',+ rebuildPendingMessage:+ 'Pulse has collected provider-owned inventory and is rebuilding the canonical monitored-system ledger. Usage will appear when that rebuild finishes.',+ },countingDetailsCollapsedLabel: 'View counting details',countingDetailsExpandedLabel: 'Hide counting details',currentStatusHeading: 'Current status',@@ -101,6 +122,21 @@ export function getMonitoredSystemLedgerErrorState() {return MONITORED_SYSTEM_LEDGER_PRESENTATION.errorState;}+export function getMonitoredSystemLedgerUnavailableState() {+ return MONITORED_SYSTEM_LEDGER_PRESENTATION.unavailableState;+}++export function formatMonitoredSystemLedgerUnavailableMessage(reason?: string): string {+ switch (normalizeMonitoredSystemValue(reason)) {+ case 'supplemental_inventory_unsettled':+ return MONITORED_SYSTEM_LEDGER_PRESENTATION.unavailableState.unsettledMessage;+ case 'supplemental_inventory_rebuild_pending':+ return MONITORED_SYSTEM_LEDGER_PRESENTATION.unavailableState.rebuildPendingMessage;+ default:+ return MONITORED_SYSTEM_LEDGER_PRESENTATION.unavailableState.fallbackMessage;+ }+}+export function getMonitoredSystemCountingDetailsToggleLabel(expanded: boolean): string {return expanded? MONITORED_SYSTEM_LEDGER_PRESENTATION.countingDetailsExpandedLabel@@ -198,6 +234,10 @@ export function formatMonitoredSystemLatestIncludedSignalSentence(signal: {return `${MONITORED_SYSTEM_LEDGER_PRESENTATION.latestIncludedSignalSummaryLabel}: ${signal.attribution}, reported ${signal.relative}.`;}+export function formatMonitoredSystemGroupedSourcesLabel(count: number): string {+ return `${count} grouped ${count === 1 ? 'source' : 'sources'}`;+}+export function getMonitoredSystemSourceLabel(source: string | undefined): string {switch (normalizeMonitoredSystemValue(source)) {case 'agent':diff --git a/tests/integration/tests/54-monitored-system-billing-focus.spec.ts b/tests/integration/tests/54-monitored-system-billing-focus.spec.tsindex dd09813ccb..0563c08a02 100644--- a/tests/integration/tests/54-monitored-system-billing-focus.spec.ts+++ b/tests/integration/tests/54-monitored-system-billing-focus.spec.ts@@ -144,11 +144,14 @@ async function configureMonitoredSystemBillingFixtures(page: Page) {});});- await page.route('**/api/license/monitored-system-ledger', async (route) => {+ await page.route('**/api/license/monitored-system-ledger**', async (route) => {+ const payload = route.request().url().endsWith('/explain')+ ? { ledger: MONITORED_SYSTEM_LEDGER, preview: null }+ : MONITORED_SYSTEM_LEDGER;await route.fulfill({status: 200,contentType: 'application/json',- body: JSON.stringify(MONITORED_SYSTEM_LEDGER),+ body: JSON.stringify(payload),});});}@@ -180,6 +183,16 @@ test.describe('Monitored-system billing focus', () => {'true',);await expect(page.getByRole('button', { name: 'Hide counting rules' })).toBeVisible();+ await expect(page.getByText('Counts as 1 monitored system')).toBeVisible();+ await expect(page.getByText('1 grouped source')).toBeVisible();+ await expect(+ page+ .getByText(+ 'Counts as one monitored system because Pulse merged multiple top-level views into one canonical cluster.',+ )+ .first(),+ ).toBeVisible();+ await expect(page.getByText('edge-cluster (Cluster via Kubernetes)').first()).toBeVisible();await openPageWithUrgentMonitoredSystemBanner(page);diff --git a/tests/integration/tests/55-self-hosted-upgrade-return.spec.ts b/tests/integration/tests/55-self-hosted-upgrade-return.spec.tsindex cde82f1d15..8da8c2c6bd 100644--- a/tests/integration/tests/55-self-hosted-upgrade-return.spec.ts+++ b/tests/integration/tests/55-self-hosted-upgrade-return.spec.ts@@ -331,9 +331,12 @@ async function configureBillingFixtures(context: BrowserContext, page: Page) {});await context.route(- "**/api/license/monitored-system-ledger",+ "**/api/license/monitored-system-ledger**",async (route) => {- await fulfillJSON(route, MONITORED_SYSTEM_LEDGER);+ const payload = route.request().url().endsWith("/explain")+ ? { ledger: MONITORED_SYSTEM_LEDGER, preview: null }+ : MONITORED_SYSTEM_LEDGER;+ await fulfillJSON(route, payload);},);}