feat(grpc-data): X0 review - tolerate any unknown bit at the artifact/catalog seam; drop diagnostics for exports and mappings
- ValidateDeployed ignores every bit outside Understood (understood subset still validated); P02's two 1<<30 rows become 'tolerated, grants nothing'. - UnknownOperationDrops: Warning + counter tagged kind=connection|export|mapping, counted once per row per accepted artifact change; collected under each lock, logged after release. Mappings masked at Stage. - Surfaced via DataConnectionDiagnosticsSnapshot (DroppedUnknownOperations, MappingsWithDroppedOperations) and NodeDiagnosticsSnapshot.DroppedExportOperations. - End-to-end test: 1<<30 through parse -> catalog compile -> mapping stage -> runtime apply. - DataConnectionProtoContract.Validate() now runs at AddOtOpcUaDataConnections.
This commit is contained in:
+39
@@ -29,6 +29,12 @@ public sealed class ProjectedMappingDeploymentRuntime : IDisposable
|
||||
private object _configuredStamp = new();
|
||||
private bool _disposed;
|
||||
|
||||
private IReadOnlyDictionary<string, (string ConnectionId, DataOperations Bits)> _droppedOperations =
|
||||
new Dictionary<string, (string, DataOperations)>();
|
||||
private string? _droppedRevision;
|
||||
/// <summary>Diagnostics sink for the X0 dropped-operation warning (init so the DI constructor shape is unchanged).</summary>
|
||||
public Microsoft.Extensions.Logging.ILogger Logger { private get; init; } = Microsoft.Extensions.Logging.Abstractions.NullLogger.Instance;
|
||||
|
||||
public ProjectedMappingDeploymentRuntime(LocalCatalogCoordinator coordinator, RemoteNamespaceResolver resolver)
|
||||
{
|
||||
_coordinator = coordinator ?? throw new ArgumentNullException(nameof(coordinator));
|
||||
@@ -123,13 +129,45 @@ public sealed class ProjectedMappingDeploymentRuntime : IDisposable
|
||||
ArgumentNullException.ThrowIfNull(connections);
|
||||
var frozenMappings = mappings.Select(Copy).ToArray();
|
||||
var frozenConnections = connections.Select(Copy).ToArray();
|
||||
// X0 tolerant reader: a mapping bit this build does not implement grants nothing. Mask the frozen copies (the
|
||||
// caller's rows are untouched) so every downstream check sees only understood operations.
|
||||
var dropped = new Dictionary<string, (string ConnectionId, DataOperations Bits)>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var mapping in frozenMappings)
|
||||
{
|
||||
var unknown = UnknownOperationDrops.Unknown(mapping.AllowedOperations);
|
||||
if (unknown == DataOperations.None) continue;
|
||||
mapping.AllowedOperations &= DataOperationSets.Understood;
|
||||
dropped[mapping.RemoteNamespaceMappingId] = (mapping.DataConnectionId, unknown);
|
||||
}
|
||||
var report = false;
|
||||
lock (_gate)
|
||||
{
|
||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||
if (!ReferenceEquals(attempt, _attempt)) return;
|
||||
_staged = frozenMappings;
|
||||
_connections = frozenConnections;
|
||||
_droppedOperations = dropped;
|
||||
report = dropped.Count != 0 && !string.Equals(_droppedRevision, attempt.Revision, StringComparison.Ordinal);
|
||||
_droppedRevision = attempt.Revision;
|
||||
}
|
||||
// Collected under _gate, reported after release.
|
||||
if (report)
|
||||
UnknownOperationDrops.Report(Logger, UnknownOperationDrops.MappingKind, attempt.Revision,
|
||||
dropped.ToDictionary(x => x.Key, x => x.Value.Bits, StringComparer.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
/// <summary>X0 diagnostics: the staged mappings whose unknown operation bits were dropped, by mapping id.</summary>
|
||||
public IReadOnlyDictionary<string, DataOperations> DroppedUnknownOperations
|
||||
{
|
||||
get { lock (_gate) return _droppedOperations.ToDictionary(x => x.Key, x => x.Value.Bits, StringComparer.OrdinalIgnoreCase); }
|
||||
}
|
||||
|
||||
/// <summary>Per data connection id, how many of the staged mappings had unknown operation bits dropped.</summary>
|
||||
public IReadOnlyDictionary<string, int> CaptureDroppedByConnection()
|
||||
{
|
||||
lock (_gate)
|
||||
return _droppedOperations.Values.GroupBy(x => x.ConnectionId, StringComparer.OrdinalIgnoreCase)
|
||||
.ToDictionary(x => x.Key, x => x.Count(), StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
internal void AttemptBegan(CatalogAttempt attempt)
|
||||
@@ -144,6 +182,7 @@ public sealed class ProjectedMappingDeploymentRuntime : IDisposable
|
||||
Volatile.Write(ref _configuredStamp, new object());
|
||||
_configuredCapabilities.Clear();
|
||||
_staged = []; _connections = [];
|
||||
_droppedOperations = new Dictionary<string, (string, DataOperations)>();
|
||||
changed = _active.Count != 0;
|
||||
Volatile.Write(ref _active, Array.Empty<ProjectedMappingPlacement>());
|
||||
_byMapping.Clear();
|
||||
|
||||
Reference in New Issue
Block a user