fix(adminui): Faulted-devices tile counts distinct Faulted devices across the cluster pair (#786)

Owner decision 2026-11-11: /fleet/diagnostics "Faulted devices" counts DISTINCT
devices across the nodes of the selected node's cluster, Faulted state only.

- DriverHostActor: FaultedDevices = HostState.Faulted only (Stopped no longer
  counted); new StoppedDevices + FaultedHostNames. Counting extracted to the
  testable DiagnosticsFromHealth.
- DriverInstanceDiagnostics: StoppedDevices (default 0) and FaultedHostNames
  (default null) are additive with defaults, so a pre-#786 sender's snapshot
  still deserializes over Akka's default JSON serializer (pinned by a test).
- FleetDiagnosticsAggregation (pure): identity key = (driver-instance string
  id, HostName), case-insensitive; a single-host driver / nameless pre-#786
  count is combined by MAX across nodes, never summed. Cluster peers come from
  enabled ClusterNode rows of the selected node's ClusterId.
- FleetDiagnostics.razor: tile fetches the cluster peers and shows the
  distinct count + "n of m nodes answered"; per-driver table gains a Stopped
  devices column.

Claude-Session: https://claude.ai/code/session_01GT67AD99zQQqpLCVm3p7xk
This commit is contained in:
Joseph Doherty
2026-11-11 11:58:35 -05:00
parent e857135e8b
commit 43bdeff2b6
6 changed files with 437 additions and 10 deletions
@@ -2,13 +2,35 @@ using ZB.MOM.WW.OtOpcUa.Commons.Types;
namespace ZB.MOM.WW.OtOpcUa.Commons.Interfaces;
/// <summary>One driver child's row in a <see cref="NodeDiagnosticsSnapshot"/>.</summary>
/// <param name="DriverInstanceId">The driver instance's ConfigDb row id.</param>
/// <param name="Name">The string driver-instance id (the identity every other surface keys on).</param>
/// <param name="State">The child's last-published health state, or "Connecting" / "Stubbed".</param>
/// <param name="ConnectedDevices">Hosts in <c>Running</c> (or 1 for a Healthy/Degraded single-host driver).</param>
/// <param name="FaultedDevices">
/// Hosts in <c>Faulted</c> only (or 1 for a Faulted single-host driver). Since #786 a <c>Stopped</c> host is
/// NOT counted here — it is <paramref name="StoppedDevices"/>. A sender built before #786 still counts
/// Stopped hosts in this figure.
/// </param>
/// <param name="LastChangeUtc">When the child last published a changed health snapshot (its spawn time until the first).</param>
/// <param name="StoppedDevices">
/// Hosts in <c>Stopped</c> (#786). Additive with a default so a snapshot from an older sender — which has no
/// such member on the wire — still deserializes, reading 0.
/// </param>
/// <param name="FaultedHostNames">
/// The <c>HostName</c>s of the hosts counted in <paramref name="FaultedDevices"/> (#786), so the AdminUI can
/// count a device faulted on BOTH nodes of a redundant pair once. Empty for a single-host driver (the driver
/// itself is the device); <see langword="null"/> from a sender built before #786.
/// </param>
public sealed record DriverInstanceDiagnostics(
Guid DriverInstanceId,
string Name,
string State,
int ConnectedDevices,
int FaultedDevices,
DateTime LastChangeUtc);
DateTime LastChangeUtc,
int StoppedDevices = 0,
IReadOnlyList<string>? FaultedHostNames = null);
/// <summary>
/// Per-node diagnostics returned by <c>IFleetDiagnosticsClient</c>. Populated by the node's