liveBook · Manning

Chapter 8: Evaluation is king: how to trust code you didn’t write

What you will learn in chapter 8 of Vibe Engineering

The introduction explains why AI-generated code creates a distinct trust problem and calls for confidence based on verified properties rather than an AI’s assurance.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction explains why AI-generated code creates a distinct trust problem and calls for confidence based on verified properties rather than an AI’s assurance.

Key terms: legacy code, code coverage, trust deficit, author's intent, mental model, code review, verified properties, confidence level, use case

8.1 Evaluation matters more than generation

This section shifts attention from how quickly AI generates code to whether the generated code can be trusted in real use.

Key terms: generation, evaluation

8.1.1 Code is now produced faster than confidence

AI accelerates code generation without increasing thoughtful review capacity, creating a trust deficit that cannot be solved by rushing review or blindly trusting the AI.

Key terms: engineering trust, generation, evaluation, trust deficit, adequate verification, production incident queue

8.1.2 Scale of generation creates scale of potential debt

The section explains how AI-generated code can multiply hidden trust debt because its polished appearance makes mistakes harder to spot as code volume grows.

Key terms: trust debt, cognitive debt, plausible-looking code, invariants, verified logic, scale of generation

8.1.3 "Works for me" means nothing now

The section explains why a few successful checks provide much less confidence in AI-generated code than “works on my machine” once did.

Key terms: works on my machine, works for me, AI-generated code, mental model, inductive power, counterexample

