Refactor: Separate data models from service logic in application/services #3861

Open
opened 2026-04-06 06:58:56 +00:00 by freemo · 0 comments
Owner

Several files in the src/cleveragents/application/services directory have been found to mix data models (Pydantic models, dataclasses, TypedDicts) with service logic in the same file. This violates the Single Responsibility Principle and the project's architectural guidelines, which state that domain models should reside in the domain/models directory.

Affected Files (so far):

  • src/cleveragents/application/services/memory_service.py: Mixes conversation memory and entity store concerns, and defines Entity and EntityType models.
  • src/cleveragents/application/services/validation_apply.py: Defines ValidationAttachment, ApplyValidationResult, and ApplyValidationSummary models alongside the ApplyValidationGate service.
  • src/cleveragents/application/services/semantic_validation_service.py: Defines PipelineResultDict and NormalisedOutputDict alongside the SemanticValidationService.
  • src/cleveragents/application/services/subplan_merge_service.py: Defines FileMergeOutcome and SubplanMergeResult models alongside the SubplanMergeService.
  • src/cleveragents/application/services/semantic_validation_rules.py: Duplicates the SemanticValidationSeverity and SemanticCheckResult models.

Recommendation:

Refactor the affected files to separate the data models from the service logic. The data models should be moved to the appropriate subdirectories within src/cleveragents/domain/models. This will improve the modularity, maintainability, and testability of the codebase.


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

Several files in the `src/cleveragents/application/services` directory have been found to mix data models (Pydantic models, dataclasses, TypedDicts) with service logic in the same file. This violates the Single Responsibility Principle and the project's architectural guidelines, which state that domain models should reside in the `domain/models` directory. **Affected Files (so far):** * `src/cleveragents/application/services/memory_service.py`: Mixes conversation memory and entity store concerns, and defines `Entity` and `EntityType` models. * `src/cleveragents/application/services/validation_apply.py`: Defines `ValidationAttachment`, `ApplyValidationResult`, and `ApplyValidationSummary` models alongside the `ApplyValidationGate` service. * `src/cleveragents/application/services/semantic_validation_service.py`: Defines `PipelineResultDict` and `NormalisedOutputDict` alongside the `SemanticValidationService`. * `src/cleveragents/application/services/subplan_merge_service.py`: Defines `FileMergeOutcome` and `SubplanMergeResult` models alongside the `SubplanMergeService`. * `src/cleveragents/application/services/semantic_validation_rules.py`: Duplicates the `SemanticValidationSeverity` and `SemanticCheckResult` models. **Recommendation:** Refactor the affected files to separate the data models from the service logic. The data models should be moved to the appropriate subdirectories within `src/cleveragents/domain/models`. This will improve the modularity, maintainability, and testability of the codebase. --- **Automated by CleverAgents Bot** Supervisor: Architecture Guard | Agent: ca-architecture-guard
freemo added the
Points
3
label 2026-04-06 07:09:33 +00:00
Sign in to join this conversation.
No Label
Points
3
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: cleveragents/cleveragents-core#3861