From 4d41e61858d315f30b94da77bf68189ceee5e394 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sat, 28 Nov 2026 10:41:39 -0500 Subject: [PATCH] docs(#937): CallAsync remarks + evidence skeleton Co-Authored-By: Claude --- docs/plans/evidence/followups/937.md | 50 +++++++++++++++++++ .../ImportedConditionMethods.cs | 6 ++- 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 docs/plans/evidence/followups/937.md diff --git a/docs/plans/evidence/followups/937.md b/docs/plans/evidence/followups/937.md new file mode 100644 index 000000000..d8ccf8743 --- /dev/null +++ b/docs/plans/evidence/followups/937.md @@ -0,0 +1,50 @@ +# #937 — a rejected scripted-alarm command is reported Good to the caller + +Follow-up to #935. After a failed scripted-alarm load the engine rejects operator commands +(`ScriptedAlarmCommandRejectedException`), but the `alarm-commands` topic is fire-and-forget, so the OPC UA Part 9 method +(and a remote gRPC-data `CallConditionMethod`) had already returned Good. + +## What changed + +| Layer | Change | +|---|---| +| Pre-check | `ScriptedAlarmCommandReadinessView` (Runtime singleton) holds the host's latest completed load outcome. `HandleAlarmCommand` reads it (one volatile read, under `Lock`) after the role/ACL gate and the Warm-standby check: last load failed ⇒ `BadInvalidState`, nothing applied/routed/reported. | +| Bounded ask | `OtOpcUaNodeManager.CallAsync` (off `Lock`) runs each local request through `base.Call` alone with an `AsyncLocal` verdict slot. The handler only STARTS `AlarmCommandAsker` (non-blocking) and returns Good; the Call awaits the verdict after `Lock` is released. Applied ⇒ Good; NotApplied ⇒ `BadInvalidState`; no answer within min(5 s, deadline − 250 ms) ⇒ `BadTimeout` "OutcomeUnknown" (never "refused" — it may still apply). | +| Host | `OtOpcUaServerHostedService.AskScriptedAlarmCommand`: broadcast on `alarm-commands` for the redundant peer (unchanged semantics) + `DriverHostActor` → `ScriptedAlarmHostActor.ExecuteAlarmCommand` on the LOCAL engine. Fresh `AlarmCommand.CommandId` (additive, wire-compatible) ⇒ the local host applies the ask/broadcast copies once (bounded 1024-entry memo). Ownership = latest plan set ∪ engine set (stable across an in-flight / failed load). | +| A2b origin | `IOriginConditionSource.ExecuteConditionMethodAsync` (DIM default = the sync verdict). `LocalDataServices` maps a post-dispatch refusal ⇒ `DriverConfirmedFailure`, no answer ⇒ `OutcomeUnknown`. | +| Redundancy | The verdict is the local engine's (it projects the local node). The peer applies its broadcast copy independently, as before. | + +Status choice: Part 9's method result codes do not cover "the state owner cannot act"; Part 4 `Bad_InvalidState` ("object … +uninitialized or in some other invalid state") does, and the server already uses it for a native ack off-Primary. + +## Residual / not covered + +- A refusal that arrives through the ask (a load in flight when the command queued, which then failed) leaves the SDK-applied + node change (and its one event) until the next good deploy re-asserts the node; the caller gets `BadInvalidState`. +- AdminUI `/alerts` buttons remain fire-and-forget across the central→node transport (DPS fan or one gRPC `Execute` per + node, `ExecuteAck` = "handed to the comm actor") — follow-up. +- Accepted (#935) trade-off, documented: one transient failed deploy = one duplicate activation per still-true alarm. + +## Red / green + +| Test | Red | +|---|---| +| `ScriptedCommandVerdictWireTests` (OpcUaServer.IntegrationTests, 8: refusal ×4 methods, applied + one event, timeout, preflight + sentinel + positive control, remote `ExecuteConditionMethodAsync`) | 8/8 red with the pre-check and the ask disabled in `HandleAlarmCommand` (every call Good) | +| `ScriptedAlarmCommandVerdictTests` (Runtime.Tests, 4) | dedupe theory 2/2 red with the `CommandId` memo disabled; the rest are new API | +| `GrpcDataConditionMethodTests.A_scripted_engine_verdict_after_dispatch_…` | new outcome fields | + +## Gates + +| Gate | Result | +|---|---| +| `dotnet build -c Release` (solution) | 0 warnings / 0 errors | +| OpcUaServer.Tests | 1460 passed, 2 skipped | +| OpcUaServer.IntegrationTests | 432 passed, 39 skipped | +| Runtime.Tests | 2097 passed, 3 skipped | +| Host.Tests (incl. `GrpcDataV1CompatibilityTests`) | 497 passed | +| Commons.Tests / Core.ScriptedAlarms.Tests | 512 / 146 passed | +| grpc-data python `tests/test_scenarios.py` | 31 passed | + +## Live leg + +LIVE_RESULTS_PLACEHOLDER diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/ImportedConditionMethods.cs b/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/ImportedConditionMethods.cs index 6317f1b0c..ef70a9831 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/ImportedConditionMethods.cs +++ b/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/ImportedConditionMethods.cs @@ -98,8 +98,10 @@ public sealed partial class OtOpcUaNodeManager : ICallAsyncNodeManager /// /// §5.6 step 1: (a) claim every unprocessed request whose ObjectId is in mapped/conditions — a namespace-index - /// test, no lock; (b) the unchanged synchronous base.Call for everything else (it skips claimed requests), run - /// and completed before any remote await; (c) the claimed calls concurrently, bounded by the per-node semaphore. + /// test, no lock; (b) the synchronous base.Call for everything else (it skips claimed requests), run and + /// completed before any remote await — per request, plus the scripted-alarm engine's verdict awaited off Lock, + /// when an is wired (#937, ); (c) the claimed calls + /// concurrently, bounded by the per-node semaphore. /// No Lock is held by this method at any point. Review S1: nothing after base.Call throws — local items are /// already applied by then, so a fault there must become a per-item status, never a ServiceFault for the batch. ///