fix(grpc-data): A1 review round 2 N3 — FOCAS does not signal a condition a truncated alarm list shows inactive

A list cut off at the per-read cap may hide the alarm a selector matches; a condition that matched nothing on such a
read stays unknown instead of being signalled known-inactive.
This commit is contained in:
Joseph Doherty
2026-11-24 11:35:01 -05:00
parent 4a6c894268
commit d377e3775a
2 changed files with 28 additions and 1 deletions
@@ -314,13 +314,16 @@ internal sealed class FocasAlarmProjection : IAsyncDisposable
List<string>? established = null;
foreach (var tag in deviceTags.Where(t => sub.References.Contains(t.RawPath)))
{
(established ??= new List<string>()).Add(tag.RawPath);
// Lift a Bad this projection put there BEFORE the normal diff, so a recovery that also changed the
// alarm state (cleared during the outage) lands as Good then Clear.
if (_qualityBadTold.Remove(tag.RawPath, out _))
Deliver(handlers, QualityOnly(tag, sub.Handle, QualityGood, now), tag.RawPath);
var view = FocasAlarmMatcher.Evaluate(tag.Selector, alarms, deviceSelectors, truncated);
// A1 review round 2 N3: on a list cut off at the per-read cap, a condition that sees NO matching alarm
// may only be missing it (the alarm is past the cap) — its inactive state is not established, so it is
// not signalled (it stays unknown). One that matched something is established either way.
if (!truncated || view.Matched.Count > 0) (established ??= new List<string>()).Add(tag.RawPath);
_told.TryGetValue(tag.RawPath, out var told);
var (evt, nowTold) = FocasAlarmConditionMapper.Transition(told, view, tag, sub.Handle, now);
_told[tag.RawPath] = nowTold;