From efb3a39229bfbe1809ab1ceb30013e6a7b764d1c Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sat, 28 Nov 2026 10:25:31 -0500 Subject: [PATCH] test(grpc-data): live H05 vs pinned 0c86edc1 origin PASS 25/25 (#921) and A09 driver-failure ack revert PASS 12/12 (#927); v1 listener refuses HistoryRead PERMISSION_DENIED; evidence --- docs/DataConnections.md | 4 ++ docs/plans/evidence/grpc-data-ext/A3-927.md | 49 +++++++++++++++ .../evidence/grpc-data-ext/H05-v1-origin.md | 59 +++++++++++++++++++ docs/plans/evidence/grpc-data-ext/H3.md | 2 +- scripts/validation/grpc-data/README.md | 2 +- .../grpc-data/history_v1_origin_gate.py | 21 ++++--- scripts/validation/grpc-data/probe/Program.cs | 7 ++- 7 files changed, 132 insertions(+), 12 deletions(-) create mode 100644 docs/plans/evidence/grpc-data-ext/A3-927.md create mode 100644 docs/plans/evidence/grpc-data-ext/H05-v1-origin.md diff --git a/docs/DataConnections.md b/docs/DataConnections.md index 07fc7c2db..0078a261d 100644 --- a/docs/DataConnections.md +++ b/docs/DataConnections.md @@ -200,6 +200,10 @@ the bit (see "Mixed versions" below); the AdminUI editor shows a reminder. **Negotiation.** The capabilities probe always asks for `history`; an origin advertises it only when a historian backend is configured. Other calls carry the header only toward an endpoint that advertised it. An origin without a historian, a pre-H2 origin, or a call without the header answers unsupported — the v1 responses are unchanged. +Live-gated against a real pre-H2 origin (#921, `docs/plans/evidence/grpc-data-ext/H05-v1-origin.md`): a pre-H2 origin +ignores the probe's header (capabilities byte-identical with and without it), so the consumer's projected variables have +`Historizing` False, HistoryRead answers `BadHistoryOperationUnsupported` locally, and no HistoryRead or feature-headed data +call is sent. (Sent anyway, a HistoryRead is refused `PERMISSION_DENIED` by the old data listener's v1 method allowlist.) **Limits.** diff --git a/docs/plans/evidence/grpc-data-ext/A3-927.md b/docs/plans/evidence/grpc-data-ext/A3-927.md new file mode 100644 index 000000000..0c8ba5279 --- /dev/null +++ b/docs/plans/evidence/grpc-data-ext/A3-927.md @@ -0,0 +1,49 @@ +# #927 — live gate: driver-failure ack revert through DriverHostActor under the connection service principal + +A2b (remote `CallConditionMethod`) had been gated live only for a scripted condition. The path where a remote ack of a +**native** condition reaches a driver that fails it, and DriverHostActor reverts the node (`RevertNativeAlarmAck`, +`AlarmStateUpdate(EstablishesState: false)`), was unit-tested only (`ConditionMethodNodeManagerTests`, A2.md "Driver failure +revert seen in the stream"). This adds scenario **A09** to `scripts/validation/grpc-data/conditions_scenarios.py` and runs it. + +## How the driver is made to fail (a real failure, no seam) + +The conditions profile's SOURCE `OpcUaClient` driver `source-opcua` watches the run-owned `opc-plc:2.14.10 --alm` native alarm +`EastTankYellow`. A09 `docker compose pause`s the `opcplc` container immediately before the consumer's ack. The driver is still +`Connected` (its keep-alive has not yet noticed), so `OpcUaClientDriver.AcknowledgeAsync` sends the upstream +`AcknowledgeableConditionType.Acknowledge` call and gets **no reply**; the SDK call fails with a `ServiceResultException` +(request timeout) inside the 5 s ack window, `DriverInstanceActor.HandleAcknowledgeAsync` reports `AlarmAckFailed`, and +DriverHostActor reverts. The container is unpaused in the scenario's `finally` (and again by the per-scenario restore if it +was left paused). Pausing also freezes opc-plc's own alarm cycling, so no upstream transition can explain the +Unacknowledged that follows the ack. + +**Why not an upstream refusal.** The option the issue suggests — an upstream that answers the Acknowledge with a Bad status +(stale EventId, already acked) — does **not** revert today: `OpcUaClientDriver.AcknowledgeAsync` only logs a per-ack Bad +result (and an ack whose condition id resolves to nothing), by design (`docs/drivers/OpcUaClient.md`: "a reply still returns +normally, including per-ack refusals … a refusal is the server answering"), to keep refusals off the AlarmAcknowledge breaker. +`DriverOperationRefusedException` now exists for exactly that (breaker-exempt, reverts), so an upstream refusal leaving the +node Acknowledged is a gap — reported as a follow-up, not changed here (it reverses a documented driver decision). A +no-reply transport failure is the failure class the driver does surface, and it exercises the whole revert path. + +## Result — run `a927-1`, 2026-11-28, HEAD `cdbbe22a9`: A09 **PASS** (12/12) + +`rig.py up --conditions` → `seed` → 85 s → `deploy --timeout 300` → `conditions_scenarios.py --only A09` → `rig.py down` +(0 run containers, 0 run volumes). + +| Check | Evidence | +|---|---| +| native condition present on both sides, Unacknowledged | consumer `EastTankYellow` `Inactive, Unacknowledged` (opaque `ns=6;s=c1.…` id), origin `ns=2;s=opcua/opcplc/EastTankYellow` same record time | +| caller gets Good | 15:13:40 `opcplc` paused; consumer CLI `ack` ⇒ `Acknowledge successful` (plan §5.6 step 5: native ⇒ Good, `AcceptedUnconfirmed`; the failure reaches the caller as the revert) | +| audit records the remote call | origin `source-1`: `Data-connection condition method Acknowledge by fixture-consumer (key …) on Raw:…:opcua/opcplc/EastTankYellow op a3-…: AcceptedUnconfirmed 0x00000000; on behalf of fixture-cli` — the connection's **service principal** (`fixture-consumer`) on behalf of the end user | +| the driver really failed | 15:13:46 `DriverInstance source-opcua: native-alarm acknowledge of opcua/opcplc/EastTankYellow failed` | +| DriverHostActor reverted (EstablishesState: false) | 15:13:46 `DriverHost source-1:4053: … did not reach the alarm system (the upstream acknowledge failed (ServiceResultException)); reverting the condition to unacknowledged` — `RevertNativeAlarmAck` is the only producer of that line and of an `EstablishesState: false` update | +| origin node applied, then reverted | origin Server-object events after the ack: `Inactive, Acknowledged` → `Inactive, Unacknowledged` (nothing else: upstream frozen) | +| consumer saw the reverted delta | consumer events after the ack: `Inactive, Acknowledged` → `Inactive, Unacknowledged`; same ConditionId, a new EventId | +| positive control | 15:13:48 unpaused; 30 s later the condition was `Active, Unacknowledged` (opc-plc had re-activated it; whether the paused call was later applied upstream is not observable from this state); a second consumer ack of the current EventId ⇒ Good and **no** new revert line in the next 15 s | + +Evidence files (removed with the run folder; copies taken before `down`): `evidence/A4S-A09.json`, `A4S-results.md`, the CLI +`*.process.json` logs. + +## Not covered + +- The upstream-refusal flavour (Bad per-ack status) — it does not revert; follow-up above. +- `/alerts` (alarm-history) rows for the ack and its revert were not asserted. diff --git a/docs/plans/evidence/grpc-data-ext/H05-v1-origin.md b/docs/plans/evidence/grpc-data-ext/H05-v1-origin.md new file mode 100644 index 000000000..9df80a922 --- /dev/null +++ b/docs/plans/evidence/grpc-data-ext/H05-v1-origin.md @@ -0,0 +1,59 @@ +# #921 — H05 live gate against a real pre-H2 (v1) origin + +The H3 gate replaced H05 ("v1 origin ⇒ unsupported") with an origin export that drops HistoryRead (H3.md "Not verified / +substitutions"). That removes `Historizing` before any wire call, so the plan §4.3 mixed-version row "new consumer → v1 origin" +was never exercised live. This gate runs it against a SOURCE pair built from a pinned pre-H2 commit. + +## Rig additions (`scripts/validation/grpc-data/`, README "Pinned pre-H2 SOURCE") + +- `rig.py up --source-revision `: `resolve_pinned_source_revision` requires X0 `a15912539` to be an ancestor (a pre-X0 + node rejects the whole snapshot once a newer bit is authored), H2 `ef938b435` **not** to be one, and no `rpc HistoryRead` in + that revision's `data_connection.proto`. **`0c86edc19`** (the #918 merge, between H1 and H2 on master's first-parent line) + passes; it is post-X0 (tolerant readers, feature header parsed with `SupportedFeatures = None`), its + `LocalDataServices.Implemented()` has no HistoryRead and its proto has no HistoryRead RPC — a genuine v1 origin. +- The rig `git archive`s it into the run folder, adds one rig file (`node-probe/WireTap.cs`, ASP.NET Core only, compiled + unchanged against the pinned tree) and builds the pinned tree's own Dockerfile (`compose.source-pinned.yml`). CONTROL and + CONSUMER run this checkout. `verify_candidate` checks SOURCE stamps against the pinned revision and export hash, the other + four against this checkout. Unit tests: `PinnedSourceRevisionTests` (6, incl. the real `0c86edc1` / H2 commits). +- **Wire tap** (`GRPC_DATA_WIRE_TAP=1`, only on the pinned SOURCE): per data-listener request, one line at arrival (gRPC path, + `x-otopcua-data-features` value, remote address — before authentication) and one at completion (gRPC status). No credential + or body. +- `Client.CLI read --attribute ` (new; `Historizing`, `AccessLevel`, …) for a real OPC UA attribute read. +- `history_v1_origin_gate.py` (H05V1) and probe `--scenario history-v1-origin`. + +## Result — run `h05v1-1`, 2026-11-28 15:20–15:26 UTC: **PASS, 25/25 checks** + +`rig.py up --history --source-revision 0c86edc1 --timeout 1500` → `seed` → 80 s → `deploy --timeout 300` (all six nodes +applied the HEAD-built artifact, including the pinned SOURCE pair) → `history_v1_origin_gate.py` → `down` (0 containers, +0 volumes, 0 images left). SOURCE has a SqlServer historian and historizes `counter` (the `--history` overlay). + +| Assertion | Observed | +|---|---| +| builds | `source-1/2` stamp `0c86edc194bf…` (pinned export hash `1111f654…`); `control-*`, `consumer-*` stamp HEAD `cdbbe22a9` | +| projected Raw + UNS `counter` `Historizing` | `False` (Good) on both; `AccessLevel` = 1 (CurrentRead, no HistoryRead bit) | +| control: origin's own `counter` | `Historizing` `True`, `AccessLevel` = 13 (HistoryRead bit set); projected value Read Good on both realms | +| `historyread` on projected Raw / UNS `counter` | `HistoryRead of ns=4;s=p1.… failed: BadHistoryOperationUnsupported (0x80720000).` (UNS `ns=5` same) | +| control: `historyread` on the origin's node | Good, 30–31 rows in the window | +| diagnostics (CONSUMER page, prerendered) | `Negotiated features none (v1 behaviour) · origin history not advertised · projected history reads good 0 · uncertain 0 · bad 0` | +| diagnostics (SOURCE page) | `Exports with dropped unknown operation bits: export-raw: HistoryRead; export-uns: HistoryRead — this node's build is older than a feature authored here; the dropped bits grant nothing until the node is upgraded.` | +| tap, consumer window (12 arrivals, all from the two consumer containers, no other remote) | methods `GetCapabilities, Browse, GetMetadata, Read` (control: the consumer's v1 traffic is there); **no** `HistoryRead` / `CallConditionMethod`; the only arrivals carrying the feature header are the capability probes (`history,conditions`, plan §4.1: the probe always asks) | +| tap positive control (probe `history-v1-origin`, both origins) | capabilities with `history,conditions` byte-identical to capabilities without (operations 31, no `history`, no `conditions`); a HistoryRead with header `history` arrives at the tap with that header and completes **`grpc-status 7` (PERMISSION_DENIED)** | + +**Finding (harness expectation, not a product defect).** The first pass (same run) failed two expectations of mine, both +corrected in the harness and re-run green: +1. A sent HistoryRead is refused **PERMISSION_DENIED**, not the UNIMPLEMENTED the issue/plan text guessed. At `0c86edc1`, + `DataConnectionEndpoints` admits only its six v1 methods (`GetCapabilities, Browse, GetMetadata, Read, Write, Subscribe`) on + the data listener and refuses any other path before gRPC routing. A current consumer never sends one (the tap shows it), so + this only affects a hand-rolled caller; documented in `DataConnections.md`. +2. The first projected value Read answered `BadWaitingForInitialData`; the gate now retries only that status (bounded 60 s), + as every mapped positive read on this rig does (README). + +The re-run used `--pinned-build` (harness and probe source edited after `up`; images unchanged, probe republished). + +Evidence (run folder removed by `down`; copies taken before): `evidence/H05V1-results.json`, `probe/source-1/wire-tap.jsonl`. + +## Not covered + +- Subscribe / Write from the consumer to the v1 origin did not occur in the window (the gate reads via the CLI); the H2/A2 + recorded-v1-client gates cover the header-less shapes of those calls. +- Conditions against a v1 origin (`--conditions` with a pinned SOURCE) were not run. diff --git a/docs/plans/evidence/grpc-data-ext/H3.md b/docs/plans/evidence/grpc-data-ext/H3.md index f27bfbe42..6ea9fa12a 100644 --- a/docs/plans/evidence/grpc-data-ext/H3.md +++ b/docs/plans/evidence/grpc-data-ext/H3.md @@ -173,7 +173,7 @@ Round 3 was itself an independent (Fable) verification of the round-2 commits - **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**. + path is follow-up **#921** — since run live against a pinned pre-H2 origin (`0c86edc1`), PASS 25/25: `H05-v1-origin.md`. - **H01 tie clusters**: not representable live on either backend — SqlServer `hist.Sample` PK `(TagId, SourceTimeUtc)`, QuestDB `DEDUP 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. diff --git a/scripts/validation/grpc-data/README.md b/scripts/validation/grpc-data/README.md index 3f9cd6578..e23196ba4 100644 --- a/scripts/validation/grpc-data/README.md +++ b/scripts/validation/grpc-data/README.md @@ -172,7 +172,7 @@ python3 scripts/validation/grpc-data/rig.py down --run-id h05v1 and — from the tap — no consumer call but the capability probe carries the feature header and no HistoryRead/CallConditionMethod reaches the origin. Controls: the origin's own `counter` is historizing and its `historyread` returns rows; the consumer's v1 calls are in the same tap window; the probe's `--scenario history-v1-origin` sends new-shape calls (capabilities with the header are -byte-identical to without; HistoryRead ⇒ `UNIMPLEMENTED`) and the tap records them. +byte-identical to without; HistoryRead ⇒ `PERMISSION_DENIED`: a pre-H2 data listener admits only its six v1 methods) and the tap records them. ## Scenario authoring and node probes diff --git a/scripts/validation/grpc-data/history_v1_origin_gate.py b/scripts/validation/grpc-data/history_v1_origin_gate.py index 2934ca6b7..d53945a80 100644 --- a/scripts/validation/grpc-data/history_v1_origin_gate.py +++ b/scripts/validation/grpc-data/history_v1_origin_gate.py @@ -24,8 +24,9 @@ What is asserted (results: the run's restricted `evidence/H05V1-results.json`): Subscribe) present in the same window (control). The capability probe itself always carries the client's features (plan §4.1); a v1 origin ignores the header, which (6) shows byte-for-byte; 6. tap positive control: the probe's `history-v1-origin` scenario sends new-shape calls to both pinned origins — capabilities - with the feature header answer byte-identically to capabilities without it, a HistoryRead with the header answers - UNIMPLEMENTED (the wire path the plan's row names) — and the tap records those arrivals with the header. + with the feature header answer byte-identically to capabilities without it, a HistoryRead with the header is refused + PERMISSION_DENIED (a pre-H2 data listener admits only its six v1 methods and refuses any other path before routing — not + the UNIMPLEMENTED the plan's table guessed) — and the tap records those arrivals with the header and that status. """ import argparse import html @@ -101,9 +102,15 @@ class V1OriginGate(history_gate.HistoryGate): def value_read(self, node, node_id, name): argv = ["dotnet", str(self.runner.cli_dll), "read", "-u", self.runner.endpoint(node), "-U", "apikey", "-P", self.runner.key, "-n", node_id, "--max-age", "5000"] - result = self.runner.process(argv, self.runner.active + "-" + name + "-" + uuid.uuid4().hex[:6], timeout=60) - status = re.search(r"^Status:\s*(\S+)", result.stdout, re.M) - return status[1] if status else None + # As every mapped positive read on this rig: retry only an explicit BadWaitingForInitialData (README), bounded. + end = time.monotonic() + 60 + while True: + result = self.runner.process(argv, self.runner.active + "-" + name + "-" + uuid.uuid4().hex[:6], timeout=60) + status = re.search(r"^Status:\s*(\S+)", result.stdout, re.M) + observed = status[1] if status else None + if observed != "BadWaitingForInitialData" or time.monotonic() >= end: + return observed + time.sleep(2) def history(self, node, node_id, name): result = self.cli(node, ["-n", node_id, *self.window_args(), "--max", "50"], name) @@ -230,7 +237,7 @@ class V1OriginGate(history_gate.HistoryGate): self.runner.process(argv, "H05V1-probe", timeout=120) report = scenarios.restricted_json(output) if output.exists() else {"passed": False} self.detail["probe"] = report - self.check("probe_v1_origin_capabilities_identical_and_history_read_unimplemented", report.get("passed") is True) + self.check("probe_v1_origin_capabilities_identical_and_history_read_refused", report.get("passed") is True) time.sleep(1) after = {node: rows[before[node]:] for node, rows in self.taps().items()} control = {} @@ -244,7 +251,7 @@ class V1OriginGate(history_gate.HistoryGate): and self.method(row) == "GetCapabilities" and row.get("features"))} self.check(f"tap_recorded_probe_history_read_with_header_{node}", history_arrivals and all(row.get("features") == "history" for row in history_arrivals)) - self.check(f"tap_recorded_unimplemented_status_{node}", completions and all(row.get("grpcStatus") == "12" for row in completions)) + self.check(f"tap_recorded_permission_denied_status_{node}", completions and all(row.get("grpcStatus") == "7" for row in completions)) self.detail["tap_control"] = control diff --git a/scripts/validation/grpc-data/probe/Program.cs b/scripts/validation/grpc-data/probe/Program.cs index 788457f9e..ad4aeb54c 100644 --- a/scripts/validation/grpc-data/probe/Program.cs +++ b/scripts/validation/grpc-data/probe/Program.cs @@ -466,8 +466,9 @@ try { // lmxopcua#921 (H05 against a pinned pre-H2 origin): what a NEW caller sees from a v1 origin when it asks for the // features. Capabilities with the full feature header are byte-identical to those without it (no history, no - // conditions, no HistoryRead bit), and a HistoryRead with the header is answered UNIMPLEMENTED: the method does not - // exist on that build. This deliberately sends new-shape calls, so on a wire-tapped origin it is also the tap's + // conditions, no HistoryRead bit), and a HistoryRead with the header is refused PERMISSION_DENIED: a pre-H2 data + // listener admits only its six v1 methods (DataConnectionEndpoints.Methods at that revision) and refuses any other + // path before gRPC routing, so the call never reaches a handler (observed live, #921). This deliberately sends new-shape calls, so on a wire-tapped origin it is also the tap's // positive control (the tap must record them). failurePhase = ProbeFailurePhase.WireOperation; var fixture = root.GetProperty("fixture"); @@ -514,7 +515,7 @@ try historyRead = "OK"; } catch (RpcException error) { historyRead = error.StatusCode.ToString(); } - results.Add(new("history-v1-origin-" + name, "history-v1-origin", v1Shape && identical && historyRead == "Unimplemented", 3, new() + results.Add(new("history-v1-origin-" + name, "history-v1-origin", v1Shape && identical && historyRead == "PermissionDenied", 3, new() { ["withoutHeader"] = new { operations = plain.Operations, historyPresent = plain.History is not null, conditionsPresent = plain.Conditions is not null, protocolMinor = plain.ProtocolMinor, bytes = plain.CalculateSize() },