-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add env var substitution and config file discovery to loader #76
Copy link
Copy link
Closed
Labels
prio:mediumShould do, but not blockingShould do, but not blockingscope:medium1-3 days of work1-3 days of workspec:architectureDESIGN_SPEC Section 15 - Technical ArchitectureDESIGN_SPEC Section 15 - Technical Architecturetype:featureNew feature implementationNew feature implementationtype:testTest coverage, test infrastructureTest coverage, test infrastructure
Description
Context
PR #75 implements the core YAML config loader with layered merging and Pydantic validation. Two acceptance criteria from #59 were deferred to keep the PR focused:
- Environment variable substitution —
${ENV_VAR}placeholders in config values should be expanded before validation - Config file discovery —
load_config()should search standard locations (./,~/.ai-company/, etc.) when no explicit path is given
Acceptance Criteria
-
${ENV_VAR}syntax in any string value is replaced with the environment variable's value before Pydantic validation - Missing env vars raise
ConfigValidationErrorwith a clear message naming the variable - Optional default syntax
${ENV_VAR:-default}is supported -
discover_config()searches:./ai-company.yaml,./config/ai-company.yaml,~/.ai-company/config.yaml(in order) -
load_config()acceptsconfig_path=Noneand falls back to discovery -
ConfigFileNotFoundErrorraised when no config found in any location - Unit tests for: substitution (present/missing/default), discovery (each location, precedence, not found)
Design Spec Reference
Sections 4.3, 5.4
Notes
- Keep
load_config(config_path: Path | str)signature backward-compatible — makeconfig_pathoptional withNonedefault - Env var expansion should happen on the merged dict (after deep merge, before Pydantic validation)
- Use
re.subwithos.environ.get()for substitution — no need for a templating library
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
prio:mediumShould do, but not blockingShould do, but not blockingscope:medium1-3 days of work1-3 days of workspec:architectureDESIGN_SPEC Section 15 - Technical ArchitectureDESIGN_SPEC Section 15 - Technical Architecturetype:featureNew feature implementationNew feature implementationtype:testTest coverage, test infrastructureTest coverage, test infrastructure