Skip to content

feat(api): evaluate SLO burn alerts and notify - #3798

Open
alex-fedotyev wants to merge 1 commit into
alex/HDX-3001-slo-10-api-external-guardfrom
alex/HDX-3001-slo-11-api-evaluator
Open

alex-fedotyev wants to merge 1 commit into
alex/HDX-3001-slo-10-api-external-guardfrom
alex/HDX-3001-slo-11-api-evaluator

Conversation

@alex-fedotyev

@alex-fedotyev alex-fedotyev commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a built-in evaluator for SLO alerts. Each check runs one query that
counts eligible and good events in 5-minute buckets over the last 6 hours,
from a materialized view when one covers it, and computes both burn rules
from it. Fast burn fires when 2% of the error budget is spent within an
hour, slow burn when 5% is spent within six hours, and each also needs its
last 5 or 30 minutes to burn as fast, so it resolves soon after a burn
stops. Fast burn is checked every 5 minutes, slow burn every 15.

Each alert notifies once when it starts firing (or on the first check after
a silence ends) and once when it resolves. The title and message name the
rule and state the numbers, and link to the SLO page with the bad events of
the window. A title reads like this:

SLO "Checkout" (ServiceName:frontend): slow burn, 17.2% of the 7-day
budget spent in the last 6 hours

A grouped SLO's
alerts fire and resolve for each group with at least 100 events in the
window, and resolve groups the SLO no longer tracks.

Each check also stores its burn numbers on the SLO, so the SLO list shows
the alerts' own verdict. SLO alerts only run while SLOs are enabled.

Stack

