fix(runtime): #869 review round 3 — key a native-ack revert to the ack that failed
A pending local ack can outlive its own delivery (sources that send no Acknowledge back; a Clear now only carries it through), so a later failed re-ack — or a stale Galaxy confirmation timing out after the alarm re-occurred and was acked again — could revert an ack it does not own. MarkAcknowledged now issues a sequence (0 when the ack changed nothing), carried on RouteAlarmAck and echoed on AlarmAckFailed; TryRevertAcknowledge reverts only on a matching sequence. Claude-Session: https://claude.ai/code/session_01GT67AD99zQQqpLCVm3p7xk
This commit is contained in:
+19
@@ -83,6 +83,25 @@ public sealed class DriverInstanceActorAckConfirmationTests : RuntimeActorTestBa
|
||||
router.ExpectMsg<DriverInstanceActor.AlarmAckFailed>(Timeout, cancellationToken: TestContext.Current.CancellationToken).ConditionNodeId.ShouldBe("n-bad");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// lmxopcua#869 review — the failure echoes the routed ack's <see cref="DriverInstanceActor.RouteAlarmAck.AckSequence"/>,
|
||||
/// which is what lets the host revert only the acknowledge that failed (keyed in
|
||||
/// <c>NativeAlarmProjector.TryRevertAcknowledge(nodeId, ackSequence, …)</c>).
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void A_failed_confirmation_echoes_the_ack_sequence()
|
||||
{
|
||||
var driver = new ConfirmingDriver();
|
||||
var actor = SpawnConnected(driver);
|
||||
driver.Confirmation = () => Task.FromException(new DriverOperationRefusedException("unconfirmed"));
|
||||
var router = CreateTestProbe();
|
||||
|
||||
actor.Tell(Ack("n-seq") with { AckSequence = 42 }, router.Ref);
|
||||
|
||||
router.ExpectMsg<DriverInstanceActor.AlarmAckFailed>(Timeout, cancellationToken: TestContext.Current.CancellationToken)
|
||||
.AckSequence.ShouldBe(42L);
|
||||
}
|
||||
|
||||
private static DriverInstanceActor.RouteAlarmAck Ack(string conditionNodeId) =>
|
||||
new("Tank.Hi", "c", "alice", ConditionNodeId: conditionNodeId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user