From e15bd7c9f96e61c74fbca8182a4c43603cc8bf51 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Tue, 24 Nov 2026 16:18:25 -0500 Subject: [PATCH] feat(grpc-data): A3 IProjectedConditionAccess / IProjectedConditionSink contracts --- .../IProjectedConditionAccess.cs | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/IProjectedConditionAccess.cs diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/IProjectedConditionAccess.cs b/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/IProjectedConditionAccess.cs new file mode 100644 index 000000000..41613492d --- /dev/null +++ b/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/IProjectedConditionAccess.cs @@ -0,0 +1,77 @@ +using ZB.MOM.WW.OtOpcUa.Core.Abstractions.DataConnections; +using ZB.MOM.WW.OtOpcUa.OpcUaServer.Security; + +namespace ZB.MOM.WW.OtOpcUa.OpcUaServer; + +/// +/// A3 (plan §5.2/§5.5): one current placement of an imported condition on this consumer — realm-consistent: the +/// placement address lives in the realm of 's export, and the folder it hangs under is a +/// projected node of that same mapping. +/// +/// The RemoteNamespaceMapping whose root item listed the placement. +/// The mapping's (and the placement's) realm. +/// The origin placement address (a listing view; never a cross-realm id). +/// +/// The LOCAL subject (slash-joined local scope segments) of the projected folder the placement sits under: the +/// mapping anchor's own subject when the placement's parent is the remote root. The node manager wires that folder +/// when (and only while) it is materialised (N7). +/// +/// The placement address relative to the mapping's remote root (display only). +public sealed record ImportedConditionPlacement(string MappingId, DataRealm Realm, DataView Placement, string FolderLocalSubject, + string RelativePath); + +/// +/// A3: one imported condition as the consumer's condition runtime hands it to the node manager — identity +/// (, ), its current placements (primary first) and +/// the origin record to mirror. The node manager mints the NodeId from the identity only (N4). +/// +/// The deployed DataConnection the condition was imported over. +/// The origin record (already version-gated by the runtime). +/// The condition's static facts (type, name, source kind); the latest one the stream carried. +/// Every current placement on this node, the PRIMARY one first (§5.2: deployed config only). +/// The primary placement's display path (§5.2). +public sealed record ImportedConditionUpdate(string ConnectionId, DataConditionState State, DataConditionInfo? Info, + IReadOnlyList Placements, string SourceName); + +/// +/// A3 (§5.3/§5.5): what the consumer's condition runtime tells the node manager. Every call is bounded per Lock hold by +/// the implementation; none blocks on the network. +/// +public interface IProjectedConditionSink +{ + /// Materialises new conditions and applies records through the shared #656 delta gate. + void ApplyConditions(IReadOnlyList updates); + + /// Removes conditions (an origin removed record, or a complete re-snapshot that no longer lists them). + void RemoveConditions(string connectionId, IReadOnlyCollection conditionKeys); + + /// The connection is gone past its stale timeout: Quality = BadNoCommunication, one event each. + void MarkConnectionStale(string connectionId); + + /// Sends RefreshRequiredEventType to every item that may see a condition of the connection. + void RequireRefresh(string connectionId); +} + +/// +/// A3 (§5.4/§5.5): the consumer's condition access — the per-caller visibility gate and per-connection demand. SDK-free +/// apart from the identity type, like . +/// +public interface IProjectedConditionAccess +{ + /// + /// The §5.4 gate: whether passes the mapping gate for CreateMonitoredItems + /// () on ANY current placement mapping. Evaluated regardless of + /// Security:Acl:Enabled. Null caller ⇒ false. + /// + bool CanSee(RoleCarryingUserIdentity? caller, IReadOnlyList placements); + + /// A generation that moves whenever anything the gate reads may have changed (verdict caches key on it). + long AuthorityGeneration { get; } + + /// + /// An admitted local event item that could see imported conditions (Server object or a projected notifier). The + /// first one opens condition demand for every connection the caller could see; disposing the last starts the linger. + /// Null when no connection carries conditions (nothing to open). + /// + IDisposable? AcquireEventDemand(RoleCarryingUserIdentity? caller); +}