# RFD 001: Frontier Architecture & Operational Invariants

How #CloudRING separates tenant state, object data planes, managed databases, hypervisor lifecycles, and cryptographic boundaries on a 3-node bare-metal cell without proprietary storage licenses or single-row bottlenecks.

> Sources: `docs/RFD-001-FRONTIER-ARCHITECTURE.md`, `docs/PR-FAQ.md`, and executable Z3 proofs in `docs/verification/frontier_invariants_z3.py`.

## 1. Per-tenant partitioned control-plane persistence

Early prototype control planes frequently serialize all tenants, secrets, alarms, and object payloads into one shared JSON document. A single-row document hits hard PostgreSQL row-size ceilings and creates global lock contention across unrelated tenants.

\#CloudRING partitions mutable tenant state across independent primary-keyed rows in `cloudring_state.documents` (`PRIMARY KEY (scope, document_key)`):

- Five isolated scopes per tenant: `portal-tenant-kv`, `portal-tenant-secrets`, `portal-tenant-tags`, `portal-tenant-alarms`, and `portal-tenant-metrics`.
- 64-way striped per-tenant locks and per-tenant compare-and-swap revisions so writes from tenant A never block or collide with tenant B.
- Zero demo fixture accounts, zero synthetic alerts, and zero placeholder diagnostics inside `NewProductionShell()`.
- Platform-scoped Alertmanager filtering (`IsPlatformAlert()`) excludes synthetic `Watchdog`, `InfoInhibitor`, `DeadMansSwitch`, and tenant workload alerts from platform SLO calculations.

## 2. Apache-2.0 SeaweedFS HA object data plane (zero bytes in PostgreSQL)

Storing S3 object bodies as base64 strings inside PostgreSQL limits object sizes to kilobytes and causes unbounded relational write amplification. At the same time, AGPLv3-licensed S3 servers introduce copyleft friction for independent European hosting operators.

\#CloudRING deploys an **Apache-2.0 SeaweedFS HA** cluster across all 3 bare-metal cell nodes:

- 3 Raft masters pinned one-per-node (`cloudring-ovh-node-1..3`).
- 3 volume servers tagged with `-rack=$(NODE_NAME)` and replication factor `010` (every volume is synchronously replicated across two distinct physical nodes, surviving any single-node outage without 10+4 erasure-coding overhead on a 3-node cell).
- 2 HA Filer + S3 gateway replicas backed by a shared 3-node CloudNativePG `[postgres2]` filer metadata store (zero local `leveldb2` split-brain across pods under N-1), fail-closed `"defaultEffect": "Deny"` IAM policy from Kubernetes Secrets, HTTP health probes, and a `*/15 * * * *` 3-master `volume.fix.replication` reconciliation CronJob.
- Direct binary HTTP streaming proxy (`/api/v1/object-storage/data/<bucket>/<key>`) connecting both the web console and `pkg/awscompat` SigV4 multipart uploads straight to SeaweedFS with **zero object bytes stored in PostgreSQL**.

## 3. Tenant Managed PostgreSQL via CloudNativePG 18.4

Running PostgreSQL on top of a 3-way replicated network block layer (such as Longhorn) while simultaneously running 3-way streaming replication creates 9x storage write amplification and tail-latency spikes.

Every tenant `managed-postgresql` order reconciles a real `clusters.postgresql.cnpg.io/v1` `Cluster` inside the project's isolated namespace:

- **Pinned image:** `ghcr.io/cloudnative-pg/postgresql:18.4` by immutable SHA-256 digest.
- **Local NVMe storage:** strictly enforces `openebs-hostpath` (overriding any replicated block StorageClass) paired with `podAntiAffinityType: required` so HA replicas never land on the same physical host.
- **Hardened defaults:** `enableSuperuserAccess: false`, namespace-scoped TCP `5432` `NetworkPolicy`, and `plugin-barman-cloud` `ObjectStore` backups targeting SeaweedFS S3 (avoiding deprecated in-tree `barmanObjectStore`).
- **NDSS 2026 cross-namespace bulkhead:** Every claim reference (`secretRef`, `objectStoreRef`, `storageClass`, `networkRef`) is validated against strict same-namespace boundaries (`CrossNamespaceReferenceDenied`).

## 4. Real KubeVirt lifecycle and honest Kubernetes HA boundary

VMware replacement claims only matter when every lifecycle control maps to real cluster custom resources:

