ProDG Studios Mainframe — Orchestration Infrastructure Plan v2.0

For Hermes: Use subagent-driven-development skill to implement this plan task-by-task.

Date: 2026-04-27
Version: 2.0
Domain: prodg.studio (owned)
Target: Hardened central orchestrator for multi-agent workloads over a Tailscale mesh.

Architecture: Self-hosted Headscale control plane on the VPS; mainframe and all agent nodes join the Tailnet. Trusted agents run in Docker containers on-box. Untrusted code and burst inference run on remote Tailscale nodes or Modal. All internal services (DBs, caches, dashboards) communicate over Tailscale. Caddy reverse-proxies Tailscale-internal services. Infisical handles secrets; Vaultwarden handles team passwords. Backblaze B2 provides offsite backup.

Tech Stack: Ubuntu 24.04, Docker CE + Compose, Headscale/Tailscale, PostgreSQL 16, Redis 7, Caddy, Prometheus + Grafana, Infisical, Vaultwarden, Backblaze B2 (restic).


1. Current State (v1.0 → v2.0 Additions)

ResourceValue
OSUbuntu 24.04.3 LTS
CPUAMD Ryzen 5 3600 (6c/12t)
RAM62 GB
Storage2×476 GB NVMe RAID1 → 436 GB usable
Public IPv465.109.89.215
Domainprodg.studio (owned)
Hermesv0.11.0, gateway active
SSH KeyMitch ed25519 key present in /root/.ssh/authorized_keys
Firewallufw inactive
DockerNot installed
VPNNot installed

New Context Since v1.0:

  • Web Search: Tavily API key provided (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) — replaces Perplexity as primary web backend.
  • Object Storage: Backblaze B2 App Key ID K005+ixrAG8niwbXZmjfHUMVfiwn8Hg — offsite backup target.
  • Secrets Management: Infisical (self-hosted) for structured secrets; Vaultwarden (self-hosted) for team passwords.
  • Agent Workload Model:
    • Trusted agents (research, infra) → on-box Docker containers.
    • Untrusted code / burst inference → remote Tailscale nodes or Modal.
  • Hermes API: Routed through Tailscale (not public internet).

2. Target Architecture v2.0

