convex/runs.ts¶
Purpose¶
Realtime ingestion and read APIs for LLM runs in runs_live.
Public Surface¶
ingestRun({ projectId, payload }) => { id }ingestRuns({ projectId, payloads }) => { ids }listRuns({ projectId, sinceMs }) => Doc[]listRunsByOrganization({ organizationId, sinceMs }) => Doc[]getById({ runId }) => Doc | nullmarkSynced({ runId }): internal
Behavior & Invariants¶
- Idempotent insert by
payload.runId(checked viaby_run_id). - Truncates
promptPreviewto 160 chars. - Schedules internal sync action after insert.
listRuns*caps total to 500.
Dependencies¶
- Depends on:
schema.tstables;runsActions.internalSyncToPg. - Used by: API
/api/ingestand UI pages (runs, dashboard).
Error Handling¶
- Duplicate run IDs return existing ID without mutation.
Configuration & Flags¶
- None directly; sync action depends on
RUNFORGE_SYNC_URL/RUNFORGE_SYNC_SIGN.
Example Usage¶
TODO / Technical Debt¶
- Add TTL cleanup for
runs_live. - Consider pagination for
listRuns.