# Verification engineering > When agents write the code, most of the engineering effort is expected to go into verification: deciding what counts as evidence for each clause, and building the environments that produce it. - Site: CanonBall. The lifecycle agents can run and people can trust. - HTML page: https://canonball.org/guide/verification-engineering/ - This file: https://canonball.org/guide/verification-engineering/agents.txt --- Guide part: Verification and observability. Chapter 20 of 28. Key points: - Verification engineering is the work of building environments in which a promise can be checked, and can be seen to fail. - An environment is engineered like product code and designed with a person, so that someone can explain where each result came from. - Each clause has an assurance case, which splits the clause into parts and argues that the parts are enough. - The weakest thing a part depends on decides how it is verified. ## Where the effort goes An agent produces a change quickly, but nobody can tell from the change alone whether it is right. Establishing that is expected to take more effort than writing it, and the work is called **verification engineering**: deciding, for each clause, what would count as evidence; building the [environments](../environments/agents.txt) that produce it; and keeping the evidence trustworthy as the system changes. ## Engineered, and designed with a person Agents produce most of the evidence, so the process gives them environments that are engineered and designed with a person, because **people can trust evidence only if they understand how it is produced**. An engineered environment is part of the product: it has a design, known limits and defects of its own, and it is reviewed, versioned and repaired like the code it tests. Designing it with a person means that someone can state, for any clause, what was real in the test, what was faked, which failures were tried, and what the environment could never have shown. Agents can generate passing checks in large numbers, and those checks become evidence only when a person can give that account of them. That person is the **verification lead**, who works with the verifier agent at two stations. At [Shape](../shape/agents.txt) they agree the evidence plan before any code exists: what will count as evidence for each clause, and which environment produces it. At [Verify](../verify/agents.txt) they build the environment, the checks and the injected faults. Which of the two drafts the design is [the team's choice](../delegation/agents.txt), but in every team people decide what counts as evidence and review any change that would weaken an environment. ## What a passing suite leaves open A passing test suite establishes that the tests passed. An agent deciding whether its work is finished, and a person deciding whether to accept it, need more, and CanonBall records each answer in a fixed place. | Question | Where the answer is recorded | |---|---| | Which promise is each test evidence for? | Every check names the example it encodes. | | Could this test ever fail? | Every check keeps a run in which it did. | | What did the test assume about the outside world? | Assumptions are listed in the assurance case. | | Which promises have no test at all? | The Verification Record shows them as unsupported. | ## The assurance case: one per clause An **assurance case**, or *case*, connects a clause to its evidence. The idea comes from safety engineering, where a claim about a system is supported by a structured argument as well as by test results. [Figure: An assurance case splits a clause into parts and argues that the parts are enough.] The clause "No robot moves while a person is in its zone" splits into four parts, each with a level and a method: P1 the move gate refuses motion (level 0, model check); P2 a person is detected within 200 ms (level 3, test on the real sensor); P3 stopping distance at rated speed (level 4, brake tests); P4 sensors cover every shared zone (level 3, coverage sweep). An argument joins them: together they cover motion during detection, command latency, braking and coverage. A case splits the clause into **parts** that can each be checked, names as **assumptions** whatever depends on the outside world, gives every part a **method and an environment**, and ends with an **argument** for why the parts, taken together, are enough. The argument is where gaps are usually found. A verified move gate and a fast sensor do not add up to "no robot moves near a person" until braking distance and sensor blind spots are also accounted for, and writing the argument down is how someone notices that they were left out. ## The weakest dependency decides the method How a part is verified follows from one question: what must be true outside the decision logic for the claim to hold? The answer places the part at a **verification level**. | Level | The claim depends on | Method | For software alone | |---|---|---|---| | 0 | Pure logic | Model checking, proof | Decision logic with no side effects | | 1 | Concrete code | Property-based tests | Code run against fakes | | 2 | Components interacting over time | Simulation, scripted scenarios | Real processes and a local database | | 3 | Real devices, drivers, latency | Tests on real hardware | Real infrastructure, a staging system | | 4 | Physics, materials, people | Measurement, field data | Production traffic | The levels resemble the test pyramid, except that the pyramid sorts tests by size and the levels sort claims by what they depend on. A level is not a measure of confidence: a narrow proof about an abstract controller can leave a larger gap than a well-designed physical test. [Figure: As an environment becomes more realistic, you control less of it.] Five verification levels from 0 (pure logic) to 4 (physics and people). Realism rises from level 0 to level 4. Control falls over the same range: at level 0 and 1 you can freeze time and hold a race open; at level 3 and 4 you can only observe. Control over an environment falls as its realism rises. At level 1 a test can freeze time and hold a race condition open; on real infrastructure it can only wait for the race. Timing faults are therefore best caught at the low levels and only observed at the high ones. ## Tiers: how much rigor A full case for every clause would cost more than most clauses justify. Safety standards scale rigor to criticality, and CanonBall does the same. | Tier | Which clauses | The case | A person reads the argument | |---|---|---|---| | 0 | Most. Logic with no side effects | One part, generated | No | | 1 | Some. Clauses that cross a side effect | A few parts and a short argument | No | | 2 | Safety, money, irreversible actions | A full argument, assumptions with treatments | Yes | In the refunds service, INV-004 (a refund is never issued twice for the same order) concerns money, so it is tier 2. Its case names one assumption, ASM-011 (the payment gateway pays at most once per request key), and the verification lead reads its argument. ## The procedure for one clause 1. **Split** the clause into logic, assumptions and measured outcomes. 2. **Argue** why those parts establish the clause as deployed. 3. **Place** each part by its weakest dependency and choose the method. 4. **Treat** each assumption: how it is watched, how fast a failure shows, and what happens then. 5. **Decide** whether the evidence is enough, against the policy. 6. **Move the boundary.** If a part will not verify because the logic lives in the wrong place, move the logic. If it depends on the world, make that an assumption and give it a treatment. The sixth step can be misused: moving logic to where it can be checked is progress, whereas relabeling a hard problem as an assumption hides it. The Record keeps the two apart by showing every assumption as an assumption. ## What a proof does not give you A proof shows that the logic satisfies a property for every input. It leaves four questions open: whether the property is the right one, whether the world behaves as assumed, whether the parts are enough, and whether the code matches the model that was proved. Examples, treatments, the argument, and checks against recorded behavior address those four in turn, and the Record shows "proven" only together with its property, model, bounds and assumptions. ## What a case depends on Every case lists the code its clause depends on. When that code changes, the clause shows as *unknown* until the case is checked again, by the mechanism described under [evidence](../evidence/agents.txt). Explaining a failed check also requires seeing inside the running system, the subject of [observability](../observability/agents.txt). --- ## References - Previous chapter: Handing over decisions: https://canonball.org/guide/delegation/agents.txt - Next chapter: Verification environments: https://canonball.org/guide/environments/agents.txt - Related: Verification environments: https://canonball.org/guide/environments/agents.txt - Related: Evidence and the Verification Record: https://canonball.org/guide/evidence/agents.txt - Related: Observability: letting agents see: https://canonball.org/guide/observability/agents.txt - Related: Shape: settle what the milestone promises: https://canonball.org/guide/shape/agents.txt - Related: Verify: prove it in an engineered environment: https://canonball.org/guide/verify/agents.txt - Glossary: https://canonball.org/glossary/agents.txt - Site overview and index of every chapter: https://canonball.org/agents.txt