diff --git a/docs/DataConnections.md b/docs/DataConnections.md index 6f0968576..0d8f7c776 100644 --- a/docs/DataConnections.md +++ b/docs/DataConnections.md @@ -192,8 +192,67 @@ local OPC UA clients keep at least one slot. At N = 1 there is no reservation: t **Consistency.** History follows the connection's consistency. `ReadyReplica` is allowed; the newest seconds can lag on a secondary while its continuous-historization outbox drains. -**Not supported yet.** OPC UA clients reading history on projected nodes of the consumer (H3); HistoryReadEvents and -modified-value reads (deferred); **HistoryUpdate is never forwarded**. +**Not supported yet.** HistoryReadEvents and modified-value reads (deferred); **HistoryUpdate is never forwarded**. + +## OPC UA HistoryRead on projected nodes (H3) + +Since H3 an OPC UA client of the CONSUMER can HistoryRead (Raw, Processed, AtTime) a projected variable in the +`https://zb.com/otopcua/mapped/raw|uns` namespaces exactly as it reads a local one; the consumer forwards the read over the +mapping's deployed connection (the runtime path above) and returns the origin's Part 11 answer verbatim — statuses, info bits, +timestamps (absent stays absent), values typed as the catalog says (a disagreeing value kind is `BadTypeMismatch`). + +**What a client sees.** A projected variable is `Historizing = true` with the `HistoryRead` access-level bit **only** when the +mapping grants `HistoryRead` (masked by the export's) **and** the origin's negotiated metadata says the node is historizing for +this principal (`HistoryInfo`, bit 32). Otherwise it carries `CurrentRead` only and the SDK answers +`BadHistoryOperationUnsupported` before any remote call. The `HistoryWrite` bit is never set: HistoryUpdate is not forwarded. + +**Grants** — all default off, and all required **even with `Security:Acl:Enabled=false`**, because mapped nodes always enforce the +mapping gate: + +| Where | What | +|---|---| +| Consumer `DataConnection.AllowedOperations` | `HistoryRead` (32) | +| Consumer `RemoteNamespaceMapping.AllowedOperations` | `HistoryRead` (32) | +| Consumer node ACL | `NodePermissions.HistoryRead` for the client's principal on the `RemoteNamespaceMapping` scope (or a scope above it) | +| Origin `DataExport.AllowedOperations` + origin node ACL | as for the runtime path above | + +Without the local grant (or without the mapping bit) the node answers `BadUserAccessDenied` — a local decision, distinct from the +origin's `BadHistoryOperationUnsupported`. An origin-side denial, an unhistorized node and an unknown node stay indistinguishable +(the origin's metadata does not mark the node historizing, so the consumer refuses it `BadHistoryOperationUnsupported`). + +**Mixed batches.** One HistoryRead may mix local and projected nodes: local nodes are served by the local historian exactly as +before, projected nodes remotely, every result in its own slot. The remote half runs under the same process-wide HistoryRead batch +limiter and never holds the node-manager lock. + +**Continuation points.** A projected read's continuation point lives in the client's OPC UA session like a local one (a `Remote` +cursor; capped by `MaxHistoryContinuationPoints`, oldest evicted). It wraps the origin's token and binds the caller (principal, key, +credential version), the mapping id **and revision**, the deployed connection route, the projection generation, the origin view and +the origin serving identity; a resume resends the **original** request details (the origin binds their hash — a client that changes +details on resume gets what it first asked for, as locally). Rules: + +- **A fresh read may move endpoint** within its deadline (a failed SOURCE node ⇒ the next endpoint); **a resumed read never moves**. +- A mapping revision change, a connection redeploy / lease expiry, a failover or origin restart (serving node / incarnation / + generation / role), a projection rebuild, another caller, or an origin history-epoch bump (an origin address-space removal or + rebuild) ⇒ `BadContinuationPointInvalid`; read again from the start. +- **Release:** `releaseContinuationPoints`, the session's close, an eviction and a refused save each forward one best-effort + `ReleaseHistoryAsync` per connection (releases coalesce for ~25 ms, so a session close sends one call per origin). The origin's + 60 s idle expiry is the backstop. +- Uncapped Raw (`NumValuesPerNode = 0`) returns the origin's continuation point (Part 11 permits a short page + CP): the origin pages + at its `MaxHistoryValuesPerPage` ceiling. + +**Limits.** + +| Limit | Effect | +|---|---| +| `RemoteNamespaceMapping.MaxHistoryAssemblyBytesPerRequest` (16 MiB) | One budget per request, shared across the batch (the tightest mapping in the batch). Nodes are charged in request order; once a node does not fit, it and every later projected node is `BadTooManyOperations` (never a partial answer; its origin cursor is released). | +| `ServerHistorian:HistoryReadDeadline` (consumer, 60 s) | The consumer request's remaining deadline, capped per call by `DataConnection.HistoryTimeoutMilliseconds` ⇒ `BadTimeout`. A cancelled request is never counted as an origin fault. | +| Aggregates | An aggregate the consumer cannot name is `BadAggregateNotSupported` unsent; one the origin's backend refuses (unknown to it, or not valid for the node's type — #897) comes back `BadAggregateNotSupported` from the origin. The consumer's `HistoryServerCapabilities/AggregateFunctions` does not describe remote backends. | + +Modified-value reads (`IsReadModified`) and HistoryReadEvents on projected nodes are refused `BadHistoryOperationUnsupported`. + +**Client CLI.** Resolve projected NodeIds by browsing from the mapping anchor (never construct `p1.` ids), then +`otopcua-cli historyread -n "" …`; `--page-size`, `--pause-after-page` and `--abandon-after-page` exercise the +continuation lifecycle (`Client.CLI.md`). Live gate: `scripts/validation/grpc-data/history_gate.py` (H01–H06, README). ## Feature boundary diff --git a/scripts/validation/grpc-data/README.md b/scripts/validation/grpc-data/README.md index 74607f1f4..003edf5d3 100644 --- a/scripts/validation/grpc-data/README.md +++ b/scripts/validation/grpc-data/README.md @@ -93,6 +93,32 @@ the consumer's connection and exports, and seeds a second principal `fixture-noh the probe's `--scenario history` origin RPCs, the CLI `historyread` and the CONSUMER `history` node-probe operation, and checks value parity. Without `--history` the rig, the seed and every D-scenario are unchanged. +## H3 projected-history gate (opt-in) + +`rig.py up --run-id --history [--history-backend sqlserver|questdb]` — `questdb` layers `compose.history.questdb.yml`: +SOURCE historizes into a run-owned QuestDB container (labelled, removed by `down`) instead of the run's SQL container. The H3 +seed profile also: grants HistoryRead on both mappings; gives the CLI principal its CONSUMER HistoryRead **only** through +`RemoteNamespaceMapping`-scoped grants (`cli-history-map-raw|uns`; the cluster grant is `Admin` minus HistoryRead); historizes +`text` (a String node, for the per-type aggregate refusal); and accepts the mutation +`acl_permissions: {node_acl_id, permission_flags}` (one ACL row's flags; the baseline restore reverts it). + +```bash +python3 scripts/validation/grpc-data/rig.py up --run-id h3-sql --history --timeout 900 +python3 scripts/validation/grpc-data/rig.py seed --run-id h3-sql +sleep 75 # CONTROL's ClusterNode contact refresh before the first deploy +python3 scripts/validation/grpc-data/rig.py deploy --run-id h3-sql --timeout 300 +python3 scripts/validation/grpc-data/history_gate.py --run-id h3-sql # H01..H06, or --scenario H04 +python3 scripts/validation/grpc-data/rig.py down --run-id h3-sql +``` + +`history_gate.py` accumulates `counter` history, resolves the projected NodeIds by a CLI `browse` from the shared root +(leaves under the `remote-source` anchors; never constructed `p1.` ids), then runs each `scenarios.json` → +`history_scenarios` row through the Client CLI `historyread` on CONSUMER and compares with the same read on the SOURCE +primary. The continuation scenarios use the CLI's hand-paged mode (`--page-size`, `--pause-after-page`, +`--abandon-after-page`, `--held-marker-file`); the origin's open continuations come from the `topology` node probe +(`originAccounting.historyOpenContinuations`). Every scenario restores the baseline. Results: +`evidence/H3-history--results.json`. + ## Scenario authoring and node probes The seeder is available through `LocalRig.seed_helper(action, *arguments)`. Its