Skip to content

Refactor: explicit config injection (only roots read ConfigManager) #496

Closed

Description

@phernandez

Refactor: explicit confnjection (only roots read ConfigManager)

Why

Deep modules calling ConfigManager().config creates hidden coupling and environment-dependent behavior. This is especially problematic with cloud mode.

Scope

  • Establish a rule: Only composition roots read ConfigManager/env vars.
  • Refactor high-impact modules to accept:
    • BasicMemoryConfig explicitly, or
    • a narrow Protocol/dataclass containing only required fields.
  • Remove/avoid direct ConfigManager().config usage in non-root modules.

Acceptance criteria

  • No new ConfigManager().config usage outside containers.
  • Reduce existing usages substantially; remaining ones are tracked with follow-ups.
  • Tests pass.

Dependencies

Activity

  1. claude commented on Dec 31, 2025

    @claude
    Contributor

    Claude finished @phernandez's task in 1m 29s —— View job


    Triage Analysis for Issue #496

    • Read repository guidelines
    • Classify issue type and complexity
    • Search for duplicates
    • Add appropriate labels
    • Provide triage analysis

    Classification

    Type: Enhancement / Refactoring
    Priority: Medium-High
    Component: Architecture / Configuration Management
    Complexity: Medium-Complex

    Analysis

    This issue is part of a larger architectural refactoring effort (umbrella issue #490) to reduce coupling and improve SOLID principles in the codebase.

    Key Points:

    1. Problem: Deep modules calling ConfigManager().config creates hidden coupling and makes the system difficult to test, especially problematic for cloud mode
    2. Goal: Establish rule that only composition roots (containers) read ConfigManager/env vars
    3. Scope: Refactor modules to accept explicit config injection via BasicMemoryConfig or narrow Protocol/dataclass
    4. Dependencies: This issue depends on Refactor: add composition roots (api/container.py, mcp/container.py, cli/container.py) #492 (adding composition roots) being completed first

    Related Issues:

    No duplicates found - This is a distinct part of the larger refactoring effort.

    Recommendation

    This is a valuable architectural improvement that follows SOLID principles. The issue is well-scoped with clear acceptance criteria:

    • No new ConfigManager().config usage outside containers
    • Reduce existing usages substantially
    • Tests pass

    Priority Justification: Medium-High because:

    Implementation Approach:
    Should be tackled incrementally in small PRs after #492 is complete, focusing on high-impact modules first while maintaining test coverage.

    Labels Applied

    • enhancement ✓
  2. added
    enhancement
    on Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions