Files
docs/INFRASTRUCTURE.md
T
Sharang ParnerkarandClaude Opus 5.5 734c3c68e9
ci / shared (pull_request) Successful in 11s
docs(infra): backup retention for local copies, S3 and the archive bucket
- platform local copies 30 days, infra local copies 3 days
- OVH backup objects expire after 30 days, deleted versions 7 days later
- bp-infra-archive-ovh: no expiry, DSMS and certifai only, no platform
  customer data

Refs: t74

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 09:18:50 +01:00

41 KiB
Raw Blame History

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; hosting update 2026-11-17) Companion docs: PLATFORM_ARCHITECTURE.md, IMPLEMENTATION_PLAN.md, COST_PLAN.md, BreakPilot Infra/Infrastructure Architecture (both clusters, service catalog, backup runbook) Cloud provider: OVHcloud Public Cloud, region DE1 (Frankfurt): platform cluster since 2026-10-17, core cluster since the 2026-11-05/06 window. Backups in OVH Object Storage (region DE) since 2026-11-06. Hetzner Object Storage (nbg1) still holds documents, receipts and artefacts. DNS at Hetzner DNS (OpenTofu, infra/ovh-tofu/dns); mail at Strato. Language models on OVH AI Endpoints (Gravelines, FR) behind our LiteLLM.


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.

2026-11-17 — hosting update. Both clusters moved from Hetzner Cloud to OVHcloud Public Cloud, DE1 (Frankfurt): the platform cluster on 2026-10-17, the core cluster in the window of 2026-11-05/06 (sign-off 2026-11-06). Node names stayed the same, so every placement.node still resolves; the old Hetzner nodes are retired (ovh-tofu #28). The nodes are defined in infra/ovh-tofu (OpenTofu), DNS for breakpilot.com/.ai/.de moved from Strato to Hetzner DNS (ovh-tofu/dns), and mail stays at Strato. Nightly backups go to OVH Object Storage (bp-<cluster>-backups-ovh, age-encrypted, 30-day lifecycle on platform). The portal documents and Reisekosten receipts are copied into it every night as well. Documents, receipts, Harbor image storage and Gitea packages stay in Hetzner Object Storage nbg1. LiteLLM sends model calls to OVH AI Endpoints in Gravelines (France); we run no models ourselves. Public SSH and the public orca API port 6880 are closed; admin SSH and deploy webhooks go over NetBird. Platform master and agent still talk over WireGuard wg0 (10.66.0.1/.2). This update changes hosting facts only; values marked to confirm are not verified yet.

1. Cluster and VM Inventory

┌──────────────────────┬─────────────────────┬───────┬──────────────────────────────┬─────────────────┬────────────────────────────────┐
│ Node                 │ Cluster             │ Env   │ Size                         │ Public IP       │ Role                           │
├──────────────────────┼─────────────────────┼───────┼──────────────────────────────┼─────────────────┼────────────────────────────────┤
│ breakpilot-infra-vm1 │ breakpilot (core)   │ core  │ OVH b3-16 + 100 GB backup vol│ 51.75.95.16     │ master · identity, git, images │
│ ubuntu-16gb-fsn1-1   │ breakpilot (core)   │ core  │ OVH r3-32                    │ 51.75.88.10     │ agent · ERP, files, CI runner  │
│ bp-infra-runner-1/-2 │ — (CI runners)      │ core  │ OVH c3-16 each               │ to confirm      │ Gitea Actions runners          │
│ bp-platform-stage    │ breakpilot-platform │ stage │ OVH c3-8                     │ 51.89.4.55      │ MASTER · all *-stage services  │
│ bp-platform-prod     │ breakpilot-platform │ prod  │ OVH c3-16                    │ 57.129.34.146   │ agent · all *-prod services    │
│ (dev)                │ —                   │ dev   │ laptop docker-compose        │ n/a             │ local development              │
└──────────────────────┴─────────────────────┴───────┴──────────────────────────────┴─────────────────┴────────────────────────────────┘
All nodes: OVHcloud Public Cloud DE1 (Frankfurt), Ubuntu 24.04, Docker. IPs from ovh-tofu dns/main.tf; flavors from the
ovh-tofu *.tfvars.example files (to confirm against the live state). Orca version after the move: to confirm.

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, 51.75.95.16)
  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, 51.75.88.10)
  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); whether it still runs next to the OVH runners: to confirm
  [until M-MIG-9] tenant-registry-dev + db