Part 11 of 27 PRs in a GitHub stack (stack #3815). The header says this PR merges into the branch below it, but the stack's base is main: merging a PR lands it and every PR below it on main, one squashed commit each. Each diff is only its own change, and CI runs as if each PR targets main.

  1. feat(common-utils): SLO definition schema #3788 common-utils: SLO definition schema
  2. feat(common-utils): SLO fast and slow burn rules #3789 common-utils: SLO fast and slow burn rules
  3. feat(common-utils): SLO alert targets and status types #3790 common-utils: SLO alert targets and status types
  4. feat(common-utils): SLO counts query #3791 common-utils: SLO counts query
  5. feat(common-utils): SLO stats and state #3792 common-utils: SLO stats and state
  6. feat(common-utils): SLO history and ordering #3793 common-utils: SLO history and ordering
  7. feat(api): SLO definitions behind ENABLE_SLOS #3794 api: SLO definitions behind ENABLE_SLOS
  8. feat(api): refresh SLO statuses in the check-alerts task #3795 api: refresh SLO statuses in the check-alerts task
  9. feat(api): SLO burn alerts as their own alert source #3796 api: SLO burn alerts as their own alert source
  10. feat(api): keep SLO alerts out of the external alerts API #3797 api: keep SLO alerts out of the external alerts API
  11. feat(api): evaluate SLO burn alerts and notify #3798 api: evaluate SLO burn alerts and notify (this PR)
  12. feat(api): clickstack_get_slo MCP tool #3799 api: clickstack_get_slo MCP tool
  13. feat(api): SLO preview, save and delete MCP tools #3800 api: SLO preview, save and delete MCP tools
  14. feat(app): SLO list page behind NEXT_PUBLIC_ENABLE_SLOS #3801 app: SLO list page behind NEXT_PUBLIC_ENABLE_SLOS
  15. feat(app): search, filter, sort and delete SLOs in the list #3802 app: search, filter, sort and delete SLOs in the list
  16. feat(app): SLO builder for a new SLO #3803 app: SLO builder for a new SLO
  17. feat(app): SLO objective, details and editing in the builder #3804 app: SLO objective, details and editing in the builder
  18. feat(app): eligible-event filters and the latency template in the builder #3805 app: eligible-event filters and the latency template in the builder
  19. feat(app): preview an SLO in the builder before saving it #3806 app: preview an SLO in the builder before saving it
  20. feat(app): create an SLO from a search, and duplicate an SLO #3807 app: create an SLO from a search, and duplicate an SLO
  21. feat(app): SLO detail page #3808 app: SLO detail page
  22. feat(app): bad events flyout on the SLO page #3809 app: bad events flyout on the SLO page
  23. feat(app): SLI, error budget and burn rate charts on the SLO page #3810 app: SLI, error budget and burn rate charts on the SLO page
  24. feat(app): fast and slow burn alerts in the SLO builder, list and page #3811 app: fast and slow burn alerts in the SLO builder, list and page
  25. feat(app): SLO alerts on the Alerts page #3812 app: SLO alerts on the Alerts page
  26. feat(app): group-by in the SLO builder #3813 app: group-by in the SLO builder
  27. feat(app): grouped SLOs in the list and on the SLO page #3814 app: grouped SLOs in the list and on the SLO page

Parts 1 to 6 are shared code, 7 to 13 the API and its MCP tools, and 14 to 27 the app. Everything ships behind ENABLE_SLOS (API) and NEXT_PUBLIC_ENABLE_SLOS (app), both off by default.

Rules

Alert Fires when Short window Min events Checked every
Fast burn 2% of the budget is spent within 1 hour (14.4x for 30 days, 3.36x for 7 days) last 5 minutes 20 5 minutes
Slow burn 5% of the budget is spent within 6 hours (6x for 30 days, 1.4x for 7 days) last 30 minutes 100 15 minutes

The thresholds are fixed for now; making them editable is one of the follow-ups listed on the ticket.

How to reproduce

Starting point: a checkout of this branch with Docker (make dev-int starts ClickHouse and Mongo for the integration tests).

On main: nothing to compare; this is new code.

On this branch:

  1. cd packages/api && npx jest src/tasks/checkAlerts/__tests__/sloEvaluator.test.ts: each alert fires on its own rule, notifies once per episode (and on the first check after a silence ends), resolves when the short window stops burning, alerts per group, and resolves groups the SLO stops tracking.
  2. make dev-int FILE=renderAlertTemplate: titles and messages per rule and per group, and links to the SLO page with the window's bad events.
  3. Manual, with yarn dev: give an SLO on a source with errors a fast burn alert to a webhook (webhook.site works). The webhook gets one message when the burn starts and one when it resolves, not one every 5 minutes.

Test plan

  • unit: tasks/checkAlerts/__tests__/sloEvaluator.test.ts
  • integration: renderAlertTemplate.int.test.ts, the check-alerts suites, slos.int.test.ts (write-back)
  • manual: a webhook sink received one notification per episode
  • typecheck and knip at this commit, for every package

How to test on Vercel preview

N/A, non-UI change.

References

  • Linear Issue: HDX-3001
  • Related PRs: the rest of this stack, listed above

[as-cast: allow] The cast check matches the word "as" in comments and strings here; the diff has no as casts.

@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Nov 24, 2026 7:01pm UTC
hyperdx-storybook Ready Ready Preview Nov 24, 2026 7:01pm UTC

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

Duplicate code analysis

1 new clone introduced by this PR.

  • packages/api/src/routers/external-api/v2/alerts.ts:908-925 ↔ packages/api/src/routers/external-api/v2/alerts.ts:1181-1197 — 18 lines

If one of these duplicates a helper that already exists, import it instead
of redefining it. If the duplication is deliberate, ignore this comment —
the check is advisory and never fails the build.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 108 in total (1.11%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 478 passed • 1 skipped • 1132s

Status Count
✅ Passed 478
❌ Failed 0
⚠️ Flaky 10
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

Adds a built-in evaluator for SLO alerts. Each check runs one query that
counts eligible and good events in 5-minute buckets over the last 6 hours,
from a materialized view when one covers it, and computes both burn rules
from it. Fast burn fires when 2% of the error budget is spent within an
hour, slow burn when 5% is spent within six hours, and each also needs its
last 5 or 30 minutes to burn as fast, so it resolves soon after a burn
stops. Fast burn is checked every 5 minutes, slow burn every 15.

Each alert notifies once when it starts firing (or on the first check after
a silence ends) and once when it resolves. The title and message name the
rule and state the numbers, and link to the SLO page with the bad events of
the window. A title reads like this:

    SLO "Checkout" (ServiceName:frontend): slow burn, 17.2% of the 7-day
    budget spent in the last 6 hours

A grouped SLO's
alerts fire and resolve for each group with at least 100 events in the
window, and resolve groups the SLO no longer tracks.

Each check also stores its burn numbers on the SLO, so the SLO list shows
the alerts' own verdict. SLO alerts only run while SLOs are enabled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alex-fedotyev
alex-fedotyev force-pushed the alex/HDX-3001-slo-11-api-evaluator branch from fc822e4 to 8cca8b2 Compare November 24, 2026 18:58
@changeset-bot

changeset-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8cca8b2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@hyperdx/api Patch
@hyperdx/common-utils Patch
@hyperdx/app Patch
@hyperdx/otel-collector Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

🔴 Tier 4 — Critical

Touches authentication, tenancy data models, the public API or shipped database config — or substantially changes the query rendering engine, background tasks, the OTel pipeline, image build, or release CI.

Why this tier:

  • Background tasks or delivery pipeline substantially modified — 581 lines (bar: 30):
    • packages/api/src/tasks/checkAlerts/evaluators.ts
    • packages/api/src/tasks/checkAlerts/index.ts
    • packages/api/src/tasks/checkAlerts/providers/default.ts
    • packages/api/src/tasks/checkAlerts/providers/index.ts
    • packages/api/src/tasks/checkAlerts/sloEvaluator.ts
    • packages/api/src/tasks/checkAlerts/template.ts

Review process: Deep review from a domain expert. Synchronous walkthrough may be required.
SLA: Schedule synchronous review within 2 business days.

Stats
  • Production files changed: 7
  • Production lines changed: 638 (+ 757 in test files, excluded from tier calculation)
  • Critical-path lines changed: 581
  • Branch: alex/HDX-3001-slo-11-api-evaluator
  • Author: alex-fedotyev

To override this classification, remove the review/tier-4 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

? deriveGroupedSloState(overall, groups)
: deriveSloState(overall),
};
await Slo.updateOne(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 P2 — Alert's burn write-back can overwrite a newer refresh snapshot with stale window numbers

CheckAlertTask.execute (tasks/checkAlerts/index.ts:2458) starts refreshDueSloStatuses() at the same time as getAlertTasks(), so each alert holds a copy of slo.status read before the refresh wrote. recordSloAlertBurn then writes {...previous, burn} through $set: { status }. The only guard is updatedAt, which status writes never change (timestamps: false). The result is that a refresh's new window, groups, windowEvaluatedAt, or a just-cleared error gets reverted to the older copy. Fix: guard the update on the snapshot the alert read, e.g. add 'status.windowEvaluatedAt': previous.windowEvaluatedAt and 'status.state': previous.state to the filter. Better still, $set only status.burn, status.evaluatedAt, status.state and the per-group burn/state fields, so the window part is never rewritten.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

const { slo, source } = details;
// A grouped SLO's alert checks the groups its status tracks; until the
// status refresh has picked them, there is nothing to check.
if (getSloGroupBy(slo) != null && !slo.status?.groups?.length) return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 P1 — Firing groups never resolve once a grouped SLO's status has zero groups

The early return treats 'refresh has not run yet' and 'refresh ran and found no groups' as the same case. computeSloWindow (controllers/sloStatusQueries.ts:118) stores groups = [] when the window has no eligible events, for example after a service stops sending data or an edit to the eligible filter matches nothing. From then on the evaluator returns before resolveUnchecked, so groups that were ALERT stay ALERT and never send a resolve. Fix: return early only when slo.status?.windowEvaluatedAt == null, and let an empty tracked list fall through so resolveUnchecked resolves the old groups. Add a test that starts with status.groups = [] and a previously alerting group.

Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond

...(groups != null ? { groups } : {}),
// A failing window query keeps its error until the refresh clears it.
state:
previous.state === 'error'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 P2 — Error state outlives a successful burn check because the alert keeps evaluatedAt fresh

An ungrouped SLO's fast burn alert sets evaluatedAt to now every 5 minutes, but keeps state: 'error' when it is already error. The refresh only reruns when evaluatedAt is 5 minutes old or the window is 30 minutes old (SLO_WINDOW_MAX_AGE_MS). So a passing burn error keeps the SLO showing 'error' for up to 30 minutes, even though each alert check's burn query against the same source succeeds. Fix: when the burn numbers are fresh, re-derive the state, or clear the error if it came from the burn query, or skip updating evaluatedAt while state is 'error' so the refresh stays due.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

const config =
isBuilderChartConfig(ctx.chartConfig) &&
mvSource?.materializedViews?.length
? await tryOptimizeConfigWithMaterializedView(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 P2 — Materialized-view optimization runs twice per SLO alert check

processAlert already calls tryOptimizeConfigWithMaterializedView on this same config (tasks/checkAlerts/index.ts:1311-1320) before handing it to the evaluator, and drops the result. queryBurnRows repeats the call, which repeats the metadata queries. The SLO evaluator does not change the date range or granularity, so the first result is valid. Fix: add optimizedChartConfig to AlertEvaluationContext and use it here, or skip the up-front optimization when an evaluator is present.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

* unoptimized. A failure is recorded as a query error or timeout, as for
* threshold alerts, and returns null.
*/
async function queryBurnRows(ctx: AlertEvaluationContext, source: ISource) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 P2 — SLO alert queries are not counted in the alerts.query operation outcome

The threshold path calls recordOperationOutcome({ operation: 'alerts.query', ... }) on success and on failure (tasks/checkAlerts/index.ts:1613-1628). queryBurnRows records only queryDurationMs, so failing or slow SLO burn queries never show up in the alert-query SLI. Fix: call recordOperationOutcome in the try and catch blocks of queryBurnRows, with alert_source: 'slo'.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

* longer tracks, or the whole SLO's state once it is grouped (and each
* group's once it is not).
*/
async function resolveUnchecked(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 P2 — Ungrouping an SLO resolves at most one of its firing groups

The doc comment says resolveUnchecked resolves 'each group's [state] once it is not [grouped]'. But for a non-grouped alert, loadAlerts (providers/default.ts:532-540) seeds previousMap from the single latest history row, without groupValues. Only that one group can be resolved, and its resolve message has no attributes. Every other group that was ALERT is never resolved. Fix: when getSloGroupBy(slo) is null, also fetch the latest per-group rows. Alternatively, correct the comment and document this limitation.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

logger.error({ message: 'SLO not found for SLO alert', alertId: alert.id });
return [];
}
const source = await Source.findOne({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 P2 — Third copy of the source + connection populate-and-check block

getSloAlertDetails repeats the Source.findOne(...).populate<Omit<ISource,'connection'> & { connection: IConnection }>({ path: 'connection', match: { team }, select: '+password' }) lookup, the missing-connection check and the { ...source.toObject(), connection: connection.id } reshaping. The same code is at default.ts:227 and default.ts:322. Fix: move it into one helper, e.g. findSourceWithConnection(sourceId, team), and call it from all three.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

@github-actions

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 P0/P1 in code this PR adds or changes: fix before asking for review.
  • 🟡 P2 in code this PR changes: your call. Fix if small, otherwise reply.
  • 🔵 P3 is collapsed at the bottom: nobody needs to act on it before merge.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    priority. Reply with one sentence; if it is P0, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

8 finding(s): 🔴 1 P0/P1 · 🟡 6 P2 · 🔵 1 P3

7 posted as inline comment(s) on the changed lines. 1 P3 folded at the bottom.

🔵 1 P3 — no action needed before merge
  • 🔵 P3 packages/api/src/tasks/checkAlerts/template.ts:1778 — state param on buildAlertMessageTemplateTitle is optional but its only production caller always passes it → The only non-test caller (index.ts:610) always passes state. Leaving it optional means a future SLO caller that forgets it silently gets a 'fast burn, …' firing title on a resolve. Fix: make state: AlertState required.

Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides.

@github-actions

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found. The core evaluator logic — bucket summation, fast/slow thresholds, notify-once via previous.fired, resolve path, and grouped fire/resolve — is internally consistent and matches the tests. No P0/P1 defects survived verification. The items below are recommended hardening and test-coverage gaps.

🟡 P2 — recommended

  • packages/api/src/controllers/sloStatus.ts:93 — recordSloAlertBurn and the concurrent refresh both $set the whole status with a {_id, updatedAt} filter and timestamps: false, so neither bumps updatedAt and the guard gives no mutual protection; an alert write built from a stale snapshot can clobber freshly-refreshed window numbers (and drop a newly-tracked group for up to ~30 min) since the refresh is started un-awaited at index.ts:2458 and races the per-alert Slo.findOne.
    • Fix: Write only the burn sub-fields the alert path owns via a targeted $set (status.burn and per-group burn), or gate the write on a monotonic status version rather than updatedAt.
    • reliability, adversarial, correctness
  • packages/api/src/tasks/checkAlerts/sloEvaluator.ts:233 — the guard getSloGroupBy(slo) != null && !slo.status?.groups?.length conflates "status not yet refreshed" with "refreshed to zero groups", returning before resolveUnchecked, so a group previously in ALERT is never resolved and the alert stays stuck firing while re-evaluating every tick.
    • Fix: Short-circuit only when slo.status is absent; when a refreshed status has an empty groups list, still run resolveUnchecked over previousMap.
    • correctness, adversarial, reliability
  • packages/api/src/tasks/checkAlerts/sloEvaluator.ts:63 — the fast and slow burn alerts on one SLO each resolve to a byte-identical ~6h chart config (getChartConfigFromAlert keys only on slo+source) and each runs its own ClickHouse scan, so an SLO pays two full 6h 5-minute-bucket scans even though getSloBurnChecks already derives both rules from one result set, and fast burn over-scans 6h for a 1h need.
    • Fix: Share one query per SLO evaluation window and derive both rules' verdicts from it, or scope the fast-burn config to its 1h window.
    • performance
  • packages/api/src/tasks/checkAlerts/sloEvaluator.ts:179 — the ungrouped ALERT→OK resolve-notification path through runSloBurnCheck is untested; the one "stops burning" test uses an empty previousMap, so sendNotificationIfResolved never fires, and all resolve coverage goes through resolveUnchecked.
    • Fix: Add a case with an ungrouped ALERT (fired: true) in previousMap and clean current rows, asserting state OK and one resolve render.
    • testing
  • packages/api/src/controllers/sloStatus.ts:71 — the grouped write-back branch (per-group burn merge, deriveSloGroupState, worst-first sort, deriveGroupedSloState) has no test: the evaluator unit test fully mocks recordSloAlertBurn and the integration write-back case passes only ungrouped {burn}.
    • Fix: Add an integration case passing {groups: Map} against a grouped SLO status and assert per-group burn, re-derived state, worst-first ordering, and grouped overall state.
    • testing
🔵 P3 nitpicks (10)
  • packages/api/src/tasks/checkAlerts/index.ts:1443 — for a slow-burn alert endTime is dateRange[1] (15-minute floor) while the burn query end is 5-minute floored, so the notification link's to can be up to 10 minutes earlier than the window the burn numbers describe.
    • Fix: Derive the SLO notification endTime from getSloBurnQueryRange(now)[1] so it matches the computed burn window.
    • adversarial, correctness
  • packages/api/src/tasks/checkAlerts/sloEvaluator.ts:206 — resolveUnchecked calls getBurnStart(end) with the default fast-burn window, so a slow-burn alert resolving a dropped group builds a 1h link window instead of 6h.
    • Fix: Pass getSloBurnCondition(rule).window explicitly and drop the defaulted parameter.
    • maintainability
  • packages/api/src/controllers/sloStatus.ts:93 — the function returns the computed status and the caller assigns slo.status = status even when the guarded updateOne matched nothing, so the in-memory snapshot diverges from the DB on a concurrent edit.
    • Fix: Check matchedCount/modifiedCount and return null (or log) when the guard dropped the write.
    • correctness, adversarial
  • packages/api/src/tasks/checkAlerts/sloEvaluator.ts:153 — when alertable is false (group below SLO_GROUP_MIN_EVENTS), met becomes false and a previously-firing group is resolved, contradicting the inline comment that such a group "waits".
    • Fix: Carry forward the previous state when !alertable instead of leaving it OK, or confirm resolve-on-insufficient-data is intended.
    • correctness
  • packages/api/src/tasks/checkAlerts/sloEvaluator.ts:252 — the alert.sloRule ?? 'fastBurn' default is chosen independently here and in template.ts (getSloRuleMessage), so a future change to the default could make the fired rule and the described rule diverge.
    • Fix: Extract a single getSloRule(alert) helper beside getSloBurnCondition and call it from both sites.
    • kieran-typescript, maintainability
  • packages/api/src/tasks/checkAlerts/template.ts:325 — the budget-spent share burnRate * burnWindowMs / sloWindowMs is inlined in the template and is the inverse of the common-utils burn-threshold ratio, splitting the share↔rate relationship across files.
    • Fix: Move it into a named helper beside the existing ratio in common-utils and call it here.
    • maintainability
  • packages/api/src/tasks/checkAlerts/evaluators.ts:137 — the evaluator↔task import cycle is contained only by the lazy builtInEvaluators() factory, with no regression test, so an eager top-level reference would silently reintroduce the load-order bug.
    • Fix: Move the shared helpers (computeHistoryMapKey, extractGroupKeyFromMapKey, makeQueryAlertError) into a leaf module both sides import.
    • maintainability
  • packages/api/src/tasks/checkAlerts/index.ts:1366 — sloBurn is typed SloBurnStats[] | null in fireChannelEvent but SloBurnStats[] | undefined in the evaluator context and trySendNotification, forcing readers to treat absent and null as distinct.
    • Fix: Standardize on ?: SloBurnStats[] across the view type, context, and fireChannelEvent.
    • kieran-typescript
  • packages/api/src/tasks/checkAlerts/providers/index.ts:103 — buildSloLink is added as a non-optional method on the exported AlertProvider interface, a compile-time break for any out-of-repo provider registered via ADDITIONAL_PROVIDERS.
    • Fix: Make buildSloLink optional with a caller fallback, or document it as a required extension-API addition in the changeset.
    • api-contract
  • packages/api/src/tasks/checkAlerts/providers/default.ts:361 — getSloAlertDetails runs Slo.findOne plus a populated Source.findOne per alert, so an SLO's two alerts refetch the same two docs each loadAlerts tick.
    • Fix: Memoize the SLO and source fetch across an SLO's alerts within one loadAlerts run.
    • performance

Reviewers (11): correctness, adversarial, reliability, performance, kieran-typescript, testing, maintainability, project-standards, api-contract, agent-native, learnings-researcher.

Testing gaps:

  • recordSloAlertBurn optimistic-write no-op on a changed updatedAt is unverified.
  • getSloAlertDetails not-found / missing-connection branches and the IS_SLOS_ENABLED load gate are untested.
  • The query-timeout variant of makeQueryAlertError is not distinguished from the generic query-error path.
  • The resolve-message body (describeSloBurn reading stored numbers, budgetRemaining == null, "no events") is untested; resolve coverage is title-only.

No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond

This branch was successfully deployed

2 active deployments
Preview – hyperdx-storybook — 8cca8b29 Deployed Nov 24, 2026 by vercel[bot]
Preview – hyperdx-oss — 8cca8b29 Deployed Nov 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review/tier-4 Critical — deep review + domain expert sign-off

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant