R467 · AI-built software and its verification › Formal methods for AI-written code

Optimize for human verification: a contract-and-proof language built on the assumption that agents write the code

Read the original

formal-verificationcoding-agentsopen-sourceverificationagent-harnessclaim-checking

Truss, as described in its repository rather than its announcement: what it proves, what its proof economics buy, the numeric ceiling on its logic, and an unusually honest published trust boundary.

The premise

The starting observation is the one worth taking seriously: review did not get faster when agents started writing the code. Generation became elastic; verification did not. Most responses to that have been process — more gates, more reviewers, more scanning. This is a response at the language level.

The repository states the inversion directly: traditional languages "were designed for the ergonomics of human authors, effectively optimizing for the convenience of writing code," whereas this one "assumes code is no longer written by hand, but instead written by AI agents." Three design axes flip as a result — optimize for human verification rather than human editing, for correctness rather than convenience, and spend tokens at authoring time to buy enduring correctness rather than minimizing authoring time.

The positioning against Rust is the clearest way to see the bet: Rust is "a small step in this direction, providing compile-time memory safety — making Rust code a bit harder to write for humans, but a fantastic language target for AI." The move here is to extend that trade well past memory management into behavioural contracts. If the human is no longer typing, ergonomics stop being a constraint, and verification difficulty becomes the thing worth minimizing.

The author is explicit that it is a prototype intended to start an argument about what platforms agent-written software needs, and equally explicit about the ambition behind it — that most pre-AI software will eventually be rewritten because it is "imperfect, insecure, and slow," and that agents could produce provably correct software at a scale humans could not.

The mechanism: contract, provider, proof

The atomic unit of a package is a contract: data structures and functions together with formally verified behaviours — what they return, what memory they may access, what state they may change. Providers implement contracts; a Map contract can have an inline and a sorted provider. Each provider must provably satisfy every claim in its contract and ships the evidence as a package.proof file beside the implementation source.

A contract looks like this — the repository's own worked example, replacing one element of a slice and returning the overwritten value:

contract ReplaceElement {
    function replace(words: &mutable Slice<UInt64>, index: UInt64, value: UInt64) -> UInt64
        requires index < words.len
        ensures result == old(words[index])
            and snapshot(words) == update(old(snapshot(words)), index, value)
        terminates
        effects { read(words), write(words) }
}

Four clause kinds carry the whole specification: requires for the caller's obligation, ensures for the postcondition over old(), snapshot() and update(), terminates as a separate obligation, and an explicit effects frame naming exactly what is read and written. The implementation is then three ordinary lines, and truss proof update emits the conformance evidence. A consumer declares the contract dependency and binds it to a named provider at a pinned version.

Two things to notice about that clause set. The effect frame is mandatory and explicit, which makes "what can this touch" a checked property rather than a review question — the single most useful thing to know about code you did not write. And termination is separated from correctness, so a proof of behaviour does not quietly assume the function returns.

The proof economics, which is the actual contribution

The design insight is not that contracts can be proved. It is where the cost lands.

When a program uses a contract, the compiler reasons from the contract's claims and never re-verifies each provider. When a program binds a provider, the compiler validates the shipped evidence instead of reconstructing the proof — and that validation "can be an order of magnitude faster than constructing the proof itself." Verification therefore scales by pushing the expensive half onto package authors: publishing a package costs roughly as many tokens for proofs as for code, and every dependent gets the guarantee for the price of a replay.

This is the same shape as a build cache or a signed attestation, applied to proof obligations, and it is why the approach is plausible at all for large codebases. It also makes the package registry the trust boundary: you are replaying someone else's certificate against their contract. The repository is careful here — importing published package evidence "uses strict replay regardless of local cache contents," so a local cache cannot be used to wave through evidence that does not check.

The chain is stated end to end: a provider proves it implements the contract, the compiler proves its translation preserves the body's observable behaviour, and a separate-compilation rule proves the guarantee survives linking against conforming implementations.

One gap: "an order of magnitude" is the only quantification offered. No proof-construction time, replay time, or token figure for generating the standard library's proofs is published, despite the token-cost claim being central to the argument.

The ceiling nobody will read off the announcement

This is the part that matters most for judging what "provably correct" means here, and it is all in the compiler documentation rather than the README.

The logic is affine integer arithmetic with Farkas-style refutation. An affine row denotes c + Σ(aᵢxᵢ) ≥ 0 over the integers; replay starts from the approved premises plus the integer complement of the goal (−goal − 1 ≥ 0), every derived row is a positive weighted sum of earlier rows, normalization divides by the GCD of the coefficients and floors the constant, and a final negative constant row contradicts the premises. Intermediate signed 128-bit operations are checked and overflow is rejected.

