---
title: "The Spec the Agent Does Not Write"
url: https://raskell.io/articles/the-spec-the-agent-does-not-write/
author: Raffael Schneider
date: 2026-12-02
description: "Two lunches with the founders of mynatix, a Basel compiler startup, on why compilers matter again when agents write the code: for speed, and for proof."
tags: [formal-methods, lean, compilers, bhc, ai-engineering, context-engineering, basel]
---

# The Spec the Agent Does Not Write

On 10 June I gave a short talk at [IT's ABOUT TECH #13](https://raskell.io/talks/iat-13-basel/) in the Aula of the FHNW in Basel, about how I stopped writing most of my code. One slide lists the projects I work on in the evenings, and one of them is the [Basel Haskell Compiler](https://arcanist.sh/bhc/). At the apero afterwards, Andres Gartmann came over to one of the standing tables, and of everything I had mentioned, the compiler was what he wanted to talk about.

Andres builds compilers too, with a company of his own, [mynatix](https://mynatix.com/), a few steps from my office on Aeschenplatz, under Jonathan Borofsky's *Hammering Man*. Since then we have had lunch twice. The first time he told me about his compiler. Yesterday, in his office, with his co-founder Christian C. Moesch and Salah Eddine Al Khiati, a research intern from EPFL, he showed me something new. Both conversations were about the same question, from two sides: what is a compiler for, now that a growing share of the code it compiles was not written by a person?

## Why compilers matter again

For most of my career, the compiler was the boring part. You chose a language for its ecosystem, its hiring pool and how pleasant it was to write, and the compiler came with it. Agents change that ordering. When a model writes most of the code, how pleasant a language is to write stops mattering much, which was the argument of [Almost Irrelevant](https://raskell.io/articles/almost-irrelevant/). What gains weight is what happens to the code after it was written: what is checked, what is guaranteed, and how well it runs.

I put the first half of that in the [arcanist.sh manifesto](https://arcanist.sh/manifesto/) this year: *"Plausible code is cheap, and plausible code is often wrong."* And, a few lines later, the sentence the whole project rests on: *"The generator does not need to be trusted. The artifact needs to be checkable."* In Haskell a well-typed function is a small proof, and the compiler is the proof checker, so every class of mistake the compiler can rule out is one that never reaches a reviewer, let alone production. That is why I bet on Haskell in [The Last Programming Language Might Not Be for Humans](https://raskell.io/articles/what-programming-languages-become-when-ai-writes-the-code/), and why [The Proof You Only Have to Write Once](https://raskell.io/articles/the-proof-you-only-have-to-write-once/) argues that once generation is cheap, verification is the expensive step, and repeating it is the waste.

A small example shows both the power and the limit of that. Here are two signatures for taking the first element of a list:

```haskell
-- well-typed, and still wrong: it crashes on the empty list
head :: [a] -> a

-- the type now says what the caller must provide, and the compiler checks it
head :: NonEmpty a -> a
```

With the second, an agent cannot write code that takes the head of an empty list: the program does not compile until it has shown, in the types, that the list has an element. A whole class of crash is gone, and nobody had to review for it. A type does not say everything, though. `sort :: Ord a => [a] -> [a]` is satisfied by a function that returns the empty list for every input. The type knows the shape of the answer, not whether it is sorted or contains the same elements. Haskell's types rule out more than most languages', and they still stop well short of what the code is for. Everything beyond that point is left to tests, which, when an agent writes them, check what the agent believed.

That is the correctness side. Andres came at it from the other one.

## The first lunch: making compiled code run in parallel

Most of the code we write still runs on one core while the others wait. Compilers are very good at optimising a program for a single core and still poor at splitting it across many, and automatic parallelisation is one of the oldest unkept promises of the field. mynatix's technology, LAYCOS, short for "Latency-Optimized Code Segmentation", goes after it: it breaks a program into the smallest units that can be computed fastest and distributes them across the hardware, as their [technology page](https://mynatix.com/technology/) describes it. Its unusual move is to use a kind of dependency that compilers normally ignore, read-after-read, two parts of a program reading the same data, and to use it to decide how fine the tasks should be. The work was presented at PASC24 as [*Using Read-After-Read Dependencies to Control Task-Granularity*](https://dl.acm.org/doi/10.1145/3659914.3659921), and mynatix argues the same analysis applies from compilers and operating system kernels to high-level synthesis, chip design and quantum computers. They have filed patents across those areas, one of them granted so far, and ran a pre-study with Innosuisse in 2022.

It helps to see why that dependency is unusual. Compilers classify the ways two pieces of a program can touch the same data, and three of the four impose an order:

| Dependency | What happens | Must B wait for A? |
|---|---|---|
| read after write | B reads what A wrote | yes |
| write after read | B overwrites what A still reads | yes, unless the data is copied |
| write after write | both write the same place | yes, the last write must win |
| read after read | both only read | no |

The last row is the one compilers drop, because it constrains nothing: two reads can happen in any order, or at the same time. mynatix's point is that it still carries information, about which pieces of work share data, and they use that information to decide how large the tasks should be. Granularity is where automatic parallelisation usually fails. Tasks that are too small drown in the cost of scheduling them; tasks that are too large leave cores idle.

```c
// Illustrative. Neither loop writes x, so they can run side by side;
// that both read x is a read-after-read dependency, invisible to most compilers.
for (i = 0; i < n; i++) a[i] = f(x[i]);
for (i = 0; i < n; i++) b[i] = g(x[i]);
```

We talked about it over lunch at [Restaurant Aeschenplatz](https://www.basel.com/en/restaurants-nightlife/aeschenplatz-91ca436272), and what struck me was how close it sits to the reason I like Haskell. Parallelising a program is mostly a question of dependencies: what has to wait for what. In most languages that is buried in shared mutable state, and the compiler has to dig it out, conservatively, before it dares to split anything. In [The Field Exists Now](https://raskell.io/articles/the-field-exists-now/) I wrote that functional purity makes dependencies visible and gives the compiler more to work with. Both halves of that apply here. What a pure language makes explicit for the person reading it, a compiler like LAYCOS has to reconstruct for a language that hides it.

BHC is not there. Its threads today are [concurrent, not parallel](https://arcanist.sh/bhc/blog/threads-honestly/); they interleave on one core, because parallel execution waits on a real garbage collector and an audit of shared state. Its `numeric` profile is designed for strict, fused, unboxed code with SIMD and parallel loops, and the [numeric page](https://arcanist.sh/bhc/numeric/) is honest that native code does not use those parallel loops yet. Talking to someone who has spent years on exactly the part I have postponed was useful, and a little humbling.

## The second lunch: a spec beside the code

Yesterday Andres showed me what they have added to their compilation layer since. It is a checker for the output of coding agents. You describe what an artifact must do in a declarative language based on [Lean](https://lean-lang.org/), and you describe it without saying in which programming language it will be written. A coding agent produces the code. The compiler checks the result against the spec, and the spec, not the agent's own tests, decides whether it passes. The four of us spent most of the hour ping-ponging it: what it can express, who would write the specs, and who would pay for it.

I think the shape is right, for the reason in the manifesto. The weakest link in agent-written code today is that the same model often writes the implementation and the tests, and both share its misunderstanding. A spec written separately, in a language that states properties and not only examples, breaks that loop: the thing that judges the work is not the thing that did it. It is the rule I ended [The Behavioural Turn](https://raskell.io/articles/the-behavioural-turn/) with: keep at least one check out of the agent's reach.

To make the difference to a type concrete, here is what a specification for that sort function could look like in plain Lean. This is my own illustration with Mathlib's definitions, not mynatix's language, which I have not seen written down:

```lean
-- Whatever an agent writes, in whatever language, its sort must do this:
-- the result is ordered, and it is a rearrangement of the input.
def SortSpec (sort : List Int → List Int) : Prop :=
  ∀ xs, List.Sorted (· ≤ ·) (sort xs) ∧ List.Perm (sort xs) xs
```

Two lines that say what a suite of example-based tests only samples. The function that returns the empty list fails the second condition; a function that drops duplicates fails it too; a function that sorts in descending order fails the first. And the statement says nothing about how to sort, which leaves the agent, and the compiler, free to choose. How mynatix connects a statement like this to code written in another language is the part I would most like to see written up, because that bridge is where the hard engineering is.

None of this is new as an idea. [CompCert](https://compcert.org/), a C compiler whose correctness Xavier Leroy's team proved in Coq starting in 2005, and [seL4](https://trustworthy.systems/publications/papers/Klein_EHACDEEKNSTW_09.pdf), the microkernel whose functional correctness was proved in Isabelle/HOL and published in 2009, showed that a specification and a machine-checked proof can stand behind real systems software. They also showed the price: a handful of experts, for years, for one program. The closest precedent for what mynatix showed me is more recent. AWS built its authorisation language Cedar with what its team calls [verification-guided development](https://arxiv.org/abs/2407.01688): an executable model of each core component in Lean, proofs of its key properties, production code in Rust, and differential random testing that runs millions of inputs through both and compares the answers. The proofs found four bugs, the testing twenty-one more, and a new version is not released unless its model, proofs and tests are up to date. The spec stands beside the code, in another language, and gates the release. What agents change is the economics: if a model writes the implementation, the expensive human work shrinks to the part that was always the point, saying precisely what the code must do.

It is also a different answer to the same problem from the one I am building.

| | Checking inside the language (BHC) | Checking beside the language (mynatix, as shown to me) |
|---|---|---|
| Where the guarantee lives | in the types of the program itself | in a separate spec, written in a Lean-based language |
| What the agent writes | Haskell, which the compiler checks as it compiles | code in any language, checked against the spec |
| What a human reviews | types and signatures, close to the code | the spec, apart from the code |
| Strength | nothing to keep in sync: the program is the proof | language-agnostic, and stronger properties than most type systems express |
| Weakness | only as strong as Haskell's types; one language | a second artifact that can drift from what was meant |

BHC's bet is that Haskell already carries enough proof machinery to make a lot of correctness checkable without a second language. Stronger checks are on its road too, but only on paper so far: the [commons](https://arcanist.sh/commons/) design records a refinement as established when it has been discharged to a solver, and that is a draft, not a feature. mynatix's bet is that the spec should not depend on the language at all, which is the only realistic option for the very large amount of code that will never be Haskell. I do not think one replaces the other. If anything, a good spec layer would make a commons of checked results more valuable, because a spec checked once could be reused by every agent that writes against it.

The hard questions are the old ones of formal methods, and they do not go away because an agent writes the code. A wrong spec is checked perfectly; the [arcanist.sh glossary](https://arcanist.sh/glossary/) puts it as "a well-typed function proves consistency with a specification, not fitness for intent", and the same is true of a spec in Lean. Writing specifications is a scarce skill, and Lean even more so; if agents end up drafting the specs as well, the review moves to a smaller, denser artifact, which may be the real gain. And a spec that does not care about the programming language has to describe behaviour at the boundary of the artifact, which is easy for a sorting function and much harder for a service that talks to three others.

## Lean, briefly

Lean is worth a short detour, because most programmers have heard the name and few have looked inside. Leonardo de Moura started it at Microsoft Research; the first commit to its repository is from July 2013. He had worked on automated reasoning for years before, and he is now at AWS. Lean 3, in 2017, was the first version stable enough for wide use, and around it grew Mathlib, a library of formalised mathematics started the same year that had passed 210,000 theorems and 100,000 definitions by May 2025. Lean 4 is a rewrite, begun in 2018 and officially released in 2023, and it is written largely in Lean itself. Since 2023 a non-profit, the [Lean FRO](https://lean-lang.org/fro/about), founded by de Moura and Sebastian Ullrich, has carried its development.

Underneath is a dependent type theory, the calculus of constructions with inductive types, in which a statement is a type and a proof is a program of that type. A small trusted kernel checks every proof down to that foundation, so you do not have to trust the clever automation that found a proof, only the kernel that accepts it. And Lean is a real programming language as well as a proof assistant: it compiles to native code, and the [homepage](https://lean-lang.org/) makes the point that you write proofs in the same language as your program, with no separate spec language. A definition and a theorem about it:

```lean
-- a definition, as in any functional language
def double (n : Nat) : Nat := n + n

#eval double 21   -- 42

-- a statement about it, and a proof the kernel checks
theorem double_even (n : Nat) : double n % 2 = 0 := by
  unfold double   -- replace double n with n + n
  omega           -- a decision procedure for arithmetic finishes the goal
```

For someone coming from Haskell the first two lines read like home, with more Unicode. The rest is the part with no counterpart in everyday programming. After `by`, a proof is a short script of tactics, and the editor shows the goal that is still open after each line, so writing a proof is a conversation with the checker: you take a step, it shows what remains, and the file stays red until nothing does. When it turns green, the statement holds for every natural number, not for the handful a test happened to try.

That has been a niche for mathematicians and verification engineers, and it is moving. Terence Tao used Lean to formalise his proof of the polynomial Freiman-Ruzsa conjecture with collaborators in 2023, in about three weeks; Google DeepMind's AlphaProof reached silver-medal performance at the 2024 International Mathematical Olympiad working in Lean and Mathlib; AWS uses it for Cedar, as above; and the Lean FRO lists verified code synthesis with AI among its aims. Models are getting good at writing Lean because Lean tells them, precisely, when they are wrong.

## From Markdown to proof

Which brings me to the files I spend my own days with. Every agent setup I know runs on Markdown: `AGENTS.md` and `CLAUDE.md` in the repository, rules and skills under `.claude/` and `.agents/`, and the personal [context layer](https://raskell.io/articles/context-is-king/) my agents start every session from. This site has all of them. They work, and I wrote a whole article on why they matter. But they share one property: they are advice. An agent reads "every public function handles the empty list" and follows it most of the time, and nothing checks the times it does not.

I already moved some of that advice out of prose. In Context Is King, separation between contexts stopped being an instruction and became a hook that refuses the commit; this site's rules about dashes and filler words became a script that checks every social post before it goes out. A Lean spec is the next step on the same ladder:

| A rule in my context files | Its strongest form today | Who enforces it |
|---|---|---|
| write calmly, in the first person | prose in a rules file | a reader, or a model asked to judge |
| no em dashes, no filler words | a check script | the script, before anything is posted |
| contexts never mix | a git hook | the commit |
| the sort returns its input, in order | a specification with a proof | the kernel |

The higher a rule sits in that table, the more it depends on someone's judgement; the lower, the less it depends on anyone's goodwill. What a spec layer like mynatix's offers is to move the rules about *what the result must be* all the way down: the invariants, the contracts at an interface, the properties that today sit in a Markdown file as a hopeful sentence. For an agent that is a better input as well as a better gate. A prose rule tells it what someone wanted; a spec tells it exactly what will be checked, and the checker's error says exactly what is missing, which is the kind of feedback I argued for in [Agent Experience](https://raskell.io/articles/agent-experience/).

It will not replace the Markdown, and I would distrust anyone who claims it will. Most of what my context files hold is not a property of an artifact: why a decision was made, what matters more than what, how I like to work, when to commit and when to ask. That stays prose, because it is about intent and judgement, and no kernel can check taste. What I expect is a split. Markdown for how and why; a spec for what must be true; and a context file that points to the spec instead of paraphrasing it. The agent reads both, and only one of them can say no.

## Who buys it

A checker nobody is obliged to run does not get run, so the question of who pays decides more than the technology does. What follows is my own reading, not mynatix's plan: three places I would look first.

The first is regulated software, where someone has to sign off on code: banks, insurers, medical devices, avionics. These industries already pay for reviews, audits and certification, and agents make the signature harder to give, because the person signing did not write the code and cannot read all of it. A spec a reviewer can read, with a checker that shows the code meets it, is evidence an auditor could accept. Whether auditors will is a separate question, and auditors move slowly.

The second is hardware. High-level synthesis and chip design are among mynatix's core areas, and there a bug found after tape-out costs a new run of silicon, so formal verification already has a line in the budget. Specifications are not a new idea to sell there; a checker that works with designs an agent produced might be.

The third is closer to my own days: platform teams that let agents change code across many repositories and want a gate that does not depend on the agent having understood the task. Today that gate is review and CI. A spec is a stronger one, but someone has to write it, and that cost settles the question. If a model can draft the spec and a person can review it in a fraction of the time the code would take, the sums work. If every spec needs a Lean expert, they do not, and the market shrinks to the few teams that already employ one.

## Lunch, and the fabric of reality

Then we crossed the square to lunch, and the restaurant was full to the brim. Over schnitzel and pasta the conversation left compilers behind for the rest of the hour: innovation in Switzerland, in Europe and in the rest of the world (my own view on capital and risk is in [A billion without a plan](https://raskell.io/notes/a-billion-without-a-plan/)); what makes a startup work, which a friend once answered for me in [Citizen entrepreneurs](https://raskell.io/notes/citizen-entrepreneurs/); what philosophy is for once machines can argue; and what reality may be made of, a question I touched in [An emergent property of matter](https://raskell.io/notes/an-emergent-property-of-matter/). Not one of those has an answer a compiler could check, which made a pleasant change after an hour of specifications.

<figure>
<img src="/the-spec-the-agent-does-not-write-lunch.avif" alt="Four men smile into the camera at a long table with white tablecloths in a wood-panelled restaurant, plates and a bread basket between them, and the busy room behind them blurred." width="1600" height="800" loading="lazy">
<figcaption>Lunch at Restaurant Aeschenplatz with the mynatix team, and not a free table in the room.</figcaption>
</figure>

## Two halves of one job

What I took home from both lunches is that compiler work has two halves again, and agents make both of them urgent. One half is speed: getting code, increasingly written by machines that do not care how it performs, to use the hardware it runs on. The other is proof: making sure that code does what was meant before anything runs it. For thirty years most of us could ignore both, because a person wrote the code and a person read it, and that arrangement is ending.

The two halves also meet in one place, and it is the place my trilogy on languages kept arriving at: describe what, not how. A specification that states only what must be true leaves the compiler free to decide how, and that freedom is exactly what a parallelising compiler needs. Code that spells out every step in order is hard to check and hard to split; a statement of the result is easy to check and leaves the order open. The less a program says about how, the more there is for a compiler like LAYCOS to optimise and for a checker to prove. I did not expect a lunch about read-after-read dependencies and a lunch about Lean to end up making the same argument, but they did.

It was a good lunch, twice, and I learned something from each of the three. Basel has more of this than people think: a few founders on a square full of banks, working on the plumbing that everything else will run on.

## References

- mynatix, [Home](https://mynatix.com/), [Company](https://mynatix.com/company/), [Technology](https://mynatix.com/technology/) and [Core areas](https://mynatix.com/core-areas/), Mynatix AG.
- [Using Read-After-Read Dependencies to Control Task-Granularity](https://dl.acm.org/doi/10.1145/3659914.3659921), PASC24 proceedings, ACM, 2024, as listed on mynatix.com.
- [Lean](https://lean-lang.org/), the programming language and theorem prover; [Mathlib](https://leanprover-community.github.io/mathlib4_docs/), its library of mathematics.
- Lean FRO, [About](https://lean-lang.org/fro/about), with the timeline of Lean's releases; [Learn Lean](https://lean-lang.org/learn/); [Use cases](https://lean-lang.org/use-cases/); [Lean community](https://leanprover-community.github.io/).
- [Lean (proof assistant)](https://en.wikipedia.org/wiki/Lean_(proof_assistant)), Wikipedia, for Lean 3, Mathlib's size in May 2025, and Tao's formalisation of the polynomial Freiman-Ruzsa conjecture.
- Craig Disselkoen, Aaron Eline, Shaobo He, Kyle Headley, Michael Hicks, Kesha Hietala, John Kastner, Anwar Mamat, Matt McCutchen, Neha Rungta, Bhakti Shah, Emina Torlak, and Andrew Wells, [How We Built Cedar: A Verification-Guided Approach](https://arxiv.org/abs/2407.01688), arXiv:2407.01688, 2024; and [Lean into verified software development](https://aws.amazon.com/blogs/opensource/lean-into-verified-software-development/), AWS Open Source Blog.
- Xavier Leroy, [Formal verification of a realistic compiler](https://cacm.acm.org/magazines/2009/7/32099-formal-verification-of-a-realistic-compiler/fulltext), *Communications of the ACM*, July 2009; [CompCert](https://compcert.org/).
- Gerwin Klein and others, [seL4: Formal Verification of an OS Kernel](https://trustworthy.systems/publications/papers/Klein_EHACDEEKNSTW_09.pdf), SOSP 2009.
- arcanist.sh, [Manifesto](https://arcanist.sh/manifesto/), [Glossary](https://arcanist.sh/glossary/), [The commons](https://arcanist.sh/commons/), [Runtime profiles](https://arcanist.sh/bhc/profiles/), [Numeric performance](https://arcanist.sh/bhc/numeric/) and [Threads, honestly](https://arcanist.sh/bhc/blog/threads-honestly/).
- Raffael Schneider, [I Stopped Writing Most of My Code](https://raskell.io/talks/iat-13-basel/), IT's ABOUT TECH #13, FHNW Basel, 10 June 2026.
- [Hammering Man](https://en.wikipedia.org/wiki/Hammering_Man), Wikipedia; [Restaurant Aeschenplatz](https://www.basel.com/en/restaurants-nightlife/aeschenplatz-91ca436272), Basel Tourism.
