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
+27 -5
View File
@@ -191,8 +191,8 @@ after a full rebuild, carrying the unchanged `LastTransitionUtc`. Decisions:
SDK applies anything (no event, nothing routed); a call that passed that pre-check and then met a rejection (it was queued
behind a load that failed) also returns `BadInvalidState` and the node is reverted — see
[Operator command verdicts](#operator-command-verdicts-937).
The AdminUI `/alerts` buttons still publish fire-and-forget ("Ack sent"), so for them the only record remains the host's
Warning `… NOT applied — …`. The next good load re-asserts every node from the store.
Since #950 the AdminUI `/alerts` buttons report it too ("Refused: …" — see [AdminUI path](#adminui-path)).
The next good load re-asserts every node from the store.
**Accepted trade-off:** because the next good load after a failed one reads the store (which has no `Active` column), each
alarm whose predicate is still true is a new occurrence — **one transient failed deploy costs one duplicate activation
(`Activated` + `Unacknowledged`, one `alerts` row) per still-true alarm** on the next good deploy.
@@ -478,8 +478,7 @@ Timed→Timed re-shelve or a ClientUserId change. The captured raw severity is r
**Residual.** Only the pre-check stops the SDK from applying the node change, so a refusal that arrives through the ask
shows subscribers two events: the method's, then the corrective one. An OutcomeUnknown leaves the node changed (the engine
may still apply it). A command racing the engine's first load queues behind it rather than failing.
**Not covered:** the AdminUI `/alerts` buttons are still fire-and-forget across the central→node transport (they report
"Ack sent", not "applied").
The AdminUI `/alerts` buttons report the engine's verdict too since #950 — see [AdminUI path](#adminui-path).
`OnTimedUnshelve` (the SDK's internal auto-unshelve timer, armed for the real remaining time since Gitea #597) is a **no-op**: the engine owns timed-shelve expiry via `ApplyShelvingCheck` (`system / AutoUnshelve`), and routing an `Unshelve` from the timer pre-empted that on every expiry as an operator-style unshelve from both pair nodes (review R1 M2).
@@ -489,7 +488,30 @@ may still apply it). A command racing the engine's first load queues behind it r
### AdminUI path
The AdminUI `/alerts` page (`Alerts.razor`) shows per-row **Acknowledge / Shelve / Unshelve** buttons. These are gated by the `DriverOperator` AdminUI policy and routed through the `AdminOperationsActor` cluster singleton (`AcknowledgeAlarmCommand` / `ShelveAlarmCommand`), which publishes onto the same `alarm-commands` topic. Cross-node routing is handled by the cluster singleton — the command always reaches the driver-role node hosting the engine that owns the alarm regardless of which AdminUI instance the operator is connected to. The Shelve button accepts a duration (minutes) and passes it to `ShelveAlarmAsync(Timed, unshelveAtUtc)`; result chips auto-clear after ~8 s. The `/alerts` and `/script-log` live-status pills reflect real feed health driven by the SignalR bridge actors' DPS subscription state.
The AdminUI `/alerts` page (`Alerts.razor`) shows per-row **Acknowledge / Shelve / Unshelve** buttons. These are gated by the `DriverOperator` AdminUI policy and routed through the `AdminOperationsActor` cluster singleton (`AcknowledgeAlarmCommand` / `ShelveAlarmCommand`), which publishes onto the same `alarm-commands` topic. Cross-node routing is handled by the cluster singleton — the command always reaches the driver-role node hosting the engine that owns the alarm regardless of which AdminUI instance the operator is connected to. The Shelve button accepts a duration (minutes) and passes it to `ShelveAlarmAsync(Timed, unshelveAtUtc)`; result chips auto-clear after ~8 s.
**The result chip is the engine's verdict (#950), not "sent".** For each request `AdminOperationsActor` spawns an
`AlarmCommandVerdictCollector`, which sends the command with `AlarmCommand.VerdictRequested` set and gathers every node's
answer for up to **7 s** (`AlarmCommandVerdictCollector.DefaultWindow`, under the client's 10 s ask), finishing early once
each node it sent to has answered:
- **gRPC command plane** (`MeshTransport:Mode=Grpc`, every split-topology deployment): `CentralCommunicationActor` tells the
collector the dialled `ClusterNode` set, then one verdict per node. A node handles a `verdict_requested`
`AlarmCommandMessage` by asking its driver host (`ScriptedAlarmHostActor.ExecuteAlarmCommand`, the #937 path, **no ask
deadline** — nothing else carries the command to that node, so a late engine still applies it), bounded at 5 s, and
returns the outcome in the additive `ExecuteAck.alarm_verdict`. A transport failure, a timed-out engine, or an **empty
ack (a node built before #950, which takes the old one-way path)** is that node's *unknown*.
- **DistributedPubSub** (`Dps`, single mesh): the command is published with the collector as the sender; each
`ScriptedAlarmHostActor` answers it — non-owners with `AlarmCommandOutcome.NotOwned` — and the collector expects one answer
per Up `driver` member. A node built before #950 (or a driver node with no scripted-alarm host) stays silent: that node is
*unknown* and the reply waits the full window.
Aggregation (`AlarmCommandVerdictAggregator`): **any owner applied ⇒ Applied** (green; "Applied on n of m servers" when a
peer owner refused or did not answer); else **any unknown ⇒ Outcome unknown** (amber — never "refused": that node may still
apply it); else an owner's refusal ⇒ **Refused: <reason>** (red); else no node owns the alarm ⇒ **Not applied**. The
per-node breakdown is in the chip's "Request details". A result with no verdict (a validation failure, a server fault, or a
pre-#950 admin singleton during a rolling upgrade) renders as before. Wire changes are additive both ways: a pre-#950
central never sets `verdict_requested`, so a new node serves it exactly as before. The `/alerts` and `/script-log` live-status pills reflect real feed health driven by the SignalR bridge actors' DPS subscription state.
Under redundancy, the `alerts` topic rows are deduplicated to the Primary node — see [Redundancy.md §Primary-gated alarm emission and historization](Redundancy.md#primary-gated-alarm-emission-and-historization).