fix(alarms): AdminUI /alerts ack/shelve reports the scripted engine's verdict (#950)

The /alerts buttons went central->node fire-and-forget and always showed
"Ack sent". AdminOperationsActor now spawns a per-request
AlarmCommandVerdictCollector (7 s window, under the client's 10 s ask) that
sends the command with AlarmCommand.VerdictRequested and gathers each node's
answer, finishing early once every node it sent to has answered.

- gRPC plane: CentralCommunicationActor tells the collector the dialled
  ClusterNode set and one verdict per node. A node handles a
  verdict_requested AlarmCommandMessage by asking its driver host
  (ScriptedAlarmHostActor.ExecuteAlarmCommand, the #937 path, no ask deadline,
  bounded 5 s) and returns it in the ADDITIVE ExecuteAck.alarm_verdict.
  Transport failure / timeout / empty ack (pre-#950 node) => that node unknown.
- DPS: published with the collector as sender; each ScriptedAlarmHostActor
  answers (non-owners NotOwned); expected set = Up driver members.
- Aggregation: any owner applied => Applied (partial noted); else any
  unknown/silent node => Outcome unknown (never "refused"); else owner
  refusal => Refused: <reason>; else no owner => Not applied.
- UI: green Applied / red Refused (reason) / amber Outcome unknown, per-node
  detail in the details pane; a verdict-less reply (validation, server fault,
  pre-#950 singleton) renders as before.

Wire is back-compatible both ways (new proto fields only; VerdictRequested and
NotOwned default false). Real-wire test through the real router, dialer,
interceptor and NodeCommandGrpcService (red without the node change).

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Joseph Doherty
2026-12-01 19:45:17 -05:00
parent 6b60845931
commit 09aaabbeef
28 changed files with 1451 additions and 72 deletions
@@ -788,12 +788,18 @@ public sealed class ScriptedAlarmHostActor : ReceiveActor
/// <param name="cmd">The inbound alarm command.</param>
private async Task OnAlarmCommand(AlarmCommand cmd)
{
// #950: central's AdminUI path publishes with its verdict collector as the sender and asks every host to answer —
// non-owners included, so the collector can stop waiting once each driver node has spoken. Any other publisher
// (the OPC UA broadcast, a pre-#950 central) gets no reply, exactly as before.
var replyTo = cmd.VerdictRequested && !Sender.IsNobody() ? Sender : null;
// #937: the broadcast copy of a command this host already took through ExecuteAlarmCommand (or the other way
// round) is applied once.
if (cmd.CommandId is { } id && _recentCommands.ContainsKey(id))
if (cmd.CommandId is { } id && _recentCommands.TryGetValue(id, out var known))
{
_log.Debug("ScriptedAlarmHost: skipping duplicate AlarmCommand {Op} for {AlarmId} (command {CommandId})",
cmd.Operation, cmd.AlarmId, id);
replyTo?.Tell(known);
return;
}
@@ -803,10 +809,14 @@ public sealed class ScriptedAlarmHostActor : ReceiveActor
{
_log.Debug("ScriptedAlarmHost: ignoring AlarmCommand {Op} for unowned alarm {AlarmId}",
cmd.Operation, cmd.AlarmId);
replyTo?.Tell(new AlarmCommandOutcome(cmd.AlarmId, cmd.Operation, AlarmCommandVerdict.NotApplied,
NotLoadedRefusal, NotOwned: true));
return;
}
Remember(cmd, await ApplyCommandAsync(cmd));
var outcome = await ApplyCommandAsync(cmd);
Remember(cmd, outcome);
replyTo?.Tell(outcome);
}
/// <summary>
@@ -840,7 +850,7 @@ public sealed class ScriptedAlarmHostActor : ReceiveActor
var outcome = Owns(cmd.AlarmId)
? await ApplyCommandAsync(cmd)
: new AlarmCommandOutcome(cmd.AlarmId, cmd.Operation, AlarmCommandVerdict.NotApplied,
_readiness?.Refusal() ?? NotLoadedRefusal);
_readiness?.Refusal() ?? NotLoadedRefusal, NotOwned: true);
Remember(cmd, outcome);
replyTo.Tell(outcome);