fix(grpc-data): A1 review nit — colliding condition placements are logged at Warning (locally)

DistinctPlacements still drops every placement of an address claimed twice (fail closed); Compile takes an
optional logger (the coordinator passes its own) and the drop is reported in the local log only.
This commit is contained in:
Joseph Doherty
2026-11-24 10:44:00 -05:00
parent 16166c21e5
commit 2fdf9d87c2
3 changed files with 54 additions and 5 deletions
@@ -101,6 +101,40 @@ public sealed class GrpcDataConditionPlacementTests
catalog.TryResolveConditionPlacement(placements[2].View with { MappingId = "m", MappingRevision = 1 }, out _).ShouldBeFalse();
}
/// <summary>Review nit: an address claimed by two placements drops both (fail closed) and says so at Warning in the
/// LOCAL log; the listing simply does not carry them.</summary>
[Fact]
public void Colliding_placements_are_dropped_and_logged_at_Warning()
{
using var fixture = new LocalDataFixture();
var b = Fixed();
var clash = new ScriptedAlarm
{
ScriptedAlarmId = "Area/Line/Filler/OverTemp", EquipmentId = "eq-1", Name = "Clash", AlarmType = "AlarmCondition",
MessageTemplate = "x", PredicateScriptId = "script",
};
var log = new CapturingLogger();
var catalog = LocalExportCatalog.Compile(With(b, scripted: [.. b.ScriptedAlarms, clash]), fixture.Serving,
fixture.Activation.CaptureAuthority(), logger: log);
catalog.ConditionPlacements.ShouldNotContain(p => p.View.Address.Identifier == "Area/Line/Filler/OverTemp");
catalog.ConditionPlacements.Count.ShouldBe(3);
log.Warnings.ShouldHaveSingleItem().ShouldContain("Area/Line/Filler/OverTemp");
}
private sealed class CapturingLogger : Microsoft.Extensions.Logging.ILogger
{
public List<string> Warnings { get; } = [];
public IDisposable? BeginScope<TState>(TState state) where TState : notnull => null;
public bool IsEnabled(Microsoft.Extensions.Logging.LogLevel logLevel) => true;
public void Log<TState>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, TState state,
Exception? exception, Func<TState, Exception?, string> formatter)
{
if (logLevel == Microsoft.Extensions.Logging.LogLevel.Warning) Warnings.Add(formatter(state, exception));
}
}
[Fact]
public void The_v1_catalog_is_unchanged_by_the_enumeration()
{