22 KiB
H3 evidence — consumer OPC UA projection of remote history
Phase H3 of docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md, 2026-11-24.
What changed
- Projected access level.
ProjectedVariableDefinition.Historizing(set by the applier and the exact-item renewal fromProjectedHistoryAccess.Advertises(proof)= mapping∧export grantHistoryReadand the origin's negotiatedHistoryInfo.Historizing). Only then is the nodeHistorizingwithCurrentRead | HistoryRead; it follows renewals in place (ApplyProjectedHistorizing, underLock, a change-mask notify).HistoryWriteis never set. OpcUaServer/IProjectedHistoryAccess.cs: SDK-free contract —ReadAsync(caller, DataHistoryDetails, nodes, deadline, ct),ProjectedHistoryNode(NodeId, AggregateId, Resume),ProjectedHistoryOutcome(status, OriginHistorySample[], next)and the opaqueProjectedHistoryContinuation(idempotentRelease,TryClaimForResume).- Override split (
OpcUaServer/ProjectedHistoryRead.cs, a NM partial). Raw/Processed/AtTime overrides authorize as before, thenServeHistoryReadSplit: with no projected handle the H1 adapter is called exactly as before; otherwise local handles go to the H1 port and projected handles (mapped/raw, mapped/uns namespaces) toProjectedHistoryAccess, every outcome written to its handle's ownresults[i]/errors[i]. The remote half runs under the same process-wide batch limiter, block-bridged once per batch; the SDK has releasedLockbefore it dispatches the overrides and nothing here takes it. Modified reads ⇒BadHistoryOperationUnsupported; an aggregate the consumer cannot name ⇒BadAggregateNotSupported, unsent. HistoryCursorKind.Remote+HistoryContinuationState.Remote: the cursor lives in the SDK session store, bound to the node (realm, identifier, namespace tag) and the consumer's history epoch. A take marks the SDK pointTaken; any other dispose of the point (session close, oldest-eviction,releaseContinuationPoints→ReleaseHistory, a faulted request) callsRemote.Release()(decompiled SDK 2.0.1SessionContinuationPoints:Clear,AddHistoryContinuationPointeviction,ReleaseHistory,ReleaseSavedHistoryall dispose the stored value). A cursor of another node/kind/epoch is refusedBadContinuationPointInvalidand released.Runtime/DataConnections/ProjectedHistoryAccess.cs: per node aDataOperations.HistoryReaddemand throughProjectedDataAccess.TryAcquire(allowlist extended; requiresdefinition.Historizing; policyAuthorizeMapped(HistoryRead)⇒ mapping bit + localNodePermissions.HistoryReadon the mapping scope, ACLs on or off), described byTryDescribeHistoryDemand(mapping id/revision, connection, origin metadata, serving, generation). Groups = (connection, details, resumed endpoint|fresh) so a resumed item never shares a call with items that may move. TheRemoteCursorbinds caller key (principal, key, credential version), mapping id+revision, connection id + leaseRouteIdentity, projection generation, origin view, serving (node, incarnation, serving generation, role), the ORIGINAL details and aggregate;CursorMatchesre-checks all of it on resume, and the route identity before the call; any change ⇒BadContinuationPointInvalidand the origin token released. Per-request assembly budget = minMaxHistoryAssemblyBytesPerRequestof the batch's mappings, charged in request order across groups; a node that does not fit and every later node ⇒BadTooManyOperations(its origin cursor released). Deadline = min(remainingHistoryReadDeadline,HistoryTimeoutMilliseconds— the connection applies the latter) ⇒BadTimeout; a cancel is never an origin fault. Releases coalesce per connection (25 ms) into oneReleaseHistoryAsync. Values: Raw/AtTime checked against the catalog kind (BadTypeMismatch); Processed values keep their aggregate's own scalar kind.DataPlaneAuthorizer: mapped HistoryRead opened deliberately via an explicit allowlist (Browse/Read/Write*/TransferSubscriptions/ HistoryRead); every other mapped operation stays closed. DI/host:ProjectedHistoryAccessregistered besideProjectedDataAccess;OtOpcUaServerHostedServicewiresNodeManager.ProjectedHistoryAccess.- H2 pin replaced:
HistoryRead_on_a_projected_node_stays_a_clean_refusal_until_H3(Runtime) becameGranted_projected_HistoryRead_is_served_verbatim…(granted ⇒ served) andWithout_the_local_HistoryRead_grant…(⇒BadUserAccessDenied, unsent), both tagged H2 + H3. - Client.
IOpcUaClientService.HistoryReadPageAsync(one page verbatim) and CLIhistoryread --page-size / --pause-after-page / --resume-when-file / --held-marker-file / --fresh-after-failure / --abandon-after-page / --release-after-page / --hold-seconds / --at-time. Defect found by the gate (H02, pre-existing): Client.Shared processed reads sent the SDK's defaultAggregateConfiguration(all false/0), which this server refusesBadAggregateConfigurationRejected(#677) — CLI/UI--aggregatenever worked against OtOpcUa; nowUseServerCapabilitiesDefaults = true(OI regression test, red without). - Defect found by the gate (H02, H3): projected Processed values were decoded against the node's catalog kind (a Double
Average of a UInt16 node ⇒ null +
BadTypeMismatchper interval under a Good result). Fixed; the wire test now asserts the value.
Tests
| Suite | What |
|---|---|
O ProjectedHistoryReadTests (7) |
access bit only when historizing, never HistoryWrite; allow/deny with ACLs off and on (no local grant, no mapping bit, no identity ⇒ BadUserAccessDenied, unsent); mixed local+projected batch keeps slots (one remote call); Remote cursor resumes once (same object), single use, wrong node ⇒ invalid + released, releaseContinuationPoints and session close (store Clear) release; bad remote answer keeps no cursor; consumer-unknown aggregate and modified read unsent; absent bounds |
R GrpcDataConfiguredDiscoveryWireTests H3 (12) |
real consumer SDK session + real projection stack + real origin (LocalDataServices over a real NM history port and PeerHistoryContinuationStore): page-through verbatim to completion (origin store 0); no local grant ⇒ BadUserAccessDenied unsent; session close ⇒ origin continuations 0 and exactly one release call; releaseContinuationPoints; resume after lease expiry (route rotated) and after an origin epoch bump ⇒ invalid, fresh read Good; uncapped Raw returns the origin CP; BadAggregateNotSupported both ways + a served Average's value; Historizing/AccessLevel follow the grant; assembly budget shared across the batch (25 kB ⇒ 2 of 3, 15 kB ⇒ 1, 1.2 kB ⇒ 0, refused in request order, never partial) |
R GrpcDataProjectedHistoryCursorTests (12) |
resume rule: mapping revision change, another mapping/connection, projection rebuild, failover (node), origin restart (incarnation), serving generation, role, origin view, another caller, rotated credential ⇒ refused; epoch-only change resumes |
OI GrpcDataProjectedHistoryWireTests (6) |
real consumer session → real origin NM history port: mixed batch slots + page-through (ACL off/on), single use, session close ⇒ origin cursor store 0 (one release), no grant ⇒ denied unsent (ACL off/on); Client.Shared aggregate + page API |
CLI HistoryReadPagedCommandTests (6) |
paging, pause/resume + fresh, abandon/release + held marker, AtTime, option validation |
Gates
| Gate | Result |
|---|---|
dotnet build ZB.MOM.WW.OtOpcUa.slnx |
0 warnings, 0 errors |
run-unit-phase.py H3 (new key: OpcUaServer.Tests + Runtime.Tests) |
passed (at af0618341) |
run-unit-phase.py H2 |
passed (at af0618341) |
run-unit-phase.py H1, X0, P01–P09 |
all passed (at 07eeea2bd; later commits touch Client/CLI/rig and one Runtime decode path covered by H3/H2 reruns) |
Full unit suites (Category!=E2E&Category!=LiveIntegration) |
OpcUaServer 1415 (+1 skip), Runtime 1882 (+3 skips), Host 479, Client.CLI 224, Client.Shared 361, Client.UI 131 — all green |
OpcUaServer.IntegrationTests Feature=GrpcData + history classes |
87 passed, 2 skips (AVEVA live) |
Rig harness unit tests (scripts/validation/grpc-data/tests) |
296 passed |
The runner accepts unit projects only, so OI is run separately (as H1 did).
Live gate — H01–H06 on both origin backends
Standalone rig (scripts/validation/grpc-data, OrbStack, macOS), fresh run per backend at af0618341, normal build-hash checks
(no --pinned-build), recipe in the rig README §"H3 projected-history gate":
python3 scripts/validation/grpc-data/rig.py up --run-id h3f-<backend> --history --history-backend <sqlserver|questdb> --timeout 900
python3 scripts/validation/grpc-data/rig.py seed --run-id h3f-<backend>
sleep 75
python3 scripts/validation/grpc-data/rig.py deploy --run-id h3f-<backend> --timeout 300
python3 scripts/validation/grpc-data/history_gate.py --run-id h3f-<backend>
python3 scripts/validation/grpc-data/rig.py down --run-id h3f-<backend>
Every read goes through the Client CLI historyread on CONSUMER's OPC UA endpoint, on projected NodeIds resolved by a CLI
browse from the shared root (leaves under the remote-source anchors; the same opaque p1. ids come back after every
deploy — re-browsed, never constructed), and is compared with the same read on the SOURCE primary. Every scenario restored the
baseline.
| ID | SqlServer (h3f-sqlserver, 06:05–06:15 UTC) |
QuestDB (h3f-questdb, 06:14–06:21 UTC) |
|---|---|---|
| H01 Raw paging, Raw + UNS | PASS (38): page size 3 ⇒ 11 pages, 31 rows per realm, last page no CP, row-for-row = origin; single read = origin | PASS (38): 10 pages, 29 rows per realm, = origin (µs timestamps) |
| H02 Processed, aggregate refused for the node type | PASS (28): Average on String text ⇒ BadAggregateNotSupported (origin answers the same); Average on counter 4 intervals = origin |
PASS (28): same; 3 intervals = origin |
| H03 AtTime, integer node | PASS (26): 3 times, values 7/11/15 = origin, UInt16 on both |
PASS (26): 8/12/16 = origin, UInt16 |
| H04 continuation across origin failover | PASS (38): page 1 held; source-1 stopped ⇒ source-2 primary; resumed page BadContinuationPointInvalid; fresh read Good on the new primary |
PASS (38): identical |
| H05 v1 origin ⇒ unsupported (substituted) | PASS (46): Good ⇒ BadHistoryOperationUnsupported once the export drops HistoryRead; the UNS export still Good |
PASS (46): identical |
| H06 denied vs unhistorized; session close; rebuild mid-page | PASS (154): unhistorized scalar and origin-ACL-denied counter ⇒ identical HistoryRead of <node> failed: BadHistoryOperationUnsupported (0x80720000).; no local mapping grant ⇒ BadUserAccessDenied (UNS mapping still Good); origin open continuations 1 while the CLI held page 1, 0 after its session closed; resume after an origin rename (epoch bump) BadContinuationPointInvalid, fresh Good |
PASS (154): identical |
Teardown: rig.py down after each run; label-filtered docker container ls -a / volume / network / image ls ⇒ 0/0/0/0 for both
runs (the QuestDB container and volume carry the run labels). Results files: evidence/H3-history-<backend>-results.json in each
(removed) run folder; copies taken before down.
Earlier passes on h3-sql (pre-fix builds, same rig, down 0/0/0/0) found the two H02 defects above and that a deploy retires
cold projected nodes (BadNodeIdUnknown until re-browsed — the gate now re-browses after every deploy; a client reading a
projected node it has not browsed since a deploy sees the same; pre-existing v1 projection behaviour).
Review (Fable, approve-with-changes) — fixes
Each fix is a new commit; red/green by reverting the fix (mutation) and re-running its test, unless noted.
| # | Finding | Resolution | Red/green |
|---|---|---|---|
| D1 | A deadline during the connection's capability probe faulted the whole HistoryRead (RpcException(Cancelled) escaped) |
GrpcDataConnection turns a caller cancel during the probe into OperationCanceledException and caps the probe by HistoryTimeout; ProjectedHistoryAccess fails any escaping fault per node (BadTimeout when the deadline fired) and releases every cursor it owns; the node manager's catch is total |
client probe tests; wire test (Hang/Throw): local half of a mixed batch served, projected BadTimeout / BadContinuationPointInvalid, origin store back to 0 — both red on revert |
| D2 | Release() after TryClaimForResume() was a no-op ⇒ claimed cursors leaked on post-claim exits |
ProjectedHistoryContinuation.ReleaseEvenIfClaimed() (at most once) on every such exit: no gateway/identity, deadline spent, limiter rejection, gateway fault, count mismatch |
O test over all four exits + a positive control (a normal resume does not release) — red on revert |
| D3 | Projected reads could hold every history batch slot for up to 60 s | projected sub-limit N − max(1, N/4) (OriginHistoryPort.RemoteSlots), Wait(0) ⇒ BadTooManyOperations for the projected half |
O test: 3 held projected reads at N=4, a 4th refused at once, a local read still served — red (hangs, bounded to 5 s) on revert |
| D4 | A group larger than the lease/origin batch failed entirely | sub-batches ≤ min(lease batch, origin's advertised MaxBatchItems) and ≤ one item per 256 B of the remaining budget; shortfall ⇒ BadTooManyOperations per node |
wire test: 3 nodes vs an origin batch of 2 ⇒ calls [2, 1], all Good — red on revert |
| D5 | A Remote cursor presented to a local node was taken and dropped | released in the local (raw/modified) and events take paths | O test — red on revert |
| D6 | Release flush lost wake-up; _stop disposed under a running flush |
_flushScheduled flag under the gate; _stop only cancelled |
2,000 concurrent enqueues all released — not shown red (the race did not reproduce with the fix reverted); kept as a regression check |
| D7 | Budget charged in group order | calls are runs of consecutive request positions read in request order, then charged in request order | wire test [A fresh, B resumed, C fresh] with room for two: C refused, not B — red on revert |
| Float32 | Double from the backend for a Float32 node | no defect: the origin port normalises Raw/AtTime to the node's type (Single) before the wire; Runtime test + live legs (H01/H03: Good Singles = origin) | — |
| H06(a) | Origin-ACL denial exercised only via metadata | also read through the consumer's deployed connection (node probe): denied and unhistorized both 0x80720000, identical pages; the origin's inbound data requests 73 ⇒ 79 |
live |
| Nits | page API default-throwing; probe uncapped; int cast; CLI doc |
HistoryReadPageAsync abstract (fakes implement it); probe capped by HistoryTimeout; budgets stay long; Client.CLI.md notes --aggregate now sends UseServerCapabilitiesDefaults = true |
— |
Gates after the fixes (HEAD 60e594ddd): build 0/0; run-unit-phase.py H3, H2, H1, X0 passed; OI Feature=GrpcData + history
87 passed (2 AVEVA skips); OpcUaServer 1418 (+1 skip), Runtime 1890 (+3 skips), Host 479, Client.CLI 224, Client.Shared 361, Client.UI 131;
rig harness tests OK.
Live re-run (fresh h3r3-sqlserver 07:19–07:28 and h3r3-questdb 07:28–07:35 UTC at 60e594ddd, normal build checks): H01–H06
all PASS on both backends (H06 238 assertions each); Float32 legs Good Singles equal to the origin; H06(c) origin continuations 1
while held, 0 after the session closed; down ⇒ 0/0/0/0 for both runs.
Found on the re-run (pre-existing v1 projection behaviour, not an H3 defect — for a follow-up): an idle projected node's
authority lapses with its 15 s MetadataLeaseMilliseconds; any read after that is BadUserAccessDenied — a value Read exactly as a
HistoryRead (reproduced in the Runtime harness) — and a re-browse served from the still-cached browse page does not renew it
(live: the H06 rebuild leg denied right after a re-browse). The gate now starts each held leg right after a deploy + re-browse.
Review round 3 (approve-with-changes) — fixes
Review of 37cbeff48 + 7aaa98751. Every finding verified before fixing; none skipped. Red/green by reverting the fix (mutation)
and re-running its test, unless noted. Commits 34e72de3d (S4), 9c2d6273a (S1/S2/S3/S6/a), 30d66fdc7 (S5), f1b23abcb (b/c/d).
| # | Finding | Resolution | Red/green |
|---|---|---|---|
| S1 | ServeSplitAsync: an escape (caller cancel, fault) in sub-batch k>0 stranded earlier sub-batches' answers (continuations never released, samples never disposed) |
any escape disposes the collected answers and releases their new continuations on the endpoint (Abandon) |
client test: cancel during sub-batch 2 ⇒ both sub-batch-1 page tokens released — red on revert |
| S2 | later sub-batches sent with MaxBytes = left could break the origin's count <= MaxBytes/256 admission ⇒ RpcException ⇒ RecordFailure + BadNoCommunication, claimed cursors lost |
each sub-batch trimmed to left / MinimumBytesPerItem (shared constant 256); the rest BadTooManyOperations with ConsumerBudgetRefused, unsent; an unsent resumed item's origin token released (still live there) |
client test, fake origin enforcing the rule: [2, 1], rest consumer-refused, next read Good (no backoff) — red on revert ([2, 2], BadNoCommunication) |
| S3 | an assembly overflow inside a sub-batch left used below MaxBytes, so further sub-batches were still sent |
any consumer budget refusal latches spent; the rest answered unsent |
client test: calls [2, 2] (was [2, 2, 1, 1]) — red on revert |
| S4 | budget stop keyed on Diagnostic.Contains("budget"), which matched the ORIGIN's "remainder budget is full" and refused later nodes, incl. Good ones |
internal DataHistoryReadResult.ConsumerBudgetRefused (never on the wire), set only by the connection's own assembly / split refusal; ProjectedHistoryAccess keys on it |
wire test: origin refuses A ⇒ B still read (two runs sent) — red on revert |
| S5 | RpcException(Cancelled) without a caller cancel ⇒ BadTimeout even when the channel-retired / scope / shutdown token fired; the access's outer catch read any escaped OCE as a timeout |
that case ⇒ BadNoCommunication (resumed BadContinuationPointInvalid), chunk tokens released, no further sub-batches; outer catch: BadTimeout only for the caller's cancel or the deadline, else FailCancelled classification |
client test: scope moved mid-call ⇒ fresh BadNoCommunication, resumed BadContinuationPointInvalid — red on revert. Outer catch: no dedicated test (nothing reachable throws past ReadGroupAsync's own catch) |
| S6 | a Verify failure / item mismatch on a follow-up chunk released nothing but samples; ServeSplitAsync swallowed later sub-batch faults silently |
the assembly's catch releases finished nodes' continuations (final[]), held chunk tokens and the rejected response's tokens; a later sub-batch's endpoint fault is RecordFailured |
client test: n0 done on call 1, call 2 malformed ⇒ n0's page token and n1's chunk token released — red on revert |
| a | after a sub-batch endpoint failure further sub-batches were still sent | ServeAsync reports EndpointFailed; nothing more is sent, rest BadNoCommunication / resumed BadContinuationPointInvalid |
client test: calls [2, 2] (was [2, 2, 1]) — red on revert |
| b | a Bad answer to a resumed node left the prior origin cursor open (refused unsent) | ReleaseOrigin() on the prior cursor for any Bad answer (and a mismatched one); idempotent |
wire test: resume answered Bad unsent ⇒ origin open continuations 1 ⇒ 0 — red on revert |
| c | lease dropped an in-flight answer on a scope move without releasing its new continuations; resumed items BadNoCommunication |
dropped answers' continuations released (best effort); resumed BadContinuationPointInvalid |
GrpcDataDeployedHistoryLeaseTests — red on revert |
| d | a throw from SaveRemoteContinuation / FromClr for outcome i stranded outcomes i+1.. |
the loop's catch releases outcome i's cursor unless the store owns it, and every later outcome's | ProjectedHistoryReadTests (unconvertible value on outcome 0 ⇒ outcome 1's cursor released once, outcome 0's left to the store) — red on revert |
Gates after round 3 (HEAD f1b23abcb): build 0/0; run-unit-phase.py H3, H2, H1, X0 passed (H3 107 + 144); OI Feature=GrpcData
- history 87 passed (2 AVEVA skips); OpcUaServer 1419 (+1 skip), Runtime 1903 (+3 skips) (
Category!=E2E&Category!=LiveIntegration); noGrpcDataConfiguredDiscoveryWireTests(#920) flake this run.
Live re-run after round 2 (h3r5-sqlserver, h3r5-questdb at 7aaa98751) and after round 3 (h3r6-sqlserver,
h3r6-questdb at 713cbfb21, 2026-11-24, fresh rig per run, normal build checks): H01–H06 all PASS on both backends, both
rounds (H01 47, H02 34, H03 35, H04 71, H05 58, H06 238 assertions); down ⇒ 0 run containers left. (A first h3r4-sqlserver
attempt failed in seed after an interrupted earlier seed on the same run; torn down and replaced by h3r5.)
Round 3 was itself an independent (Fable) verification of the round-2 commits — approve-with-changes, every finding above fixed.
Not verified / substitutions
- H05: the rig builds no pinned v1 image, so "v1 origin" is substituted by an origin that does not advertise history for the principal (export without bit 32). The v1 wire shape itself is covered by the H2 recorded-v1-client gates; the live v1-origin path is follow-up #921.
- H01 tie clusters: not representable live on either backend — SqlServer
hist.SamplePK(TagId, SourceTimeUtc), QuestDBDEDUP UPSERT KEYS(ts, tag)keep one sample per timestamp. Tie paging is proven by the H1 port fuzz (10k seeds). - ReadyReplica consistency on projected history and the Gateway backend (H4) were not run.
- ACL-off on the live rig: the rig runs
Security:Acl:Enabled=true; ACL-off is covered by O and OI tests. - Diagnostics/metrics for projected history are H4.