docs(grpc-data): A4 docs — feature negotiation, imported conditions end to end, method status table, limits, security, ScadaBridge impact

DataConnections.md: x-otopcua-data-features negotiation; condition forwarding (key secret, bits 64/128/256, AllowGalaxyServiceAck,
methods + status codes, limits/defaults, troubleshooting); corrects the A2a 'deploy adds/removes arrive as deltas' claim (a deploy
ends the stream). AlarmTracking.md: Imported conditions. ScriptedAlarms.md: known after the first completed evaluation; what
forwards. security.md: imported-condition gate, per-caller method re-check, service principal, on_behalf_of, audit category.
Evidence A4-docs.md: plan-vs-code disagreements, TODO markers for the A4 code merge, ScadaBridge consumer impact.
This commit is contained in:
Joseph Doherty
2026-11-24 22:58:23 -05:00
parent 9143804987
commit 916c14eca1
5 changed files with 553 additions and 17 deletions
+117
View File
@@ -786,6 +786,122 @@ directly via System Platform's `HistorizeToAveva` toggle on the
alarm primitive — no involvement from OtOpcUa. This sidecar path is
exclusively for non-Galaxy alarm producers.
## Imported conditions (gRPC data connections)
A consumer node can import another cluster's alarm conditions over a gRPC data connection. To do that, a
`RemoteNamespaceMapping` needs `Subscribe` + `AlarmSubscribe` and the origin needs `DataConnections:ConditionKeySecret`. The
wire contract, grants, limits and method failure table are in [Data connections](DataConnections.md#condition-forwarding-end-to-end-a1a3).
This section is what an OPC UA client of the **consumer** sees. Code: `OpcUaServer/ProjectedConditionRegistry.cs`,
`ProjectedEventDelivery.cs`, `ImportedConditionMethods.cs`, `Runtime/DataConnections/ProjectedConditionAccess*.cs`.
### Identity
| Field | Imported condition |
|---|---|
| Namespace | `https://zb.com/otopcua/mapped/conditions`, the node manager's fifth namespace, separate from `mapped/raw` and `mapped/uns`. Its ids are classified before `RealmOf`, so they never fall back to Raw/UNS path grants. |
| `ConditionId` (NodeId) = `SourceNode` | opaque `s=c1.<base64url(JSON{ConnectionId, ConditionKey})>`. Children are `<id>/<browse path>` (instance-scoped, #629). **Never construct or parse it**: browse, or take it from an event. |
| `SourceName` | `<local anchor subject of the primary placement's mapping>/<placement address relative to that mapping's remote root>`, e.g. `Plant/remote-a/Modbus/dev1/HR200` (Raw) or `assembly/remote-line-2/filler/HR200` (UNS). A display field, not identity. The local rule "SourceName = ConditionId identifier" does **not** hold here. |
| `ConditionName`, `Message`, `Comment`, `ClientUserId`, `ConditionClass`, `Quality` | from the origin's record |
| `Severity` | verbatim from the origin (Part 9, 1..1000, clamped the same way as local conditions) |
| Type | `OffNormalAlarm`, `DiscreteAlarm` or `AlarmCondition`, from the origin's condition type |
- **`ConditionId` is stable for the life of the connection.** It depends only on the connection id and the origin's
`condition_key`, which comes from the origin cluster, the realm and the origin ConditionId under the cluster's secret.
- Mapping changes do **not** move it. This covers adding a second mapping that sees the same condition, and disabling
the primary-placement mapping. Only the notifiers and `SourceName` move.
- Both consumer pair members show the same id, whatever principal each authenticates as.
- What **does** change it:
- rotating the origin's `ConditionKeySecret`;
- the two origin pair members holding different secrets;
- re-creating the connection under a new id.
- One origin condition seen through several mappings or placements (a native alarm under a Raw mapping and two equipment
references) is **one** consumer condition with several placements.
- **Primary placement** (chooses `SourceName`) comes from deployed config only: Raw mappings before UNS, then mapping id
ordinal, then placement address ordinal. It never depends on stream order.
### Notifiers and delivery
- Each placement's folder is wired as a notifier when it is materialised: a projected folder, or the mapping anchor.
Wiring is lazy, in both directions, and also adds a root notifier. It is unwired at every projected-removal site.
Projected folders of a condition-bearing mapping have `SubscribeToEvents` from materialisation. A client can therefore
subscribe at a folder before any condition is wired there, and that subscription opens demand.
- **One event per origin transition.** It is delivered to every wired folder item and to the Server object (`i=2253`),
however many placements the condition has (one `ReportEvent`, through the shared report walk).
- A folder holding an admitted event item is pinned: projection eviction and paging skip it. Removing the mapping still
removes it.
- Every imported event takes the gated, marked delivery path, and the gate is re-checked at publish (see
[security](security.md#imported-conditions-over-data-connections)). An imported condition never re-enters the
consumer's own condition-state hub, so it cannot be re-exported.
### ConditionRefresh and RefreshRequired
- `ConditionRefresh` replays imported conditions once each, through the gated path, ACLs on or off. The replay runs 128
conditions per `Lock` hold. Imported conditions are excluded from the local replay paths.
- `RefreshRequiredEventType` (`SourceName = "Server"`) is queued, off `Lock`, only to the items that may see an affected
condition. It is sent when:
- a snapshot barrier is incomplete (a mapping timed out, was refused or its metadata failed);
- an imported condition is removed (a complete re-snapshot no longer lists it, a `removed` record, a capacity
eviction, or a secret rotation). Removal emits **no** `NodeDeleted` model change;
- a resync leaves retained EventIds un-re-bindable (see EventIds below).
- **Before the first barrier, a refresh returns nothing imported**, because nothing is materialised yet. Conditions appear
as their records apply. A RefreshRequired follows only if that barrier is incomplete; a refresh that merely preceded a
complete barrier gets none (plan-vs-code note: A07, see `docs/plans/evidence/grpc-data-ext/A4-docs.md`).
- A resync of unchanged state reports no event (#656 delta gate).
- Clients **must** handle `RefreshRequiredEventType` by calling ConditionRefresh.
### EventIds and re-binding
- The consumer mints its own EventId for each imported event. It keeps the last **8** per condition, each bound to the
origin activation marker of the record it was reported with.
- Acknowledge, AddComment and Confirm accept only an EventId this consumer minted for that condition under the **current**
marker. Anything else is `BadEventIdUnknown`, unsent.
- The marker is bumped only for a new occurrence: an Active false→true edge, or any Acked true→false edge. A state-only
record, a severity or message update, or a re-assert invalidates nothing.
- **Origin failover or restart:** the new incarnation is a new marker.
- The retained EventIds are re-bound, and stay ackable, only when the resynced record's state is unchanged **and** its
`time` equals the time they were bound under.
- Otherwise a fresh EventId is stamped (a ConditionRefresh returns it), the condition's watchers get `RefreshRequired`,
and a pre-failover EventId answers `BadEventIdUnknown`.
- A clear-and-re-raise during the gap never re-binds.
- A consumer stream reset against the **same** origin incarnation keeps the old EventIds ackable.
### State, staleness and `state_known`
- **T2 invariant:** the consumer never retires or clears an alarm that is active at the origin.
- A record with `state_known = false` changes nothing.
- A condition first seen unknown is `Quality = UncertainInitialValue` until a known record arrives.
- A stream end is a re-snapshot, never a removal. After `ConditionStaleTimeoutMilliseconds` each condition gets
`Quality = BadNoCommunication` (one event, Active/Acked unchanged).
- When an origin condition becomes known: scripted conditions, see
[ScriptedAlarms § Forwarding over a data connection](ScriptedAlarms.md#forwarding-over-a-data-connection). Native
conditions become known on the driver's standing-alarms signal; see DataConnections "Known state".
### Methods
| Method | Native (driver) condition | Scripted condition |
|---|---|---|
| Acknowledge | forwarded (Galaxy only with the export's `AllowGalaxyServiceAck`) | forwarded |
| AddComment | forwarded (same Galaxy rule) | forwarded |
| Confirm | **`BadNotSupported`**, unsent | forwarded |
| Shelve / Unshelve / TimedShelve / Enable / Disable | `BadNotSupported`, unsent | `BadNotSupported`, unsent |
- Nothing is applied locally: the SDK handlers on an imported node refuse, and the node changes only when the origin's
record arrives.
- The native `ConfirmedState = true` rule is the origin's. A native ack at the origin re-asserts Confirmed, and the record
the consumer applies carries it. The consumer's imported native conditions start Confirmed, as local ones do.
- Each call is re-authorized for the **local** caller (the caller's `AlarmAcknowledge` / `AlarmConfirm` on the placement
folder scope, and the mapping's bit).
- Status codes, budgets and the "OutcomeUnknown" answers are in
[Data connections § Condition methods](DataConnections.md#condition-methods-callconditionmethod).
### What the consumer does not do with imported conditions
- **No `alerts` topic publication.** So no `/alerts` rows and no consumer alarm history (AVEVA or SQL): imported conditions
are not in `_alarmConditions` and the condition-state sink never sees them. The origin historizes its own transitions.
- Not fed to `NativeAlarmProjector`; no local shelving timers.
- Not HistoryRead-able, not writable. Imported condition ids refuse HistoryRead, Write and the alarm operations other than
the three forwarded methods.
## Cross-references
- Plan: [docs/plans/alarms-over-gateway.md](plans/alarms-over-gateway.md)
@@ -793,3 +909,4 @@ exclusively for non-Galaxy alarm producers.
- Galaxy driver: [docs/drivers/Galaxy.md](drivers/Galaxy.md)
- Phase 7 scripting + alarming: [docs/v2/implementation/phase-7-scripting-and-alarming.md](v2/implementation/phase-7-scripting-and-alarming.md)
- Security + ACL: [docs/security.md](security.md)
- Imported conditions over data connections: [docs/DataConnections.md](DataConnections.md)
+246 -13
View File
@@ -142,12 +142,40 @@ snapshot when a row carries a bit it does not know, taking down every connection
**Data connections** page (per connection, the count of mappings with drops, and per node the exports with
drops — named when the AdminUI knows the bit, hex otherwise, with a hint that the node's build is older
than the authored feature; #919).
- Authoring rejects a bit until the release that implements it. H2 implements `HistoryRead`; the
alarm bits stay rejected until A2.
- Authoring rejects a bit until the release that implements it. H2 implements `HistoryRead`; A2
implements `AlarmSubscribe`, `AlarmAcknowledge` and `AlarmConfirm`; `AlarmShelve` (512) stays reserved.
- The optional per-call header `x-otopcua-data-features` negotiates features. X0 parsed it and
supported none; H2 supports `history` (see "Remote history" above). A call without it gets
supported none; H2 supports `history` and A2 `conditions` (see "Feature negotiation" above). A call without it gets
unchanged v1 behaviour.
## Feature negotiation (`x-otopcua-data-features`)
Remote history and condition forwarding add no protocol minor version. Each feature has a `CapabilitiesResponse`
advertisement and a per-call request header, `x-otopcua-data-features`, whose value is a comma list of `history` and/or
`conditions` (summed length ≤ 256 characters; `DataConnectionProtoContract.FeaturesHeader`).
- **The capabilities probe always asks for every feature the consumer supports.** The origin advertises a feature only
when the probe asked for it **and** it can serve it:
- `history` needs a historian backend (`CapabilitiesResponse.history`, field 16, and bit 32);
- `conditions` needs a provisioned `DataConnections:ConditionKeySecret` and a running node manager
(`CapabilitiesResponse.conditions`, field 17, and bits 64/128/256).
- **Every other RPC carries the negotiated set**: the consumer's features ∩ what the *selected endpoint* advertised. It is
re-derived per endpoint, so after a failover it follows the new endpoint's capabilities. On the origin, the effective set is
header ∩ server-supported ∩ origin-servable.
- **A call without the header gets byte-identical v1 behaviour.**
- Browse and GetMetadata keep the v1 shapes: no `Metadata.history`, no bit 32 or condition bits in `allowed_operations`.
Conditions never appear in the catalog for anyone; they are discovered only through a root-scoped condition item.
- Subscribe never emits the `condition_states` arm (9). A v1 client faults on an unknown frame arm, so the header gate is
mandatory, not a courtesy.
- The new RPCs (`HistoryRead`, `CallConditionMethod`) answer `FailedPrecondition("feature not negotiated")`. A
history-only call is also refused `CallConditionMethod`.
- Header-less goldens (`*Goldens.cs`) and the recorded-v1-client gates (`GrpcDataV1CompatibilityTests`,
`GrpcDataV1RealOriginCompatibilityTests`) pin the v1 bytes. Every phase ran them with an empty goldens diff.
Fix two v1 defects before any v1 deploy. #916: `stable_source_id` leaks the driver id and RawPath to UNS-only peers.
#917: v1 exports alarm-bearing raw tags as variables that never get a value. G0, the v1 deploy and soak (#915), is still
open; see the plan's §1.1.
## Remote history (runtime consumers)
**Status: supported** (H4). Verified end to end (live gate H01–H06) with the origin on the **SqlServer** and **QuestDB**
@@ -303,7 +331,7 @@ connection, node or principal id in a label:
Before H4 the origin's `otopcua.dataconn.history.reads` sat on a private meter the host did not export; it is now on the
OtOpcUa meter and carries `side`.
## Condition streams (A2a, origin side)
## Condition streams (origin side)
An origin streams its alarm condition state to a peer that negotiated `conditions` (`x-otopcua-data-features`). Plan:
`docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md` §5.1/§5.5; evidence `docs/plans/evidence/grpc-data-ext/A2.md`.
@@ -324,22 +352,227 @@ An origin streams its alarm condition state to a peer that negotiated `condition
- record chunks (≤ 128 records, `info` on every snapshot record and on a condition's first delta);
- the last snapshot chunk carries `snapshot_complete` only when every node-manager hold saw a completed apply of one
generation and the node is Primary; otherwise the snapshot is retaken (at most once a second) when the origin is ready;
- then delta records in order; a condition added or removed by a deploy arrives as a delta record (`removed` for one
that left the listing).
- then delta records, in order. A `removed` record can still arrive within one serving identity (a hub removal, or a
listing change without a catalog attempt).
- **A deploy ends the stream.** Every origin deploy begins a catalog attempt, which changes the serving identity, and a
condition item cannot outlive the identity it was admitted under. Conditions that a deploy adds or removes therefore never
arrive as delta records. The consumer reconnects and takes a complete snapshot of the new catalog. (Corrected in the A2
review, S1. Earlier text here said a deploy's adds/removes arrive as deltas; only a fixture could do that.)
- **Priority and overflow.** A control or ack at the head of the stream goes first, then condition frames, then queued
values. Condition production is pull-based: a slow consumer leaves records in the bounded condition-state hub; if the hub
evicts records the item has not read, the item takes a fresh snapshot, and if that happens while its previous snapshot
is still undelivered the stream is `Reset` ("Condition stream overflow; retry later.").
- **Revocation** (grant, catalog or authority change) ends the stream like a revoked v1 value item; no further condition
frame is delivered.
- **Limits** (`AddDataConnectionConditions`): `DataExport.MaxConditions` (1000, ≤ 5000), `RemoteNamespaceMapping.MaxConditions`
and the three condition timeouts (consumer side, A3). Metrics: `otopcua.dataconn.conditions.items`, `…resyncs`,
- **Limits** (`AddDataConnectionConditions`): `DataExport.MaxConditions` (1000, ≤ 5000) and `RemoteNamespaceMapping.MaxConditions`.
The consumer-side timeouts are under "Limits and defaults" below. Metrics: `otopcua.dataconn.conditions.items`, `…resyncs`,
`…capacity_rejections`.
- Condition methods (`CallConditionMethod`) are stage A2b; the OPC UA projection of imported conditions is A3.
## Condition forwarding end to end (A1–A3)
**Status: implemented and live-smoked on the grpc-data rig** (`conditions_a3_smoke.py`, runs `a3b-cond-3`, `a3r1-cond-1`,
`a3br1-cond-1`, `a3r2-cond-1`, `a3v2-cond-1`). The A4 scenario gate A01–A08 (plan §9, phase A4) is the exit gate. Until it
passes, treat condition forwarding as pre-release. The OPC UA side of an imported condition (namespace, ids, notifiers,
refresh, EventIds) is documented in [Alarm tracking § Imported conditions](AlarmTracking.md#imported-conditions-grpc-data-connections).
1. **Origin state.** The origin node manager keeps a per-condition `state_known` flag and feeds every condition change into
a bounded condition-state hub. A snapshot is taken under short `Lock` holds of at most `MaxConditions` each, with a
watermark. Deltas raised between holds are neither lost nor duplicated. Each condition is either:
- native, at its RawPath in the Raw realm; or
- scripted, at its `ScriptedAlarmId` in the UNS realm.
Which conditions are *known* is described in [Scripted alarms § Forwarding over a data connection](ScriptedAlarms.md#forwarding-over-a-data-connection)
and, for native drivers, under "Known state" below.
2. **Origin stream.** See "Condition streams" above: one root-scoped item per mapping, a snapshot then deltas. Each record
carries an opaque `condition_key`, a per-key version, `state_known`, `removed` and an activation marker. It also carries
`info` (name, type, source kind, placements, `supported_methods`).
3. **Consumer demand.** The consumer opens condition streams only on demand. The first admitted event item opens them; that
item is on the Server object (`i=2253`) or on a projected folder of a condition-bearing mapping.
- One stream is opened per condition-bearing connection, under that connection's service principal. A mapping is
condition-bearing when it is enabled and its operations (∩ the connection's) include `Subscribe` and `AlarmSubscribe`.
- The stream carries one item per mapping, Raw mappings first, then by mapping id.
- Demand is node-wide, not per caller: one admitted item opens every condition-bearing connection. The per-event gate
still decides what each session sees.
- All of a connection's items close together 30 s after the last event item goes (the linger). The linger also removes
what they materialised.
4. **Primary only, both ends.**
- The origin serves condition items and methods only while it is **Primary**; a Secondary or Warm standby answers
`Unavailable`.
- The consumer subscribes condition items to the Primary endpoint explicitly (`IDataPrimarySubscriptionSource`). It also
drops any condition stream whose provenance role is not Primary.
- Every consumer node in the mapping's `ConsumerNodeIds` mirrors state independently. Both pair members show the same
`ConditionId`, whatever principal each authenticates as.
5. **Snapshot barrier.** Nothing is materialised until every mapping of the connection has completed its snapshot, or until
`ConditionSnapshotTimeoutMilliseconds` has passed.
- A mapping that is incomplete at the barrier is `Unavailable`. The others proceed, and clients get `RefreshRequired`.
- A mapping that completes late is merged in.
- A mapping still `Unavailable` after the barrier ends the stream after a bounded wait
(`ConditionSnapshotTimeoutMilliseconds` × 1, 2, 4, 8 backoff).
- TODO(A4 #930 reconcile): describe the refused-mapping backoff and the in-stream `ConditionCapacity` recovery as merged.
6. **Lifetime rule.** The end of a stream means "re-snapshot", never "removed".
- During a disconnect, imported conditions keep their last state. After `ConditionStaleTimeoutMilliseconds` their
`Quality` becomes `BadNoCommunication`: one event per condition, with Active/Acked unchanged.
- An in-stream re-snapshot is buffered. The live set and the nodes stay untouched until `snapshot_complete`.
- A condition is removed only when a **complete** snapshot no longer lists it (and no other mapping lists it), or when a
`removed` record arrives. An incomplete snapshot removes nothing. It marks the unlisted keys stale (`BadNoCommunication`).
7. **Known state (T2 invariant).** *The consumer never retires or clears an alarm that is active at the origin.*
- A record with `state_known = false` never changes the consumer's last state.
- A condition first seen unknown is materialised with `Quality = UncertainInitialValue` until a known record arrives.
- Native drivers become known through a per-device "standing alarms delivered" signal (`IAlarmInitialStateSignal`).
`DataConnections:ConditionKnownSignalTimeout:<DriverType>` is the origin's wait for that signal (default 120 s). On
expiry the conditions **stay unknown**, the `otopcua.dataconn.conditions.unsignalled` counter moves, and a diagnostic
is raised on the hub.
- `DataConnections:ConditionKnownSettle:OpcUaClient` (default 60 s) is the only backstop timer. It exists for upstreams
without ConditionRefresh.
- Open gaps: #924 (L4 latency for Galaxy, Heidenhain and real Logix ALMD), #925 (Galaxy deploy-added conditions stay
unknown) and #926 (an OpcUaClient RefreshEnd can signal known over lost events).
### Condition key (`DataConnections:ConditionKeySecret`)
```
condition_key = base64url(HMAC-SHA256(K, upper(originClusterId) ‖ 0x00 ‖ realm ‖ ConditionId))
K = HKDF-SHA256(ConditionKeySecret, info = "otopcua/condition-key/v1") realm: 1 = Raw, 2 = Uns
```
- **Per origin cluster, identical on both pair members**, supplied as a `${secret:…}` reference or the
`DataConnections__ConditionKeySecret` environment variable. Never a committed literal.
- **Missing ⇒ the feature is off, not an error.** The origin logs one Information line (`… is not provisioned; this origin
does not advertise the conditions capability`). It advertises no `conditions` capability and no bits 64/128/256, and
condition items are `Unsupported`. Everything else is unaffected.
- **Present but weak ⇒ a startup error** (`DataConnectionOptionsValidator`, only while `DataConnections:Enabled`). These
count as weak: shorter than 32 UTF-8 bytes, blank, containing control characters, or still holding an unexpanded
`${secret:`. The message never echoes the value.
- The key is stable across restarts, failover and redeploys, and is the same for every principal and listing. It lets a
consumer dedupe one condition's Raw and UNS placements. Because it is keyed, it cannot be dictionary-reversed from
guessable RawPaths, and it carries no RawPath or driver id.
- **Rotation is a planned operation that changes every imported `ConditionId`** on every consumer. After a rolling restart of
the origin pair, the next complete snapshot carries new keys. Consumers remove the old conditions, materialise new ones and
send `RefreshRequired`. Clients that key on `ConditionId` see every alarm as removed and re-added. Rotate both pair members
in one change: if they differ, a failover changes every id.
### Operation bits
| Bit | Name | Where it is authored | What it grants |
|---|---|---|---|
| 64 | `AlarmSubscribe` | connection, export, mapping | the root-scoped condition item; with `Subscribe` on the mapping it makes the mapping condition-bearing |
| 128 | `AlarmAcknowledge` | connection, export, mapping | remote Acknowledge and AddComment |
| 256 | `AlarmConfirm` | connection, export, mapping | remote Confirm (scripted conditions only; see below) |
| 512 | `AlarmShelve` | reserved, not authorable | — (Shelve/Unshelve/Enable/Disable are not forwarded, plan §7) |
The mapping's bits must be a subset of the connection's. An effective grant is the intersection of the connection, the
mapping and the origin export, plus the origin ACL for the connection's service principal and the local caller's grants
(see [security § Imported conditions](security.md#imported-conditions-over-data-connections)). A node older than X0 must
not see these bits; see "Mixed versions" above.
**`DataExport.AllowGalaxyServiceAck`** (default `false`; valid only with `AlarmAcknowledge`, validator code
`DataExportGalaxyAckInvalid`).
- Without it, the origin lists Galaxy-sourced native conditions with `supported_methods = 0`. The consumer then refuses
Acknowledge/AddComment on them with `BadNotSupported`, unsent. If a call does reach the origin, it is refused
`BadUserAccessDenied`, unapplied.
- With it, the ack runs under the Galaxy ack identity of the connection's service key. Provision
`otopcua/apikeys/<serviceKeyId>/galaxy-ack-user` and `…/galaxy-ack-password` in the **origin's** secrets store; without
them the #765 preflight refuses `BadUserAccessDenied`.
### Condition methods (`CallConditionMethod`)
An OPC UA client calls Acknowledge, AddComment or Confirm on an imported condition (the type method or the condition's
instance child). The consumer node manager **claims** the call before the SDK's synchronous `Call` runs. It does the checks
below without I/O and without the node manager `Lock`, then awaits the origin with no request thread held. The L3 gate
measured Read, Browse and Publish unaffected during a 5 s origin stall.
- **Nothing is applied locally.** The imported node changes only when the origin's record arrives on the condition stream,
so a `Good` answer can precede the confirming event.
- **Budget** = min(the request's deadline − 250 ms grace, the mapping's `ConditionMethodTimeoutMilliseconds`). A dispatch with
less than 250 ms left is refused `BadTimeout`, unsent.
- **Slots:** 8 in-flight dispatches per consumer node and 4 per connection inside them, so one stalled origin cannot starve
another. Waiting for a slot counts against the budget.
- **Joins:** an identical call already in flight joins it and gets the same answer. Identical means the same principal,
condition, EventId, method and comment. Each dispatch has a fresh operation id; the origin's operation registry joins
duplicates of an id.
- **Never retried**, not even after a reconnect or failover.
The origin runs the call through the same wrapped SDK handler a local client uses, under a bounded `Lock` wait (5 s, then
`BadTimeout`, unapplied). So a remote ack produces exactly one origin event and keeps the native Confirmed/Retain re-assert.
It also routes once to the driver (`AlarmCommand` unchanged) and keeps the #760 revert contract. `ClientUserId` and the
`AlarmCommand` user are the connection's service principal.
| Answer on the consumer | Meaning | Sent to the origin? |
|---|---|---|
| `Good` | Scripted: the origin applied it (`DriverConfirmedSuccess`). Native: the origin accepted it and routed it to the driver (`AcceptedUnconfirmed`). The state change arrives on the stream. | yes, applied/accepted |
| `BadNodeIdUnknown` | not an imported condition this node holds | no |
| `BadNotSupported` | Shelve / Unshelve / Enable / Disable / unknown method; **native Confirm**; method not in the origin's `supported_methods` (e.g. Galaxy without the opt-in) | no |
| `BadUserAccessDenied` | the local caller fails the mapping method gate, or the deployed connection lacks the bit | no |
| `BadArgumentsMissing` / `BadTooManyArguments` / `BadTypeMismatch` / `BadInvalidArgument` | argument shape; comment over 4,096 characters | no |
| `BadEventIdUnknown` | EventId not minted by this consumer for this condition under the current activation marker (stale, superseded or pre-failover; see AlarmTracking) | no |
| `BadInvalidState` | this consumer node is the Warm standby | no |
| `BadNoCommunication` | no open condition stream for the connection (down or never opened) | no |
| `BadTooManyOperations` | no method slot free within the budget | no |
| `BadTimeout` (no "OutcomeUnknown" in the diagnostic) | budget below the 250 ms dispatch floor | no |
| `BadRequestCancelledByClient` | cancelled while waiting for a slot | no |
| `BadInternalError` | a fault before dispatch (logged) | no |
| origin's status (e.g. `BadUserAccessDenied`, `BadNodeIdUnknown`, `BadEventIdUnknown`, `BadInvalidState`, `BadTooManyOperations`, `BadTimeout`) | `RejectedBeforeDispatch` / `DriverConfirmedFailure` at the origin. Causes include an ACL or export refusal, an unresolved placement (existence is not disclosed), a marker mismatch (a new occurrence not yet streamed), non-Primary, a full operation registry, or a busy node manager. | sent, **not applied** |
| `BadTimeout` / `BadCommunicationError` with **"OutcomeUnknown: …"** in the diagnostic | sent, and no answer arrived in time, or the transport failed after send. **It may have been applied.** Watch the condition's events; do not replay. Logged as a Warning. | sent, outcome unknown |
`OutcomeUnknown` is reported as a Bad code on purpose: Part 4 gives a Call result no "maybe applied" Uncertain meaning, and
most clients read an Uncertain status as success.
### Limits and defaults
| Setting | Where | Default | Notes |
|---|---|---|---|
| `DataExport.MaxConditions` | ConfigDb, origin | 1,000 (≤ 5,000) | the listing of one root-scoped item above this ⇒ snapshot begin carries only `total`; the item is `ConditionCapacity` |
| `RemoteNamespaceMapping.MaxConditions` | ConfigDb, consumer | 1,000 (≤ 5,000) | the consumer's admission; `total` above it ⇒ `Unavailable(ConditionCapacity)` before anything is materialised; other mappings are unaffected. Imported conditions never consume `MaxProjectionNodes` |
| `RemoteNamespaceMapping.ConditionSnapshotTimeoutMilliseconds` | ConfigDb | 30,000 (≤ 1 h) | snapshot barrier |
| `RemoteNamespaceMapping.ConditionStaleTimeoutMilliseconds` | ConfigDb | 30,000 (≤ 1 h) | disconnect ⇒ `BadNoCommunication` |
| `RemoteNamespaceMapping.ConditionMethodTimeoutMilliseconds` | ConfigDb | 5,000 (≤ 1 h) | per-call method budget ceiling |
| `DataConnections:MaxImportedConditionNodes` | host, consumer | 122,500 (2,500 × 49 worst-case nodes) | node-wide across connections, order-independent |
| `DataConnections:MaxImportedConditionBytes` | host, consumer | 400,000,000 B (≈ 381 MiB = 160,000 B × 2,500, measured by L2) | node-wide |
| `DataConnections:MaxConditionMethodOperations` | host, origin | 4,096 | duplicate-protection registry, all principals; completed ids kept 5 min |
| `DataConnections:MaxConditionMethodOperationsPerPrincipal` | host, origin | 256 | the same per principal; full ⇒ `BadTooManyOperations`, unapplied |
| `DataConnections:ConditionKnownSignalTimeout:<DriverType>` | host, origin | 120 s | see "Known state" |
| `DataConnections:ConditionKnownSettle:OpcUaClient` | host, origin | 60 s | backstop; ignored for other driver types |
| `DataConnections:ConditionKeySecret` | host, origin (secret) | absent ⇒ feature off | see "Condition key" |
| Consumer method slots | fixed | 8 per node, 4 per connection | not configurable |
| Retained EventIds | fixed | 8 per condition | see AlarmTracking |
| Demand linger | fixed | 30 s | `ProjectedConditionOptions.Linger` |
Two charges are made against the host caps: a snapshotting mapping is charged its admitted `total`, and a completed mapping
its record count. Growth is charged as it happens. Records beyond `total`, live records beyond `MaxConditions`, or growth past
a host cap make that mapping `ConditionCapacity`. Its item is removed, its conditions are removed (except keys another
mapping lists) and clients get `RefreshRequired`. The deploy gate also logs a non-blocking `DataConditionCapacityWarning`
when Σ `MaxConditions` × 49 of a consumer node's mappings exceeds `MaxImportedConditionNodes`.
### Diagnostics and troubleshooting
TODO(A4 diagnostics reconcile): list the condition metrics (consumer stream state, snapshot time, condition count vs limit
with the 80 % warning, capacity state, `state_known = false` count, RefreshRequired count, method outcomes) and the
**Data connections** page fields here, with their exact names, once the A4 diagnostics branch merges. Today's metrics:
`otopcua.dataconn.conditions.items`, `…resyncs`, `…capacity_rejections`, `…unsignalled`, `…partition_overflows`,
`…marks_discarded` and `otopcua.dataconn.condition_methods` (tags `method`, `outcome`; origin).
Consumer logs (Information unless noted) record each condition stream it opens, each item the origin refuses (Warning, with
status and diagnostic), and each snapshot barrier (per-mapping status, record count, whether it timed out).
| Symptom | Check |
|---|---|
| No imported conditions at all | Is `ConditionKeySecret` provisioned on the origin? The origin logs "not provisioned" once at start. Are bit 64 and `Subscribe` on the connection, mapping and export? Does the service principal have the origin ACL `Subscribe` on the placements? Is a client subscribed to events (`i=2253` or a projected folder)? Streams open only on demand. Does the consumer log show a barrier? |
| A mapping refused `Denied` / `Unavailable` | Origin export grant and ACL for the service principal. The origin is not Primary. Metadata for the remote root failed (logged). |
| `ConditionCapacity` | The listing's `total` against the mapping's or export's `MaxConditions`, and the host caps. Narrow the remote root or raise the limits. |
| Conditions `Uncertain` | The origin has not established their state: a scripted alarm has not completed an evaluation; a native driver has not signalled (see `…conditions.unsignalled`). |
| Conditions `BadNoCommunication` | Stream down longer than `ConditionStaleTimeoutMilliseconds`, or the mapping was incomplete at the last barrier. |
| Ack answers `BadEventIdUnknown` | The client holds an old EventId (superseded occurrence, or an origin restart that re-announced a different time). ConditionRefresh and ack with the new EventId. |
| Ack answers "OutcomeUnknown" | Check the origin's audit log (`ZB.MOM.WW.OtOpcUa.DataConnections.Audit`) for the operation and watch the condition's events. Never replay blindly. |
| All `ConditionId`s changed | `ConditionKeySecret` was rotated or differs between the origin pair members, or the connection was re-created under a new id. |
Open follow-ups: #927 (live-gate the driver-failure ack revert), #928 (an overflow test fails under load), #929 (re-measure
the per-condition memory figures in the plan), #930 (a refused mapping causes a refresh storm; `ConditionCapacity` never
recovers in-stream; A4 work in progress) and #931 (review nits).
## Feature boundary
Alarm/event forwarding and relay operations are future work; remote history is above. Authorized imported
current values can feed local derived engines, including calculations, scripts, historization and
alarm evaluation. Such local processing does not add a remote history/alarm API or permit re-export
of an imported branch.
Remote history (above) and condition forwarding (Acknowledge, AddComment, Confirm) are supported. Still deferred (plan §7):
remote Shelve/Unshelve/Enable/Disable (bit 512 reserved), HistoryReadEvents on mapped notifiers, modified-value history
reads and HistoryUpdate. Relay operations are a separate design (plan §8). Imported conditions are not republished to the
consumer's `alerts` topic and are not written to its alarm history. Authorized imported current values can feed local derived
engines, including calculations, scripts, historization and alarm evaluation. Such local processing does not permit
re-export of an imported branch.
+39
View File
@@ -401,6 +401,45 @@ In the v2 actor system, scripted-alarm engine composition is owned by the driver
Both engine and source are disposed on server shutdown via the driver-role host teardown path.
## Forwarding over a data connection
An origin can stream its scripted conditions to another cluster over a gRPC data connection
([DataConnections.md](DataConnections.md#condition-forwarding-end-to-end-a1a3)). The consumer projects them as imported
conditions ([AlarmTracking.md](AlarmTracking.md#imported-conditions-grpc-data-connections)). Two scripted-specific rules
apply.
**A scripted condition becomes *known* only after its first completed evaluation.**
- `Active` is not persisted. After a load, the engine re-derives it from a value cache that `ReadTag` seeds before any
driver has published, so "loaded" is not "known".
- The engine raises `OnInputsEstablished(alarmId, Established: true)` only after the first predicate evaluation that
**completes** since the load or the last revert (`ScriptedAlarmEngine.NoteEvaluationCompleted`). Completes means: no input
still never-pushed, valid evidence, and the predicate returned a bool.
- A Bad input, a script runner that is not up, or a predicate that timed out, was refused or threw establishes nothing.
- The flag is queued as the last of that evaluation's emissions, so the Active projection is dispatched first.
`ScriptedAlarmHostActor` then sends `MarkConditionsKnown` on the same chain as its `AlarmStateUpdate`s.
- During a load the host holds the flags until the post-load re-assert of non-normal (#487) conditions has been queued.
This keeps a freshly re-materialised, inactive node from being declared known ahead of its persisted active state.
- An input that reverts to never-pushed (`NoteInputsReverted`, e.g. a tag re-created by a deploy) withdraws "known". Every
reload clears the established set and re-raises the flag for each alarm as it evaluates again.
- Until then the origin streams the condition with `state_known = false`, and the consumer shows it
`Quality = UncertainInitialValue` and never as "known inactive". A scripted alarm whose inputs never arrive stays
unknown, which is honest: the origin cannot know its state either.
- A projection alone never marks a scripted condition known. That includes a restored-unacked re-assert and an early ack;
only native projections do that (A1 review B1).
**What forwards.**
- Scripted conditions are listed at their `ScriptedAlarmId` in the **UNS** realm, under the equipment that owns them. A
UNS mapping whose remote root covers that equipment imports them; a Raw mapping does not.
- They advertise Acknowledge, AddComment **and Confirm** (`supported_methods` = all three), gated by the export, connection
and mapping bits `AlarmAcknowledge` (128) and `AlarmConfirm` (256).
- A remote call is dispatched through the same wrapped handler as a local OPC UA call, so the engine receives the same,
unchanged `AlarmCommand` (`User` = the connection's service principal). The consumer answers `Good` once the origin has accepted
the call and routed the command (`DriverConfirmedSuccess`). The consumer's node changes only when the resulting record arrives.
- Shelve/Unshelve/Enable/Disable are not forwarded (`BadNotSupported` on the consumer; bit 512 reserved). Operators shelve at
the origin, where `/alerts` and the shelving timers live.
- The activation marker survives a rebuild for scripted conditions, so the engine's re-assert of a still-active alarm is not
a new occurrence. Consumer EventIds stay ackable across that re-assert.
## Key source files
- `src/Core/ZB.MOM.WW.OtOpcUa.Core.ScriptedAlarms/ScriptedAlarmEngine.cs` — orchestrator, cascade wiring, shelving timer, `OnEvent` emission
@@ -0,0 +1,95 @@
# A4 evidence: documentation
Phase A4 (docs part) of `docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md`. Written 2026-11-24 on branch
`a4-docs`, from master `91438049` (X0–A3 merged). Docs only: no code, test or script changes. The A4 code work happens on a
separate branch: #930 (refused-mapping backoff and in-stream `ConditionCapacity` recovery), #931 (nits), and condition
diagnostics/metrics/AdminUI. Where these docs depend on it, they say "A4" in general terms and carry a `TODO(A4 …)` line.
The sources were the code at `91438049` and the evidence logs X0–A3. The plan was used only where the code agreed with it.
## What was written
| File | Change |
|---|---|
| `docs/DataConnections.md` | New "Feature negotiation (`x-otopcua-data-features`)" section. In "Condition streams (origin side)", the stale claim that a deploy's adds and removes arrive as delta records is corrected (A2 S1: a deploy ends the stream). New "Condition forwarding end to end" section, with subsections for the condition key, operation bits + `AllowGalaxyServiceAck`, condition methods (with the status-code table), limits and defaults, and diagnostics/troubleshooting. "Feature boundary" is updated. History (H1–H4) was already documented and is not duplicated; the negotiation section only points at it. |
| `docs/AlarmTracking.md` | New "Imported conditions (gRPC data connections)" section, covering identity, notifiers, ConditionRefresh/RefreshRequired, EventIds, state, methods and the exclusions. Adds a cross-reference. |
| `docs/ScriptedAlarms.md` | New "Forwarding over a data connection" section: known after the first completed evaluation, what forwards, and Confirm support. |
| `docs/security.md` | The stale "remote history, alarm/event … are not part of this contract" sentence is fixed. New "Imported conditions over data connections" subsection, covering the gate independent of the ACL flag, the per-local-caller method re-check, the service-principal stream, `on_behalf_of` and the audit category. |
## TODO markers left for reconciliation at merge
1. `docs/DataConnections.md` § "Condition forwarding end to end", step 5: `TODO(A4 #930 reconcile)`. Describe the
refused-mapping backoff and the in-stream `ConditionCapacity` recovery as merged. The text today describes the A3
behaviour: a still-`Unavailable` mapping ends the whole stream after a ×1/2/4/8 backoff, and an in-stream capacity
refusal removes the mapping's keys.
2. `docs/DataConnections.md` § "Diagnostics and troubleshooting": `TODO(A4 diagnostics reconcile)`. Add the exact condition
metric names (consumer stream state, snapshot time, count vs limit with the 80 % warning, capacity state,
`state_known = false` count, RefreshRequired count, method outcomes) and the AdminUI **Data connections** page fields.
The plan's `…conditions.refresh_required` does not exist in code at `91438049`.
## Plan vs. code disagreements (the docs follow the code)
| # | Plan says | Code does (evidence) |
|---|---|---|
| D1 | §5.6 step 2(c): one per-node semaphore (default 8) bounds remote method calls. | 8 per node **and** 4 per connection inside them. A dispatch with < 250 ms of budget left is `BadTimeout`, unsent (`ImportedConditionMethods.cs:63-79`, `:247`, `:270`; A3b review S4). |
| D2 | §5.5 / §6: `MaxImportedConditionBytes` 400 MiB, ≈ 157 KiB (160,997 B) per condition. | `BytesPerCondition` = 160,000. The default is 400,000,000 B ≈ 381 MiB (`ProjectedConditionAccess.cs:58-61`, `DataConnectionOptions.cs:25`; A3 round-2 L2 measured the retained heap, not `GC.GetTotalMemory`). #929 re-measures the plan's figures. |
| D3 | §6 metrics list `…conditions.refresh_required`. | Not present (`OtOpcUaTelemetry.cs:233-265` has `unsignalled`, `partition_overflows`, `items`, `resyncs`, `capacity_rejections`, `condition_methods`, `marks_discarded`). A4 diagnostics work; TODO 2. |
| D4 | §5.4/§5.5: demand per connection the caller could see. | Demand is node-wide: the first admitted event item opens every condition-bearing connection, and the per-event gate still decides visibility (A3a deviation 2). |
| D5 | §6: local visibility uses "the Subscribe grant on the `RemoteNamespaceMapping` scope". | `Subscribe` on the **placement folder's** scope, within a current mapping of the placement's realm that grants `AlarmSubscribe`, not `AlarmRead` (`ProjectedConditionAccess.cs:170-190`; A3 Runtime gate tests). Narrower than the mapping scope, and consistent with it. |
| D6 | A07: "RefreshRequired observed if refresh preceded snapshot". | RefreshRequired is sent only at an **incomplete** barrier, on removal and on an un-re-bindable resync (`ProjectedConditionAccess.Runner.cs:374`, `:405`; `ProjectedConditionRegistry.cs:311-340`, `:412`). A ConditionRefresh before a *complete* first barrier gets no RefreshRequired; the conditions then arrive as their records apply (A3a deviation 4, never closed). The A4 live gate should decide whether A07's expectation or the code is right. |
| D7 | A03: "an ack with a pre-failover EventId ⇒ `BadEventIdUnknown`". | Holds only when the resynced record's `time` differs. With the same `time` and unchanged state, a new incarnation re-binds the retained EventIds and the old EventId stays ackable (F6, `ImportedConditionMethods.cs:386-415`). This matches plan §5.6 step 3 N6/F6, so A03's wording is the narrower case. A03 should drive a failover where `time` changes. |
| D8 | `RemoteNamespaceMapping.ConditionMethodTimeoutMilliseconds` doc comment: "ack/confirm/shelve". | Shelve is not forwarded (bit 512 reserved, `BadNotSupported`). The comment is stale; code is not changed here. |
| D9 | §5.2/§6: secret rotation = "removal + addition + RefreshRequired". | True after an origin restart: the next complete snapshot carries new keys, and the old ones are removed with RefreshRequired (Deviation 6 fix). The docs add that the two pair members must hold the same secret, or a failover changes every id (`ConditionKeys.cs:17-20`). This is not a disagreement, only an operational consequence the plan does not state. |
| D10 | `.claude/rules/alarms.md` has nothing on imported conditions. | Not edited (docs-only scope covered the four guides). Consider a one-line pointer at merge. |
## ScadaBridge consumer impact (A4 exit-gate input)
For a ScadaBridge Data Connection Layer subscribed to a **consumer** OtOpcUa node that imports conditions. ScadaBridge files
are cited at `~/Desktop/ScadaBridge` `a87c0575`. **This is to be recorded in `sister-project-history/otopcua.md` at the exit
gate.** Two findings need a ScadaBridge change; they are not yet filed as issues.
1. **`SourceName` shape: `<local anchor subject>/<placement path relative to the remote root>`.**
- Evidence: `ProjectedConditionAccess.Runner.cs:563-564` builds `anchor + "/" + primary.RelativePath`. `:567-575`
strips the remote root subject and computes the folder. `ProjectedConditionRegistry.cs:458` sets it at creation, and
`:479` updates it on every record ("display only; rides the next event").
- Impact: ScadaBridge builds its per-condition key from `SourceName` + `.` + `ConditionName` (`OpcUaAlarmMapper.cs:45-51`;
`RealOpcUaClient.cs:1228-1240`). For an imported condition, that key is therefore the projected path, not the origin's
RawPath. It **changes when the primary-placement mapping changes**, for example when the Raw mapping is disabled and a
UNS mapping becomes primary. ScadaBridge would then see a different alarm, even though `ConditionId` did not move.
- **Finding:** ScadaBridge should key imported conditions on `ConditionId`/`SourceNode`, or accept that a mapping change
re-keys them.
2. **`ConditionId` is opaque and stable for the life of the connection. Mapping changes do not move it; secret rotation does.**
- Evidence: the NodeId is `c1.` + base64url(JSON{ConnectionId, ConditionKey}) (`ImportedConditionIds.cs:11`, `:38`, `:53`;
`ProjectedConditionRegistry.cs:193`, `:443`).
- `condition_key` = HMAC over (upper(originClusterId), 0x00, realm, origin ConditionId) under
HKDF(`ConditionKeySecret`) (`ConditionKeys.cs:10-20`). No mapping, placement or principal input.
- The A3 OI test "disabling the primary mapping keeps the ConditionId and the instance" pins it (A3.md:96).
- Rotation, or different secrets on the origin pair, changes every id (`DataConnectionOptions.cs:37-44`).
3. **Native `ConfirmedState = true` re-assert: preserved.**
- At the origin, a remote ack runs the same wrapped handler as a local one (`OtOpcUaNodeManager.ConditionMethods.cs:32-45`).
That handler re-asserts Confirmed for native keys (`OtOpcUaNodeManager.cs:3100-3108`), and the remarks there say why:
ScadaBridge maps `ConfirmedState` straight into its alarm state (`:3010-3015`).
- The consumer applies the origin's `Confirmed` verbatim (`ProjectedConditionRegistry.cs:484`) and creates imported
native conditions Confirmed (`OtOpcUaNodeManager.cs:2520-2522`, inside `CreateConditionNode`, which the imported
factory shares). It never applies an ack locally (`ProjectedConditionRegistry.cs:460-465`; claimed methods do not touch
node state).
- Native Confirm is refused unsent (`ImportedConditionMethods.cs:173`).
- ScadaBridge reads `ConfirmedState/Id` (`RealOpcUaClient.cs:1077`, `:1248`).
4. **Severity: verbatim.**
- The origin record carries the node's Part 9 severity (`MappedSeverity: (ushort)ToPart9Severity(...)`,
`OtOpcUaNodeManager.cs:2417`; `ToPart9Severity` = clamp 1..1000, `:4249`).
- The consumer clamps 1..1000 at creation and on apply (`ProjectedConditionRegistry.cs:458`, `:486`), then
`SetSeverity(ToPart9Severity(...))` (`OtOpcUaNodeManager.cs:1441`). That is the identity for any in-range value.
- The A3 OI test asserts Severity 777 arrives as 777 (A3.md:96). ScadaBridge clamps 0..1000 (`OpcUaAlarmMapper.cs:57`).
No change.
5. **RefreshRequired handling: new for ScadaBridge.**
- Until A3, OtOpcUa never emitted `RefreshRequiredEventType`; the only producer is `ProjectedConditionRegistry.cs:416-430`.
- It is now sent, with `SourceName = "Server"`, to items that may see an affected imported condition. That happens at an
incomplete snapshot barrier, on removal of an imported condition (including a secret rotation or capacity eviction),
and after an un-re-bindable resync.
- ScadaBridge handles `RefreshStartEventType`/`RefreshEndEventType` (`RealOpcUaClient.cs:1211-1226`) but has **no
RefreshRequired branch**. Such an event falls through to the condition mapping and is keyed by `SourceName` "Server"
(`:1228-1240`); ScadaBridge neither re-runs ConditionRefresh nor ignores it.
- **Finding:** ScadaBridge should handle `RefreshRequiredEventType` by calling `TriggerConditionRefreshAsync`
(`RealOpcUaClient.cs:1179`) for that handle, and should not map it as a transition. The type is unchanged for local
(non-imported) conditions.
+56 -4
View File
@@ -223,10 +223,62 @@ Read/browse/subscription admission and final value delivery retain current autho
metadata alone does not confer write-through, and secondary/read-replica access never confers writes.
The flag-off descriptions below concern locally owned nodes. They are not a bypass for gRPC export
or mapped nodes. Remote projected branches cannot be re-exported as locally owned data, and remote
history, alarm/event and relay operations are not part of this contract. Authorized imported current
values can feed local derived engines. See [Data connections](DataConnections.md) and
[Read/write operations](ReadWriteOperations.md).
or mapped nodes. Remote projected branches cannot be re-exported as locally owned data. Remote
history (HistoryRead) and condition forwarding (Acknowledge, AddComment, Confirm) are part of the
contract since H2/A3, behind the per-call feature negotiation. Relay operations are not. Authorized
imported current values can feed local derived engines. See [Data connections](DataConnections.md)
and [Read/write operations](ReadWriteOperations.md).
### Imported conditions over data connections
**The gate is independent of `Security:Acl:Enabled`.** An imported condition, and the projected folders that are its
notifiers, are mapped nodes, so the mapping gate always applies, flag on or off. Ids in the
`https://zb.com/otopcua/mapped/conditions` namespace are classified **before** `RealmOf` at every authorizer entry point:
read, browse, subscribe, history, call and alarm commands. An opaque `c1.` id therefore never falls back to a local
Raw/UNS path grant. A guard test pins this.
| Operation (consumer) | Requires, for the local caller |
|---|---|
| Browse / Read the condition and its children; event items; each delivered event; ConditionRefresh replay | `Subscribe` on a placement folder's scope (not `AlarmRead`), on a current mapping of the placement's realm that grants `AlarmSubscribe` |
| Acknowledge / AddComment | `AlarmAcknowledge` on a placement folder's scope, plus the mapping's bit 128 |
| Confirm | `AlarmConfirm` on a placement folder's scope, plus the mapping's bit 256 |
| HistoryRead, Write, Shelve, Enable/Disable | refused |
- **Visibility is re-checked per item and per event.** That covers the Server object (`i=2253`), each folder hop (the folder
must also be currently wired), the refresh replay and again at Publish/Republish. A queued event whose gate fails at
publish is dropped.
- Verdicts are cached per (identity, condition, authority generation, placement version). A positive verdict lives at
most 5 s, or until the credential expires.
- The authority generation folds in the mapping set and each mapping's `IsActive`.
- A3-SEC (ACLs off, a session with no mapping grant at `i=2253`) receives zero imported events, live or on refresh.
- **Methods re-check the local caller on every call** (`ProjectedConditionAccess.AuthorizeMethod` → `DataOperationPolicy.AuthorizeLocal`).
The check includes the caller's key usability (#563) and is made regardless of the ACL flag. The first placement, in
primary order, on which the caller passes is the one dispatched through. A caller refused locally is
`BadUserAccessDenied` and **nothing is sent**.
- The method gate does not separately require visibility through that placement. The 128-bit EventId, minted per consumer
and delivered only to items that see the condition, is the practical visibility requirement (A3b review N9).
- Identical in-flight calls join only within one principal.
- **The stream runs under the connection's service principal**, not the client's.
- The origin admits a condition item for that principal when its export grants `AlarmSubscribe` and the principal has
the origin ACL `Subscribe` on each placement's scope. A UNS-only principal's records carry no RawPath.
- A remote method is authorized at the origin against the export bit, the origin ACL on the placement's subject, the
key's usability and, for Galaxy conditions, `AllowGalaxyServiceAck`.
- The origin's `ClientUserId` and the `AlarmCommand.User` are the service principal only. They are never concatenated with
remote text. `AlarmCommand` was deliberately not extended, because it crosses the mesh.
- A grant, catalog or key revocation ends the stream. Authorization happens at call start (one synchronous hop before
apply), the same bound as a local call. Primary/Warm-standby status is re-checked under the origin's `Lock`.
- **`on_behalf_of` and the audit log.** The consumer sends the local caller's principal as `on_behalf_of`.
- The origin treats it as untrusted text. It strips control and format characters, caps it at 128 characters, and writes
it **only** to the data-connection audit log.
- Every remote condition-method call is audited whatever its end (applied, refused, joined, unknown). The entry carries
method, principal, API key id, placement realm/namespace/identifier, operation id, outcome state and status, joined
flag and on-behalf-of.
- The log is the dedicated logger category **`ZB.MOM.WW.OtOpcUa.DataConnections.Audit`**, so operators can route it to
its own sink. Every caller-supplied field is re-sanitised there and capped at 512 characters, so log text cannot
receive injected CR/LF.
- Remote audit text is not surfaced in alarm history.
- **`DataConnections:ConditionKeySecret`** is a secret: `${secret:}` or the environment variable, never committed. A weak
value fails startup without echoing it.
## OPC UA Authentication