# Feature: Configuration Loading
### Scope
- **Purpose**: Load typed configuration from TOML, JSON, and YAML files located relative to the workspace root using serde deserialization.
- **Responsibility**: Detect file format by extension, deserialize file content into caller-defined structs, and support layered merging where later files override earlier ones.
- **In Scope**: Typed configuration loading, format detection, layered merge, priority search, and writing configuration to disk (all require `serde` feature).
- **Out of Scope**: Schema validation (see `feature/005_configuration_validation.md`), config file watching or hot-reload, remote configuration sources, encryption of config values.
### Design
Format detection is entirely extension-driven: `.toml` → TOML, `.json` → JSON, `.yaml`/`.yml` → YAML. No explicit format argument is required; the loader tries each extension in order until a file is found.
Layered merging follows a last-wins rule: configs are deserialized into the same target type and merged in declaration order, with each subsequent file overriding keys from earlier files. This enables a `base.toml` + `dev.toml` pattern where environment-specific files override shared defaults.
Config search uses a priority order — workspace-local `config/` directory first, then the workspace root — allowing per-project overrides of shared defaults without moving files.
Typed configuration can be serialized back to TOML and written to a workspace-relative path, enabling tools that mutate and persist configuration programmatically.
### Sources
| [src/lib.rs](../../src/lib.rs) | Config loading, merging, and format detection impl |
| [Cargo.toml](../../Cargo.toml) | `serde` feature flag and optional dependency declarations |
### Tests
| [tests/serde_integration_tests.rs](../../tests/serde_integration_tests.rs) | Integration with serde for configuration deserialization |
| [tests/comprehensive_test_suite.rs](../../tests/comprehensive_test_suite.rs) | Full coverage matrix including config loading |
| [tests/feature_combination_tests.rs](../../tests/feature_combination_tests.rs) | Feature flag combination correctness |
### Tasks
| [task/completed/005_serde_integration.md](../../task/completed/005_serde_integration.md) | Initial serde configuration loading implementation |
### APIs
| [api/001_workspace.md](../api/001_workspace.md) | Configuration loading method signatures |
### Features
| [feature/005_configuration_validation.md](../feature/005_configuration_validation.md) | Schema validation on top of config loading |