Neon Blog· Russ Dias·· 1d ago
Building a Software Factory on Neon
Building a software factory on Neon
Key Takeaway
Neon runs several agent pipelines that turn Slack requests, GitHub issues and alerts into reviewed PRs, keeping orchestrator state in Postgres and giving each request its own branch of the production database.
Why It Matters
Isolating each request in a branch of production and keeping process control in plain code lets agents change data without touching production or colliding; the cost is maintaining orchestrator state tables plus branch expiration and snapshot policies.
Technical Breakdown · Distilled from the original source
Pipeline and orchestrator
- Every request runs the same six stages: intake, plan, build, verify, ship, measure; humans act only at plan and review, replying in the originating thread to approve, stop or send back.
- The orchestrator's scheduled
tick()takes a Postgres advisory lock so ticks take turns, then claims one request withUPDATE ... WHERE id = (SELECT ... FOR UPDATE SKIP LOCKED LIMIT 1) RETURNING *; aclaimed_untillease frees requests whose worker died. - Hard rules live in code: caps on concurrent requests, retries per stage and spend per request, a kill switch, a decision log and expirations.
Data-side capabilities
- On plan approval a copy-on-write branch of production is created in seconds with its own password; the build agent gets only that branch's connection string. Branches expire after 7 days and scale to zero while awaiting review.
- Before risky steps (migration, backfill, retry) the orchestrator records
checkpoint_at; a failure restores the branch to that moment and keeps the failed state on a side branch. - PR previews run on the request branch, with a schema diff between production and the branch posted next to the code diff; a production snapshot before migrations is the last-resort rollback, and restoring it discards later writes.
- On close, the request branch and side branches are deleted and the request's AI Gateway credential revoked; credentials are tied to the branch, so the consumption API reports tokens per request.
Starting and measuring
- Start with three pieces: a
work_itemstable, an expiring branch per request, and a preview per review; add checkpoints, schema diffs, snapshots and measurement as the queue grows. eventsis an append-only decision log;percentile_cont(0.5)gives median hours from request to first PR over the last 7 days, and the same table yields ship rate, human interventions and failed agent sessions.- Planning agents connect through the Neon MCP Server in read-only mode with a limited Postgres role; roles created in the Console or API can read all data and cannot be used to restrict access.
Source: Neon Blog· neon.com
PG Radar summarizes verified changes and impact. Read the original post for full technical details and code samples.