feat(grpc-data): H2 AddDataConnectionHistory schema; authoring accepts HistoryRead

Migration per plan 6 (HistoryTimeoutMilliseconds 30000; MaxConcurrentHistoryReads 4, MaxHistoryValuesPerPage
10000, MaxHistoryResponseBytes 4 MiB; MaxHistoryAssemblyBytesPerRequest 16 MiB) with non-null defaults and widened
check constraints. Validator known set grows by HistoryRead (mapping bits still subset of connection bits; history
limits positive); scope revision includes the history timeout.
This commit is contained in:
Joseph Doherty
2026-11-23 20:38:31 -05:00
parent 9d194a7e97
commit b6895c19d4
11 changed files with 2280 additions and 15 deletions
@@ -10,10 +10,11 @@ namespace ZB.MOM.WW.OtOpcUa.Configuration.Validation;
public static class DataConnectionValidator
{
/// <summary>
/// The operations AUTHORING may grant. Deliberately the v1 set: it grows only in the phase that implements a bit
/// (H2, A2), so authoring cannot get ahead of the code (plan section 4.3, "grow site").
/// The operations AUTHORING may grant. It grows only in the phase that implements a bit, so authoring cannot get ahead
/// of the code (plan section 4.3, "grow site"): H2 added <see cref="DataOperations.HistoryRead"/> together with
/// <see cref="DataOperationSets.Understood"/> and the origin's <c>Implemented(target)</c>; A2 adds the alarm bits.
/// </summary>
private const DataOperations KnownOperations = DataOperationSets.V1;
private const DataOperations KnownOperations = DataOperationSets.V1 | DataOperations.HistoryRead;
private static readonly StringComparer Ids = StringComparer.OrdinalIgnoreCase;
/// <summary>Authoring/deploy-gate validation: an operation bit outside the known set is an error.</summary>
@@ -122,7 +123,8 @@ public static class DataConnectionValidator
if (!ValidOps(connection.AllowedOperations))
Add("DataConnectionOperationsInvalid", id, "Connection operations must be a supported nonempty subset.");
if (connection.TimeoutMilliseconds <= 0 || connection.MaxBatchItems <= 0 || connection.MaxPageItems <= 0 ||
connection.MaxMessageBytes <= 0 || connection.MaxStreams <= 0 || connection.MaxMonitoredItems <= 0 || connection.MaxPendingBytes <= 0)
connection.MaxMessageBytes <= 0 || connection.MaxStreams <= 0 || connection.MaxMonitoredItems <= 0 || connection.MaxPendingBytes <= 0 ||
connection.HistoryTimeoutMilliseconds <= 0)
Add("DataConnectionLimitInvalid", id, "Connection limits must be positive.");
}
@@ -274,7 +276,8 @@ public static class DataConnectionValidator
(mapping.AllowedOperations.HasFlag(DataOperations.Write) && !mapping.WriteThrough))
Add("DataMappingOperationsInvalid", id, "Mapping operations must be permitted by the connection and write-through policy.");
if (mapping.MaxProjectionNodes <= 0 || mapping.MaxProjectionDepth <= 0 || mapping.MetadataLeaseMilliseconds <= 0 ||
mapping.StaleTimeoutMilliseconds <= 0 || mapping.SamplingIntervalMilliseconds <= 0 || mapping.PublishingIntervalMilliseconds <= 0)
mapping.StaleTimeoutMilliseconds <= 0 || mapping.SamplingIntervalMilliseconds <= 0 || mapping.PublishingIntervalMilliseconds <= 0 ||
mapping.MaxHistoryAssemblyBytesPerRequest <= 0)
Add("DataMappingLimitInvalid", id, "Mapping limits and intervals must be positive and the metadata lease bounded.");
}
foreach (var export in draft.DataExports.Where(x => x.Enabled))
@@ -285,7 +288,8 @@ public static class DataConnectionValidator
!Same(Owner(export.RootKind, export.RootEntityId), export.ClusterId))
Add("DataExportRootInvalid", id, "Export requires a named principal and an origin-local root in its realm.");
if (!ValidOps(export.AllowedOperations)) Add("DataExportOperationsInvalid", id, "Export operations must be a supported nonempty subset.");
if (export.MaxBatchItems <= 0 || export.MaxPageItems <= 0 || export.MaxMonitoredItems <= 0 || export.MaxStreams <= 0)
if (export.MaxBatchItems <= 0 || export.MaxPageItems <= 0 || export.MaxMonitoredItems <= 0 || export.MaxStreams <= 0 ||
export.MaxConcurrentHistoryReads <= 0 || export.MaxHistoryValuesPerPage <= 0 || export.MaxHistoryResponseBytes <= 0)
Add("DataExportLimitInvalid", id, "Export limits must be positive.");
}
return errors;