Skip to content

fix(api): SLA compliance endpoint honors the definition's targets and exclusion flags (#9371) - #9494

Merged
ToddHebebrand merged 2 commits into
mainfrom
fix/9371-sla-compliance-honest-endpoint
Oct 21, 2026
Merged

ToddHebebrand merged 2 commits into
mainfrom
fix/9371-sla-compliance-honest-endpoint

Conversation

@ToddHebebrand

Copy link
Copy Markdown
Collaborator

Summary

  • GET /analytics/sla/:id/compliance now measures the definition's own targets (site / device / group via target_type + target_ids; org-wide otherwise; a scoped definition with no targets measures nothing, never the whole org) and returns uptimeTarget, meetsTarget and an exclusions block alongside liveUptime.
  • exclude_weekends: Sat/Sun do not count toward the window length (window reaches back over the same number of weekdays).
  • exclude_maintenance_windows: devices in a maintenance window right now (existing isDeviceInMaintenance) leave numerator and denominator. Point-in-time only, checked for up to 500 target devices (exclusions.maintenanceWindows = applied / skipped_too_many_devices). Historical window overlap needs the availability-interval work (Uptime KPIs from data Breeze already has: site WAN and device availability, with maintenance excluded #9273).
  • history: [] returned honestly (nothing writes sla_compliance; no period-close writes added). Dead history[0].compliancePercentage reads removed from the web page.

Linked Issues

Closes #9371

Merge Danger

Door: two-way (revert the PR; no schema/migration change)

Blast radius: SLA uptime figure on the Analytics page / compliance endpoint

Type of Change

  • Bug fix

Tests

  • Red first: 4 new route tests (site-targeted scoping + missed target, weekend widening, maintenance exclusion, empty history/meetsTarget) failed before the change.
  • apps/api vitest run src/routes/analytics.test.ts: 51 passed. apps/web vitest run src/components/analytics: 3 files / 10 tests passed.
  • tsc --noEmit exit 0 in apps/api and apps/web.

🤖 Generated with Claude Code

… exclusion flags; drop dead history read (#9371)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Deploying breeze with  Cloudflare Pages  Cloudflare Pages

Latest commit: f76bf89
Status: ✅  Deploy successful!
Preview URL: https://25b30cbd.breeze-9te.pages.dev
Branch Preview URL: https://fix-9371-sla-compliance-hone.breeze-9te.pages.dev

View logs

…ported, group targets denied to narrowed callers, DST-safe weekend window (#9371)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@ToddHebebrand

Copy link
Copy Markdown
Collaborator Author

Review run: /pr-review-toolkit:review-pr (code-reviewer, scoped to code + tests + error handling)
Findings: 3 important, 4 suggestions. Fixed in f76bf89: maintenance-lookup failure now reported as exclusions.maintenanceWindows: 'unavailable' (was an unhandled 500; concurrency lowered to 10), group-targeted definitions denied to site-narrowed callers (shared gate treats group as org aggregate), DST-safe weekend window length, tests added for lookup failure, empty targets and group denial. Deferred: SQL-side aggregation instead of fetching target device rows (3 columns/device; fine at current scale, revisit with #9273), group/device/over-cap test paths.
Tests: api analytics.test.ts + slaSiteScope.test.ts 78 passed; web analytics 3 files/10 tests passed; tsc --noEmit exit 0 in api and web (api needs a 20GB heap on this host).
Status: review-clean for blocking issues, awaiting maintainer merge.

@ToddHebebrand
ToddHebebrand added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit 0ccbae0 Oct 21, 2026
98 of 103 checks passed
@ToddHebebrand
ToddHebebrand deleted the fix/9371-sla-compliance-honest-endpoint branch October 21, 2026 11:51
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.

SLA compliance endpoint ignores the SLA definition and the history path never runs

1 participant