# SLOs + Error Budgets

What we promise + how we measure.

## SLIs and SLOs

| SLI                                       | SLO                   | Window         | Source                                                          |
| ----------------------------------------- | --------------------- | -------------- | --------------------------------------------------------------- |
| API availability (`/api/*` returns < 500) | 99.9%                 | 30-day rolling | Ingress + `http_server_requests_total{job=api-*}`               |
| API p95 latency                           | ≤ 300 ms              | 30-day rolling | `http_server_request_duration_seconds_bucket` p95               |
| Login success rate                        | ≥ 99.5%               | 7-day rolling  | `loma_auth_login_total{result=success} / loma_auth_login_total` |
| Queue processing latency p95 (audit)      | ≤ 5 s                 | 7-day rolling  | BullMQ exporter `bullmq_jobs_completed_seconds`                 |
| Frontend LCP p75                          | ≤ 2.5 s on 3G profile | 7-day rolling  | Lighthouse CI in CI; RUM (Phase 9+)                             |
| DSAR fulfillment time                     | ≤ 30 days             | per-request    | Manual track in compliance dashboard                            |

## Error budgets

A 99.9% / 30-day SLO allows **43 m 49 s** of unavailability per month.

| SLO                   | Budget per 30 days                       |
| --------------------- | ---------------------------------------- |
| 99.9% availability    | 43 m 49 s                                |
| Login success ≥ 99.5% | 0.5% of attempts                         |
| API p95 ≤ 300 ms      | 5% of windows can breach without ringing |

## Burn-rate alerts

- **Fast burn**: 14.4× burn → 2% of budget in 1 hour → page immediately.
- **Slow burn**: 6× burn → 10% of budget in 6 hours → page during business hours.

Implement in `platform/observability/grafana/dashboards/` + Alertmanager rules (Phase 9+).

## What we do when the budget is depleted

1. Freeze risky changes (feature flags + deploys) for 7 days.
2. Allocate engineering time to reliability work.
3. If the budget is depleted in < 7 days repeatedly, raise the SLO or invest in resilience — write an ADR.

## What we do when we have surplus budget

1. Ship aggressively (it's literally what the budget is for).
2. Run game days / chaos experiments (deliberately use some budget to find weaknesses).

## Review cadence

- Engineering reviews SLO compliance monthly.
- The SLO targets themselves are revisited every 6 months (or after a major architecture change).
