fix(alarms): #937 review r2 — deadline/poison refusals unsent, Call size quota, expired asks skip the engine, mutation-counter revert guard

M1: a scripted method whose request deadline leaves < the dispatch floor, or that
follows an unanswered scripted method in the same Call, is refused BadTimeout in
its handler (unsent, unapplied); OpcUa:Quotas:MaxNodesPerMethodCall = 1000.
M2: ExecuteAlarmCommand carries the asker's deadline; an expired ask skips the
engine and is not remembered (the broadcast copy applies).
L1: revert guarded by a per-condition mutation counter; raw severity restored.
L5 + nits: docs, stale comment. SDK check: no Part 9 handler calls our delegate
before its own validation.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Joseph Doherty
2026-11-28 12:47:08 -05:00
parent 2d54d9d671
commit e42e666a1d
12 changed files with 249 additions and 25 deletions
@@ -94,7 +94,10 @@ public sealed class ScriptedAlarmHostActor : ReceiveActor
/// redundant peer; this host applies whichever copy arrives first and skips the other.
/// </summary>
/// <param name="Command">The command.</param>
public sealed record ExecuteAlarmCommand(AlarmCommand Command);
/// <param name="DeadlineUtc">#937 review r2 M2: when the asker stops waiting. An ask still queued past it is answered
/// without touching the engine (the asker reported OutcomeUnknown and broadcast the command; the broadcast copy decides
/// what this host applies). Null ⇒ no deadline.</param>
public sealed record ExecuteAlarmCommand(AlarmCommand Command, DateTime? DeadlineUtc = null);
/// <summary>
/// Told to the parent from <see cref="PostRestart"/>. A supervision restart is otherwise invisible to the
@@ -822,6 +825,18 @@ public sealed class ScriptedAlarmHostActor : ReceiveActor
return;
}
// Review r2 M2: the asker already gave up (OutcomeUnknown) and broadcast the command — applying it now, minutes late
// behind a stalled store, would only grow this mailbox. Skipped without touching the engine and NOT remembered, so
// the broadcast copy of the same command (which the peer also got) still applies here.
if (msg.DeadlineUtc is { } deadline && DateTime.UtcNow >= deadline)
{
_log.Warning("ScriptedAlarmHost: {Op} for alarm {AlarmId} skipped on the direct path — its asker stopped waiting; the broadcast copy applies",
cmd.Operation, cmd.AlarmId);
replyTo.Tell(new AlarmCommandOutcome(cmd.AlarmId, cmd.Operation, AlarmCommandVerdict.OutcomeUnknown,
"OutcomeUnknown: the ask expired before the engine reached it.", TimedOut: true));
return;
}
var outcome = Owns(cmd.AlarmId)
? await ApplyCommandAsync(cmd)
: new AlarmCommandOutcome(cmd.AlarmId, cmd.Operation, AlarmCommandVerdict.NotApplied,