Truss is a programming language designed for agent-written software - finiteloop/truss
97 comments
My understanding of this is: You write a "contract" that defines the specification for some functionality, including inputs, outputs, preconditions, post-conditions, etc. and the contract can be formally verified by some proof checker that says it's logically consistent. Then you build the implementation and the implementation can be proven to abide by the contract (or not).
But somebody has to write the contract (either a person or AI). If the contact specifies behavior that is logically consistent as far as a proof checker is concerned, but the behavior is defined incorrectly, you could have a situation where "you built the thing right", but "you didn't build the right thing".
So someone still needs to make sure the contracts are specifying the correct behavior. Once you know you have, then I suppose the formal verification is good because everybody (people and AI) know that it guarantees its behavior.
My question then is: Assuming everything I just said isn't nonsense, aren't we still in the same place as before? Someone needs to know how to specify (and program) the right behavior?
A not-quite-there way to close the gap is that you can generate traces from the spec/proof, a sequence of states and events that must hold true. and then you can use that trace to replay back in tests, and if the implementation is correct, then it should mirror the trace.
E.g. with a normal programming language a bug in the hash-map internals that rarely returns the wrong element is undectable. With a spec, if the spec says it can ever return the wrong element, I'm going to run head first into that when I try and prove that my pathfinding algorithm using that hashmap for memoization is correct.
ppl always come with weird workarounds to put in loops and if conditions and then throw it all away to use a general purpose programming languge
In situations where the specification is as complex as the program one should really wonder if one is doing the right thing.
Take sorting as an example. Verifying any one instance is easy even in something like Python
all(a<=b for a,b in zip(L,L[1:]))
Which wasn't really made for the task. If you have theorem proving as part of your contracts then that just gives you extra confidence above and beyond however else you're verifying them. Note that this is much easier to understand even if you don't know Python than a typical sorting algorithm.I've personally never seen a contract system properly handle business rules well (the set of rules is usually about as verbose and we'll abstracted as the top-level code implementing them, and bugs are typically exactly the issue you posed, that the rules were improperly specified), so I'm skeptical of this approach.
That heavily depends on what problem you're trying to solve. The very example from TFA is quite illustrative:
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) }
}
implementation InlineReplaceElement of ReplaceElement {
function replace(words: &mutable Slice<UInt64>, index: UInt64, value: UInt64) -> UInt64 {
let previous = words[index]
words[index] = value
previous
}
}
Or take, for instance, this spec in English prose: "given a predicate that returns true or false for each value, and a list of values, `filter` returns a new list that contains exactly the values in the original for which the predicate returned true". I guarantee you that turning this into the Truss contract would produce a significantly larger amount of code that the implementation that would consist of just the following 5 lines, modified accordingly: result := []{}
for _, v := range list {
if predicate(v) { result = append(result, v) }
}
return result
And of course, please note that the spec I've given is defective: it doesn't say anything about the order of the elements in the resulting list, or the presence/absence of duplicates. Also, you probably will have to insist on the predicate being a pure or at least a repeatable (reproducible?) function — I don't know how you'll spec `filter` when it's given a non-idempotent predicate.Like if you want a program that sorts a list that is a subjective goal because you could just as easily choose a shuffled list, or a different sorting, or any other sort of list ordering.
Once you've established what you want fulfilling that is an objective task.
Today's programming languages entangle subjectivity and objectivity together, and better decoupling them means we can automate the objective parts which dramatically reduces the programming left over for humans.
Source: I also tried writing an agent-optimized language (for concision and adaptability, not correctness), then I measured.
I've been building a new programming language, Zena [1], for a year and modern Claude and Gemini have absolutely no problem generating the code with about a 300-line skill: https://github.com/elematic/zena/blob/main/skills/zena/SKILL...
(I also happen to be adding contracts and formal verification for gen AI, maybe similar to Truss, but that targets Wasm for sandboxing).
Sounds like we overlap a lot. LLMLL has requires/ensures contracts too, and the SMT check you have planned for @verify already runs there over a decidable fragment. Anything outside that fragment is marked asserted or tested, not proven. It compiles to Haskell today, with WASM/WASI on the roadmap as the sandbox. Happy to compare notes.
https://carolina.codes/speakers/2026/redvers-davies
It was really interesting. Pony is also deeply underrated.
I think there's some truth here: linters and compilers for general purpose languages are only so powerful, and LLMs will always be tempted to use patterns they've seen before when they're knee-deep in a language they think they understand how to use for your problem. Restricting them to think about problems from first principles in languages with clear and enforced guidelines about data sharing, ownership, traceability, etc. can be very powerful.
Direct link to talk: https://www.youtube.com/watch?v=oU5sV1ljTzs
Here someone else who tried to write a coding agent optimized programming language, but I asked it to optimize for cost. Using less tokens is an obvious one but while working on it the actual engineer (LLM) decided that saving on tokens would be marginal savings compared to being able to write the same quality code by a cheaper model. But it never found out how.
After a couple of hours seeing benchmarks in which it lost from Python on pretty much everything, it told me to give up. I did.
(Or did I just describe something that has been done eleven times already?)
Incorrect. I built my own programming language [0] and agents just look up the docs and write it with great success. It helps to have static linting/analysis of course, but they always do just fine writing Rad despite it being very small.
For instance:
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) }
}
This is _extremely_ similar to JS/Rust/Java style syntax mixed with common forms from general ALGOL descendant languages. LLMs should have no trouble writing this whatsoever.I went around and around today because Claude wrote to obsidian in the wrong folder even though the obsidian vault path was in the env variables. It writes to obsidian 20 times a day and suddenly it writes to a path outside the vault path. The content never synced.
It claimed it went from recall and didn’t check the environment variables. I pointed out that each process wrote successfully to the correct path and it retorted that each effort is a new effort and had nothing to do with previous successful efforts.
These situations require more and more deterministic instructions in AGENTS.md but then it’ll find another way to escape the instructions. It’s an endless digressive evasive cycle.
but .. a collection of scripts, with a datastore.. starting to feel like a framework.
I guess the best way will be to improve on existing languages by adding the contracts and verification methods on top of them.
But more substantively, part of the thesis of Truss is composition of verification:
> When you bind Map to a provider like InlineMap, Truss uses the supplied evidence in package.proof to independently verify its conformance, a simple validation process that can be an order of magnitude faster than constructing the proof itself. > > This approach enables formal verification to scale with large code bases, pushing the majority of the work of formal verification to package authors; when you publish a package, you spend as many tokens generating proofs as you do writing the code, and the programs depending on your package don’t need to recreate your efforts.
By (1) explicitly tying the proofs to the language (as opposed to proving independent code, which can stray from what was proven), (2) making the contract claims the basis of proof composition, (3) tying this all together in the packaging system, I have a hypothesis it will make scaling verification more practical, especially in very large codebases.
Also, aren't function composition known to be bad-behaving, and unfortunately just because you can prove something about f and something about g, f(g) may be prohibitively expensive to prove again? Do you have an idea how common it is?
I couldn't find a connection between Truss's author and Microsoft, so I do wonder if he maybe got an LLM to design the syntax, which then included prior art from Microsoft etc.
Read the full thread on Hacker News →
Related stories
- Hacker News · 1 points · 3 days ago
- Hacker News · 2 points · 3 days ago
- Lobsters · 86 points · about 1 year ago
- Lobsters · 2 points · over 3 years ago
- Hacker News · 5 points · 2 months ago
- Flare Programming Languageflarelang.sourceforge.netLobsters · 6 points · almost 10 years ago