Why Mandala

To Joe Armstrong.

· Julien Marie

There are a few ideas in computer science that looked right to me the first time I saw them. Not proven right. Just right in the way a well-made tool feels right in the hand before you’ve even used it.

The first was Erlang, around 2004. The idea that distribution works by sharing messages, not state, immediately made sense to me. State stays local. Every process owns its own state, and if you want to know something about another process, you ask it. At the time I didn’t really have the words to explain why I liked this so much. I just had the feeling that most systems I’d seen become horrible had become horrible because everybody was touching the same state.

Then came event sourcing and CQRS, which felt like the same idea applied to data. Don’t keep overwriting the world and pretending the previous version never existed. Store what happened, in order, and derive the present from it. The history is the truth. The current state is just one possible view of that history.

The third idea took me longer to formulate. If state is derived from events, then the projections you build should follow the questions your application actually asks. And most of those questions are known in advance. The screen showing open invoices asks essentially the same question every single time somebody opens it. The product page asks the same questions. The order screen asks the same questions. A ridiculous amount of what databases do consists of recomputing answers to questions they’ve already answered thousands or millions of times. Why? If you know the question, keep the answer ready and update it when something changes. Exploratory queries obviously exist, but they are the exception. I don’t think the exception should dictate the architecture of the entire system.

Put these ideas together and you get something close to what I think of as distributed reactive programming. Something happens, events are produced, projections change, reactions follow. The system is constantly deriving its present from what happened before. Nothing needs to share mutable state, and nothing important needs to disappear.

Then cryptocurrencies arrived, and I genuinely believed in the original dream: a record that nobody could forge, without needing some company sitting in the middle telling everybody what was true. But I watched the implementation turn into a gigantic speculative casino because, to me, the mechanism was fundamentally wrong. It was slow, complicated and cumbersome because it tried to solve trust by making the entire world participate in it. Everybody had to agree about everything, including things that were absolutely none of their business. And after paying that enormous price, the result wasn’t even private.

I think the mistake was making the whole world the trusted third party. We don’t need the whole world. Most of the time we need something much simpler: an unfakeable proof that something happened, that the person or machine doing it had the authority to do it, and that the rules were respected. The people who need that proof are the parties involved and whoever they decide should be allowed to verify it. Nobody else needs to know. Once you accept that, you can have something that is distributed without being absurdly slow, verifiable without being public, and trustworthy without requiring universal consensus.

That’s where Dharma came from. Instead of smart contracts, I wrote a small language called DHL for describing relatively boring things: what a record is, who is allowed to change it, and what must be true before that change can happen. Every action is signed and every rule is compiled. The important part is that an invalid action doesn’t happen. You don’t detect it later, compensate for it, reconcile it, write another service to clean it up and eventually create a dashboard to monitor the service that cleans it up. It simply cannot happen.

Karma came next for a considerably less noble reason: I wanted to see what it would take to build a multimodal database engine faster than kdb+. So I built one. Tables, text, vectors, graphs, geography and time in the same store, with projections maintained as data changes instead of repeatedly recomputed when somebody asks for them. I wrote it in C++ because eventually there is a point where you have to stop being clever and make the computer go fast.

Then I put Dharma and Karma together, and something interesting happened: the rules effectively became the schema of the record. Not a schema that merely says this field is a string, but one that also knows what the thing means operationally, who can do something to it, under which authority, and under what conditions.

Medha came from an even more mundane problem. One day I wanted to get organized. I’d used org-mode for years and wanted something with the same simplicity, except for an entire business: plain text that knows what it is, with tasks, documents and an agenda living inside it. Since Dharma and Karma already existed, I built Medha on top of them. The odd part is that the Markdown files are projections too. Human-readable files are simply another view of the system.

At some point I wondered what would happen if I rebuilt my own e-commerce site using all of this. Catalogue, cart, quotes, checkout. It took two days.

And that was when I started to understand what I had accidentally built. I had a system where every action is checked against rules before it happens, everything that happens is signed and retained, and the data, the rules governing that data, and the interfaces through which something can act on it all belong to the same architecture. None of this had been designed for AI. I had been building it for myself, mostly because I was annoyed by the way existing software worked.

And yet it turns out to be almost exactly the architecture I want for AI.

An AI agent is only as safe as the weakest tool you give it. Today we connect agents to databases, APIs, SaaS products, MCP servers and internal services, each with its own permission model, its own understanding of identity and usually no understanding whatsoever of the rules governing the rest of the system. Then we try to make the agent safe by adding another layer on top. More permissions, more prompts, more guards, more middleware. You don’t make this architecture safe by adding more guards. You make it safe by removing the gaps.

There should be one place where the rules apply to every action, regardless of whether that action came from a human, an AI, an API or another machine. There should be a cryptographic record of what happened, who or what did it, on whose behalf, and under which authority. If the action isn’t allowed, it doesn’t happen. If it happens, it cannot later pretend it didn’t.

Once you have that, something changes. You can actually let the AI act.

Not because you trust the AI.

Because it doesn’t matter whether you trust it.

It cannot do what the law of the system forbids, and it cannot hide what it did.

That’s Mandala.

It runs on your own machines. Mandalas talk directly to other Mandalas. Your data remains yours. The system is distributed because people and organizations are distributed, not because every computer on Earth needs a copy of your lunch order. It is built for a world of sovereign people and sovereign organizations that can cooperate without surrendering control of themselves to each other, or to somebody in the middle. And the whole thing is open source, because I don’t see how you can seriously talk about digital sovereignty while asking people to trust a black box owned by somebody else.

The funny thing is that almost none of the ideas behind Mandala are new. Some of them are twenty years old. Some are much older.

I just think we took a few wrong turns.

And maybe they were right the first time.

Julien MarieOctober 2026

Coming really soon