┌─────────────────────────────────────────────────────────────────────┐
│                    ProDG Studios Mainframe                          │
│              65.109.89.215 • Ubuntu 24.04 • Hetzner               │
└─────────────────────────────────────────────────────────────────────┘
                      │ Public (22, 80, 443)
        ┌─────────────────────────────────────────────┐
        │         Tailscale Mesh (Headscale)          │
        │    100.64.0.0/10 • WireGuard • Magic DNS    │
        └─────────────────────────────────────────────┘
               │              │              │
    ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────┐
    │Dev Laptop│  │GPU Node  │  │Modal     │  │CI Runner │
    │(Mitch)   │  │(Tailscale│  │(Burst)   │  │(Tailscale│
    └──────────┘  └──────────┘  └──────────┘  └──────────┘

┌─────────────────────────────────────────────────────────────────────┐
│                    MAINFRAME INTERNAL STACK                         │
├─────────────────────────────────────────────────────────────────────┤
│ Caddy RP │ PostgreSQL │ Redis │ Hermes GW/API │ Prometheus/Grafana │
│ Infisical│ Vaultwarden│ MinIO │   (Tavily)    │   (Backups)        │
└─────────────────────────────────────────────────────────────────────┘

3. Implementation Phases

Phase 0: Security Hardening — Before anything else

StepActionCommand / Config
0.1Create service useruseradd -m -s /bin/bash prodg
0.2Add Mitch SSH key to prodg userCopy /root/.ssh/authorized_keys → /home/prodg/.ssh/
0.3Set hostnamehostnamectl set-hostname mainframe.prodg.studio
0.4Activate ufwufw default deny incoming, ufw allow ssh, ufw allow http, ufw allow https, ufw enable
0.5Harden SSHPasswordAuthentication no, PermitRootLogin prohibit-password, PubkeyAuthentication yes
0.6Install & configure fail2banapt install fail2ban, jail for ssh
0.7Auto-updatesapt install unattended-upgrades, configure 50unattended-upgrades

Validation: ss -tlnp shows only 22/80/443 externally; ufw status verbose confirms default deny.


Phase 1: Container Runtime & Compose Stack

StepActionRationale
1.1Install Docker CE + Compose pluginOfficial repo for latest compose
1.2Add prodg user to docker groupNon-root container management
1.3Verify with docker run hello-worldSanity check
1.4Create /opt/prodg/compose/Central stack definitions
1.5Create /opt/prodg/data/Persistent data volumes
1.6Create /opt/prodg/backups/Backup staging

Validation: docker compose version returns v2.x; docker ps works as prodg user.


Phase 2: Tailscale Mesh (Headscale Control Server)

The mainframe hosts the Headscale control plane. All nodes (dev laptop, GPU nodes, CI) join this Tailnet.

StepActionDetails
2.1Create Headscale directories/opt/prodg/compose/headscale/{config,data}
2.2Write config.yamlserver_url: https://headscale.prodg.studio; listen_addr: 0.0.0.0:8080; magic_dns: true; base_domain: prodg.studio
2.3Deploy Headscale via Docker ComposeImage headscale/headscale:latest
2.4Create initial userheadscale users create prodg
2.5Generate pre-auth keyheadscale preauthkeys create --user prodg --reusable --expiration 30d
2.6Install Tailscale client on mainframecurl -fsSL https://tailscale.com/install.sh | sh
2.7Join mainframe to Tailnettailscale up --login-server https://headscale.prodg.studio --authkey <preauth-key>
2.8Enable IP forwardingsysctl -w net.ipv4.ip_forward=1, net.ipv6.conf.all.forwarding=1

Key ports: Headscale control (8080/tcp), DERP/STUN (3478/udp).

Validation: tailscale status shows mainframe; headscale nodes list returns entries.


Phase 3: Data Layer (PostgreSQL 16 + Redis 7 + MinIO)

3.1 PostgreSQL 16

PropertyValue
Containerpostgres:16-alpine
Data dir/opt/prodg/data/postgres/
Databaseshermes, agents, infisical
NetworkTailscale IP only
BackupsDaily pg_dump → /opt/prodg/backups/

3.2 Redis 7

PropertyValue
Containerredis:7-alpine
UseHermes cache, agent queue broker
PersistenceAOF + RDB
PasswordVia Docker secret

3.3 MinIO

PropertyValue
Containerminio/minio:latest
Bucketsprodg-artifacts, prodg-logs, prodg-backups
UseS3-compatible local object store
ConsoleTailscale-only via Caddy

Phase 4: Secrets & Password Management

4.1 Infisical (Self-Hosted)

  • Image: infisical/infisical:latest-postgres
  • Database: Uses the shared PostgreSQL instance (DB infisical)
  • Use: Structured secrets for services (Tavily, B2, API keys)
  • Access: Tailscale-internal at secrets.mainframe.prodg.studio

4.2 Vaultwarden (Self-Hosted)

  • Image: vaultwarden/server:latest
  • Data: /opt/prodg/data/vaultwarden/
  • Use: Team password manager (Bitwarden-compatible)
  • Access: Tailscale-internal at vault.mainframe.prodg.studio

First Migration: Move the Tavily key and B2 key from plaintext chat into Infisical vaults immediately after deployment.


Phase 5: Hermes Mainframe Hardening

StepActionDetails
5.1Update Hermeshermes update (16 commits behind)
5.2Enable web toolsetweb backend → Tavily
5.3Configure TavilyTAVILY_API_KEY=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
5.4Enable core toolsetsfile, terminal, browser, web
5.5Configure fallback modelOpenRouter anthropic/claude-sonnet-4
5.6Enable API serverAPI_SERVER_HOST=0.0.0.0, API_SERVER_KEY=<strong-secret>; bind to Tailscale IP only
5.7Move Hermes to Docker ComposeUse existing docker-compose.yml with UID/GID mapping
5.8Mount persistent volumes~/.hermes:/opt/data, Docker socket for container ops

Hermes API Routing:

  • API server listens on Tailscale IP (100.x.x.x:8000)
  • Caddy reverse-proxies api.mainframe.prodg.studio → Tailscale IP:8000
  • No public internet exposure for API

Phase 6: Reverse Proxy & Ingress (Caddy)

ServiceExposureCaddy Route
Hermes DashboardTailscale onlydash.mainframe.prodg.studio
Hermes APITailscale + mTLSapi.mainframe.prodg.studio
Headscale UITailscale onlyheadscale.prodg.studio
GrafanaTailscale onlymetrics.mainframe.prodg.studio
MinIO ConsoleTailscale onlys3.mainframe.prodg.studio
InfisicalTailscale onlysecrets.mainframe.prodg.studio
VaultwardenTailscale onlyvault.mainframe.prodg.studio

Why Caddy: Auto HTTPS (Tailscale certs), HTTP/3, simple config.


Phase 7: Observability

ComponentStackPurpose
MetricsPrometheus + node_exporter + cadvisorCPU, RAM, disk, network, container stats
LogsPromtail + LokiCentralized log aggregation
DashboardsGrafanaPre-built dashboards
AlertingGrafana Alerting → TelegramHigh CPU, disk full, service down

Phase 8: Multi-Agent Orchestration

Agent Registry: PostgreSQL table agents tracking agent_id, name, tailscale_ip, capabilities[], trust_tier, last_heartbeat, status.

Trust Tiers:

TierAgentsRuntime
TrustedResearch, Infra, Internal ToolsDocker containers on mainframe
UntrustedExternal code review, sandboxed tasksRemote Tailscale nodes
BurstLLM inference, media generationModal / Daytona ephemeral

Inter-Agent Communication:

  • Synchronous: Hermes delegate_task → ACP subagents
  • Asynchronous: Redis pub/sub per agent topic
  • Persistent: PostgreSQL job queue

Phase 9: Backup & Disaster Recovery

DataFrequencyTargetMethod
~/.hermes/HourlyMinIO prodg-backupsrestic
PostgreSQLDailyMinIO + Backblaze B2pg_dump + restic
RedisHourlyMinIOredis-cli --rdb
Headscale DBDailyMinIO + B2Volume snapshot
VaultwardenDailyMinIO + B2rsync + restic

Offsite: Backblaze B2 bucket prodg-mainframe-backups using restic with B2 App Key.


4. Port & Service Matrix

PortProtocolServiceExposure
22TCPSSHPublic (fail2ban hardened)
80TCPCaddy HTTP redirectPublic
443TCPCaddy HTTPSPublic
8080TCPHeadscale controlPublic (mTLS/auth)
3478UDPHeadscale DERP/STUNPublic
5432TCPPostgreSQLTailscale only
6379TCPRedisTailscale only
9000TCPMinIO S3 APITailscale only
9001TCPMinIO ConsoleTailscale only
9090TCPPrometheusTailscale only
3000TCPGrafanaTailscale only
8000TCPHermes APITailscale + API key only
8081TCPHermes DashboardTailscale only

5. Files Likely to Change

  • ~/.hermes/config.yaml — toolsets, Tavily provider, fallback model
  • /opt/prodg/compose/docker-compose.yml — full stack definition
  • /opt/prodg/compose/Caddyfile — reverse proxy routes
  • /opt/prodg/compose/headscale/config.yaml — Tailnet control plane
  • /etc/ssh/sshd_config — SSH hardening
  • /etc/fail2ban/jail.local — brute-force protection
  • /opt/prodg/scripts/backup.sh — automated backup orchestration

6. Success Criteria

The mainframe is fully operational when:

  • [ ] ufw active; only 22/80/443 public; DBs Tailscale-internal.
  • [ ] Headscale running; mainframe joined; Mitch's laptop can tailscale ping it.
  • [ ] docker compose ps shows healthy containers for Postgres, Redis, Caddy.
  • [ ] Hermes web toolset uses Tavily and returns grounded results.
  • [ ] Hermes API answers authenticated requests only from Tailscale IPs.
  • [ ] Infisical and Vaultwarden accessible via Tailscale DNS.
  • [ ] Grafana displays node + Docker metrics.
  • [ ] Nightly backups run to B2; restore test passes.
  • [ ] A delegate_task to a trusted on-box agent succeeds; an untrusted task can target Modal.

End of Plan v2.0