Skip to content

Alert texts: the word agrees with the count (#6703) - #6704

Merged
erikdarlingdata merged 4 commits into
devfrom
fix/6703-alert-count-words
Oct 24, 2026
Merged

erikdarlingdata merged 4 commits into
devfrom
fix/6703-alert-count-words

Conversation

@erikdarlingdata

@erikdarlingdata erikdarlingdata commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Claude posting for Erik Darling.

Fixes #6703.

Why

Alert and self-alert texts printed a count followed by "(s)", so a count of one read "1 checkpoint(s)" or "1 mute rule(s) have been". These strings reach e-mail, Slack and the other routes, the alert history and the MCP alert tools.

What changes

Each site below keeps the count in hand next to the text and picks the word inline (n == 1 ? "x" : "xs"), with the verb agreeing where there is one. No new shared helper (FactAdvice.Plural is internal to PerformanceMonitor.Analysis and cannot be reached from these projects). Text already stored keeps "(s)"; no stored row is rewritten. AlertValueParser takes the first number in the text, so no stored value changes.

Sites changed (file, line on this branch, old -> new):

PerformanceMonitor.Alerting/AlertEngine.cs (shared by Lite and Darling)

  • 1503 N blocking session(s) -> 1 blocking session / N blocking sessions
  • 1852 ... across N blocked session(s) -> session / sessions (1846 comment example updated)
  • 1857 ... across N session(s) (threshold ...) -> session / sessions
  • 2017 N deadlock(s) in the last hour -> deadlock / deadlocks
  • 2850 N query(s), longest Nm -> 1 query / N queries
  • 3511 N job(s) exceeding ... -> job / jobs
  • 3622, 3628 N job failure(s) -> failure / failures

PerformanceMonitor.Alerting/AlertContextBuilders.cs

  • 95 +N more distinct blocking incident(s) -> incident / incidents
  • 920 N more request(s) in the newest query snapshot -> request / requests (875 doc comment)
  • 1215 N more maintenance session(s) not shown -> session / sessions
  • 1396 ... across N blocked session(s) -> session / sessions

PerformanceMonitor.Notifications

  • PerEventNotification.cs 88 +N more incident(s) this cycle -> incident / incidents
  • IncidentDeliveryFilter.cs 207 N other incident(s) still open -> incident / incidents
  • RepeatDeliveryBudget.cs 588 N occurrence(s) (roster line) -> occurrence / occurrences (570 doc comment)

Darling/PerformanceMonitor.Darling.Service/DarlingWorker.cs (PostgreSQL parity of the engine texts)

  • 8866 deadlocks, 9045 blocking sessions, 9258 queries (same wording as the engine)
  • 9677 victim pid P, N participant(s) -> participant / participants
  • 9770 root pid P blocking N session(s) -> session / sessions

Darling/PerformanceMonitor.Darling.Service/DarlingSelfAlertEvaluator.cs

  • 1825 The X Extended Events session(s) are missing -> session is missing / sessions are missing
  • 3188 N hours (history audit current value) -> 1 hour / N hours; 3191 N thin hour(s) -> hour / hours
  • 5219 N custom alert rule(s) need attention -> 1 custom alert rule needs attention / N ... rules need attention
  • 5586 N mute rule(s) have been suppressing -> 1 mute rule has been / N mute rules have been
  • 5798 N owned setting(s) -> setting / settings
  • 5834 N managed-store setting condition(s) need attention -> condition needs / conditions need
  • 7041 N chunk(s) -> chunk / chunks
  • 7288, 7290, 7296 compose hours: N hour(s) -> hour / hours, and the detail's "and are now retried" -> is / are
  • 7292 N failure(s) -> failure / failures
  • 7710, 7738, 7740, 7765, 7781, 7782 checkpointer: N (requested) checkpoint(s) -> checkpoint / checkpoints
  • 8211 N new failure(s) , 8212 N more failed run(s), 8224 N more time(s) -> singular / plural
  • 2464 comment only

MCP alert answers (Darling Mcp/DarlingMcpAlertTools.cs 149, 1130; Lite Mcp/McpAlertTools.cs 99, 798, same wording)

  • N dismissed alert(s) were excluded -> 1 dismissed alert was excluded / N dismissed alerts were excluded
  • N rule(s) exist but every one of them is disabled -> 1 rule exists but it is disabled / N rules exist but every one of them is disabled

Not touched, per the brief: CollectionHistoryAudit.Render "source(s)" and the "external alert(s) were not delivered" and "+ N more source(s)." lines (#6702).

"(s)" alert-adjacent sites left, and why

  • PoisonWaitEvaluator.cs 148/160 and PostgresAlertEvaluator.cs 605/609 (task(s), backend(s)): the number is an AVERAGE printed with one decimal ("1.5 tasks"), not a count; the plural is right for every non-1 value.
  • AlertReadFailureCounter.cs 730-733 (read(s), pass(es)): text of the collection-health finding in the MCP data tools, not an alert body.
  • FleetSweepEngine.cs 464, DarlingWorker.cs 489 (partition maintenance exception), 14938: sweep and status notes, not alert bodies.
  • Lite/Controls/AlertsHistoryTab.xaml.cs and Darling.Viewer/AlertsHistoryTab.xaml.cs ("alert(s)" count indicator, dismiss prompts, status line): Viewer/Lite UI text, not an alert body or history row. JobHistoryCap.CountText takes the noun from the caller and has its own pinned tests.
  • DarlingMcpBlockingTools.cs 821 / McpBlockingTools.cs 465 (report(s)): MCP blocking answers, not alert tools.
  • Log lines (ExternalAlertDrain.cs 144/243, DuckDbAlertHistoryStore.cs 116, PgAlertHistoryStore.cs 123, EmailSendCore.cs, WebhookAlertService.cs) and CLI output: out of scope per the issue.
  • DarlingSelfAlertEvaluator.cs 7743 "N of those checkpoints were REQUESTED" and the plain "N days"/"N minutes" plurals: no "(s)" form; left.

Tests

Existing tests that pinned the old wording now pin the new (AlertEngineTests, LiteAlertForwardingTests, DarlingPgOperationalAlertTests, DarlingSelfAlertTests, PolicyJobFailingRetryTests, StoreToastAndCheckpointerTests, RunnableQueue*, IncidentDeliveryFilterTests, RepeatDeliveryBudgetTests, both McpPageContractTests, AlertContextBuildersTests, BlockingDeadlockContextBuilderTests, AlertValueParserTests). One singular and one plural case per changed file, in the existing classes (new methods only):

  • AlertEngine.cs: blocking / deadlock singular (AlertEngineTests), job and job-failure plural, existing 1-query / 2-queries.
  • AlertContextBuilders.cs: 1 vs 2 maintenance sessions, 1 vs 3 requests, +1 vs +2 incidents, new Lite/Darling cases.
  • PerEventNotification: +1 and +2 more incident(s) (LiteAlertForwardingTests).
  • IncidentDeliveryFilter: 1 and 2 other incidents; RepeatDeliveryBudget: 1 and 4 occurrences.
  • DarlingSelfAlertEvaluator: capture down 1/2 sessions, custom rules 1/3, mute rules 1/2, compose hours 1/2 (verb too), policy job 1/2 failures, checkpointer 1/2/4.
  • DarlingWorker: participant and session singular next to the existing plural.
  • MCP alert answers: Lite 1 vs 2 dismissed alerts. The Darling counterpart (McpPageContractTests live case, 5 dismissed) was only re-worded; it needs a rig, which I did not run.
  • No census, pin or source-text test added. I did not revert the production code to watch the new cases fail: each asserts a literal singular or plural string the old "(s)" text cannot produce.

Run on this branch (Debug, no pre-push.sh, no full suite, per the brief):

  • Darling.Tests: *AlertEngine*, *DarlingSelfAlert*, *DarlingPgOperationalAlert*, *IncidentDeliveryFilter*, *RepeatDeliveryBudget*, *RunnableQueue*, *StoreToastAndCheckpointer*, *PolicyJobFailing*, *McpPageContract*, *AlertHistory*, *McpAlert*, *Census*, *Ratchet*: Total 1707, Failed 1 (RunnableQueueAlertDetailTests pinned "1 more request(s)"; fixed), then *RunnableQueue* + *AlertReadFailure* rerun: Total 165, Failed 0, Skipped 15 (live).
  • Lite.Tests: *AlertContextBuilders*, *BlockingDeadlockContextBuilder*, *LiteAlertForwarding*, *McpPageContract*, *AlertValueParser*, *Census*, *Ratchet*, *AlertHistory*, *McpAlert*, *BlockingWaitSnapshot*, *IncidentCooldown*: Total 357, Failed 0.
  • Darling live McpPageContractTests (rig) and the full suite: CI decides.

CHANGELOG

SECTION: Fixed
ENTRY:

For the coordinator

  • The CHANGELOG entry is in the body because no buffer directory was given.
  • Merge order with Darling alert text: the word agrees with the source count (#6700) #6702: my edits in DarlingSelfAlertEvaluator.cs are at 5219 and 5586/5798; its lines are 5346 and 5362.
  • Reviewers should know the 3188 change ("1 hour" for the history-audit current value) goes slightly past "(s)": it was the same defect without the parentheses.

Round 1 fixes

Claude posting for Erik Darling. Answers review 5637523648 (head dc43c03).

  1. The deadlock text has a reader (blocking finding). PgDeadlockRemask.s_noStatementObject now matches participant, participants and participant(s) (participant(?:s|\(s\))?), so the builder's "1 participant" / "3 participants" lines are kept as written when a report is Missing and no longer flip neverRemasked. Stored rows keep "(s)" for their retention, so the old spelling stays accepted. Doc comment updated. Test: PgDeadlockRemaskTests.TheBuildersNoStatementLine_IsKeptAsWritten_AndNotJudgedToCarryLiterals (1 and 3 participants) builds the line with DarlingWorker.BuildPgDeadlockIncident itself, runs RemaskAlert with a Missing report, and asserts that with reportsMayBeRaw nothing is rewritten, and with the key passed the key is replaced and the line is unchanged. Proved on the old regex: both cases fail. The existing tests with the old literal stay and now cover stored rows.
  2. Other readers. Grepped product code (cs, js, sql, py, ps1) for a regex, StartsWith, EndsWith, Contains, IndexOf, LIKE or Replace over each text this PR changed. None found beyond s_noStatementObject. The only text matches are the Contains("XE session") checks on SQL exception messages (DarlingWorker.cs:17516, Lite RemoteCollectorService.BlockedProcessReport.cs:699), which read the engine's error, not our alert text. The "+N more" overflow text is documented as unparsed (NumericValue carries the number).
  3. Stale doc comments now quote the new text: IAlertDeliverer.cs ("3 deadlocks in the last hour" / "1 deadlock ..."), CurrentBlockingWaitResult.cs ("across N blocked sessions", "across 1 blocked session"), PerEventNotification.cs ("+N more incidents this cycle", "+1 more incident this cycle").
  4. Custom rule health sentence. DarlingSelfAlertEvaluator.RenderCustomRuleHealth: "1 no longer compiles" / "N no longer compile", "1 armed but never fires" / "N armed but never fire". CustomRuleHealth_OneRule_ReadsInTheSingular now asserts the whole sentence for (1,0), (1,1) and (0,2).
  5. Capture-down short message. ApplyCaptureDownAsync: "XE session missing" for one, "XE sessions missing" for two. CaptureDown_OneMissingSession_ReadsInTheSingular asserts the short message and adds the Blocking-and-Deadlock case (detail and short message).
  6. Store metrics MCP text. DarlingMcpStoreMetricsTools.CheckpointerNote: "N checkpoint(s), spending" is "1 checkpoint, spending" / "N checkpoints, spending", and "N checkpoint(s) were REQUESTED" is "1 checkpoint was REQUESTED" / "N checkpoints were REQUESTED". StoreToastAndCheckpointerTests.TheCheckpointerNote_SaysOneThingPerStatus_AndNamesTheLeversOnPressure updated for the plural pins and gains a one-checkpoint case.
  7. Considered, not added: a shared plural helper. The reviewer does not ask for one, and a helper would not have caught item 1 (a reader of the text, not its plural), so the ternaries stay.

Tests run (Debug, Darling.Tests.exe): *PgDeadlock*, *DarlingSelfAlert*, *StoreToastAndCheckpointer*, *StoreMetrics*, *PerEvent*, AlertEngineTests, *Census*, *Ratchet*, *DarlingPgOperationalAlert*, *DarlingMcpTools*: Total 1172, Failed 0, Skipped 55 (needs-rig live tests). Build: 0 errors, 1 warning (xUnit2000 in StoreConnectionStringAppendPinTests.cs, a file this PR does not touch). Not run: pre-push.sh, the full suite, live classes (CI decides).

Seat corrections

  • McpMissMessageParityPinTests' lapsed-mute fragment now starts at "disabled or expired": the word before it is now picked by the count, in both products.

Replace the count-then-word(s) forms in alert bodies, self-alert texts, MCP alert answers and the
shared engine texts with the singular for 1 and the plural otherwise, with the verb agreeing.
@erikdarlingdata
erikdarlingdata marked this pull request as ready for review October 24, 2026 08:11
unbounded one can bloat the stored context past what Slack/Teams will accept. */
string.IsNullOrWhiteSpace(row.VictimStatement)
? $"victim pid {row.VictimPid}, {row.ParticipantCount} participant(s)"
? $"victim pid {row.VictimPid}, {row.ParticipantCount} {(row.ParticipantCount == 1 ? "participant" : "participants")}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This text has a reader, and the reader still spells it participant(s).

PgDeadlockRemask.cs:786-787 holds a compiled copy of exactly this string, documented as "The live alert's text for a report with no victim statement (DarlingWorker.BuildPgDeadlockIncident), which carries no SQL":

private static readonly Regex s_noStatementObject = new(
    @"^victim pid -?[0-9]+, -?[0-9]+ participant\(s\)$", RegexOptions.Compiled | RegexOptions.CultureInvariant);

With this hunk the builder emits victim pid 555, 3 participants / victim pid 555, 1 participant, which that regex no longer matches. Two call sites change behaviour for every incident the new builder writes:

  1. WithheldObjects (PgDeadlockRemask.cs:817-820) — the regex is the whitelist that keeps a no-SQL line as it is. An incident whose pg_deadlocks report is Missing (retention dropped it, its server's rows are gone, or the hash never resolved) now falls to the else and the pid/participant line is overwritten with PgLogTextRedactor.WithheldStatement. The pass destroys a line that was never sensitive — the whole reason the arm exists — and the alert-history row loses the victim pid and cycle size.
  2. StillCarriesLiterals (PgDeadlockRemask.cs:809-811) — !s_noStatementObject.IsMatch(o) && NormalizeStatement(o) != o. NormalizeStatement → PgLogTextRedactor.MaskQuery masks every literal, so victim pid 555, 3 participants normalizes to something different from itself and the object is judged to still carry literals. That flips neverRemasked at :971-972, which decides whether unresolved keys are keyed (keyWith, :980) — a row with no literals at all now steers that decision.

Nothing fails today: PgDeadlockRepairTests.cs:110,120,331,343 and PgDeadlockRemaskTests.cs:291,302,441 all hand the pass the hand-written "victim pid 3101, 2 participant(s)" literal, which still matches, so no test ever drives the pass with what the builder now produces.

This is the #3684 trap exactly — "Two copies of one definition pinned EQUAL to each other fail only after BOTH have drifted. Alias, do not copy." The fix wants the regex to accept both spellings (old rows keep (s) for 90 days, so it cannot simply be re-spelled), and a behaviour test that feeds the pass an incident built by BuildPgDeadlockIncident itself rather than a literal:

@"^victim pid -?[0-9]+, -?[0-9]+ participants?(?:\(s\))?$"

The sibling at :9770 (root pid P blocking N sessions) has no such reader — I grepped; s_noStatementObject is the only regex in the tree over these strings.

@claude

claude Bot commented Oct 24, 2026

Copy link
Copy Markdown

Non-blocking notes from the blind read, none of which change the verdict on their own (the blocking one is the inline comment on DarlingWorker.cs:9677).

Three doc comments still quote the old wording. The PR updated the examples in AlertContextBuilders.cs:875, RepeatDeliveryBudget.cs:570 and DarlingSelfAlertEvaluator.cs:2464, but three siblings that quote the same strings were left:

  • PerformanceMonitor.Alerting/IAlertDeliverer.cs:24 — <param name="CurrentValue">Human-readable current value (e.g. "3 deadlock(s) in the last hour").</param>, now produced as 3 deadlocks in the last hour by AlertEngine.cs:2017.
  • PerformanceMonitor.Alerting/CurrentBlockingWaitResult.cs:52 — "the alert text's "across N blocked session(s)"", now across N blocked sessions at AlertEngine.cs:1852 and AlertContextBuilders.cs:1396.
  • PerformanceMonitor.Notifications/PerEventNotification.cs:52 — ("+N more incident(s) this cycle"), changed at :88 in this PR.

Two sentences the PR edited still disagree elsewhere in the same sentence.

  • DarlingSelfAlertEvaluator.cs:5219 now reads 1 custom alert rule needs attention: 1 no longer compile, 0 armed but never fire — the head agrees, the first clause does not. The new CustomRuleHealth_OneRule_ReadsInTheSingular asserts only the prefix with StartsWith, so it passes either way.
  • ApplyCaptureDownAsync (:1825) fixes the detail to "The Blocking and Deadlock Extended Events sessions are missing", but its shortMessage two lines down is still $"{list} capture is not running — XE session missing" — singular for the two-session case that the detail just learned to pluralize. The new CaptureDown_OneMissingSession_ReadsInTheSingular asserts DetailText only.

On the shape of the fix. ~40 inline n == 1 ? "x" : "xs" ternaries is the thing #6703 asked for and I am not asking for a refactor in this PR. But the body's reason for not sharing one — FactAdvice.Plural is internal to PerformanceMonitor.Analysis — is a visibility accident, not a design decision: FactAdvice.cs:1015 already carries the irregular-noun rule this PR open-codes (query → queries at AlertEngine.cs:2850), and #4478 is the issue that paid for it. A Plural in PerformanceMonitor.Common, aliased by both, is the version of this that cannot drift; PgDeadlockRemask's stale regex is what drift costs.

Scope, read against the body's "(s) sites left" list. The exclusions hold up — I checked each against the tree and found no alert-body site the list misses. Worth noting that DarlingMcpStoreMetricsTools.cs:862,866 still print N checkpoint(s), spending and N checkpoint(s) were REQUESTED for the same checkpointer the alert at DarlingSelfAlertEvaluator.cs:7738 now pluralizes properly, so an operator reading get_store_metrics and the alert about the same interval sees both spellings. It is an MCP answer rather than an alert body, so it is outside the stated scope — flagging it only so the follow-up issue can be opened deliberately rather than discovered.

claude[bot]
claude Bot previously requested changes Oct 24, 2026

@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: CHANGES REQUESTED

Claims

  • VERIFIED — every site in the "Sites changed" roster is changed as described — walked each against the hunks: AlertEngine.cs 1503/1852/1857/2017/2850/3511/3622/3628, AlertContextBuilders.cs 95/920/1215/1396, PerEventNotification.cs:88, IncidentDeliveryFilter.cs:207, RepeatDeliveryBudget.cs:588, DarlingWorker.cs 8866/9045/9258/9677/9770, and the DarlingSelfAlertEvaluator.cs list.
  • VERIFIED — "AlertValueParser takes the first number in the text, so no stored value changes" — AlertValueParser.cs:61-131 scans to the first digit and ignores everything around it; ResolveStoredValue (:145) is the only seam both stores use, so 1 hour(s) and 1 hour both resolve to 1.
  • VERIFIED — "FactAdvice.Plural is internal to PerformanceMonitor.Analysis and cannot be reached from these projects" — FactAdvice.cs:1015 is internal static; PerformanceMonitor.Analysis.csproj:22-36 names Lite, Dashboard, Darling.Analysis, Darling.Viewer and the two test projects, not .Alerting or .Notifications.
  • VERIFIED — "No census, pin or source-text test added" — every new test asserts a string a built alert produced (DarlingSelfAlertTests.ComposeHoursStuck_OneHourWithOneFailure_ReadsInTheSingular, RepeatDeliveryBudgetTests.ARosterLine_ForAnIncidentSeenOnce_ReadsInTheSingular); none reads source text or a roster.
  • VERIFIED — the MCP alert answers changed in both SKUs with the same wording — Lite/Mcp/McpAlertTools.cs:99,798 against Darling/.../Mcp/DarlingMcpAlertTools.cs:149,1130, identical replacements.
  • VERIFIED — "CollectionHistoryAudit.Render 'source(s)' … not touched, per the brief (#6702)" — absent from gh pr diff; the only neighbour changed is the alert text at DarlingSelfAlertEvaluator.cs:3188,3191.
  • VERIFIED — "DarlingSelfAlertEvaluator.cs 7743 'N of those checkpoints were REQUESTED' … left" — visible as unchanged context inside the edited FireAsync call.
  • VERIFIED — "One singular and one plural case per changed file" — holds at file granularity: AlertEngineTests.AnomalousJob_TwoJobsReadInThePlural beside the 1-job case, Lite.Tests/AlertContextBuildersTests 1-vs-2 maintenance sessions, IncidentDeliveryFilterTests.TwoHeldBackIncidents_AreFootnotedInThePlural beside Footer. Not per site — see Riskiest lines 3.
  • UNVERIFIED — the local run figures (Darling.Tests 1707 total / 1 failed then green; Lite.Tests 357 / 0) — a read-only tree cannot build or run xUnit; needs the filtered dotnet test the body describes.
  • UNVERIFIED — "Darling live McpPageContractTests (rig) and the full suite: CI decides" — left unchecked by the author; needs a live PostgreSQL store, and Darling.Tests/McpPageContractTests.cs:1607 is re-worded but unexercised here.
  • REFUTED — "Text already stored keeps '(s)'; no stored row is rewritten." — PgDeadlockRemask rewrites stored alert contexts on every hourly store-maintenance tick, and its s_noStatementObject regex (PgDeadlockRemask.cs:786-787) still spells participant\(s\). Rows already stored do keep their text and still match; rows the new builder writes do not, so WithheldObjects (:817-820) overwrites the pid/participant line with PgLogTextRedactor.WithheldStatement, and StillCarriesLiterals (:809-811) reports a literal-free object as still carrying literals. The reassurance holds for the past and fails for the future.

Riskiest lines

  1. Darling/PerformanceMonitor.Darling.Service/DarlingWorker.cs:9677 — the only changed string in the diff with a machine reader, and that reader is a hand-copied regex nobody updated; the cost is a destroyed history line plus a flipped neverRemasked decision at PgDeadlockRemask.cs:971-980. UNCOVERED — PgDeadlockRepairTests.cs:110,120,331,343 and PgDeadlockRemaskTests.cs:291,302,441 feed the pass the hand-written "victim pid 3101, 2 participant(s)" literal, which still matches, so nothing drives the remask with what the builder now emits.
  2. PerformanceMonitor.Alerting/AlertContextBuilders.cs:920 — ranked.Count - RunnableQueueRequestDisplayCap is now written twice on one line (number, then noun), the shape where an edit to one copy misses the other. Covered by Darling.Tests/RunnableQueueRound1Tests.TheBuilder_SaysAtLeast_OnlyWhenTheReadHitItsCap, which asserts the 1-, 2- and at-least-2 forms off BuildRunnableQueueRequestItems directly.
  3. Darling/PerformanceMonitor.Darling.Service/DarlingSelfAlertEvaluator.cs:3188 (and :3191) — the history-audit ValueText, the one change the body flags as going past "(s)", so it rewrites a string that previously read N hours for every N including 1. UNCOVERED — no test exercises HistoryAuditAlertText at hours == 1, and the body's per-file test roster does not list this site.

Traps near this diff

  • "Two copies of one definition pinned EQUAL to each other fail only after BOTH have drifted (#3684). Alias, do not copy." — applies — DarlingWorker.cs:9677 is the definition, PgDeadlockRemask.cs:787 the copy whose own doc comment names BuildPgDeadlockIncident as its source, and this PR is the drift.
  • "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 — the census in McpPageContractTests compares the two SKUs' payload keys by tool name for exactly this (#3594)." — does not apply — the engine and builder texts live in shared PerformanceMonitor.Alerting/.Notifications, and the two SKU-local MCP answers moved together (Lite/Mcp/McpAlertTools.cs:99,798 / DarlingMcpAlertTools.cs:149,1130), with Lite.Tests/McpPageContractTests.cs:431 and Darling.Tests/McpPageContractTests.cs:1607 both re-pinned.
  • "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 — the new tests drive a producer and assert its output, e.g. Lite.Tests/McpPageContractTests.cs:1102 seeds a dismissed alert and reads the tool's message.
  • "Slack: the payload is ONE attachment, Slack caps it at 50 blocks, and the Details path spends about two blocks per detail (divider + section) … Budget blocks, not characters, and state the omission." — does not apply — no detail item is added or removed; IncidentDeliveryFilter.cs:204-207 edits text inside one existing field and PerEventNotification.cs:88 the message of an already-produced overflow Message.
  • "A text cut at a UTF-16 index can land between the halves of a surrogate pair; System.Text.Json then substitutes U+FFFD … Cut on StringInfo text elements." — does not apply — no truncation logic is touched; DarlingWorker.cs:9678 still hands the statement to the untouched AlertContextBuilders.TruncateText, and the changed branch carries no SQL at all.
  • "hours_back, limit, top, days_back are refused when out of range, never clamped (#3699)." — does not apply — the MCP edits sit inside already-built empty-status messages; no parameter is read or re-validated.

Divergence (blind read vs PR body)

The body is unusually complete: it rosters every site, names the sites it deliberately left, and marks its own unrun rig. The divergence is a reader it does not account for. "What changes" reasons about consumers of the changed strings exactly once — for AlertValueParser — concludes "no stored value changes", and generalizes that into "Text already stored keeps '(s)'; no stored row is rewritten". There is a second consumer: PgDeadlockRemask holds a compiled regex copy of the text at DarlingWorker.cs:9677 and uses it as the whitelist protecting a no-SQL line from being withheld, and as half the test for whether an object still carries literals. Neither the roster nor the "(s) alert-adjacent sites left, and why" list mentions PgDeadlockRemask.cs:787 — the one remaining (s) in the non-deprecated tree written as a regex rather than as display text, and the one place where leaving it is not cosmetic. The body's test section explains why it stayed invisible: the new cases went "in the existing classes", and the existing deadlock-repair classes pin the string as a hand-written literal instead of taking it from the builder, so re-pinning them was never forced and the drift never surfaced.

Reviewer checklist

  • Run the Darling live McpPageContractTests rig (GetAlertHistory with 5 dismissed and with 1 dismissed) — marked unrun, and Darling.Tests/McpPageContractTests.cs:1607 needs a real PostgreSQL store.
  • On a store that has run PgDeadlockRemask, let one hourly maintenance tick walk config_alert_log after this build fired a PostgreSQL deadlock alert with no victim statement, then read that row's context_json: confirm whether InvolvedObjects[0] still reads victim pid N, M participants or has become the withheld-statement placeholder.
  • Build both SKUs — the ternaries sit inside interpolated holes and string.Create(CultureInfo.InvariantCulture, …) calls (DarlingSelfAlertEvaluator.cs:714,727,736,745,754), where a mis-parenthesized conditional is a compile error a read-only review cannot rule out.
  • Send one real e-mail and one real Slack post for a count-of-one alert (blocking, deadlock, compose hours) and read the rendered body — the singular forms now vary the sentence's verb, which no test renders end to end.

@claude

claude Bot commented Oct 24, 2026

Copy link
Copy Markdown

Follow-up pass on 210a2f59e..dc43c03b8 (one commit: dc43c03b8 "Alert count words").

This commit answers all three blocking items from the prior review:

  • Stale doc comments (IAlertDeliverer.cs:24, CurrentBlockingWaitResult.cs:52, PerEventNotification.cs:52) now quote the actual singular/plural output.
  • Self-disagreeing sentences: RenderCustomRuleHealth's clauses ("no longer compile(s)", "never fire(s)") and ApplyCaptureDownAsync's shortMessage ("XE session(s) missing") now agree with their own counts, each with a new two-session/multi-rule test (DarlingSelfAlertTests).
  • The regex drift (the REFUTED claim + riskiest line Add check for updates feature #1 from the last review): PgDeadlockRemask.s_noStatementObject now accepts participant, participants, and the legacy participant(s), matching what DarlingWorker.BuildPgDeadlockIncident actually emits post-Alert texts say "1 checkpoint(s)": make the word agree with the count (rest of #6700) #6703. PgDeadlockRemaskTests.TheBuildersNoStatementLine_IsKeptAsWritten_AndNotJudgedToCarryLiterals drives both the report-stage and key-stage paths and confirms the no-SQL line survives RemaskAlert unmolested instead of being flagged as still carrying literals and overwritten with the withheld-statement placeholder.

Bonus (not required, but closes a gap the last review flagged as "worth noting"): DarlingMcpStoreMetricsTools.CheckpointerNote now also pluralizes correctly, with singular-case coverage in StoreToastAndCheckpointerTests.

No new defects found in this commit. The rest of the files in the gh pr diff --name-only stat for this range (ServerHardwareScope, TimescaleSupport, plain-text.js, the MCP cancellationToken threading, etc.) come from the dev merge commit (5caffa008) that this commit sits on top of, carrying in three already-separately-reviewed PRs (#6646, #6649, #6648/#6671) — out of scope for this pass since dc43c03b8 doesn't touch or interact with them.

@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 — "the deadlock text's reader accepts the new spelling" — PgDeadlockRemask.cs:787-789's s_noStatementObject regex now matches participant, participants and the legacy participant(s); PgDeadlockRemaskTests.TheBuildersNoStatementLine_IsKeptAsWritten_AndNotJudgedToCarryLiterals (new) feeds it both spellings through RemaskAlert at both stages and asserts the no-SQL line survives unchanged.
  • VERIFIED — "the round-1 sibling sites agree with their counts" — DarlingSelfAlertEvaluator.cs:1830 (XE session/sessions missing) and :5219 (no longer compiles/compile, never fires/fire) now vary every clause with the count, each with new 1-vs-2/3 cases in DarlingSelfAlertTests.cs; DarlingMcpStoreMetricsTools.cs:862,866 (checkpoint(s)) likewise, covered by new cases in StoreToastAndCheckpointerTests.cs.
  • VERIFIED — the three doc-comment sites the prior review named as still quoting old wording (IAlertDeliverer.cs:24, CurrentBlockingWaitResult.cs:52, PerEventNotification.cs:52) are all updated to the new spelling in this commit's diff.

Riskiest lines

  1. Darling/PerformanceMonitor.Darling.Service/PgDeadlockRemask.cs:789 — the regex is the sole machine reader of DarlingWorker.BuildPgDeadlockIncident's hand-written output; a mismatch here silently turns a no-SQL line into "still carries literals" and overwrites it with the withheld-statement placeholder on the next hourly maintenance tick. Covered by PgDeadlockRemaskTests.TheBuildersNoStatementLine_IsKeptAsWritten_AndNotJudgedToCarryLiterals, which drives RemaskAlert with the builder's own singular and plural output and asserts the line is untouched.
  2. Darling/PerformanceMonitor.Darling.Service/DarlingSelfAlertEvaluator.cs:1830 — the shortMessage for the two-missing-session capture-down alert; a regression here reintroduces the exact "sessions are missing, session missing" self-disagreement the prior review flagged. Covered by DarlingSelfAlertTests's new two-session case asserting EndsWith("capture is not running — XE sessions missing", ...).
  3. Darling/PerformanceMonitor.Darling.Service/DarlingSelfAlertEvaluator.cs:5219 — RenderCustomRuleHealth's three independently-pluralized clauses in one interpolated string. Covered by the two new DarlingSelfAlertTests cases (broken:1,neverFiring:1 and broken:0,neverFiring:2) that assert the full literal string, not just a prefix.

Traps near this diff

  • "Two copies of one definition pinned EQUAL to each other fail only after BOTH have drifted (#3684). Alias, do not copy." — applies, and this commit is the fix rather than a new instance — PgDeadlockRemask.cs:787-789 is the copy of DarlingWorker.cs:9677's builder output the prior review flagged as drifted; this commit brings the copy back in sync (still a copy, not an alias, but the drift that trap warns about is what's being repaired here, not introduced).
  • "Lite and Darling ship in parity … a fix to one SKU's reader, tool, alert or description without the counterpart's is a finding." — does not apply — every site this commit touches (XE session alerts, custom-rule health, PostgreSQL deadlock remasking, the Postgres checkpointer) is Darling/PostgreSQL-only; grep for the changed sentences and for CheckpointerNote/custom-rule-health wording in Lite/ and Lite.Tests/ finds nothing, confirming there is no Lite counterpart to miss.
  • "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 — every new test in this commit drives a producer (RemaskAlert, ApplyCaptureDownAsync, ApplyCustomRuleHealthAsync, CheckpointerNote) and asserts its output string, not source text.

Divergence (blind read vs PR body)

None — the commit message's two claims ("the deadlock text's reader accepts the new spelling" and "the round-1 sibling sites agree with their counts") match the diff exactly: the regex fix and the two self-disagreeing sentences are the only functional changes, each with a direct new test.

Reviewer checklist

  • Build both SKUs — the new/edited ternaries sit inside interpolated string holes (DarlingSelfAlertEvaluator.cs:1830,5219, DarlingMcpStoreMetricsTools.cs:862,866), where a mis-parenthesized conditional is a compile error a read-only review cannot rule out.
  • On a store that has run PgDeadlockRemask against a PostgreSQL deadlock alert with no victim statement fired after this build, let one hourly maintenance tick walk config_alert_log and read that row's context_json: confirm InvolvedObjects[0] still reads victim pid N, M participant(s) rather than becoming the withheld-statement placeholder.

@erikdarlingdata
erikdarlingdata dismissed claude[bot]’s stale review October 24, 2026 09:05

Claude posting for Erik Darling. Round 2 (5637620024) verified every round-1 item on dc43c03.

@erikdarlingdata
erikdarlingdata enabled auto-merge (squash) October 24, 2026 09:05
@erikdarlingdata
erikdarlingdata merged commit 11b31c1 into dev Oct 24, 2026
44 of 45 checks passed
@erikdarlingdata
erikdarlingdata deleted the fix/6703-alert-count-words branch October 24, 2026 10:03
@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