Skip to content

Incubator Server Setup

The Incubator is an optional, stateless FastAPI + SQLModel + Alembic server that coordinates multiple developers, repositories, and AI agents around one authoritative database (Neon PostgreSQL, MySQL 8+ / MariaDB 10.6+, or SQLite).


1. Choose & Configure Your Database (Server / Operator Only)

Section titled “1. Choose & Configure Your Database (Server / Operator Only)”

Security Note — Server & Superuser Operator Secret Only: SPECHATCH_DATABASE_URL is a server-side secret of the Incubator service itself (configured in your hosting platform’s secret manager or container runtime environment). Only the Incubator operator / superuser needs temporary local access to SPECHATCH_DATABASE_URL when running one-time DB-direct bootstrap (spechatch admin init) or break-glass recovery commands (spechatch admin ...). Regular developers and AI agents should NEVER set SPECHATCH_DATABASE_URL — they only store SPECHATCH_URL and their personal SPECHATCH_API_KEY (shk_*) and communicate with the Incubator strictly over HTTPS.

spechatch normalizes database URLs automatically (postgres:// / postgresql:// → postgresql+psycopg://; mysql:// / mariadb:// → mysql+pymysql:// with the [mysql] extra) and namespaces every table with SPECHATCH_TABLE_PREFIX (default spechatch_).

Terminal window
# On the Incubator server (or operator machine for one-time `spechatch admin init` only):
# Store in your server secret manager, or locally in ~/.config/spechatch/.env (0600 permissions)
spechatch secret put DATABASE_URL --shared
# Verify DB connectivity (and wake scale-to-zero Neon instances)
spechatch ping --db

On first startup, Alembic automatically runs all bundled migrations (0001–0008), creating the 15 spechatch_* tables:

The 15 spechatch_* tables created automatically in Neon PostgreSQL


2. Bootstrap Your First Superuser (Production / Authenticated Mode)

Section titled “2. Bootstrap Your First Superuser (Production / Authenticated Mode)”

For shared team deployments, always enable authentication (SPECHATCH_AUTH_ENABLED=true). Run the one-time DB-direct bootstrap command to create the initial superuser and mint your first shk_* human API key:

Terminal window
spechatch admin init --username admin --full-name "Platform Admin"

Store the one-time printed shk_* key and server URL locally:

Terminal window
spechatch secret put URL https://incubator.example.com --shared
spechatch secret put API_KEY --shared

Break-glass recovery: If a superuser loses their key or leaves the team, DB-direct operators can run spechatch admin reset-password <user> --rotate-key or spechatch admin transfer-superuser --from <old> --to <new>.


3. Run the Server (Local Process or Docker)

Section titled “3. Run the Server (Local Process or Docker)”

Option A — Local Process (spechatch serve)

Section titled “Option A — Local Process (spechatch serve)”
Terminal window
# Local development (127.0.0.1:8787)
spechatch serve
# Production bind (requires SPECHATCH_AUTH_ENABLED=true)
SPECHATCH_AUTH_ENABLED=true spechatch serve --host 0.0.0.0 --port 8787

Option B — Stateless Docker Container (spechatch incubator init)

Section titled “Option B — Stateless Docker Container (spechatch incubator init)”

In any directory or deployment repo, scaffold a ready-to-build PyPI-based Dockerfile (non-root USER spechatch, [incubator,mysql] drivers, /api/spechatch/v1/health HEALTHCHECK) and .dockerignore:

Terminal window
spechatch incubator init
# Build locally
docker build --load -t spechatch-incubator .
# Run using your stored ~/.config/spechatch/.env (or explicit -e flags)
docker run --rm -p 8787:8787 \
--env-file ~/.config/spechatch/.env \
-e SPECHATCH_AUTH_ENABLED=true \
spechatch-incubator

Verify the running server:

Terminal window
spechatch healthcheck

4. Manage Projects, Users, Roles & API Keys from the CLI

Section titled “4. Manage Projects, Users, Roles & API Keys from the CLI”

Everything can be administered directly through spechatch incubator (all subcommands support --json, and accept either a usr_* ID or username):

Terminal window
# 1. Create a project (superuser only)
spechatch incubator project create my-app --name "My App" --description "Core platform"
# 2. Create a teammate account (superuser only; prompts for password securely)
spechatch incubator user create alice --full-name "Alice Dev" --role member
# 3. Assign project role (owner | maintainer | developer | viewer)
spechatch incubator member add my-app alice --role developer
# 4. Mint a personal API key (actor_type: human | agent | ci)
spechatch incubator key create alice --name alice-laptop --actor-type human
spechatch incubator key create alice --name alice-agent --actor-type agent

On her workstation, Alice only configures the Incubator URL and her personal API key (never DATABASE_URL):

Terminal window
spechatch secret put URL https://incubator.example.com
spechatch secret put API_KEY # paste shk_... when prompted
Terminal window
# List & inspect
spechatch incubator user list
spechatch incubator project list
spechatch incubator project show my-app
spechatch incubator member list my-app
spechatch incubator key list alice
# Update, deactivate, or reactivate users & projects (last active superuser is protected with 409)
spechatch incubator user update alice --role superuser
spechatch incubator user deactivate bob
spechatch incubator project deactivate legacy-app
spechatch incubator project activate legacy-app
# Revoke a compromised key or inspect the immutable audit trail
spechatch incubator key revoke key_01abc...
spechatch incubator audit --limit 50
Action Allowed Roles
Create / list / update / deactivate users, view /audit superuser only
Create projects superuser only
Update / deactivate / reactivate a project, update project settings Project owner or superuser
Add / remove project members, bootstrap project, manage webhooks Project maintainer+ or superuser
Allocate IDs, upsert roadmap, claim/revise specs, ingest tests, bump version Project developer+ or superuser
Approve human checkpoints (spechatch approve) Project maintainer+ with actor_type=human key
Read roadmap, context, epics, health, version Project viewer+ or superuser

5. Bootstrap Existing Specs & Sync Test Health

Section titled “5. Bootstrap Existing Specs & Sync Test Health”

Inside your repository (with spechatch.project.yml configured):

Terminal window
# Seed monotonic counters (highest + 1) and import existing specs into the ledger
spechatch bootstrap
# Run configured test runners and ingest per-spec health into the Incubator
spechatch test run --remote
# Atomically bump the project's version on the Incubator + local manifests
spechatch version bump minor --remote

Every spec’s status, version, owner, content_hash, and health (healthy / regressed) is tracked live in spechatch_spec_ledger:

Live spechatch_spec_ledger rows in Neon PostgreSQL

And running spechatch test run --remote attributes JUnit results directly to each spec while streaming 200 OK updates to the Incubator:

Split terminal showing spechatch test run --remote alongside live FastAPI Incubator logs


  • Webhooks & Notifications — Receive rich Slack, Discord, or Microsoft Teams cards whenever specs transition, regress, or bump versions.
  • AI Agents & Native MCP — Enable SPECHATCH_INCUBATOR_AUTO_SYNC=true so AI agents sync seamlessly with your Incubator.