32
Working with AI and LLM tools
A usage-tier Strategy pairing a correct implementation against an AI-plausible one with a single boundary bug, caught by the same behavior table run against both.
The verify-AI-output discipline, made runnable on a usage-tier billing domain:
- A correct Strategy with spec-exact tier boundaries (inclusive lower bounds).
- An AI-plausible Strategy that looks right but carries one realistic bug: a
<=where the spec wants<at the Starter/Growth boundary. - One behavior table run against both. It passes on the correct
implementation and catches the plausible-wrong one at the boundary value, using
GoogleTest’s
EXPECT_NONFATAL_FAILUREso the wrong implementation is exercised and caught while the suite stays green.
The chapter covers prompting with the forces vocabulary, the failure modes of an unchecked LLM, and the test-and-idiom gate that decides whether a draft ships.
Build, run, observe
./scripts/build.sh cpp23
./scripts/verify.sh cpp23 # 6/6 tests pass
./examples/32-ai-and-llm-tools/demo.sh cpp23
The demo runs both strategies over the tier table and isolates the exact dollar
figure the boundary bug produces, the kind of defect a careless read of
plausible AI output would miss. Builds standalone and under the cpp20 preset
(6 tests).