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:
@@ -745,7 +745,16 @@ public sealed class ScriptedAlarmEngine : IDisposable
|
||||
private async Task ApplyAsync(string alarmId, CancellationToken ct, Func<AlarmConditionState, TransitionResult> op)
|
||||
{
|
||||
ScriptedAlarmEvent? pending = null;
|
||||
await _evalGate.WaitAsync(ct).ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await _evalGate.WaitAsync(ct).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException ex)
|
||||
{
|
||||
// #952: cancelled before the gate was acquired (SemaphoreSlim never acquires on a cancelled wait) — nothing
|
||||
// was applied or saved. Distinguished from a cancellation inside SaveAsync below, which may have committed.
|
||||
throw new ScriptedAlarmCommandNotStartedException(alarmId, ex);
|
||||
}
|
||||
try
|
||||
{
|
||||
// #937 review: no separate "not loaded" check before the gate any more — a command racing the FIRST load used
|
||||
|
||||
Reference in New Issue
Block a user