- Snapshots emit real `VirtualMachineSnapshot` (`snapshot.kubevirt.io/v1beta1`), restores emit `VirtualMachineRestore`, and migrations emit `VirtualMachineInstanceMigration` (`kubevirt.io/v1`).
- Base OS catalog supports Ubuntu 24.04 LTS, Debian 12, and AlmaLinux 9 alongside OVA/VMDK/QCOW2 template workflows.
- **Honest Tenant Kubernetes boundary:** OSS vCluster runs single-replica control planes and is explicitly labeled `oss-vcluster-dev-single-replica` in API responses and documentation. Multi-replica HA tenant Kubernetes control planes are sequenced on Apache-2.0 Kamaji + Cluster API (`kamaji-capk-apache-2.0`).

## 5. OpenBao security gate and encrypted control-plane stores

- An audited OpenBao Transit/KV v2 client (`exportable: false`, `allow_plaintext_backup: false`) monitors live OpenBao health (`/api/v1/kms/status`) and enforces a strict `>= 2.7.3` version gate (`IsOpenBaoVersionSafeForNamespaces()`) before enabling multi-tenant OpenBao namespaces (preventing `GHSA-fgmw-h9wp-wc7g` and `GHSA-h8fh-pmch-cjww` on `2.7.2` cells).
- Until the cell upgrades to OpenBao `>= 2.7.3`, AWS KMS and Secrets Manager routes run on AES-256-GCM encrypted per-tenant PostgreSQL partitions and are transparently classified as control-plane stores (`dataPlaneBacked: false`) in `/aws/_awscompat/healthz`.

## 6. Honest AWS SigV4 compatibility boundary

Instead of advertising inflated namespace counts where half the endpoints are in-memory stubs, `/aws/_awscompat/healthz` serves `cloudring.awscompat.matrix/v2` with `"honestBoundary": true`, separating:

- **Data-plane-backed services:** S3 (SeaweedFS HA streaming & multipart), EC2/VPC (KubeVirt & Cilium), RDS (CloudNativePG 18.4), EKS (Tenant Kubernetes), IAM/STS, Cost/Budgets, and CloudWatch.
- **Control-plane stores & helper routes:** KMS & Secrets Manager (AES-256-GCM encrypted per-tenant PG stores until OpenBao `>= 2.7.3` multi-tenant namespaces) plus metadata helpers explicitly marked `dataPlaneBacked: false`.

## 7. Formal invariants verified in Z3 SMT

Six architectural invariants are encoded and checked in `docs/verification/frontier_invariants_z3.py` alongside planted-defect negative controls:

| Invariant | Property Proved in Z3 (`frontier_invariants_z3.py`) |
| --- | --- |
| `INV-1` | `control_plane_state_partitioning`: monolithic row fails at 100 tenants (64-tenant hard ceiling at 64 KiB/tenant); partitioned rows satisfy 10,000 tenants. |
| `INV-2` | `n1_worst_case_largest_node_loss_envelope`: surviving 2 smallest nodes (`63,665 MiB` allocatable, `57,298 MiB` 90% usable) leave `12,241 MiB` verified tenant headroom; 20 GiB overcommit is `unsat`. |
| `INV-3` | `zero_spof_3node_ha_placement`: quorum services (`replicas >= 3`) and stateless services (`replicas >= 2`) survive any single-node failure; single-replica SPOF is `unsat`. |
| `INV-4` | `ipam_host_node_disjointness`: zero IP overlap between bare-metal host subnets and tenant IPAM pools; planted colliding pool is caught (`sat`). |
| `INV-5` | `cross_namespace_operator_bulkhead_ndss2026`: same-namespace reference enforcement leaves zero cross-namespace bypass counterexamples (`unsat`). |
| `INV-6` | `iam_revocation_60s_bound_fr13`: revocation propagation stays within the 60s bound (`unsat` violation); planted 300s cache TTL violation is caught (`sat`). |

## 8. Honest EC Cloud Sovereignty Framework (v1.2.1) scorecard

| Sovereignty Objective | Current 3-Node EU Cell | Honest Ceiling & Reason |
| --- | --- | --- |
| `SOV-1..4`, `SOV-6..7` (Strategic, Legal, Data, Operational, Security, Compliance) | `SEAL-3` (with EU DNS & registry cutover tracked for `v0.9.5`) | Open Apache-2.0 control plane, EU bare metal, Ed25519-attested `cloudring-exit` switching bundles (`EUR 0.00` fee). |
| `SOV-5` (Technology / Silicon Supply Chain) | `SEAL-2` | Commodity x86 server silicon and firmware remain non-EU manufactured; #CloudRING never overclaims `SEAL-4` on commodity hardware. |
