Documentation Index
Fetch the complete documentation index at: https://docs.ctrlplane.dev/llms.txt
Use this file to discover all available pages before exploring further.
| Category | Status | Created | Author |
|---|---|---|---|
| Infrastructure | Draft | 2026-04-01 | Mike Leone |
Summary
This RFC proposes a unified data model for managing variables across resources, deployments, and deployment job agents. It consolidates the current fragmented schema into a single, extensible system that supports:- Multiple scopes (resource, deployment, deployment job agent)
- Multiple value types (literal, reference, secret reference)
- Override semantics via selectors and priority
- First-class support for secret providers without duplicating schema
Motivation
The current schema exhibits significant duplication across two dimensions:- Scope duplication
- Separate handling for resource, deployment, and job-agent variables
- Value-type duplication
- Separate tables for literal values and reference values
- Schema explosion and maintenance overhead
- Repeated logic in queries and resolution code
- Increased risk of inconsistency and bugs
- Difficulty extending the system (e.g., adding secrets)
- Treats scope and value type as data, not schema
- Supports extensibility without table proliferation
- Centralizes resolution logic
Goals
- Eliminate duplicated tables across scopes and value types
- Provide a single resolution model for all variable types
- Support secret references without storing raw secrets
- Maintain strong data integrity constraints
- Enable future extensibility (new value types, new scopes)
Non-Goals
- Implementing secret storage (this system references external providers)
- Defining a full selector language
- Enforcing cross-variable resolution correctness at the database level
Proposal
Core Concepts
The system is built around two primary entities:- Variable
- Defines a key within a specific scope
- Variable Value
- Defines one or more candidate values for a variable
- Supports override semantics via priority and selectors
Variable
Represents a named configuration key scoped to a specific owner. Key properties:- scope: one of resource, deployment, deployment_job_agent
- Exactly one owner reference is set
- key: variable identifier
- is_sensitive: indicates whether the variable contains sensitive data
Variable Value
Represents a candidate value for a variable. Supports three value types:- literal: JSON value stored directly
- ref: reference to another variable
- secret_ref: reference to an external secret provider
- resource_selector: optional matching condition
- priority: determines precedence
Value Types
Literal
Stores a JSON value directly in the database. Example:Reference
References another variable by key, optionally with a path. Example:Secret Reference
References a value stored in an external secret manager. Example:Resolution Model
To resolve a variable:- Identify the variable by scope and key
- Retrieve all associated variable_value rows
- Filter by selector (if applicable)
- Sort by priority (descending)
- Select the highest-priority match
- Resolve based on value type:
- literal → return value
- ref → recursively resolve referenced variable
- secret_ref → fetch from external provider
Why This Design
Eliminates Duplication
- One table for variables instead of per-scope tables
- One table for values instead of per-type tables
Extensible
Adding a new value type (e.g., computed, templated) requires:- Adding a new enum value
- Adding optional columns or extending logic
Unified Resolution Logic
All variables follow the same resolution pipeline regardless of scope or type.Secret Handling
Secrets are treated as a value source, not a separate system:- Avoids duplicating schema
- Keeps resolution consistent
- Prevents storing sensitive data directly in the DB
Alternatives Considered
1. Separate Tables per Scope
Rejected because:- Leads to schema duplication
- Requires duplicating logic
- Hard to extend
2. Separate Tables per Value Type
Rejected because:- Introduces join complexity
- Makes adding new types expensive
3. Separate Secret Tables
Rejected because:- Secrets participate in the same resolution semantics
- Only the value source differs
- Duplication would increase system complexity
Tradeoffs
Pros
- Dramatically simpler schema
- Centralized resolution logic
- Easier to extend
- Reduces duplication
Cons
- More nullable columns in variable_value
- Some validation shifts to application logic
- Slightly more complex constraints
Future Work
- Replace ref_key with referenced_variable_id for stronger integrity
- Introduce structured selector model (e.g., JSON-based matching)
- Add expression-based value model (single JSON expression column)
- Add audit logging and versioning
Migration Strategy
- Create new tables alongside existing schema
- Backfill variables and values
- Update read paths to use new schema
- Deprecate old tables
- Remove old schema after validation
Conclusion
This proposal replaces a fragmented and duplicated schema with a unified, extensible model for variable management. By treating scope and value type as data rather than schema, the system becomes:- Easier to maintain
- Easier to extend
- More consistent in behavior