Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/en/docs/operate/database-migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ literal mutable draft ID `000`. The registered revisions are:
| `v1_5_0_005` | 1.5.0 | 5 | `v1_5_0_005` | Remove previous plugin-framework storage and add nullable Artifact metadata |
| `v1_5_0_006` | 1.5.0 | 6 | `v1_5_0_006` | Source collection runner and target tables; remove the write plugin registry |
| `v1_6_0` | 1.6.0 | — | `v1_6_0` | Independent prepare diagnostics |
| `000` | Unreleased | — | `000` | Shared organization, membership, credentials, and Scope ownership |

Both registered source paths reach `v1_6_0` after `v1_5_0_006`; only 1.3.0 is selected for CI upgrade acceptance:
Both registered source paths reach the frozen `v1_6_0` after `v1_5_0_006`. The development build then applies the shared
draft `000`. Only 1.3.0 is selected for CI upgrade acceptance:

```text
1.3.0: v1_3_0_000 -> v1_4_1_001 -> v1_4_1_002 -> v1_4_1_003 -> v1_4_1_004 -> v1_4_1_005 -> v1_4_1_006 -> v1_5_0_001 -> v1_5_0_002 -> v1_5_0_003 -> v1_5_0_004 -> v1_5_0_005 -> v1_5_0_006 -> v1_6_0
Expand Down
7 changes: 7 additions & 0 deletions docs/en/docs/operate/portable-archive.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ Format version 1 carries the portable relational representation of these support
| Preserved | Not portable |
| --- | --- |
| Scope identity, hierarchy, context/external references, and creation identity | Scope access bindings and host-local default selection |
| Managed Scope ownership for target validation | Organization membership, team assignments, project participation, and invitations |
| Source journal heads, Source records, and referenced remote Source Definition manifests | Search projections and indexes |
| Accepted Memory evidence: per-Source declaration bindings, the Definition manifests they reference, and exact-revision evidence snapshots | Today's registry declarations, which never replace a saved snapshot |
| Artifact Revisions, their timestamps/actors/rollback metadata, stable handles, lineage, cross-Scope publication provenance, and heads | Source cursors and scheduler state |
Expand Down Expand Up @@ -172,6 +173,12 @@ payload for an existing immutable identity never overwrites it: restore exits wi
transaction rolled back. Resolve the conflicting target data or choose a clean destination, then run the same restore
command again.

For an organization-managed Scope, a `scope_organization_owner` record carries `scope_id`, `org_id`, `owner_kind`,
and `owner_id`. A personal Scope records its original `member_id` as the owner ID. Dry-run and restore require the
target database to already contain the same Scope ownership in the same organization. A missing or different
ownership record fails before restore writes start. Membership and Access permissions remain under the target's
control. Use a native database backup to recover the organization catalog itself.

The restore command opens its maintenance Runtime without bootstrapping a new default scope. This lets an archive
containing the canonical default scope restore its original identity and creation key into a fresh target. On the next
normal startup, default-scope bootstrap reuses that creation identity when present. Default selection bindings remain
Expand Down
32 changes: 32 additions & 0 deletions docs/en/docs/workflows/scopes-and-access.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,38 @@ Teams use the API, MCP, or host integrations with their own identities and permi
personal and demonstration deployments, with optional static token authentication. It is not a team RBAC interface; leave
`POWERCONTEXT_SERVER_DASHBOARD_ENABLED=false` in team deployments.

## Onboard an organization

Start the Server with enforced Access, a deployment administrator token, and persistent storage shared by Scope and Access.

```dotenv
POWERCONTEXT_SERVER_ACCESS_MODE=enforced
POWERCONTEXT_SERVER_AUTH_TOKEN=<deployment-administrator-token>
```

Use the deployment administrator token to call `POST /v1/org-bootstrap` with the organization `name`, `slug`,
and the first administrator's `email`. The code has no organization association. Share the returned
`invitation_code` with that person. Redeeming it creates the organization and activates its first administrator.
Organization administrators issue subsequent codes for that organization through
`POST /v1/orgs/{slug}/members/invite`. Existing accounts accept pending invitations through
`POST /v1/my/org-membership-requests/{slug}/accept`.

The Python client's `register_organization_account` generates a random Bearer token and calls the supplied
`save_token` callback before it sends `POST /v1/org-registration`. The request carries the invitation code
and SHA-256 token digest. Pass the saved token back through the `token` argument when retrying. The client
uses that token for subsequent Bearer requests. The Server stores the account and digest in the shared database.
Use the returned `personal_scope_id` as the explicit Scope for the first session.

Server replicas use the same Access deployment ID and cursor signing secret. Embedded deployments can pass
an existing account directory to `create_server_app` for authenticated accounts provisioned outside PowerContext.

To run background processing on a managed Scope, grant `scope.contributor` on that Scope to the service identity
configured by `POWERCONTEXT_SERVER_ACCESS_BACKGROUND_PRINCIPAL_ID`. The worker checks the current Access grant and
Scope ownership when it runs. Direct HTTP requests from the same service identity still follow the usual organization
eligibility checks.

For the membership, team, and project interfaces, see [RFC 2857](https://github.com/oceanbase/powercontext/pull/2857).

## Recover external ownership writes

When `create_server_app` composes the built-in Runtime with relationship/audit stores outside its business transaction,
Expand Down
4 changes: 3 additions & 1 deletion docs/zh/docs/operate/database-migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ MySQL 兼容后端的结构反射支持 CHECK 表达式中的二元 `+`、`-`、
| `v1_5_0_005` | 1.5.0 | 第五步 | `v1_5_0_005` | 移除旧插件框架存储并新增可空的 Artifact 元数据 |
| `v1_5_0_006` | 1.5.0 | 第六步 | `v1_5_0_006` | Source 采集的 runner 与目标表,移除 write 插件登记表 |
| `v1_6_0` | 1.6.0 | — | `v1_6_0` | 独立上下文准备诊断 |
| `000` | 未发布 | — | `000` | 共享组织、成员资格、凭据和 Scope 归属 |

两条已登记来源路径都在 `v1_5_0_006` 之后到达 `v1_6_0`;CI 升级验收只选择 1.3.0:
两条已登记来源路径都在 `v1_5_0_006` 之后到达冻结版本 `v1_6_0`,开发版本再应用共享草稿 `000`。
CI 升级验收只选择 1.3.0:

```text
1.3.0: v1_3_0_000 -> v1_4_1_001 -> v1_4_1_002 -> v1_4_1_003 -> v1_4_1_004 -> v1_4_1_005 -> v1_4_1_006 -> v1_5_0_001 -> v1_5_0_002 -> v1_5_0_003 -> v1_5_0_004 -> v1_5_0_005 -> v1_5_0_006 -> v1_6_0
Expand Down
6 changes: 6 additions & 0 deletions docs/zh/docs/operate/portable-archive.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ powercontext archive restore ./backups/payments.pcb --yes
| 会保留 | 不可移植 |
| --- | --- |
| Scope identity、层级、context/external reference 和创建 identity | Scope access binding 和 host-local default selection |
| 用于校验目标的受管 Scope 归属 | 组织成员资格、团队归属、项目参与关系和邀请 |
| Source journal head、Source record 和引用的远程 Source Definition manifest | 搜索 projection 和 index |
| 已接受的 Memory evidence:逐 Source 的 declaration binding、其引用的 Definition manifest 和精确 revision 的 evidence snapshot | 当前 registry 的 declaration,它不会覆盖已保存的快照 |
| Artifact Revision 及其时间戳、actor、回滚元数据;稳定句柄、lineage、跨 Scope 发布来源和 head | Source cursor 和 scheduler state |
Expand Down Expand Up @@ -149,6 +150,11 @@ Atomic Memory 迁移后,归档保留迁移后的 Atomic Memory identity、不
时,恢复绝不会覆盖它:命令以退出码 `3` 结束,并回滚本次写 transaction。解决目标数据冲突,或选择一个干净的目标后,
再次运行同一个恢复命令。

