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:
@@ -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.
|
||||
Reference in New Issue
Block a user