Skip to content

Fix two Dashboard analysis bugs that drifted from Lite#1155

Merged
erikdarlingdata merged 2 commits into
devfrom
feature/baseline-anomaly-drift-fix
Jun 19, 2026
Merged

Fix two Dashboard analysis bugs that drifted from Lite#1155
erikdarlingdata merged 2 commits into
devfrom
feature/baseline-anomaly-drift-fix

Conversation

@erikdarlingdata

@erikdarlingdata erikdarlingdata commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Summary

A Lite↔Dashboard code-sharing drift audit found two cases where a fix landed in Lite but the duplicated Dashboard copy still carried the bug. Both fixes here bring Dashboard in line with the already-correct Lite behavior.

1. SqlServerBaselineProvider — tier mislabeled for sparse buckets

The full (hour, day-of-week) bucket Tier was assigned by a copy-paste ternary whose two arms both returned BaselineTier.Full:

Tier = count >= RestoreThreshold ? BaselineTier.Full
     : count >= CollapseThreshold ? BaselineTier.Full
     : BaselineTier.HourOnly

So any bucket with count < CollapseThreshold (<10 samples) was written to baseline_tier as HourOnly. Every bucket on this path is a full bucket; HourOnly/Flat are only assigned on the collapse/flat paths. Now Tier = BaselineTier.Full, matching Lite/Analysis/BaselineProvider.cs.

2. SqlServerAnomalyDetector.DetectBlockingAnomalies — ratio scaled with window length

Blocking/deadlock spike detection compared a raw count over the whole analysis window (default 4h) against a per-hour baseline mean, so the ratio scaled with window length and a steady event rate could trip the spike threshold. Now the current counts are normalized to per-hour before the ratio, mirroring Lite.

Why this happened

Dashboard has no SqlServerBaselineProvider/SqlServerAnomalyDetector unit tests, while Lite has BaselineProviderTests + AnomalyDetectorTests (which is where the Lite fixes were validated). The Dashboard classes are wired directly to SqlConnection, so there's no in-memory test seam today. Durable fix for the drift class is the shared-base extraction recommended by the audit (follow-up) — that would give both apps one tested code path.

Test plan

  • dotnet build Dashboard (+ all shared projects) succeeds
  • dotnet test Dashboard.Tests487 passed, 0 failed
  • No Lite changes (Lite copies were already correct)

🤖 Generated with Claude Code

erikdarlingdata and others added 2 commits June 19, 2026 11:18
Both fixes bring Dashboard in line with the already-correct Lite copies;
surfaced by a Lite<->Dashboard code-sharing drift audit.

1. SqlServerBaselineProvider: the full (hour, day-of-week) bucket tier was
   assigned via a copy-paste ternary whose two arms both returned
   BaselineTier.Full, so sparse buckets (count < CollapseThreshold) were
   mislabeled HourOnly in baseline_tier. Every bucket on this path is Full;
   HourOnly/Flat are assigned only on the collapse/flat paths. Matches Lite.

2. SqlServerAnomalyDetector.DetectBlockingAnomalies: blocking/deadlock spike
   ratios compared a raw window count against a per-hour baseline mean, so the
   ratio scaled with window length (default 4h) and a steady event rate could
   trip the spike threshold. Normalize current counts to per-hour before the
   ratio, mirroring Lite.

Dashboard build + 487 Dashboard.Tests pass. No Lite changes (already correct).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit 5a40c60 into dev Jun 19, 2026
2 checks passed
@erikdarlingdata erikdarlingdata deleted the feature/baseline-anomaly-drift-fix branch June 19, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant