Declare the scope types a scope action may be configured at, and expose them over the API
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 17h 7m
- Merged PRs (30d)
- 358
Description
### Problem
Which scope types a permission may be configured at is a hand-written table (common/data/permission/scope_entity_combinations.py), so it drifts from the wiring it is supposed to describe. A scope action already declares its entity type, its operation and its name, but the scope types it accepts are only visible at run time, inside scope_targets().
### Contract
BaseScopeAction (manager/actions/v2/scope/base.py) gains one abstract classmethod, declared beside the run-time scope_targets() it constrains:
```python
@classmethod
@abstractmethod
def available_scope_types(cls) -> Sequence[EntityType]:
"""The scope types this action may be targeted at."""
```
Every wired scope action implements it - 82 classes across 68 declaring bases, as `backend.ai mgr ops list` counts them. The value is what scope_targets() may return: a fixed pair for an action that branches on its input, the accepted set for one that takes a caller-named scope.
### API surface
Read-only catalog served from the processor registry at startup, in the shape entity-types already uses (api/adapters/entity).
- REST v2: GET /v2/scope-operations, auth_required
- GraphQL: a root field over the same adapter payload
- SDK: client/v2/domains_v2/
- CLI: ./bai scope-operation list
One item per wired scope operation: action_name, entity_type, operation, scope_types.
### Out of scope
VALID_SCOPE_ENTITY_COMBINATIONS and the rbacScopeEntityCombinations resolver stay as they are; replacing them is a follow-up once a caller reads the new endpoint.
JIRA Issue: BA-7483
Contributor guide
Research direction
Start with BaseScopeAction in manager/actions/v2/scope/base.py and compare its scope_targets() implementations with the 68 declaring bases; backend.ai mgr ops list shows the wired actions. Then trace the processor registry, api/adapters/entity, client/v2/domains_v2/, and ./bai scope-operation list. Done means all wired scope operations expose their scope types through REST, GraphQL, SDK, and CLI surfaces.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, python
- Domain
- api, backend-api-design, cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100