fix(adminui): snapshot already old at dialog open is stale immediately (#857)

The Controls panel primed its per-node view from the snapshot store with
ReceivedUtc = now, so a node that stopped publishing before the dialog
opened looked live for the first 30 s stale window.

InMemoryDriverStatusSnapshotStore now records each snapshot's LOCAL
receive time (TimeProvider-injectable) and exposes it via
GetAllWithReceiveTime(); the panel primes through the pure seam
DriverStatusByNode.Prime/PrimedReceiveTime, which keeps the store's
receive time (clamped to now; still skew-proof). A store that does not
track one (default interface impl -> null) falls back to the publish
time only when that is already older than the stale window, else now.

Claude-Session: https://claude.ai/code/session_01GT67AD99zQQqpLCVm3p7xk
This commit is contained in:
Joseph Doherty
2026-11-11 09:50:15 -05:00
parent 03e5145796
commit 2bd3a6c3c8
5 changed files with 198 additions and 15 deletions
@@ -274,11 +274,11 @@
try
{
// Subscribe BEFORE priming so a publish racing the read is not missed; a primed copy that lands after
// a newer racing live one is dropped by Upsert (it keeps the later PublishedUtc per node).
// a newer racing live one is dropped by Upsert (it keeps the later PublishedUtc per node). Primed
// copies keep the store's own receive time (#857): stamping them "now" showed a node that stopped
// publishing before the dialog opened as live for the first StaleAfter.
StatusStore.SnapshotChanged += OnSnapshotChanged;
var primedUtc = DateTime.UtcNow;
foreach (var snap in StatusStore.GetAll())
_byNode.Upsert(snap, primedUtc);
_byNode.Prime(StatusStore.GetAllWithReceiveTime(), DateTime.UtcNow, StaleAfter);
// Prime + subscribe the resilience store (same in-process read pattern as the health store).
ResilienceStore.SnapshotChanged += OnResilienceChanged;