docs(grpc-data): X0 review - real vs faked layers of the v1 gate, extension rule, extra tolerance sites, drop counter semantics

This commit is contained in:
Joseph Doherty
2026-11-23 18:28:53 -05:00
parent 4c03d9025d
commit 981c60784c
3 changed files with 87 additions and 54 deletions
+8 -4
View File
@@ -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 - **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. 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), - An X0 node drops any operation bit it does not implement from that row only, fail closed (an
and logs a warning naming the connection. It also counts it: unknown grant is no grant). This applies to connections, exports and mappings alike.
`otopcua.dataconnection.unknown_operations_dropped`. Exports and mappings are read the same way. - Each drop is logged as a warning naming the row and counted on
Authoring still rejects the bits until the release that implements them. `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 - 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. feature, and an X0 consumer never sends it, so the wire behaviour is unchanged v1.
@@ -352,6 +352,12 @@ X0 changes:
grant) and counted in diagnostics. They no longer throw for the whole snapshot. 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. - `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). - `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 - `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. (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). - `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 — 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. 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` **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. has only identity, ports, flags and `LastSeenAt`. The validator therefore cannot enforce it.
+67 -50
View File
@@ -72,65 +72,81 @@ solution.
- **Operation bits.** `DataOperations` reserves `HistoryRead`, `AlarmSubscribe`, `AlarmAcknowledge`, `AlarmConfirm` and - **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`. `AlarmShelve` (32 to 512). `DataOperationSets` is the one authority: `V1`, `Understood` (= `V1` in X0) and `Reserved`.
- **Tolerant readers.** Each drops unknown bits, fail closed: - **Tolerant readers.** Any bit outside `Understood` is dropped, fail closed (an unknown grant is no grant), at every
- `DataConnectionDeploymentRuntime.Apply` drops them per row and counts them (diagnostics property, Warning log, counter node-side reader:
`otopcua.dataconnection.unknown_operations_dropped`); - `DataConnectionValidator.ValidateDeployed` re-validates a deployed artifact. It is called by `DeploymentArtifact`
- `DataCapabilities.Operations` masks in its accessor, both at construction and on `with`; data-row parsing and `LocalExportCatalog.Compile`.
- `DataProtoMapper` masks metadata and capabilities on decode; - 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. - `LocalExportCatalog` masks export rules.
- **Two node-side sites the plan missed.** - `ProjectedMappingDeploymentRuntime.Stage` masks its frozen mapping copies.
- `DeploymentArtifact` data-row parsing and `LocalExportCatalog.Compile` re-ran the authoring validator, which rejects - `DataCapabilities.Operations` masks in its accessor, both at construction and on `with`.
unknown bits. - `DataProtoMapper` masks metadata and capabilities on decode.
- Either would still have rejected a whole snapshot (consumer side) or the whole origin catalog (origin side) when a newer - **Dropped-bit diagnostics.**
central authored a reserved bit. - Every drop is logged as a Warning naming the row id and the bits.
- Both now call `DataConnectionValidator.ValidateDeployed`. This is the same validator, but the reserved bits (32 to 512) - It is counted on `otopcua.dataconnection.unknown_operations_dropped`, tagged `kind` = connection | export | mapping.
are ignored rather than rejected. Any other unknown bit is still a malformed row. Nothing can author it, and The helper is `UnknownOperationDrops`.
`GrpcDataArtifactReadTests` (P02) pins `1 << 30` failing closed. - A drop is counted once per row per accepted artifact change. Re-applying the same revision does not recount, A → B → A
- The runtime, decoders and catalog rules still drop any unknown bit. does, and a restart resets.
- **Grow sites unchanged.** Authoring `Validate`, `ProjectedDataAccess` and `LocalDataServices.Implemented` are unchanged, and - Drops are collected under each component's lock and logged after the lock is released.
authoring still rejects bit 32. - 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. - **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. - 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`. - 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. - 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: - **Proto reservations.** These are comments plus `DataConnectionProtoContract` constants:
- Capabilities 16 (`history`) and 17 (`conditions`); - Capabilities 16 `HistoryCapabilities history` and 17 `ConditionCapabilities conditions`;
- Metadata 14 (`history`); - Metadata 14 `HistoryInfo history`;
- SubscriptionItem 4 (`condition_scope`); - SubscriptionItem 4 `ConditionScope condition_scope`;
- SubscriptionFrame arm 9 (`condition_states`). - SubscriptionFrame oneof `frame` arm 9 `ConditionStates condition_states`.
No field was added, so the server advertises nothing new. The descriptor tests pin name, singular message type and oneof, so `string history = 16` fails.
- **Recorded-v1-client gate.** `GrpcDataV1CompatibilityTests` (Host.Tests) replays recorded v1 requests for all six RPCs `DataConnectionProtoContract.Validate()` (frozen numbers plus reservations) now runs at host start in
against the real `DataConnectionGrpcService` and a deterministic origin. It compares `ToByteArray()` hex with goldens `AddOtOpcUaDataConnections`, when data connections are enabled. No field was added, so the server advertises nothing new.
captured on pre-X0 master `2e4e4063` (commit `3279a7f9d`, before any X0 change).
- No field is time-varying, so nothing is normalised. ### Recorded-v1-client gate: what is real and what is faked
- It runs with no header and with `history,conditions`.
- H2, A2 and A3 rerun it unchanged. `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 ## 3. Gate runs
Run on macOS, on worktree HEAD `d89bc8619`, 2026-11-23: GATE_RESULTS_PLACEHOLDER
| 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.
Commands: Commands:
@@ -138,4 +154,5 @@ Commands:
dotnet build ZB.MOM.WW.OtOpcUa.slnx dotnet build ZB.MOM.WW.OtOpcUa.slnx
python3 scripts/validation/grpc-data/run-unit-phase.py X0 # and P01 … P09 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 python3 -m pytest scripts/validation/grpc-data/test_unit_phase_runner.py
dotnet test <touched project> --filter "Category!=E2E&Category!=LiveIntegration"
``` ```