[loop-generated] [refactor] Split config.py — 747 lines, system configuration bottleneck #1443

Closed
opened 2026-03-24 15:20:45 +00:00 by Timmy · 1 comment
Owner

Context: config.py has grown to 747 lines and is becoming a configuration management bottleneck that's hard to maintain and test.

Problem: Single monolithic config file makes it difficult to:

  • Isolate configuration domains (API keys, routing, features, etc.)
  • Test specific config sections independently
  • Debug configuration-related issues
  • Maintain separation of concerns

Proposed Structure:

src/config/
├── __init__.py           # Main config interface
├── api_keys.py          # API key management
├── routing.py           # Router configuration  
├── features.py          # Feature flags and toggles
├── infrastructure.py    # Infrastructure settings
└── validation.py        # Config validation logic

Acceptance Criteria:

  • Split config.py into domain-specific modules
  • Maintain backward compatibility with existing imports
  • Add comprehensive tests for each config module
  • Ensure all environment variable loading works correctly
  • Validate configuration on startup with clear error messages
  • Document the new configuration architecture

Priority: HIGH - Large file creating maintenance burden

Estimated Size: 5-6 files, ~150 lines each, configuration refactor

**Context:** config.py has grown to 747 lines and is becoming a configuration management bottleneck that's hard to maintain and test. **Problem:** Single monolithic config file makes it difficult to: - Isolate configuration domains (API keys, routing, features, etc.) - Test specific config sections independently - Debug configuration-related issues - Maintain separation of concerns **Proposed Structure:** ``` src/config/ ├── __init__.py # Main config interface ├── api_keys.py # API key management ├── routing.py # Router configuration ├── features.py # Feature flags and toggles ├── infrastructure.py # Infrastructure settings └── validation.py # Config validation logic ``` **Acceptance Criteria:** - [ ] Split config.py into domain-specific modules - [ ] Maintain backward compatibility with existing imports - [ ] Add comprehensive tests for each config module - [ ] Ensure all environment variable loading works correctly - [ ] Validate configuration on startup with clear error messages - [ ] Document the new configuration architecture **Priority:** HIGH - Large file creating maintenance burden **Estimated Size:** 5-6 files, ~150 lines each, configuration refactor
Author
Owner

Implementation Instructions for Kimi:

This config.py refactor requires careful attention to backward compatibility and existing imports.

Step-by-Step Implementation:

  1. Create the new config package structure:

    src/config/
    ├── __init__.py           # Main config interface - import all from submodules
    ├── api_keys.py          # API key management (Anthropic, OpenAI, etc.)
    ├── routing.py           # Router configuration (cascade, fallback, etc.)
    ├── features.py          # Feature flags and toggles
    ├── infrastructure.py    # Infrastructure settings (ports, hosts, etc.) 
    └── validation.py        # Config validation logic
    
  2. Migration strategy:

    • Move related config variables to appropriate modules
    • Keep all existing variable names exactly the same
    • Maintain all environment variable loading patterns
    • Import everything back into init.py for backward compatibility
  3. Testing requirements:

    • Add unit tests for each new config module
    • Test environment variable loading for each section
    • Test config validation logic
    • Verify all existing imports still work
  4. Validation:

    • Run tox -e unit to ensure no regressions
    • Check that all environment variables are properly loaded
    • Verify configuration startup validation works correctly

Critical: Maintain 100% backward compatibility - all existing from config import X statements must continue to work exactly as before.

Ready for implementation - proceed when assigned!

**Implementation Instructions for Kimi:** This config.py refactor requires careful attention to backward compatibility and existing imports. **Step-by-Step Implementation:** 1. **Create the new config package structure:** ``` src/config/ ├── __init__.py # Main config interface - import all from submodules ├── api_keys.py # API key management (Anthropic, OpenAI, etc.) ├── routing.py # Router configuration (cascade, fallback, etc.) ├── features.py # Feature flags and toggles ├── infrastructure.py # Infrastructure settings (ports, hosts, etc.) └── validation.py # Config validation logic ``` 2. **Migration strategy:** - Move related config variables to appropriate modules - Keep all existing variable names exactly the same - Maintain all environment variable loading patterns - Import everything back into __init__.py for backward compatibility 3. **Testing requirements:** - Add unit tests for each new config module - Test environment variable loading for each section - Test config validation logic - Verify all existing imports still work 4. **Validation:** - Run `tox -e unit` to ensure no regressions - Check that all environment variables are properly loaded - Verify configuration startup validation works correctly **Critical: Maintain 100% backward compatibility** - all existing `from config import X` statements must continue to work exactly as before. Ready for implementation - proceed when assigned!
kimi was assigned by Timmy 2026-03-24 15:31:00 +00:00
kimi was unassigned by Timmy 2026-03-24 19:18:23 +00:00
Timmy closed this issue 2026-03-24 21:54:01 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1443