Refactor: Decompose change.py into smaller modules #3922

Open
opened 2026-04-06 07:26:53 +00:00 by freemo · 0 comments
Owner

The src/cleveragents/domain/models/core/change.py file has been identified as a major violation of the Single Responsibility Principle and the 500-line limit guideline.

Issues:

  1. Mixed Concerns: The file mixes several distinct concerns:
    • Legacy Data Models: OperationType, Operation, Change, and LegacyChangeSet.
    • Current Data Models: ChangeOperation, ChangeEntry, and SpecChangeSet.
    • Tool Invocation Models: ToolInvocation.
    • Protocols: InvocationTracker and ChangeSetStore.
    • In-Memory Implementations: InMemoryInvocationTracker and InMemoryChangeSetStore.
  2. File Length: The file is over 600 lines long, which makes it difficult to read and maintain.

Recommendation:

Perform a major refactoring of the change.py file by splitting it into smaller, more focused modules:

  • Move the legacy models to a new file, src/cleveragents/domain/models/core/change_legacy.py, and create an issue to track their removal.
  • Keep the current data models in src/cleveragents/domain/models/core/change.py.
  • Move the ToolInvocation model to its own file, src/cleveragents/domain/models/core/tool_invocation.py.
  • Move the protocols (InvocationTracker, ChangeSetStore) to a new protocols or interfaces directory within the domain layer.
  • Move the in-memory implementations (InMemoryInvocationTracker, InMemoryChangeSetStore) to the src/cleveragents/infrastructure layer, possibly in a new persistence or tracking package.

This refactoring will significantly improve the architecture of the change tracking functionality, making it more modular, maintainable, and testable.


Automated by CleverAgents Bot
Supervisor: Architecture Guard | Agent: ca-architecture-guard

The `src/cleveragents/domain/models/core/change.py` file has been identified as a major violation of the Single Responsibility Principle and the 500-line limit guideline. **Issues:** 1. **Mixed Concerns:** The file mixes several distinct concerns: * **Legacy Data Models:** `OperationType`, `Operation`, `Change`, and `LegacyChangeSet`. * **Current Data Models:** `ChangeOperation`, `ChangeEntry`, and `SpecChangeSet`. * **Tool Invocation Models:** `ToolInvocation`. * **Protocols:** `InvocationTracker` and `ChangeSetStore`. * **In-Memory Implementations:** `InMemoryInvocationTracker` and `InMemoryChangeSetStore`. 2. **File Length:** The file is over 600 lines long, which makes it difficult to read and maintain. **Recommendation:** Perform a major refactoring of the `change.py` file by splitting it into smaller, more focused modules: * Move the legacy models to a new file, `src/cleveragents/domain/models/core/change_legacy.py`, and create an issue to track their removal. * Keep the current data models in `src/cleveragents/domain/models/core/change.py`. * Move the `ToolInvocation` model to its own file, `src/cleveragents/domain/models/core/tool_invocation.py`. * Move the protocols (`InvocationTracker`, `ChangeSetStore`) to a new `protocols` or `interfaces` directory within the `domain` layer. * Move the in-memory implementations (`InMemoryInvocationTracker`, `InMemoryChangeSetStore`) to the `src/cleveragents/infrastructure` layer, possibly in a new `persistence` or `tracking` package. This refactoring will significantly improve the architecture of the change tracking functionality, making it more modular, maintainable, and testable. --- **Automated by CleverAgents Bot** Supervisor: Architecture Guard | Agent: ca-architecture-guard
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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
cleveragents/cleveragents-core#3922
No description provided.