Skip to content

feat(on-call): a private calendar feed per schedule, and docs for schedules and chains - #3023

Merged
Makisuo merged 87 commits into
mainfrom
oncall/calendar-feed
Nov 24, 2026
Merged

Makisuo merged 87 commits into
mainfrom
oncall/calendar-feed

Conversation

@Makisuo

@Makisuo Makisuo commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Stacked on #3018. On-call shifts in your own calendar, and docs for schedules and escalation chains.

What changed

  • A calendar feed per schedule. A schedule can hand out one private iCalendar link. A calendar app subscribes to it and shows the schedule's final shifts from a week back to 60 days ahead. Every handoff starts an event, so a rotation of one person still shows a shift per rotation, and a long override is one event with its real start and end. Make it, replace it or turn it off from Calendar feed on the schedule's page, or with POST and DELETE /v2/alerts/oncall_schedules/{id}/calendar_feed.
  • A link in use is never replaced by accident. Creating a link when one exists answers 409 (oncall_calendar_feed_exists) unless the request says replace=true, and the check is part of the write. The page asks before replacing; a create that finds a link someone else made shows theirs.
  • The link is the only credential, and is treated as one.
    • 32 random bytes, shown once. Only its SHA-256 is stored, so a database read does not hand out working links.
    • Served at GET /calendar/oncall/<token>.ics with no sign-in. An unknown link is a bare 404.
    • Kept out of telemetry: the automatic server span is suppressed for the whole prefix (in every spelling the router serves) and replaced by a server span that carries the route, method and status, never the path. The route parameter is redacted as a second line, and the worker's two error logs that carry a request path now redact the credential segment. That last change also covers the heartbeat ping path, which had the same gap.
    • Rate limited per caller and per link, with the limiter shared dashboard links already use.
    • Replacing the link ends the old one at once. The audit log records who made or ended a link, never the link.
  • What the feed shows. People by display name. Someone without one is shown as "On call (schedule)", never by email or id, and event ids are hashes. Shifts of people who left pass on, as when paging. When the member directory is down the route answers 503, so a calendar app keeps its last good copy instead of a feed without names.
  • Docs. Two new pages, On-call schedules and Escalation chains, and the incidents page gains the resolve by hand and time to acknowledge from feat(alerts): resolve an incident by hand, and time to acknowledge #3018.
  • Migration: oncall_schedules.calendar_feed_token_hash and calendar_feed_created_at (both nullable), and a unique index on the hash.

Screenshots (lab)

Schedule page, before and after (the Calendar feed section at the bottom):

The link just made, shown once (new):

A feed that is already on (the link is not shown again), and the question before replacing it:

Verification

  • packages/alerting-core oncall-ics.test.ts (7): one event per shift in UTC, escaping, CRLF, folding at 75 octets without splitting a character.
  • OnCallSchedulesService.test.ts (PGlite, 8 feed cases): the link opens the feed and a guess, a truncated link or a wrong shape opens nothing; only a hash is stored; a second create is refused and the first link keeps working, a replace ends the old link and turning off ends both; a rotation of one person has an event per handoff and an 80 day override keeps its real dates seven weeks in; only someone who manages alerts in the schedule's own org can make or end a link; a deleted schedule's link opens nothing; a shift keeps its real start, end and event id from one fetch to the next; a directory outage fails instead of serving a feed without names.
  • API: oncall-calendar.http.test.ts (5: 200 as text/calendar with private caching, the bare 404, 503 for the database and for the directory, 429 keyed by a hash), the feed endpoints in alerts.http.test.ts (403 for a read-only key, the link's shape, the schedule never carrying the link, 409 on a second create, replace, turn off, 404), and api-observability.test.ts for the span filter and log redaction.
  • Web: scene tests for the section (off, made once, on, replace and turn off behind a question, locked for a member, a later read by someone else's change, a read that left before a replace, a create refused because someone else made a link).
  • Suites run: API (78 files, 838 tests), packages/domain (1565), packages/alerting-core (96), MCP tools (882), apps/web alerts, lab and audit log (840), the landing app's docs tests. Typecheck for alerting-core, backend, api, web, domain, ai.
  • A review pass found the span filter missing spellings the router serves, the path in two error logs, shifts clipped at the window's edge and no rate limit. The bot reviews added: a create that silently replaced a link, merged events for a rotation of one person, long overrides clipped at the render range, the feed span not being a server span, and an old schedule read removing a link just made. All fixed here, with the tests above.

Not verified here

  • The feed in a real calendar app. The format follows RFC 5545 and is unit tested; subscribing from Google Calendar, Apple Calendar and Outlook is worth a manual check on the preview.

🤖 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.
# Conflicts:
#	packages/backend/src/services/alerts/AlertsService.ts
#	packages/backend/src/services/alerts/delivery/deleted-rule-resolve.ts
…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.

@Makisuo

Makisuo commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

On F4 from the review summary (a link another admin turned off stays on the page as live): fixed in 07e6937. The page remembers whether a read of the schedule has shown the link it made. Before that, a read that says "off" is taken as one that left before the create landed; after it, "off" means someone turned the feed off, and the page shows that. Scene test added.

@maple-review-bot

This comment has been minimized.

@Makisuo

Makisuo commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

On F3 from the review summary (the feed dialog's exit paths had no test): added in b2a2041. The scene test covers Escape and Close (the question closes, nothing is sent, a confirm afterwards has nothing to answer) and that the question cannot be left while the change runs.

@maple-review-bot

This comment has been minimized.

Base automatically changed from alerts/incident-actions to main November 24, 2026 13:47
@Makisuo
Makisuo merged commit c32822e into main Nov 24, 2026
8 checks passed
@Makisuo
Makisuo deleted the oncall/calendar-feed branch November 24, 2026 13:48
@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 10/10 · safe to merge. The new unauthenticated route, the hashed-credential write and the page's reconcile are each pinned by tests; the token stays out of spans and logs.
no findings · tests covered · risk high · 3/3 new units observable

Adds a per-schedule iCalendar feed: a hashed one-time link, an unauthenticated GET /calendar/oncall/:file that renders shifts with stable event ids, v2 create/delete endpoints that refuse to replace a live link without replace=true, a schedule-page section, and docs. Safe to merge.

  • createCalendarFeed decides replace inside the update, so a live link is only swapped on request
  • The feed route carries its own server span while the automatic one is suppressed for the prefix
  • reconcileCalendarFeed keeps the page's own link until a later schedule read contradicts it
  • renderOnCallCalendar emits one event per shift with a hashed UID stable across fetches

Before merge

4d8d519 · 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.

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