Phase 2 — MC + HiveMind API
Phase 2 — MC + HiveMind API
Timeline: Weeks 1-2
Goal: Mission Control and HiveMind leave ANVIL and become cloud-hosted APIs. This is the biggest architectural change — SQLite becomes Postgres, local scripts become REST calls.
MC Task: #8495
Proveo Owner: Angie Jones
Status: PREVIEW — Kelsey working in parallel
Why Second
MC and HiveMind are the nervous system. Once they are cloud-hosted, every other phase can run from any machine without touching ANVIL.
Deliverables
- mc-api.js: Express-based REST API wrapping current
mc.jslogicGET /tasks,POST /tasks,PATCH /tasks/:id,GET /stats- Postgres driver (pg) replacing SQLite
- Schema migration: 8378 tasks, 127 open — pg-migrate from SQLite dump
- hivemind-api.js: REST + optional WebSocket for pub/sub
- Postgres backend (hivemind schema)
- Docker images for both, pushed to Azure Container Registry
- Azure Container Apps: deploy mc-api and hivemind-api
- Consumption plan (serverless, scale-to-zero when no traffic)
- Min replicas: 1 (so cold start is 2-4s max, not 30s+)
- Memory: 0.5GB each, vCPU: 0.25 each
- Azure Database for Postgres Flexible Server: Burstable B1ms
- Region: swedencentral
mission_controlDB +hivemindDB on same instance- Automated backups (7-day retention, included in cost)
- Update
mc.jsclient wrapper: detectALAI_MC_URLenv var, proxy to API if set- Backward compatible: if no
ALAI_MC_URL, still uses local SQLite (ANVIL stays working)
- Backward compatible: if no
Cost Estimate
Container Apps (2 apps, ~5h/day active, consumption plan): ~$1.50/month per app = $3/month total (Free grant: 180,000 vCPU-s/month covers most light usage) Azure Postgres B1ms: ~$22-24/month (swedencentral, Flexible Server) Azure Container Registry Basic: $5/month Total Phase 2 additions: ~$30-32/month
Rollback Plan
mc.js still reads local SQLite if ALAI_MC_URL is not set. If Postgres or Container Apps fail, unset ALAI_MC_URL on ANVIL and operations continue locally. SQLite is kept in parallel for 30 days post-migration before decommission.
Proveo Validation Criteria
Test Owner: Angie Jones (Proveo)
- From ab-mac (no local SQLite):
alai mc listreturns live tasks - From ANVIL:
node ~/system/tools/mc.js liststill works (backward compat) - POST to mc-api: task appears in both
mc.js listAND cloud Postgres within 2s - Postgres automated backup: verify restore of 100-row sample matches source
- Container App scales to zero after 10min idle, cold starts under 5s
Detailed Implementation
Kelsey Hightower (FlowForge) is implementing Azure Container Apps + Postgres in parallel. Full runbook will be linked here once ready.
Credit: ALAI, 2026