And the budgets are published as hard numbers: a judgment is limited to 32 parameters, 512 terms and depth 16; a derivation to 128 steps; an inference using substitution gets a separate 4,096 substitution steps. Receipt chunks cap at 4 MiB, 32,768 certificates and 1,048,576 total steps, with entries in strict digest order and readers that reject truncation, duplicates, unordered keys and trailing bytes.

That is a small, decidable, cheap fragment — and it is well matched to what the standard library actually proves. Look at the eight advertised examples and the pattern is unmistakable: index bounds, byte counts, prefix and suffix preservation, ordering, framing boundaries, and idempotence across arbitrary chunk splits. A streaming digest contract proves "the digest covers exactly the bytes accepted, in order, however you split them across calls" — a statement about accounting, not about cryptographic strength. A ZIP extraction contract proves that on mid-way failure "the reported file and byte counts cover exactly the prefix whose publication was confirmed." A socket-readiness contract proves that a delayed event for a closed connection cannot be accepted for a new connection reusing the slot — a genuine use-after-free class bug, caught in the type and proof system rather than in review.

Those are excellent properties and they are the ones that actually bite in systems code. They are not "this program is correct." Nonlinear arithmetic, cryptographic correctness proper, and anything needing rich quantifier reasoning sit outside the fragment. The repository never claims otherwise; a reader going by the headline will overestimate it.

The trust boundary, published properly

There are two compilers — a Rust bootstrap (C0) and a self-hosted compiler written in the language itself — and the installer chains them: C0 builds C1, C1 builds C2, the installer checks C2 reports C0's version, strictly replays the compiler package with C2, has C2 emit C3, and compares C2 and C3 byte for byte.

What follows is the most useful paragraph in the repository, and it is a disclaimer: matching C2 and C3 "establishes a fixed point for those inputs," while compiler correctness "also requires relating the typed program to the source and the emitted instructions to the typed program." Independent Rust checks inspect selected linked operations; Lean audits cover named compiler and checker rules. And then, plainly: "Trust in the host and uncovered lowering remains a premise of running the image."

The source-proof scope carries the same honesty: the argument "starts from the approved typed representation and relies on faithful parsing, typing and extraction." A linked check adds correspondence for a specific image, function or call closure, under its ABI, storage and host premises.

So the trusted computing base is: the parser, the type checker, the extraction into the proof calculus, the host, and any lowering not covered by a linked check. Lean sits at the level of the rules — auditing proof rules and replay, selected lowering and runtime primitives, and the hash and byte-order operations behind toolchain identities — not at the level of each user program. Named theorems cover the receipt decoders and the affine replay soundness, with one audit checked against actual ARM64 instructions.

This is how a verification claim should be published. It is also a large TCB, and the correct reading is "here is exactly what you are trusting," not "there is nothing left to trust."

What the post-hype read should be

Three things are genuinely notable.

The standard library is not a toy. Collections, arenas, UTF-8 and Unicode normalization and regular expressions, typed JSON and CSV, Base64, varints, exact decimals, Adler-32 and CRC-32/32C, ustar and PAX and ZIP64 with deterministic multi-entry writing, raw DEFLATE and gzip and zlib, streaming multipart MIME, TCP/UDP/Unix/TLS, DNS, URL handling, HTTP/1.x dispatch and HTTP/2 framing with flow control and HPACK, clocks and deadlines and cancellation and process workers, structured logging, SHA-256 and HMAC and PBKDF2, and shared SQL over file-backed SQLite and TLS-protected PostgreSQL with SCRAM. For a one-week personal project that is a startling amount of surface, and it is the strongest evidence for the thesis: if agents write the code, a language can afford a standard library this wide, this early, with contracts on it.

The target reality is narrow. The language manual's examples target arm64 macOS. Concurrency primitives cover arm64 macOS plus static arm64 and amd64 Linux. The HTTP client example binds macOS TLS and system DNS; the Linux HTTPS and PostgreSQL path uses a bundled Rustls. Database and crypto availability is stated per target. Portability is per-provider and partial by design.

The unverified artifact moved, it did not disappear. A proof establishes that an implementation meets its contract for every admitted input. It says nothing about whether the contract says the right thing. That was always true of contract-based verification; what is new is that the contract is now also written with agent assistance, so the one artifact a human must actually read is the one the human is most likely to skim. The whole bet is that contracts are small and reviewable enough for that to work — and the ensures clause in the repository's own three-line example is already dense. Nothing here measures whether reviewers catch a wrong contract, which is the experiment the thesis most needs.

Review checklist

Connections

See R467 on the knowledge map

Part of the Research notes on nowucca.com. Figures and claims are the source's own unless the summary says otherwise.