Skip to content

Darling alert text: the word agrees with the source count (#6700) - #6702

Merged
erikdarlingdata merged 3 commits into
devfrom
fix/6700-source-count-word
Oct 24, 2026
Merged

erikdarlingdata merged 3 commits into
devfrom
fix/6700-source-count-word

Conversation

@erikdarlingdata

@erikdarlingdata erikdarlingdata commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Claude posting for Erik Darling.

Fixes #6700.

Why

Two Darling alert texts printed a count with "source(s)", so one source read "1 source(s)". The text reaches e-mail, Slack, the other delivery routes and the Viewer's alert history.

What changes

  • CollectionHistoryAudit.Render: "in 1 source," / "in N sources,".
  • DarlingSelfAlertEvaluator.RenderExternalAlerts: "+ 1 more source." / "+ N more sources."
  • Same function, same alert, found while grepping: the short message "N external alert(s) were not delivered in the last hour" now reads "1 external alert was not delivered ..." / "N external alerts were not delivered ...". No test pinned the old wording.
  • Tests: ExternalAlertDeliverySelfAlertTests (the line-121 case now expects "+ 5 more sources."; the short message is asserted for 7; a new case covers 1 alert and 1 unlisted source), CollectionHistoryAuditTests (new case for 1 and for 2 sources).
  • wwwroot/js/util.js (localizeAlertDetail) is untouched: alert rows stored before this fix still hold "source(s)".

Other "(s)" text

Left, on purpose. git grep "[a-z](s)" over the Darling service and Lite finds well over 200 sites. Nearly all are log lines, CLI output, tool descriptions and other alert texts ("N blocking session(s)", "N deadlock(s)", "N query(s)" and so on) that AlertEngineTests and other classes pin character for character. The issue names two texts; changing the rest is a separate sweep with its own test churn. No shared pluralizer is used: FactAdvice.Plural lives in PerformanceMonitor.Analysis and builds "{n} noun" strings for advice text, not these sentences.

#6670 / WebPartialWindowBehaviourTests

#6670 (fix/6649-web-mcp-names) is still open, so this branched from dev as is. On dev, WebPartialWindowBehaviourTests has no case built from Render (it uses a fixed body in web-partial-window-harness.mjs), so I did not touch it.

Test plan

  • Darling.Tests builds, 0 errors (15 warnings, all in files this PR does not touch).
  • *CollectionHistoryAudit*, *ExternalAlertDeliverySelfAlert*, *WebPartialWindow*, *DarlingSelfAlert*, *Census*, *Ratchet*: Total 871, Failed 0, Skipped 10 (live classes without a store).
  • New cases assert the new wording; the old code printed "(s)", so they fail on it by construction (not reverted and rerun, to spare the hot laptop).
  • Full suite and pre-push.sh not run (laptop); CI decides.
  • Build ran through cpucap.sh and testslot.sh via PowerShell with Git Bash's full path (the Bash tool refused the wrappers).

CHANGELOG

SECTION: Fixed
ENTRY:

Seat corrections

@erikdarlingdata
erikdarlingdata marked this pull request as ready for review October 24, 2026 08:28
@claude

claude Bot commented Oct 24, 2026

Copy link
Copy Markdown

Blind read first, then the body. The three renderer changes do what the title says, the two new cases are behaviour tests (they call Render / ApplyExternalAlertsAsync and assert the output, not the source text), and the web test's .Replace keeps localizeAlertDetail's old-row path honest. Three non-blocking notes, none of which changes the verdict:

1. The nearest unfixed sibling is in the same file, and it is not pinned. DarlingSelfAlertEvaluator.cs:1825 builds "The {list} Extended Events session(s) are missing and could not be created. " — same #6700 shape, same alert layer, one function family over. The only other copy of that string in the tree is deprecated/Dashboard/MainWindow.AlertEngine.cs:321, and no test asserts it, so the body's stated reason for leaving the rest ("AlertEngineTests and other classes pin character for character" — true of Darling.Tests/AlertEngineTests.cs:1385, :1403, :2759) does not cover this one. Scope does, and the body says the rest is a separate sweep; naming it so the sweep has a starting point. Note its count is a {list} of names, not a number, so the fix there is "session is / sessions are" off the list length, not this PR's ternary.

2. The stored-row repair is asymmetric, in the direction the body states but readers may not expect. For the audit sentence, a pre-fix row still reads correctly on the web: localizeAlertDetail (util.js:290) runs the Retained history for … sentence through plainText, whose generic rule at plain-text.js:357 turns 1 source(s) into 1 source. The external-alerts short message gets no such repair — get_alert_history's detail_text column (read-fields.js:589) carries localizeAlertDetail: true and no plain: true, and localizeAlertDetail plainTexts only that one sentence, so pre-fix external-alert rows keep alert(s) were on the web exactly as they do in e-mail. Consistent with "Alert rows stored before the fix keep their old wording"; just not symmetric between the two texts this PR fixes.

3. Reuse, for the record. FactAdvice.Plural (PerformanceMonitor.Analysis/FactAdvice.cs:1015) already carries the consonant+y → ies rule that #4478 paid for. The body is right that it is not usable here: it is internal to PerformanceMonitor.Analysis (visible to the test projects, not to the Darling service), and the subject-verb arm "alert was" / "alerts were" is outside what a {n} noun helper does. Agreeing with the decision, not asking for a change — but if the "separate sweep" lands, promoting one pluralizer to PerformanceMonitor.Common beats a ternary per sentence.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: LGTM

Claims

  • VERIFIED — CollectionHistoryAudit.Render: "in 1 source," / "in N sources," — CollectionHistoryAudit.cs:426; CollectionHistoryAuditTests.TheSourceCount_AgreesWithTheWord_ForOneSourceAndForMore asserts both arms.
  • VERIFIED — RenderExternalAlerts: "+ 1 more source." / "+ N more sources." — DarlingSelfAlertEvaluator.cs:5362-5364; the 21-source arm lands on "+ 1 more source.", the 25-source arm on "+ 5 more sources.".
  • VERIFIED — the short message now reads "1 external alert was not delivered ..." / "N external alerts were not delivered ..." — DarlingSelfAlertEvaluator.cs:5346.
  • VERIFIED — "No test pinned the old wording" of that short message — no external alert(s) survives anywhere in the tree, and the diff only ADDS the assertion at ExternalAlertDeliverySelfAlertTests.cs:58; no pin was edited away.
  • VERIFIED — the test edits the body lists — ExternalAlertDeliverySelfAlertTests.cs:122, :58, :126-141, and CollectionHistoryAuditTests.cs:402-415.
  • VERIFIED — wwwroot/js/util.js (localizeAlertDetail) is untouched — absent from gh pr diff --name-only; pre-fix rows are still repaired by plain-text.js:357's generic (\d[\d,]*) (...)\(s\) rule, which is a no-op on the new wording, so the path is idempotent either way.
  • VERIFIED — "Alert rows stored before this fix still hold 'source(s)'" — nothing in the diff touches stored text; the repair is presentation-side only.
  • VERIFIED — git grep "[a-z](s)" over the Darling service and Lite "finds well over 200 sites" — a grep over those two trees returns 643 matches.
  • VERIFIED — other alert texts are pinned character for character by AlertEngineTests — Darling/Darling.Tests/AlertEngineTests.cs:1385, :1403, :2759.
  • VERIFIED — "No shared pluralizer is used: FactAdvice.Plural lives in PerformanceMonitor.Analysis" — FactAdvice.cs:1015, and it is internal (test projects only), so the service could not call it; its {n} noun shape also cannot produce "alert was" / "alerts were".
  • VERIFIED — Seat correction: the web audit test now hands the page a pre-fix row — WebPartialWindowBehaviourTests.cs:199 rewrites Render's output back to "in 1 source(s)" and :205 asserts the page shows the agreed form, so the test still exercises localizeAlertDetail rather than its own input.
  • UNVERIFIED — "Darling.Tests builds, 0 errors (15 warnings ...)" — needs a build.
  • UNVERIFIED — "Total 871, Failed 0, Skipped 10" across the named filters — needs a test run. By reading, the new assertions match the new strings, the tuple/params shapes mirror neighbouring cases that already compile, and FireAsync passes shortMessage through untouched (DarlingSelfAlertEvaluator.cs:8980), so the new Assert.StartsWith has no prefix to trip on.
  • UNVERIFIED — "the new cases fail on the old code by construction (not reverted and rerun)" — the direction was reasoned, not executed; confirming it needs the revert-and-run.

Riskiest lines

  1. Darling/PerformanceMonitor.Darling.Service/DarlingSelfAlertEvaluator.cs:5346 — the only line here that changes a subject AND its verb, so an off-by-one on Total == 1 reads as a grammar error in e-mail, Slack and the Viewer — covered by Undelivered_TheWordsAgreeWithTheCounts_ForOneAlertAndForOneUnlistedSource (singular) and Undelivered_FiresOnceWithTheCountsPerSource_AndNeverRepeatsASubmittedText (plural, 7).
  2. Darling/PerformanceMonitor.Darling.Service/DarlingSelfAlertEvaluator.cs:5364 — the tested count is derived (perSource.Count - MaxListedExternalSources), the one number in this diff not already printed elsewhere in its sentence — covered by Undelivered_TheWordsAgreeWithTheCounts_ForOneAlertAndForOneUnlistedSource and Undelivered_ListsAtMostTwentySources_AndTheCountReflectsAll.
  3. Darling/PerformanceMonitor.Darling.Service/CollectionHistoryAudit.cs:426 — this sentence is what the web rewrite keys on, so wording here is also a contract with localizeAlertDetail for pre-fix rows — covered by CollectionHistoryAuditTests.TheSourceCount_AgreesWithTheWord_ForOneSourceAndForMore and WebPartialWindowBehaviourTests.TheCollectionHistoryAuditAlert_AgreesItsSourceCount_AndKeepsEveryOtherClauseAsWritten (whose .Replace would no-op and fail the next Assert.Contains if the wording moved).

Traps near this diff

  • "Lite and Darling ship in parity (CONTRIBUTING's two-store rule): a fix to one SKU's reader, tool, alert or description without the counterpart's is a finding, not a nit" — does not apply — both texts are Darling-only: CollectionHistoryAudit.cs exists only under Darling/PerformanceMonitor.Darling.Service/, and external-alert ingestion only in Darling/PerformanceMonitor.Darling.Storage/ExternalAlertStore.cs; Lite has no submitter, no externalalerts key and no retained-history audit.
  • "Ruling (#5833): tests are load-bearing. ... never answer a trap with a test that reads source text or asserts how code is spelled" — does not apply — both new cases drive real paths: CollectionHistoryAuditTests.cs:409-414 calls Render, ExternalAlertDeliverySelfAlertTests.cs:130-140 calls ApplyExternalAlertsAsync and reads the deliverer's outcome.
  • "Two copies of one definition pinned EQUAL to each other fail only after BOTH have drifted (#3684). Alias, do not copy." — does not apply — the ternaries are inline word choices in two unrelated sentences, not a second copy of FactAdvice.Plural (FactAdvice.cs:1015), and no test pins them equal to it.
  • "An alert evaluated every ~30 s against an observation that changes once per COLLECTION re-fires on every cooldown expiry against the same rows" — does not apply — the gate is untouched: DarlingSelfAlertEvaluator.cs:5315 still routes through DecideStateAlert / _lastExternalAlertsAlert; only the strings at :5346 and :5364 changed.
  • "A history row wearing the colour its alert's NAME implies rather than the tier it fired at (#3635; the PostgreSQL half in #3680)" — does not apply — DarlingSelfAlertEvaluator.cs:5331 still fires AlertSeverityLevel.Warning with the same metric names and currentValue, so no classifier or triage mapping moves.
  • "A test that reads the clock twice measures the CI scheduler ... One anchor owns both ends of an interval." — does not apply — neither new case reads a clock: the audit case uses the fixed AuditDay (CollectionHistoryAuditTests.cs:36), the external-alert case asserts only text.

Divergence (blind read vs PR body)

One stale paragraph, retracted by the body itself. "#6670 / WebPartialWindowBehaviourTests" says the test "has no case built from Render (it uses a fixed body in web-partial-window-harness.mjs), so I did not touch it" — the tree contradicts both halves: the file is in the diff, Run(string? auditBody = null) (:28) forwards a body to the harness, and :189 builds that body from CollectionHistoryAudit.Render. Not graded REFUTED: it describes the pre-merge dev base and the body's own "Seat corrections" supersedes it with an account that matches the tree. Two things the diff does that the body does not quite say, both in the posted comment and neither blocking: the fix also repairs the external-alerts short message on the web, where detail_text gets no plainText pass (read-fields.js:589 carries only localizeAlertDetail, which rewrites the Retained history for ... sentence alone), so that text had no presentation-side repair at all before; and the nearest unfixed sibling, DarlingSelfAlertEvaluator.cs:1825's "Extended Events session(s) are missing", is pinned by no test, so the "pinned character for character" rationale is scope rather than test churn for that one.

Reviewer checklist

  • Run the full suite and pre-push.sh — the body marks both unrun ("laptop; CI decides"); the build/warning and 871-test counts are the claims a read-only tree cannot confirm.
  • Confirm Node is present on the CI leg running Darling.Tests — Run calls Assert.Skip when node is missing (WebPartialWindowBehaviourTests.cs:43), and that test is the only thing holding Render's new wording and localizeAlertDetail's old-row rewrite together; a silent skip leaves :199's coupling unverified.
  • Eyeball one real delivery of each alert at count 1 and count > 1 — the renderers are covered, but the channels wrap ShortMessage and DetailText themselves.

@erikdarlingdata
erikdarlingdata enabled auto-merge (squash) October 24, 2026 08:46
@erikdarlingdata
erikdarlingdata merged commit db93ae3 into dev Oct 24, 2026
27 of 30 checks passed
@erikdarlingdata
erikdarlingdata deleted the fix/6700-source-count-word branch October 24, 2026 09:05
@github-actions github-actions Bot mentioned this pull request Oct 24, 2026
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