grange: A Database Your Agent Can Pay For
grange: A Database Your Agent Can Pay For
Every database assumes a human will show up at some point — to create the account, paste the card, click through the console. Agents can't do any of that. So I built a database where the wallet is the signup.
A database in a language for agents
grange is a document database written in machin, my language for AI agents. One static binary. JSON in, JSON out, semantic exit codes, a guide verb that is the manual. Embed the engine in any machin app the way you'd embed SQLite, drive the CLI, or run the server.
Two properties fell out of the language rather than being engineered in. Crash-safety: MFL has no file append or rename, so every commit is one immutable, checksummed WAL chunk — kill -9 at any moment leaves exactly the committed prefix, and the repo ships the harness that proves it. Race-freedom: 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, no trust-me.
Honestly benchmarked against SQLite
The bench ships in the repo (make bench) and runs both engines with the same indexes on the same box, 100k documents. Bulk insert with two indexes maintained: 278k docs/s vs 25k. Indexed count, a thousand times: under 1 ms vs 1.5 s. Group-by count/sum/avg, a thousand times: under 1 ms vs 49 s — grange maintains aggregate registers at write time, so a group-by answer costs a map lookup. Range queries after a one-time 79 ms sort: under 1 ms vs 257 ms. The one row SQLite wins — the no-index full scan — is in the README too, because a benchmark you can't lose is marketing, not measurement.
Dogfooding found two compiler bugs
This is why I build real things in machin. The first bench ran 70× too slow — my installed compiler predated a hash-map fix, so every map was O(n). The billing math went negative — integer literals compiled to bare C constants, so 30 * 86400000 overflowed in 32-bit arithmetic before widening to 64. A database is a merciless test program: it found both in one day, and both fixes went back into the language.
The wallet is the signup
The hosted instance at grange.intrane.fr has no signup form. An agent presents a péage wallet and gets an isolated, metered namespace back:
curl -X POST https://grange.intrane.fr/tenants \
-H 'X-Peage-Wallet: pw_...' -d '{"name":"my agent"}'
# -> {"tenant":"t...","token":"gt_..."}Pricing is pay-as-you-go: €0.15/GB/month above 50 MB free, queries free. Storage accrues continuously and charges the wallet when it crosses five cents; GET /usage shows bytes, accrual and charges at any time. No subscription, no card on file, and no lock-in — the engine is MIT, so when you outgrow the hosted rail you self-host the same binary and take your data with you.
With péage to pay, relais to receive, portier to authenticate and now grange to persist, the agent web stack has its memory. The full contract, written for agents: grange.intrane.fr/llms.txt.