Resolve all high-severity architecture review findings

This commit is contained in:
Joseph Doherty
2026-09-09 16:13:58 -04:00
parent 8bfe65512e
commit 146a13238f
192 changed files with 3160 additions and 753 deletions
@@ -52,6 +52,8 @@ public class NativeAlarmActor : ReceiveActor
/// <summary>Buffer accumulating a snapshot replay until <see cref="AlarmTransitionKind.SnapshotComplete"/>.</summary>
private readonly Dictionary<string, NativeAlarmTransition> _snapshotBuffer = new();
private Guid? _snapshotId;
private Guid? _lastCompletedSnapshotId;
/// <summary>
/// Pending mirror upserts coalesced by source reference (P4): under an alarm storm each
@@ -135,6 +137,9 @@ public class NativeAlarmActor : ReceiveActor
/// <inheritdoc />
protected override void PostStop()
{
_dclManager.Tell(new UnsubscribeAlarmsRequest(
Guid.NewGuid().ToString("N"), _instanceName, _source.ConnectionName,
_source.SourceReference, DateTimeOffset.UtcNow), Self);
_retryTimer?.Cancel();
_flushTimer?.Cancel();
// Best-effort final flush of any coalesced upserts so a graceful stop does not lose the
@@ -227,14 +232,29 @@ public class NativeAlarmActor : ReceiveActor
private void HandleTransition(NativeAlarmTransitionUpdate update)
{
var t = update.Transition;
if (t.SnapshotSourceReference is { } scope && scope != _source.SourceReference)
return;
switch (t.Kind)
{
case AlarmTransitionKind.SnapshotStart:
if (t.SnapshotId is null || t.SnapshotId == _lastCompletedSnapshotId || t.SnapshotId == _snapshotId)
return;
_snapshotId = t.SnapshotId;
_snapshotBuffer.Clear();
break;
case AlarmTransitionKind.Snapshot:
if (t.SnapshotId != _snapshotId)
return;
_snapshotBuffer[t.SourceReference] = t;
break;
case AlarmTransitionKind.SnapshotComplete:
if (t.SnapshotId != _snapshotId || (t.SnapshotId is not null && t.SnapshotId == _lastCompletedSnapshotId))
return;
ApplySnapshotSwap();
_lastCompletedSnapshotId = t.SnapshotId;
_snapshotId = null;
break;
default:
@@ -310,6 +330,10 @@ public class NativeAlarmActor : ReceiveActor
private void HandleSourceUnavailable(NativeAlarmSourceUnavailable msg)
{
// An interrupted refresh is not a snapshot. Never merge its partial rows
// into the next connection's replay.
_snapshotBuffer.Clear();
_snapshotId = null;
// Keep last-known conditions (uncertain) rather than clearing them; the
// reconnect snapshot reconciles state. No emit — avoids a flap.
_logger.LogWarning(