Building an agent‑first document database in 75KB
Описание и применение
Grange – это 75 КБ статический бинарный документный хранилище, созданный для автономных агентов. Он обеспечивает мгновенные агрегаты, низкое потребление памяти и самоподписку через curl, без кредитных карт.
Задача
AI agents need a lightweight, self‑provisioned database that accepts JSON, handles billing per call, and can be self‑hosted as a single binary.
Результат
Grange delivers sub‑millisecond group‑by queries, 278k docs/s bulk inserts, and 4.4 MB RAM usage for 200k cold docs, all in a single 7.5 MB binary. Agents can self‑provision and pay per call without human intervention.
Рабочий процесс
- 1. Agent sends a POST to /tenants with its wallet to create a tenant. 2. Agent receives tenant ID and token. 3. Agent uses the token to PUT documents to /put. 4. Agent queries aggregates via /agg with JSON parameters. 5. For self‑hosting, compile machin to a single static binary and run locally.
- 6. Use
grange indexto create indexes with aggregate registers for O(1) group‑by queries. - 7. Use
grange coldto move large collections to disk‑resident cold mode for low RAM usage. - 8. Verify data integrity with
grange verifyand test harnesses (fuzz, crash, differential).
Доказательства
group‑by count/sum/avg × 1000 takes <1 ms
Crash injection: kill -9 mid‑flight on cold collections, recovery must open cleanly
Each tenant gets a separate database directory on disk — separate WAL, separate collections, separate indexes.
- Дата записи: 2026-09-16T04:45:21.458Z