Some checks failed
Rust CI / Security Audit (push) Has been cancelled
Rust CI / Check + Test + Lint (nightly) (push) Has been cancelled
Rust CI / Check + Test + Lint (stable) (push) Has been cancelled
mdBook Build & Deploy / Build mdBook (push) Has been cancelled
Nickel Type Check / Nickel Type Checking (push) Has been cancelled
mdBook Build & Deploy / Documentation Quality Check (push) Has been cancelled
mdBook Build & Deploy / Deploy to GitHub Pages (push) Has been cancelled
mdBook Build & Deploy / Notification (push) Has been cancelled
137 lines
4.1 KiB
Markdown
137 lines
4.1 KiB
Markdown
# Platform Templates
|
|
|
|
Shared configuration patterns, constraints, validators, and default values for VAPORA services.
|
|
|
|
## Directory Structure
|
|
|
|
```plaintext
|
|
platform/
|
|
├── schemas/ # Shared schemas for common configuration patterns
|
|
│ ├── common/
|
|
│ │ ├── server.ncl # Server configuration (host, port, workers, etc.)
|
|
│ │ ├── database.ncl # Database configuration
|
|
│ │ ├── monitoring.ncl # Monitoring and observability
|
|
│ │ └── storage.ncl # Storage and backup configuration
|
|
│ └── README.md
|
|
│
|
|
├── constraints/ # Validation rules and constraints
|
|
│ ├── common.ncl # Common validation predicates
|
|
│ └── README.md
|
|
│
|
|
├── validators/ # Reusable validation functions
|
|
│ ├── port-validator.ncl # Port range validation
|
|
│ ├── budget-validator.ncl# Budget and cost validation
|
|
│ └── README.md
|
|
│
|
|
├── values/ # Constants and enumeration values
|
|
│ ├── limits.ncl # Platform limits and bounds
|
|
│ ├── defaults.ncl # Default values
|
|
│ ├── ranges.ncl # Valid value ranges and enums
|
|
│ └── README.md
|
|
│
|
|
├── defaults/ # Default configurations per mode
|
|
│ ├── common/
|
|
│ │ ├── server-defaults.ncl
|
|
│ │ ├── database-defaults.ncl
|
|
│ │ └── monitoring-defaults.ncl
|
|
│ ├── deployment/
|
|
│ │ ├── solo.ncl # Solo mode defaults
|
|
│ │ ├── multiuser.ncl # Multiuser mode defaults
|
|
│ │ └── enterprise.ncl # Enterprise mode defaults
|
|
│ └── README.md
|
|
│
|
|
├── templates/ # Code generation templates
|
|
│ ├── configs/ # Configuration file templates
|
|
│ ├── kubernetes/ # Kubernetes manifest templates
|
|
│ ├── docker-compose/ # Docker Compose templates
|
|
│ └── README.md
|
|
│
|
|
├── configs/ # Composed configurations (Nickel files)
|
|
│ ├── vapora.solo.ncl
|
|
│ ├── vapora.multiuser.ncl
|
|
│ └── vapora.enterprise.ncl
|
|
│
|
|
├── common/
|
|
│ └── helpers.ncl # Helper functions for composition
|
|
│
|
|
└── README.md # This file
|
|
```
|
|
|
|
## Usage
|
|
|
|
### For Configuration Composition
|
|
|
|
Import schemas and defaults to compose configurations:
|
|
|
|
```nickel
|
|
let server_schema = import "schemas/common/server.ncl" in
|
|
let server_defaults = import "defaults/common/server-defaults.ncl" in
|
|
let deployment_defaults = import "defaults/deployment/solo.ncl" in
|
|
|
|
# Merge: schema → deployment defaults → user customizations
|
|
std.record.merge server_schema (std.record.merge server_defaults user_config)
|
|
```
|
|
|
|
### For Validation
|
|
|
|
Use constraints and validators:
|
|
|
|
```nickel
|
|
let constraints = import "constraints/common.ncl" in
|
|
let budget_validator = import "validators/budget-validator.ncl" in
|
|
|
|
# Validate port
|
|
assert constraints.valid_port 8080
|
|
|
|
# Validate budget configuration
|
|
budget_validator.validate_role_limits {
|
|
architect_cents = 500000,
|
|
developer_cents = 300000,
|
|
reviewer_cents = 200000,
|
|
testing_cents = 100000,
|
|
}
|
|
```
|
|
|
|
### For Constants
|
|
|
|
Import values for limits and defaults:
|
|
|
|
```nickel
|
|
let limits = import "values/limits.ncl" in
|
|
let ranges = import "values/ranges.ncl" in
|
|
|
|
# Use port limits
|
|
let valid_port = port > limits.port.min && port < limits.port.max in
|
|
|
|
# Check valid log level
|
|
let valid_level = std.array.contains ranges.log_levels level in
|
|
```
|
|
|
|
## Composition Pattern
|
|
|
|
The typical composition flow:
|
|
|
|
1. **Schema** → Defines structure and types
|
|
2. **Constraints** → Validates values are valid
|
|
3. **Defaults** → Provides reasonable defaults per mode
|
|
4. **User Config** → Customizations override defaults
|
|
5. **Output** → Valid, merged configuration
|
|
|
|
```
|
|
User Input
|
|
↓
|
|
Constraints (validation)
|
|
↓
|
|
Merge with Defaults
|
|
↓
|
|
Merge with Schema
|
|
↓
|
|
Output JSON/TOML
|
|
```
|
|
|
|
## References
|
|
|
|
- **Nickel Language**: https://nickel-lang.org/
|
|
- **Configuration Layout**: `@.claude/layout_conventions.md`
|
|
- **Nickel Guidelines**: `@.claude/guidelines/nickel.md`
|