Spec-Driven LLM-as-Judge Evals with CI Drift Gates
Built an automated evaluation suite scored by an LLM judge (Braintrust, AWS Bedrock), paired with deterministic CI freshness tests that fail builds whenever eval fixtures drift from live tool specs.
- Role
- Lead Software Engineer
- Domain
- AI Evaluation & CI Systems
- Timeline
- 2026
- Outcome
- Zero silent spec drift in CI
- TypeScript
- Braintrust
- AWS Bedrock
- LLM-as-Judge
- CI/CD Gates
01 / Problem & Constraints
Once an AI tool layer is live in production, every schema tweak, prompt edit, or model upgrade carries regression risk. Manual prompt-clicking before deploys does not scale—and worse, naive automated evals rot quietly as soon as tool specs evolve faster than test fixtures.
We needed an evaluation system that met three criteria:
- Grounded in live tool contracts: Test scenarios needed to reflect what tools actually accept and return today, not what they looked like two sprints ago.
- Actionable in CI: Engineers needed fast, legible pass/fail signals on pull requests without drowning in noisy nondeterministic flakes.
- Resistant to hollow passes: With coding agents writing a large share of code and refactors, our test and eval harness had to catch silent test degradation—not stay falsely green when assertions or mocks broke.
02 / System Architecture
Instead of treating eval datasets as static, hand-edited spreadsheets disconnected from code, we structured the pipeline directly around tool specifications and split verification into two layers: deterministic CI freshness checks and LLM-as-judge behavioral scoring.
- Scenario generation from tool specs: Each tool’s specification drives structured evaluation scenarios covering happy paths, parameter edge cases, and negative/out-of-scope prompts.
- Deterministic freshness gate: A fast CI check compares eval fixtures against current tool definitions and fails the build immediately if a schema changes without updating corresponding eval coverage.
- LLM-as-judge scoring: Scenarios execute against the tool surface and are scored via Braintrust backed by AWS Bedrock against explicit behavioral rubrics (correct tool selection, argument fidelity, faithful grounding in returned data).
03 / Key Architectural Trade-offs
| Decision | Chosen Approach | Alternative Considered | Why |
|---|---|---|---|
| Eval Dataset Ownership | Spec-derived scenarios enforced by CI freshness tests | Static hand-curated golden spreadsheet | Hand-curated sets drift silently the first time a parameter is renamed; coupling freshness checks to CI turns drift into a loud build failure. |
| Scoring Strategy | Deterministic checks for schema/freshness + LLM-as-judge for semantic output quality | Pure regex/exact-match assertions or 100% LLM judging | Exact string matching is too brittle for natural-language responses, while using an LLM to check structural invariants is slow, expensive, and noisy. |
| Failure Philosophy | Fail loud on missing mocks, zero-scenario runs, or skipped assertions | Graceful fallbacks / permissive test runners | Permissive harnesses produce the worst failure mode in engineering: a green CI checkmark over broken verification. |
04 / Failure Modes & Test Integrity
Running evals alongside heavy coding-agent usage exposed several real classes of hollow and gamed tests that shaped our permanent CI invariants:
- Missing mocks silently passing after refactors: After an internal refactor changed a lookup key, a suite kept passing without exercising the expected fixture. We updated the harness so missing mocks always throw loudly.
- Dropped eval scenarios with green CI: An automated fix commit once stripped eval scenarios while leaving the CI runner reporting success. Enforcing explicit non-zero scenario coverage closed that loophole.
- Identical-error parity passes: In parity-style checks, comparing two outputs for equality can pass when both sides fail with the same error and skip downstream assertions. Every test must explicitly assert success state before comparing payloads.
05 / Outcome
The evaluation suite became a dependable release gate for the AI tool platform rather than an afterthought. Tool specification changes can no longer drift out of sync with eval coverage unnoticed, and the integrity invariants carried directly into team-wide PR review standards—ensuring every behavior change ships with a test proven to fail without it.