bp-infra-runner-1, bp-infra-runner-2 (OVH c3-16, NetBird)
  Gitea Actions runners for platform builds (ovh-tofu docs/ci-runners)

Platform cluster (platform/orca-platform)

bp-platform-prod (agent, 57.129.34.146, OVH c3-16)                   ≈ 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, 51.89.4.55, OVH c3-8)                      ≈ 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) → OVH AI Endpoints, Gravelines (FR)
→ 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 over NetBird (100.80.221.131:6880; 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 Hetzner DNS — OpenTofu, no wildcard)
       ┌──────────────────────────────┼──────────────────────────────┬──────────────────────────────┐
┌──────▼──────────────┐   ┌───────────▼──────────┐   ┌───────────────▼───────┐        ┌─────────────▼─────────┐
│ CORE master         │   │ CORE workhorse       │   │ bp-platform-stage     │ wg0    │ bp-platform-prod      │
│ 51.75.95.16         │   │ 51.75.88.10          │   │ 51.89.4.55            │◄──────►│ 57.129.34.146         │
│ 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 (OVH security group per cluster + ufw on the node)
  public:  80, 443; 51820/udp from the cluster's own nodes only. No public SSH (22) and no public 6880
           since 2026-11-06.
  NetBird: admin SSH, the orca agent link on infra, and the deploy webhooks to the stage master
           (http://100.80.221.131:6880, HMAC-signed); ufw allows everything on wt0.
  wg0:     platform master ↔ agent (stage 10.66.0.1, prod 10.66.0.2), unchanged by the move.

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 Hetzner DNS, managed in ovh-tofu/dns (delegated to the Hetzner nameservers; checked 2026-11-17): stage app-stage, registry-stage, pruefwerk-stage, firmwerk-stage, docs-stage → 51.89.4.55; prod app, registry, pruefwerk, firmwerk, docs → 57.129.34.146. 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 disk (to confirm)   │
│ bp-platform-prod   │ pg-prod, pruefwerk-mongo-prod, firmwerk-mongo-prod       │ local disk; block volume  │
│                    │                                                          │ when > 60 % (to confirm)  │
└────────────────────┴──────────────────────────────────────────────────────────┴───────────────────────────┘

Object storage (OVH, region DE, s3.de.io.cloud.ovh.net) — backups since 2026-11-06:
  s3://bp-platform-backups-ovh  nightly backups of the platform cluster (age-encrypted; objects expire after 30 days,
                                deleted versions 7 days later),
                                plus objects/<bucket>/: nightly copies of bp-docs-prod and bp-reisekosten-prod
                                (orca-platform scripts/object-backup.sh, 02:20 UTC on the stage master)
  s3://bp-infra-backups-ovh     nightly backups of the core cluster (lifecycle set by hand; values to confirm)
  s3://bp-infra-archive-ovh     last backups of the services taken offline at the move (DSMS, certifai);
                                no expiry; no platform customer data

