Skip to content
Greg King
02 / CASE STUDY

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.

Spec-Driven LLM-as-Judge Eval Pipeline with CI Drift Gates Tool specifications feed both a CI freshness drift gate and a scenario generator, which executes against an evaluation runner and LLM-as-judge scorer (Braintrust and AWS Bedrock) before gating pull requests. SOURCE OF TRUTH Tool Specs Schemas & contracts Tool descriptions CI FRESHNESS DRIFT GATE Fails CI immediately if eval data drifts from specs Scenario Suite Derived per tool Versioned fixtures LLM-as-Judge Scorer Braintrust · AWS Bedrock Tool selection + fidelity CI GATE Pass / Fail Blocks stale specs & regressions TEST & EVAL INTEGRITY INVARIANTS (ANTI-HOLLOW-TEST RULES) 01 / Missing mocks must throw Refactors cannot pass silently when mocked fixtures vanish. 02 / Non-zero scenario counts Automated fixes cannot drop eval scenarios while CI stays green. 03 / Assert non-error states explicitly 04 / Every behavior change fails without the fix
Fig. 02 — Spec-driven eval pipeline pairing Braintrust/Bedrock LLM scoring with deterministic CI freshness and test-integrity checks.
  1. 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.
  2. 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.
  3. 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

DecisionChosen ApproachAlternative ConsideredWhy
Eval Dataset OwnershipSpec-derived scenarios enforced by CI freshness testsStatic hand-curated golden spreadsheetHand-curated sets drift silently the first time a parameter is renamed; coupling freshness checks to CI turns drift into a loud build failure.
Scoring StrategyDeterministic checks for schema/freshness + LLM-as-judge for semantic output qualityPure regex/exact-match assertions or 100% LLM judgingExact string matching is too brittle for natural-language responses, while using an LLM to check structural invariants is slow, expensive, and noisy.
Failure PhilosophyFail loud on missing mocks, zero-scenario runs, or skipped assertionsGraceful fallbacks / permissive test runnersPermissive 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.