fix(telemetry): fix ValidationTracker grace period boundary and hard trim

- Use >= instead of > for grace period comparison to reconcile at exactly
  8 seconds rather than skipping the boundary
- Two-pass hard trim: first remove entries past late-repair window, then
  any reconciled entry, to avoid sabotaging late repairs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Pratik Mankawde
2026-03-31 13:43:57 +01:00
parent 8365f7dda3
commit 1f2a36b316

View File

@@ -48,7 +48,7 @@ ValidationTracker::reconcile()
for (auto& [hash, evt] : pending_)
{
if (!evt.reconciled && (now - evt.recordTime) > kGracePeriod)
if (!evt.reconciled && (now - evt.recordTime) >= kGracePeriod)
{
// Initial reconciliation after grace period.
evt.reconciled = true;
@@ -106,9 +106,21 @@ ValidationTracker::evictOldPending(TimePoint now)
++it;
}
// Hard trim if still over limit -- remove oldest reconciled entries.
// Hard trim if still over limit -- remove reconciled entries that are
// past the late-repair window first, then any reconciled entry as a
// last resort.
if (pending_.size() > kMaxPendingEvents)
{
// Pass 1: only entries past late-repair window.
for (auto it = pending_.begin();
it != pending_.end() && pending_.size() > kMaxPendingEvents;)
{
if (it->second.reconciled && it->second.recordTime < cutoff)
it = pending_.erase(it);
else
++it;
}
// Pass 2: any reconciled entry if still over limit.
for (auto it = pending_.begin();
it != pending_.end() && pending_.size() > kMaxPendingEvents;)
{