Skip to content

issue-3653 A8 option B: WindowTiles shared tile helpers (lane L1c) - #4167

Merged
erikdarlingdata merged 2 commits into
devfrom
feat/3653-b-tile-helpers
Sep 24, 2026
Merged

erikdarlingdata merged 2 commits into
devfrom
feat/3653-b-tile-helpers

Conversation

@erikdarlingdata

@erikdarlingdata erikdarlingdata commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

Part of #3653 (A8 option B, lane L1c)

What

Adds PerformanceMonitor.Analysis.Baselines.WindowTiles, the shared per-hour tile helpers every detector call site (24 of them, across the SQL Server store, the PostgreSQL target and Lite's DuckDB — design §2) will call. Per the brief, this lane touches only two new files:

  • PerformanceMonitor.Analysis/Baselines/WindowTiles.cs
  • Darling/Darling.Tests/WindowTilesTests.cs

WindowTiles provides:

  1. LocalHourSql — the tile-key SQL const (date_trunc('hour', BaselineLocalClock.LocalCollectionTimeSql)), documented to bind $4..$6 from BaselineBucketMap.WindowClock, never the cached baseline clock.
  2. WholeWindow(IReadOnlyList<WindowTile>) — the whole-window aggregate the never-blind fallback feeds to today's EvaluateZScore. Peak = max; Mean = samples-weighted mean; Samples = sum; PeakTimeUtc = the max-peak tile's, later tile wins a tie; LocalHour = earliest tile's. Empty list or ΣSamples = 0 → default with Samples 0.
  3. LocalHourToUtc(DateTime, LocalClockWindow) — inverts LocalCollectionTimeSql: tries local − OffsetBeforeMinutes, accepts it if before TransitionAtUtc, else falls back to local − OffsetAfterMinutes. A repeated (fall-back) local hour maps to its FIRST occurrence, since the before-candidate is tried first.
  4. AddTileMetadata(...) — adds exactly the 7 new fired-fact keys the design's §1 lists (tile_local_hour, tile_day_of_week, tile_start_ticks, tiles_scored, tiles_fired, window_peak, window_samples_total). Does not touch the existing peak_*/baseline_*/deviation_sigma keys — those stay the detectors' job.
  5. ReadTile(IDataRecord, ...) — builds one WindowTile from a row, tolerant of DBNull peak/mean/samples (→ 0) and a negative/DBNull peak-time ordinal (→ null). Uses Convert.ToDouble/Convert.ToInt64 so it works against both NpgsqlDataReader and DuckDBDataReader.

TileVerdict and WindowTile already existed from #4166 (lane L1a); this lane only consumes them.

Tests added (all in Darling.Tests.WindowTilesTests)

  • LocalHourSql_Contains_LocalCollectionTimeSql_Verbatim
  • WholeWindow_WeightedMean_And_MaxPeak_LaterTileWinsTie
  • WholeWindow_EmptyList_ReturnsDefault_ZeroSamples
  • WholeWindow_AllTilesZeroSamples_ReturnsDefault_ZeroSamples
  • LocalHourToUtc_FixedOffset_MapsLocalToUtc
  • LocalHourToUtc_SpringForward_MapsBothSidesOfTheTransition
  • LocalHourToUtc_FallBack_AmbiguousHourMapsToFirstOccurrence
  • AddTileMetadata_AddsExactlySevenKeys
  • ReadTile_ReadsAllColumns_WhenPresent
  • ReadTile_DBNullCells_BecomeZeroOrNoPeakTime
  • ReadTile_NegativePeakTimeOrdinal_MeansNoPeakTime

Verification

  • dotnet build green for PerformanceMonitor.Analysis, Darling/Darling.Tests (both with -p:EnableWindowsTargeting=true) and Lite/PerformanceMonitorLite.csproj (confirms the helper compiles for Lite too).
  • Targeted runs (macOS, Microsoft.WindowsDesktop.App stripped from the test runtimeconfig for the run only, then restored): *WindowTiles* (11/11), *AnomalyGateTiles* (12/12), *DocCommentHygiene* (77/77), *LocalClock* → LocalClockBucketKeyTests (13/13). All green.
  • Full Darling suite once, DARLING_TEST_PG unset: Total: 13657, Errors: 0, Failed: 214, Skipped: 727, Not Run: 2. All 214 failures are the pre-existing Windows-only set the brief names (WPF/registry/Windows-service-install classes — ViewerChartContextMenuTests, DarlingInstallLocationTests, TargetProviderTests, BulkServerOnboardingMappingTests, etc.) — none are new, none touch WindowTiles, AnomalyGate, or BaselineBucketMap.
  • scrubcheck on the diff: 0 hits.

Not verified

  • No live PostgreSQL test needed per the brief (none added; WindowTiles has no store dependency).
  • The 24 detector call sites are NOT wired to WindowTiles in this lane — that is later lanes' work per the design's §2 inventory.

Base

Based on origin/feat/3653-b-tile-gate (PR #4166 was still open at start; WindowTile and TileVerdict came from it) rather than dev, per the brief's stacking rule.

CHANGELOG entry

None (per brief).

Coordinator verification (head fd91b4d)

  • The core file was read. WindowTiles.cs matches the lane-L1c brief.
  • LocalHourToUtc was checked by hand against both DST cases:
    • spring-forward: local 01:00 → 06:00Z, local 03:00 → 07:00Z;
    • fall-back: local 01:00 → 05:00Z (the first occurrence), local 02:00 → 07:00Z.
  • Classes run: *WindowTiles* 11/11, *AnomalyGate* 23/23, *DocCommentHygiene* 77/77, *LocalClock* 13 passed with 1 live skip.
  • Builds: Lite/ builds with the new helper, with 0 errors.
  • Full Darling suite without PG, on macOS: 13657 total, 214 failed. The failure set is identical to dev's Windows-only set.
  • Rebased onto dev after issue-3653 A8 option B: the per-hour tile gate and its math (lane L1a) #4166 merged (82abf48). The head is now adad1b9, with the same two files. The build is green after the rebase.

@erikdarlingdata erikdarlingdata changed the title DO NOT MERGE (stacked on #4166): issue-3653 B L1c tile helpers issue-3653 A8 option B: WindowTiles shared tile helpers (lane L1c) Sep 24, 2026
@erikdarlingdata
erikdarlingdata marked this pull request as ready for review September 24, 2026 15:52
@erikdarlingdata
erikdarlingdata enabled auto-merge (squash) September 24, 2026 15:52
@erikdarlingdata
erikdarlingdata merged commit fe6a164 into dev Sep 24, 2026
18 of 20 checks passed
@erikdarlingdata
erikdarlingdata deleted the feat/3653-b-tile-helpers branch September 24, 2026 16:01
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