Gnomon 为 Postgres 数据引入 Git 式分支

原标题:Gnomon. Git for Postgres data, built for agents
74AI 研判分

BitsInfra 推出 Gnomon,一个直接运行在现有 Postgres 内的扩展,为数据库数据提供类似 Git 的分支、差异对比、三方合并与回滚能力。智能体仅凭一条连接字符串即可获得真实数据库的独立分支,改动可逐字段审查后再合并或撤销,并配套 MCP 服务器支持 schema 探索与检查点回滚。

报道正文

本文目录5 个章节

Gnomon

Git for Postgres data, built for agents. Give an agent its own branch of your real database, as nothing more than a connection string. See every field it changed, merge it into main when it's right, and undo it if it wasn't.

Gnomon runs inside the Postgres you already have. One extension, no copies, no second database.

SQL
create extension gnomon;
select gnomon.track('orders');                    -- history starts now, no backfill

select gnomon.create_branch('agent/refunds');
select gnomon.use('agent/refunds');

-- Every query from here on runs on the branch
update orders set status = 'refunded' where id = 4182;

select * from gnomon.diff('agent/refunds');       -- every row and field it changed
select gnomon.merge('agent/refunds');             -- three-way, type-aware, conflicts as rows
select gnomon.undo_merge(1);                      -- and back

A branch of production, in an instant

A branch reads everything from main and keeps only what it changes, so it opens instantly and copies nothing, however big your database is. Give one to every agent run, every pull request and every test.

Your application doesn't change. A branch is a connection string: point a session at it, and the queries it already runs read and write the branch instead of main.

WhereHow
A sessionselect gnomon.use('feature')
One transaction (behind a pooler)select gnomon.begin('feature')
A connection stringgnomon branch url feature
With the C moduleSET gnomon.branch = 'feature'
A past momentselect gnomon.use('main', '2026-10-31 23:59')

Schema changes come along too. Run a migration on a branch to add a column, rename one or create a table, and main stays as it is until the merge, which brings the new shape and its data across together.

Review data like code

Every branch comes with a diff: each row and field it changed, before and after. Review it in your browser, comment on a single row and settle conflicts side by side. When an agent is done, Gnomon opens the review and sends you the link.

Add checks written in SQL, and Gnomon runs them on the merged result before the merge is allowed to land. An approval covers what you saw: if the branch changes afterwards, it comes back to you.

Merges that understand your data

When main and a branch change the same value, Gnomon doesn't just pick a side. Counts add up, JSON merges key by key and text merges line by line. Anything that truly clashes becomes a conflict, for a person to settle or for a query to resolve.

Branches merge into each other too, not only into main, and a single transaction can be picked from one branch onto another. Undo works the same way: take back one transaction, everything an agent did this afternoon, or a whole merge.

Any moment, exactly as it was

Gnomon keeps the history of every table you track. Read the whole database as it was at any moment, with the queries you already have, and get the same answer every time. When an agent makes a decision, you can see exactly what it saw.

SQL
-- The open invoices at the end of October
select gnomon.use('main', '2026-10-31 23:59');
select sum(amount) from invoices where status = 'open';

The same history streams out as it happens, to Kafka, NATS or a webhook, and into dbt as snapshots that keep deleted rows. Older history can move to object storage, and Gnomon brings it back when a query reaches that far.

When a check that used to pass starts failing, gnomon bisect finds the transaction that broke it: who made it, when and why.

Safe to hand to an agent

One command gives an agent a database role, a branch of its own and a connection string. That's all it needs, whatever it's built with. It reads and writes its branch, and the database refuses the rest, main included, even when the agent asks for it by name.

BASH
# A database role, a branch of its own and a connection string
gnomon agent create support-bot
  • It merges only what you allow. Merging is for the people you choose, or for an agent within rules you write: at most twenty rows, only these tables, every check passing. Postgres enforces them, whatever the agent is told.
  • Nothing leaves before you approve. Emails, webhooks and payments an agent queues stay on its branch until the merge.
  • Every change has a name on it. Each change records the agent, the run and the reason it gave.
  • Replay what it saw. Gnomon records the moment of every read, so a replay returns exactly the rows the agent read.
  • Try a few ways at once. Start several attempts from the same moment, compare their changes and checks, and keep the best one.
  • Stop it, and take it back. One command locks an agent out, closes its branches and undoes what it merged, newest first.
  • Ready for your agents. The Gnomon MCP server, on the agent's machine or over HTTP, lets it explore the schema, try a change without keeping it, and rewind its branch to a checkpoint.

(注:更多技术实现细节与完整 API 文档请查阅原项目 README)