From 6a621423f4eab0b7c0d338fb8ea7fed85ced63d0 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Mon, 23 Nov 2026 21:53:58 -0500 Subject: [PATCH] fix(grpc-data): H2 review 8 - history timeout rides the artifact, not the trust-scope fingerprint DataConnectionScopeRevision covers consumer/connection/secret scope only; limits (TimeoutMilliseconds and now HistoryTimeoutMilliseconds) reach DB-less nodes and the LocalDb cache in the artifact's entity JSON. Dropping the field also avoids a one-time scope-version bump on upgrade. Plan 6 corrected. --- ...1-23-grpc-data-connections-history-alarms-plan.md | 2 +- .../Validation/DataConnectionScopeRevision.cs | 4 +--- .../GrpcDataHistoryConfigurationTests.cs | 12 +++++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md b/docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md index ae7ccc6ba..582faa617 100644 --- a/docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md +++ b/docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md @@ -962,7 +962,7 @@ NodeId: accepted under owner decision Q2, as removal + addition + RefreshRequire | A2 (host options, not ConfigDb) | — | `DataConnections:MaxImportedConditionNodes` (122500), `DataConnections:MaxImportedConditionBytes` (400 MiB), `DataConnections:ConditionKnownSignalTimeout:` (origin; 120 s), `DataConnections:ConditionKnownSettle:OpcUaClient` (origin backstop for upstreams without ConditionRefresh; 60 s), `DataConnections:ConditionKeySecret` (secret) | Each migration phase also adds the bits to `KnownOperations`, extends `DeploymentArtifact.DataConnections.cs`, and includes the -new fields in `DataConnectionScopeRevision` (so DB-less nodes and the LocalDb artifact cache receive them). It also adds +new fields in the artifact (limits ride the artifact's entity JSON to DB-less nodes and the LocalDb artifact cache, like `TimeoutMilliseconds`; they are NOT part of the trust-scope fingerprint `DataConnectionScopeRevision`, which covers consumer/connection/secret scope only — H2 review). It also adds validator rules: mapping bits ⊆ connection bits, limits positive, `AllowGalaxyServiceAck` only with `AlarmAcknowledge`, and (A2) a warning when Σ `MaxConditions` of a consumer node's mappings × 49 (the counted worst-case subtree) exceeds `MaxImportedConditionNodes`. Each also grows `LocalDataServices.cs:47` `Implemented(target)`. diff --git a/src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Validation/DataConnectionScopeRevision.cs b/src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Validation/DataConnectionScopeRevision.cs index 622b2509f..caab73cba 100644 --- a/src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Validation/DataConnectionScopeRevision.cs +++ b/src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Validation/DataConnectionScopeRevision.cs @@ -15,9 +15,7 @@ public static class DataConnectionScopeRevision var entries = connections.Where(c => c.Enabled).SelectMany(c => c.ConsumerNodeIds.Select(node => new { Owner = c.ClusterId.ToUpperInvariant(), Consumer = node.ToUpperInvariant(), - Connection = c.DataConnectionId.ToUpperInvariant(), SecretOwner = c.SecretScopeClusterId.ToUpperInvariant(), Secret = c.SecretReference, - // H2 (plan §6): new connection fields are part of the scope so DB-less nodes and the LocalDb cache re-scope on a change. - c.HistoryTimeoutMilliseconds + Connection = c.DataConnectionId.ToUpperInvariant(), SecretOwner = c.SecretScopeClusterId.ToUpperInvariant(), Secret = c.SecretReference })).OrderBy(x => x.Owner, StringComparer.Ordinal).ThenBy(x => x.Consumer, StringComparer.Ordinal) .ThenBy(x => x.Connection, StringComparer.Ordinal).ThenBy(x => x.SecretOwner, StringComparer.Ordinal).ThenBy(x => x.Secret, StringComparer.Ordinal).ToArray(); var fingerprint = Convert.ToHexString(SHA256.HashData(JsonSerializer.SerializeToUtf8Bytes(entries))); diff --git a/tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests/DataConnections/GrpcDataHistoryConfigurationTests.cs b/tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests/DataConnections/GrpcDataHistoryConfigurationTests.cs index 79edf1884..d3e48fdb2 100644 --- a/tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests/DataConnections/GrpcDataHistoryConfigurationTests.cs +++ b/tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests/DataConnections/GrpcDataHistoryConfigurationTests.cs @@ -67,18 +67,20 @@ public sealed class GrpcDataHistoryConfigurationTests } [Fact] - public void The_scope_revision_includes_the_history_timeout() + public void Limits_ride_the_artifact_so_the_trust_scope_revision_ignores_the_history_timeout() { + // The scope fingerprint covers credential/trust scope only (consumer, connection, secret); limits such as + // TimeoutMilliseconds and HistoryTimeoutMilliseconds travel in the artifact's entity JSON (GrpcDataArtifactReadTests). var connection = new DataConnection { DataConnectionId = "c", ClusterId = "a", Enabled = true, ConsumerNodeIds = ["n"], SecretScopeClusterId = "a", SecretReference = "s", }; var first = DataConnectionScopeRevision.Advance(0, null, [connection]); - DataConnectionScopeRevision.Advance(first.Version, first.Fingerprint, [connection]).Version.ShouldBe(first.Version); connection.HistoryTimeoutMilliseconds = 5000; - var changed = DataConnectionScopeRevision.Advance(first.Version, first.Fingerprint, [connection]); - changed.Fingerprint.ShouldNotBe(first.Fingerprint); - changed.Version.ShouldBe(first.Version + 1); + connection.TimeoutMilliseconds = 7000; + var same = DataConnectionScopeRevision.Advance(first.Version, first.Fingerprint, [connection]); + same.Fingerprint.ShouldBe(first.Fingerprint); + same.Version.ShouldBe(first.Version); } [Fact]