fix(report): 跨团队完成回报精确回注主编排 Session - #764
Conversation
deepcoldy
left a comment
There was a problem hiding this comment.
复审结论:暂不建议合入。定向测试 206/206 通过,pnpm build 通过;但支持的 sandbox-on 会话里精确回报仍走不通,且新增的 delegate-report 缺少重放幂等。
影响面:前者覆盖 Linux bwrap / macOS Seatbelt 的 transport bot,core-only/no-transport 更严格地不可达;后者覆盖 hub→origin spoke 的跨机回源。正常 join/成功 leave 会同步建立/删除两端 token,当前没有 token rotation API;hub 单边踢人时 spoke membership 不会同步撤销,这是既有生命周期边界,但本 PR 让同一 bearer 新增了“向编排 Session 注入回报”的职责,因此至少应把这条新写路径做成幂等。
| if (explicitDispatchRoot && registryMatch?.key !== explicitDispatchRoot) { | ||
| console.error(`精确 dispatch root ${explicitDispatchRoot} 在本机注册表中不存在;为避免串到其他 PM 会话,本次回报已停止。`); | ||
| process.exit(1); | ||
| const result = await submitFederatedDispatchReport({ |
There was a problem hiding this comment.
[P1] sandbox-on 下这里无法获得 host 路由数据。cmdReport 前面读的 orchestrate-dispatch.json 不在 fs-policy allowlist;transport sandbox 实测为 none,core-only/no-transport 为 deny,所以本机 registry 分支进不去。随后这个 fallback 又会读 federation-memberships.json 和 team-groups.json,它们同样是 none/deny,最终只会得到 route_not_found。.dashboard-secret 也不可读,但加裸 fetch 兜底解决不了更早的路由不可见问题。建议把 report 变成 session-scoped daemon/host relay:沙盒只提交当前 session capability + dispatchRoot + report,host 侧重推身份并读取 registry/team/token 后投递;不要把含 sync/delegation token 的 membership store 暴露给沙盒。请补 transport sandbox 与 core-only/no-transport 的行为测试。
| return true; | ||
| } | ||
|
|
||
| if (path === '/api/federation/delegate-dispatch-report' && method === 'POST') { |
There was a problem hiding this comment.
[P2] 新的 delegate-report 写端点没有幂等键或 replay ledger。同一带有效 delegationToken 的请求每次都会继续到 buildDispatchReportTrigger();该 helper 用 Date.now() 生成 source requestId,而 /api/trigger 不按 source.requestId 去重、会生成新的随机 triggerId,因此重放会向同一编排 Session 重复注入并启动多个 turn。相邻的 delegate-group 已按 delegationToken + requestId 做 10 分钟幂等,这条路径也应从报告发起端生成稳定 reportId,端到端透传,并在 origin/daemon 侧做有界持久去重(仅靠进程内缓存无法覆盖重启/超时重试)。
做了什么
botmux report --dispatch-root本机命中时改用已鉴权 daemon IPC,并统一构造trusted: false的完成回报 trigger。为什么做
跨机器 Coding Bot 看不到发起部署的本地 dispatch registry,旧路径会丢失准确 orchSessionId,或退化为群顶部消息并创建无原编排上下文的新 Session。本改动让完成结果沿已建立的 federation 认证链路回到原主编排 Session。
改动范围
dispatch/report、dispatch registry、federation hub/spoke API 与 dashboard daemon proxy;不改 CLI 适配器、后端、UI、角色管理或依赖。pnpm vitest run test/dispatch.test.ts test/federation-api.test.ts test/federation-spoke-api.test.ts(136/136);pnpm build;git diff --check。