8.1.4 How the community measures "good AI code" (and why it's misleading)

This section explains why coding benchmark scores can show progress on narrow tasks without establishing that AI-generated code is trustworthy in production.

Key terms: HumanEval, EvalPlus, codebase context, SWE-bench, solution leakage, inadequate test cases, clear test, collaborative

8.1.5 The benchmark-reality gap

Explains why strong coding benchmark scores do not establish that code is ready for production, and why evaluation must bridge that gap.

Key terms: HumanEval, MBPP, SWE-bench, domain, adversarial input, maintain, benchmark-reality gap, production readiness, evaluation, clear boundaries

8.1.6 Where evaluation actually lives

This section explains how code gains trust through successive evaluation gates and why AI-generated code requires gates that verify properties rather than rely on an author's judgment.

Key terms: evaluation pipeline, gates, local development, pull request review, CI pipeline, staging environment, lowest cost, user impact, AI-generated code, human failure modes

8.2 Always-on verification

Introduces a deceptively plausible AI-generated markup parser and explains why cheap, always-on verification gates are a necessary baseline, though not proof of correctness.

Key terms: lightweight markup language, happy path, nested formatting, always-on verification, gates, baseline

8.2.1 Compilation and type checking: a signal, not proof

Compilation and type checking catch structural errors, but type-correct AI-generated code can still be logically wrong.

Key terms: dynamic typing, TypeScript, type checking, verification baseline, string -> string, correctness, pesticide paradox, AI-generated code, logically wrong

8.2.2 Static analysis: linters, rule engines, and SAST

The section shows how static analysis can quickly flag risky code patterns in an AI-generated parser, while explaining why it cannot establish that the parser behaves correctly.

Key terms: static analysis, linters, rule engines, code smells, ReDoS, nested quantifier, backtracking, eslint-plugin-security, Static Application Security Testing, SAST

8.2.3 AI code review: rules, checklists, and heuristics

AI code review can catch useful issues, but it works best as a targeted check alongside independent tools and human judgment.

Key terms: AI code review, requirements, architectural conventions, LLM evaluators, perplexity, LLM-as-a-Judge, correlated failures, explicit checklists, targeted prompts, non-LLM analytic checker

8.2.4 Dependency, license, and security scanning

This section explains why AI-selected dependencies need verification, which checks to apply, and what dependency scanning cannot establish.

Key terms: dependency, hallucinated package names, Slopsquatting, vulnerability scanning, license scanning, supply chain verification, dependency necessity review, hallucination check, dependency scanning, all-green dependency scans

8.2.5 Diff-based sanity checks: what actually changed?

This section shows how to check whether an AI-generated change matches the requested size, scope, and behavior, while recognizing the limits of diff checks.

Key terms: diff-based analysis, size reasonableness, scope containment, scope creep, semantic diff analysis, function signatures, public interfaces, API contract, blast radius, baseline expectations

8.2.6 The limits of always-on gates

The section explains why always-on checks provide useful structural confidence but cannot establish that AI-generated code behaves correctly.

Key terms: always-on gates, static verification, type checking, tests

8.3 Tests as contracts, not as coverage

This section reframes tests for AI-generated code as inspectable definitions of correct behavior, rather than checks that code merely passes.

Key terms: tests as specification, tests as verification, intent, high coverage, tests that pass

8.3.1 Manual testing: still necessary, but different

Manual testing remains useful for AI-generated code as brief reconnaissance that reveals unexpected behavior and guides subsequent automated tests.

Key terms: manual testing, automated test, human pattern recognition, reconnaissance, happy path, boundaries, automated testing

8.3.2 Unit tests: the foundation that can betray you

This section shows why passing unit tests can give false confidence in AI-generated code, using a parser bug to expose shared human and AI blind spots.

Key terms: parser, unit tests, nested formatting, malformed, edge cases, false sense of verification, AI-generated code

8.3.3 TDD with AI and test-driven prompting

Shows how to give an AI executable tests as a coding specification, then verify its output while recognizing that the tests cover only cases the developer anticipated.

Key terms: Test-Driven Prompting, executable specifications, edge cases, Test-Driven Development, specification-driven generation, nested formatting, manual exploration

8.3.4 Code coverage: why AI can game it

The section explains why high code coverage can give false confidence in AI-generated code and tests.

Key terms: code coverage, lines, branches, or paths, correct behavior, tests and implementation are correlated, blind spots, adversarially

8.3.5 Snapshot and golden testing: where they help and where they rot

This section explains how snapshot tests detect changed output, why they cannot establish that the original output was correct, and why AI-generated code amplifies that risk.

Key terms: snapshot testing, golden files, regression detection, golden standard, primary verification, regression, timing, volume, first snapshot

8.3.6 Approval testing and visual regression

This section explains how human-approved baselines verify outputs and UI changes, why visual stability is not the same as quality, and where review costs limit these methods.

Key terms: approval testing, golden file, golden standards, visual regression testing, visual diffs, baseline, visual regression, reference-based evaluation, generate-evaluate-revise, regression baseline

8.3.7 Key shift: tests describe intent, not implementation

This section reframes tests for AI-generated code as statements of intended behavior, while explaining why passing tests cannot establish correctness beyond the cases tested.

Key terms: tests as contracts, specifications, intent, implementation, unit tests, coverage, specific cases

8.4 Tests that break AI-generated code

The section explains why example-based unit tests share a developer’s blind spots and introduces adversarial verification as a way to find unexpected failures in AI-generated code.

Key terms: unit tests, example-based testing, blind spots, adversarial verification, properties, randomness, systematic exploration

8.4.1 Property-based testing: from examples to universals

The section explains how property-based testing checks universal claims about a parser, why the choice of property matters, and what random input generation can miss.

Key terms: property-based testing, properties, Hypothesis, deterministic, plain text, well-formed HTML, should not crash, markup characters, counterexample, random generators

8.4.2 Invariants, metamorphic relations, and conservation laws

The section explains three kinds of properties for testing a markup parser and shows how failed property tests can reveal either code defects or missing specifications.

Key terms: invariants, unbalanced tags, metamorphic relations, concatenation, multi-line bold, conservation laws, markdown link, HTML link, property-based testing, specification

8.4.3 Fuzzing: when random isn't random enough

The section explains how feedback-guided and LLM-guided fuzzing find hard-to-reach bugs, and when their cost is justified.

Key terms: coverage-guided fuzzing, instrumenting, branches, mutates inputs, LLM-guided fuzzing, plausible-but-tricky inputs, failure-inducing inputs, instrumentation, harness, untrusted input

8.4.4 Mutation testing: testing your tests

The section explains how mutation testing checks whether tests detect meaningful bugs, why conventional mutations can miss AI-generated faults, and what the technique costs.

Key terms: mutation testing, mutation, survived, killed, mutation score, coverage, competent programmer hypothesis, syntactic mutants, semantic mutation, LLM-powered mutation testing

8.4.5 Differential testing: multiple versions, one truth

This section explains how comparing independent implementations on the same inputs can expose bugs without a known correct answer for every test case.

Key terms: differential testing, independent implementations, random inputs, disagreement, different models, different prompts, consensus, shared blind spots, human judgment

8.4.6 New mindset: adversarial verification

The section explains why AI-generated code calls for adversarial verification and where unit-level checks leave a gap.

Key terms: adversarial mindset, AI-generated code, implicit verification, individual functions or components, system-level contracts, end-to-end behavior

8.5 System-level and contract testing

The section explains why verifying a component in isolation is not enough: its connections and assumptions can fail even when the component itself is correct.

Key terms: system-level verification, contract, system assumptions

8.5.1 Design by contract: making assumptions explicit

The section explains how explicit, executable contracts make the assumptions and guarantees of AI-generated functions visible and catch boundary failures early.

Key terms: Design by Contract, preconditions, postconditions, invariants, require decorators, ensure decorators, unstated assumptions, runtime overhead

8.5.2 Contract testing: AI and API stability

The section explains how consumer-owned contract tests catch AI-generated API changes that would break another service’s expectations.

Key terms: Contract Testing, consumer, provider, Design by Contract, API contract, breaking changes, contract test, Pact-style workflow, consumer's repository, contract broker

8.5.3 Integration and end-to-end tests

Integration and end-to-end tests check that a complete content workflow works for users, even when AI changes its internal implementation.

Key terms: unit tests, contract tests, integration tests, E2E tests, outcomes, implementations, observable behavior, refactoring

8.5.4 Self-healing tests: real value vs. marketing

This section distinguishes useful self-healing of fragile tests from dangerous automatic adaptation to changed application behavior.

Key terms: self-healing tests, test fragility, locators, intentional change, regressions, business logic verification

8.5.5 Testing what the AI didn't know it changed

This section shows how to detect unintended behavior changes in AI-generated code through characterization testing and targeted impact analysis.

Key terms: unknown unknowns, collateral damage, Chesterton's fence, characterization testing, corpus, explicitly allowed patterns, impact analysis, diff, call graph, blast radius

8.6 Formalism and proofs (the high-cost zone)

Introduces formal verification as a costly way to establish that code satisfies a specification, while stressing that even a proof cannot establish that the specification captures the intended behavior.

Key terms: testing, sampling, formal methods, formal proof, specification, spec, formal verification

8.6.1 Much more strong(er) type systems

This subsection shows how stronger type systems can turn correctness constraints for AI-generated code into compile-time guarantees.

Key terms: refinement types, compile-time proofs, strong type systems, dependent types, type-level constraint

8.6.2 SMT solvers: automated theorem proving

The section explains how SAT and SMT solvers can verify code properties by searching for satisfying inputs, and why complex code limits their practicality.

Key terms: SAT, SMT, logical constraints, unsat, SMT solvers, logical formulas, Z3, CVC5, scalability

8.6.3 LLM + symbolic execution: the emerging hybrid

The section explains how LLMs can guide symbolic execution toward promising code paths while formal analysis supplies rigor, though the hybrid remains research-grade.

Key terms: symbolic execution, symbolic values, constraints, path explosion, LLM-guided symbolic execution, LLM-Sym, formal methods, research-grade tooling

8.6.4 Formal verification with AI assistance

This section explains how formal verification works, why its specification burden limits adoption, and how AI can help without replacing human judgment or mathematical verification.

Key terms: formal verification, formal specification, TLA+, Dafny, preconditions, postconditions, annotation burden, loop invariants, intermediate assertions, specifications

8.6.5 When to consider such a level of evaluation

This section explains when formal methods are worth their cost and why they can complement AI-generated code.

Key terms: formal methods, property-based testing, mutation testing, contract testing, formal verification, AI plus formal methods, rigorous verification, LLM-generated code

8.7 Runtime verification and production

The section explains why pre-deployment tests cannot anticipate every real-world behavior and why deliberate production-time verification is necessary.

Key terms: testing operates on models, production, runtime verification, detect, contain, and learn

8.7.1 Regression testing as CI for every AI change

The section explains why every AI-generated change should pass regression tests in CI and how to choose the scope of those tests.

Key terms: blast radius, regression testing, CI/CD pipelines, component and dependency, entire test suite, targeted test selection, CI times

8.7.2 Observability as evaluation: logging, tracing, and metrics

The section shows how production logs, traces, and metrics evaluate AI-generated code against real usage and expose cases that pre-production tests missed.

Key terms: logging, property test corpus, tracing, flow of requests, metrics, p50, p95, p99, error rate, observability

8.7.3 Canary deployments and progressive rollout

The section explains why generated code needs more cautious production rollouts and how A/B testing answers a different question from correctness checks.

Key terms: canary deployments, progressive rollout, feature flags, staging environment, ramp, A/B testing, generated parser, hand-written one, production

8.7.4 Chaos engineering: testing resilience

The section explains how deliberately introduced failures reveal whether AI-generated code fails safely under adverse conditions.

Key terms: chaos engineering, fail safely, degrade gracefully, resource exhaustion, happy-path

8.7.5 Non-functional testing: performance, security, accessibility, compatibility

The section explains why code that passes functional tests still needs performance, security, accessibility, and compatibility testing.

Key terms: functional tests, non-functional tests, performance testing, security testing, accessibility testing, compatibility testing

8.8 Choosing evaluation methods

This section frames evaluation as choosing among verification techniques rather than applying every technique to every project.

Key terms: verification, always-on gates, runtime observability

8.8.1 What determines "sufficient confidence"?

The section explains that sufficient confidence in code depends on the consequences of failure and the effort justified to reduce that risk.

Key terms: sufficient confidence, property-based tests, integration tests, security testing, fuzzing, XSS attacks

8.8.2 System criticality vs. evaluation cost

The section explains how to spend verification effort according to the cost of bugs, while keeping inexpensive checks as a baseline for all code.

Key terms: system criticality, verification investment, risk management, always-on gates, adversarial verification, system-level verification, formal methods, runtime verification

8.8.3 When to test more vs. when to regenerate

This section explains when regenerating AI-generated code is more sensible than debugging it, and when existing test evidence should guide the decision instead.

Key terms: debugging, regeneration, mental model, debug, regenerate, prompt, tests are evidence

8.8.4 Minimum viable testing for AI-first teams

The section lays out a minimum viable verification stack for teams that generate significant code with AI, organized by when checks should run.

Key terms: minimum viable verification stack, Always on, Before merge, Regularly, Before major releases

8.8.5 Evaluation as competence, not checklist

The section argues that verifying AI-generated code requires human judgment beyond completing a testing checklist.

Key terms: checklist, verification, judgment, evaluation competence, mental model, coverage numbers, false confidence

8.8.6 Revenge of the QA

This section argues that as AI automates code generation, software engineering increasingly centers on QA-style evaluation and the ability to establish trust in code.

Key terms: QA, evaluation, adversarial thinking, failure mode analysis, trust engineer, happy paths, failure paths, build confidence

8.9 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 7: Vibe performance engineering: when assumptions mislead Chapter 9: Economics of vibe engineering: cost optimization at scale →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.