feat(config): implement configuration system #73

Merged
fuzzy merged 4 commits from feature/0009-implement-config-system into main 2026-07-05 13:37:18 +00:00
Owner

What

Implement the KronAI configuration system: schema, loader, merging, and defaults.

Why

Foundation for all job execution - config controls LLM endpoints, job directories, logging, and MCP server definitions.

Testing

  • 17 unit tests pass
  • Pre-commit hooks pass (ruff, mypy, formatting)
  • Coverage: 58% (config module at 100%)

Breaking Changes

None.

Notes

Config in TOML format with three search paths: /etc/kronai/config.toml, ~/.config/kronai/config.toml, ./kronai.toml. Job-specific config files supported via parse_job_config().

Closes #0005
Closes #0006
Closes #0007
Closes #0008
Closes #0009

## What Implement the KronAI configuration system: schema, loader, merging, and defaults. ## Why Foundation for all job execution - config controls LLM endpoints, job directories, logging, and MCP server definitions. ## Testing - [x] 17 unit tests pass - [x] Pre-commit hooks pass (ruff, mypy, formatting) - [x] Coverage: 58% (config module at 100%) ## Breaking Changes None. ## Notes Config in TOML format with three search paths: /etc/kronai/config.toml, ~/.config/kronai/config.toml, ./kronai.toml. Job-specific config files supported via parse_job_config(). Closes #0005 Closes #0006 Closes #0007 Closes #0008 Closes #0009
Demonstrates all config sections: general, LLM, and MCP servers.
Closes #0005
- load_config: search default paths, parse TOML, merge with defaults
- merge_config: deep-merge override dict into KronaiConfig dataclass
- parse_job_config: load job-specific TOML config with defaults
- _resolve_config_path, _parse_toml: internal helpers
Closes #0006
Closes #0007
Closes #0008
Cover defaults, merging, file loading, error handling, and
job-specific config parsing.
docs: mark Phase 1 Task 2 complete
All checks were successful
CI / lint (pull_request) Successful in 1m15s
CI / test (pull_request) Successful in 54s
d4a25aaf20
Configuration system with schema, loader, merging, and defaults done.
Closes #0009
the.auditor left a comment

Automated Review — PR #73

Result: APPROVED (no blocking issues found)


Solid implementation. Here's what I checked:

  • Correctness: Config loading, merging, and defaults all work as expected. _resolve_config_path properly falls through search paths, merge_config handles dict merging and Path coercion, _parse_toml wraps errors cleanly in ConfigError.
  • Completeness: Closes #5–#9. ROADMAP updated, example config included.
  • Test coverage: 17 tests, 4 test classes, covers defaults/merging/loading/error paths. 100% config module coverage.
  • Error handling: ConfigError for invalid TOML and unreadable files. Missing config falls back to defaults.
  • Security: llm_api_key defaults to empty string, example shows it blank — no secrets in the repo.
  • Maintainability: Clean code, good type hints, from __future__ import annotations for forward compatibility.

Suggestions (non-blocking)

  1. src/kronai/config.py:113 — The error message in _parse_toml includes the full path in the exception string. If the path contains user-home or other sensitive directory info, it could leak in logs. Consider using path.name or path.resolve() depending on needs.

  2. kronai.toml.example — Consider adding a comment that llm_api_key should be set via environment variable in production (e.g., # In production, prefer KRONAI_LLM_API_KEY env var).

  3. src/kronai/config.py:57merge_config silently ignores type mismatches (e.g., passing a string for default_temperature). Runtime-safe since dataclasses don't enforce types, but adding a try/except TypeError with a ConfigError wrapping could catch accidental misuse early.

## Automated Review — PR #73 **Result: APPROVED** (no blocking issues found) --- Solid implementation. Here's what I checked: - **Correctness**: Config loading, merging, and defaults all work as expected. `_resolve_config_path` properly falls through search paths, `merge_config` handles dict merging and Path coercion, `_parse_toml` wraps errors cleanly in `ConfigError`. - **Completeness**: Closes #5–#9. ROADMAP updated, example config included. - **Test coverage**: 17 tests, 4 test classes, covers defaults/merging/loading/error paths. 100% config module coverage. - **Error handling**: `ConfigError` for invalid TOML and unreadable files. Missing config falls back to defaults. - **Security**: `llm_api_key` defaults to empty string, example shows it blank — no secrets in the repo. - **Maintainability**: Clean code, good type hints, `from __future__ import annotations` for forward compatibility. ### Suggestions (non-blocking) 1. **`src/kronai/config.py:113`** — The error message in `_parse_toml` includes the full `path` in the exception string. If the path contains user-home or other sensitive directory info, it could leak in logs. Consider using `path.name` or `path.resolve()` depending on needs. 2. **`kronai.toml.example`** — Consider adding a comment that `llm_api_key` should be set via environment variable in production (e.g., `# In production, prefer KRONAI_LLM_API_KEY env var`). 3. **`src/kronai/config.py:57`** — `merge_config` silently ignores type mismatches (e.g., passing a string for `default_temperature`). Runtime-safe since dataclasses don't enforce types, but adding a `try/except TypeError` with a `ConfigError` wrapping could catch accidental misuse early.
fuzzy merged commit d4a25aaf20 into main 2026-07-05 13:37:18 +00:00
fuzzy deleted branch feature/0009-implement-config-system 2026-07-05 13:37:18 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/kronai!73
No description provided.