-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Summary
Evolve the amp local development experience to support a persistent, zero-configuration PostgreSQL metadata database that lives entirely within the project's .amp/ directory. This eliminates the need for Docker, system-installed PostgreSQL, or manual database management while providing a seamless developer experience.
Goals
- Zero-config experience: Running
ampd soloshould "just work" without requiring any database setup - Persistence: Metadata DB state persists across amp daemon restarts
- Self-contained: All amp data lives under
<project>/.amp/directory - No external dependencies: No Docker, no system PostgreSQL installation required
- IPC communication: Use Unix sockets for database communication (easier discovery, better security)
- Sensible defaults: Opinionated configuration that works for 90% of use cases
Current Pain Points
| Issue | Impact |
|---|---|
config.toml required |
Cannot run ampd dev without setup |
| Directories not auto-created | Manual setup of data/, providers/, manifests/ |
| No default metadata DB | Must configure PostgreSQL or set ALLOW_TEMP_DB=true |
pgtemp is ephemeral |
All state lost on daemon restart |
pgtemp needs system PostgreSQL |
Additional system dependency |
| No standard project structure | Each developer may use different paths |
Requirements
ampup install --component postgresdownloads PostgreSQL binaries successfullyampd soloworks after PostgreSQL component is installed (no other setup required)- Data persists across daemon restarts
- No Docker or system PostgreSQL required
- Clear error messages when PostgreSQL component is missing
- Clear upgrade path from current Docker-based setup
- < 30 second first-run experience (after component installation)
Proposal
Phase 0: Refactoring - Establish Foundations
- Rename
devsubcommand tosolo - Create
crates/services/metadata-db-postgres/service crate - Remove
temp.rsfrommetadata-db - Clean up
config.rs- remove temp DB spawning logic - Rework config loading for sensible defaults
Phase 1: Persistent pgtemp (Quick Win)
- Configure
pgtempto store data in.amp/metadb/data/ - Use
PgTempDBBuilder::persist_data(true)to prevent cleanup on shutdown - Add reconnection logic to existing database on daemon restart
- Limitation: Still requires system PostgreSQL installation
Phase 2: PostgreSQL as an ampup Component (Full Solution)
Key Principle: PostgreSQL binary download MUST NOT happen at ampd startup. Instead:
ampupis responsible for downloading and managing PostgreSQL binaries- PostgreSQL is treated as a component alongside
ampdandampctl postgresql_embeddedcrate is used by thetempdbservice to manage PostgreSQL lifecycle (init, start, stop, connect) using pre-installed binariesampd soloexpects PostgreSQL binaries to already be installed (or embedded)
Architecture:
┌──────────────────────────────────────────────────────────────────┐
│ ampup │
│ (downloads PostgreSQL binaries to ~/.ampup/components/postgres) │
└──────────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────────┐
│ tempdb service │
│ (uses postgresql_embedded to manage PostgreSQL lifecycle) │
│ - Locates binaries from ampup components dir │
│ - Initializes data directory (.amp/metadb/data/) │
│ - Starts/stops PostgreSQL process │
│ - Provides connection URL to config │
└──────────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────────┐
│ metadata-db │
│ (connects to PostgreSQL using provided URL) │
└──────────────────────────────────────────────────────────────────┘
Component Management via ampup:
# Install PostgreSQL component (downloads binaries)
ampup install --component postgres
# List installed components
ampup list
# Output:
# ampd v0.5.0 (active)
# ampctl v0.5.0 (active)
# postgres 18.x (active)Milestone 3: Zero-Config Experience
- Implement smart config resolution (default -> config.toml -> env vars)
- Auto-create
.amp/structure on first run - Auto-discover existing
.amp/metadb/and reconnect
Decisions
- PostgreSQL version: Prefer PostgreSQL 18 if available in zonky/theseus builds, otherwise use the latest available version
Open Questions
-
Binary source: Which PostgreSQL binary distribution should ampup download from?
- theseus-rs/postgresql-binaries - Rust-focused, smaller
- zonky/embedded-postgres-binaries - Java ecosystem, well-tested
-
Multi-project support: How do we handle users with multiple amp projects?
-
Database migrations on version upgrade: How do we handle amp upgrades that require schema migrations?
-
Disk space management: Should we provide tools to clean up old data or compact the database?
-
Component versioning: How do we handle PostgreSQL version upgrades? Should
ampup updatealso update components? -
Windows support: Unix sockets work differently on Windows. Do we fall back to TCP localhost?