Skip to content

feat(BA-5764): add RBAC-enforced VFolder delete and restore mutations#11164

Draft
fregataa wants to merge 3 commits intomainfrom
feature/BA-5764-vfolder-delete-restore-rbac
Draft

feat(BA-5764): add RBAC-enforced VFolder delete and restore mutations#11164
fregataa wants to merge 3 commits intomainfrom
feature/BA-5764-vfolder-delete-restore-rbac

Conversation

@fregataa
Copy link
Copy Markdown
Member

@fregataa fregataa commented Apr 16, 2026

Summary

  • Add DeleteVFolderV2RBACAction (SingleEntityActionProcessor + single_entity_rbac_validators) with Updater/execute_updater pattern via new VFolderTrashUpdaterSpec + trash_vfolder() repository method.
  • Expose restoreVFolder GQL mutation, REST POST /v2/vfolders/{id}/restore, SDK restore(), and CLI restore command backed by existing RestoreVFolderFromTrashAction with RBAC.

Test plan

  • pants fmt/fix/lint — green
  • pants check — green (pre-existing processors.py errors only)
  • Component test: TestDeleteVFolderRBAC (regular user 403, superadmin bypass) + TestRestoreVFolderRBAC (regular user 403) via SDK
  • Repo unit test: TestVFolderRepositoryTrashAndRestore (trash sets DELETE_PENDING, not found, restore→READY, nonexistent empty)

Resolves BA-5764


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


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

Copilot AI review requested due to automatic review settings April 16, 2026 15:11
@github-actions github-actions bot added size:XL 500~ LoC comp:manager Related to Manager component comp:client Related to Client component comp:cli Related to CLI component labels Apr 16, 2026
@fregataa fregataa force-pushed the feature/BA-5764-vfolder-delete-restore-rbac branch from 24465bc to 83a49cf Compare April 16, 2026 15:14
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

Adds RBAC-enforced soft-delete (trash) for v2 vfolders via a new SingleEntityActionProcessor action, and exposes “restore from trash” across GraphQL, REST v2, SDK, and CLI, backed by the existing restore action.

Changes:

  • Introduces DeleteVFolderV2RBACAction + processor/service plumbing and a repository trash_vfolder() update path using an UpdaterSpec.
  • Adds /v2/vfolders/{id}/restore REST endpoint, restoreVFolder GraphQL mutation, SDK restore(), and CLI vfolder restore.
  • Adds unit/component tests for the new repository trash/restore behavior and RBAC denial paths.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/unit/manager/repositories/vfolder/test_vfolder_repository.py Adds unit tests for trash_vfolder() and restore_vfolders_from_trash()
tests/component/vfolder_v2/test_vfolder_mutation.py New component tests exercising v2 delete/restore via SDK with RBAC
src/ai/backend/manager/services/vfolder/services/vfolder.py Adds delete_v2_rbac() service method for RBAC-enforced soft-delete
src/ai/backend/manager/services/vfolder/processors/vfolder.py Registers delete_v2_rbac as a SingleEntityActionProcessor with RBAC validators
src/ai/backend/manager/services/vfolder/actions/vfolder_in_project.py New RBAC action/result types for v2 delete
src/ai/backend/manager/repositories/vfolder/updaters.py Adds VFolderTrashUpdaterSpec to set status to DELETE_PENDING
src/ai/backend/manager/repositories/vfolder/repository.py Adds trash_vfolder() repository method using execute_updater()
src/ai/backend/manager/api/rest/v2/vfolder/registry.py Registers POST /{vfolder_id}/restore route
src/ai/backend/manager/api/rest/v2/vfolder/handler.py Adds REST handler for restore
src/ai/backend/manager/api/gql/vfolder_v2/types/mutations.py Adds GraphQL payload type for restore
src/ai/backend/manager/api/gql/vfolder_v2/resolver/mutation.py Adds restoreVFolder GraphQL mutation
src/ai/backend/manager/api/gql/vfolder_v2/resolver/init.py Exports restore mutation resolver
src/ai/backend/manager/api/gql/vfolder_v2/init.py Re-exports restore mutation from module
src/ai/backend/manager/api/gql/schema.py Wires restore mutation into the GraphQL schema
src/ai/backend/manager/api/adapters/vfolder.py Routes delete() to RBAC processor; adds adapter restore()
src/ai/backend/client/v2/domains_v2/vfolder.py Adds SDK restore() method for REST v2 endpoint
src/ai/backend/client/cli/v2/vfolder/commands.py Adds CLI vfolder restore command
changes/BA-5764.feature.md Towncrier fragment for the feature

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

Comment thread src/ai/backend/manager/api/adapters/vfolder.py
Comment thread tests/component/vfolder_v2/test_vfolder_mutation.py
Comment thread src/ai/backend/manager/repositories/vfolder/repository.py
Comment thread src/ai/backend/manager/services/vfolder/services/vfolder.py
Comment thread src/ai/backend/manager/services/vfolder/actions/vfolder_v2_rbac.py
@github-actions github-actions bot added the area:docs Documentations label Apr 16, 2026
@fregataa fregataa force-pushed the feature/BA-5764-vfolder-delete-restore-rbac branch 2 times, most recently from b930805 to 096820e Compare April 17, 2026 01:51
Comment thread docs/manager/graphql-reference/supergraph.graphql Outdated
fregataa and others added 3 commits April 19, 2026 18:41
Add DeleteVFolderV2RBACAction (SingleEntityActionProcessor + RBAC) with
Updater/execute_updater pattern. Expose restoreVFolder GQL mutation,
REST endpoint, SDK method, and CLI command backed by existing
RestoreVFolderFromTrashAction. Adapter delete() routes to RBAC path;
bulk_delete() stays on legacy.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: octodog <mu001@lablup.com>
Rename the Strawberry `name=` override so the exposed GraphQL type is
`RestoreVFolderPayload` instead of `RestoreVFolderV2Payload`, matching
the preferred V2-free naming convention for new types.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@fregataa fregataa force-pushed the feature/BA-5764-vfolder-delete-restore-rbac branch from 4449356 to fbd8f72 Compare April 19, 2026 09:42
@fregataa fregataa requested review from a team and jopemachine April 19, 2026 11:07
@fregataa fregataa added this to the 26.5 milestone Apr 19, 2026
@fregataa fregataa marked this pull request as draft April 20, 2026 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs Documentations comp:cli Related to CLI component comp:client Related to Client component comp:manager Related to Manager component size:XL 500~ LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants