fix(grpc-data): X0 node-side re-validation tolerates only the reserved bits; runtime logger via init property

P02 GrpcDataArtifactReadTests pins an arbitrary bit (1<<30) as a malformed row that fails closed; keep that and
tolerate only DataOperationSets.Reserved. P07 GrpcDataHotRouteContinuityTests reflects over the runtime constructor
shape, so the logger moves from a ctor parameter to an init property.
This commit is contained in:
Joseph Doherty
2026-11-23 17:52:54 -05:00
parent a5ef7ea6d8
commit 75cf5eb8f7
4 changed files with 31 additions and 11 deletions
@@ -212,7 +212,11 @@ public static class DataConnectionRegistration
var eligible = state.Generation > 0 && Enum.TryParse<RedundancyRole>(state.Role, out var actual)
&& DataConnectionRoleAdapter.MayAcquire(mode, state.WarmRole, actual);
return new DataConnectionConsumerRoleSnapshot(mode, eligible, state.Generation);
}, logger: sp.GetService<Microsoft.Extensions.Logging.ILoggerFactory>()?.CreateLogger<DataConnectionDeploymentRuntime>());
})
{
Logger = (Microsoft.Extensions.Logging.ILogger?)sp.GetService<Microsoft.Extensions.Logging.ILoggerFactory>()?.CreateLogger<DataConnectionDeploymentRuntime>()
?? Microsoft.Extensions.Logging.Abstractions.NullLogger.Instance,
};
return runtime;
});
services.AddSingleton(sp =>
@@ -49,7 +49,8 @@ public sealed class DataConnectionDeploymentRuntime : IAsyncDisposable
UnknownOperationsCounterName, unit: "{row}",
description: "Data-connection rows carrying operation bits this node does not understand; the bits were dropped (no grant).");
private readonly object _sync = new();
private readonly ILogger _log;
/// <summary>Diagnostics sink for the X0 dropped-operation warning; optional (an init property keeps the constructor shape).</summary>
public ILogger Logger { private get; init; } = NullLogger.Instance;
private IReadOnlyDictionary<string, DataOperations> _droppedOperations = new Dictionary<string, DataOperations>();
private long _unknownOperationRows;
private readonly string _node, _owner;
@@ -76,9 +77,8 @@ public sealed class DataConnectionDeploymentRuntime : IAsyncDisposable
public DataConnectionDeploymentRuntime(string nodeId, string ownerCluster, IDataConnectionSecurityProvider security,
IDataConnectionScopeActivator scopeActivator, int maxConnections, TimeProvider? clock = null,
Func<bool>? consumerMayAcquire = null, bool useCompactBatches = true,
Func<RedundancyMode, DataConnectionConsumerRoleSnapshot?>? consumerRoleSnapshot = null, ILogger? logger = null)
Func<RedundancyMode, DataConnectionConsumerRoleSnapshot?>? consumerRoleSnapshot = null)
{
_log = logger ?? NullLogger.Instance;
ArgumentException.ThrowIfNullOrWhiteSpace(nodeId); ArgumentException.ThrowIfNullOrWhiteSpace(ownerCluster);
if (maxConnections <= 0) throw new ArgumentOutOfRangeException(nameof(maxConnections));
_node = nodeId; _owner = ownerCluster; _security = security ?? throw new ArgumentNullException(nameof(security));
@@ -226,7 +226,7 @@ public sealed class DataConnectionDeploymentRuntime : IAsyncDisposable
foreach (var (id, bits) in dropped)
{
UnknownOperationsCounter.Add(1);
_log.LogWarning("Data connection {DataConnectionId} in artifact {ArtifactRevision} grants operation bits {UnknownOperations} " +
Logger.LogWarning("Data connection {DataConnectionId} in artifact {ArtifactRevision} grants operation bits {UnknownOperations} " +
"this node does not implement; they were dropped (no grant). Upgrade this node before relying on them.",
id, revision, (int)bits);
}