Object storage (Hetzner, nbg1):
  s3://bp-docs-stage|prod     customer documents ("Unterlagen"), private, 5-minute signed download links
  s3://bp-reisekosten-*       Reisekosten receipts
  s3://bp-downloads           CLI releases + checksums (public read) for /install/{firmwerk,werkpilot} (to confirm)
  s3://bp-rag                 dsms RAG data (dsms is offline since the move; to confirm)
  core: breakpilot-harbor-registry, bp-gitea-packages (to move to OVH later); bp-kellnr-*, bp-nextcloud (to confirm)
  old backups: bp-orca-backups, bp-platform-backups — kept until the OVH buckets hold 30 days (≈ 2026-12-07)

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 + OVH Object Storage (since 2026-11-06), age-encrypted (private key offline in KeePass). Consistent logical dumps (pg_dumpall, mongodump, mariadb-dump) land in each database volume first — through the pre_hooks and, on the platform nodes, scripts/db-dumps.sh from cron at 02:30. Retention: local copies 30 days on platform (staging included), 3 days on infra. In OVH Object Storage, platform backups expire after 30 days and deleted versions go 7 days later, so a backup is gone at the latest 37 days after it was made (customer wording: "kept for 30 days and deleted within 7 days after that"). The infra bucket's lifecycle was set by hand (values to confirm). The archive bucket bp-infra-archive-ovh has no expiry; it holds only the DSMS and certifai backups, no platform customer data.

┌──────────────────────────────┬──────────────────────────┬────────────┬───────────┬────────────────────┐
│ Data store                   │ Method                   │ Frequency  │ Retention │ Status             │
├──────────────────────────────┼──────────────────────────┼────────────┼───────────┼────────────────────┤
│ keycloak-db (core)           │ pg_dumpall pre_hook      │ nightly    │ 3 d local │ 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    │ 3 d local │ in place           │
│ harbor (core)                │ db pre_hook; images      │ nightly    │ 3 d local │ in place           │
│ erpnext mariadb (core)       │ mariadb-dump pre_hook    │ nightly    │ 3 d local │ 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)     │ object-backup.sh → OVH   │ nightly    │ 30 d      │ in place           │
│ stage *                      │ same as prod             │ nightly    │ 30 d      │ in place           │
│ Orca config (IaC)            │ Gitea                    │ on commit  │ forever   │ in place           │
└──────────────────────────────┴──────────────────────────┴────────────┴───────────┴────────────────────┘
Retention column: platform rows are 30 days, locally and in S3 (deleted S3 versions go 7 days later). Core rows show the 3-day
local copy; their S3 retention follows the infra bucket's hand-set lifecycle (to confirm).

Drills: pg-stage 2026-09-12; production Postgres and Mongo 2026-09-24/25 — both restored into scratch containers. Object copy drill: a bp-reisekosten-prod snapshot restored into stage 2026-11-06 (bp-docs-prod was empty then; drill again once it holds documents). 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 for the database backups (3-2-1). No regular restore checks for the managed Gitea instances yet.

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 DE (OVH DE1, Hetzner nbg1), LLM FR · COLD_START §10 F · STAGE_ISOL. §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

               OVH AI Endpoints (Gravelines, FR)
                          │ (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): Hetzner 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 a snapshot + nightly backup. RTO target 15 min.
Mitigation: snapshot schedule for the core master on OVH (to confirm); 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: snapshots on OVH (to confirm); 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.
        → snapshot schedule (on OVH: to confirm) + 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  Database backups sit at the same provider as the databases (OVH; encryption solved: age).
        Documents live at Hetzner and are copied to OVH nightly. → second provider for the database
        backups. 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 CI capacity. Until the move one runner on the workhorse serialised all repositories and filled
        its disk (disk-full 2026-09-26). Two OVH runner VMs (bp-infra-runner-1/-2, pruning every 3 h)
        now carry the platform builds. → confirm the workhorse runner's role. Priority: MEDIUM

RISK-12 LiteLLM calls OVH AI Endpoints (single upstream); 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 c3-8 + prod c3-16 on OVH (today; flavors to confirm)
                             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);
                             block volume for prod data; second provider for the database backups
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), a load balancer 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 (not yet updated for OVH). Platform today: OVH stage + prod nodes, OVH backup storage, Hetzner object storage for documents and artefacts.


End of document. As-built update 2026-09-29, hosting update 2026-11-17; review after any significant infrastructure change.