Skip to content

feat(BA-6191): add ScopeCreatorSpec and ScopePurgerSpec to Ops layer#11843

Open
fregataa wants to merge 1 commit into
mainfrom
feat/BA-6191-scope-creator-spec
Open

feat(BA-6191): add ScopeCreatorSpec and ScopePurgerSpec to Ops layer#11843
fregataa wants to merge 1 commit into
mainfrom
feat/BA-6191-scope-creator-spec

Conversation

@fregataa
Copy link
Copy Markdown
Member

@fregataa fregataa commented May 28, 2026

Summary

  • Add ScopeCreatorSpec / ScopePurgerSpec as composite coordinators for scope provisioning and teardown. Leaf sub-specs stay single-table.
  • New RBACWriterOps class owns create_scope / purge_scope. Provisioning inserts the scope row, snapshots a role + its permissions per active preset matching the new scope, and writes role-to-scope plus parent-scope association rows in a single transaction.
  • Teardown runs the inverse: scope-bound permissions, then association rows, then the scope row. Roles are intentionally left alone — their lifecycle is independent of the scope's.

Test plan

  • CI typecheck + lint

Resolves BA-6191

@github-actions github-actions Bot added size:L 100~500 LoC comp:manager Related to Manager component labels May 28, 2026
fregataa added a commit that referenced this pull request May 28, 2026
@fregataa fregataa force-pushed the feat/BA-6191-scope-creator-spec branch 2 times, most recently from a9cdfd8 to 7576fba Compare May 28, 2026 15:07
@fregataa fregataa marked this pull request as ready for review May 28, 2026 15:14
@fregataa fregataa requested a review from a team as a code owner May 28, 2026 15:14
Copilot AI review requested due to automatic review settings May 28, 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

This PR introduces composite “scope lifecycle” specs and a dedicated RBAC write-ops surface to orchestrate multi-table RBAC scope provisioning/teardown in a single transaction, rather than forcing each repository spec to span multiple tables.

Changes:

  • Add ScopeCreatorSpec / ScopePurgerSpec (and result wrappers) as composite coordinators for scope create/purge flows.
  • Implement RBACWriterOps with create_scope() and purge_scope() orchestration (role-preset → roles/permissions + scope/entity associations; and inverse teardown).
  • Expose DBOpsProvider.rbac_write_ops() and re-export new scope APIs from repositories.base.

Reviewed changes

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

Show a summary per file
File Description
src/ai/backend/manager/repositories/ops/provider.py Adds RBACWriterOps orchestration and a new rbac_write_ops() context manager on DBOpsProvider.
src/ai/backend/manager/repositories/base/scope_creator.py Introduces ScopeContext and ScopeCreatorSpec/ScopeCreatorResult composites for scope provisioning.
src/ai/backend/manager/repositories/base/scope_purger.py Introduces ScopePurgerSpec/ScopePurgerResult composites for scope teardown.
src/ai/backend/manager/repositories/base/__init__.py Re-exports the new scope-creator/purger APIs from the base repository package.
changes/11843.feature.md Towncrier fragment describing the new RBAC scope orchestration surface.

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

Comment thread src/ai/backend/manager/repositories/base/scope_creator.py
Comment thread src/ai/backend/manager/repositories/base/scope_creator.py
Comment thread src/ai/backend/manager/repositories/base/scope_purger.py Outdated
Comment thread src/ai/backend/manager/repositories/base/scope_purger.py
Comment thread src/ai/backend/manager/repositories/ops/provider.py
Comment thread src/ai/backend/manager/repositories/ops/provider.py Outdated
@fregataa fregataa force-pushed the feat/BA-6191-scope-creator-spec branch from 7576fba to d25b1e7 Compare June 2, 2026 11:33
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@fregataa fregataa force-pushed the feat/BA-6191-scope-creator-spec branch from d25b1e7 to 80838db Compare June 2, 2026 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:manager Related to Manager component size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants