Introduction
Once contracts, decoding, style, context, tools, and validators are in place, you still need one thing to ship safely: evidence that a change will not break production. Evaluation and operations provide that evidence. This article describes a practical framework—golden tests, canary releases, and one-click rollback—that turns prompt-engineered routes into systems you can change every day without fear. We’ll define the artifacts, the gating metrics, and the minimal automation you need to graduate from “it looks good locally” to “it’s safe at scale.”
The Problem Evaluation Must Solve
Generative systems fail in ways that unit tests don’t catch:
Small contract or policy edits cause subtle regressions in refusal behavior, tone, or claim freshness.
A decoding tweak improves one section and degrades another.
Retrieval indexes or claim-shaping rules change underneath you.
Costs drift upward as repairs and retries quietly increase.
Traditional QA by eyeball can’t keep up. You need stable, automated signals that fire before customers notice.
Core Concepts
Golden Tests (Goldens). Fixed, anonymized inputs with expected properties (not verbatim text). They encode the non-negotiables: schema, refusal/ask rules, citation coverage, banned lexicon, jurisdictional limits, and tool safety.
Canary Releases. Expose a change to a small, representative slice of traffic (typically 5–10%), measure predefined gates, and pause automatically on regression.
Rollback. Promote changes behind feature flags and keep the last “green” artifact bundle (contract, policy, decoder, validators). If gates fail, revert in one action; no rebuilds or manual edits.
Designing Golden Tests
What a Golden Encodes
Inputs: realistic prompts + parameters (and claim packs if grounded).
Expected properties:
“Must refuse if
required_fieldsare missing.”“At least 70% of factual sentences have claim IDs.”
“No banned terms; product casing correct.”
“If tool proposal is emitted, preconditions must be listed.”
Rationales: short notes explaining why the property matters (useful during reviews).
Size and Coverage
Start with 30–50 cases per route and grow to 100–200 for high-risk flows or varied locales. Keep a challenge subset (10–20%) for adversarial prompts, conflicting claims, and missing fields. Rotate a few cases each sprint to avoid overfitting.
File Layout (example)
/routes/<route>/goldens/
001_missing_field.json
014_conflicting_claims.json
037_tool_proposal_limits.json
Each test contains inputs, optional claim pack IDs, and property assertions. The runner returns pass/fail plus a failure taxonomy (SCHEMA, CITATION, SAFETY, TONE, LENGTH, EVIDENCE, IMPLIED_WRITE).
Building a Minimal Test Runner
Your runner should accept an artifact bundle and an input bundle, then emit structured results:
Inputs: contract hash, policy version, decoder policy, validator config; prompt params; claim pack ID(s).
Outputs: chosen variant, validator errors, repair steps, time-to-valid, tokens used, tool proposals and decisions.
Judgment: pass/fail per property; overall pass when all properties succeed on the first attempt.
Make the runner usable locally and in CI. In CI, block merges when:
First-pass Constraint Pass-Rate (CPR) drops,
Time-to-valid p95 increases beyond threshold, or
$/accepted output exceeds budget (when you simulate cost).

Join the conversation! Your thoughts help the community grow.