fix(opcua): #855 review 2 — frozen replay skips non-live conditions; per-hop ACL resolution; drain never inline
- QueueFrozenReplay's verdict refuses a condition a deploy removed or replaced since the cut (Server-object and folder), so the cut path cannot replay a ghost or judge a replaced scripted alarm on its old folder. - DeliverToNotifierItems resolves the #826 decision's item-independent part (live condition, notifier check, scopes) once per hop; only the grant and SDK role checks stay per item. - A deferred delivery's drain starts on the pool, never inline under Lock. - Test: a condition removed between the cut and its replay (folder + Server object). Claude-Session: https://claude.ai/code/session_01GT67AD99zQQqpLCVm3p7xk
This commit is contained in:
+63
@@ -426,6 +426,69 @@ public sealed class FolderConditionRefreshWireTests
|
||||
after.ShouldBeEmpty("and nothing reaches the item after RefreshEnd either");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// #855 review 2: a condition removed by a deploy between the cut and the queueing of its frozen replay must not be
|
||||
/// replayed — its frozen Retain=true state would be a ghost no Retain=false ever follows. ACL off, so nothing but the
|
||||
/// liveness check stands in the way.
|
||||
/// </summary>
|
||||
/// <param name="serverObject">Refresh a Server-object item instead of a folder item.</param>
|
||||
[Theory]
|
||||
[InlineData(false)]
|
||||
[InlineData(true)]
|
||||
public async Task A_condition_removed_between_the_cut_and_its_replay_is_not_replayed(bool serverObject)
|
||||
{
|
||||
var ct = TestContext.Current.CancellationToken;
|
||||
await using var rig = await ServerEventRig.StartAsync("Refresh855RemoveCut", encrypted: false, ct);
|
||||
rig.KeyRoles = [];
|
||||
rig.MaterialiseNative();
|
||||
rig.Enforce(false, [ServerEventRig.Key()], KeyEquipmentGrant(EqA));
|
||||
|
||||
// A second subscriber keeps EqA a notifier fan-out the stall applies to.
|
||||
using var other = await rig.ConnectAsync(anonymous: true, ct);
|
||||
var otherEvents = new RecordedEvents();
|
||||
var otherSub = await RecordedEvents.SubscribeAsync(other, otherEvents, ct);
|
||||
RecordedEvents.AddEventItem(otherSub, ServerEventRig.UnsNodeId(other, EqA));
|
||||
await otherSub.ApplyChangesAsync(ct);
|
||||
|
||||
using var session = await rig.ConnectAsync(anonymous: false, ct);
|
||||
var events = new RecordedEvents();
|
||||
var subscription = await RecordedEvents.SubscribeAsync(session, events, ct);
|
||||
var item = RecordedEvents.AddEventItem(subscription, serverObject ? ObjectIds.Server : ServerEventRig.UnsNodeId(session, EqA));
|
||||
await subscription.ApplyChangesAsync(ct);
|
||||
|
||||
rig.Project(native: true, Active("seed"));
|
||||
await RecordedEvents.WaitUntilAsync(() => events.Has(item, "seed"));
|
||||
|
||||
var removed = 0;
|
||||
void Remove(bool cut, bool _)
|
||||
{
|
||||
if (cut && Interlocked.Exchange(ref removed, 1) == 0)
|
||||
rig.Nm.RemoveAlarmConditionNode(ServerEventRig.RawAlarmPath, AddressSpaceRealm.Raw).ShouldBeTrue();
|
||||
}
|
||||
|
||||
if (serverObject) rig.Nm.ServerObjectRefreshProbe = Remove;
|
||||
else rig.Nm.DirectRefreshProbe = Remove;
|
||||
|
||||
using (var stall = NotifierStall.Hold(rig.Nm, EqA))
|
||||
{
|
||||
for (var i = 0; i < FloodSize; i++) rig.Project(native: true, Active($"f{i}"));
|
||||
rig.Nm.DeferredEventReports.ShouldBeGreaterThan(0);
|
||||
await session.CallAsync(ObjectTypeIds.ConditionType, MethodIds.ConditionType_ConditionRefresh, ct, subscription.Id);
|
||||
await RecordedEvents.WaitUntilAsync(() => events.HasType(item, ObjectTypeIds.RefreshEndEventType));
|
||||
stall.Release();
|
||||
}
|
||||
|
||||
rig.Nm.ServerObjectRefreshProbe = null;
|
||||
rig.Nm.DirectRefreshProbe = null;
|
||||
Volatile.Read(ref removed).ShouldBe(1, "the refresh took the cut path");
|
||||
await RecordedEvents.WaitUntilAsync(() => rig.Nm.DeferredEventReports == 0);
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(500), ct);
|
||||
|
||||
var (replayed, after) = Window(events.Of(item));
|
||||
replayed.ShouldBeEmpty("the condition was removed before its frozen replay was queued");
|
||||
after.ShouldBeEmpty("and none of its deferred events follows");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// #855 review: a delivery that fails inline (here: a hop that throws) is over, not suspended — it must not be booked
|
||||
/// as a deferral episode (which moved the episode a concurrent plain refresh checks, and cleared cuts under the
|
||||
|
||||
Reference in New Issue
Block a user