systemprompt-config 0.4.0

Profile-based configuration for systemprompt.io AI governance infrastructure. Bootstraps profiles, secrets, and credentials with zero environment-variable fallback.
Documentation

Production infrastructure for AI agents

Website · Documentation · Guides · Core · Template · Discord


systemprompt-config

Crates.io Docs.rs License: BSL-1.1

Profile-based configuration for systemprompt.io AI governance infrastructure. Bootstraps profiles, secrets, and credentials with zero environment-variable fallback. Provides configuration management including YAML loading, variable resolution, secrets management, and validation.

Layer: Infra — infrastructure primitives (database, security, events, etc.) consumed by domain crates. Part of the systemprompt-core workspace.

Overview

This crate provides configuration management for the systemprompt.io platform:

  • YAML Configuration Loading: Loads and merges base and environment-specific YAML files
  • Variable Resolution: Resolves ${VAR_NAME} and ${VAR_NAME:-default} patterns
  • Secrets Management: Loads .env.secrets files into environment
  • Validation: Validates configuration completeness, URL formats, and environment-specific rules
  • File Generation: Writes .env files for deployment

Architecture

src/
├── lib.rs                      # Crate root - public API exports
└── services/
    ├── mod.rs                  # Module declarations and re-exports
    ├── manager.rs              # ConfigManager - YAML loading, merging, variable resolution
    ├── schema_validation.rs    # Generic YAML/JSON schema validation utilities
    ├── types.rs                # DeployEnvironment, DeploymentConfig, EnvironmentConfig
    ├── validator.rs            # ConfigValidator, ValidationReport
    └── writer.rs               # ConfigWriter - .env file generation

manager.rs

Core configuration management functionality:

  • ConfigManager::new(project_root) - Initialize with project path
  • ConfigManager::generate_config(environment) - Load and merge YAML configs
  • Variable resolution with environment variable fallback
  • Secrets file loading

schema_validation.rs

Generic schema validation utilities:

  • validate_config<T>() - Validate YAML against typed schema
  • validate_yaml_file() - Parse and validate YAML syntax
  • generate_schema<T>() - Generate JSON schema from types
  • build_validate_configs() - Build-time validation for build.rs

types.rs

Configuration type definitions:

  • DeployEnvironment - Enum: Local, DockerDev, Production
  • DeploymentConfig - Raw YAML configuration container
  • EnvironmentConfig - Resolved environment variables

validator.rs

Configuration validation:

  • ConfigValidator::validate() - Run all validation checks
  • ValidationReport - Collect errors and warnings
  • Checks: unresolved variables, required variables, URL formats, port values

writer.rs

Configuration file output:

  • ConfigWriter::write_env_file() - Write standard .env file
  • ConfigWriter::write_web_env_file() - Write VITE_* variables for web builds

Usage

[dependencies]
systemprompt-config = "0.2.1"
use std::path::PathBuf;
use systemprompt_config::{ConfigManager, ConfigValidator, DeployEnvironment};

fn load_env(project_root: PathBuf) -> anyhow::Result<()> {
    let manager = ConfigManager::new(project_root);
    let config = manager.generate_config(DeployEnvironment::Local)?;
    let report = ConfigValidator::validate(&config);
    report.into_result()?;
    Ok(())
}

Public API

use systemprompt_config::{
    ConfigManager,
    ConfigValidator,
    DeployEnvironment,
    EnvironmentConfig,
    ValidationReport,
    validate_config,
    validate_yaml_file,
};

Dependencies

Crate Purpose
systemprompt-logging CLI output via CliService
serde_yaml YAML parsing
schemars JSON schema generation
regex Variable resolution patterns
anyhow Error handling
thiserror Typed errors for schema validation
tracing Warning logs for unsupported features

License

BSL-1.1 (Business Source License). Source-available for evaluation, testing, and non-production use. Production use requires a commercial license. Each version converts to Apache 2.0 four years after publication. See LICENSE.


systemprompt.io · Documentation · Guides · Live Demo · Template · crates.io · docs.rs · Discord

Infra layer · Own how your organization uses AI.