Files
docs/INFRASTRUCTURE.md
T
2026-09-29 08:23:52 +00:00

478 lines
36 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Infrastructure Specification
**Status:** As built — production live (silent launch 2026-09-25), first customer pilot 2026-09-30
**Authors:** Sharang, Benjamin
**Date:** 2026-05-11 (topology lock 2026-05-18; cluster split 2026-06-30; revised 2026-09-11; **as-built update 2026-09-29**)
**Companion docs:** PLATFORM_ARCHITECTURE.md, IMPLEMENTATION_PLAN.md, COST_PLAN.md, `BreakPilot Infra/Infrastructure Architecture` (both clusters, service catalog, backup runbook)
**Cloud provider:** Hetzner Cloud (EU, Germany) + Hetzner Object Storage (nbg1). DNS and mail at Strato.
---
> **2026-09-29 — as built.** The design of 2026-09-11 stands: the core cluster (`breakpilot`) is company infrastructure only, and the platform cluster (`breakpilot-platform`) carries staging and production on separate VMs. What changed on the way: production is a **CPX42** joined over **WireGuard** (no Hetzner private network), production images are **pinned by digest** and promoted by PR (no prod webhooks), backups on both clusters are **age-encrypted**, customer docs live on `docs[-stage].breakpilot.com`, and staff sign in to `/admin` with their **company account**. Sections 1–5, 8 and 12–14 describe the live state; 6, 7 and 9–11 are the targets they are measured against.
## 1. Cluster and VM Inventory
```
┌──────────────────────┬─────────────────────┬───────┬──────────────────────────────┬─────────────────┬────────────────────────────────┐
│ Node │ Cluster │ Env │ Size │ Public IP │ Role │
├──────────────────────┼─────────────────────┼───────┼──────────────────────────────┼─────────────────┼────────────────────────────────┤
│ breakpilot-infra-vm1 │ breakpilot (core) │ core │ 12 vCPU / 22 GB, 451 GB │ 46.225.100.82 │ master · identity, git, images │
│ ubuntu-16gb-fsn1-1 │ breakpilot (core) │ core │ 8 vCPU / 15 GB, 301 GB │ 178.105.159.224 │ agent · ERP, files, CI runner │
│ bp-platform-stage │ breakpilot-platform │ stage │ CPX32 4 vCPU / 8 GB, 150 GB │ 178.105.223.117 │ MASTER · all *-stage services │
│ bp-platform-prod │ breakpilot-platform │ prod │ CPX42 8 vCPU / 16 GB │ 46.225.108.74 │ agent · all *-prod services │
│ (dev) │ — │ dev │ laptop docker-compose │ n/a │ local development │
└──────────────────────┴─────────────────────┴───────┴──────────────────────────────┴─────────────────┴────────────────────────────────┘
All nodes: Orca 0.3.0-rc.6, Docker, no swap.
```
**Why this topology**
- **Core stays where it is.** Keycloak, Gitea, Harbor, ERPNext, LiteLLM, Infisical, SigNoz, Nextcloud, chat and the website are company infrastructure. Nothing customer-facing shares a node with them (the dsms stack is the one temporary exception, M-MIG-9).
- **One platform cluster, one node per environment.** Orca pins services to a node (`placement.node`) but has no environments or label scheduling. Separate VMs give staging and production physical isolation; separate Orca projects, service names, realms, databases and secret scopes give logical isolation.
- **The staging VM is the cluster master**; production joined as an agent on 2026-09-23. Unpinned services would land on the master, so `validate.sh` rejects them.
- **Per-node ingress.** Every node binds 80/443 and issues its own certificates (HTTP-01). A hostname's A record points at the node running the service. No wildcard, no DNS-01.
---
## 2. Service-to-Node Mapping
### Core cluster (`sharang/orca-infra`)
```
breakpilot-infra-vm1 (master, 46.225.100.82)
keycloak + db auth.breakpilot.com realms: master, breakpilot, breakpilot-stage, breakpilot-prod, breakpilot-dev (legacy)
gitea + db git.breakpilot.com (+ SSH :22222)
harbor (9 svcs) repo.breakpilot.com projects: breakpilot, pruefwerk, firmwerk, platform, observability, infra, certifai (legacy)
litellm + db/redis llm.breakpilot.com + searxng (internal, Werkpilot web search via /v1/search)
infisical + db/redis secrets.breakpilot.com
gatus status.breakpilot.com groups incl. "Platform Staging" and "Platform Production"
synapse + proxy + db chat.breakpilot.com + coturn
landing + kontakt-relay breakpilot.com, www.
otel-agent-master, vuln-watch-master
[until M-MIG-9] breakpilot-dsms (12 svcs, incl. pitch.breakpilot.com) · compliance-mcp · certifai-mongo
ubuntu-16gb-fsn1-1 (agent, 178.105.159.224)
erpnext stack (9 svcs) erp.breakpilot.com + Frappe CRM + Helpdesk; wired to registry-prod (webhooks, Usage Record)
nextcloud + collabora cloud.breakpilot.com, collabora.
signoz + clickhouse signoz.breakpilot.com, otel.breakpilot.com
element, jitsi, penpot element., meet., design.breakpilot.com
kellnr crates.breakpilot.com
otel-agent-workhorse, vuln-watch-workhorse
gitea-act-runner (plain container, not Orca) — the ONLY CI runner
[until M-MIG-9] tenant-registry-dev + db
```
### Platform cluster (`platform/orca-platform`)
```
bp-platform-prod (agent, 46.225.108.74, CPX42 16 GB) ≈ 8.8 GiB committed
project platform-prod
portal-prod app.breakpilot.com 768 MiB tenants /<slug>, staff /admin
tenant-registry-prod registry.breakpilot.com 512 MiB licences, ERP link (live erp.breakpilot.com)
pg-prod internal, volume 1 GiB dump hook + 02:30 cron
docs-prod docs.breakpilot.com 64 MiB VitePress, DE + EN
project pruefwerk-prod
pruefwerk-dashboard-prod pruefwerk.breakpilot.com 640 MiB
pruefwerk-agent-prod internal 3 GiB
pruefwerk-mcp-prod pruefwerk.breakpilot.com/mcp 256 MiB
pruefwerk-mongo-prod internal, volume 1.5 GiB
project firmwerk-prod
firmwerk-cloud-prod firmwerk.breakpilot.com 384 MiB
firmwerk-mongo-prod internal, volume 512 MiB
otel-agent-prod 192 MiB
bp-platform-stage (master, 178.105.223.117, CPX32 8 GB) ≈ 6.5 GiB committed
project platform-stage portal-stage (app-stage.), tenant-registry-stage (registry-stage.), pg-stage,
docs-stage (docs-stage.), erpnext-mock-stage (internal, stage only)
project pruefwerk-stage dashboard (pruefwerk-stage.), agent 1.25 GiB, mcp (/mcp), docs (/docs), mongo 768 MiB,
werkbank-runner-stage (stage only)
project firmwerk-stage firmwerk-cloud-stage (firmwerk-stage.), firmwerk-mongo-stage
otel-agent-stage
NOT deployed anywhere yet (need more memory): browserless (Chrome), soft-PLC, PLC-sim.
Prüfwerk runs PW_FEATURES=source_only on both environments (no DAST, pentest, PLC runtime).
```
Per-service detail (images, memory): `BreakPilot Infra/Infrastructure Architecture/Service Catalog`.
### Calls from the platform cluster into core (all HTTPS, public hostnames)
```
→ auth.breakpilot.com OIDC, JWKS, admin API (tenant-registry-svc-{env}); staff via the company-realm broker
→ erp.breakpilot.com ERPNext REST + inbound webhooks (prod only; stage uses the mock)
→ repo.breakpilot.com image pulls (docker login per node)
→ llm.breakpilot.com LiteLLM (Prüfwerk triage, Werkpilot, portal assistant)
→ otel.breakpilot.com traces, logs, metrics
→ smtp.strato.de noreply@breakpilot.com (registry mails, Keycloak invites)
← git.breakpilot.com CI calls the stage master's signed webhook (stage only)
```
### Stage isolation (enforced by the platform, not by product code)
| Risk | Enforcement | Status |
|---|---|---|
| Stage writes to prod data | Separate VM, Orca projects and project-scoped secrets; prod values never global (`scripts/prod-secrets.sh` checks the project scope). | in place |
| Stage mails real customers | Stage realm and registry send only for test workspaces; Strato does not deliver plus addresses, so real mailboxes are used for tests. | in place |
| Stage creates real ERP records | Stage has no ERPNext credentials; `ERP_BASE_URL` points at `erpnext-mock-stage`. | in place |
| Stage JWT used in prod | Different realm → different issuer; services pin `iss` and `aud`. | in place |
| Stage load hurts prod | Different VM; shared Keycloak and LiteLLM. | in place |
| Stage CI deploys prod | Prod has **no webhooks and no `:latest`**; only a merged promotion PR changes a prod image (by digest). Orca tokens are still cluster-wide (RISK-2). | in place |
---
## 3. Network Topology
```
INTERNET
│ (breakpilot.com at Strato — manual A records, no wildcard)
┌──────────────────────────────┼──────────────────────────────┬──────────────────────────────┐
┌──────▼──────────────┐ ┌───────────▼──────────┐ ┌───────────────▼───────┐ ┌─────────────▼─────────┐
│ CORE master │ │ CORE workhorse │ │ bp-platform-stage │ wg0 │ bp-platform-prod │
│ 46.225.100.82 │ │ 178.105.159.224 │ │ 178.105.223.117 │◄──────►│ 46.225.108.74 │
│ auth git repo llm │ │ erp cloud signoz │ │ app-stage registry- │10.66.0.1 10.66.0.2 │
│ secrets status chat │ │ meet design crates │ │ stage pruefwerk-stage │ UDP │ app registry │
│ breakpilot.com │ │ element collabora │ │ firmwerk-stage docs- │ 51820 │ pruefwerk firmwerk │
│ pitch *-dev.ai │ │ otel (CI runner) │ │ stage │ │ docs │
└─────────────────────┘ └──────────────────────┘ └───────────────────────┘ └───────────────────────┘
Master ↔ agent: WireGuard wg0 only (Orca's agent channel is plain ws:// and carries resolved secrets).
The agent announces "bp-platform-prod:6881" → the stage master has /etc/hosts 10.66.0.2 bp-platform-prod.
Firewall
bp-platform-prod (ufw): 22, 80, 443, 51820/udp; everything on wg0; drop the rest.
bp-platform-stage: 22, 80, 443; 6880 reachable for the CI webhook (HMAC-signed); WireGuard peer of prod.
Ingress (per node, Orca proxy, HTTP-01)
prod: app. → portal-prod:3000 · registry. → tenant-registry-prod:8090 · docs. → docs-prod
pruefwerk. → dashboard-prod, /mcp/* → mcp-prod (strip_prefix) · firmwerk. → firmwerk-cloud-prod
stage: the same with -stage, plus pruefwerk-stage…/docs/* → pruefwerk-docs-stage
Cross-node traffic: Docker networks are node-local; nothing talks stage ↔ prod by design.
```
DNS at Strato (all set): stage `app-stage`, `registry-stage`, `pruefwerk-stage`, `firmwerk-stage`, `docs-stage` → `178.105.223.117`; prod `app`, `registry`, `pruefwerk`, `firmwerk`, `docs` → `46.225.108.74`. There is no `licence.` host: the licence endpoint is part of the registry.
---
## 4. Storage
```
┌────────────────────┬──────────────────────────────────────────────────────────┬───────────────────────────┐
│ Node │ Data stores (Docker volumes orca-*) │ Disk │
├────────────────────┼──────────────────────────────────────────────────────────┼───────────────────────────┤
│ bp-platform-stage │ pg-stage, pruefwerk-mongo-stage, firmwerk-mongo-stage │ local 150 GB (46 %) │
│ bp-platform-prod │ pg-prod, pruefwerk-mongo-prod, firmwerk-mongo-prod │ local NVMe; Hetzner │
│ │ │ Volume when > 60 % │
└────────────────────┴──────────────────────────────────────────────────────────┴───────────────────────────┘
Object storage (Hetzner, nbg1):
s3://bp-platform-backups nightly backups of the platform cluster (age-encrypted, 30 days)
s3://bp-docs-stage|prod customer documents ("Unterlagen"), private, 5-minute signed download links
s3://bp-downloads CLI releases + checksums (public read) for /install/{firmwerk,werkpilot}
s3://bp-rag dsms RAG data (moves with dsms)
core: bp-orca-backups, bp-harbor-registry, bp-gitea-packages, bp-kellnr-*, bp-nextcloud
```
**MongoDB and open files:** Docker's default limit of 1024 open files is too low for Prüfwerk's Mongo (one WiredTiger file per collection and index across all tenant databases). The mongo services start through `bash -c "ulimit -n 64000 && exec docker-entrypoint.sh mongod"` (orca has no ulimit setting): staging since 2026-09-28, production with the next promotion.
---
## 5. Backup Requirements
Orca-native backups per cluster: nightly at 03:00, local copy + S3, **age-encrypted** (private key offline in KeePass). Consistent logical dumps (`pg_dumpall`, `mongodump`, `mariadb-dump`) land in each database volume first — through the `pre_hook`s and, on the platform nodes, `scripts/db-dumps.sh` from cron at 02:30. Retention: core 14 days, platform 30 days (staging included).
```
┌──────────────────────────────┬──────────────────────────┬────────────┬───────────┬────────────────────┐
│ Data store │ Method │ Frequency │ Retention │ Status │
├──────────────────────────────┼──────────────────────────┼────────────┼───────────┼────────────────────┤
│ keycloak-db (core) │ pg_dumpall pre_hook │ nightly │ 14 d │ in place │
│ keycloak realm definitions │ orca-platform/keycloak/ │ on change │ git │ in place (partial │
│ │ *.json + scripts │ │ │ export + scripts) │
│ gitea-db + repos (core) │ pre_hook + volume │ nightly │ 14 d │ in place │
│ harbor (core) │ db pre_hook; images │ nightly │ 14 d │ in place │
│ erpnext mariadb (core) │ mariadb-dump pre_hook │ nightly │ 14 d │ in place │
│ pg-prod (tenant-registry) │ pg_dumpall hook + cron │ nightly │ 30 d │ in place; drilled │
│ pruefwerk-mongo-prod │ mongodump hook + cron │ nightly │ 30 d │ in place; drilled │
│ firmwerk-mongo-prod │ mongodump hook + cron │ nightly │ 30 d │ in place │
│ documents (bp-docs-prod) │ S3 (Hetzner) │ — │ — │ single copy │
│ stage * │ same as prod │ nightly │ 30 d │ in place │
│ Orca config (IaC) │ Gitea │ on commit │ forever │ in place │
└──────────────────────────────┴──────────────────────────┴────────────┴───────────┴────────────────────┘
```
**Drills:** `pg-stage` 2026-09-12; production Postgres and Mongo 2026-09-24/25 — both restored into scratch containers. **Open:** the 6-hourly pg-prod dump for RPO ≤ 6 h is not set up yet (nightly only: RPO ≤ 24 h today); a second storage provider (3-2-1); a copy of the uploaded documents outside the bucket.
### RPO by data criticality (targets)
```
CRITICAL (RPO ≤ 6h) keycloak-db · pg-prod (tenants, subscriptions, licences, audit) · erpnext mariadb
IMPORTANT (RPO ≤ 24h) pruefwerk-mongo-prod · firmwerk-mongo-prod · customer documents
RECOVERABLE harbor images (CI) · gitea (mirrored on laptops) · docs site (built from git)
NOT BACKED UP redis caches · scan working copies (/tmp in the agent)
```
---
## 6. Constraint Framework
Constraint types (AVAILABILITY, RTO, RPO, IaC, SECRET_HYGIENE, NETWORK, DATA_RESIDENCY, AUDIT_TRAIL, IMMUTABILITY, STAGE_ISOLATION) are unchanged. Planes remain the **SLA + ownership abstraction**; clusters and nodes are the **operational unit**.
```
╔════════════════════════════════════════════════════════════════════════════════════════╗
║ IDENTITY PLANE (core cluster, breakpilot-infra-vm1) ║
║ AVAILABILITY ≥ 99.5% (root dependency of both environments) · RTO ≤ 15 min ║
║ AUDIT_TRAIL realm events · DATA_RESIDENCY EU · STAGE_ISOLATION separate realms ║
║ Note: one Keycloak instance serves company SSO + both platform realms (RISK-3). ║
╠════════════════════════════════════════════════════════════════════════════════════════╣
║ CONTROL PLANE (platform cluster, per env node) ║
║ RPO (tenant registry) ≤ 6h · RPO (ERPNext, core) ≤ 24h · AUDIT_TRAIL portal actions ║
║ AVAILABILITY portal ≥ 99.5%, registry ≥ 99.5%, ERPNext ≥ 99% (internal) ║
║ RTO portal ≤ 10 min · registry ≤ 5 min · ERPNext ≤ 60 min ║
║ ERP LINK: outbox depth < 100 and reconcile age < 30 min are SLOs (alerted) ║
╠════════════════════════════════════════════════════════════════════════════════════════╣
║ APP PLANE (platform cluster, per env node) ║
║ DATA_RESIDENCY EU · DATA_ISOLATION per-tenant DB or tenant_id on every query ║
║ AVAILABILITY Prüfwerk ≥ 99.5%, Firmwerk cloud ≥ 99.5%, licence endpoint ≥ 99.9% ║
║ (CLIs tolerate 30 days of licence-endpoint outage by design) ║
║ Co-tenant note: the prod node is the scale driver; bump flavor at 80% RAM. ║
╠════════════════════════════════════════════════════════════════════════════════════════╣
║ INFRA PLANE (both clusters) ║
║ BACKUP per cluster bucket · IaC all services in Gitea · IMMUTABILITY git → orca deploy║
║ SECRET_HYGIENE project-scoped Orca secrets, Infisical for signing keys ║
║ NETWORK per-node ingress, host firewall, WireGuard wg0 for master↔agent ║
║ DATA_RESIDENCY Hetzner DE · COLD_START ordering (§10 F) · STAGE_ISOLATION (§2) ║
╚════════════════════════════════════════════════════════════════════════════════════════╝
```
---
## 7. SLA Table
```
┌────────────────────────────┬──────────────┬─────────┬─────────┬──────────────────────────────┐
│ Service │ Availability │ RTO │ RPO │ Node │
├────────────────────────────┼──────────────┼─────────┼─────────┼──────────────────────────────┤
│ Keycloak │ 99.5% │ 15 min │ 6h │ core master (root auth dep) │
│ Harbor │ 99% │ 30 min │ 24h │ core master (deploys only) │
│ Gitea │ 99% │ 2h │ 24h │ core master │
│ LiteLLM │ 99% │ 5 min │ N/A │ core master (soft dep) │
│ ERPNext + Helpdesk │ 99% │ 60 min │ 24h │ core workhorse (internal) │
│ Customer Portal │ 99.5% │ 10 min │ N/A │ platform prod │
│ Tenant Registry + licences │ 99.9% │ 5 min │ 6h │ platform prod │
│ pg-prod │ 99.9% │ 20 min │ 6h │ platform prod (RISK-4) │
│ Prüfwerk (dashboard/agent) │ 99.5% │ 10 min │ 24h │ platform prod │
│ Prüfwerk MCP │ 99.5% │ 10 min │ N/A │ platform prod │
│ Firmwerk cloud-server │ 99.5% │ 10 min │ 24h │ platform prod │
│ Werkbank runner │ 99% │ 30 min │ N/A │ platform prod (stateless) │
│ stage (any service) │ 95% │ best ef.│ 7d │ platform stage (no SLA) │
└────────────────────────────┴──────────────┴─────────┴─────────┴──────────────────────────────┘
```
Measured via `status.breakpilot.com` (Gatus, 3-fail, 30-day rolling) per `Breakpilot SKU + SLA`.
---
## 8. IaC Constraint (Orca)
Every platform service is declared in `platform/orca-platform`, every core service in `sharang/orca-infra`. No exceptions (the Gitea runner on the workhorse is the one container outside Orca).
```
1. ALL containers run via Orca service files committed to Gitea
→ platform: services/<project>/service.toml (one [[service]] per container)
→ config changes: PR → CI (validate.sh, gitleaks) → merge → the master pulls and deploys (push hook)
2. EVERY platform service is pinned: [service.placement] node = "bp-platform-stage" | "bp-platform-prod"
→ validate.sh fails the PR otherwise; it also rejects :latest on -prod and fixture mode on stage
3. Service names are unique cluster-wide and suffixed by environment (-stage / -prod)
4. Secrets are project-scoped: `orca secrets set --project <p> KEY value`
→ production values are NEVER set globally (project secrets fall back to global)
→ scripts/prod-secrets.sh sets the prod keys and checks the project section, not the fallback
5. resources.memory on every service (validate.sh)
6. Images
→ staging: product CI pushes :sha-<short> and :latest to Harbor, then calls the signed webhook
(orca redeploy <svc>-stage)
→ production: no webhooks, no :latest. scripts/promote.sh reads the digest staging runs and writes
image = "<repo>@sha256:…" into services/*-prod; the PR is merged only after the founder's go
→ releases: platform v0.1.0 (portal, tenant-registry, product-docs, 2026-09-29) goes to production
together with Prüfwerk v0.4.x
7. NO manual docker run / compose on any node. SSH for debugging only. Every node has
`docker login repo.breakpilot.com` done once at provisioning.
8. Keycloak realms (core instance) are changed by scripts, reviewed in orca-platform and run on the
core master: scripts/import-realm.sh (realm + settings a partial export lacks), scripts/staff-sso.sh
(company-realm broker for staff)
9. Orca state is recoverable: service files in Gitea = desired state; losing a master = reinstall Orca,
restore ~/.orca (age key needed), `orca deploy`. After `systemctl restart orca`, run `orca deploy`.
```
---
## 9. Dependency Graph
```
EXTERNAL AI APIs
│ (soft)
▼
┌───────────────────── CORE cluster ─────────────────────────────────────────┐
│ keycloak-db ─► keycloak harbor litellm infisical erpnext │
│ │ │ │ │ │ │
└─────────────────────┼───────────┼────────────┼───────────┼───────────┼──────┘
JWKS/OIDC ────┘ images ──┘ LLM ─────┘ signing ─┘ REST+webhooks (prod)
▼ ▼
┌───────────────────── PLATFORM cluster · one node per env ──────────────────┐
│ pg-{env} ──► tenant-registry-{env} ◄──── erpnext-mock (stage) / erp (prod)│
│ │ entitlements/check, api-keys/verify, usage, licences│
│ ├──► portal-{env} │
│ ├──► pruefwerk-agent ◄── pruefwerk-mongo, browserless, │
│ │ │ soft-plc, plc-sim │
│ │ ├──► pruefwerk-dashboard, pruefwerk-mcp, docs │
│ │ └──► werkbank-runner (leases jobs) │
│ └──► firmwerk-cloud ◄── firmwerk-mongo │
│ CLIs (customer machines) ──► licence endpoint on tenant-registry │
└────────────────────────────────────────────────────────────────────────────┘
```
Critical path (customer login → product use): Strato DNS → node ingress → portal → Keycloak (core) → tenant-registry → product host → Keycloak (SSO) → product → tenant-registry (`entitlements/check`, cached).
---
## 10. Failure Scenarios
### A — Core master (Keycloak, Harbor, Gitea, LiteLLM) fails — HIGHEST SEVERITY
```
Impact: No new logins on either environment (JWTs expire within the access-token TTL); no deploys;
no LLM features. Running product sessions continue until token expiry. CLIs keep working
on their licence tokens (30-day ladder). ERPNext (workhorse) unaffected.
Recovery: Restore VM / Orca on the core master from Hetzner snapshot + nightly backup. RTO target 15 min.
Mitigation: Hetzner snapshot schedule for the core master; runbook; RISK-1.
```
### B — bp-platform-stage (cluster master) fails
```
Impact: Staging down. Production containers keep running but cannot be deployed/redeployed;
webhooks 503 until the master is back. No customer impact.
Recovery: Rebuild VM, reinstall Orca, restore ~/.orca, `orca deploy`; prod agent re-joins. RTO 30 min.
Mitigation: RISK-2; consider a small dedicated control VM at Tier B.
```
### C — bp-platform-prod fails
```
Impact: All products, portal, registry and licence endpoint down for production.
CLIs degrade along the ladder only after 7 days without heartbeat.
Recovery: Rebuild from snapshot + nightly backup; re-join; redeploy. RTO 30 min, RPO ≤ 6h for pg-prod.
Mitigation: Hetzner snapshots; tested restore drill (M-MIG-8); RISK-4.
```
### D — LiteLLM fails: Prüfwerk LLM triage and Werkpilot degrade; scans and CRUD unaffected. Soft.
### E — Stage compromised or buggy: nothing reaches prod (separate VM, realm, secrets, mock ERP). Roll back image. RISK-5.
### F — Cold start (platform node): databases → tenant-registry (needs Keycloak up on core) → portal, products. Orca `depends_on` + health checks; 3–5 min. Core cold start unchanged from the as-built runbook.
### G — Tenant Registry fails
```
Impact: Portal tenant lookup fails (cached 60 s); products' entitlement cache expires after 60 s
→ they fail CLOSED (deny) per contract §9.1; licence heartbeats fail (ladder tolerates 7 days);
usage events buffered client-side and retried.
Recovery: Restart; pg-{env} must be healthy. RTO ≤ 5 min.
```
### H — ERPNext down or unreachable from the platform
```
Impact: NO customer impact. Outbox accumulates (customer upserts, leads, usage records); webhooks
are not received; the ladder does not change. Backstage /system/erp-link alerts at
outbox depth > 100 or reconcile age > 30 min.
Recovery: ERPNext restore per core runbook; outbox drains; reconcile repairs any missed webhook.
```
---
## 11. Cross-Dependency Summary
```
Needs → │ KC │ pg-env │ mongo │ registry │ ERP │ LiteLLM │ Harbor │ Infisical │
─────────────────────┼────┼────────┼───────┼──────────┼─────┼─────────┼────────┼───────────┤
tenant-registry │ ● │ ● │ │ │ ◐ │ │ │ ◐ (licence key bootstrap) │
portal │ ● │ │ │ ● │ │ │ │ │
pruefwerk-agent │ ● │ │ ● │ ● │ │ ◐ │ │ │
pruefwerk-dashboard │ ● │ │ │ │ │ │ │ │
werkbank-runner │ │ │ │ ◐ │ │ │ │ │
firmwerk-cloud │ ● │ │ ● │ ● │ │ │ │ │
werkpilot (CLI) │ ◐ │ │ │ ◐ │ │ ● │ │ │
all (deploy time) │ │ │ │ │ │ │ ● │ │
● hard ◐ soft (degrades / cached / buffered)
```
---
## 12. Open Infrastructure Risks (Priority Order)
```
RISK-1 Core master is a single VM owning auth, git, image registry and LLM.
→ Hetzner snapshot schedule + tested restore; long-term: move Keycloak to its own node.
Priority: HIGH
RISK-2 The staging VM is the platform cluster's only control plane and Orca tokens are cluster-wide.
→ Production takes images only through promotion PRs (no prod webhooks); keep deployer tokens
out of CI; revisit a small dedicated control VM at Tier B.
Priority: MEDIUM
RISK-3 One Keycloak instance serves company SSO and both platform realms (and now brokers staff
logins into them). → realm changes only by reviewed scripts; RTO 15 min runbook.
Priority: MEDIUM
RISK-4 pg-prod is a single instance for tenants, subscriptions, licences and audit; nightly dumps only
(RPO ≤ 24 h, target ≤ 6 h). → add the 6-hourly dump; split audit at > 100 tenants.
Priority: MEDIUM
RISK-5 Stage isolation rests on the controls in §2. → periodic check: prod secret from a stage project,
stage JWT on prod. Priority: MEDIUM
RISK-6 ERPNext → registry webhooks have no guaranteed delivery. → outbox + idempotent receiver +
15-min reconcile, tested on staging (M-MIG-8). Note: ERPNext's queue workers carry the webhooks;
they were down 2026-09-26 (disk full on the workhorse) until repaired. Priority: LOW–MEDIUM
RISK-7 Orca project secrets fall back to global secrets. → no platform secrets set globally;
prod-secrets.sh checks the project scope. Priority: MEDIUM
RISK-8 Backups are single-provider (encryption solved: age, since orca 0.3.0-rc).
→ second S3 provider. Priority: MEDIUM
RISK-9 Orca does not restart a container that exited (OOM kill, crash): it stays down until
`orca redeploy`. Seen on staging 2026-09-28 (tenant-registry OOM during uploads, since fixed).
→ size limits with headroom; Gatus alerts; health-based restarts in Orca. Priority: HIGH
RISK-10 Container defaults: Docker's open-files limit (1024) broke Mongo on staging 2026-09-28.
→ ulimit start wrapper on all mongo services (stage done, prod with the next promotion).
Priority: HIGH until prod has it, then LOW
RISK-11 One CI runner on the workhorse: serialises all repositories and fills the workhorse disk
(disk-full 2026-09-26). → second runner / own build VM; build-cache pruning. Priority: MEDIUM
RISK-12 LiteLLM calls external AI APIs; intermittent 502s slow Prüfwerk's triage on large repositories.
→ fallback routing; triage cap and parallelism (Prüfwerk). Priority: LOW
```
---
## 13. Growth Trajectory
```
Tier A (launch, ≤ 50 cust): stage CPX32 + prod CPX42 (today)
next step on prod: 32 GB (browserless for DAST, dsms after M-MIG-9)
Tier B (50–200): bump prod flavor (dedicated cores); small control VM as Orca master (RISK-2);
Hetzner Volume for prod data; second S3 provider; second CI runner
Tier C (200–500): split prod: app node + db node (pg, mongo); Keycloak to its own core node
Tier D (500+): second prod app node (Orca pins per product), Hetzner LB in front
```
Each step is justified by a measurable signal (> 80 % RAM, > 70 % CPU, sustained queue depth, or a specific outage). Never split preemptively.
---
## 14. Cost summary
See `COST_PLAN.md`. Platform today: stage CPX32 + prod CPX42 + object storage; core cluster unchanged.
---
*End of document. As-built update 2026-09-29; review after the pilot and after any significant infrastructure change.*