fix(runtime): malformed artifact bytes on boot/restore are no answer (#601); evict telemetry snapshots on driver removal (#609)

Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
Joseph Doherty
2026-10-08 06:53:45 -04:00
parent 3baa332d6b
commit 53247a056a
10 changed files with 162 additions and 6 deletions
@@ -37,9 +37,8 @@ public sealed class TelemetryLocalHub : ITelemetryLocalHub
// Snapshot last-value caches. Only ever mutated under _gate (kept ConcurrentDictionary so a
// Subscribe reading them under the gate is trivially safe even against any future lock-free read).
// TODO(mesh-phase5+): evict snapshot cache entries on driver-instance removal (needs a
// driver-lifecycle hook); pre-production, accepted for now. Until then a decommissioned driver
// instance's last-known Health/Resilience state replays to new subscribers forever.
// Entries are evicted via Evict when DriverHostActor removes the instance (#609), so a
// decommissioned driver's last-known state does not replay to new subscribers.
private readonly ConcurrentDictionary<string, TelemetryItem.Health> _healthCache = new();
private readonly ConcurrentDictionary<(string InstanceId, string HostName), TelemetryItem.Resilience> _resilienceCache = new();
@@ -66,6 +65,20 @@ public sealed class TelemetryLocalHub : ITelemetryLocalHub
}
}
/// <inheritdoc />
public void Evict(string driverInstanceId)
{
ArgumentNullException.ThrowIfNull(driverInstanceId);
lock (_gate)
{
_healthCache.TryRemove(driverInstanceId, out _);
foreach (var key in _resilienceCache.Keys)
if (string.Equals(key.InstanceId, driverInstanceId, StringComparison.Ordinal))
_resilienceCache.TryRemove(key, out _);
}
}
/// <inheritdoc />
public ITelemetrySubscription Subscribe(int boundedCapacity)
{