← Back to the blog

Blog

Formal Verification for Agent-Written Code

Formally verifying agent-written code could make large AI-generated changes easier to review at scale. Microsoft Research presented PDD Kit on November 5. The tool turns agreed requirements into formal specifications, has agents generate the corresponding proofs, and relies on tests where proofs cannot reach.

From a plan to a checkable contract

A plan in agentic development is usually nothing more than a statement of intent. An agent can drift away from it and end up writing tests that confirm its own implementation rather than the original requirement.

PDD Kit steps in earlier. The team clarifies ambiguous requirements in plain language and approves an intent artifact. These become specifications for Verus, a system for verifying Rust code. The verifier then checks whether the code satisfies the specified properties for every modelled input.

Microsoft demonstrates the approach using the login logic of a Rust web application with roughly 5,000 lines of code. Among the verified properties are the conditions for issuing tokens and administrator roles. According to Microsoft, the process uncovered existing bugs, and the developer reviewed the intent and trust boundaries instead of every generated line of code.

A proof only covers its specification

Formal verification gives stronger assurance than a passing test, but it has its limits. It proves only the properties that were actually specified. External libraries, database queries, clocks, token signing, or user interfaces may fall outside the visible proof boundary.

PDD Kit makes this Trusted Computing Base explicit. Someone has to decide whether to accept every assumed contract. Tests add evidence for components the verifier cannot inspect. Runtime behaviour, usability, and requirements nobody wrote down also remain outside the proof.

What enterprises should take from this

Do not start with the entire system. Pick properties whose violation would cause substantial damage: authorization rules, approval boundaries, transaction limits, role changes, or invariant booking rules.

Then define four artifacts:

  • a specification approved by the responsible business owner
  • the code scope that the formal proof covers
  • the accepted trust boundary and who owns it
  • tests and runtime controls for everything outside the proof

This fits the NIST Secure Software Development Framework: requirements, verification evidence, and protective controls belong in a repeatable development process. For regulated companies, the metric that matters is therefore not the number of generated proofs, but how well they can be traced back to a business decision.

The new review question is no longer just whether agent-written code looks plausible. It is which guaranteed property is proved, which component is merely trusted, and who approved that boundary.

← Back to the blog