feat(BA-5514): register roles in association_scopes_entities with optional scope#10704
Open
feat(BA-5514): register roles in association_scopes_entities with optional scope#10704
Conversation
fregataa
added a commit
that referenced
this pull request
Apr 1, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds optional scope registration when creating RBAC roles (so newly created roles can be atomically registered into association_scopes_entities when a scope is provided), and refactors GraphQL RBAC enum/type placement to avoid circular imports.
Changes:
- Thread optional
scope_reffrom GraphQL input → adapter → action/service → repository and useRBACEntityCreatorto insert the scope association alongside role creation. - Introduce
ScopeInput(DTO + GQL) and moveRBACElementTypeGQLinto a newscope.pymodule to break circular imports. - Update affected imports/exports and adjust enum sync test to the new module path.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/manager/api/gql/rbac/test_rbac_element_type_sync.py | Updates enum import location after moving RBACElementTypeGQL. |
| src/ai/backend/manager/services/permission_contoller/service.py | Passes new scope_ref through to repository create-role input. |
| src/ai/backend/manager/services/permission_contoller/actions/create_role.py | Extends CreateRoleAction with optional scope_ref. |
| src/ai/backend/manager/repositories/permission_controller/role_manager.py | Uses RBACEntityCreator to register system roles in association_scopes_entities. |
| src/ai/backend/manager/repositories/permission_controller/db_source/db_source.py | Conditionally uses RBACEntityCreator to create+register roles when scope_ref is provided. |
| src/ai/backend/manager/api/gql/rbac/types/scope.py | New module defining RBACElementTypeGQL and ScopeInputGQL. |
| src/ai/backend/manager/api/gql/rbac/types/role.py | Adds optional scope to GraphQL CreateRoleInput. |
| src/ai/backend/manager/api/gql/rbac/types/permission.py | Imports RBACElementTypeGQL from the new scope module. |
| src/ai/backend/manager/api/gql/rbac/types/entity.py | Imports RBACElementTypeGQL from the new scope module. |
| src/ai/backend/manager/api/gql/rbac/types/init.py | Re-exports RBACElementTypeGQL and new ScopeInputGQL. |
| src/ai/backend/manager/api/adapters/rbac.py | Converts optional GraphQL scope into internal RBACElementRef and passes it to CreateRoleAction. |
| src/ai/backend/common/dto/manager/v2/rbac/types.py | Adds ScopeInput request model. |
| src/ai/backend/common/dto/manager/v2/rbac/request.py | Extends CreateRoleInput (DTO) with optional scope. |
| src/ai/backend/common/dto/manager/v2/rbac/init.py | Exports ScopeInput. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/ai/backend/manager/repositories/permission_controller/db_source/db_source.py
Outdated
Show resolved
Hide resolved
jopemachine
reviewed
Apr 1, 2026
80468fd to
c04ee83
Compare
…ional scope Add optional scope registration when creating roles. When scope is provided, RBACEntityCreator atomically creates the role row and its scope association. When absent, only the role row is created. - Add ScopeInput DTO type (scope_type enum + scope_id) - Add ScopeInputGQL and move RBACElementTypeGQL to scope.py to break circular import chain - Thread scope_ref through adapter → action → service → db_source - System role creation now uses RBACEntityCreator with scope Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: octodog <mu001@lablup.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: octodog <mu001@lablup.com>
…ations Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Change scope from single optional to a list, leveraging RBACEntityCreator's existing additional_scope_refs support. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: octodog <mu001@lablup.com>
99f7958 to
783131e
Compare
Co-authored-by: octodog <mu001@lablup.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ScopeInput(scope_type + scope_id)RBACEntityCreatoratomically creates the role row and its scope association; when absent, only the role row is createdRBACElementTypeGQLto a newscope.pymodule to break the circular import chain and co-locate it withScopeInputGQLTest plan
pants lint --changed-since=origin/mainpassespants checkpasses (0 new errors)tests/unit/manager/api/gql/rbac/test_rbac_element_type_sync.pypassestests/unit/common/dto/manager/v2/rbac::passesResolves BA-5514
📚 Documentation preview 📚: https://sorna--10704.org.readthedocs.build/en/10704/
📚 Documentation preview 📚: https://sorna-ko--10704.org.readthedocs.build/ko/10704/