Introduce Backend.AI standard pattern in Agent GQL nodes operation
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 17h 7m
- Merged PRs (30d)
- 358
Description
## Motivation
The current Agent GQL nodes operation implementation in `src/ai/backend/manager/models/gql_models/agent.py` directly mixes GraphQL handlers with database operations, using legacy patterns like `simple_db_mutate` and `simple_db_mutate_returning_item`. This creates several problems:
1. Lack of separation of concerns: Business logic is tightly coupled with GraphQL layer and database operations
1. Inconsistent architecture: Other components (e.g., group, domain) have already adopted the modern
action-processor pattern with service and repository layers
1. Poor testability: Direct database operations in mutations make unit testing difficult
1. Limited reusability: Business logic cannot be easily reused in different contexts (e.g., CLI, internal services)
1. Maintenance challenges: Tight coupling makes refactoring and feature additions risky
Applying this pattern to scaling_group will improve code quality, maintainability, and architectural consistency across the codebase.
## Objective
Refactor the scaling group implementation to follow [http://Backend.AI](http://Backend.AI) 's standard action-processor architecture pattern, ensuring:
1. Complete separation of concerns across layers (GraphQL handlers → Actions → Services → Repositories → Database)
1. Type-safe DTOs for all data transfers
1. Testable business logic with proper unit and integration tests
1. Architectural consistency with other components (group, domain)
1. Zero breaking changes to the GraphQL API
1. All existing functionality preserved and tested
JIRA Issue: BA-3558
Contributor guide
Assessment
This issue has not been assessed yet.