Friday, December 04, 2026

Who Owns the Code written by AI Agents?

very interesting and relevant podcast discussion!

 .NET Rocks! Who Owns the Code with Richard Hundhausen and Brad Frazer

minipg: PostgreSQL as single-file exe

power of AI assisted sw dev!

using Zig!?
ad actually running as "hidden" container?!

 How I Got Postgres into a Single Binary · progrium

miniPG is a single, self-contained, cross-platform binary by Jeff Lindsay (progrium) that brings a sqlite3-like CLI and local workflow to real PostgreSQL. Instead of running a persistent database server or spinning up Docker, you point minipg at a directory and immediately run queries, serve a Postgres endpoint, or launch programs with Postgres environment variables already configured.

How It Works

  • Immediate queries: Point minipg at a folder (which becomes the database directory on disk and can be copied, backed up, or deleted when unused) to run SQL right away (minipg ./mydb "select * from notes").

  • Server & wrapper modes: Run a temporary Postgres server (minipg serve ./mydb -p 5432) or wrap an application (minipg run ./mydb -- some-tool) so no background daemon is left behind when the command exits.

  • Real Postgres engine: Built as an actual Postgres server rather than a compatibility layer, compiling across macOS, Windows, and Linux.

Why It Exists: Three Attempts

  1. Attempt 1 — PGlite (WASM): Compiling Postgres to WebAssembly worked like an embedded library, but supporting only a single connection/session caused deadlocks in apps that open a transaction and query over a separate connection before committing.

  2. Attempt 2 — VM in a headless webview: Running an x86 emulator (v86) inside a headless webview via webframe with WebSocket tunneling delivered full Postgres across platforms, but startup/initialization took ~7 seconds on an M3 MacBook—too slow for CLI queries.

  3. Attempt 3 — Hyper9: Using Hyper9's system API translation and hypervisor approach to run Plan 9 executables at near-native speed cut startup from 7 seconds down to 800ms, making the SQLite-style CLI practical.

Ideal Use Cases & Limits

  • Good fit: Local single-user tools, trying or self-hosting Postgres-only open source apps without Docker, using Postgres features (JSONB, full-text search, window functions, pgvector, PostGIS) in SQLite-style workflows, learning SQL, and throwaway databases for tests, local dev, or agents.

  • Not a replacement for: Cloud deployments, replication, or multi-user high-concurrency production workloads where standard Postgres is required.

GitHub - progrium/minipg: SQLite and PostgreSQL had a baby · GitHub

PostgreSQL as a single executable. No server setup, no Docker, and a .pgdb folder that holds the whole database: minipg app.pgdb opens a shell on it.

minipg embeds Docker Hub's postgres:18-alpine image and runs it with hyper9 (h9), used as a Zig library. h9's Linux personality runs Alpine's own Postgres binaries directly on the host's hypervisor, with h9's Plan 9 kernel answering their system calls. There's no Linux kernel to boot, no VM image, and no Docker.

minipg by progrium is a lightweight, single-executable distribution of PostgreSQL (built with Zig) that runs a full Postgres instance locally without Docker, background services, or complex installation.

Core Highlights

  • Architecture: Uses hyper9 (h9) to run Postgres binaries inside a lightweight virtualized micro-VM directly on your system's hypervisor.

  • Single Directory DB (.pgdb): All data, configuration (minipg.toml), generated credentials, and locks are self-contained inside a .pgdb folder that can be easily moved or checked into development environments.

  • Requirements: Built with Zig 0.17.1. Requires Windows Hypervisor Platform (WHP) on Windows (Windows 10 1803+), KVM on Linux, or Hypervisor.framework on macOS.

Key Commands

CommandAction
minipg app.pgdbStarts a psql interactive shell (initializes app.pgdb automatically if missing).
minipg serve app.pgdbRuns the Postgres database server in the foreground.
minipg url app.pgdbDisplays the connection string (postgres://...).
minipg run app.pgdb -- npm startLaunches your host app with DATABASE_URL pre-configured.
minipg dump app.pgdb > dump.sqlExports database schema and data to SQL.

Status & Limitations

  • Status: Early research prototype.

  • Performance: On Linux (x86_64 without KVM), running on h9's native emulation backend incurs a 2x to 12x performance hit compared to native execution.

  • Architecture Limits: Windows ARM64 is currently unsupported.



Here is my (with Gemini) contribution: a logo :)


miniPG is a single, self-contained, cross-platform binary by Jeff Lindsay (progrium) that brings a sqlite3-like CLI and local workflow to real PostgreSQL. Instead of running a persistent database server or spinning up Docker, you point minipg at a directory and immediately run queries, serve a Postgres endpoint, or launch programs with Postgres environment variables already configured.

How It Works

  • Immediate queries: Point minipg at a folder (which becomes the database directory on disk and can be copied, backed up, or deleted when unused) to run SQL right away (minipg ./mydb "select * from notes").

  • Server & wrapper modes: Run a temporary Postgres server (minipg serve ./mydb -p 5432) or wrap an application (minipg run ./mydb -- some-tool) so no background daemon is left behind when the command exits.

  • Real Postgres engine: Built as an actual Postgres server rather than a compatibility layer, compiling across macOS, Windows, and Linux.

Why It Exists: Three Attempts

  1. Attempt 1 — PGlite (WASM): Compiling Postgres to WebAssembly worked like an embedded library, but supporting only a single connection/session caused deadlocks in apps that open a transaction and query over a separate connection before committing.

  2. Attempt 2 — VM in a headless webview: Running an x86 emulator (v86) inside a headless webview via webframe with WebSocket tunneling delivered full Postgres across platforms, but startup/initialization took ~7 seconds on an M3 MacBook—too slow for CLI queries.

  3. Attempt 3 — Hyper9: Using Hyper9's system API translation and hypervisor approach to run Plan 9 executables at near-native speed cut startup from 7 seconds down to 800ms, making the SQLite-style CLI practical.

Ideal Use Cases & Limits

  • Good fit: Local single-user tools, trying or self-hosting Postgres-only open source apps without Docker, using Postgres features (JSONB, full-text search, window functions, pgvector, PostGIS) in SQLite-style workflows, learning SQL, and throwaway databases for tests, local dev, or agents.

  • Not a replacement for: Cloud deployments, replication, or multi-user high-concurrency production workloads where standard Postgres is required.