Expand description
Unified configuration system for the Astrid runtime.
This crate provides a single Config type that consolidates all
configuration previously scattered across RuntimeConfig, SecurityPolicy,
BudgetConfig, ServersConfig, GatewayConfig, and HooksConfig.
§Usage
use astrid_config::Config;
// Load with full precedence chain (defaults → system → user → workspace → env).
let resolved = Config::load(Some(std::path::Path::new("."))).unwrap();
let config = resolved.config;
println!("Using model: {}", config.model.model);§Configuration Precedence
From highest to lowest priority:
- Workspace (
{workspace}/.astrid/config.toml) — can only tighten security - User (
~/.astrid/config.toml) - System (
/etc/astrid/config.toml) - Environment variables (
ASTRID_*,ANTHROPIC_*) — fallback only - Embedded defaults (
defaults.tomlcompiled into binary)
§Design
This crate has no dependencies on other internal astrid crates. It only
depends on serde, toml, thiserror, tracing, and directories.
Conversion from config types to domain types happens at the integration
boundary (CLI startup, gateway init) via bridge modules.
Re-exports§
pub use error::ConfigError;pub use error::ConfigResult;pub use show::ResolvedConfig;pub use show::ShowFormat;pub use types::*;
Modules§
- env
- Environment variable fallback resolution.
Environment variable fallback and
${VAR}reference resolution. - error
- Configuration error types.
- loader
- Configuration file discovery and loading. Config file discovery and layered loading.
- merge
- Layered configuration merging with precedence. Deep merge of TOML values with restriction enforcement.
- show
- Resolved configuration display and serialization.
Source-annotated display for
config show. - types
- Configuration struct definitions. Configuration types for the Astrid runtime.
- validate
- Configuration validation rules. Post-merge configuration validation.