受组织管理的 Scope 使用 `scope_organization_owner` 记录保存 `scope_id`、`org_id`、`owner_kind` 和
`owner_id`。个人 Scope 使用原始 `member_id` 作为归属对象 ID。dry-run 和实际恢复都要求目标数据库已保存同一
组织下的相同 Scope 归属。归属缺失或不一致会在恢复写入前被拒绝。成员资格和 Access 权限以目标库为准。
恢复整个组织目录时,使用原生数据库备份。

restore 命令会以维护模式打开 Runtime,不预先创建新的默认 scope。因此,包含规范默认 scope 的归档可以在干净的目标中恢复
原始 identity 和创建幂等键;下次正常启动时,默认 scope 初始化会复用该创建 identity。默认选择绑定仍属于部署本地状态,
恢复不会覆盖现有部署的选择,也不会覆盖冲突的 scope。
Expand Down
28 changes: 28 additions & 0 deletions docs/zh/docs/workflows/scopes-and-access.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,34 @@ Scope 选择项目上下文边界。其不透明 ID 用于标识数据,不负
团队通过 API、MCP 或宿主集成使用各自的身份与权限。Dashboard 仅用于个人和演示部署,可选用静态 token 鉴权,
不作为 RBAC 团队入口;团队部署保持 `POWERCONTEXT_SERVER_DASHBOARD_ENABLED=false`。

