LLMLL: AI agents fill function bodies; a verifier checks their contracts

LLMLL is a programming language built for AI agents to write. Every function has a contract: a precondition and a postcondition the code must satisfy. An agent fills in the body, and llmll verify hands the body and its contract to an SMT solver. If the body breaks the contract, verification fails, and the error names the branch that fails. If the body uses a construct the solver does not handle, the postcondition is assumed rather than proved and verify names the function. The agent loop in these examples runs with --require-proof, which rejects those bodies too.

Three ways in:

A rejected bug

In 2014, two bugs broke the encryption most of the web relied on. goto-fail reported a TLS handshake as successful on a path where the signature check never ran. Heartbleed copied as many bytes as the peer asked for, without checking that many existed. Both passed review and tests. One is about whether a check executes, the other about whether a length is bounded, and both can be written as contracts.

A goto-fail hole is checked out, a fill that returns Verified on every path is rejected and leaves the program unchanged, the guarded fill is accepted, and the program verifies SAFE

The fills in the recording are scripted stand-ins for agents, so the rejection is reproducible. The demonstration walks through it step by step.

Here is goto-fail’s invariant as a contract: a function may return Verified only when the check passed.

(def-shell finalize [sig: Step payload: int] -> Verdict
  (post (=> (= result Verified) (= sig Continue)))   ;; Verified => the check passed
  (match sig ((Continue) Verified) ((Abort c) (Rejected c))))

That body verifies. Now make the goto-fail mistake: return Verified on every path.

  (match sig ((Continue) Verified) ((Abort c) Verified))
$ llmll verify finalize-bad.llmll
   body-faithful: finalize
   Running liquid-fixpoint ...
error: body verification of 'finalize' failed
       (else-branch does not satisfy postcondition) (constraint #1)

The rejection comes from verify, not from build. llmll build checks types and emits Haskell, and it compiles the bad body without complaint. The proof is a separate pass, and the agent loop in this series runs both. Post 2 walks through this example in full.

Run it

You need Docker and nothing else:

docker run --rm ghcr.io/machunter/llmll verify /opt/llmll/examples/gotofail/finalize-bad.llmll

It prints the error above. Swap finalize-bad for finalize to see the guarded version verify.

What this does not claim

Post 5 states the full scope.

The series

The five posts read in order, but each one stands on its own.

  1. The bugs that looked like correct code What goto-fail and Heartbleed have in common, and why reviews, tests, and type-checkers all slide past it.

  2. A compiler that refuses The smallest working loop: one contract, one agent, and a verifier that rejects the body which skips the check.

  3. Composition, and the bound that wasn’t there What the guarantee does at a call boundary, and why Heartbleed is a precondition nobody discharged.

  4. Can agents invent the helper functions too? Agents splitting a contract into helper functions with contracts of their own, and why a helper contract cannot quietly weaken the one above it.

  5. 163 agent-written functions, verified against their contracts An arithmetic model of the TLS record layer’s control flow and bounds: who wrote what, and exactly where the guarantee stops.

Try to break it

Two kinds of report are useful, and they show different things:

Either way, open an issue.

The code

Every command in the posts runs against the repository.