diff --git a/docs/en/rfcs/2857-organization-team-and-project.md b/docs/en/rfcs/2857-organization-team-and-project.md new file mode 100644 index 0000000000..6318dfc941 --- /dev/null +++ b/docs/en/rfcs/2857-organization-team-and-project.md @@ -0,0 +1,453 @@ +--- +title: "RFC 2857: PowerContext Organizations, Teams, and Projects" +description: "Define how organizations, teams, and projects relate, and describe the data structures, interfaces, and permissions needed to manage an organization." +--- + +- Proposal Name: `organization_team_and_project` +- Start Date: 2026-11-26 +- RFC PR: [oceanbase/powercontext#2857](https://github.com/oceanbase/powercontext/pull/2857) + +# Summary + +This RFC defines the PowerContext model for organizations, teams, members, and projects. Organizations directly own teams +and projects. Teams manage members, and a member can participate in multiple projects within the same organization. In +the first version, each shared database serves one organization and can be used by multiple Servers. People using +PowerContext independently manage their own memory through the same Server and Scope interfaces. + +# Motivation + +Organizations need to manage membership and team rosters in one place. Team and project boundaries support different +working relationships. Moving to another team should leave a member's existing project participation intact. An +organization should be able to scale by adding Server instances while keeping membership, projects, and authorization +consistent. + +# Guide-level explanation + +## Deploy PowerContext for yourself + +In an empty deployment, Mei uses the deployment administrator credential to request a signup code with no +associated organization. She redeems it to create her account and default organization, and becomes its first +administrator. She can organize notes in her personal Scope and add teams and projects as needed. Scopes in +existing deployments can still be used as before. + +## Join an organization + +The organization gives administrators a place to admit users and manage membership. An administrator invites Mei by +email address. If Mei already has an account, she can accept the pending invitation. If she has yet to create an +account, the administrator shares an invitation code associated with the organization. Mei joins that organization +when she signs up. The pending invitation appears in the roster. Mei can begin working in the organization once her +membership becomes active. + +## Create teams and assign project members + +An administrator creates the Platform team and two projects, Search and Import. The team roster records which team Mei +belongs to. The organization owns both projects directly, and the administrator gives Mei access to each one separately. +Chen can join the same Platform team and participate only in Search. + +```text +Organization + +-- Platform team ---- roster: Mei, Chen + +-- Search project --- participants: Mei, Chen + +-- Import project --- participant: Mei +``` + +Mei can open either project, and Chen can open Search with the permissions he received. When Mei looks up or records a +decision in Search, project memory is one of the use cases. The detailed design describes the corresponding Scopes and +access rules. + +## Move teams, leave a project, and remove a member + +If Mei moves from Platform to another team, the administrator only needs to update her team assignment. She loses +access to Platform's team memory and keeps her existing project permissions. If Mei finishes her work on Import, the +administrator can revoke her access to that project separately. Removing Mei from the organization ends her access to its +teams and projects. Existing project materials stay in the original projects. + +| Administrator action | Mei's team assignment | Mei's project access | +| --- | --- | --- | +| Move Mei to another team | Switches to the new team | Keeps access to Search and Import | +| Revoke Mei's access to Import | Keeps her current team | Keeps access to Search | +| Remove Mei from the organization | Clears her team assignment | Ends access to projects in the organization | + +## Serve one organization from multiple Servers + +An operator can add a second Server to serve the same organization. Both Servers share one OceanBase logical database. +Users see the same roster, projects, and authorization decisions from either Server. An administrator can issue an +invitation on one Server, and Mei can accept it on the other. + +# Reference-level explanation + +## Organization creation and account signup + +Organization creation and account signup are separate actions that can complete together on first signup. +Signup requires a valid invitation code. **The code's organization association determines whether the user joins an +existing organization or creates a default organization.** A code associated with an organization admits the user +to that organization with the invited role. A deployment administrator issues a code with no organization association +as bootstrap authority for an empty database. The registrant redeems it to create the organization and becomes its +first administrator. The first version supports one organization per logical database. Once it exists, new accounts +join through invitations from that organization. + +```text +Register with a valid invitation code -> Create account + | + +-- Code has org ID -> Join that org with the invited role + +-- Code has no org ID -> Create default org and join as org admin + +Both paths -> Activate membership -> Allocate personal Scope -> Consume code -> First session +``` + +The account, credential digest, organization record if one is created, consumed code, membership, personal Scope, +and Access binding are committed together. A retry with the same code and digest reuses the signup result while the +credential digest is current. +The client generates and saves a random Bearer token and submits its SHA-256 digest with the code. Subsequent +requests use the token through existing Server Bearer authentication. An existing account accepts its own pending +invitation through the organization API to establish or activate membership and receive a personal Scope. + +The system makes the organization just joined or created the account's default organization. The first version has +one organization per database, so the default is derived from the active membership record without storing an +additional field on the account. The client selects the member's personal Scope +in their first organization session. The deployment default Scope, existing bindings, and data are preserved. + +When signing in again, the client calls `GET /v1/my/org-session` with the saved Bearer token to resolve the default +organization and personal Scope from the current active membership. Subsequent requests use the same token. + +An account can call `PUT /v1/my/account-token` with its current token and the SHA-256 digest of a fresh random +token. The client saves the candidate separately before sending the request, then switches credentials after +confirming the outcome. In one shared database transaction, the Server verifies the current digest still belongs to +the caller and replaces it. At most one concurrent replacement succeeds. After commit, subsequent authentication +on every replica requires the new token. The account ID, membership, and Scope grants remain intact. If the +response is lost, the client can call `GET /v1/access/me` with the new token to verify its account identity. +Static deployment tokens and external credentials are managed through their respective configuration or provider. +Recovering an account after credential loss requires a separate flow. + +Subsequent Scope selection follows the order in [RFC 1345](1345_scope_organization_and_agent_integration.md) of +explicit selection, persisted binding, and configured default Scope. Resolving the default organization or selecting a +Scope leaves read and write permissions subject to authorization. + +## Organization boundary and shared database + +The first version supports at most one organization per **logical database**. Multiple Servers can connect to the same +logical database on an OceanBase instance and serve the organization together. Server replicas share the deployment +identity, accounts, credential digests, organization record, members, teams, projects, Scopes, and Access bindings. +Servers connected to different logical databases on the same physical instance use the configuration and data of +their respective logical databases. + +```text +Server A ----+ + +--> OceanBase logical database --> Organization +Server B ----+ +-- Teams + +-- Projects +``` + +A deployment administrator issues the organization bootstrap code through the shared database. At redemption, +the transaction and uniqueness constraints allow concurrent signups to create at most one organization. +Retrying a successful redemption with the same code and credential digest returns its result. A configuration +mismatch rejects redemption. +Replicas read organization and role state from the shared database and use the same Access deployment identifier and +identity mapping. The identity of a replica process is excluded from organization, member, and Scope keys. A request +from the same account uses the same organization member record through either replica. Invitation code consumption, +member changes, and Scope allocation rely on shared database transactions and constraints. Replicas must use current +state to authorize requests. Once a member or role revocation commits, subsequent authorization on any replica must +see it. Migration is coordinated once per logical database using the existing +[shared database migration process](../docs/operate/database-migrations.md). + +The account's default organization is resolved from its sole active membership in the deployment. The first version +derives this value and needs no switch endpoint. The organization slug in a route must identify the deployment's +organization. Persistence keys, queries, and authorization still use `org_id` explicitly. Teams and projects are +resolved within the organization, and members are identified by `(org_id, account_id)`. Account identity, the Access +deployment identifier, and the organization ID are stored separately. A future version can resolve the organization per +request and verify the account's membership in that organization. Existing organization IDs, records, and Scope IDs +keep their identities. Before serving multiple organizations, existing standalone Scopes, database queries, background +jobs, and other shared state need organization isolation. Existing standalone Scopes keep their current access paths in +the first version. Access to an organization-managed Scope must be denied if its ownership cannot be verified. + +Shared database acceptance uses two Servers with the same deployment identifier. After creating a team and project on A, +B should discover the same IDs. Accepting an invitation through either replica should produce one member record and one +personal Scope. After A revokes permissions, the next request on B should be denied. After restarting B, it should +still resolve the same organization and Scopes. + +## Use case for team, project, and personal memory + +| Level | Scope allocation | Purpose | +| --- | --- | --- | +| Organization | No organization-level Scope in the first version | Manage accounts, members, teams, and projects. | +| Team | Allocate a Scope for each team | Store memory needed for the team's ongoing work. | +| Project | Allocate a Scope for each project | Store project memory for members of the organization who participate in the project. | +| Personal | Allocate a personal Scope for each member | Store personal memory. Read access is authorized separately from team or project relationships. | + +```text +PowerContext Server + +-- Organization + +-- Platform team ------> Team Scope + +-- Search project ------> Project Scope + +-- Mei ----------------> Personal Scope +``` + +Team, project, and personal Scopes each own their memory. Read and write permissions are checked independently of team +assignment, project participation, or Scope selection. Organization and member state determine whether the subject is +eligible to access this deployment. The target Scope and requested operation still require authorization. + +## Data structures and constraints + +The table below defines the first version's logical SQL schema. Each backend can map the physical types. IDs are +opaque strings, timestamps use UTC, and fields are non-null by default. A `?` marks a nullable field. Account IDs +identify Server `PrincipalRef` values. Self-service accounts use a shared database record and one Bearer credential digest. + +| Table | Columns | Keys and constraints | +| --- | --- | --- | +| `pc_organizations` | `org_id, slug, name, state, creator_id, created_at, updated_at` | Primary key `org_id`. Unique `slug`. At most one row per database. Created when the first registrant redeems a code with no organization association. `creator_id` is the registrant's account ID. States are `initializing / active / removed`. | +| `pc_organization_accounts` | `account_id, invited_email, name, token_digest, created_at` | Primary key `account_id`. Unique invited email and token digest. The email records the administrator's invitation address. | +| `pc_organization_members` | `member_id, org_id, account_id?, invite_email, kind, state, invited_at?, created_at, updated_at, team_id?, personal_scope_id?` | Primary key `member_id` and foreign key `org_id`. Unique `(org_id, account_id)` once the account is bound. Indexes on `account_id` and `(org_id, invite_email)`. An active member must have an account and a personal Scope. | +| `pc_invitation_codes` | `invitation_id, code, email, org_id?, member_id?, org_name?, org_slug?, member_kind, expire_seconds, created_at, used_at?, deleted_at?` | Primary key `invitation_id`, unique `code`, and nullable foreign key `org_id`. An associated code points to the target organization and membership invitation. A code with no organization association records the future organization's name and slug and records the member ID upon redemption. | +| `pc_teams` | `org_id, team_id, name, scope_id` | Primary key `(org_id, team_id)` and foreign key `org_id`. Unique `scope_id`. | +| `pc_projects` | `org_id, project_id, name, scope_id` | Primary key `(org_id, project_id)` and foreign key `org_id`. Unique `scope_id`. | + +The organization association is set when a code is issued. A code issued with a null `org_id` keeps that value +after redemption. + +A member's `kind` is `admin` or `collaborator`, and their `state` is `invited / active / rejected / expired`. +The first version uses a nullable `team_id` on the member row for the primary team. The composite foreign key +`(org_id, team_id)` keeps the assignment within the organization. Project records use only `org_id` for organizational +ownership. In the first memory use case, existing direct user role bindings on a project's Scope provide the entire +project membership model. + +Each team, project, and active member has its own Scope allocated through the existing Scope creation flow. +`personal_scope_id` is unique in the member table. All three types of binding reference existing Scope records. +The first version allocates new Scopes to these entities, and a Scope can only be assigned to one entity. +The Scope and its ownership record are published together. A Scope whose creation is incomplete stays out of all +discovery endpoints. + +## Invitations and membership state + +A deployment administrator issues a code with no organization association in an empty database. An organization +administrator issues a signup code associated with the current organization. The first administrator and subsequent +new accounts redeem their invitations through the same signup endpoint. + +```text +Invite a registered account --> pending membership --> accept / reject +Invite an unregistered email -> pending membership + signup code + -> administrator shares code + -> signup joins organization +``` + +Redeeming an unassociated code publishes the organization together with the creator's member record and personal +Scope. An associated code requires an existing, active target organization. Existing accounts only act on pending +records bound to their own identity. Acceptance makes the member active, and rejection marks the record as rejected. +An invitation code must be unused, unrevoked, and within its seven-day lifetime. A new account inherits the email +address assigned by the administrator. If an account is provisioned separately after the code was issued, the +administrator can reissue the invitation to bind it to that account for acceptance. Consuming the code and activating +membership must succeed together. Retries and concurrent acceptance must avoid duplicate members and personal Scopes. +Removing a member deletes the membership. Removing an unregistered invitee +also revokes registration codes for that organization and email. + +## HTTP API + +The following paths are relative to `/v1`. Registration uses the invitation code as authorization. Other paths require +Bearer authentication. The path parameter `slug` is the +organization slug, and `member_id` is the ID of a member record in the organization. JSON uses lower snake case field +names. A successful object or array response returns `200`. An empty array indicates no records, and `204` has no +response body. A `?` marks an optional request field. + +| Method and path | JSON request body | Success response | Behavior | +| --- | --- | --- | --- | +| `POST /org-bootstrap` | `{email, name, slug}` | `200 OrganizationBootstrapResponse` | A deployment administrator issues a code with no organization association in an empty database. | +| `POST /org-registration` | `{invitation_code, token_digest, name?}` | `200 OrganizationSession` | Create an account. Use the code's association to join an existing organization or create a default one, and activate membership. | +| `GET /orgs/{slug}` | `—` | `Organization` | Active members read organization details. | +| `POST /orgs/{slug}/edit` | `{name?, slug?}` | `204` | Administrators update the supplied fields. | +| `GET /orgs/{slug}/members` | `—` | `Member[]` | Active organization administrators list the full roster and invitation states. | +| `GET /orgs/{slug}/member-kinds` | `—` | `MemberKind[]` | Returns the fixed role options. | +| `POST /orgs/{slug}/members/invite` | `{email, org_member_kind}` | `200 InviteOrganizationMemberResponse` | Administrators invite an existing account or unregistered email. | +| `POST /orgs/{slug}/members/{member_id}/edit` | `{member_kind}` | `204` | Administrators change another member's role. | +| `DELETE /orgs/{slug}/members/{member_id}` | `—` | `204` | Administrators remove another member or cancel an invitation. | +| `GET /my/orgs` | `—` | `Member[]` | Returns up to one current member record for the caller. | +| `GET /my/org-session` | `—` | `OrganizationSession` | Resolves the caller's default organization and personal Scope from active membership. | +| `PUT /my/account-token` | `{token_digest}` | `204` | Authenticates with the current account token and replaces its stored digest. | +| `GET /my/org-membership-requests` | `—` | `MembershipRequest[]` | Lists pending invitations addressed to the caller. | +| `POST /my/org-membership-requests/{slug}/accept` | `—` | `204` | Accepts the caller's own pending invitation. | +| `POST /my/org-membership-requests/{slug}/reject` | `—` | `204` | Rejects the caller's own pending invitation. | + +Timestamps in the response structures below are RFC 3339 strings. IDs, names, emails, roles, and states are strings. +A `null` value for `account_id` indicates an invitee whose account has yet to be bound. + +| Type | JSON fields | +| --- | --- | +| `Organization` | `name, member_count, state, created_at, updated_at`. The integer `member_count` counts the organization's member records, including pending invitations. | +| `Member` | `id, account_id, account_name, account_email, account_avatar_url, org_slug, org_name, org_state, member_kind, state, created_at, updated_at`. | +| `MembershipRequest` | `org_name, org_slug, account_id, state, created_at, updated_at`. | +| `OrganizationBootstrapResponse` | `org_slug, invitation_code`. The slug is for the organization to be created. | +| `OrganizationSession` | `org_slug, personal_scope_id`. | +| `InviteOrganizationMemberResponse` | `invitation_code` is a string for an unregistered email or `null` for an existing account. The response uses `Cache-Control: no-store`. | +| `MemberKind` | `value`, either `admin` or `collaborator`. | + +Invalid parameters return `400`, missing authentication returns `401`, and insufficient permissions return `403`. +A missing target organization, member, or pending invitation addressed to the caller returns `404`. An invalid, +expired, or revoked registration code returns `403`. Inviting an active member again or registering an account +that already exists returns `409`. Rotation also returns `409` if the replacement matches the current token, +another account's token, or a known deployment credential. Errors use the existing PowerContext HTTP error format. +Issuing or first redeeming a code with no organization association returns `409` if the database already has an +organization. The first version needs no organization switch endpoint. Memory operations use the existing Scope API. + +### Team and project management interfaces + +These interfaces manage only assignments and discovery. Memory for projects, teams, and individuals still uses the +existing Scope API. The `team_id` and `project_id` values used in these routes are opaque IDs within the deployment's +organization. + +| Method and path | JSON request body | Success response | Behavior | +| --- | --- | --- | --- | +| `POST /orgs/{slug}/teams` | `{name}` | `201 Team` | Administrators create a team and its dedicated Scope. | +| `GET /orgs/{slug}/teams` | — | `Team[]` | Administrators list teams to manage rosters. Other active members discover only their own team. | +| `PUT /orgs/{slug}/members/{member_id}/team` | `{team_id: ID or null}` | `204` | Administrators set an active member's team. `null` clears the assignment. An unknown team or one from another organization returns `404`. | +| `POST /orgs/{slug}/projects` | `{name}` | `201 Project` | Administrators create a project and its dedicated Scope. | +| `GET /orgs/{slug}/projects` | — | `Project[]` | Administrators can manage project metadata. Other active members discover only the projects they have permission to read. | + +`Team` returns `team_id, name, scope_id`, and `Project` returns `project_id, name, scope_id`. +All of those fields are non-null strings. The `Member` response adds a nullable `team_id`. Members can discover +Scopes they are authorized to access, including their organization-assigned personal Scope, through the existing +`POST /v1/access/resources/list` endpoint. A caller who can manage project metadata must still pass the data-plane +check to read the project's memory. + +## RBAC, attribute checks, and existing Scope permissions + +### Bearer authentication and authorization + +**A Bearer token identifies the caller.** For protected requests, the Server first resolves the credential to a +Principal through its Authentication Provider, then checks deployment, organization, or Scope permissions for the +requested operation and target resource. + +```text +Authorization: Bearer + -> Authenticate + +-- Invalid credential -> 401 + +-- Valid credential -> Resolve Principal + +-- Deployment admin operation -> Check server.admin + +-- Organization operation ----> Check active membership and org role + +-- Managed Scope operation ---> Check organization ownership, active membership, + and permission for the target Scope and action +``` + +When `POWERCONTEXT_SERVER_AUTH_TOKEN` is used for compatibility authentication, the static token resolves to a fixed +service Principal, `server-token`. The Server initializes deployment administrator permissions for that Principal, +and callers who use the same credential share that identity. Organization collaboration uses account-level tokens. +The Server resolves them to individual user Principals through its Authentication Provider and checks permissions +through existing Access. For accounts registered with an invitation code, the provider uses the credential digest +in the shared database. See [Server configuration](../docs/operate/configuration.md). + +### Deployment administrators, organization administrators, and members + +The account provides identity. Server Access, organization membership, and Scope Access record three independent layers +of authorization. + +```text +Account + +-- Server Access binding -> server.admin + +-- Organization membership -> admin | collaborator + +-- Scope Access bindings -> permissions on specific Scopes +``` + +| Identity or role | Responsibilities | +| --- | --- | +| Deployment administrator `server.admin` | Manage the Server deployment and issue organization bootstrap codes. Its authority covers the deployment identifier shared by its Server replicas. | +| Organization administrator `admin` | Manage the organization, membership invitations, team rosters, and projects. The registrant who creates the organization receives this role. | +| Organization member `collaborator` | Participate as an active member and use projects and memory according to the corresponding Scope authorizations. | + +The same person can hold both deployment and organization administrator permissions when setting up their own +deployment. Inviting another organization administrator grants an organization role on that person's membership. +Reading team, project, and personal memory still requires authorization on the target Scope. + +### Organization operations and Scope authorization + +Active collaborators and administrators can read organization details. Editing the organization requires an active +administrator. The role determines the available operations. Authorization checks the account, target organization, and +member state. The slug in the route resolves the target organization. + +```text +Authenticated account + organization slug + | + v + Resolve organization ID + | + v + Find membership for account + org + | + active membership? + / \ + no yes + deny read allowed + | + admin role? + | + yes: edit allowed +``` + +Server Access still evaluates existing PowerContext operations such as `scope.read` and `scope.contribute`. +Sources and Artifact revisions still belong to their Scope. The product organization manages membership. The Scope +`Organization Parent` organizes Scopes, and the parent relationship leaves read access subject to authorization. +[RFC 1345](1345_scope_organization_and_agent_integration.md) + +Organization-managed Scopes use existing Access endpoints to create, replace, and revoke bindings. +Organization administrators can grant team Scope roles only to active members of the current team and project Scope +roles only to active members of the current organization. Grants must also satisfy existing Access management +permissions. An administrator who creates a team or project receives `scope.admin` for its Scope. Reading still +requires `scope.read`. When the initial member or a new member is activated, existing Access grants that member +`scope.contributor` for their personal Scope and publishes the binding with the member record. + +## Access behavior for memory + +- **Team.** An administrator creates a team and allocates a team Scope. Administrators can add active members to a + team, remove them, or move them to another team. Moving teams updates only the team field on the organization + member row. Existing project bindings are preserved. Team memory requires current team assignment and permission + for the requested operation on its Scope. +- **Project.** An administrator creates a project and its Scope in the current organization. Eligible organization + members can receive roles on multiple project Scopes through existing Access. Each memory operation uses a + single, explicitly selected project. Scope authorization is evaluated for that operation and target. +- **Personal.** The initial administrator and each approved member receive a personal Scope, published when their + membership becomes active. The data plane allows only the member to perform operations that Access authorizes in + their personal Scope. +- **Member removal.** Revoke the member's Scope bindings in the organization before deleting the roster record. + Once deletion takes effect, the membership check immediately denies subsequent access even if other resource bindings + exist. Memory stays in its original Scope, and existing Scope ownership is preserved. A member who later rejoins + needs new project permissions. +- **Access boundary.** The organization and member must both be active, and the operation must be authorized on the + Scope. This check applies to reads, writes, discovery, and the Scope candidates considered by Prepare Context. + Context References still require authorization. Managing the organization or roster leaves memory reads subject to + the same permission check. + +## Background processing and portable archives + +Server background processing uses a configured service identity and checks its current Access grant on the Scope. +For a managed Scope it also verifies the Scope's organization and ownership. Requests from a service identity over +HTTP follow the same organization eligibility rules as other HTTP requests. + +A portable archive records the organization ID, owner kind, and owner ID for each managed Scope. Restore requires +the target database to have the same Scope, organization, and ownership. Use native database recovery to restore +the organization catalog itself. See [Portable archives](../docs/operate/portable-archive.md). + +# Drawbacks + +Hosting multiple organizations in the first version requires separate logical databases and Server deployment +contexts, which increases operational cost. A single organization can still add Server replicas. + +# Rationale and alternatives + +One organization per shared database supports multiple teams and projects within an organization and simplifies how +accounts select an organization. Hosting multiple organizations in one service requires resolving the organization on +each request, isolating member and discovery operations by organization, and checking that the target team, project, +personal Scope, and referenced resources all belong to that organization. Personal Scopes are identified by organization +and member, so the same person can have a separate personal Scope in each organization. Whether to allocate an +organization-level Scope depends on whether organization-wide memory is needed. + +# Prior art + +[RFC 1345](1345_scope_organization_and_agent_integration.md) defines Scope ownership of persistent memory. +Server Access already evaluates operation permissions on Scope resources. + +# Unresolved questions + +- Claiming existing standalone Scopes and handling retained personal Scopes after someone leaves the organization need + separate lifecycle rules. +- The need for team management roles beyond administrators is left to future work. + +# Future possibilities + +A single service could host multiple organizations by reusing tables keyed by organization and stable IDs, and adding +request-level organization resolution and data isolation. diff --git a/docs/zh/rfcs/2857-organization-team-and-project.md b/docs/zh/rfcs/2857-organization-team-and-project.md new file mode 100644 index 0000000000..9e283007d5 --- /dev/null +++ b/docs/zh/rfcs/2857-organization-team-and-project.md @@ -0,0 +1,382 @@ +--- +title: "RFC 2857:PowerContext 组织、团队与项目" +description: "定义组织、团队与项目的关系,并说明组织管理所需的数据结构、接口和权限。" +--- + +- Proposal Name: `organization_team_and_project` +- Start Date: 2026-11-26 +- RFC PR: [oceanbase/powercontext#2857](https://github.com/oceanbase/powercontext/pull/2857) + +# Summary + +本 RFC 定义 PowerContext 的组织、团队、成员和项目模型。组织直接拥有团队和项目,团队负责管理成员, +同一成员可以参与组织内的多个项目。组织部署首版每套共享数据承载一个组织,可由多个 Server 共同提供服务。 +独立使用时,用户通过相同的 Server 和 Scope 接口处理自己的记忆。 + +# Motivation + +组织需要统一管理成员和团队名册,团队和项目的边界则服务于不同的协作关系。成员换队时,其现有项目参与 +关系不应随之变化。同一组织需要能通过增加 Server 实例扩容,同时保持成员、项目和授权的一致性。 + +# Guide-level explanation + +## 为自己部署 PowerContext + +空部署中,小梅用部署管理员凭据申请一张未关联组织的注册邀请码。她用邀请码注册,创建账号和默认组织, +并成为该组织的首位管理员。她可以用分配到的个人 Scope 整理笔记,以后再按需要添加团队和项目。 +已有部署中的 Scope 仍可按原方式使用。 + +## 加入组织 + +组织是管理员接纳用户、管理成员资格的入口。管理员通过邮箱邀请小梅。如果小梅已有账号,她可以接受 +待处理邀请。如果她还没有账号,管理员将关联到该组织的邀请码转交给她。小梅用邀请码注册后加入该组织。 +待处理邀请会出现在成员名册中,成员资格生效后,小梅就可以在组织内开展工作。 + +## 建立团队并安排项目成员 + +管理员创建平台团队,以及搜索和导入两个项目。团队名册记录小梅属于哪个团队。两个项目都直接归组织, +管理员分别授予小梅两个项目的访问权限。小陈同样可以加入平台团队,只参与搜索项目。 + +```text +Organization + +-- Platform team ---- roster: Mei, Chen + +-- Search project --- participants: Mei, Chen + +-- Import project --- participant: Mei +``` + +小梅可以打开任意一个项目,小陈按所获权限打开搜索项目。小梅在搜索项目中查找或记录决策时,项目记忆 +是其中一个应用场景。对应的 Scope 和访问规则见详细设计。 + +## 换队、退出项目与移出组织 + +如果小梅从平台团队调到另一个团队,管理员只需更新她的团队归属。她不再访问平台团队的团队记忆, +原有项目权限继续有效。如果小梅结束导入项目的工作,管理员可以单独撤销该项目的访问权限。 +将小梅移出组织后,她失去对组织内团队和项目的访问权限,已有项目材料仍留在原项目。 + +| 管理员操作 | 小梅的团队归属 | 小梅的项目访问 | +| --- | --- | --- | +| 将小梅调到另一团队 | 改为新团队 | 保留搜索和导入项目权限 | +| 撤销小梅的导入项目权限 | 保持原团队 | 保留搜索项目权限 | +| 将小梅移出组织 | 解除团队归属 | 终止组织内的项目访问 | + +## 由多个 Server 服务同一个组织 + +运维人员可以增加第二个 Server 来服务同一组织。两个 Server 共用同一个 OceanBase 逻辑数据库, +用户从任一 Server 访问,看到的成员名册、项目和权限判定都一致。管理员可以在一个 Server 发出邀请, +小梅可以在另一个 Server 接受。 + +# Reference-level explanation + +## 新组织开立与账号注册 + +开立组织和注册账号是两个动作,可以在首次注册时一起完成。注册需要有效邀请码。**邀请码是否关联组织, +决定注册者加入已有组织还是开立默认组织。** 使用关联组织的邀请码注册时,注册者按邀请指定的角色加入目标组织。 +未关联组织的邀请码由部署管理员签发,用于在空库开立组织。持码注册者开立组织并成为首位组织管理员。 +首版每个逻辑库最多一个组织。库里已有组织时,新账号通过该组织签发的邀请加入。 + +```text +Register with a valid invitation code -> Create account + | + +-- Code has org ID -> Join that org with the invited role + +-- Code has no org ID -> Create default org and join as org admin + +Both paths -> Activate membership -> Allocate personal Scope -> Consume code -> First session +``` + +新账号、凭据摘要、必要的组织记录、邀请码消费、成员关系、个人 Scope 和 Access 绑定在同一事务提交。 +凭据摘要未轮替时,使用相同邀请码和摘要重试会复用同一次开户结果。客户端生成并保存随机 Bearer Token,将它的 SHA-256 摘要和 +邀请码一起提交。后续请求通过 Server 现有 Bearer 认证使用该 Token。已有账号通过组织 API 接受自己的待处理邀请, +建立或激活该组织的成员关系并获得个人 Scope。 +系统将本次加入或创建的组织作为账号的默认组织。首版每库只有一个组织,默认值从活跃成员记录推导,无需为 +账号另存字段。客户端在首次组织会话中选中该成员的个人 Scope。部署级默认 Scope、已有绑定和数据都保留。 + +再次登录时,客户端用已保存的 Bearer Token 调用 `GET /v1/my/org-session`,从当前活跃的成员关系读取默认组织 +和个人 Scope。后续请求继续使用该 Token。 + +账号可以用当前 Token 调用 `PUT /v1/my/account-token`,提交新随机 Token 的 SHA-256 摘要。客户端先将新 +Token 另行保存,确认结果后再替换正在使用的凭据。Server 在共享数据库的同一事务中验证当前摘要仍属于调用 +账号,并替换摘要。并发提交至多成功一次。提交后,所有 Server 的后续认证都要求使用新 Token。账号 ID、成员 +关系和 Scope 授权保持原样。若响应丢失,客户端可用新 Token 调用 `GET /v1/access/me` 验证账号身份。 +部署静态 Token 和外部身份提供方的凭据各自通过其配置或提供方管理。账号凭据丢失后的恢复需要独立流程。 + +之后的 Scope 选择沿用 [RFC 1345](1345_scope_organization_and_agent_integration.md) 的顺序,即显式 +选择、持久化绑定、配置的默认 Scope。默认组织和 Scope 选择本身不授予读写权限。 + +## 组织边界与共享数据库 + +首版每个**逻辑数据库**最多有一个组织。多个 Server 可以连接同一 OceanBase 实例中的同一逻辑数据库, +共同服务该组织。Server 副本共享部署身份、账号、凭据摘要、组织记录、成员、团队、项目、Scope 和 Access 绑定。 +连接同一物理实例但使用不同逻辑库的 Server,则各自使用其逻辑库的配置和数据。 + +```text +Server A ----+ + +--> OceanBase logical database --> Organization +Server B ----+ +-- Teams + +-- Projects +``` + +部署管理员在共享数据库中签发开立组织的邀请码。兑换时,事务和唯一约束保证并发注册最多开立一个组织。 +用同一邀请码和凭据摘要重试成功的兑换,仍得到原结果。配置不一致时拒绝兑换。 +副本从共享数据库读取组织和角色状态,使用一致的 Access 部署 +标识与身份映射。副本的进程标识不进入组织、成员或 Scope 的键。同一账号通过任一副本发起请求,使用 +同一组织成员记录。邀请码消费、成员修改和 Scope 分配依赖共享数据库事务与约束。副本不得用过期的本地 +状态继续授权,成员或角色撤销提交后,任一副本的后续授权都须看到撤销结果。迁移按逻辑数据库协调一次, +遵循现有的[共享数据库迁移流程](../docs/operate/database-migrations.md)。 + +账号的默认组织由本部署内唯一的活跃成员关系解析,首版无需另存字段或提供切换入口。路由中的组织 slug 必须指向本部署的组织。 +持久化键、查询及授权仍显式使用 `org_id`,团队和项目按组织定位,成员用 `(org_id, account_id)` 定位。 +账号身份、Access 部署标识和组织 ID 分开保存。未来可将组织解析改为请求级选择,再验证账号在该组织的成员 +关系。已有组织 ID、记录和 Scope ID 无需重编号。多组织上线前仍需补齐已有独立 Scope、数据库查询、后台任务和其他共享状态的组织隔离。首版上线后,已有 +独立 Scope 沿用现有访问路径。受组织管理的 Scope 无法验证归属时,必须拒绝访问。 + +共享库验收使用部署标识相同的两个 Server。通过 A 创建团队和项目,在 B 上应发现相同 ID。通过任一副本 +接受邀请,应只产生一份成员记录和个人 Scope。通过 A 撤销权限后,B 上的下一次请求应被拒绝。重启 B 后, +应仍能解析相同的组织与 Scope。 + +## 应用场景:团队、项目与个人记忆 + +| 层级 | Scope 分配 | 用途 | +| --- | --- | --- | +| 组织 | 首版不分配组织级 Scope | 管理账号、成员、团队和项目。 | +| 团队 | 分配团队自己的 Scope | 保存团队持续工作所需的记忆。 | +| 项目 | 分配项目自己的 Scope | 保存项目记忆,供组织内参与该项目的成员协作。 | +| 个人 | 给成员分配个人 Scope | 保存个人记忆,团队或项目关系不会因此获得读取权限。 | + +```text +PowerContext Server + +-- Organization + +-- Platform team ------> Team Scope + +-- Search project ------> Project Scope + +-- Mei ----------------> Personal Scope +``` + +团队、项目和个人的 Scope 各自拥有其记忆。团队归属、项目参与和选择 Scope 本身都不授予读写权限。 +组织及成员状态决定主体是否有资格访问本部署,目标 Scope 和具体操作仍需授权。 + +## 数据结构与约束 + +下表定义首版逻辑 SQL 结构,物理类型可由各后端映射。ID 为不透明字符串,时间戳使用 UTC,字段默认 +非空,表中 `?` 表示可空。账号 ID 对应 Server `PrincipalRef`。自助开户的账号在共享库保存一份 Bearer 凭据摘要。 + +| 表 | 列 | 键与约束 | +| --- | --- | --- | +| `pc_organizations` | `org_id, slug, name, state, creator_id, created_at, updated_at` | 主键 `org_id`,`slug` 唯一。首版每库最多一条组织记录。持未关联组织的邀请码首次注册时创建,`creator_id` 为注册者账号 ID。状态为 `initializing / active / removed`。 | +| `pc_organization_accounts` | `account_id, invited_email, name, token_digest, created_at` | 主键 `account_id`,受邀邮箱和凭据摘要各自唯一。邮箱记录管理员指定的受邀地址。 | +| `pc_organization_members` | `member_id, org_id, account_id?, invite_email, kind, state, invited_at?, created_at, updated_at, team_id?, personal_scope_id?` | 主键 `member_id`,外键 `org_id`,账号绑定后 `(org_id, account_id)` 唯一;索引 `account_id` 与 `(org_id, invite_email)`。活跃成员必须绑定账号与个人 Scope。 | +| `pc_invitation_codes` | `invitation_id, code, email, org_id?, member_id?, org_name?, org_slug?, member_kind, expire_seconds, created_at, used_at?, deleted_at?` | 主键 `invitation_id`,`code` 唯一,可空外键 `org_id`。关联码指向目标组织及成员邀请。未关联码记录待开立组织的名称和 slug,兑换后记录成员 ID。 | +| `pc_teams` | `org_id, team_id, name, scope_id` | 主键 `(org_id, team_id)`,外键 `org_id`,`scope_id` 唯一。 | +| `pc_projects` | `org_id, project_id, name, scope_id` | 主键 `(org_id, project_id)`,外键 `org_id`,`scope_id` 唯一。 | + +邀请码的组织关联在签发时确定。未关联码保存空的 `org_id`,即使兑换后也保留这个值。 + +成员的 `kind` 为 `admin` 或 `collaborator`,`state` 为 `invited / active / rejected / expired`。 +首版通过成员行上的可空 `team_id` 表达主要团队,使用 `(org_id, team_id)` 复合外键确保同组织。 +项目不保存团队 ID。首个记忆场景用既有 Access 的项目 Scope 直接用户角色绑定表达项目参与,无需项目成员表。 + +每个团队、项目和活跃成员分别绑定一个由现有 Scope 创建流程分配的专属 Scope。`personal_scope_id` +在成员表内唯一。三类绑定都引用现有 Scope,首版不接管已有 Scope,因此同一个 Scope 不能再次分配给其他对象。 +Scope 和归属记录一起发布,创建未完成的 Scope 不出现在任何发现入口。 + +## 邀请与成员状态 + +部署管理员在空库签发未关联组织的邀请码。组织管理员发出的注册邀请码关联到当前组织。首位管理员和后续 +新账号使用同一个注册接口兑换邀请码。 + +```text +Invite a registered account --> pending membership --> accept / reject +Invite an unregistered email -> pending membership + signup code + -> administrator shares code + -> signup joins organization +``` + +兑换未关联码时,组织与创建者的成员记录和个人 Scope 一起发布。兑换关联码时,目标组织必须存在且活跃。 +已有账号只处理绑定到自己的待接受记录,接受后转为活跃,拒绝后转为已拒绝。邀请码须未使用、未撤销且 +处于七天有效期内。新账号继承管理员指定的受邀地址。 +如果邀请码签发后账号在外部创建,管理员可以重新发邀请,将邀请绑定到该账号,由账号在站内接受。 +消费邀请码与激活成员必须一并成功。重试及并发接受不得创建重复的成员或个人 Scope。 +移除成员删除成员关系;移除尚未注册的受邀者还会撤销该组织和邮箱的注册邀请码。 + +## HTTP API + +以下路径相对于 `/v1`。开户使用邀请码授权,其余路径要求 Bearer 认证。路径参数 `slug` 是组织 slug, +`member_id` 是该组织的成员记录 ID。 +JSON 使用小写下划线字段名。带对象或数组的成功响应为 `200`,空数组表示无记录,`204` 无响应体。 +请求体中的 `?` 表示字段可省略。 + +| 方法和路径 | JSON 请求体 | 成功响应 | 行为 | +| --- | --- | --- | --- | +| `POST /org-bootstrap` | `{email, name, slug}` | `200 OrganizationBootstrapResponse` | 部署管理员在空库签发未关联组织的邀请码。 | +| `POST /org-registration` | `{invitation_code, token_digest, name?}` | `200 OrganizationSession` | 创建账号。按邀请码关联加入已有组织或开立默认组织,并激活成员关系。 | +| `GET /orgs/{slug}` | `—` | `Organization` | 活跃成员读取组织详情。 | +| `POST /orgs/{slug}/edit` | `{name?, slug?}` | `204` | 管理员更新提供的字段。 | +| `GET /orgs/{slug}/members` | `—` | `Member[]` | 活跃组织管理员列出完整名册和邀请状态。 | +| `GET /orgs/{slug}/member-kinds` | `—` | `MemberKind[]` | 返回固定角色选项。 | +| `POST /orgs/{slug}/members/invite` | `{email, org_member_kind}` | `200 InviteOrganizationMemberResponse` | 管理员邀请已有账号或未注册邮箱。 | +| `POST /orgs/{slug}/members/{member_id}/edit` | `{member_kind}` | `204` | 管理员更改目标成员的角色,不可编辑自己。 | +| `DELETE /orgs/{slug}/members/{member_id}` | `—` | `204` | 管理员移除成员或取消邀请,不可移除自己。 | +| `GET /my/orgs` | `—` | `Member[]` | 返回调用者当前的成员记录,最多一条。 | +| `GET /my/org-session` | `—` | `OrganizationSession` | 从调用者的活跃成员关系解析默认组织和个人 Scope。 | +| `PUT /my/account-token` | `{token_digest}` | `204` | 使用当前账号 Token 认证并替换共享库中的凭据摘要。 | +| `GET /my/org-membership-requests` | `—` | `MembershipRequest[]` | 列出发给调用者的待接受邀请。 | +| `POST /my/org-membership-requests/{slug}/accept` | `—` | `204` | 接受调用者自己的待处理邀请。 | +| `POST /my/org-membership-requests/{slug}/reject` | `—` | `204` | 拒绝调用者自己的待处理邀请。 | + +响应结构如下。时间戳使用 RFC 3339 字符串,ID、名称、邮箱、角色和状态均为字符串。`account_id` +可为 `null`,表示受邀者尚未绑定账号。 + +| 结构 | JSON 字段 | +| --- | --- | +| `Organization` | `name, member_count, state, created_at, updated_at`。其中 `member_count` 为整数,统计该组织的成员记录,包括待接受的记录。 | +| `Member` | `id, account_id, account_name, account_email, account_avatar_url, org_slug, org_name, org_state, member_kind, state, created_at, updated_at`。 | +| `MembershipRequest` | `org_name, org_slug, account_id, state, created_at, updated_at`。 | +| `OrganizationBootstrapResponse` | `org_slug, invitation_code`。其中 `org_slug` 是待开立组织的 slug。 | +| `OrganizationSession` | `org_slug, personal_scope_id`。 | +| `InviteOrganizationMemberResponse` | 受邀邮箱未注册时,`invitation_code` 为字符串。已有账号时为 `null`。响应使用 `Cache-Control: no-store`。 | +| `MemberKind` | `value`,为 `admin` 或 `collaborator`。 | + +参数无效返回 `400`,未认证返回 `401`,权限不足返回 `403`,目标组织、成员或调用者的待处理邀请 +不存在时返回 `404`。无效、过期或已撤销的注册邀请码返回 `403`。重复邀请活跃成员或注册已有账号返回 +`409`。轮替时,新摘要与当前账号 Token、其他账号 Token 或部署已知凭据冲突也返回 `409`。 +错误使用现有 PowerContext HTTP 错误结构。 +库中已有组织时,签发或首次兑换未关联码返回 `409`。首版无需组织切换入口。记忆操作沿用现有 Scope API。 + +### 团队与项目管理接口 + +以下接口只管理归属与发现。项目、团队和个人的记忆内容继续使用已有 Scope API。路径中的 `team_id` +和 `project_id` 是部署组织下的不透明 ID。 + +| 方法和路径 | JSON 请求体 | 成功响应 | 行为 | +| --- | --- | --- | --- | +| `POST /orgs/{slug}/teams` | `{name}` | `201 Team` | 管理员创建团队和专属 Scope。 | +| `GET /orgs/{slug}/teams` | — | `Team[]` | 管理员列出团队以管理名册,其他活跃成员仅发现自己的团队。 | +| `PUT /orgs/{slug}/members/{member_id}/team` | `{team_id: ID or null}` | `204` | 管理员设置活跃成员的团队,`null` 解除归属。外组织或未知团队返回 `404`。 | +| `POST /orgs/{slug}/projects` | `{name}` | `201 Project` | 管理员创建项目和专属 Scope。 | +| `GET /orgs/{slug}/projects` | — | `Project[]` | 管理员可以管理项目元数据。其他活跃成员只发现具有读取权限的项目。 | + +`Team` 返回 `team_id, name, scope_id`,`Project` 返回 `project_id, name, scope_id`。 +以上字段均为非空字符串。`Member` 响应增加可空 `team_id`。成员可通过既有的 +`POST /v1/access/resources/list` 发现其已获授权的 Scope,包括组织分配的个人 Scope。 +有权管理项目元数据的调用者仍须通过数据面检查才能读取其记忆。 + +## RBAC、属性检查与现有 Scope 权限 + +### Bearer 认证与授权 + +**Bearer Token 用来识别调用者。** 对受保护的请求,Server 先通过认证提供方将凭据解析为 Principal, +再根据本次操作和目标资源判断部署、组织或 Scope 权限。 + +```text +Authorization: Bearer + -> Authenticate + +-- Invalid credential -> 401 + +-- Valid credential -> Resolve Principal + +-- Deployment admin operation -> Check server.admin + +-- Organization operation ----> Check active membership and org role + +-- Managed Scope operation ---> Check organization ownership, active membership, + and permission for the target Scope and action +``` + +使用 `POWERCONTEXT_SERVER_AUTH_TOKEN` 作为兼容认证时,静态 Token 映射到固定的服务 Principal +`server-token`。Server 为该 Principal 初始化部署管理员授权,持有同一凭据的调用者共享这个身份。 +组织协作使用账号级 Token。Server 通过认证提供方把它解析为具体的用户 Principal,再由现有 Access 判定权限。 +通过邀请码开户的账号使用共享数据库中的凭据摘要解析。见 [Server 配置](../docs/operate/configuration.md)。 + +### 部署管理员、组织管理员和普通成员 + +账号提供身份。Server Access、组织成员关系和 Scope Access 分别记录三个层级的授权。 + +```text +Account + +-- Server Access binding -> server.admin + +-- Organization membership -> admin | collaborator + +-- Scope Access bindings -> permissions on specific Scopes +``` + +| 身份或角色 | 职责 | +| --- | --- | +| 部署管理员 `server.admin` | 管理 Server 部署并签发开立组织的引导码。多个 Server 共用同一部署标识时,权限以该部署为范围。 | +| 组织管理员 `admin` | 管理所属组织、成员邀请、团队名册和项目。开立组织的注册者获得这一角色。 | +| 普通组织成员 `collaborator` | 以活跃成员身份参与组织,按对应 Scope 的授权使用项目和记忆。 | + +首次自部署时,同一个人可以同时拥有部署管理员和组织管理员权限。邀请另一位组织管理员,只在其成员关系上 +授予组织角色。团队、项目和个人记忆的读取仍须通过目标 Scope 的授权检查。 + +### 组织操作与 Scope 授权 + +组织读取允许活跃协作者和管理员,组织编辑要求活跃管理员。角色决定操作范围, +账号、目标组织与成员状态是授权时检查的属性。路由中的 slug 用于解析目标组织。 + +```text +Authenticated account + organization slug + | + v + Resolve organization ID + | + v + Find membership for account + org + | + active membership? + / \ + no yes + deny read allowed + | + admin role? + | + yes: edit allowed +``` + +PowerContext 已有的 `scope.read` 和 `scope.contribute` 等操作仍由 Server Access 判定。 +Source 和 Artifact 修订版本仍归 Scope 所有。产品组织与 Scope 的 `Organization Parent` 是不同的概念, +后者用于组织 Scope,父关系不授予读取权限。[RFC 1345](1345_scope_organization_and_agent_integration.md) + +受组织管理的 Scope 沿用现有 Access 的绑定创建、替换和撤销入口。 +组织管理员只能将团队 Scope 角色授予当前团队的活跃成员,项目 Scope 角色只能授予当前组织的活跃成员, +并且任何授权仍须满足 Access 原有的管理权限。创建团队或项目的管理员获得该 Scope 的 +`scope.admin`,该角色不隐含 `scope.read`。初始成员和新成员激活时,通过现有 Access 授予其个人 +Scope 的 `scope.contributor`,同时发布成员记录。 + +## 记忆场景的访问行为 + +- **团队。** 管理员创建团队并分配团队 Scope。管理员将活跃成员加入团队、移除或调往另一团队。 + 换队只修改组织成员行上的团队字段,既有项目绑定不变。团队记忆要求当前团队归属与对应 Scope 操作权限。 +- **项目。** 管理员在当前组织建立项目及其 Scope。符合组织成员条件的用户可通过现有 Access 获得多个 + 项目 Scope 的角色。一次记忆操作只使用明确选定的项目,Scope 授权按当前操作及目标执行。 +- **个人。** 初始管理员和获准入组的成员各获得一个个人 Scope,在成员激活时一起发布。 + 数据面只允许该成员本人在其个人 Scope 内由 Access 授权的操作。 +- **移除成员。** 删除名册记录前撤销成员在组织内的 Scope 绑定。删除生效后,成员资格检查立即拒绝后续 + 访问,即使另有资源绑定。移除不迁移记忆或改变既有 Scope 的归属。以后重新加入须重新获得项目权限。 +- **访问边界。** 组织活跃、成员活跃与 Scope 操作权限必须同时满足。该检查应用于读取、写入、发现和 + Prepare Context 的候选 Scope;Context Reference 不代替授权。管理组织或名册本身不赋予读取记忆的权限。 + +## 后台处理与便携归档 + +Server 后台处理使用配置的服务身份,执行时检查该身份在目标 Scope 上的当前 Access 授权。对受管 Scope, +后台还要验证其组织和归属。服务身份发起 HTTP 请求时,适用相同的组织资格规则。 + +便携归档为每个受管 Scope 记录组织 ID、所有者类型和所有者 ID。恢复要求目标数据库中已存在同一 Scope、 +同一组织和同一归属。恢复组织目录本身使用原生数据库恢复流程。见[便携归档](../docs/operate/portable-archive.md)。 + +# Drawbacks + +首版托管多个组织需要独立的逻辑数据库和 Server 部署上下文,增加运维成本。同组织仍可增加 Server 副本。 + +# Rationale and alternatives + +一套共享数据承载一个组织,已经能支持组织内的多团队和多项目协作,并简化了账号的组织选择。 +如果同一服务承载多个组织,每次请求都需要确定组织上下文,成员和发现操作按组织隔离,并检查目标团队、 +项目、个人 Scope 和引用的资源是否都归该组织。个人 Scope 按组织和成员定位,同一个人可以在不同组织 +拥有各自的个人 Scope。是否需要额外分配组织级 Scope,则取决于是否要支持全组织共享记忆。 + +# Prior art + +[RFC 1345](1345_scope_organization_and_agent_integration.md) 定义了 Scope 的持久化记忆归属。 +Server Access 已能对 Scope 资源判定操作权限。 + +# Unresolved questions + +- 已有独立 Scope 的认领,以及退出组织后保留的个人 Scope 的处置,需要独立的生命周期规则。 +- 是否需要管理员以外的团队管理角色,留待后续工作。 + +# Future possibilities + +未来可在同一服务内托管多个组织,沿用已经按组织归属的表和稳定 ID,补充请求级组织解析和数据隔离。