## 启用组织并接纳成员

启动 Server 时启用 Access 强制模式,配置部署管理员 Token,并让 Scope 和 Access 共用持久化存储。

```dotenv
POWERCONTEXT_SERVER_ACCESS_MODE=enforced
POWERCONTEXT_SERVER_AUTH_TOKEN=<deployment-administrator-token>
```

用部署管理员 Token 调用 `POST /v1/org-bootstrap`,提交组织 `name`、`slug` 和首位管理员的 `email`。
邀请码尚未关联组织。把返回的 `invitation_code` 转交给对方。对方兑换时开立组织,成为首位活跃管理员。
后续由组织管理员通过 `POST /v1/orgs/{slug}/members/invite` 为该组织签发邀请码。已有账号通过
`POST /v1/my/org-membership-requests/{slug}/accept` 接受待处理邀请。

Python 客户端的 `register_organization_account` 生成随机 Bearer Token,并在发出 `POST /v1/org-registration`
之前调用传入的 `save_token` 保存凭据。请求携带邀请码和 Token 的 SHA-256 摘要。重试时通过 `token`
参数传入已保存的 Token。客户端随后用该 Token 发起 Bearer 请求。Server 将账号和摘要存入共享数据库。
首次会话显式选择返回的 `personal_scope_id`。

Server 副本使用相同的 Access 部署 ID 和游标签名密钥。嵌入式部署可向 `create_server_app` 传入已有账号目录,
接纳在 PowerContext 之外配置的认证账号。

要在受管 Scope 上运行后台处理,请在该 Scope 上为 `POWERCONTEXT_SERVER_ACCESS_BACKGROUND_PRINCIPAL_ID`
配置的服务身份授予 `scope.contributor`。后台执行时校验当前 Access 授权和 Scope 归属。同一服务身份直接发起
HTTP 请求时,仍遵循常规组织资格检查。

