Skip to content

feat(gateway): 接入计划审批 RPC#689

Merged
phantom5099 merged 3 commits into
1024XEngineer:mainfrom
Yumiue:codex/gateway-plan-approval-rpc
May 21, 2026
Merged

feat(gateway): 接入计划审批 RPC#689
phantom5099 merged 3 commits into
1024XEngineer:mainfrom
Yumiue:codex/gateway-plan-approval-rpc

Conversation

@Yumiue
Copy link
Copy Markdown
Collaborator

@Yumiue Yumiue commented May 21, 2026

背景

计划模式已经能生成带 plan_idrevision 的 draft 计划,但 Web 端缺少一条经过 Gateway 的显式审批通道。用户同意计划后只能继续发送普通文本推动执行,计划审批语义无法被协议层校验,也无法稳定处理 revision 过期、计划 ID 不匹配或状态非法等场景。

Closes #688

修改内容

  • 新增 gateway.approvePlan JSON-RPC 方法与 approve_plan Frame Action,补齐参数归一化、payload 校验、ACL、metrics、registry 与 dispatch 接入。
  • 新增 Gateway PlanApprovalRuntimePort 与 CLI bridge 适配,将计划审批请求收敛到 Runtime ApproveCurrentPlan,并把可预期业务拒绝映射为 invalid_action
  • 在 Runtime 计划审批逻辑中补充可判定错误,区分当前计划缺失、计划 ID 不匹配、revision 不匹配和状态非法。
  • Web API 增加 approvePlan 调用;ChatPanel 对最新 draft 计划展示审批面板,支持以 defaultbypass 权限模式批准后进入 build 执行,并在执行启动失败时提供重试入口。
  • 更新 Gateway RPC 文档与 reference 文档,补充 gateway.approvePlan 的请求、响应和语义说明。

验证

  • git diff --check
  • go test ./internal/gateway ./internal/gateway/protocol ./internal/runtime
  • go test ./internal/cli -run "ApprovePlan|ApproveCurrentPlan|GatewayRuntimePortBridge"
  • cd web && npm test -- --run
  • cd web && npm test -- --run src/api/gateway.test.ts src/components/chat/ChatPanel.test.tsx

已知情况

  • go test ./... 在本地 Windows 环境存在与本次改动无关的既有失败:internal/cli 的 symlink 权限、临时 npm shim 与 web command 用例,internal/memo 的固定日期断言,以及 internal/tools/bash 的 shell 输出相关用例。上述失败未发生在本次新增审批链路的定向测试中。

关联 issue: 1024XEngineer#688

新增 gateway.approvePlan 协议、Gateway 分发与 Runtime bridge 适配,Web 端在最新 draft 计划上提供批准并执行入口。
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Copy link
Copy Markdown

@fennoai fennoai Bot left a comment

Choose a reason for hiding this comment

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

发现 2 个需要处理的问题:一个会让同一版 draft 计划失去再次审批入口,另一个会让 approvePlan 的无效 revision 在不同入口返回不同的网关错误码。

Comment thread web/src/components/chat/ChatPanel.tsx
Comment thread internal/gateway/protocol/jsonrpc.go Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

❌ Patch coverage is 94.30894% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/gateway/bootstrap.go 85.00% 3 Missing and 3 partials ⚠️
internal/cli/gateway_runtime_bridge.go 95.23% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Yumiue added 2 commits May 21, 2026 05:13
保留计划审批拒绝当前 revision 后隐藏的产品语义,并将 Web 文案调整为需要修改。
覆盖 approve_plan 的网关校验、运行时端口缺失、多工作区路由错误和 bridge 访问拒绝分支。
@Yumiue
Copy link
Copy Markdown
Collaborator Author

Yumiue commented May 21, 2026

已补充计划审批链路的测试覆盖:

  • Gateway bootstrap:覆盖 runtime port nil、可选计划审批端口缺失、从 frame.session_id 回填 session、invalid revision 分支。
  • Gateway validate:覆盖 approve_plan payload 正常、缺失 payload/session_id/plan_id、invalid revision、payload shape 非法。
  • MultiWorkspaceRuntime:覆盖 workspace not found 与底层 runtime 不支持 PlanApprovalRuntimePort。
  • CLI bridge:覆盖 subject access denied,确保不会下发到 runtime approve。

本地覆盖率检查中新增函数已提升到:validateApprovePlanFrame/decodeApprovePlanPayload/MultiWorkspaceRuntime.ApprovePlan/requirePlanApprovalRuntimePort 100%,handleApprovePlanFrame 88.5%,bridge ApprovePlan 91.7%。

已验证:

  • git diff --check
  • go test ./internal/gateway ./internal/gateway/protocol ./internal/runtime
  • go test ./internal/cli -run ApprovePlan
  • cd web && npm test -- --run src/components/chat/ChatPanel.test.tsx src/api/gateway.test.ts

@phantom5099 phantom5099 merged commit b41729a into 1024XEngineer:main May 21, 2026
3 checks passed
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.

【提案】 为计划模式补齐 Gateway 计划审批 RPC

2 participants