Refactor: Decompose async_job.py into smaller modules #3901

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

The src/cleveragents/domain/models/core/async_job.py file has been identified as a violation of the Single Responsibility Principle.

Issues:

The file mixes several distinct concerns:

  1. Data Models: AsyncJob model and AsyncJobStatus enum.
  2. Exception: InvalidJobTransitionError.
  3. Helper Functions: can_transition_job, serialize_job_payload, and deserialize_job_payload.

Recommendation:

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

  • Keep the AsyncJob model and AsyncJobStatus enum in src/cleveragents/domain/models/core/async_job.py.
  • Move the InvalidJobTransitionError exception to a central exceptions module (e.g., src/cleveragents/core/exceptions.py).
  • Move the helper functions (can_transition_job, serialize_job_payload, deserialize_job_payload) to the src/cleveragents/application layer, possibly in a new async_jobs package or a utils module.

This refactoring will improve the modularity, maintainability, and testability of the asynchronous job functionality.


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

The `src/cleveragents/domain/models/core/async_job.py` file has been identified as a violation of the Single Responsibility Principle. **Issues:** The file mixes several distinct concerns: 1. **Data Models:** `AsyncJob` model and `AsyncJobStatus` enum. 2. **Exception:** `InvalidJobTransitionError`. 3. **Helper Functions:** `can_transition_job`, `serialize_job_payload`, and `deserialize_job_payload`. **Recommendation:** Refactor the `async_job.py` file by splitting it into smaller, more focused modules: * Keep the `AsyncJob` model and `AsyncJobStatus` enum in `src/cleveragents/domain/models/core/async_job.py`. * Move the `InvalidJobTransitionError` exception to a central exceptions module (e.g., `src/cleveragents/core/exceptions.py`). * Move the helper functions (`can_transition_job`, `serialize_job_payload`, `deserialize_job_payload`) to the `src/cleveragents/application` layer, possibly in a new `async_jobs` package or a `utils` module. This refactoring will improve the modularity, maintainability, and testability of the asynchronous job functionality. --- **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#3901
No description provided.