feat(grpc-data): A2a — byte-bounded condition chunks (256 KiB estimate); DataConnections.md condition streams

This commit is contained in:
Joseph Doherty
2026-11-24 12:30:28 -05:00
parent 6572ee83bc
commit 1977d8ce84
2 changed files with 61 additions and 5 deletions
+34
View File
@@ -303,6 +303,40 @@ 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)
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`.
- **Served only when** `DataConnections:ConditionKeySecret` is provisioned (≥ 32 UTF-8 bytes, identical on both pair
members) and the node manager is up. Otherwise `CapabilitiesResponse.conditions` (field 17) and the `AlarmSubscribe` bit
(64) are absent and condition items are `Unsupported`.
- **Grant.** `AlarmSubscribe` on the export (and the connection/mapping, authored like the other bits), plus the origin
ACL `Subscribe` (`CreateMonitoredItems`) on each placement's scope for the connection's service principal. A stream with
only `AlarmSubscribe` (no `Subscribe`) is admitted when the call negotiated `conditions`.
- **The item.** `SubscriptionItem.condition_scope` on the mapping's remote root (an export root) = every condition placed
under that root in the root's realm (Raw: native, at the RawPath; UNS: native at the reserved reference id and scripted
at the ScriptedAlarmId; a UNS listing never carries a RawPath). One handle; it counts as one monitored item. Primary only
(`Unavailable` on a Secondary or Warm standby).
- **Frames** (`condition_states`, arm 9, never on a call without the header):
- snapshot begin: `is_snapshot`, `total`, no records. `total` above the export's `MaxConditions` ⇒ that is the only
frame for the item (nothing is copied); a later deploy that changes the listing re-admits it;
- 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).
- **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`,
`…capacity_rejections`.
- Condition methods (`CallConditionMethod`) are stage A2b; the OPC UA projection of imported conditions is A3.
## Feature boundary
Alarm/event forwarding and relay operations are future work; remote history is above. Authorized imported