Convex realtime
Tables & indices¶
runs_live- Fields:
id,projectId,experimentId?,provider,model,inputTokens,outputTokens,costUSD,costSource?,costEstimated?,latencyMs,status,errorCode?,promptHash?,promptPreview?,traceId?,createdAt,syncedToPg,metadata? - Indices:
by_project_time,by_experiment_time,by_status_time,by_run_id,by_created_time kpis_1m: per-minute aggregates byprojectId, minuteTsprojects: withby_organization,by_organization_activeapiKeys: withby_project,by_organization,by_key_hash,by_project_activeentitlements: withby_org
See also: convex/schema.md
Functions¶
runs.ingestRun,runs.ingestRuns: insert run(s), schedule sync, idempotent byid(set fromrunIdwhen provided).runs.listRuns(projectId, sinceMs): recent runs for a project, capped at 500.runs.listRunsByOrganization(organizationId, sinceMs): scans time index and filters by project membership.runs.getById(runId): lookup byby_run_id.runs.markSynced(runId): internal mutation to setsyncedToPg=true.runsActions.internalSyncToPg(runId): internal action to POST to/api/internal/pg-syncwith HMAC.kpis.rollup1m: internal mutation; Convex cron every minute.projects.create,projects.listByOrganization,projects.getById,projects.update,projects.archive.apiKeys.create,apiKeys.listByProject,apiKeys.listByOrganization,apiKeys.validateKey,apiKeys.recordUsage,apiKeys.revoke,apiKeys.update.
See also: convex/runs.md, convex/runsActions.md, convex/kpis.md, ../03-architecture.md, ../06-frontend.md
Subscriptions in UI¶
/dashboard:useQuery(api.runs.listRunsByOrganization, { organizationId, sinceMs })/runs:useQuery(api.runs.listRuns, { projectId, sinceMs })/settings: API keys viaapi.apiKeys.listByProject/projects:api.projects.listByOrganization,api.projects.getById
Cleanup & retention¶
- TTL for
runs_livenot yet configured. TODO: Add periodic cleanup/archival.