Skip to content

10 · Versioned configuration

Status: Implemented (T4) · Owner: Platform · Code: control-plane/src/flux_cp/config/

One service stores every configurable object in Flux with full history: pipelines, connections, schedules, trigger rules, calendars, compute profiles, the connector catalog, and anything added later. Each object has a latest version (newest saved) and an active version (what the system uses). They differ whenever you save without activating.

erDiagram
  config_items ||--o{ config_versions : has
  config_items ||--o{ config_activations : logs
  config_items {
    uuid id PK
    string kind
    string key
    string name
    text description
    jsonb labels
    timestamptz deleted_at
  }
  config_versions {
    uuid id PK
    uuid item_id FK
    int version
    jsonb body
    string checksum
    text message
    string author
    bool is_latest
    bool is_active
    timestamptz activated_at
  }
  config_activations {
    bigint id PK
    uuid item_id FK
    int version
    int previous_version
    string action
    string actor
    timestamptz at
  }
  • (kind, key) is unique. Keys are lowercase [a-z0-9._-], max 200 characters.
  • Versions are numbered from 1 and never change after they are written.
  • checksum = sha256 of the canonical JSON body (sorted keys, no whitespace).
  • config_activations is an append-only log of create, activate, and rollback.
Invariant Enforced by
Exactly one is_latest per item Partial unique index uq_config_versions_latest + row lock
At most one is_active per item Partial unique index uq_config_versions_active + row lock
Version numbers are dense and increasing SELECT … FOR UPDATE on the item row during save
Saving an unchanged body creates nothing Checksum compare with latest

Every mutation locks the item row (SELECT … FOR UPDATE). Concurrent activations of the same item run one after another; the test suite runs 15 concurrent activations and checks the invariants.

Operation Effect
create(kind, key, body) Item + version 1. Version 1 is activated automatically unless the kind opts out
save(kind, key, body, activate=false) Appends version n+1 as latest. Unchanged body → returns the existing latest
activate(kind, key, n) Makes version n active. Logged with the previously active version
rollback(kind, key, n?) Re-activates n, or the version that was active before the current one (from the log; falls back to the next-lower version)
diff(from, to) Structural JSON diff: add / remove / replace with paths
delete(kind, key) Soft delete. Re-creating the key starts a fresh history

Rollback never creates a new version. Old versions stay available for runs that pinned them.

Each object type registers a KindSpec:

  • validate(body) rejects invalid bodies with a readable message (HTTP 422).
  • prepare(body, previous) transforms the body before storage. Connections use it to encrypt secrets and keep unchanged secrets from the previous version.
  • redact(body) transforms the body before it leaves the API, for example to hide secrets. Diffs are computed on redacted bodies.
  • auto_activate_first controls whether version 1 becomes active immediately.

All endpoints need a bearer token or session cookie. Reads need viewer; writes need editor.

GET /api/config kinds
GET /api/config/{kind}?search= items (latest/active version numbers)
POST /api/config/{kind} create {key, name, description, labels, body, message}
GET /api/config/{kind}/{key} item + latest + active bodies
PATCH /api/config/{kind}/{key} name / description / labels
DELETE /api/config/{kind}/{key} soft delete
GET /api/config/{kind}/{key}/versions version list (no bodies)
POST /api/config/{kind}/{key}/versions save {body, message, activate}
GET /api/config/{kind}/{key}/versions/{ref} ref = number | latest | active
POST /api/config/{kind}/{key}/activate {version}
POST /api/config/{kind}/{key}/rollback {version?}
GET /api/config/{kind}/{key}/diff?from=&to= defaults active → latest
GET /api/config/{kind}/{key}/history activation log

Runs record (kind, key, version) for the pipeline and every connection they use, so a run can be replayed with exactly the same configuration even after later activations. Schedulers and trigger rules always resolve the active version at fire time.

  • Promotion labels (dev → prod): planned as a label on versions plus an “activate in environment” operation once there is more than one environment.