Files
trade-message-center/.trellis/spec/server/backend/summary-authorization.md
T

3.3 KiB
Raw Blame History

后台纪要内部网络读取

1. Scope / Trigger

Mind 后台纪要通过与 Center 同一 Docker daemon 的 trade-message-center-summary internal 网络读取单会话历史时应用本规范。Cookie 页面、plugin binding、WS、发送和 public 7878 仍由现有 Mind HTTP 授权处理。网络成员资格是摘要读取的唯一授权边界;Center 不连接 Mind 数据库,也不推导 workspace/user 归属。

2. Signatures

GET http://trade-message-center:7777/api/bright/onetalk/accounts/:channelAccountId/conversations/:conversationId/messages
Query: fromSentAtMs, toSentAtMs, limit?, cursor?
Response: { conversationId, messages, page }

3. Contracts

  • entry.ts 通过 runtime 组合 public 和 internal 两个 Fastify listenerinternal listener 固定绑定 0.0.0.0:7777,只注册 history GET,不注册 WebSocket、CORS、列表、详情或扩展下载路由。
  • internal listener 直接以 server-local communication_summary_read purpose 调用唯一 OneTalkReadService。它不读取 Cookie、Bearer、X-Mind-PurposeX-Mind-Workspace-Id,不回调 Mind,也不返回 scope/workspace/user/binding/authorization version。
  • summary 必须有完整且有效的 [fromSentAtMs,toSentAtMs);cursor 仍绑定账号、会话、窗口和 snapshot。historyComplete=false 返回 503 history_incompleteRetry-After: 30
  • public listener 只走 Cookie/Mind session reader;旧 summary headers 不创建未授权分支。MIND_AUTH_BASE_URL 继续只服务页面/plugin 的通用授权。
  • 发布仅 --publish 7878:7878workflow 让 Center 先加入仅供它自身 egress/public port 的 trade-message-center-public bridge network,再附加 Internal=true 的 summary network。Center 不得留在 Docker 默认 bridge,否则其默认 bridge peers 可直连 7777。Mind 容器由其所有者附加 summary network,且必须与 Center 在同一 Docker daemon。EXPOSE 不提供访问控制。
  • 网络成员可读取任何已知 account/conversationDocker socket 持有者或宿主机 root 不受该边界约束。若需要 workspace 或会话级授权,必须另行恢复明确授权机制,不能从 Center 数据猜测。

4. Validation & Error Matrix

条件 Center 行为
internal 请求缺少 from/to,或 from >= to 400 invalid_time_range
cursor 跨账号/会话/窗口 400 invalid_cursor
历史未完整同步 503 history_incompleteRetry-After: 30
cutover 被暂停或 epoch 变化 503 authorization_unavailable;它表示可用性 fence,不是凭据检查
数据库失败 503 database_unavailable
public 请求携带 retired Bearer/workspace/purpose headers 仍走 Cookie/Mind page 授权;不会获得 internal summary

5. Tests Required

  • internal route 证明无认证读取、完整窗口、history gate、无 scope 响应、数据库/epoch 错误和 cursor 语义。
  • public HTTP/WS/CORS 回归证明 Cookie 授权保持,旧 summary headers 不改变路由选择。
  • release 静态检查证明 token、callback 和 secret 注入已删除;部署时用 docker network inspectdocker port 与 Mind 容器真实请求验证网络。
  • 真实 Docker 网络不可用时单列 external-unverified,不能以 HTTP injection 宣称已经完成双容器验收。