Перейти к основному содержимому

ADR-037. Organization access layer belongs to identity

Контекст

Организации нужны сразу нескольким частям экосистемы: олимпиадам, банку задач, CRM, management, внутренним кабинетам и будущим франшизным сценариям. При этом organization model включает не только название организации, но и членство, owner/admin/member roles, команды, заявки на владение, учеников организации, дубли, grants и audit.

Если передать владение организациями product domains, появятся конкурирующие источники истины: competitions начнёт владеть школьными списками, task-bank — командами доступа, CRM — коммерческой организацией как будто это та же сущность. Это ломает правило one owner / one source of truth.

Решение

  • organization, organization_reference, membership, organization roles, teams, organization students, ownership claims, ownership transfers, organization merges and permission grants belong to identity.
  • Product domains consume organization context but do not own it.
  • organization_reference is a search/dedupe layer and never a permission source.
  • There is no global teacher role. Teacher/editor/organizer access is context-based: membership + role/grant + product permission.
  • Permissions in organization roles and grants must use the common catalog format <domain>.<resource>.<action>[.<scope>].
  • Product permissions remain owned by their product domains, for example competitions.results.manage.organization and task-bank.collections.manage.organization.

Альтернативы

АльтернативаПочему отвергнута
Выделить organizations как 8-й доменНарушает принятую семидоменную декомпозицию и создаёт отдельный сервис ради access layer
Отдать организации competitionsОлимпиады стали бы владельцем школьных списков, хотя организации нужны CRM/task-bank/management
Отдать организации CRMКоммерческий account не равен access organization; CRM владеет оплатами и entitlements, а не membership context
Хранить локальные roles/permissions в каждом продуктеПоявятся несовместимые permission namespaces и невозможность единого actor context

Последствия

  • Identity schema расширяется organization reference, claims, transfers, teams, grants, students and merge.
  • Competitions stores competition_participant and may reference organization_student_id, but does not mutate organization students.
  • Task-bank may use organization/team grants for collection access, but owns problem sets and problem usage.
  • CRM may link organization to commercial account, but commercial ownership remains CRM.
  • Management consumes organization events for analytics and does not mutate identity-owned organization data.
  • Automatic organization merge is forbidden; merge is manual and audited.

Затрагиваемые области

  • apps/docs/docs/target/domains/identity/*;
  • apps/docs/docs/target/platform/permissions-model.md;
  • apps/docs/docs/target/integrations/identity--all.md;
  • apps/docs/docs/target/integrations/competitions--identity.md;
  • apps/docs/docs/target/integrations/task-bank--identity.md;
  • apps/docs/docs/target/domains/competitions/data-model.md;
  • apps/docs/docs/target/domains/task-bank/data-model.md.

Связи