Evidence for AI-Written Code
An AI assistant can write the next version of a controller in seconds. Whether that version still holds the set point, reacts within its deadline, or never drives a valve on a broken sensor isn't in the diff. It shows only in the behavior over time. This guide describes a workflow where the assistant writes and runs the code, and CppModel gives both of you the evidence to judge it.
It assumes a coding agent connected to the CppModel MCP server, ideally with the CppModel plugin. The tutorials show each step on real code.
1. Write down what correct means
Start from the requirements, not from the code. Give each one an ID, and say it in measurable terms: a deadline, a band, a limit, an allowed sequence.
GD-2: An obstruction while closing sends the door back up within 1 s.
Then have the assistant turn them into verification rules:
Turn the requirements in
docs/requirements.mdinto verification rules for the GarageDoor simulation, and prove each rule can fail.
The verification skill writes one rule per requirement, records the requirement IDs, and shows that each rule fails on a run that breaks it. A rule that can't fail proves nothing.
Keep the rules apart from the code under test. They belong to the simulation, and they state the requirement from the signals, not from the controller's internal state, so a bug in the controller can't hide its own failure. In the Excavator Boom Control tutorial, the simulation works out "bad signal" from the joystick voltage itself, not from the controller's fault flag.
2. Let the assistant write the code
Ask for the change in terms of behavior:
The boom must stop as soon as the joystick signal is bad, without waiting for the fault delay. Change
BoomControl.c, run the simulation, and tell me which rules pass.
The assistant edits the code, builds it, and runs the simulation signed in as your account. Every run is recorded in your workspace with the build fingerprint and the git commit it came from (with -dirty for uncommitted changes), so a result can always be traced to the code that produced it.
3. Review the evidence, not just the diff
Read the diff, and then look at what the code did:
- The verdicts. Each rule passes or fails, and gives a margin in physical units: how close a passing run came to failing. A margin of 0 is a pass with nothing to spare, as in the Garage Door Controller tutorial.
- The graph. The workspace draws each rule on the signal it checks: the allowed band, the deadline, and the signal in red where it failed. One look shows whether a failure is a near miss or a real fault.
- What changed. Compare the run with the one before the change: which parameters changed, whether the code changed, and which signals appeared or disappeared.
Ask the assistant the same questions, and check its answers against the workspace links it gives:
Why did the last GarageDoor run fail? Show me the chart with the mode sequence rule.
What changed between the last two BoomControl runs, and did any margin get smaller?
The assistant reads the same recorded runs and draws the same charts you see, so its explanation and your review are about the same evidence.
4. Explore before you decide
When there is more than one way to meet the requirements, try them without rebuilding. Parameters and input profiles come from files (--inputs), so one build runs every variant:
Sweep IntegralTime from 200 to 1200 s with anti-windup on, and show where the settle rule starts to fail.
Every variant is a recorded run, so you can compare them on one chart, as the Temperature Control tutorial does.
5. Lock it in with CI
Run the same simulations in CI on every change (the ci-pipeline skill sets this up). Each simulation exits with 1 when a step or rule fails, so a behavior regression fails the build like any other test. Each run also writes the requirements it verified to cppmodel-requirements.json, which a CI job can collect into a requirement coverage report.
A run from a developer's machine and a CI run of the same commit are told apart by their build fingerprint and git hash. Ask:
Which simulations haven't been run from a clean commit yet?
What the evidence doesn't tell you
- A rule checks only what it states. Review the rules as carefully as the code, and more carefully when the assistant wrote them. When a change makes a rule pass by loosening it, that is a change of requirement, not a fix.
- A plant model is a simplification. It answers the questions it was built for. When the simulation and the machine disagree, the model needs data from the machine (the
experiment-designandexperiment-reconcileskills help with that). - Some things only the machine and its operator show. How a movement feels, what happens under real load, what nobody thought to write down. The simulation makes the time on the machine count; it doesn't replace it.
The point isn't to trust the assistant, or the simulation, blindly. It is to make every change cheap to check, so you can check every change.