Apply the virtual scope chain to the entity invitation entity
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 17h 7m
- Merged PRs (30d)
- 358
Description
Settle every scope operation of the `entity_invitation` entity on the virtual scope chain. The wiring declares 4 scope operations for it; each one is accounted for below. Resolve ownership through `entity_memberships` joined to `virtual_scopes`; helpers live in `src/ai/backend/manager/models/virtual_scope/queries.py`.
## Convert
- `search_entity_invitations` — two of its scope items: `EntityInvitationInviteeScope` (`models/entity_invitation/scopes.py:26`), an email subquery, and `EntityInvitationInviterScope` (`:55`), `EntityInvitationRow.inviter_user_id`
## Already settled
- `accept_entity_invitation`, `reject_entity_invitation` — status transitions on a named invitation, not scoped lists
## Out of scope
- `EntityInvitationTargetScope` — the third scope item of the same operation; it reads the offered entity, which is a parent read
## Write side
Missing for both arms. `models/entity_invitation/creators.py:42` declares `member_of() -> (target,)` only, so `create_entity_invitation` records neither the invitee nor the inviter. The write side has to land first.
## Done when
- The invitee and inviter edges are written at creation and backfilled for existing rows.
- Neither scope references the invitee email subquery nor the inviter column.
- Each converted read has a test proving it returns the same rows as the column-based query on backfilled data.
JIRA Issue: BA-7550
Contributor guide
Research direction
Start with models/entity_invitation/creators.py:42 and the helpers in src/ai/backend/manager/models/virtual_scope/queries.py, then inspect the invitee and inviter scope definitions in models/entity_invitation/scopes.py. Implement and test the write-side edges and backfill before converting search_entity_invitations. Done means both reads match the column-based query on backfilled data and no longer reference the email subquery or inviter column.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, database
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100