成员、团队和项目接口见 [RFC 2857](https://github.com/oceanbase/powercontext/pull/2857)。

## 恢复外部所有权写入

`create_server_app` 将内置 Runtime 与业务事务之外的 relationship/audit store 组合时,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,26 @@
// generated from openapi/powercontext.yaml; do not edit.

export const OPERATIONS = {
bootstrap_organization: { method: 'POST', path: '/v1/org-bootstrap', location: "body", scopeMode: 'none', pathParameters: [], queryParams: [], headerParams: [], successStatuses: [200], emptyStatuses: [] },
register_organization_account: { method: 'POST', path: '/v1/org-registration', location: "body", scopeMode: 'none', pathParameters: [], queryParams: [], headerParams: [], successStatuses: [200], emptyStatuses: [] },
get_organization: { method: 'GET', path: '/v1/orgs/{slug}', location: null, scopeMode: 'none', pathParameters: ['slug'], queryParams: [], headerParams: [], successStatuses: [200], emptyStatuses: [] },
edit_organization: { method: 'POST', path: '/v1/orgs/{slug}/edit', location: "body", scopeMode: 'none', pathParameters: ['slug'], queryParams: [], headerParams: [], successStatuses: [204], emptyStatuses: [204] },
list_organization_members: { method: 'GET', path: '/v1/orgs/{slug}/members', location: null, scopeMode: 'none', pathParameters: ['slug'], queryParams: [], headerParams: [], successStatuses: [200], emptyStatuses: [] },
list_organization_member_kinds: { method: 'GET', path: '/v1/orgs/{slug}/member-kinds', location: null, scopeMode: 'none', pathParameters: ['slug'], queryParams: [], headerParams: [], successStatuses: [200], emptyStatuses: [] },
invite_organization_member: { method: 'POST', path: '/v1/orgs/{slug}/members/invite', location: "body", scopeMode: 'none', pathParameters: ['slug'], queryParams: [], headerParams: [], successStatuses: [200], emptyStatuses: [] },
edit_organization_member: { method: 'POST', path: '/v1/orgs/{slug}/members/{member_id}/edit', location: "body", scopeMode: 'none', pathParameters: ['slug', 'member_id'], queryParams: [], headerParams: [], successStatuses: [204], emptyStatuses: [204] },
remove_organization_member: { method: 'DELETE', path: '/v1/orgs/{slug}/members/{member_id}', location: null, scopeMode: 'none', pathParameters: ['slug', 'member_id'], queryParams: [], headerParams: [], successStatuses: [204], emptyStatuses: [204] },
list_my_organizations: { method: 'GET', path: '/v1/my/orgs', location: null, scopeMode: 'none', pathParameters: [], queryParams: [], headerParams: [], successStatuses: [200], emptyStatuses: [] },
get_my_organization_session: { method: 'GET', path: '/v1/my/org-session', location: null, scopeMode: 'none', pathParameters: [], queryParams: [], headerParams: [], successStatuses: [200], emptyStatuses: [] },
rotate_organization_account_token: { method: 'PUT', path: '/v1/my/account-token', location: "body", scopeMode: 'none', pathParameters: [], queryParams: [], headerParams: [], successStatuses: [204], emptyStatuses: [204] },
list_my_organization_requests: { method: 'GET', path: '/v1/my/org-membership-requests', location: null, scopeMode: 'none', pathParameters: [], queryParams: [], headerParams: [], successStatuses: [200], emptyStatuses: [] },
accept_organization_request: { method: 'POST', path: '/v1/my/org-membership-requests/{slug}/accept', location: null, scopeMode: 'none', pathParameters: ['slug'], queryParams: [], headerParams: [], successStatuses: [204], emptyStatuses: [204] },
reject_organization_request: { method: 'POST', path: '/v1/my/org-membership-requests/{slug}/reject', location: null, scopeMode: 'none', pathParameters: ['slug'], queryParams: [], headerParams: [], successStatuses: [204], emptyStatuses: [204] },
list_organization_teams: { method: 'GET', path: '/v1/orgs/{slug}/teams', location: null, scopeMode: 'none', pathParameters: ['slug'], queryParams: [], headerParams: [], successStatuses: [200], emptyStatuses: [] },
create_organization_team: { method: 'POST', path: '/v1/orgs/{slug}/teams', location: "body", scopeMode: 'none', pathParameters: ['slug'], queryParams: [], headerParams: [], successStatuses: [201], emptyStatuses: [] },
assign_organization_team: { method: 'PUT', path: '/v1/orgs/{slug}/members/{member_id}/team', location: "body", scopeMode: 'none', pathParameters: ['slug', 'member_id'], queryParams: [], headerParams: [], successStatuses: [204], emptyStatuses: [204] },
list_organization_projects: { method: 'GET', path: '/v1/orgs/{slug}/projects', location: null, scopeMode: 'none', pathParameters: ['slug'], queryParams: [], headerParams: [], successStatuses: [200], emptyStatuses: [] },
create_organization_project: { method: 'POST', path: '/v1/orgs/{slug}/projects', location: "body", scopeMode: 'none', pathParameters: ['slug'], queryParams: [], headerParams: [], successStatuses: [201], emptyStatuses: [] },
get_recall_manifest: { method: 'POST', path: '/v1/recall/manifest', location: "body", scopeMode: 'current', pathParameters: [], queryParams: [], headerParams: [], successStatuses: [200], emptyStatuses: [] },
list_atomic_memories: { method: 'POST', path: '/v1/atomic-memory/list', location: "body", scopeMode: 'current', pathParameters: [], queryParams: [], headerParams: [], successStatuses: [200], emptyStatuses: [] },
search_atomic_memory: { method: 'POST', path: '/v1/atomic-memory/search', location: "body", scopeMode: 'current', pathParameters: [], queryParams: [], headerParams: [], successStatuses: [200], emptyStatuses: [] },
Expand Down
Loading