Skip to content

Split AlertNotebookEndpoint's authored templates into per-family files (#4223) - #4410

Merged
erikdarlingdata merged 1 commit into
devfrom
fix/4223-notebook-template-files
Sep 26, 2026
Merged

erikdarlingdata merged 1 commit into
devfrom
fix/4223-notebook-template-files

Conversation

@erikdarlingdata

@erikdarlingdata erikdarlingdata commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Refs #4223.

Why

AlertNotebookEndpoint held every authored notebook template (Blocking, Deadlocks) in one 842-line file, with a metric-name if-chain choosing between them. Splitting each family into its own file, and turning the if-chain into a single sorted registration table, means future template families can be built in parallel, each touching only its own file plus one new line in the table.

What changes

  • AlertNotebookEndpoint.cs (core): internal static class becomes internal static partial class. The metric-name if-chain in AuthoredTemplate is replaced by a static readonly array s_authoredTemplates of (string[] Metrics, AuthoredTemplateEntry Entry), one row per family, sorted case-insensitively by each row's first metric name. AuthoredTemplate now looks up the table instead of branching. Made internal (was private) so a test pin can check the table directly.
  • New AlertNotebookEndpoint.Templates.Blocking.cs: BlockingTemplateVersion and BuildBlockingCells, moved verbatim.
  • New AlertNotebookEndpoint.Templates.Deadlocks.cs: DeadlocksTemplateVersion and BuildDeadlockCells, moved verbatim.
  • Shared helpers (HeaderCell, StatusCell, ReadCell, AuthoredReadCell, TimelinePanel, RankedPanel, etc.) stay in the core file, since both families use them.

No behaviour change. Line endings (CRLF) and file header match the original.

Test plan

  • Byte-identical before/after: a temporary in-process test (not committed) serialized the bound notebook-definition JSON for "Blocking Detected", "Blocking Wait Time", "Deadlocks Detected", and one mechanical metric ("High CPU") against a fixed alert row and window, once before the move and once after. diff between the two captures reports no differences.
  • New pin (AlertNotebookAuthoredTemplateTests.cs): RegistrationTable_EveryFamilyResolvesAndValidates walks every row of s_authoredTemplates, checks every metric name resolves to a non-null entry with a unique id, and runs each entry's built cells through DarlingWebEndpoints.ValidateNotebookDefinition. RegistrationTable_IsSortedByFirstMetricName pins the table's sort order.
    • RED on the pre-fix code: s_authoredTemplates doesn't exist there, so this is a compile failure against origin/dev, not a runtime failure.
  • Existing pins, run in-process on macOS (Darling.Tests.dll, Microsoft.WindowsDesktop.App removed from its runtimeconfig for this run only): AlertNotebookAuthoredTemplateTests, AlertNotebookEndpointTests, DocCommentHygieneTests. All 126 tests pass, 0 failed.
  • Build: Darling.Tests.csproj and Lite.Tests.csproj both build 0 errors with -p:EnableWindowsTargeting=true. Neither test project runs live PostgreSQL classes (no live-DB pins touched by this change).

CHANGELOG entry

None: a structural move with no behaviour change.

#4223)

Pure move: BuildBlockingCells/BuildDeadlockCells and their template-version
constants move into AlertNotebookEndpoint.Templates.Blocking.cs and
AlertNotebookEndpoint.Templates.Deadlocks.cs. The core file becomes a
partial class and its metric-name if-chain becomes one sorted registration
table. No behaviour change; verified byte-identical output before/after.

Refs #4223.
@erikdarlingdata
erikdarlingdata marked this pull request as ready for review September 26, 2026 12:39
@erikdarlingdata
erikdarlingdata merged commit 084cfb3 into dev Sep 26, 2026
18 of 20 checks passed
@erikdarlingdata
erikdarlingdata deleted the fix/4223-notebook-template-files branch September 26, 2026 12:39
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