[R4] self 会话与 1:1 会话的最小后端实现 #4

Closed
opened 2026-11-08 23:06:06 +00:00 by keith · 1 comment
Owner

部署背景

单域名 https://wire.treeden.app:根路径由 wire-webapp 提供前端;/api/* 与 /ws/* 由 Caddy 反代到 wire-rs 并剥离前缀(handle_path)。前端配置 BACKEND_REST=https://wire.treeden.app/api、BACKEND_WS=wss://wire.treeden.app/ws。

对接原则

前端尽量不改,由后端适配;后端保持最小,前端启动链路之外的接口返回空值或默认值。

API 版本约定

前端 MAX_API_VERSION 默认 17(libraries/config/src/client.config.ts),wire-rs /api-version 宣称 0–19,协商结果为 17。部署时固定 MAX_API_VERSION=8,后端 /api-version 宣称与之匹配的 supported 范围(上限 8),桩接口按该版本的路径实现;以下路径均为剥离 /v{N} 之后的形式。v7 起 1:1 路径为 /one2one-conversations/...(libraries/api-client/src/conversation/conversationApi/conversationApi.ts)。

现象

wire-rs 只有 MLS 群会话。前端启动时调用 initialiseSelfAndTeamConversations(apps/webapp/src/script/mls/),通过 GET /conversations/mls-self 取 MLS self 会话并建/入 self group;打开与某人的 1:1 时通过 GET /one2one-conversations/{domain}/{uid}(v7+)取 MLS 1:1 会话。两者缺失会导致客户端初始化失败或无法私聊。

期望行为(前端零改动)

self 会话

  • GET /conversations/mls-self → 200,每个用户懒创建一条:type=1(self)、protocol:"mls"、group_id(随机 32 字节 base64)、epoch:0、cipher_suite:1、members.self 为本人、others:[]。
  • 客户端随后对该 group_id 发送 commit bundle(epoch 0 → 1);POST /mls/commit-bundles 需接受 self 会话(成员仅本人的多个设备),并产生 Welcome/事件推送给本人其他设备。
  • 出现在 POST /conversations/list-ids 结果中。

1:1 会话

  • GET /one2one-conversations/{domain}/{uid}(同时接受 /conversations/one2one/{domain}/{uid})→ 200,返回 {"conversation":<Conversation>,"public_keys":{"removal":{"ed25519":"<base64>"}}}(MLS1to1Conversation 形状)。
  • 会话 ID 对两个用户确定性生成(例如 UUIDv5(min(uid)‖max(uid))),type=2(one2one)、protocol:"mls"、epoch:0 起始;首次由任一方建组并 commit。
  • 不需要连接请求流程(R2 的 /list-connections 返回空),即任何已注册用户可直接建立 1:1。
  • POST /one2one-conversations(Proteus 建 1:1)→ 400 {"code":400,"label":"mls-only","message":"Proteus is not supported"},前端在 MLS 默认协议下不会调用。

涉及文件/模块

  • src/conversations/(self、one2one 查询与懒创建)
  • src/mls/(commit-bundle 对 self/1:1 的成员校验)
  • src/http.rs
  • migrations/(会话类型字段或约束)
  • README.md

工作量

M(1–2 天)

