From 25b4fc5c452f0575912f092ce10aa51726f3c08a Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Tue, 24 Nov 2026 08:28:54 -0500 Subject: [PATCH] =?UTF-8?q?docs(grpc-data):=20H4=20evidence=20=E2=80=94=20?= =?UTF-8?q?diagnostics,=20metrics,=20live=20SqlServer=20gate,=20Gateway=20?= =?UTF-8?q?leg=20blocked=20(#923)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/plans/evidence/grpc-data-ext/H4.md | 115 ++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 docs/plans/evidence/grpc-data-ext/H4.md diff --git a/docs/plans/evidence/grpc-data-ext/H4.md b/docs/plans/evidence/grpc-data-ext/H4.md new file mode 100644 index 000000000..9d8f9f81b --- /dev/null +++ b/docs/plans/evidence/grpc-data-ext/H4.md @@ -0,0 +1,115 @@ +# H4 evidence — remote-history diagnostics, metrics, docs (capability "supported") + +Phase H4 of `docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md` (revision 7), 2026-11-24. History part only; +the alarm diagnostics are A4. + +## What changed + +- **`Runtime/DataConnections/DataConnectionHistoryDiagnostics.cs`** (new, DI singleton, no dependencies): shared by the origin + services (`LocalDataServices`), the consumer gateway (`ProjectedHistoryAccess`) and the diagnostics readers + (`DataConnectionDeploymentRuntime`, `DriverHostActor`), so none of them depends on another (the origin composition is resolved + lazily after the driver host exists; a direct dependency would be a cycle). +- **Metrics** on `OtOpcUaTelemetry.Meter` (`ZB.MOM.WW.OtOpcUa`, already in the host's exported-meter allowlist), no ids in labels: + - `otopcua.dataconn.history.reads{variant,status_class,side}` — origin: one per item answered to a peer; consumer: one per + projected node answered to a local OPC UA client. + - `otopcua.dataconn.history.continuations.active{side}` — observable gauge over the live diagnostics instances (weak table). + - `…operations.unknown_bits_dropped`: **reused, not added.** X0's `otopcua.dataconnection.unknown_operations_dropped{kind}` + counts exactly that (one per row per accepted artifact change); a second instrument would double-count. Pinned by + `The_plan_unknown_bit_counter_is_the_existing_X0_instrument_not_a_second_one`. +- **Defect found: the H2 origin counter was never exported.** `otopcua.dataconn.history.reads` sat on a private + `Meter("ZB.MOM.WW.OtOpcUa.DataConnections.History")` that is not in `ObservabilityExtensions.ObservedMeters` (a strict + allowlist), so it was absent from `/metrics` and OTLP. It now lives on the OtOpcUa meter (verified on the live rig's `/metrics`). +- **Consumer evidence per connection** (`ProjectedHistoryAccess`): answers by status class, attributed to the connection the + node resolved to; open consumer continuations — a `RemoteCursor` counts from creation until it is claimed for a resume (new + `ProjectedHistoryContinuation.OnClaimed` hook) or its origin token is released, whichever first, once. +- **Origin evidence per node** (`LocalDataServices.HistoryDiagnostics` init property): backend present, live peer history sessions, + open origin continuations, answers by status class. +- **Negotiated features** (`GrpcDataConnection.RecordSelected`): `RequestedFeatures(capabilities)` and the advertised history + variants + aggregate count. +- **Contracts** (Commons, additive optional members — older senders give null = "unavailable"): + `DataConnectionDiagnosticsSnapshot` + `NegotiatedFeatures, HistoryVariants, HistoryAggregateCount, HistoryReads{Good,Uncertain,Bad}, + OpenRemoteContinuations`; new `OriginHistoryDiagnostics`; `NodeDiagnosticsSnapshot.OriginHistory`. +- **AdminUI** (`ClusterDataConnections.razor`, already inside ``; helpers in `DataConnectionDiagnostics`): per + connection a history line (negotiated features, origin history advertised, projected reads by class, open remote continuations) + and a dropped-unknown-bits line; a new **Origin evidence by node** panel (remote history served, peer sessions, open origin + continuations, answers by class, exports with dropped bits). Dropped bits are named when the AdminUI knows the bit, hex otherwise, + and carry a "node build is older than the authored feature" hint when non-empty. +- **#919 closed by this work:** the X0 fields (`DroppedUnknownOperations`, `MappingsWithDroppedOperations`, + `DroppedExportOperations`) are now rendered on the data-connections page. +- **Docs:** `DataConnections.md` (remote history **supported**, SqlServer/QuestDB verified, Gateway unverified pending #923; + new §"Remote history diagnostics and metrics"; #919 note under Mixed versions), `Historian.md` (§"Remote history over data + connections"), `Client.CLI.md` (projected-history note: opaque `p1.` ids resolved by browse, re-browse after deploy/idle, paging + flags, what is refused). + +## Tests (H4 manifest key) + +| Suite | What | +|---|---| +| R `GrpcDataHistoryMetricsTests` (5, new) | counter on the exported meter with exactly `variant,status_class,side` (no id); gauge reports both sides; per-connection counts case-insensitive, settle never negative; origin evidence null until attached / when its probe throws; unknown-bit counter is X0's | +| R `GrpcDataConfiguredDiscoveryWireTests` H4 (2) | real consumer SDK session + real projection + real origin: page 1 ⇒ consumer `(1,0,0,open 1)` and origin open 1; resume ⇒ `(2,0,0,open 1)`; `releaseContinuationPoints` ⇒ consumer open 0, origin 0 after the coalesced release; an origin-refused aggregate ⇒ one Bad each side; session close ⇒ consumer open 0 | +| R `GrpcDataDeploymentActivationTests` H4 (1) | runtime diagnostics carry per-connection counts (zeros, not null, without traffic; null when no diagnostics wired) | +| AdminUI `GrpcDataHistoryDiagnosticsDisplayTests` (5, new) | features / history-served / counts / dropped-bit rendering (#919) and the older-build hint | +| plus existing | `GrpcDataProjectedHistoryCursorTests`, `GrpcDataOriginHistorySessionTests`, OpcUaServer `ProjectedHistoryReadTests` (base class gained `OnClaimed`), AdminUI `GrpcDataDiagnosticsTests` | + +Red/green: with `RemoteCursor.OnClaimed => Settle()` reverted, the wire test fails at the resume step (consumer open 2, not 1). + +## Gates + +| Gate | Result | +|---|---| +| `dotnet build ZB.MOM.WW.OtOpcUa.slnx` | 0 warnings, 0 errors | +| `run-unit-phase.py H4` (new key: Runtime 25, OpcUaServer 11, AdminUI 9) | passed | +| `run-unit-phase.py H3` / `H2` / `H1` / `X0` | all passed (H3 107 + 144; H2 44/36/7/40/96/25; H1 578 + 17; X0 25/14/5/72/11) | +| AdminUI.Tests (`Category!=E2E&Category!=LiveIntegration`) | 2698 passed | +| Runtime.Tests (same filter) | 1911 passed, 3 skipped | +| OpcUaServer.Tests (same filter) | 1419 passed, 1 skipped | + +## Live gate — H3 scenarios on SqlServer with the metrics and the page + +Fresh run `h4a-sqlserver` (OrbStack, macOS, normal build-hash checks, 2026-11-24 ~12:50–13:10 UTC): +`rig.py up --history --history-backend sqlserver --timeout 900`, `seed`, ~80 s, `deploy --timeout 300`, `history_gate.py`, `down`. + +- **H01–H06 all PASS** (47 / 34 / 35 / 71 / 58 / 238 assertions, every scenario restored). +- **`/metrics` before traffic:** both continuation gauges 0 on every node; no reads series. +- **`/metrics` after the gate:** consumer-1 `reads{side=consumer}` raw good 31, raw bad 2, processed good 1, processed bad 1, + attime good 2; source-2 (primary after H04's failover) `reads{side=origin}` raw good 7, raw bad 2. (The CLI's comparison reads on + the SOURCE primary are local OPC UA reads and are not counted, as designed; source-1 restarted in H04, so its counts restart.) +- **AdminUI page** (`http:///clusters/CONSUMER/data-connections`, login disabled on the rig, prerendered HTML via + `urllib`): consumer-1 `Ready · endpoint https://source-2:4057 · serving source-2 · role Primary`, "Negotiated features History · + origin history raw, processed, attime (19 aggregates) · projected history reads good 34 · uncertain 0 · bad 3 · open remote + continuations (local sessions) 0" — equal to the sum of consumer-1's metric series; "Dropped unknown operation bits: connection + none · mappings with dropped bits 0". The SOURCE page's origin panel: source-2 "remote history served · peer history sessions 0 · + open origin continuations 0 · history items answered good 7 · uncertain 0 · bad 2" — equal to source-2's metric. +- **Held continuation probe** (a scratch script driving the gate's own `HistoryGate.held` on the projected raw `counter`, page size 3, + pause after page 1): while held — consumer-1 gauge `consumer=1`, source-2 gauge `origin=1`, the CONSUMER page "open remote + continuations (local sessions) 1", the SOURCE page "peer history sessions 1"; after resume to completion — both gauges 0, page 0, + projected good 35 ⇒ 54 (19 pages). +- Mid-gate the page showed the connection `Connecting` with features "unavailable" — taken during a scenario's redeploy/failover; + after the gate it read `Ready` with features `History`. +- `down` ⇒ 0 run containers, 0 run volumes. + +## Gateway leg — BLOCKED (#923), substituted by doc scoping + +The plan's required Gateway leg (origin `ServerHistorian:Backend=Gateway` against a local read-only HistorianGateway reading the +real AVEVA Historian over VPN; H01–H04 with reverse/end-only and ceiling-bounded cases) was **not attempted**: the VPN to the +historian is down. Per the plan's fallback, **#923** (`type:deploy-gate`, `blocked`) tracks it, and the docs say remote history is +verified on the **SqlServer and QuestDB** origin backends only, with the **Gateway backend unverified pending #923** +(`DataConnections.md`, `Historian.md`, `Client.CLI.md`). + +## Not verified / notes + +- **Gateway backend** remotely (#923, above). +- **QuestDB** was not re-run for H4: the H4 change is backend-independent (counting around the same port), and the H3 rounds + passed H01–H06 on QuestDB at `713cbfb21`. The brief asked for one SqlServer leg. +- **Browser-rendered** page not driven (no Chrome session used); verified from the server-prerendered HTML, which runs the same + `OnInitializedAsync` + render as the interactive circuit. +- **Akka serialization of the new snapshot members** was exercised only live (the rig's control node read data-node snapshots + through the fleet-diagnostics path and rendered every new field), not by a unit round-trip test. +- **Deviation:** the reads counter carries a third label `side` (origin | consumer) beyond the plan's `{variant,status_class}` — + a node can be both, and without it the two populations would be summed into one series. The gauge carries `side` too. +- Consumer counts include every projected node answered (Bad included), but a node refused by the node manager BEFORE the gateway + (no local HistoryRead grant ⇒ `BadUserAccessDenied`, unhistorized ⇒ `BadHistoryOperationUnsupported` from the SDK) is not counted. + A consumer node shows "remote history evidence unavailable" in the origin panel until something resolves its origin services. +- Counts are since process start (no persistence), as the docs say. +- `GrpcDataConfiguredDiscoveryWireTests` (#920 flaky class): no failure in any run this phase (H4 manifest, H3 manifest, full Runtime suite). +- Umbrella history entry (plan exit gate): **not done here** — it is a commit on `scadaproj` `main` plus a push, and this worktree brief forbids pushing; left to the orchestrator (append to `../scadaproj/.claude/skills/sister-project-history/otopcua.md`). The Gitea close of #919 likewise belongs with the merge.