Conversation
Add USER_FAIR_SHARE element type to the RBAC system as part of applying the RBAC Creator pattern to UserFairShare auto sub-entity. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…binations Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Change `FairShareDBSource.create_user_fair_share()` parameter type from `Creator[UserFairShareRow]` to `RBACEntityCreator[UserFairShareRow]` - Replace `execute_creator()` with `execute_rbac_entity_creator()` - Add imports for `RBACEntityCreator`, `execute_rbac_entity_creator`, `RBACElementRef`, and `RBACElementType` Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updated FairShareRepository.create_user_fair_share() to accept RBACEntityCreator[UserFairShareRow] instead of Creator[UserFairShareRow]. Added RBACEntityCreator import to repository module. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fixed import paths for RBACEntityCreator and execute_rbac_entity_creator to use the correct module path: ai.backend.manager.repositories.base.rbac.entity_creator Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Applies the RBAC “Creator” workflow to UserFairShare creation and wires the new entity type into the permissions model.
Changes:
- Introduces
USER_FAIR_SHAREas a newRBACElementTypeand registers it underRESOURCE_GROUPscope/entity combinations. - Migrates
create_user_fair_share()in the DB source to useRBACEntityCreator+execute_rbac_entity_creator(). - Updates
FairShareRepository.create_user_fair_share()to accept anRBACEntityCreator-typed creator.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ai/backend/manager/repositories/fair_share/repository.py | Updates repository API type signature to accept RBACEntityCreator for user fair share creation. |
| src/ai/backend/manager/repositories/fair_share/db_source/db_source.py | Switches execution path to execute_rbac_entity_creator() for user fair share creation. |
| src/ai/backend/common/data/permission/types.py | Adds USER_FAIR_SHARE element type to RBAC enum. |
| src/ai/backend/common/data/permission/scope_entity_combinations.py | Registers USER_FAIR_SHARE as an entity under RESOURCE_GROUP. |
| changes/10023.enhance.md | Adds a changelog entry for the RBAC Creator migration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| async def create_user_fair_share( | ||
| self, | ||
| creator: Creator[UserFairShareRow], | ||
| creator: RBACEntityCreator[UserFairShareRow], |
There was a problem hiding this comment.
This changes the repository method’s public type signature from Creator[...] to RBACEntityCreator[...], which is a (type-level) breaking change for callers that still pass a Creator. If backward compatibility is desired, consider widening the accepted type (e.g., a shared Protocol / Union) or providing a small adapter so existing Creator instances can still be used where RBAC registration isn’t needed.
| result = await execute_rbac_entity_creator(db_sess, creator) | ||
| sg_row = await self._fetch_scaling_group_row(db_sess, result.row.resource_group) |
There was a problem hiding this comment.
After switching to execute_rbac_entity_creator(), this code still assumes the returned object has the same shape as execute_creator() (notably result.row). To make this contract explicit and prevent future refactors from silently breaking this call site, add an explicit type annotation for result (or otherwise assert the expected interface) so type-checking can enforce that .row is present.
…Creator Add USER_FAIR_SHARE to RBACElementTypeGQL enum to stay in sync with RBACElementType. Update test_scope_entity_combinations expected set and migrate test Creator calls to RBACEntityCreator for user fair share. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: octodog <mu001@lablup.com>
Summary
USER_FAIR_SHAREtoRBACElementTypeenum as a new element typeUSER_FAIR_SHAREunderRESOURCE_GROUPin scope-entity combinationsFairShareDBSource.create_user_fair_share()to useRBACEntityCreatorandexecute_rbac_entity_creator()FairShareRepository.create_user_fair_share()to acceptRBACEntityCreatorparameterTest plan
pants fmt- no changes neededpants fix- no changes neededpants lint --changed-since=origin/main- all checks passedResolves BA-5077