Add _load_dataclass() that introspects dataclass fields and their defaults, replacing ~140 lines of repetitive .get() boilerplate with one-liner calls per config section. Config.load() reduced from ~180 to ~30 lines. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1.4 KiB
1.4 KiB
Implementation Plan — Issue #199: Config.load() boilerplate reduction
Metadata
| Field | Value |
|---|---|
| Issue | #199 |
| Title | Refactor: Config.load() boilerplate — replace manual field-by-field parsing |
| Milestone | — (tech debt) |
| Labels | type:refactor, priority:medium, service:orchestrator |
| Status | COMPLETED |
| Language | Python |
| Related Plans | — |
| Blocked by | — |
Acceptance Criteria
- Generic
_load_dataclass(cls, data)helper usingdataclasses.fields()introspection - Config.load() reduced from ~180 lines to ~30 lines
- All 9 sub-config sections use the generic helper
ConfidenceConfig.__post_init__validation still works- All existing tests pass
- Lint clean
Implementation Steps
1. Add _load_dataclass helper
Generic function that iterates dataclasses.fields(cls), picks values from data dict for present keys, and constructs the dataclass with defaults for missing keys.
2. Replace Config.load() boilerplate
Replace 9 manual section-loading blocks with one-liner calls to _load_dataclass.
Files to Create/Modify
| File | Action | Purpose |
|---|---|---|
services/orchestrator/src/orchestrator/config.py |
Modify | Add helper, simplify load() |
Deviation Log
| Deviation | Reason |
|---|---|
| None | — |