convex/kpis.ts¶
Purpose¶
Periodic rollup of per‑minute KPIs (runs, errors, p95 latency, cost) into kpis_1m.
Public Surface¶
rollup1m(ctx): internal mutation called by cron every minute.crons.interval("rollup-1m", { minutes: 1 }, internal.kpis.rollup1m)
Behavior & Invariants¶
- Scans
runs_livecreated within the last closed minute, buckets byprojectId. - Computes p95 defensively (max for small samples).
Dependencies¶
- Depends on:
runs_livewithby_created_timeindex. - Used by: UI (future) for faster KPI charts.
TODO / Technical Debt¶
- Provide queries to fetch
kpis_1mfor dashboards.