## 部署背景 单域名 https://wire.treeden.app:根路径由 wire-webapp 提供前端;`/api/*` 与 `/ws/*` 由 Caddy 反代到 wire-rs 并剥离前缀(handle_path)。前端配置 `BACKEND_REST=https://wire.treeden.app/api`、`BACKEND_WS=wss://wire.treeden.app/ws`。 ## 对接原则 前端尽量不改,由后端适配;后端保持最小,前端启动链路之外的接口返回空值或默认值。 ## API 版本约定 前端 `MAX_API_VERSION` 默认 17(`libraries/config/src/client.config.ts`),wire-rs `/api-version` 宣称 0–19,协商结果为 17。部署时固定 `MAX_API_VERSION=8`,后端 `/api-version` 宣称与之匹配的 supported 范围(上限 8),桩接口按该版本的路径实现;以下路径均为剥离 `/v{N}` 之后的形式。v7 起 1:1 路径为 `/one2one-conversations/...`(`libraries/api-client/src/conversation/conversationApi/conversationApi.ts`)。 ## 现象 wire-rs 只有 MLS 群会话。前端启动时调用 `initialiseSelfAndTeamConversations`(`apps/webapp/src/script/mls/`),通过 `GET /conversations/mls-self` 取 MLS self 会话并建/入 self group;打开与某人的 1:1 时通过 `GET /one2one-conversations/{domain}/{uid}`(v7+)取 MLS 1:1 会话。两者缺失会导致客户端初始化失败或无法私聊。 ## 期望行为(前端零改动) ### self 会话 - `GET /conversations/mls-self` → 200,每个用户懒创建一条:`type=1`(self)、`protocol:"mls"`、`group_id`(随机 32 字节 base64)、`epoch:0`、`cipher_suite:1`、`members.self` 为本人、`others:[]`。 - 客户端随后对该 `group_id` 发送 commit bundle(epoch 0 → 1);`POST /mls/commit-bundles` 需接受 self 会话(成员仅本人的多个设备),并产生 Welcome/事件推送给本人其他设备。 - 出现在 `POST /conversations/list-ids` 结果中。 ### 1:1 会话 - `GET /one2one-conversations/{domain}/{uid}`(同时接受 `/conversations/one2one/{domain}/{uid}`)→ 200,返回 `{"conversation":<Conversation>,"public_keys":{"removal":{"ed25519":"<base64>"}}}`(`MLS1to1Conversation` 形状)。 - 会话 ID 对两个用户确定性生成(例如 UUIDv5(min(uid)‖max(uid))),`type=2`(one2one)、`protocol:"mls"`、`epoch:0` 起始;首次由任一方建组并 commit。 - 不需要连接请求流程(R2 的 `/list-connections` 返回空),即任何已注册用户可直接建立 1:1。 - `POST /one2one-conversations`(Proteus 建 1:1)→ 400 `{"code":400,"label":"mls-only","message":"Proteus is not supported"}`,前端在 MLS 默认协议下不会调用。 ## 涉及文件/模块 - `src/conversations/`(self、one2one 查询与懒创建) - `src/mls/`(commit-bundle 对 self/1:1 的成员校验) - `src/http.rs` - `migrations/`(会话类型字段或约束) - `README.md` ## 工作量 M(1–2 天)
keith changed title from [R4] self 会话(MLS self group) to [R4][必需] self 会话与 1:1 会话的最小后端实现 2026-11-08 23:26:41 +00:00
keith changed title from [R4][必需] self 会话与 1:1 会话的最小后端实现 to [R4] self 会话与 1:1 会话的最小后端实现 2026-11-08 23:37:04 +00:00
Author
Owner

已实现并通过 M11 验收

  • GET /conversations/mls-self:每用户懒创建 type=1、protocol=mls、epoch=0,接受 0→1 commit 并向本人其他设备扇出 Welcome/事件。
  • GET /one2one-conversations/{domain}/{uid}:会话 ID 采用参考 one2OneConvId SHA256 算法(三方交叉验证固定向量),type=2、epoch=0,任一方首次建组 commit;无连接请求流程。
  • POST /one2one-conversations → 400 mls-only。

已知偏差:self/1:1 的 group_id 为随机 32B(参考为确定性);access_role=[];GET /conversations/{cid} 对本人 UUID 存在 create-on-read 写副作用。

M11 accepted · commit 56437e7 · doc docs/milestones/M11.md · gates: default 886 / test:db 177 (14 suites) / interop 971 / live 14 (×3, no flake) · integration agent 221 real-process assertions.

## 已实现并通过 M11 验收 - `GET /conversations/mls-self`:每用户懒创建 `type=1`、`protocol=mls`、`epoch=0`,接受 0→1 commit 并向本人其他设备扇出 Welcome/事件。 - `GET /one2one-conversations/{domain}/{uid}`:会话 ID 采用参考 `one2OneConvId` SHA256 算法(三方交叉验证固定向量),`type=2`、`epoch=0`,任一方首次建组 commit;无连接请求流程。 - `POST /one2one-conversations` → 400 `mls-only`。 已知偏差:self/1:1 的 `group_id` 为随机 32B(参考为确定性);`access_role=[]`;`GET /conversations/{cid}` 对本人 UUID 存在 create-on-read 写副作用。 M11 accepted · commit `56437e7` · doc `docs/milestones/M11.md` · gates: default **886** / test:db **177 (14 suites)** / interop **971** / live **14** (×3, no flake) · integration agent 221 real-process assertions.
keith closed this issue 2026-11-09 14:02:17 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
keith/wire-rs#4
No description provided.