Replays recorded v1 requests against the real DataConnectionGrpcService over the real origin stack (LocalExportCatalog.Compile from a DraftSnapshot with Raw + UNS exports, DataCapabilitiesProvider, PartitionedSampleHub, LocalDataServices, DataWriteExecutor, LocalSubscriptionService/DataSubscriptionSession). Only the physical driver write dispatch, upstream acquisition, transport and clock are faked. Goldens captured on pre-H2 master 1086593a; nothing normalised. Runtime gains InternalsVisibleTo Host.Tests for the Subscribe/Write seams. Class added to the X0 manifest; X0.md section 2 records real vs faked, determinism, the perturbation proof and the rule for H2/A2/A3.
18 KiB
X0 evidence: tolerant readers and contract reservation
Phase X0 of docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md. It has two parts:
- the provenance of revision 4's settled offline investigations (plan §5.1, §5.5, §5.6, §9.3);
- what X0 changed, and the gate runs.
1. Revision 4 investigations (provenance)
All three investigations were offline, against the pinned OPCFoundation.NetStandard.Opc.Ua.Server 2.0.1
(Directory.Packages.props). The second Fable pass reviewed them in
docs/plans/2026-11-23-grpc-data-connections-history-alarms-relay-plan-review.md (§"B5 — ICallAsyncNodeManager.CallAsync:
confirmed", N5, m-T7). That pass could not re-run the harness, because the harness was not yet in the repo. It is committed
here.
(a) SDK Call dispatch trace (B5, plan §5.6 step 1)
The trace was decompiled with ilspycmd from
~/.nuget/packages/opcfoundation.netstandard.opc.ua.server/2.0.1/lib/net10.0/Opc.Ua.Server.dll. The excerpts were kept in
the session scratchpad and are not committed (SDK source). Files and members used:
| Step | Decompiled file | Member |
|---|---|---|
| Service entry, async end to end | StandardServer.cs |
StandardServer.CallAsync awaits ServerInternal.NodeManager.CallAsync |
| Master hand-off | Opc.Ua.Server.MasterNodeManager.cs |
MasterNodeManager.CallAsync → NodeManagerServiceDispatcher.CallAsync; managers wrapped by ToAsyncNodeManager() |
| Validation, then per-manager await | Opc.Ua.Server.NodeManagerServiceDispatcher.cs |
CallAsync runs ValidateCallRequestItemAsync (GetManagerHandleAsync, FindMethodStateAsync, ValidatePermissionsAsync). It marks bad items Processed, then awaits IAsyncNodeManager.CallAsync on each registered manager sequentially, with ConfigureAwait(false) |
| Adapter decision | Opc.Ua.Server.AsyncNodeManagerAdapter.cs |
CallAsync: if (SyncNodeManager is ICallAsyncNodeManager m) return m.CallAsync(...), else the synchronous Call (checked at call time, ≈ line 269) |
| Lock scope during validation | Opc.Ua.Server.CustomNodeManager2.cs |
FindMethodState holds lock (Lock) only around ValidateNode + FindMethod |
| Where the lock is taken today | Opc.Ua.Server.CustomNodeManager2.cs |
Call → CallSynchronousBatch → GetMethodCalls, which skips Processed items and locks per owned item. NM adds its own lock (Lock) in ReportAfterMethod |
| Interface | Opc.Ua.Server.ICallAsyncNodeManager.cs |
ValueTask CallAsync(OperationContext, ArrayOf<CallMethodRequest>, IList<CallMethodResult>, IList<ServiceResult>, CancellationToken) |
Conclusion: OtOpcUaNodeManager can implement ICallAsyncNodeManager. It claims imported-condition calls (sets Processed),
runs base.Call for the rest, and then awaits the claimed calls with no NM Lock held. Lock-freedom stays a hard A3 gate (L3).
The review added two non-blocking notes, both now in §5.6:
base.Callruns underBeginNodeManagerOperation(). Finish it before awaiting.- Managers are awaited sequentially. A mixed batch delays later-registered managers.
(b) Condition node and byte count (N5, plan §5.5)
The harness is harness/Program.cs and harness/count.csproj, copied verbatim. It builds each condition type with the
optional children NM adds before Create(): ConfirmedState, Confirm, ShelvingState and MaxTimeShelved
(NM:2461-2475). It then counts the tree through GetChildren.
| Type | Nodes | Objects / variables / methods |
|---|---|---|
AlarmConditionType |
48 | 2 / 38 / 8 |
OffNormalAlarmType |
49 | 2 / 39 / 8 |
DiscreteAlarmType |
48 | 2 / 38 / 8 |
Quality, BranchId and Comment are present.
Retained size is ≈ 157 KiB per condition (160,997 B). It was measured on 2,000 OffNormal instances as a
GC.GetTotalMemory(true) delta.
- It excludes NM's indexes, the
c1.identifier strings, the EventId registry and placement sets (m-T7). - L2 (A3 exit) is the authority for
MaxImportedConditionBytes.
(c) Snapshot-copy timing (plan §5.1)
The same harness copies the snapshot fields of each of the 2,000 OffNormalAlarmState instances into a record. It takes
3.3–5.8 ms per 2,000 over three warm runs, which is ≈ 1.7–2.9 µs per condition.
- At
MaxConditions1,000, oneLockhold is ≈ 2–3 ms. - This was measured outside the server. L1 (A1) measures the real hold under load.
To re-run: dotnet run -c Release --project docs/plans/evidence/grpc-data-ext/harness/count.csproj. It is not part of the
solution.
2. What X0 changed
-
Operation bits.
DataOperationsreservesHistoryRead,AlarmSubscribe,AlarmAcknowledge,AlarmConfirmandAlarmShelve(32 to 512).DataOperationSetsis the one authority:V1,Understood(=V1in X0) andReserved. -
Tolerant readers. Any bit outside
Understoodis dropped, fail closed (an unknown grant is no grant), at every node-side reader:DataConnectionValidator.ValidateDeployedre-validates a deployed artifact. It is called byDeploymentArtifactdata-row parsing andLocalExportCatalog.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).
- It ignores every bit outside
DataConnectionDeploymentRuntime.Applydrops the bits per connection row.LocalExportCatalogmasks export rules.ProjectedMappingDeploymentRuntime.Stagemasks its frozen mapping copies.DataCapabilities.Operationsmasks in its accessor, both at construction and onwith.DataProtoMappermasks 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, taggedkind= connection | export | mapping. The helper isUnknownOperationDrops. - 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
DataConnectionDiagnosticsSnapshotcarriesDroppedUnknownOperationsandMappingsWithDroppedOperations. - The node carries
DroppedExportOperations.
- Each
-
Grow sites unchanged. Authoring
Validatestill rejects everything outsideV1.ProjectedDataAccessandLocalDataServices.Implementedare unchanged. -
Feature header.
x-otopcua-data-featuresis 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.
- The server records requested and effective features. Effective = requested ∩
-
Proto reservations. These are comments plus
DataConnectionProtoContractconstants:- Capabilities 16
HistoryCapabilities historyand 17ConditionCapabilities conditions; - Metadata 14
HistoryInfo history; - SubscriptionItem 4
ConditionScope condition_scope; - SubscriptionFrame oneof
framearm 9ConditionStates condition_states.
The descriptor tests pin name, singular message type and oneof, so
string history = 16fails.DataConnectionProtoContract.Validate()(frozen numbers plus reservations) now runs at host start inAddOtOpcUaDataConnections, when data connections are enabled. No field was added, so the server advertises nothing new. - Capabilities 16
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);DataConnectionAuthenticatorwith a real API key.
- Faked.
- The origin facade behind
IDataConnectionFactory: a deterministic fakeOrigin, notLocalDataServices,LocalExportCatalogorDataCapabilitiesProvider; - the gRPC/HTTP2 transport: a hand-built
ServerCallContext. Response marshalling is the generatedToByteArray().
- The origin facade behind
- Assertions.
- Response bytes equal goldens captured on pre-X0 master
2e4e4063(commit3279a7f9d, 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
InvalidArgumentwith the family's existing detail and no trailers.
- Response bytes equal goldens captured on pre-X0 master
- Real-origin variant:
GrpcDataV1RealOriginCompatibilityTests(#918), described in the next subsection. The fake-origin gate stays as the transport-layer pin (it reaches optional v1 fields, such as engineering units and a continuation token, that the real catalog never emits). - Rule for H2, A2 and A3.
- First extend the fake
Originand the real-origin fixture (RealOrigin) so they emit that phase's new-shape data: history info, conditions, and the new operation bits in metadata, capabilities and the exports. - Then, without the header, both gates must still see their golden bytes.
- Never re-record the goldens. A difference is a v1 wire regression.
- First extend the fake
Recorded-v1-client gate, real-origin variant (#918)
GrpcDataV1RealOriginCompatibilityTests + GrpcDataV1RealOriginGoldens (Host.Tests, Phase=X0). The fake-origin gate
cannot see a regression inside the origin: H2 grows LocalDataServices.Implemented(target) (HistoryRead),
DataCapabilitiesProvider and LocalExportCatalog.Compilation.cs (Metadata.history, header-gated). A headerless v1
call could then change while the fake-origin gate stays green. This variant closes that gap. Its goldens were captured on
pre-H2 master 1086593a.
-
Fixture.
RealOrigincompiles aDraftSnapshotwithLocalExportCatalog.Compile, the production path. It has one Raw export and one UNS export, bothCluster-rooted with the v1 operation set.- Raw
Plant/Modbus/dev1/…:Speed(Int32, writable),Temperature(Double),Label(String),Running(Boolean),Levels(UInt16[3]),Flow(Double,isHistorized+historianTagname) andHighTemp(Boolean,alarmintent). - UNS
Area1/Line1/Filler/…: referencesSpeed,FlowRate(display override ofFlow) andLevels. - Five tags get a sample through real hub ingress.
FlowandHighTempnever do, so they readWaitingForInitialData.
- Raw
-
Scenarios. Each request is driven from its golden request hex, with no header and with
history,conditions.- GetCapabilities.
- Browse of the raw device and of the UNS equipment.
- GetMetadata of 11 views, including a NotFound.
- Read of 8 items: every scalar kind, the array, the never-published historized tag, a UNS reference and a NotFound.
- Write of 4 items: raw and UNS writes are dispatched; a read-only and a missing node are rejected before dispatch. A positive control asserts that the two admitted writes reached the driver route.
- Subscribe, up to its initial frames: ack (raw, UNS, array, NotFound), SnapshotBegin, one Values frame per item, and SnapshotEnd. The "client" then cancels the call.
- Reject paths, code + detail + empty trailers, with and without the header: Unimplemented major 2, and PermissionDenied
when the exports lack Browse, Metadata, Read or Subscribe. Write without the grant is pinned as body bytes
(
Write/no-write-grant).
-
Real.
DataConnectionGrpcServiceandDataProtoMapper;DataConnectionAuthenticatorwith a real API key;DataPlaneAuthorityStatewith aClusterOperatorNodeAcl,TriePermissionEvaluatorandDataOperationPolicy;CatalogActivationandLocalExportCatalog.Compile;DataCapabilitiesProvider,PartitionedSampleHub,LocalDataServices;DataWriteExecutor, with itsWriteOperationRegistryandWriteValueBudget. The fake route publishes the outcome through a realLateWriteObserverreservation, as the driver host does;LocalSubscriptionService,DataSubscriptionSessionandSubscriptionTransportCapacity.
-
Faked.
- The physical driver write dispatch (
IDataWriteRoute): a fixed route, answering DriverConfirmedSuccess. - The physical upstream acquisition (
ISubscriptionDemandSource): Good, settings unrevised. - The gRPC/HTTP2 transport: a hand-built
ServerCallContext. - The clock:
FrozenClock, which never advances and never fires a timer.
Production reaches the two driver seams through the Akka
DriverHostActor, which is out of scope here. - The physical driver write dispatch (
-
Visibility. Subscribe and Write need internal Runtime seams, so
ZB.MOM.WW.OtOpcUa.Runtime.csprojgainedInternalsVisibleTo ZB.MOM.WW.OtOpcUa.Host.Tests. It did not exist before. The seams areLocalSubscriptionService,ISubscriptionDemandSource,DataWriteExecutorandIDataWriteRoute, the same ones Runtime.Tests use. -
Determinism. Nothing is normalised. Every input that could vary is fixed instead:
- the API key id and secret (not
ApiKeySecret.Generate); - the serving incarnation;
- the frozen clock, so ages are 0, timestamps are fixed and no lease or heartbeat timer runs;
- the catalog and authority epochs, which are process-local counters starting at 1 (the fixture throws if that changes);
- the hub watermark (5, one per published sample).
Browse pages are sized so that no continuation token is emitted: the token is HMAC'd with a per-process random key and is the one field that would need normalising.
Normaliseis the single place a later phase may add a listed normalisation.Bytes were identical across 9 recorder runs (Debug) and 5
run-unit-phase.py X0runs (Release). - the API key id and secret (not
-
Red/green. Each perturbation was made temporarily, run, and reverted. The fake-origin gate stayed green in all of them.
Perturbation Real-origin result Implemented+HistoryRead, withUnderstood+HistoryReadand the fixture exports granting it (an un-gated H2)GetCapabilities fails, with and without the header Compileemits an extra metadata field (engineering units on every variable)Browse, Browse/uns and GetMetadata fail DataCapabilitiesProvidercompact codec version 1 → 2GetCapabilities fails Implemented+HistoryReadalone, withUnderstoodstillV1Green, correctly: the X0 tolerance masks the bit off the wire The last row matters for H2.
LocalDataServices.Metadata()iterates a fixed list of the five v1 operations, so a new bit reaches metadata only when that list grows. Capabilities show it as soon asUnderstood,Implementedand an export all carry it. -
Rule for H2, A2 and A3.
- Extend
RealOrigin's snapshot with the phase's new-shape data: historized tags withHistoryInfo, alarm-bearing tags with conditions, and exports granting the new bits. - Still expect these exact bytes without the header.
- Expect them with the header too, until the server advertises the feature in
SupportedFeatures. - Never re-record.
- Extend
3. Gate runs
Run on macOS, 2026-11-23, on HEAD 981c60784: every code and test change, after the review fixes. The only later commit
is this results table.
| Gate | Result |
|---|---|
dotnet build ZB.MOM.WW.OtOpcUa.slnx |
succeeded, 0 warnings, 0 errors |
run-unit-phase.py X0 |
passed, 95 tests |
| P01 / P02 / P03 / P04 / P05 | passed: 53 / 213 / 239 / 542 / 939 |
| P06 / P07 / P08 / P09 | passed: 353 / 455 / 619 / 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 | 485 |
| Configuration | 314 |
| Runtime | 1,835 (3 pre-existing skips) |
| Host | 424 |
| ControlPlane | 476 |
| AdminUI | 2,689 |
Final round (second Fable pass, approve; three small fixes 9b29a5f65, 5453c20d9, 87c9f9c0b), re-run on HEAD
87c9f9c0b: X0 passed 99 tests; P02 213, P07 456, P08 620 passed; Runtime 1,837 (3 pre-existing skips) and
Configuration 314 passed. Follow-ups: #918 (real-origin variant of the v1 gate, required before the H2 exit), #919
(render the dropped-operation diagnostics in AdminUI).
#918 (real-origin variant), macOS, 2026-11-23, on master 1086593a plus the #918 change:
run-unit-phase.py X0passed 5 runs in a row, 127 tests each. Host.Tests contributed 71: 43 fake-origin and 28 real-origin.- The full Host.Tests suite (
Category!=E2E&Category!=LiveIntegration) passed 454.
History of failed runs:
- The first P02/P07 run (before
75cf5eb8f) failed.- P02 pinned
1 << 30as malformed. The review later reversed that; it is now tolerated. - P07 reflects over the runtime constructor.
- P02 pinned
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 <touched project> --filter "Category!=E2E&Category!=LiveIntegration"