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:
Joseph Doherty
2026-11-23 18:28:48 -05:00
parent 59a1654dfe
commit 4d29d539d8
15 changed files with 304 additions and 54 deletions
@@ -34,4 +34,8 @@ public sealed record DataConnectionDiagnosticsSnapshot(
long? CompactFrameCount = null,
long? FallbackFrameCount = null,
long? SerializedValueFrameBytes = null,
string? AccountingInstanceId = null);
string? AccountingInstanceId = null,
// X0 tolerant reader: operation bits this connection row was authored with that this node does not implement and
// dropped (None = nothing dropped; null = from an older sender), and how many of its mappings had bits dropped.
DataOperations? DroppedUnknownOperations = null,
int? MappingsWithDroppedOperations = null);
@@ -43,10 +43,15 @@ public sealed record DriverInstanceDiagnostics(
/// needs to be explicitly visible rather than inferred. Defaults to false, which is also what
/// every node that booted normally reports.
/// </param>
/// <param name="DroppedExportOperations">
/// X0 tolerant reader: origin exports on this node whose operation bits this build does not implement, with the
/// bits dropped (no grant). Empty when none; null from a sender built before X0 or when no catalog is staged.
/// </param>
public sealed record NodeDiagnosticsSnapshot(
NodeId NodeId,
RevisionHash? CurrentRevision,
IReadOnlyList<DriverInstanceDiagnostics> Drivers,
DateTime AsOfUtc,
bool RunningFromCache = false,
IReadOnlyList<DataConnectionDiagnosticsSnapshot>? DataConnections = null);
IReadOnlyList<DataConnectionDiagnosticsSnapshot>? DataConnections = null,
IReadOnlyDictionary<string, ZB.MOM.WW.OtOpcUa.Core.Abstractions.DataConnections.DataOperations>? DroppedExportOperations = null);
@@ -21,10 +21,11 @@ public static class DataConnectionValidator
/// <summary>
/// Node-side re-validation of an already-deployed artifact (artifact parse, origin catalog compile). Identical to
/// <see cref="Validate(DraftSnapshot)"/> except that the X0-RESERVED operation bits (<see cref="DataOperationSets.Reserved"/>)
/// are IGNORED rather than rejected: a newer central may author them, and rejecting would take down every data
/// connection/export on the node. Each consumer of the rows keeps only the bits it understands (fail closed). A bit
/// outside both sets is still a malformed row (nothing can author it).
/// <see cref="Validate(DraftSnapshot)"/> except that operation bits outside <see cref="DataOperationSets.Understood"/>
/// are IGNORED rather than rejected (X0 tolerant reader): a newer central may author them, and rejecting would take
/// down every data connection/export on the node. The understood subset is still validated (a row must be non-empty;
/// a mapping may not grant an understood operation its connection lacks), and every consumer of the rows masks the
/// rest away, so an unknown bit grants nothing (fail closed).
/// </summary>
public static IReadOnlyList<ValidationError> ValidateDeployed(DraftSnapshot draft) => Validate(draft, deployed: true);
@@ -34,8 +35,8 @@ public static class DataConnectionValidator
var errors = new List<ValidationError>();
void Add(string code, string id, string message) => errors.Add(new(code, message, id));
bool Same(string? a, string? b) => Ids.Equals(a, b);
var accepted = deployed ? KnownOperations | DataOperationSets.Reserved : KnownOperations;
bool ValidOps(DataOperations operations) => operations != DataOperations.None && (operations & ~accepted) == 0;
bool ValidOps(DataOperations operations) => operations != DataOperations.None &&
(deployed || (operations & ~KnownOperations) == 0);
DataOperations Understood(DataOperations operations) => deployed ? operations & DataOperationSets.Understood : operations;
bool NodesValid(IEnumerable<string> ids, string owner)
{