Skip to content

fix(report): 跨团队完成回报精确回注主编排 Session - #764

Open
qiaomu427 wants to merge 1 commit into
deepcoldy:masterfrom
qiaomu427:codex/cross-team-report-session-route
Open

fix(report): 跨团队完成回报精确回注主编排 Session#764
qiaomu427 wants to merge 1 commit into
deepcoldy:masterfrom
qiaomu427:codex/cross-team-report-session-route

Conversation

@qiaomu427

Copy link
Copy Markdown

做了什么

  • botmux report --dispatch-root 本机命中时改用已鉴权 daemon IPC,并统一构造 trusted: false 的完成回报 trigger。
  • 为团队派发增加基于 dispatch root 的 federation route 登记与提交;hub 按 membership token 绑定团队和报告方,必要时使用既有 callbackUrl + delegationToken 回源 spoke。
  • 明确 root 全链路缺失或鉴权、daemon、Session 失败时关闭失败,不再退化为群顶部消息。

为什么做

跨机器 Coding Bot 看不到发起部署的本地 dispatch registry,旧路径会丢失准确 orchSessionId,或退化为群顶部消息并创建无原编排上下文的新 Session。本改动让完成结果沿已建立的 federation 认证链路回到原主编排 Session。

改动范围

  • 影响 dispatch / report、dispatch registry、federation hub/spoke API 与 dashboard daemon proxy;不改 CLI 适配器、后端、UI、角色管理或依赖。
  • 同机派发、未显式 root 的普通非团队回报和 Issue in_review 路径保持原行为。
  • 验证:pnpm vitest run test/dispatch.test.ts test/federation-api.test.ts test/federation-spoke-api.test.ts(136/136);pnpm buildgit diff --check
  • 额外全量单测复跑为 13054/13058;4 个失败均在本改动外(3 个 30s 超时、1 个 worker 时序断言),目标测试与构建持续通过。

@qiaomu427
qiaomu427 requested a review from deepcoldy as a code owner August 6, 2026 10:04

@deepcoldy deepcoldy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审结论:暂不建议合入。定向测试 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 注入回报”的职责,因此至少应把这条新写路径做成幂等。

Comment thread src/cli.ts
if (explicitDispatchRoot && registryMatch?.key !== explicitDispatchRoot) {
console.error(`精确 dispatch root ${explicitDispatchRoot} 在本机注册表中不存在;为避免串到其他 PM 会话,本次回报已停止。`);
process.exit(1);
const result = await submitFederatedDispatchReport({

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] sandbox-on 下这里无法获得 host 路由数据。cmdReport 前面读的 orchestrate-dispatch.json 不在 fs-policy allowlist;transport sandbox 实测为 none,core-only/no-transport 为 deny,所以本机 registry 分支进不去。随后这个 fallback 又会读 federation-memberships.jsonteam-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') {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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 侧做有界持久去重(仅靠进程内缓存无法覆盖重启/超时重试)。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants