Treat AI quality like unit tests: run the golden set in CI and fail the build when quality drops. Without a gate, a prompt tweak or a model-version bump silently degrades production.
rag_ci_gate:
dataset: golden/refund-v3.jsonl
thresholds: { recall_at_5: '>= 0.85', faithfulness: '>= 0.92', p95_latency_ms: '<= 1800' }
fail_build_on:
- recall_at_5 drops by more than 0.03
- any P0 safety case fails
Declare what actually fails the build. A dashboard that shows a regression but doesn't block the deploy is decoration. The gate must name concrete conditions (absolute thresholds and delta-from-baseline) and a rollback action, or the regression ships and someone notices in production a week later.
Every threshold needs an owner. An unowned metric is informational only — when it fails, nobody is accountable to fix or waive it, so teams quietly start ignoring red. Assigning an owner per threshold is what keeps the gate meaningful.
Handle judge flakiness statistically. LLM-as-judge scores wobble run-to-run. Use multiple samples and a variance bound so the build fails on real drops, not noise — otherwise flaky red trains the team to bypass the gate, which is worse than having no gate.