diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/ProjectedConditionRegistry.cs b/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/ProjectedConditionRegistry.cs
index 607766e47..cf76bfe5e 100644
--- a/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/ProjectedConditionRegistry.cs
+++ b/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/ProjectedConditionRegistry.cs
@@ -709,6 +709,14 @@ public sealed partial class OtOpcUaNodeManager : IProjectedConditionSink
IsImportedConditionId(nodeId) ? AuthorizeImportedCondition(identity, operation, nodeId) : null;
/// Test observation: whether a projected folder is currently wired as a notifier of some imported condition.
+ /// Test observation (A4 review r2): a projected folder's EventNotifier (null when it is no known projected folder).
+ internal byte? ProjectedFolderEventNotifier(NodeId folderId)
+ {
+ lock (Lock)
+ return _importedConditions.FolderKeys.TryGetValue(folderId, out var key) && FindProjectedFolder(key) is { } folder
+ ? folder.EventNotifier : null;
+ }
+
internal bool IsImportedNotifierWired(NodeId folderId)
{
lock (Lock) return _importedConditions.WiredByFolder.ContainsKey(folderId);
diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests/ImportedConditionEventWireTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests/ImportedConditionEventWireTests.cs
index f2f6c335e..086e3407c 100644
--- a/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests/ImportedConditionEventWireTests.cs
+++ b/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests/ImportedConditionEventWireTests.cs
@@ -342,21 +342,39 @@ public sealed class ImportedConditionEventWireTests
var f = Fixture.Install(rig, access);
using var granted = await rig.ConnectAsync(anonymous: false, ct);
- // Control (the defect's precondition): while the mapping is not condition-bearing the folder is no notifier — refused.
+ // Control (the defect's precondition): while the mapping is not condition-bearing even a granted caller is refused — by
+ // the mapping gate, as the real one does (review r2 NIT: BadUserAccessDenied, not the SDK's BadNotSupported).
var early = await SubscribeAsync(granted, new Events(), ct);
var refused = AddItem(early, f.AnchorB);
await early.ApplyChangesAsync(ct);
- (refused.Status.Error?.StatusCode ?? StatusCodes.Good).Code.ShouldBe(StatusCodes.BadNotSupported.Code, "not condition-bearing yet");
+ (refused.Status.Error?.StatusCode ?? StatusCodes.Good).Code.ShouldBe(StatusCodes.BadUserAccessDenied.Code, "not condition-bearing yet");
access.ConditionBearing = true; // the authority activates after materialisation (first barrier of a restarted consumer)
+
+ // Review r2 NIT, negative case: an UNGRANTED caller is refused by the mapping gate before any promotion — the folder's
+ // EventNotifier is unchanged, so a refusal cannot be used to flip (or probe) notifier state.
+ using var ungranted = await rig.ConnectAsync(anonymous: true, ct);
+ var before = EventNotifier(rig, f.AnchorB);
+ (before & EventNotifiers.SubscribeToEvents).ShouldBe((byte)0, "precondition: not yet promoted");
+ var deniedSub = await SubscribeAsync(ungranted, new Events(), ct);
+ var denied = AddItem(deniedSub, f.AnchorB);
+ await deniedSub.ApplyChangesAsync(ct);
+ denied.Status.Error?.StatusCode.Code.ShouldBe(StatusCodes.BadUserAccessDenied.Code);
+ (EventNotifier(rig, f.AnchorB)).ShouldBe(before, "an ungranted caller never promotes the folder");
+ access.Outstanding.ShouldBe(0, "a refused caller opens no condition demand");
+
var events = new Events();
var sub = await SubscribeAsync(granted, events, ct);
var item = AddItem(sub, f.AnchorB);
await sub.ApplyChangesAsync(ct);
(item.Status.Error?.StatusCode ?? StatusCodes.Good).Code.ShouldBe(StatusCodes.Good.Code, "folder-first item admitted");
access.Outstanding.ShouldBe(1, "the folder-only client opened condition demand");
+ (EventNotifier(rig, f.AnchorB) & EventNotifiers.SubscribeToEvents).ShouldNotBe((byte)0,
+ "positive control: the granted caller's admission promoted it");
f.Apply(Update(Key2, version: 3, active: true, acked: false, [f.BPlacement()], message: "arrived-f4"));
await Events.WaitUntilAsync(() => events.Of(item).Any(e => Message(e) == "arrived-f4"));
+
+ static byte EventNotifier(ServerEventRig rig, NodeId folder) => rig.Nm.ProjectedFolderEventNotifier(folder).ShouldNotBeNull();
}
[Fact]
@@ -484,8 +502,9 @@ public sealed class ImportedConditionEventWireTests
public bool CanSee(RoleCarryingUserIdentity? caller, IReadOnlyList placements) =>
caller is not null && Allowed.Contains(caller.Principal);
public long AuthorityGeneration => Interlocked.Read(ref Generation);
+ /// Review r2 NIT: like the real mapping gate, a mapping that is not condition-bearing admits nobody.
public bool CanSubscribeFolder(RoleCarryingUserIdentity? caller, string mappingId, string folderLocalSubject) =>
- caller is not null && Allowed.Contains(caller.Principal);
+ caller is not null && ConditionBearing && Allowed.Contains(caller.Principal);
/// A4 F4: false models a mapping whose authority was not yet active when its folders materialised.
public volatile bool ConditionBearing = true;
public bool IsConditionBearingMapping(string mappingId) => ConditionBearing;
diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests/ImportedConditionMethodWireTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests/ImportedConditionMethodWireTests.cs
index 4619bddfb..a0f61551e 100644
--- a/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests/ImportedConditionMethodWireTests.cs
+++ b/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests/ImportedConditionMethodWireTests.cs
@@ -164,6 +164,43 @@ public sealed class ImportedConditionMethodWireTests
_ = refresh; // review S6: the RefreshRequired itself is pinned over the wire by A_resync_that_cannot_re_bind_…
}
+ ///
+ /// A4 review r2 NIT (F1 EventId retention across a held-set takeover, previously only live-gated by A03): the consumer
+ /// holds its conditions across its own deploy and the next runner re-snapshots ONTO the same nodes. What reaches the
+ /// node manager is a restart of the stream's versions with the same marker — and, after an origin reload restatement
+ /// (#935), a new record time. The condition instance, its current EventId and every older still-retained EventId stay
+ /// bound, no event is reported; the takeover's RefreshRequired is not a condition event either.
+ ///
+ [Fact]
+ public async Task R2_a_takeover_re_snapshot_with_the_same_marker_keeps_the_instance_and_every_retained_EventId()
+ {
+ var ct = TestContext.Current.CancellationToken;
+ await using var rig = await ServerEventRig.StartAsync("a4-r2-takeover", encrypted: false, ct);
+ var f = Fixture.Install(rig);
+ var t0 = DateTimeOffset.UtcNow.AddMinutes(-1);
+ f.Apply(Update(version: 3, active: true, acked: false, time: t0, message: "first"));
+ var older = f.CurrentEventId();
+ f.Apply(Update(version: 4, active: true, acked: false, time: t0.AddSeconds(1), message: "second"));
+ var current = f.CurrentEventId();
+ current.ShouldNotBe(older, "positive control: a real transition mints a new EventId");
+ var instance = rig.Nm.FindImportedCondition(Connection, Key1);
+ var reported = rig.Nm.ImportedEventsReported;
+
+ // The takeover runner's first snapshot: versions restart (new stream), same marker, a restated (newer) record time.
+ f.Apply(Update(version: 1, active: true, acked: false, time: t0.AddSeconds(30), message: "second"));
+ rig.Nm.RequireRefresh(Connection);
+ ReferenceEquals(rig.Nm.FindImportedCondition(Connection, Key1), instance).ShouldBeTrue("the same condition object — not removed and re-created");
+ f.CurrentEventId().ShouldBe(current, "no event, no new EventId");
+ rig.Nm.ImportedEventsReported.ShouldBe(reported, "an unchanged occurrence reports nothing");
+
+ using var session = await rig.ConnectAsync(anonymous: false, ct);
+ var id = f.ConditionId(session);
+ (await CallAsync(session, id, MethodIds.AcknowledgeableConditionType_Acknowledge, older, "older", ct)).ShouldBe(StatusCodes.Good);
+ (await CallAsync(session, id, MethodIds.AcknowledgeableConditionType_Acknowledge, current, "current", ct)).ShouldBe(StatusCodes.Good);
+ f.Port.Calls.Count.ShouldBe(2);
+ f.Port.Calls.ShouldAllBe(c => c.ExpectedActivation == Marker1);
+ }
+
///
/// §5.6 step 6 / §9.3 L3 (hard gate): the origin's method handler stalls 5 s. Read, Browse and a data Publish on the
/// consumer complete in < 200 ms meanwhile, the node manager's Lock is free, and no acknowledged state is