feat(BA-7731): carry the role's scope and the permission's bit in the responses - #14446
Merged
Conversation
… responses A role now belongs to one scope, but nothing said which one on the way out. The response says it, and a permission row says the bit it holds under the name the bit has. - `RoleNode`, `RoleGQL` and the v1 `RoleDTO` carry `scope_type` and `scope_id`, read off the row as an `EntityType` and an `EntityID`. No element enum stands between the column and the wire. - A permission row answers with `permission`, the bit it holds. `operation` stays as the same bit named as an action, deprecated. - `PermissionBitGQL` moves to the shared rbac scope module. It sat in `entity_share`, which imports rbac, so reading it from rbac closed a circle. The enum is unreleased, so the schema is unchanged by the move. Every schema change here is additive. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013UiMJNt9dasPDtpBP7sSsC
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013UiMJNt9dasPDtpBP7sSsC
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The reviewed changes have no unresolved approval-blocking issues.
Pull request overview
Adds role scope metadata and exposes explicit permission bits while preserving the deprecated operation field.
Changes:
- Adds
scope_typeandscope_idto role responses. - Adds
permissionand deprecatesoperation. - Relocates the shared GraphQL permission enum.
- Updates adapters, DTOs, schemas, tests, and changelogs.
File summaries
| File | Description |
|---|---|
tests/unit/manager/api/gql/rbac/test_permission_mutations.py |
Updates permission fixtures. |
tests/unit/common/dto/manager/v2/rbac/test_response.py |
Tests scope and permission response fields. |
tests/unit/client_v2/test_rbac.py |
Updates role response fixtures. |
tests/unit/client_v2/test_rbac_client.py |
Updates client fixtures. |
src/ai/backend/manager/api/rest/rbac/role_adapter.py |
Maps role scope into v1 responses. |
src/ai/backend/manager/api/gql/rbac/types/scope.py |
Hosts the shared permission-bit enum. |
src/ai/backend/manager/api/gql/rbac/types/role.py |
Exposes role scope fields. |
src/ai/backend/manager/api/gql/rbac/types/permission.py |
Exposes permission bits and deprecates operation. |
src/ai/backend/manager/api/gql/entity_share/types.py |
Reuses the shared permission-bit enum. |
src/ai/backend/manager/api/adapters/rbac/adapter.py |
Maps scope and permission data into DTOs. |
src/ai/backend/common/dto/manager/v2/rbac/response.py |
Extends v2 response models. |
src/ai/backend/common/dto/manager/rbac/response.py |
Extends v1 role responses. |
docs/manager/graphql-reference/v2-schema.graphql |
Updates the v2 GraphQL schema reference. |
docs/manager/graphql-reference/supergraph.graphql |
Updates the composed schema. |
changes/14446.feature.md |
Documents the new response fields. |
changes/14446.deprecation.md |
Documents the operation deprecation. |
Review details
- Files reviewed: 16/16 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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
RoleNode,RoleGQLand the v1RoleDTOnow carryscope_typeandscope_id, read off the row as anEntityTypeand anEntityID— no element enum stands between the column and the wire.permission, the bit it actually holds.operationstays, carrying the same bit named as an action, and is deprecated.PermissionBitGQLmoves fromentity_shareto the shared rbac scope module.entity_shareimports rbac, so reading the enum back from rbac closed a circle. The enum is unreleased, so the move leaves the schema unchanged.Schema changes
Every change is additive; the graphql-inspector check reports no breaking change.
Not in scope
The v1 REST
PermissionDTOandObjectPermissionDTOkeepoperationalone. The v1 types module has no bit enum, and mirroring the deprecation there would make v1 depend on v2. Dropping the scope from the permission rows themselves is BA-7732.Test plan
pants lintandpants check --changed-dependents=transitiveover the change setpants test --changed-since --changed-dependents=direct(11 targets)Resolves BA-7731
🤖 Generated with Claude Code
https://claude.ai/code/session_013UiMJNt9dasPDtpBP7sSsC
📚 Documentation preview 📚: https://sorna--14446.org.readthedocs.build/en/14446/
📚 Documentation preview 📚: https://sorna-ko--14446.org.readthedocs.build/ko/14446/