Skip to content

refactor(config): single-source configuration metadata and dynamic template generation - #83

Merged
JacksonFergusonDev merged 1 commit into
mainfrom
refactor/single-source-config-schema
Aug 22, 2026
Merged

refactor(config): single-source configuration metadata and dynamic template generation#83
JacksonFergusonDev merged 1 commit into
mainfrom
refactor/single-source-config-schema

Conversation

@JacksonFergusonDev

Copy link
Copy Markdown
Owner

Summary

This PR establishes a single source of truth for configuration settings, defaults, descriptions, presets, and dynamic TOML template generation:

  1. Single-Source Configuration Metadata:

    • Defined central PRESETS mapping (paranoid, aggressive, balanced, lazy) in config.py.
    • Defined CONFIG_SECTIONS_METADATA containing field keys, comments, example values, and field parsers (parse_size, parse_time).
    • Replaced hardcoded key lists in _update_dataclass with dynamic lookup in FIELD_PARSERS.
    • Simplified DaemonConfig.apply_preset() to look up from PRESETS.
  2. Dynamic Template Generation:

    • Added generate_default_config_template() -> str in config.py.
    • Replaced the 35-line hardcoded template string in cli._ensure_global_config_exists() with generate_default_config_template().
  3. Automated Tests:

    • Added unit tests in tests/test_config.py validating template generation, section coverage, uncommented TOML syntax validity, and preset handling.

Verification

  • All 168 pytest tests passing locally.
  • Pre-commit hooks (ruff check, ruff format, mypy) passing cleanly.

…mplate generation

- Define PRESETS mapping and CONFIG_SECTIONS_METADATA registry in config.py
- Add generate_default_config_template to generate the canonical global TOML configuration
- Replace hardcoded template string in cli._ensure_global_config_exists
- Simplify apply_preset and _update_dataclass using metadata parser definitions
- Add unit tests for dynamic template generation and preset handling in test_config.py
@JacksonFergusonDev
JacksonFergusonDev merged commit 0772b6e into main Aug 22, 2026
7 checks passed
@JacksonFergusonDev
JacksonFergusonDev deleted the refactor/single-source-config-schema branch August 22, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant