feat(grpc-data): A1 initial-alarm-state signal in DriverInstanceActor/DriverHostActor — ordered forward, MarkConditionsKnown routing, OpcUaClient backstop, F5 signal timeout + diagnostic

This commit is contained in:
Joseph Doherty
2026-11-24 09:30:32 -05:00
parent d64578b1c5
commit ffdaa73d0c
5 changed files with 341 additions and 5 deletions
@@ -59,7 +59,7 @@ namespace ZB.MOM.WW.OtOpcUa.Runtime.Drivers;
/// fabricates a batch of the same shape straight to the dependency mux, so the host neither receives nor
/// sends a per-value message any more (the per-value record is deleted).
/// </summary>
public sealed class DriverHostActor : ReceiveActor, IWithTimers, IWithUnboundedStash
public sealed partial class DriverHostActor : ReceiveActor, IWithTimers, IWithUnboundedStash
{
/// <summary>Replace the bounded physical gRPC interest for one driver; empty removes it.</summary>
public sealed record ApplyAcquisitionDemand(string DriverInstanceId, IReadOnlyList<string> FullReferences,
@@ -874,7 +874,8 @@ public sealed class DriverHostActor : ReceiveActor, IWithTimers, IWithUnboundedS
DataWriteRuntime? dataWriteRuntime = null,
SubscriptionAcquisitionCapacity? acquisitionCapacity = null,
DataConnectionDeploymentRuntime? dataConnections = null,
ActorProjectedValuePublisher? projectedPublisher = null) =>
ActorProjectedValuePublisher? projectedPublisher = null,
ConditionSignalOptions? conditionSignals = null) =>
// WARNING: this forwarding list is POSITIONAL, and Props.Create compiles it into an
// expression tree. Six IActorRef? parameters and several interface-typed ones mean a
// mis-ordered argument is usually type-compatible and therefore compiles clean, then binds
@@ -889,7 +890,8 @@ public sealed class DriverHostActor : ReceiveActor, IWithTimers, IWithUnboundedS
sharesHistorizationScopeWithLocal, applyWedgeTimeout, reprovisionBackoff, commsRecoveryAuditDelay,
sharesAlarmQueueWithLocal, applyOutcomeTimeout, captureWhilePrimaryUnreachable, historyUpdateRoleView,
scripting, ackPreflightView, writeBounds, writeClock, scriptedAlarmRunner, childShutdownTimeout,
enforceSnapshotOrdering, sourcePublisher, catalogCoordinator, dataWriteRuntime, acquisitionCapacity, dataConnections, projectedPublisher));
enforceSnapshotOrdering, sourcePublisher, catalogCoordinator, dataWriteRuntime, acquisitionCapacity, dataConnections, projectedPublisher,
conditionSignals));
/// <summary>Initializes a new DriverHostActor with the specified dependencies.</summary>
/// <param name="dbFactory">Database context factory for configuration database access.</param>
@@ -1031,8 +1033,10 @@ public sealed class DriverHostActor : ReceiveActor, IWithTimers, IWithUnboundedS
DataWriteRuntime? dataWriteRuntime = null,
SubscriptionAcquisitionCapacity? acquisitionCapacity = null,
DataConnectionDeploymentRuntime? dataConnections = null,
ActorProjectedValuePublisher? projectedPublisher = null)
ActorProjectedValuePublisher? projectedPublisher = null,
ConditionSignalOptions? conditionSignals = null)
{
_conditionSignals = conditionSignals ?? new ConditionSignalOptions();
_projectedPublisher = projectedPublisher;
_dataWriteRuntime = dataWriteRuntime;
_dataConnections = dataConnections;
@@ -1768,6 +1772,7 @@ public sealed class DriverHostActor : ReceiveActor, IWithTimers, IWithUnboundedS
Receive<ScriptedAlarmHostActor.ScriptedAlarmHostRestarted>(_ => HandleScriptedAlarmHostRestarted());
Receive<DriverInstanceActor.AttributeAlarmPublished>(ForwardNativeAlarm);
Receive<DriverInstanceActor.ConnectivityChanged>(OnDriverConnectivityChanged);
ReceiveConditionSignals();
Receive<CommsRecoveryAudit>(HandleCommsRecoveryAudit);
Receive<RestartDriver>(HandleRestartDriver);
Receive<DriverInstanceActor.ReprovisionRequested>(HandleReprovisionRequested);
@@ -1848,6 +1853,7 @@ public sealed class DriverHostActor : ReceiveActor, IWithTimers, IWithUnboundedS
Receive<ScriptedAlarmHostActor.ScriptedAlarmHostRestarted>(_ => HandleScriptedAlarmHostRestarted());
Receive<DriverInstanceActor.AttributeAlarmPublished>(ForwardNativeAlarm);
Receive<DriverInstanceActor.ConnectivityChanged>(OnDriverConnectivityChanged);
ReceiveConditionSignals();
Receive<CommsRecoveryAudit>(HandleCommsRecoveryAudit);
Receive<RestartDriver>(HandleRestartDriver);
Receive<DriverInstanceActor.ReprovisionRequested>(HandleReprovisionRequested);
@@ -2010,6 +2016,7 @@ public sealed class DriverHostActor : ReceiveActor, IWithTimers, IWithUnboundedS
// The mux fan-out is independent of the OPC UA sink — a node with scripted alarms but no
// publish actor (the mux-only test/dev path) must still see comms loss. Done before the early
// return for exactly that reason.
OnConditionSignalConnectivity(msg.DriverInstanceId, msg.Connected);
if (!msg.Connected)
{
if (!_retiredChildren.Contains(Sender) &&
@@ -2949,6 +2956,8 @@ public sealed class DriverHostActor : ReceiveActor, IWithTimers, IWithUnboundedS
Receive<DriverInstanceActor.AttributeAlarmPublished>(m =>
_log.Debug("DriverHost {Node}: dropping a native alarm transition ({Cond}) from {Id} while Stale",
_localNode, m.Args.ConditionId, m.DriverInstanceId));
// A1: a signal is dropped with the transitions it covers (no address space to mark), as are its timers.
ReceiveConditionSignalsWhileStale();
// A late artifact pipe-back from the apply that was in flight when the host fell Stale: that apply is
// lost (the coordinator's deadline and the boot-time orphan replay recover it). Warning, not Debug —
// an apply outcome is being discarded.
@@ -4671,6 +4680,7 @@ public sealed class DriverHostActor : ReceiveActor, IWithTimers, IWithUnboundedS
_dataWriteRuntime?.BeforeDriverStopForTests?.Invoke(driverInstanceId);
Context.Stop(entry.Actor);
_children.Remove(driverInstanceId);
ForgetConditionSignals(driverInstanceId);
PublishAckPreflight();
EvictRetainedValues(driverInstanceId);
// The instance left the plan (StopChild is only reached via plan.ToStop), so its cached