Skip to content

feat(BA-5075): apply RBAC Creator pattern to DomainFairShare#10025

Draft
fregataa wants to merge 5 commits intomainfrom
BA-5075
Draft

feat(BA-5075): apply RBAC Creator pattern to DomainFairShare#10025
fregataa wants to merge 5 commits intomainfrom
BA-5075

Conversation

@fregataa
Copy link
Member

Summary

  • Added RBACElementType.DOMAIN_FAIR_SHARE to RBAC type system
  • Registered DOMAIN_FAIR_SHARE under RESOURCE_GROUP in scope-entity combinations
  • Updated FairShareDBSource and FairShareRepository to use RBACEntityCreator pattern
  • Updated tests to use RBAC Creator with proper element_type and scope_ref

This applies the RBAC Creator pattern to DomainFairShare (auto sub-entity of ResourceGroup), following the same pattern as ProjectFairShare (BA-5076) and UserFairShare (BA-5077).

Test plan

  • pants fmt fix lint - all quality checks passed
  • pants test - all fair_share repository tests passed (17 tests)

Resolves BA-5075

fregataa and others added 2 commits March 13, 2026 03:23
- Add DOMAIN_FAIR_SHARE to RBACElementType enum in types.py
- Add DOMAIN_FAIR_SHARE to RESOURCE_GROUP scope combinations
- Update FairShareDBSource.create_domain_fair_share() to use RBACEntityCreator
- Update FairShareRepository.create_domain_fair_share() signature

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changes:
- Added RBACElementType.DOMAIN_FAIR_SHARE to types.py
- Added to scope_entity_combinations.py under RESOURCE_GROUP
- Updated EntityType.DOMAIN_FAIR_SHARE value from "domain:fair_share" to "domain_fair_share"
- Updated FairShareDBSource and FairShareRepository to use RBACEntityCreator
- Updated tests to use RBACEntityCreator and include AssociationScopesEntitiesRow table

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 12, 2026 18:38
@github-actions github-actions bot added the size:M 30~100 LoC label Mar 12, 2026
@github-actions github-actions bot added comp:manager Related to Manager component comp:common Related to Common component labels Mar 12, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Applies the RBAC “Creator” pattern to DomainFairShare so that creating a domain fair share also participates in RBAC entity creation/association under a RESOURCE_GROUP scope.

Changes:

  • Added RBACElementType.DOMAIN_FAIR_SHARE and registered it under RESOURCE_GROUP scope/entity combinations.
  • Switched DomainFairShare creation path from Creator/execute_creator to RBACEntityCreator/execute_rbac_entity_creator.
  • Updated unit tests and DB setup to include the RBAC association table mapping.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/unit/manager/repositories/fair_share/test_fair_share_repository.py Updates tests to create DomainFairShare via RBACEntityCreator and registers RBAC association table for DB setup/cleanup.
src/ai/backend/manager/repositories/fair_share/repository.py Changes repository API to accept RBACEntityCreator for domain fair share creation.
src/ai/backend/manager/repositories/fair_share/db_source/db_source.py Uses execute_rbac_entity_creator when creating domain fair share records.
src/ai/backend/common/data/permission/types.py Adds RBACElementType.DOMAIN_FAIR_SHARE and changes the EntityType.DOMAIN_FAIR_SHARE string value.
src/ai/backend/common/data/permission/scope_entity_combinations.py Allows DOMAIN_FAIR_SHARE as a child entity under RESOURCE_GROUP scope.
changes/10025.feature.md Adds changelog entry for the RBAC Creator pattern application.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +277 to 287
creator = RBACEntityCreator(
spec=DomainFairShareCreatorSpec(
resource_group=test_scaling_group,
domain_name=test_domain_name,
weight=Decimal("2.0"),
)
),
element_type=RBACElementType.DOMAIN_FAIR_SHARE,
scope_ref=RBACElementRef(RBACElementType.RESOURCE_GROUP, test_scaling_group),
)

result = await fair_share_repository.create_domain_fair_share(creator)
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests now use RBACEntityCreator, but they don’t assert the RBAC side-effect that motivates the change (i.e., that an association row is created in the RBAC association table for element_type=DOMAIN_FAIR_SHARE under the RESOURCE_GROUP scope). Adding an assertion that AssociationScopesEntitiesRow (or the equivalent RBAC association model) contains the expected scope/entity link would prevent regressions where execute_rbac_entity_creator() inserts only the fair-share row but fails to write the RBAC association.

Copilot uses AI. Check for mistakes.
…Creator

Add DOMAIN_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 domain fair share.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fregataa fregataa requested a review from a team March 12, 2026 19:07
Co-authored-by: octodog <mu001@lablup.com>
@github-actions github-actions bot added the area:docs Documentations label Mar 12, 2026
@fregataa fregataa removed the request for review from a team March 12, 2026 19:08
@fregataa fregataa marked this pull request as draft March 12, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs Documentations comp:common Related to Common component comp:manager Related to Manager component size:M 30~100 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants