P1 · Chapter 11 / 15
LLM evals / AI test quality
The 60-second cheat sheet#
An eval is a repeatable measurement of AI behavior against explicit criteria. For generated tests, “compiles,” “passes,” “covers requirements” and “detects defects” are separate outcomes. Build an approved dataset and compare versioned agent configurations under controlled conditions.
Gold dataset and evaluation harness#
Each case contains Jira acceptance criteria, approved reference behavior, edge cases, expected scenarios, controlled application fixtures and a human-reviewed baseline. Record repository/app version, dataset version, prompt/rules, model identifier, Skills/Powers versions, tool permissions, settings, seed where supported, run time/cost and generated artifact hash. Keep failures and reviewer edits, not only successful samples.
Split development examples from held-out requirements. Include unseen negative cases, multiple domains and adversarial ambiguity. Repeating exact instruction examples as the entire evaluation rewards memorization. Repeat samples when outputs are nondeterministic; compare distributions and confidence, not one lucky run.
// Standalone TypeScript: deterministic metric calculation for reviewed scenarios.
type Counts = { correct: number; generated: number; expected: number;
covered: number; criteria: number; killed: number; validMutants: number };
export function metrics(c: Counts) {
const ratio = (a: number, b: number): number | null => b ? a / b : null;
return {
precision: ratio(c.correct, c.generated), recall: ratio(c.correct, c.expected),
criterionCoverage: ratio(c.covered, c.criteria),
mutationScore: ratio(c.killed, c.validMutants),
};
}
// Counts require an agreed matching rubric; null means undefined, not 100%.
Metrics and interpretation#
| Metric | Definition / evidence | Pitfall |
|---|---|---|
| Compile success | Typecheck succeeds / generated artifacts | Transpilation alone is not typechecking |
| Execution success | Intended checks run successfully on correct baseline | Product failures need classification |
| Assertion strength | Assertions validate criterion-relevant outcomes | Counting assertions rewards noise |
| Criterion coverage | Reviewed covered criteria / eligible criteria | Weak heading assertion may not cover criterion |
| Scenario precision/recall | Correct generated / generated; matched expected / expected | Requires explicit matching rubric and baseline completeness |
| Hallucination rate | Unsupported endpoints/locators/claims / defined opportunities | Define denominator and severity |
| Reviewer acceptance/effort | Accepted changes, edits and minutes | Reviewer consistency and task difficulty |
| Flaky rate | Outcome inconsistency on unchanged controlled baseline | Environment changes confound |
| Fault detection | Valid seeded faults killed / valid seeded faults | Equivalent/unreachable mutants excluded with review |
| Cost/runtime/compliance | Tokens/tool cost, wall time, forbidden actions | Cheap unsafe output is not a success |
Controlled defect detection#
Correct behavior displays VERIFIED after successful verification. In an isolated test environment, inject a controlled response/logic mutation returning PENDING instead. A meaningful status assertion must fail; a test that checks only the “Verification” heading may still pass. That test has execution success but weak detection ability. Verify each mutant is exercised; a startup crash is not necessarily the intended defect detection.
// Complete UI-only assertion-sensitivity test; illustrative app route.
import { test, expect } from '@playwright/test';
test('controlled wrong state is visible to the assertion', async ({ page }) => {
await page.route('**/api/verification/eval-user', route => route.fulfill({
status: 200, contentType: 'application/json',
body: JSON.stringify({ id: 'eval-user', status: 'PENDING' }),
}));
await page.goto('/verification/eval-user');
// In a mutation campaign, the generated success test must fail on this fixture.
await expect(page.getByTestId('verification-status')).toHaveText('PENDING');
});
The code above verifies the mutation fixture wiring and passes for PENDING; the generated success test should instead assert VERIFIED and fail against it. Do not misreport this wiring test as a mutation kill. A UI mock is assertion-sensitivity evidence; true backend mutation tests require the controlled application mutation to be deployed in the test environment. Never mutate production.
A/A, A/B and example results#
| Comparison | Purpose | Control |
|---|---|---|
| A/A same agent/config | Estimate noise and harness stability | Same cases/environment and repeated samples |
| A/B model or agent version | Compare actual change | Hold other settings constant; paired cases |
| Rule/Skill ablation | Estimate contribution of context/validation procedure | Change one component; preserve permissions/data |
| Human baseline | Practical quality/effort reference | Comparable requirements and review rubric |
Hypothetical example, not candidate achievements:
| Agent | CI passes | Criterion coverage | Reviewer interpretation |
|---|---|---|---|
| A | 95/100 | 60% | Could omit difficult important scenarios |
| B | 85/100 | 90% | Could reveal real defects or contain more broken tests |
Neither automatically wins. Classify 15 failures, severity-weight missing criteria, review faulty assumptions and compare defect detection, cost and edit effort. CI failure caused by a real application bug can be useful evidence of a stronger test.
Judges, monitoring and interview response#
Use deterministic checks for syntax, lint, schema, real execution and policy controls. Human domain experts judge business coverage and ambiguous requirements. An LLM judge can triage using a rubric but needs calibration, disagreement review and sampled audits; don't make it sole authority. A concise dashboard should show dataset/config version, denominators, coverage, fault kills, failure classes, flake trend, review effort, cost and policy violations, with links to evidence. No colorful metric display can replace that evidence.
30 seconds: “I evaluate generated tests against approved unseen requirements on a controlled app. I measure compile/execution success separately from criterion coverage, assertion quality and seeded-fault detection. I version the model, tools and instructions, compare repeated paired runs and classify failures before choosing a winner.”
90-second senior answer: prove generated tests are useful
I establish a reviewed dataset with explicit business criteria and expected scenarios, then split development and held-out cases. The harness captures agent configuration, repository/app version, tool permissions, costs and evidence. Deterministic gates check syntax and execution; reviewers map assertions to criteria. In a sandbox I inject valid controlled defects and confirm success tests fail for the intended reason. I compare agent versions on the same cases, use A/A runs to estimate noise and inspect any CI failure for product vs automation cause. High pass rate alone can reward tests that assert nothing useful. I also measure unsupported assumptions, flakiness, review edits and policy compliance. I accept changes when the risk-weighted confidence improvement justifies the cost, with remaining gaps visible.
Memory hook: runs ≠ covers ≠ catches defects.
Quick practice · reveal answers#
How do you evaluate generated tests?
- Versioned reviewed dataset
- compile/run, criterion mapping, assertion strength, fault detection, flakiness, cost and review effort.
Pitfall: CI pass rate alone.
What is a mutation kill?
- A valid controlled defect makes the intended generated test fail for the relevant behavior.
- Exclude equivalent/unexercised mutants with evidence.
Pitfall: Counting unrelated setup crash as meaningful detection.
Agent A passes more but covers less: which wins?
- Classify failures and missing risks, compare detection/review cost under same conditions.
- A failure can expose a real product bug.
Pitfall: Automatically choosing 95 passes over 85.
Can an LLM judge be sole authority?
- No.
- Calibrate a rubric and sample disagreements; deterministic checks prove executable facts and humans assess domain meaning.
Pitfall: The judge shares the generator's blind spots.
Official references and related topics#
Optional online further reading; all core study material is included above.