Building an agent‑first document database in 75KB
说明与用途
Grange 是一个 75 KB 的静态二进制文档数据库,专为自主代理设计,提供即时聚合、低内存占用,并通过 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