fix(alarms): #951 #952 #953 — late refusal reverts, never-started command is NotApplied, superseded load failure ignored
#951: the hosted-service Ask lives LateVerdictWindow (30 s) past the caller's bound (ExecuteAlarmCommand deadline unchanged); the OutcomeUnknown it returns carries the still-running ask as AlarmCommandOutcome.LateOutcome (process-local). The node manager watches it (or the asker task itself when its backstop expired, following unknown chains) and reverts the node on a late NotApplied, under the existing per-condition mutation-counter guard. Both CallAsync and remote ExecuteConditionMethodAsync paths. #952: ScriptedAlarmEngine throws ScriptedAlarmCommandNotStartedException (an OCE) when a command is cancelled before it acquires _evalGate; a cancellation inside SaveAsync stays a plain OCE (unknown). The host maps not-started to NotApplied and remembers it, except on the direct ask once its asker's deadline passed (asker already answered unknown and broadcast): then unknown + not remembered, so the broadcast copy decides (as review r2 M2). #953: a faulted load pipes back AlarmsLoadFailed(cause, generation); a failure from a generation a newer apply superseded publishes no readiness (it would refuse every command while the newer load is in flight). Red/green: each fix reverted individually turns its tests red (Core 1, Runtime 3, Host 1, OpcUaServer.IntegrationTests 4). Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+26
-2
@@ -453,7 +453,8 @@ of which blocks under the node manager's `Lock`:
|
||||
|---|---|
|
||||
| applied (incl. an idempotent no-op) | `Good` |
|
||||
| refused — last load failed, alarm not loaded on this node (incl. the window after a host supervision restart before its reload), malformed command, no engine on this node | `BadInvalidState` (node reverted; the peer never received it) |
|
||||
| no answer within min(5 s, request deadline − 250 ms), or the engine op timed out / failed in the store | `BadTimeout` / `BadInternalError`, diagnostic "OutcomeUnknown" — the command **may still apply**, never reported as refused |
|
||||
| no answer within min(5 s, request deadline − 250 ms), or the engine op timed out / failed in the store | `BadTimeout` / `BadInternalError`, diagnostic "OutcomeUnknown" — the command **may still apply**, never reported as refused (a refusal that arrives later still reverts the node, #951) |
|
||||
| the engine never started it — still waiting for the engine gate (e.g. behind a long load) when the host's 10 s op bound expired (#952) | `BadInvalidState` while the asker still waits (definite: nothing ran); once the asker has already answered OutcomeUnknown and broadcast it, the host answers unknown and lets the broadcast copy decide |
|
||||
|
||||
`BadInvalidState` is Part 4's general "object … uninitialized or in some other invalid state" code; Part 9's method result
|
||||
codes (bad EventId, already acked/confirmed/shelved, disabled, shelving time out of range) do not cover "the state owner
|
||||
@@ -475,9 +476,32 @@ Before #937 such a call returned Good and the broadcast let the peer apply it.
|
||||
every reported condition event and every accepted method) is unchanged since the method — a field comparison missed a
|
||||
Timed→Timed re-shelve or a ClientUserId change. The captured raw severity is restored as captured.
|
||||
|
||||
**Late refusal (#951).** The caller's bound expiring no longer drops the host's answer: the hosted service's Ask lives
|
||||
`ScriptedAlarmCommandDispatch.LateVerdictWindow` (30 s) past the bound (the `ExecuteAlarmCommand` deadline is still the
|
||||
caller's bound), and the OutcomeUnknown it returns carries the still-running ask as `AlarmCommandOutcome.LateOutcome`
|
||||
(process-local). The node manager watches it (also the asker task itself when its own backstop expired, following a chain of
|
||||
unknowns): a late `NotApplied` — e.g. a command queued behind a load that then failed — reverts the node exactly like an in-time
|
||||
refusal, under the same mutation-counter guard; a late Applied / unknown / no answer leaves the node. The caller has already
|
||||
been told `BadTimeout`, and the peer already got the broadcast; the local host remembered the refusal by `CommandId`, so the
|
||||
local broadcast copy is not applied either — the reverted node matches the local engine.
|
||||
|
||||
**A command the engine never started (#952).** `ScriptedAlarmEngine` throws `ScriptedAlarmCommandNotStartedException` (an
|
||||
`OperationCanceledException`) when an operator command's token fires while it is still waiting for the evaluation gate —
|
||||
nothing was looked up or saved. A cancellation inside the store save stays a plain cancellation (it may have committed ⇒
|
||||
unknown). The host maps not-started to `NotApplied` and remembers it, except on the direct ask once its asker's deadline has
|
||||
passed: that asker already answered OutcomeUnknown and broadcast the command, so — like an ask that expired before it started
|
||||
— the host answers unknown and does not remember it, and the broadcast copy decides locally too.
|
||||
|
||||
**Superseded load failure (#953).** A failed load pipes back with its load generation; a failure from a generation a newer
|
||||
apply has already superseded publishes nothing to the readiness view (the newer load is in flight and has typically cleared
|
||||
the engine's complete-generation flag, so reading it would refuse every command until that load completes — the view must
|
||||
let through while a load is pending; the engine queues a command behind it). The newer load publishes its own outcome.
|
||||
|
||||
**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.
|
||||
may still apply it) unless a late refusal arrives inside the late window (#951). A command whose direct ask gave up and whose
|
||||
broadcast copy is then refused by the local engine (no one awaits a broadcast copy) still keeps the node change until the
|
||||
next good deploy re-asserts 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").
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ origin `ack` ⇒ `Acknowledge successful` (positive control).
|
||||
| nits | stale hosted-service comment; severity 0 ⇒ 1 on revert | Fixed (comment says ask-then-broadcast; the raw captured severity is restored). | — |
|
||||
| SDK check | Does any Part 9 handler call our delegate before its own validation? | **No** (decompiled SDK 2.0.1): Acknowledge/Confirm/AddComment run the delegate at the END of `ProcessBefore*` (after EventId/Enabled/already-acked/IsLive); the three shelve methods after Enabled + `IsCausePermitted` (+ shelving-time range); Enable/Disable after the already-enabled checks. Nothing after a Good delegate can turn the call Bad, so a started ask is always awaited. (Branch acks would recurse into a branch's own delegate — this server creates no branches.) | — |
|
||||
|
||||
Follow-ups (not fixed): **L2** a late refusal that arrives after the ask's timeout (the caller got OutcomeUnknown) is never reverted; **L3** a command cancelled while waiting on `_evalGate` (nothing applied) is reported OutcomeUnknown, not NotApplied; **L4** `OnLoadFailed` reads `HasCompleteGeneration` while a newer load may already be running (transiently refuses during that load).
|
||||
Follow-ups (filed as #951 / #952 / #953, since fixed — see `docs/ScriptedAlarms.md` §"Late refusal (#951)" and the two paragraphs after it): **L2** a late refusal that arrives after the ask's timeout (the caller got OutcomeUnknown) is never reverted; **L3** a command cancelled while waiting on `_evalGate` (nothing applied) is reported OutcomeUnknown, not NotApplied; **L4** `OnLoadFailed` reads `HasCompleteGeneration` while a newer load may already be running (transiently refuses during that load).
|
||||
|
||||
Gates (round 2): build 0 warnings / 0 errors; OpcUaServer.Tests 1460 passed / 2 skipped; OpcUaServer.IntegrationTests 441 / 39 skipped;
|
||||
Runtime.Tests 2122 / 3 skipped; Host.Tests 503; Commons.Tests 513; Core.ScriptedAlarms.Tests 147. No live re-run (the dispatch
|
||||
|
||||
Reference in New Issue
Block a user