Expand description
Configuration environment abstraction.
This module provides the ConfigEnvironment trait that abstracts all
external side effects needed for configuration operations:
- Environment variable access (for path resolution)
- Filesystem operations (for reading/writing config files)
§Design Philosophy
Configuration types like UnifiedConfig should be pure data structures.
All side effects (env vars, file I/O) are injected through this trait,
making the code testable without mocking globals.
§Dependency Injection
Production code uses RealConfigEnvironment which reads from actual
environment variables and performs real filesystem operations. Tests use
MemoryConfigEnvironment with in-memory storage for both.
§Example
ⓘ
use crate::config::{ConfigEnvironment, RealConfigEnvironment, MemoryConfigEnvironment};
// Production: uses real env vars and filesystem
let env = RealConfigEnvironment;
let config_path = env.unified_config_path();
// Testing: uses in-memory storage
let env = MemoryConfigEnvironment::new()
.with_unified_config_path("/test/config/ralph-workflow.toml")
.with_prompt_path("/test/repo/PROMPT.md")
.with_file("/test/repo/PROMPT.md", "# Goal\nTest");Structs§
- Memory
Config Environment - In-memory implementation of
ConfigEnvironmentfor testing. - Real
Config Environment - Production implementation of
ConfigEnvironment.
Traits§
- Config
Environment - Trait for configuration environment access.