Refactor: Decompose action.py into smaller modules #3912

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

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

Issues:

  1. Mixed Concerns: The file mixes several distinct concerns:
    • Data Models: Action and ActionArgument.
    • Enums: ActionState, ArgumentType, and ArgumentRequirement.
    • Business Logic: The ActionArgument class contains parse and from_mapping methods with logic for creating instances from different sources. This logic belongs in the application layer.
  2. File Length: The file is over 700 lines long, which makes it difficult to read and maintain.

Recommendation:

Refactor the action.py file by splitting it into smaller, more focused modules:

  • Keep the Action and ActionArgument models in src/cleveragents/domain/models/core/action.py.
  • Move the enums (ActionState, ArgumentType, ArgumentRequirement) to src/cleveragents/domain/models/core/enums.py.
  • Move the parsing logic from the ActionArgument class to a factory or builder class in the src/cleveragents/application layer.

This refactoring will improve the modularity, maintainability, and testability of the action functionality, and it will also resolve the file length issue.


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

The `src/cleveragents/domain/models/core/action.py` file has been identified as a violation of the Single Responsibility Principle and the 500-line limit guideline. **Issues:** 1. **Mixed Concerns:** The file mixes several distinct concerns: * **Data Models:** `Action` and `ActionArgument`. * **Enums:** `ActionState`, `ArgumentType`, and `ArgumentRequirement`. * **Business Logic:** The `ActionArgument` class contains `parse` and `from_mapping` methods with logic for creating instances from different sources. This logic belongs in the application layer. 2. **File Length:** The file is over 700 lines long, which makes it difficult to read and maintain. **Recommendation:** Refactor the `action.py` file by splitting it into smaller, more focused modules: * Keep the `Action` and `ActionArgument` models in `src/cleveragents/domain/models/core/action.py`. * Move the enums (`ActionState`, `ArgumentType`, `ArgumentRequirement`) to `src/cleveragents/domain/models/core/enums.py`. * Move the parsing logic from the `ActionArgument` class to a factory or builder class in the `src/cleveragents/application` layer. This refactoring will improve the modularity, maintainability, and testability of the action functionality, and it will also resolve the file length issue. --- **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#3912
No description provided.