diff --git a/docs/DataConnections.md b/docs/DataConnections.md index 5fb002bdf..aa10711cb 100644 --- a/docs/DataConnections.md +++ b/docs/DataConnections.md @@ -132,10 +132,14 @@ snapshot when a row carries a bit it does not know, taking down every connection - **Run X0 on every node of both clusters before any of these bits is authored.** Nothing checks this: ConfigDb records no node build, so it is a deploy-checklist step. -- An X0 node drops an unknown bit from that row only, fail closed (an unknown grant is no grant), - and logs a warning naming the connection. It also counts it: - `otopcua.dataconnection.unknown_operations_dropped`. Exports and mappings are read the same way. - Authoring still rejects the bits until the release that implements them. +- An X0 node drops any operation bit it does not implement from that row only, fail closed (an + unknown grant is no grant). This applies to connections, exports and mappings alike. +- Each drop is logged as a warning naming the row and counted on + `otopcua.dataconnection.unknown_operations_dropped` (tag `kind` = connection, export or mapping). + - A drop is counted once per row per accepted artifact change. A → B → A counts again, and a + restart resets the count. + - The dropped bits also show in the node's fleet diagnostics. +- Authoring still rejects the bits until the release that implements them. - The optional per-call header `x-otopcua-data-features` is reserved. X0 parses it but supports no feature, and an X0 consumer never sends it, so the wire behaviour is unchanged v1. diff --git a/docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md b/docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md index 53db90580..bdedc010d 100644 --- a/docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md +++ b/docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md @@ -352,6 +352,12 @@ X0 changes: grant) and counted in diagnostics. They no longer throw for the whole snapshot. - `DataContracts.cs:271-276`: `DataCapabilities.Validate` masks to the known set instead of throwing. - `DataProtoMapper.cs:284`: `Metadata.allowed_operations` masked on decode. `:1054-1062` is already masking (kept). +- **Two more node-side sites, found in X0:** artifact data-row parsing (`DeploymentArtifact.DataConnections.cs`) and origin + catalog compile (`LocalExportCatalog.Compilation.cs`) re-ran the authoring validator. + - Both now call `DataConnectionValidator.ValidateDeployed`. It ignores any bit outside `Understood` and still validates + the understood subset. + - Export rules and staged mapping copies are masked too. + - Drops are logged, counted (tag `kind`) and shown in node diagnostics (`docs/plans/evidence/grpc-data-ext/X0.md`). - `DataConnectionValidator.cs:12`: still rejects unknown bits. The known set grows only in the phase that adds the feature (H2, A2), so authoring cannot get ahead of the code. - `ProjectedDataAccess.cs:157`: extended in the phase that acquires with a new operation (H3, A3). @@ -362,6 +368,12 @@ X0 changes: behaviour, no new shapes without the header) is an exit gate of X0, **H2, A2 and A3** — the phases that touch v1 hot paths — so a v1 regression is attributable without a soak baseline. +**Gate extension rule (X0):** the gate drives the real `DataConnectionGrpcService` from the golden request bytes, backed by a +fake origin. +1. Each of H2/A2/A3 first extends that fake origin (and the real-origin variant, a follow-up) to emit its new-shape data. +2. Without the header, the gate must still see the same golden bytes. +3. The goldens are never re-recorded. + **The "every node is on X0" check is procedural (settled).** ConfigDb records no node build or feature level: `ClusterNode` has only identity, ports, flags and `LastSeenAt`. The validator therefore cannot enforce it. diff --git a/docs/plans/evidence/grpc-data-ext/X0.md b/docs/plans/evidence/grpc-data-ext/X0.md index 8c702bf9e..6860dd13d 100644 --- a/docs/plans/evidence/grpc-data-ext/X0.md +++ b/docs/plans/evidence/grpc-data-ext/X0.md @@ -72,65 +72,81 @@ solution. - **Operation bits.** `DataOperations` reserves `HistoryRead`, `AlarmSubscribe`, `AlarmAcknowledge`, `AlarmConfirm` and `AlarmShelve` (32 to 512). `DataOperationSets` is the one authority: `V1`, `Understood` (= `V1` in X0) and `Reserved`. -- **Tolerant readers.** Each drops unknown bits, fail closed: - - `DataConnectionDeploymentRuntime.Apply` drops them per row and counts them (diagnostics property, Warning log, counter - `otopcua.dataconnection.unknown_operations_dropped`); - - `DataCapabilities.Operations` masks in its accessor, both at construction and on `with`; - - `DataProtoMapper` masks metadata and capabilities on decode; +- **Tolerant readers.** Any bit outside `Understood` is dropped, fail closed (an unknown grant is no grant), at every + node-side reader: + - `DataConnectionValidator.ValidateDeployed` re-validates a deployed artifact. It is called by `DeploymentArtifact` + data-row parsing and `LocalExportCatalog.Compile`. + - It ignores every bit outside `Understood`, not only the reservation. A newer central may define bits this build has + never heard of. + - It still validates the understood subset: a row must be non-empty, and a mapping may not grant an understood + operation its connection lacks. + - These two sites were missed by the plan. Before X0 they rejected the whole snapshot (consumer side) or the whole + origin catalog (origin side). + - `DataConnectionDeploymentRuntime.Apply` drops the bits per connection row. - `LocalExportCatalog` masks export rules. -- **Two node-side sites the plan missed.** - - `DeploymentArtifact` data-row parsing and `LocalExportCatalog.Compile` re-ran the authoring validator, which rejects - unknown bits. - - Either would still have rejected a whole snapshot (consumer side) or the whole origin catalog (origin side) when a newer - central authored a reserved bit. - - Both now call `DataConnectionValidator.ValidateDeployed`. This is the same validator, but the reserved bits (32 to 512) - are ignored rather than rejected. Any other unknown bit is still a malformed row. Nothing can author it, and - `GrpcDataArtifactReadTests` (P02) pins `1 << 30` failing closed. - - The runtime, decoders and catalog rules still drop any unknown bit. -- **Grow sites unchanged.** Authoring `Validate`, `ProjectedDataAccess` and `LocalDataServices.Implemented` are unchanged, and - authoring still rejects bit 32. + - `ProjectedMappingDeploymentRuntime.Stage` masks its frozen mapping copies. + - `DataCapabilities.Operations` masks in its accessor, both at construction and on `with`. + - `DataProtoMapper` masks metadata and capabilities on decode. +- **Dropped-bit diagnostics.** + - Every drop is logged as a Warning naming the row id and the bits. + - It is counted on `otopcua.dataconnection.unknown_operations_dropped`, tagged `kind` = connection | export | mapping. + The helper is `UnknownOperationDrops`. + - A drop is counted once per row per accepted artifact change. Re-applying the same revision does not recount, A → B → A + does, and a restart resets. + - Drops are collected under each component's lock and logged after the lock is released. + - Production reader: `NodeDiagnosticsSnapshot` (AdminUI fleet diagnostics). + - Each `DataConnectionDiagnosticsSnapshot` carries `DroppedUnknownOperations` and `MappingsWithDroppedOperations`. + - The node carries `DroppedExportOperations`. +- **Grow sites unchanged.** Authoring `Validate` still rejects everything outside `V1`. `ProjectedDataAccess` and + `LocalDataServices.Implemented` are unchanged. - **Feature header.** `x-otopcua-data-features` is parsed on every RPC after authentication. - The server records requested and effective features. Effective = requested ∩ `SupportedFeatures` = none in X0. - A binary value, or a value longer than 256 characters in total, gets `InvalidArgument`. - The consumer derives the header per selected endpoint. It is always empty in X0, so it is never sent. -- **Proto reservations.** These are comments plus `DataConnectionProtoContract` constants and descriptor golden tests: - - Capabilities 16 (`history`) and 17 (`conditions`); - - Metadata 14 (`history`); - - SubscriptionItem 4 (`condition_scope`); - - SubscriptionFrame arm 9 (`condition_states`). +- **Proto reservations.** These are comments plus `DataConnectionProtoContract` constants: + - Capabilities 16 `HistoryCapabilities history` and 17 `ConditionCapabilities conditions`; + - Metadata 14 `HistoryInfo history`; + - SubscriptionItem 4 `ConditionScope condition_scope`; + - SubscriptionFrame oneof `frame` arm 9 `ConditionStates condition_states`. - No field was added, so the server advertises nothing new. -- **Recorded-v1-client gate.** `GrpcDataV1CompatibilityTests` (Host.Tests) replays recorded v1 requests for all six RPCs - against the real `DataConnectionGrpcService` and a deterministic origin. It compares `ToByteArray()` hex with goldens - captured on pre-X0 master `2e4e4063` (commit `3279a7f9d`, before any X0 change). - - No field is time-varying, so nothing is normalised. - - It runs with no header and with `history,conditions`. - - H2, A2 and A3 rerun it unchanged. + The descriptor tests pin name, singular message type and oneof, so `string history = 16` fails. + `DataConnectionProtoContract.Validate()` (frozen numbers plus reservations) now runs at host start in + `AddOtOpcUaDataConnections`, when data connections are enabled. No field was added, so the server advertises nothing new. + +### Recorded-v1-client gate: what is real and what is faked + +`GrpcDataV1CompatibilityTests` (Host.Tests) works as follows. + +- **Inputs.** It parses each recorded v1 request from `GrpcDataV1Goldens.Requests`, the golden hex itself (not + re-encoded), and calls the six RPCs in-process. +- **Real.** + - `DataConnectionGrpcService`: header parsing, authentication seam, readiness and permission gates, budget clamping, + response serving stamp, size checks and the subscription delivery sink; + - `DataProtoMapper` (all encoders and decoders); + - `DataConnectionAuthenticator` with a real API key. +- **Faked.** + - The origin facade behind `IDataConnectionFactory`: a deterministic fake `Origin`, not `LocalDataServices`, + `LocalExportCatalog` or `DataCapabilitiesProvider`; + - the gRPC/HTTP2 transport: a hand-built `ServerCallContext`. Response marshalling is the generated `ToByteArray()`. +- **Assertions.** + - Response bytes equal goldens captured on pre-X0 master `2e4e4063` (commit `3279a7f9d`, before any X0 change). Nothing + varies, so nothing is normalised. + - This holds with no header, and with `history,conditions` (the server supports nothing yet). + - The v1 rejection statuses keep their code, detail and empty trailers, with and without the header: Unimplemented + major, PermissionDenied for each missing grant. + - A binary or oversized header gets `InvalidArgument` with the family's existing detail and no trailers. +- **Not covered: a real-origin variant** (`LocalDataServices` + `LocalExportCatalog` + `DataCapabilitiesProvider`). It needs + the Runtime.Tests origin fixture rebuilt in Host.Tests through public APIs, plus its own golden set captured against + pre-X0 code. That was judged too heavy for X0 and is left as a follow-up. +- **Rule for H2, A2 and A3.** + 1. First extend the fake `Origin` (and the real-origin variant, once it exists) so it emits that phase's new-shape data: + history info, conditions, and the new operation bits in metadata and capabilities. + 2. Then, **without the header**, the test must still see the same golden bytes. + 3. **Never re-record the goldens**. A difference is a v1 wire regression. ## 3. Gate runs -Run on macOS, on worktree HEAD `d89bc8619`, 2026-11-23: - -| Gate | Result | -|---|---| -| `dotnet build ZB.MOM.WW.OtOpcUa.slnx` | succeeded, 0 warnings, 0 errors | -| `run-unit-phase.py X0` | passed, 80 tests | -| P01 / P02 / P03 / P04 / P05 | passed: 53 / 212 / 239 / 541 / 938 | -| P06 / P07 / P08 / P09 | passed: 353 / 454 / 618 / 248 | -| `pytest test_unit_phase_runner.py` | 30 passed | - -The full unit suites of the touched projects, filtered `Category!=E2E&Category!=LiveIntegration`, all passed: - -| Project | Passed | -|---|---| -| Core.Abstractions | 849 | -| Commons | 484 | -| Configuration | 314 | -| Runtime | 1,833 (3 pre-existing skips) | -| Host | 414 | -| ControlPlane | 476 | - -The first P02/P07 run, before `75cf5eb8f`, failed. That fix is described in its commit message. +GATE_RESULTS_PLACEHOLDER Commands: @@ -138,4 +154,5 @@ Commands: dotnet build ZB.MOM.WW.OtOpcUa.slnx python3 scripts/validation/grpc-data/run-unit-phase.py X0 # and P01 … P09 python3 -m pytest scripts/validation/grpc-data/test_unit_phase_runner.py +dotnet test --filter "Category!=E2E&Category!=LiveIntegration" ```