Skip to content

refactor(BA-5071): Apply RBAC Creator pattern to ImageAlias#10014

Merged
jopemachine merged 5 commits into
mainfrom
feat/BA-5071
Mar 20, 2026
Merged

refactor(BA-5071): Apply RBAC Creator pattern to ImageAlias#10014
jopemachine merged 5 commits into
mainfrom
feat/BA-5071

Conversation

@fregataa
Copy link
Copy Markdown
Member

@fregataa fregataa commented Mar 12, 2026

Summary

  • Add IMAGE_ALIAS = "image:alias" to RBACElementType enum
  • Convert Creator/execute_creator to RBACEntityCreator/execute_rbac_entity_creator in image domain
  • Update service, repository, db_source, and tests

Test plan

  • pants lint passes
  • CI validation

Resolves BA-5071


📚 Documentation preview 📚: https://sorna--10014.org.readthedocs.build/en/10014/


📚 Documentation preview 📚: https://sorna-ko--10014.org.readthedocs.build/ko/10014/

Copilot AI review requested due to automatic review settings March 12, 2026 15:50
@github-actions github-actions Bot added size:M 30~100 LoC comp:manager Related to Manager component comp:common Related to Common component labels Mar 12, 2026
Copy link
Copy Markdown
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

This PR refactors the image alias creation flow to use the RBAC-scoped entity creation pattern so that creating an ImageAlias also records the appropriate scope→entity association for permissioning.

Changes:

  • Added RBACElementType.IMAGE_ALIAS to represent image-alias RBAC entities.
  • Updated image alias creation to use RBACEntityCreator / execute_rbac_entity_creator across service, repository, and DB source layers.
  • Updated unit test assertions to validate RBAC creator metadata (element type + scope ref).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/unit/manager/services/image/test_image_service.py Updates unit test to assert RBACEntityCreator usage and correct RBAC scope metadata.
src/ai/backend/manager/services/image/service.py Switches alias-by-id service logic from Creator to RBACEntityCreator with image scope reference.
src/ai/backend/manager/repositories/image/repository.py Updates repository method signature to accept RBACEntityCreator for alias creation.
src/ai/backend/manager/repositories/image/db_source/db_source.py Uses execute_rbac_entity_creator when inserting image aliases, ensuring RBAC association rows are created.
src/ai/backend/common/data/permission/types.py Adds IMAGE_ALIAS to RBACElementType.

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

Comment on lines +388 to +390
# === Auto sub-entities with direct GET APIs ===
IMAGE_ALIAS = "image:alias"

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.

RBACElementType.IMAGE_ALIAS is introduced with a value containing : ("image:alias"). This makes RBACElementType values incompatible with the existing ...Id / ...Ref string serialization helpers that use val.partition(":") (e.g., RBACElementRef.from_str() / .to_str()), because round-tripping will break when the enum value itself contains :. Consider either (1) using a colon-free value for RBACElementType (while mapping to EntityType.IMAGE_ALIAS elsewhere), or (2) updating the parsing helpers to split from the right (e.g., rpartition) so element types may safely contain :.

Copilot uses AI. Check for mistakes.
fregataa added a commit that referenced this pull request Mar 12, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added size:L 100~500 LoC area:docs Documentations and removed size:M 30~100 LoC labels Mar 12, 2026
fregataa and others added 5 commits March 20, 2026 14:16
- Add IMAGE_ALIAS to RBACElementType enum
- Replace Creator/execute_creator with RBACEntityCreator/execute_rbac_entity_creator
  for ImageAlias creation in image domain
- Scope association: ImageAlias → IMAGE (parent scope)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: octodog <mu001@lablup.com>
@github-actions github-actions Bot added size:M 30~100 LoC and removed size:L 100~500 LoC labels Mar 20, 2026
@fregataa fregataa added this to the 26.4 milestone Mar 20, 2026
@fregataa fregataa requested review from a team and jopemachine March 20, 2026 05:37
@jopemachine jopemachine merged commit b01d8a9 into main Mar 20, 2026
33 checks passed
@jopemachine jopemachine deleted the feat/BA-5071 branch March 20, 2026 05:44
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.

3 participants