Skip to content

Data Model

AKogut edited this page Jul 15, 2026 · 1 revision

Data Model

PostgreSQL is the system of record: a relational core plus JSONB for flexible attributes and pgvector for failure-signature embeddings. Every table carries org_id / project_id for tenant isolation from day one.

Entity hierarchy

org (tenant root)
 └─ project (repo)                         -- has ingest_token(s)
     ├─ test_identity                      -- STABLE fingerprint, survives refactors
     ├─ run                                -- one CI job / workflow run
     │   └─ test_execution                 -- one execution of one test in a run
     ├─ flaky_score        (1:1 test_identity)
     ├─ error_signature    (dedup clusters)
     └─ rca_report         (per failed execution / signature)

Core tables

test_identity

The stable fingerprint that ties history together across refactors. See Test Identity Engine.

id, project_id
fingerprint            -- primary stable hash
file_path, suite, title, params_hash
aliases[]              -- prior fingerprints stitched on move/rename
first_seen_at, last_seen_at
quarantined (bool), quarantine_reason

run

id, project_id
commit_sha, branch, pr_number
ci_provider, ci_run_id, trigger
status, started_at, finished_at, duration_ms
git_diff_stat (jsonb)  -- files changed, for RCA context
otel_trace_id

test_execution

id, project_id, run_id, test_identity_id
attempt, retry_of      -- retry linkage within a run
status                 -- pass | fail | skip | flaky
duration_ms
error_message, error_signature_id
otel_span_id, otel_trace_id
artifacts_ref (jsonb)  -- object-store keys: screenshot/video/trace/HAR
attributes (jsonb)     -- raw span attributes

flaky_score (1:1 with test_identity)

Incrementally updated; never full-recompute. See Flaky Scoring.

identity_id
score (0..1)
flip_rate, pass_on_rerun_rate, same_sha_variance, entropy, fail_isolation
reason_codes (jsonb)   -- human-readable explanations
quarantine_candidate (bool)
last_flaked_at, model_version, updated_at

error_signature

Normalized failure fingerprint for dedup + clustering. See AI RCA Architecture.

id, project_id
normalized_hash
sample_message, stack_template
embedding (vector)     -- pgvector
cluster_id, occurrence_count
known_issue_ref        -- optional link to a tracking issue
first_seen_at, last_seen_at

rca_report

id, project_id, execution_id, signature_id
summary, likely_cause, suggested_action
confidence (0..1)
similar_past (jsonb)   -- top-K historical matches
llm_model, token_cost
created_at

Ingestion queue

ingestion_job
  id, project_id
  payload_ref            -- object-store key or inline
  status                 -- pending | processing | done | dead
  attempts, visible_at   -- visibility timeout for SKIP LOCKED
  created_at, updated_at

Rollups (analytics)

Dashboards must never scan raw test_execution. Pre-aggregated, incrementally refreshed:

  • daily_test_stats — per identity per day: runs, passes, fails, flakes, p95 duration
  • flaky_trends — flaky score over time per identity
  • suite_daily — project-level pass rate, flaky rate, total duration, p95

Indexing strategy (hot paths)

Query Index
Runs list for a project by time (project_id, started_at desc)
Test history (test_identity_id, started_at desc) on executions
Flaky board (project_id, score desc) on flaky_score
Signature lookup (project_id, normalized_hash) + ivfflat on embedding
Queue dequeue (status, visible_at) partial index

Retention & tiering

  • Raw test_execution + span attributes: short retention (config, e.g. 30–90d).
  • Rollups: long retention (trends outlive raw data).
  • Artifacts: object-store lifecycle + GC job.
  • At scale, span-level data moves to a columnar store (ClickHouse/Timescale) behind the same repository interface — see Ingestion and Scaling.

Clone this wiki locally