Skip to content

feat(alerts): resolve an incident by hand, and time to acknowledge - #3018

Merged
Makisuo merged 70 commits into
mainfrom
alerts/incident-actions
Nov 24, 2026
Merged

Makisuo merged 70 commits into
mainfrom
alerts/incident-actions

Conversation

@Makisuo

@Makisuo Makisuo commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Stacked on #3017. Two things an incident could not do: be resolved by a person, and say how long it waited for one.

What changed

  • Resolve by hand. An open incident can be resolved from the incident page (it asks first), over the API (POST /v2/alerts/incidents/{id}/resolve) and by the resolve_alert_incident MCP tool. Everyone the incident notified gets the all-clear, which says who resolved it, and its escalation stops. Who may do it is the same as acknowledging (incidents:respond).
  • It stays resolved. If the rule still breaches, that rule and group open no new incident until a check reads healthy or reads no data (a group that leaves the rule's results counts as that), and for a day at most. Switching the rule off, or changing how it evaluates, ends that too. Without this the next check would reopen it a minute later.
  • The all-clear cannot be lost. It is prepared before anything changes and written in the same transaction as the resolve. If it cannot be prepared, the incident stays open and the request fails.
  • Time to acknowledge. The first acknowledgement is stamped on the incident (first_acknowledged_at) and kept through unacknowledge, escalation and resolve. The inbox, the incident header and a rule's History say how long the incident stood before it.
  • Timeline. The incident page reads every delivery of its incident (it read the newest 100), and shows the resolve by hand as an entry.
  • Migration: alert_incidents.first_acknowledged_at and quiet_since (both nullable), and a partial index on quiet_since. first_acknowledged_at is filled from each incident's acknowledgement history.

Screenshots (lab)

Incident page, before and after (the Resolve button):

The question before a resolve (new), and the button locked for a role that may not respond:

Acknowledged, before and after (how long it took, in the header):

Resolved, before and after:

A rule's History, before and after (the second line under Duration):

The pages are the real ones over fixtures, in a new lab page (/lab/incident-actions). The before shots are main with the same lab file.

Verification

  • AlertsService.incident-actions.test.ts (PGlite, 7 cases): the resolve closes the incident, sends an all-clear naming who resolved it and refuses a second resolve or another org's incident; nothing reopens while it still breaches; it reopens after a healthy check, after a no-data check, after a day, after the rule is switched off and on, and for a group that left the rule's results and came back; an all-clear that cannot be prepared leaves the incident open.
  • AlertIncidentAckService.test.ts: the first acknowledgement is stamped once and kept.
  • MobilePushService.test.ts: a hand-resolved monitor or certificate push says who resolved it, not that a check passed or a certificate was renewed.
  • API: an HTTP test for the resolve route (403 for a read-only key, 200, the timeline event, 409 on a second resolve, 404).
  • MCP: resolve_alert_incident by REST id, as the caller, with the errors named on incident_id.
  • Web: scene tests for the Resolve dialog (asks first, one request, shown resolved before the sync, failure leaves the question open, locked for an analyst), the inbox line, the History line and the deliveries paging.
  • Suites run: backend alerts and push (68 files, 843 tests), packages/db (83, which replays the migration with its backfill), API alerts and runtime (45), MCP tools (883), apps/web alerts, overview and lab (803), packages/web-data (387). Typecheck for backend, api, ai, web, web-data.
  • A review pass found a group that could stay quiet for good when its checks read no data after the resolve. The bot reviews added: a group that left the results staying muted, the uptime push wording for a resolve by hand, and the first acknowledgement of incidents acknowledged before the migration. All fixed here, with the tests above.

Not verified here

  • The backfill against real acknowledgement history. The migration tests replay it on empty tables, which proves the SQL runs, not what it writes.

Not in this PR

  • An all-clear for people a chain step paged directly. Email and chat pages to a person have no resolve message today, for a resolve by a check or by hand. It needs a new member notification kind.
  • Limiting an all-clear to destinations that were paged. A destination added to a rule while an incident is open gets its resolve, as it does for a resolve by a check.
  • Posting an investigation's result into the alert's chat thread. It needs a new outbox event and thread replies in the dispatcher, so it gets its own PR.

🤖 Generated with Claude Code

- A reopen above the severity the earlier incident reached is no longer
  muted as a flap.
- Deleting a rule (or the SLO, monitor, budget or detection that owns it)
  leaves one queued resolve per destination its open incidents paged.
- A retried trigger or reminder is not sent once its incident resolved.
- A pager whose page landed after the acknowledgement is told about it.
- A reminder planned before an acknowledgement committed is not sent.
- A reopen is a flap only of an incident whose page got through.
- Every page landing after an acknowledgement is acknowledged, whatever
  was acknowledged before it.
- One staleness rule for single deliveries and chat digests; a page whose
  incident is gone is stale too. Linear still files a late ticket.
- The all-clear of a deleted rule says so and does not link a deleted page.
- The delete reads only rows that may have paged, capped, and inserts in
  chunks.
- A skipped reminder leaves the reminder clock where it was.
- A shift of someone who left the org passes to the next person in the
  rotation; their overrides are ignored. Schedules report who left.
- A step that reaches nobody is not counted, records the gap on the
  incident's timeline and moves straight to the next step of the pass.
  A pass that ends having reached nobody pages the org's admins by email.
- A chain is labelled with the tier that names it, so an incident that
  opened critical keeps the warning tier's chain when it drops back, and
  an incident that turns critical runs an inherited chain that had run out.
- A schedule cannot be deleted while a running escalation still pages it.
- Step waits count from the step's due time, not from when the tick ran.
- Schedules report their coverage gaps for the next 14 days (API and MCP).
…noise

- A dead service keeps its page: the liveness probe reads the SLO's short
  windows, not the rule's day-long one.
- A tier needs 10 events and 2 bad ones in its long window to fire; on
  fewer it holds its state instead of clearing.
- A tier's factor is capped at 80% of the highest burn the target can
  reach, so a low target can alert at all.
- New slow-burn warning tier: 3x over 24h and 2h.
- A spent error budget is a warning of its own, in its own alert group
  with a daily reminder, so a burn page still resolves when the burn ends.
- One Postgres read and one warehouse read per SLI for an org's SLOs each
  tick, instead of one of each per SLO.
- The migration is regenerated on top of main's newest.
- A skipped step keeps its due time for the step that stands in for it,
  so that step still dedupes against the tier's own page.
- A step that reaches nobody for any reason is on the incident's timeline.
- A late step still leaves half its wait to acknowledge.
- A schedule edit reads the member directory fresh.
- The noise guard counts recorded spans, not sampling-weighted ones, so one
  sampled failure cannot pass as ten.
- The worker builds its services per tick, so the SLO reads share one
  lookup per tick and the window totals are read on every fifth tick, at
  the tick's own aligned bounds.
- A rule's stored thresholds follow its target: on a target edit, and once
  for rules saved before the tiers changed.
- The budget warning has a label of its own, no chart of another group's
  series, and a 2% margin before it clears.
- Bench cases for the batched alert reads.
…and pages in flight

The newest page per incident and destination is picked in SQL, so reminders to one
destination cannot crowd out another. Pages that never left are deleted first, a page
still on its way out gets its all-clear a minute later, and an all-clear already queued
survives the delete. The all-clear links to the alerts list. CI: backend lanes are sized
at 2.9s per file, lane 2 of 9 ran over the 240s budget on main too.
A chain that keeps running after a downgrade pages its next step with the breach as it
stands. A repeat that reaches nobody emails the admins like a first pass does, and the
step admins stood in for is on the timeline. A schedule can be deleted once a running
escalation is past the steps that page it. The schedule editor's preview ignores an
override whose person left, and a gap list cut at its cap says so.
…w time to acknowledge

The incident page gets a Resolve button that asks first. The inbox, the incident header
and a rule's history say how long an incident stood before its first acknowledgement.
An incident's timeline reads every delivery, not the newest 100. Adds an HTTP test for
the resolve route and a lab page for the incident page and rule history.
The quiet after a resolve by hand ends on a check that reads healthy or reads no data,
after a day at most, and when the rule is switched off or its evaluation changes, so a
group can no longer stay muted for good. The all-clear is prepared before anything
changes and written with the resolve; if it cannot be prepared the incident stays open.
The phone push says who resolved it. The incidents route reaches the resolve through a
narrow service, and paged deliveries are de-duplicated.
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@maple-review-bot

This comment has been minimized.

…a late ticket reads the incident's current status

A chat post that was deliberately not made told nobody, so deleting the rule no longer answers it with a resolve; an older page that did go out still gets one. A ticket filed after its incident resolved is filed as resolved from the fresh read, not from the claim batch's older copy.
# Conflicts:
#	packages/backend/src/services/alerts/AlertsService.ts
#	packages/backend/src/services/alerts/delivery/deleted-rule-resolve.ts
@maple-review-bot

This comment has been minimized.

…ht or retried

A kept resolve that was being sent when its rule was deleted is rewritten for the worker that takes it over, and a retry made after the deletion points at the alerts list too.
# Conflicts:
#	packages/backend/src/services/alerts/AlertsService.ts
@maple-review-bot

This comment has been minimized.

@maple-review-bot

This comment has been minimized.

Base automatically changed from slo/alert-correctness to main November 24, 2026 13:46
@Makisuo
Makisuo merged commit 94a27d6 into main Nov 24, 2026
9 checks passed
@Makisuo
Makisuo deleted the alerts/incident-actions branch November 24, 2026 13:47
@maple-review-bot

Copy link
Copy Markdown

Merged with 1 step from "Before merge" still open. If it is done, tick it on the review comment; if not, now is the time.

  • Migration · Check it is safe on production data and with the code still deployed

Makisuo added a commit that referenced this pull request Nov 24, 2026
@maple-review-bot

maple-review-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Maple review

🟡 Confidence 6/10 · needs attention. Held at 6 because a correctness warning is open.
1 warning −1 · tests covered · risk high −1 · 2/2 new units observable

Adds a hand resolve for alerts (dashboard, POST /v2/alerts/incidents/{id}/resolve, MCP) that queues the all-clear in the same transaction, a 24h quiet on the group it resolved, and first_acknowledged_at with time to acknowledge. The backend logic holds up; one timeline sentence overstates the quiet.

  • resolveIncident writes the resolve, its event and the all-clear in one transaction
  • quietSince mutes a group after a hand resolve until a clean or no-data check, 24h at most
  • first_acknowledged_at is stamped once and rendered as time to acknowledge
  • The incident timeline pages every delivery instead of the newest 100

Before merge

Findings

🟠 Warning · F1 · resolved timeline detail promises a silence the server does not keep

correctness · packages/web-data/src/alerts/incident-timeline.ts:139

A group resolved by hand reopens when its check reads no data, and after QUIET_AFTER_RESOLVE_CEILING_MS (24h) whatever the rule reads. This line tells the reader a healthy check is the only way back, so a still-breaching rule reopens an incident the timeline said would not come.

Say "nothing reopens until the rule reads healthy or reads no data, and for a day at most", as the resolve dialog and the endpoint description do.
🤖 Prompt to fix this finding with an AI agent
Findings from an automated review of commit 16b682a45984007385ea89a5a748f236398bc977. Verify each one against the current code before changing anything, fix only those that still apply, and keep each fix to the lines it names.

---

F1 · Warning · correctness · packages/web-data/src/alerts/incident-timeline.ts:139
`resolved` timeline detail promises a silence the server does not keep
A group resolved by hand reopens when its check reads no data, and after `QUIET_AFTER_RESOLVE_CEILING_MS` (24h) whatever the rule reads. This line tells the reader a healthy check is the only way back, so a still-breaching rule reopens an incident the timeline said would not come.
Suggested fix: Say "nothing reopens until the rule reads healthy or reads no data, and for a day at most", as the resolve dialog and the endpoint description do.

16b682a · What was checked, coverage and telemetry details are on the Maple / review check. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.

@maple-review-bot maple-review-bot 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.

1 inline note from Maple's review. The score and summary are in the review comment above.

title: `Resolved by ${who}`,
detail: Arr.join(
Arr.filter(
[from, "nothing reopens until the rule has been healthy once"],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning

resolved timeline detail promises a silence the server does not keep

F1 · Warning · correctness

A group resolved by hand reopens when its check reads no data, and after QUIET_AFTER_RESOLVE_CEILING_MS (24h) whatever the rule reads. This line tells the reader a healthy check is the only way back, so a still-breaching rule reopens an incident the timeline said would not come.

Say "nothing reopens until the rule reads healthy or reads no data, and for a day at most", as the resolve dialog and the endpoint description do.
🤖 Prompt to fix with an AI agent
In `packages/web-data/src/alerts/incident-timeline.ts:139`: `resolved` timeline detail promises a silence the server does not keep.

A group resolved by hand reopens when its check reads no data, and after `QUIET_AFTER_RESOLVE_CEILING_MS` (24h) whatever the rule reads. This line tells the reader a healthy check is the only way back, so a still-breaching rule reopens an incident the timeline said would not come.

Suggested fix: Say "nothing reopens until the rule reads healthy or reads no data, and for a day at most", as the resolve dialog and the endpoint description do.

Verify the problem exists at that location before changing it, and keep the fix to those lines.

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