We know that a language designed purely for AI might not be very readable or useful to humans. Vary takes a particular approach.
Most pitches for a language in the age of AI say the same thing: it is easy for a model to write. Simple syntax, few surprises, lots of examples.
That is the smaller problem. Models already write code well enough that the typical failure is no longer a syntax error. It is a function that compiles, reads cleanly, passes the tests the same model wrote for it, and is wrong. Wrong code that looks wrong gets fixed. Wrong code that looks right gets shipped.
So Vary aims at something else. It isn't trying to make it easier for AI to write code. It is trying to make it harder for AI to produce incorrect code that appears correct.
A person who writes a bug usually leaves traces: an odd variable name, a hedging comment, a test they skipped because it was late. A model leaves none. The code is fluent, the tests are tidy, and review takes thirty seconds because nothing snags.
Reading every line doesn't scale when code arrives faster than anyone can read it. Running the tests helps less than you'd hope, because they came from the same place as the code and tend to agree with it.
What does scale is a set of checks that don't depend on anyone's impression of the code, each of which fails for a reason you can point at.
Here is a small function of the kind a model writes without a second thought, with the tests it would write beside it.
def discounted(price: Int, percent: Int) -> Int {
out(r) {
r >= 0 and r <= price
}
return price - price * percent // 100
}
test "ten percent off" {
observe discounted(200, 10) == 180
}
test "discount is applied" {
observe discounted(200, 50) > 0
}
Both tests pass. The function even states a promise: the result is never negative and never above the price. It reads correctly. It is also wrong, and the four checks below show how.
vary check is a rule-based analyzer that reads code without running it. Its rule groups show what we worry about.
| Group | What it looks for |
|---|---|
| Contracts | Functions with no stated promise, and promises too weak to mean anything |
| Testing | Tests with a single assertion, and modules where no test tries a bad input |
| Mutation readiness | Functions that could be marked pure, so mutation testing can judge them more sharply |
| Safety | Side effects tangled into logic that should be a plain calculation |
| API and effects | Code reaching past the boundary it was meant to stay behind |
It doesn't find the bug in the discount function. It does what a decent reviewer does: it notes that both tests make one assertion and that no test tries a bad input. Those two gaps are exactly what let the bug through. Many findings come with a --fix, and --json hands the same findings to a model in a form it can act on.
This layer is cheap, early and mechanical. It finds code that is thin, not code that is wrong.
A check nobody runs is not a check. vary var answers one question: is the working tree ready? It looks at what changed, decides how much validation the change deserves, runs it, and prints the blockers along with the exact next command.
vary var --json
It is built as the loop for an agent. Edit, run it, read the blockers, fix the first, run it again. A documentation change skips the deep stages. A change to core logic runs checks and tests, plus mutation testing if you ask. If the same blockers come back twice, it says you are stuck, which keeps a model from retrying a fix that doesn't work.
There is nothing clever in it. It moves "did you validate this?" out of the model's judgment and into a command with an exit code.
Passing tests tell you the code agrees with them. They say nothing about whether the tests would object to anything else. Mutation testing asks that directly. It makes small deliberate breaks in the code, like flipping a comparison or changing a constant, and reruns the tests. A break the tests catch is killed. A break nobody notices is a survivor: a place where the code could be wrong and the suite would stay green.
Run vary mutate on a Vary source file to see which changes survive:
vary mutate price.vary
On the discount example:
discounted 16% weak (reach: 13%, specificity: 33%, boundary: 0%, redundancy: 88%)
price#discounted price.vary:3-5 8 survivors CONTRACT_GAP defend contracts
price.vary survivors=10 score=50%
Half the changes to a six-line function went unnoticed, so the two tests we thought were fine constrain very little. The report also says why: the survivors cluster around the contract, which means the contract isn't defending the function.
This matters most for AI-written tests. A model that writes both the code and its tests will often write tests that cannot fail. Vary also ships a lie detector built on the same idea. It sorts tests into placebos (no real assertion), lies (the assertion observes a value that can change without the test noticing) and gaps. Contracts take part as well. Because a function states what its result must satisfy, a mutant that breaks the promise is caught by the promise, with no test needed.
The first three checks sample. Tests sample inputs, and mutation testing samples broken versions of the code. vary prove doesn't sample. It asks a solver whether the contract holds for every input, and it answers with a proof or a counterexample.
On the discount function it found the problem on the first run:
price.vary:3 discounted out { (r >= 0) and (r <= price) } REFUTED
price = -1
percent = 0
price.vary:5 discounted overflow in `price * percent` REFUTED
price = 2
percent = -6199729754951249733
Two bugs, and no sensible test would have found either. The promise can't hold for a negative price, which the function never rules out. And the multiplication overflows a 64-bit integer for large inputs, wrapping around to a result that breaks the promise. The tool prints a test block for each failure that reproduces it on the real runtime. A counterexample that doesn't reproduce is reported as unknown, never as a bug, which keeps the noise down.
The fix is an in block saying prices run from 0 to a billion and the percent from 0 to 100. With that added, all five obligations proved and nothing was refuted. The model still did the work. The prover changed what counted as finished, and the bounds it forced into the open are now written down where a person can argue with them.
| Check | What it catches | What it misses |
|---|---|---|
vary test | Behaviour that breaks on the cases someone wrote down | Every case nobody wrote down, and tests that can't fail |
vary check | Thin contracts, weak and missing tests, tangled effects | Anything well-formed and wrong |
vary var | Skipped steps, stalled fixes, unvalidated changes | Whatever the stages beneath it can't see |
vary mutate | Tests that can't fail, contracts that defend nothing | Behaviour nobody thought to specify |
vary prove | Wrong results and crashes for any input, overflow, broken invariants | Constructs it names as unsupported, and promises that are wrong to begin with |
They stack because they fail in different ways. A weak test suite shows up as survivors. A weak contract shows up as a prover that proves too little. A tool nobody ran shows up in vary var. A wrong program has to slip past all of them at once.
Every check has an edge, and it would be dishonest to leave them out. Each one also comes with something the tool already does about it.
| Edge | What it means, and what Vary does about it |
|---|---|
| Intent | No tool knows what you meant, so a contract that promises the wrong thing will be proven correct. That is why a contract is a few readable lines on the function, not a separate spec, and why vary mutate --with-proofs scores how much of the body each contract defends. A contract that defends nothing shows up as a low score instead of silence |
| Coverage | On our own standard library the prover proves 5,290 obligations, refutes none, and leaves about 100 unsupported and about 300 unknown. Every one is listed by name with the reason, the prover says unknown rather than guessing, and a counterexample is replayed on the real runtime before it is called a bug |
| Trusted base | A proof rests on the compiler and the JVM beneath it. The compiler is tested by generating thousands of programs and checking them against an independent interpreter, and the prover caught a codegen bug of its own, a NaN comparison, while we checked its float model |
| Concurrency | Tasks are checked one at a time, not across every schedule. Two tasks that may write the same field are refuted outright, and the report says what was checked |
| Equivalent mutants | Some survivors change nothing a test could observe, so they can never be killed. For functions of plain numbers, text and booleans, vary mutate --with-proofs asks the prover whether the mutant can differ from the original at all, and quarantines it only when the answer is no for every input. For everything else, five heuristics score each survivor, high-confidence equivalents quarantine automatically, and the rest are listed with the reason they are suspected |
| Defaults | vary var always runs checks and tests, and proves the changed functions that carry a contract. Mutation testing runs on the changed functions when the change is significant logic, and a flag turns either off. Whole-project mutation and review packets cost minutes, so they stay one flag away |
The prover is new and has no outside production record yet. Dafny and SPARK have decades of one. What Vary has is one command, no setup, and a report that never says proven when it means probably.
Everything above runs from one file. Save the discount function and its two tests as price.vary, then walk it through the same steps.
vary test price.vary # both tests pass
vary check price.vary # flags the one-assertion tests and the missing bad-input test
vary mutate price.vary -t price.vary # half the mutants survive
vary prove price.vary # refutes the contract, prints the failing inputs
Then add the precondition the prover asked for:
def discounted(price: Int, percent: Int) -> Int {
in {
price >= 0 and price <= 1000000000
percent >= 0 and percent <= 100
}
out(r) {
r >= 0 and r <= price
}
return price - price * percent // 100
}
Run vary prove price.vary again and all five obligations prove. The bounds are now written down where a reviewer can see them and disagree.
For your own project, do the same on the one function where a mistake costs real money: give it an out clause first, then run the four commands in that order. If an agent writes the code, start the project with vary new my-app --agent claude so the agent has the Vary skill, and tell it a task is done only when vary var --json reports complete.