Introducing DUUMBI: The Semantic Graph Compiler
What if programs weren’t text files? What if, instead of parsing syntax, a compiler operated directly on structured meaning — a graph of typed nodes connected by semantic edges?
That’s the core idea behind DUUMBI, an open-source compiler written in Rust that takes JSON-LD semantic graphs and compiles them to native machine code via Cranelift. No tokenizer. No parser. No syntax errors — by construction.
Why graphs instead of text?
Traditional compilers spend enormous effort converting text into meaning. Lexing, parsing, name resolution, type inference — all of it exists because source code is a lossy, ambiguous serialization of the programmer’s intent.
DUUMBI skips all of that. Programs are stored as JSON-LD graphs where every node has a typed @type from a well-defined vocabulary, every reference is an explicit @id link, and the structure is the program.
{
"@type": "duumbi:Function",
"@id": "fn:add",
"duumbi:params": [
{ "name": "a", "type": "i64" },
{ "name": "b", "type": "i64" }
],
"duumbi:body": [{
"@type": "duumbi:Return",
"duumbi:value": {
"@type": "duumbi:Add",
"duumbi:left": "a",
"duumbi:right": "b"
}
}]
}
This isn’t an intermediate representation — it’s the source of truth. The graph is what you edit, what gets validated, and what the compiler reads.
The compilation pipeline
DUUMBI’s pipeline has four stages:
- Parse — JSON-LD files are deserialized via
serde_jsoninto a typed AST - Graph — AST nodes are inserted into a
petgraph::StableGraph, then validated against a JSON Schema and type-checked - Lower — Graph nodes are translated to Cranelift IR, one function per subgraph, in SSA form
- Link — Cranelift emits a
.ofile, which is linked with a small C runtime viacc
The result is a native binary. No VM, no interpreter, no JIT. The add(3, 5) function above compiles to the same machine code you’d get from a C compiler.
AI-first by design
Here’s where it gets interesting. Graphs are dramatically easier for language models to work with than text. There are no whitespace ambiguities, no bracket-matching errors, no off-by-one indentation bugs. Every mutation is structural.
DUUMBI ships with built-in AI mutation via duumbi add:
$ duumbi add "create a fibonacci function"
✓ AI generated fibonacci(n: i64) → i64
✓ Graph validated, 8 nodes, 0 errors
$ duumbi build && ./output 10
55
The AI generates a set of GraphPatch operations (add function, add block, add op, etc.), which are applied atomically to the graph. If the patched graph fails validation, the compiler retries with error feedback. The graph is always in a valid state.
Ownership at the graph level
DUUMBI implements Rust-inspired ownership and borrowing — but enforced at the graph validation level, before compilation begins. Every heap value (string, array, struct) has exactly one owner. Borrowing creates references (&T, &mut T), and the validator checks for use-after-move, borrow exclusivity, and dangling references.
This means the borrow checker runs on the semantic graph, not on text. Error messages point to specific graph nodes, not line numbers. And AI agents can reason about ownership in terms of graph topology rather than syntax.
Intent-driven development
Beyond single mutations, DUUMBI supports intent-driven development. You describe what you want in natural language, and the system decomposes it into tasks:
$ duumbi intent create "build a calculator with add, sub, mul"
$ duumbi intent execute calculator
✓ Created module calculator/ops
✓ Added function add(a: i64, b: i64) → i64
✓ Added function sub(a: i64, b: i64) → i64
✓ Added function mul(a: i64, b: i64) → i64
✓ Verifier: add(10, 5) = 15 ✓
The coordinator decomposes the intent into ordered tasks, the LLM executes each mutation, and a verifier confirms the result by actually compiling and running the program.
What’s in the box
DUUMBI is a single Rust binary with:
- 40+ Op types — arithmetic, control flow, strings, arrays, structs, ownership, error handling
- Full type system —
i64,f64,bool,string,array<T>,struct<Name>,&T,&mut T,result<T,E>,option<T> - Interactive REPL — with tab completion, history, and slash commands
- Module system — multi-file projects with dependency resolution and a package registry
- 1000+ tests — comprehensive test suite with CI coverage
- Multi-LLM support — Anthropic, OpenAI, Grok, OpenRouter with fallback chains
Get started
cargo install duumbi
duumbi init myproject
cd myproject
duumbi build && ./output
Or dive into the documentation for the full quickstart tutorial.
DUUMBI is open source under the MIT license. The code is at github.com/hgahub/duumbi. We’d love your feedback — open an issue, join the Discord, or just try it out.
Programs should be meaning, not syntax. Let’s build that future.