Environment Management
Relevant source files
The following files were used as context for generating this wiki page:
Environment Management in the WIREDUP project is handled by a sophisticated, multi-source configuration system designed to support intelligent dependency injection and AI agent orchestration. The system provides a unified interface for loading, validating, and masking sensitive configuration data across different environments (e.g., development, production) and different technological stacks, including Python and Rust.
The primary purpose of this system is to ensure that AI agents, Skills, and core infrastructure components have access to type-safe, validated environment variables and configuration files. It supports complex features such as variable expansion, hierarchical overrides, and hot-reloading for dynamic updates.
Sources: src/config/env_manager.py:1-12, README.md:10-25, AGENT.md:15-30
Architecture and Core Components
The environment management architecture relies on a central EnvManager class that orchestrates configuration discovery and validation. It utilizes a priority-based loading strategy where higher-priority sources (like system environment variables) override lower-priority sources (like base .env files).
Core Data Structures
The system uses specialized data classes to manage configuration lifecycle and metadata:
| Structure | Purpose | Key Fields |
|---|---|---|
ConfigRule | Defines validation logic for a specific key. | name, validation_type, required, sensitive, default |
ConfigValue | Holds the actual value and its provenance. | key, value, source, timestamp, validated |
ConfigSource | Enum of supported input types. | ENV_FILE, ENVIRONMENT, JSON_FILE, COMMAND_LINE |
ValidationType | Enum of supported data types. | STRING, INTEGER, BOOLEAN, EMAIL, URL, PORT |
Sources: src/config/env_manager.py:21-72
Configuration Loading Flow
The EnvManager implements a specific sequence of operations during initialization to resolve the final configuration state:
The system supports variable expansion using ${VAR} syntax, allowing configuration values to reference other environment variables dynamically.
Sources: src/config/env_manager.py:176-193, src/config/env_manager.py:348-356
Validation and Security
Security is integrated via sensitive data masking and strict type validation. Configuration rules allow developers to mark specific keys (like API keys or SSH credentials) as sensitive, ensuring they are masked in logs or exported dictionaries.
Validation Types and Constraints
The _validate_value method enforces constraints based on the ValidationType.
| Type | Constraints / Validation Logic |
|---|---|
INTEGER / FLOAT | Range checks (min_value, max_value) and type conversion. |
BOOLEAN | Case-insensitive mapping of true/false, yes/no, 1/0. |
EMAIL / URL | Regex-based pattern matching for standard formats. |
PORT | Range check between 1 and 65535. |
LIST | String split based on a configurable separator (default ,). |
Sources: src/config/env_manager.py:210-255, src/config/env_manager.py:358-406
Implementation Example: Rule Definition
# src/config/env_manager.py:53-65
@dataclass
class ConfigRule:
name: str
validation_type: ValidationType
required: bool = False
default: Any = None
min_value: Optional[Union[int, float]] = None
max_value: Optional[Union[int, float]] = None
pattern: Optional[str] = None
sensitive: bool = False
Sources: src/config/env_manager.py:53-65
CLI and Integration
The WIREDUP CLI provides tools to initialize, check, and export the environment configuration. This interface allows developers to manage the lifecycle of configuration templates and current system status.
CLI Operations
The src/cli.py module exposes several commands for environment management:
init: Creates theconfig/directory, templates, and.env.example.config <key>: Retrieves a specific configuration value.export-config: Exports the entire resolved configuration in JSON, YAML, or Table format.status: Displays the health of the Auto-Wire engine and registered dependencies.
Sources: src/cli.py:36-85, src/cli.py:155-165, src/cli.py:202-225
Sequence: CLI Initialization
Sources: src/cli.py:36-85
Cross-Stack Configuration (Rust NexTerm)
The Rust-based terminal component, NexTerm, manages its own environment settings via rust-terminal/src/utils/config.rs. While primarily used for UI settings (theme, font size), it also manages the autowire_enabled flag which controls the bridge between the Rust terminal and the Python Auto-Wiring system.
Rust Config Structure
// rust-terminal/src/utils/config.rs:8-17
pub struct Config {
pub shell: String,
pub editor: String,
pub theme: String,
pub ai_enabled: bool,
pub autowire_enabled: bool,
pub font_size: u16,
pub show_status_bar: bool,
}
NexTerm configuration is stored in TOML format, typically located at ~/.config/nexterm/config.toml.
Sources: rust-terminal/src/utils/config.rs:8-17, rust-terminal/src/utils/config.rs:56-61
Conclusion
The Environment Management system provides a robust foundation for the WIREDUP ecosystem. By centralizing configuration logic in the EnvManager and providing validation and security through ConfigRule, the project ensures that intelligent agents and terminal components operate within a stable, predictable, and secure execution environment. This multi-layered approach—supporting .env files, JSON, and system variables—facilitates seamless transitions between local development and production deployments.
Sources: src/config/env_manager.py:1-12, AGENT.md:144-165, README.md:100-115