Every database assumes a human shows up eventually — to create the account, paste a card, click through a console. AI agents can't do any of that. So I built grange: a document database where a payment wallet is the signup.
curl -X POST https://grange.intrane.fr/tenants -H 'X-Peage-Wallet: pw_...' -d '{"name":"my agent"}'
# -> {"tenant":"t...","token":"gt_..."} your isolated, metered namespace
Pricing is pay-as-you-go: €0.15/GB/month above 50 MB free, queries free, billed continuously through péage — no subscription, no card on file, no human in the loop.
The engine
grange is written in machin, my language for AI agents, and two properties fell out of the language rather than being engineered in:
-
Crash-safe by construction. The language has no file append or rename, so every commit is one immutable, sha256-trailered WAL chunk.
kill -9at any moment leaves exactly the committed prefix — the repo ships the harness that proves it. - Race-free by proof. The server is a single actor with zero goroutines, and machin's inferred data-race analysis verifies the whole engine on every build. No Send/Sync, no annotations.
The benchmark (100k docs, both engines indexed, same box)
| workload | grange | SQLite |
|---|---|---|
| bulk insert, 2 indexes maintained | 278k docs/s | 25k rows/s |
| indexed count × 1000 | <1 ms | 1.5 s |
| group-by count/sum/avg × 1000 | <1 ms (write-time registers) | 49 s |
| range count × 1000 | <1 ms | 257 ms |
The aggregate rows aren't typos: declare --sums on an index and grange maintains per-group count/sum/avg at write time — a group-by answer costs a map lookup. The one row SQLite wins (unindexed full scan, 8ms vs 61ms) is in the README too, because a benchmark you can't lose is marketing, not measurement. make bench reproduces everything.
Dogfooding found three compiler bugs in one day
This is why I build real things in my own language. The first bench ran 70× slow — stale compiler binary, maps were O(n). The billing math went negative — integer literals compiled to bare C constants and 30 * 86400000 overflowed in 32-bit before widening. A WAL tombstone turned to garbage — keys(map) aliased internal storage that delete() freed: a use-after-free handed to me by a failing test. All three fixes went back into the language.
For humans: client SDKs
Agents speak curl; humans expect drivers. So: Node.js (npm i grange-db), Go (go get github.com/javimosch/grange/sdk/go), and machin. Same surface: db("crm").coll("leads"), put/get/find/count/agg, bulk writes at 263k docs/s over HTTP.
The full story is on my blog: grange: A Database Your Agent Can Pay For. The contract, written for agents: grange.intrane.fr/llms.txt. MIT, one binary, no lock-in.
Top comments (1)
I was particularly impressed by the
pay-as-you-gopricing model and the fact that grange achieves impressive performance metrics, such as bulk inserting 278k documents per second. The use of a payment wallet as the signup mechanism is also an interesting approach, as it eliminates the need for human intervention. The fact that grange is written in machin, a language designed for AI agents, and inherits properties like crash-safety and race-freedom is a testament to the language's design. I'm curious to know more about how the machin language's inferred data-race analysis works and how it verifies the engine on every build.