fix(manager): configure external delivery targets safely - #5046
Conversation
e1005f4 to
297cb7d
Compare
huangruiteng
left a comment
There was a problem hiding this comment.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机
管家在外部会话中即使有读取某个 Goal 摘要的权限,也可能没有把当前发送者的上下文投递给该 Goal 注册 Agent 的独立授权。此前补这个授权只能手改机器私有策略,容易写错、遗漏撤销,用户随后仍会遇到“找不到 Agent”。本 PR 的可验收边界是让操作者安全地配置和撤销一个投递对象;它还不是完整的自动选人、实际执行和原会话答复闭环。
改动思路
沿用现有 manager-context policy v1、注册表、读范围校验和文件锁,在 manager-inbox 增加两个显式的预览优先命令。只有现存外部 channel、有效发送者、活跃 Goal 和已注册 Agent 满足条件时才能 grant;--execute 才写入。运行时仍由既有 authority() 把策略目标与当前注册状态求交,Agent 不会因有一行配置就自动执行或获得受保护操作权限。撤销按 Goal/Agent 身份对,而不是整行字典相等,以免旧行附加元数据导致权限残留。
具体改动
loopx/cli_commands/manager_inbox.py 注册 grant/revoke 两个动作并把精确 channel、Goal、Agent 与执行标志交给 configure_delivery_target。manager_context 新函数读取现有策略,验证发送者和可选的 Goal 读取范围;预览只回报变化,执行时在同一个锁内写入并读回。自审发现并修复了含额外字段或重复行的旧目标无法完全撤销的问题,is_target 统一用于存在、删除和读回验证。README 给出预览、授予、撤销命令以及权限边界;测试覆盖真实 CLI、authority() 前后效果、幂等、非法来源、越界、停用 Agent 和旧行撤销。四个文件同属一个策略配置结果,没有新增策略存储或迁移。
关键代码讲解
handle_manager_inbox只把两个新动作路由给现有 manager-context 所有者,不自行决定权限。configure_delivery_target在写入前检验 channel、sender、Goal/Agent 与读范围;预览不写,执行使用原锁和原策略格式。is_target用 Goal/Agent 对识别有效对象,使重复或带元数据的旧行都能在撤销时清除。test_operator_delivery_target_preview_grant_revoke_and_live_authority通过真实策略读回和authority()验证授权实际生效且可撤销。
对主干的风险
这是权限配置面,主要风险是给无效发送者或错误 Agent 扩权,以及表面撤销后仍留有效 grant。负例在缺失 channel、发送者、显式读范围之外、未知或已停用 Agent 下都拒绝且不写入;重复与带元数据旧行的反例在自审时暴露并已修复。最终代码的 150 项管家、发现、Chat 和 Lark 相关测试、Ruff、mypy、公开边界扫描通过;机器上当前配置的只读 CLI 预览确认不执行也不改策略,质量收据 cqr_ce5787f45c03c8988ca6 有效。最终提交的风险分级 premerge 19 项全过、无跳过或人工 hold;远端 CI 仍须独立检查。策略模式未变,回滚可撤回新命令;已存在的授权仍按旧消费者读取。
语义与 CI 对齐
本 PR 复用的是现有 sender-bound context delivery 关系,不把“能读 Goal”说成“能投递或执行”。默认未配置的 channel 与已有 web/Lark 路径不改变;执行命令仅为所选对象写一个策略目标。隔离的真实 CLI 反例已证明纠正读范围后能投递到收件箱;完整外部消息到 Agent 接收、采纳、原入口回传仍属于现有 Todo 的后续验收,不能凭这条 CLI PR 宣称用户旅程已完成。
我的整体评价
在精确提交 297cb7daf077f85eaf16c2e16b38f38912e1aefb 上给出 APPROVE,定位为有价值且可独立回滚的配置增量。它解决了已观察到的手动策略编辑缺口,复用了正确的权威边界,也修好了自审发现的权限残留反例;前端和 Lark 当前只消费原策略,因此此步无需修改它们,但完整管家回复体验仍未验收。合并需再满足此提交的公开审查、远端检查及 LoopX readiness;不能把配置可用当成整个管家目标结案。
English verdict: APPROVE - Head 297cb7d; preview-first CLI grants/revokes one sender-bound external recipient through the existing policy, with pair-based legacy-row revocation and live authority readback. 150 focused tests, static checks and quality receipt pass; full routed execution and result return remain separate acceptance work.
Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
297cb7d to
640aaa1
Compare
huangruiteng
left a comment
There was a problem hiding this comment.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机
管家在外部会话中即使有读取某个 Goal 摘要的权限,也可能没有把当前发送者的上下文投递给该 Goal 注册 Agent 的独立授权。此前补这个授权只能手改机器私有策略,容易写错、遗漏撤销,用户随后仍会遇到“找不到 Agent”。本 PR 的可验收边界是让操作者安全地配置和撤销一个投递对象;它还不是完整的自动选人、实际执行和原会话答复闭环。
改动思路
沿用现有 manager-context policy v1、注册表、读范围校验和文件锁,在 manager-inbox 增加两个显式的预览优先命令。只有现存外部 channel、有效发送者、活跃 Goal 和已注册 Agent 满足条件时才能 grant;--execute 才写入。运行时仍由既有 authority() 把策略目标与当前注册状态求交,Agent 不会因有一行配置就自动执行或获得受保护操作权限。撤销按 Goal/Agent 身份对,而不是整行字典相等,以免旧行附加元数据导致权限残留。
具体改动
loopx/cli_commands/manager_inbox.py 注册 grant/revoke 两个动作并把精确 channel、Goal、Agent 与执行标志交给 configure_delivery_target。manager_context 新函数读取现有策略,验证发送者和可选的 Goal 读取范围;预览只回报变化,执行时在同一个锁内写入并读回。自审发现并修复了含额外字段或重复行的旧目标无法完全撤销的问题,is_target 统一用于存在、删除和读回验证。README 给出预览、授予、撤销命令以及权限边界;测试覆盖真实 CLI、authority() 前后效果、幂等、非法来源、越界、停用 Agent 和旧行撤销。四个文件同属一个策略配置结果,没有新增策略存储或迁移。
关键代码讲解
handle_manager_inbox只把两个新动作路由给现有 manager-context 所有者,不自行决定权限。configure_delivery_target在写入前检验 channel、sender、Goal/Agent 与读范围;预览不写,执行使用原锁和原策略格式。is_target用 Goal/Agent 对识别有效对象,使重复或带元数据的旧行都能在撤销时清除。test_operator_delivery_target_preview_grant_revoke_and_live_authority通过真实策略读回和authority()验证授权实际生效且可撤销。
对主干的风险
这是权限配置面,主要风险是给无效发送者或错误 Agent 扩权,以及表面撤销后仍留有效 grant。负例在缺失 channel、发送者、显式读范围之外、未知或已停用 Agent 下都拒绝且不写入;重复与带元数据旧行的反例在自审时暴露并已修复。最终代码的 167 项管家、发现、Chat 和 Lark 相关测试、Ruff、mypy、公开边界扫描通过;合成真实 CLI 路径证明预览不写入、越界拒绝、纠正读范围后可投递且撤销旧接收方,质量收据 cqr_6b1c580234f12e633375 有效。最终提交的风险分级 premerge 19/19 通过,无跳过或人工待办。Goal 当前不等待远端 CI,本评审不引用远端状态。策略模式未变,回滚可撤回新命令;已存在的授权仍按旧消费者读取。
语义与 CI 对齐
本 PR 复用的是现有 sender-bound context delivery 关系,不把“能读 Goal”说成“能投递或执行”。默认未配置的 channel 与已有 web/Lark 路径不改变;执行命令仅为所选对象写一个策略目标。隔离的真实 CLI 反例已证明纠正读范围后能投递到收件箱;完整外部消息到 Agent 接收、采纳、原入口回传仍属于现有 Todo 的后续验收,不能凭这条 CLI PR 宣称用户旅程已完成。
我的整体评价
在精确提交 640aaa169f3b95b3da71367ee17f6ef812f02931 上给出 APPROVE,定位为有价值且可独立回滚的配置增量。它解决了已观察到的手动策略编辑缺口,复用了正确的权威边界,也修好了自审发现的权限残留反例;前端和 Lark 当前只消费原策略,因此此步无需修改它们,但完整管家回复体验仍未验收。合并需再满足此提交的公开审查、已通过的风险分级 premerge 及 LoopX readiness;不能把配置可用当成整个管家目标结案。
English verdict: APPROVE - Head 640aaa1; preview-first CLI grants/revokes one sender-bound external recipient through the existing policy, with pair-based legacy-row revocation and live authority readback. 167 focused tests, risk premerge 19/19, static checks and quality receipt pass; full routed execution and result return remain separate acceptance work.
An external steward audience can read a Goal yet still lack a sender-bound delivery grant to its registered Agent. Repairing that gap currently requires editing private policy JSON by hand. This adds preview-first
manager-inbox grant-delivery-targetandrevoke-delivery-targetcommands for one exact external channel and recipient.A grant requires an existing channel with an authorized sender, an active Goal with the Agent registered, and membership in any explicit audience Goal read scope. Execute writes under the existing policy lock and verifies readback; other targets and source settings stay intact. Revocation matches Goal/Agent identity even when legacy target rows have extra metadata or duplicates, so it cannot leave an effective grant behind. These commands do not create sender access, start Agent execution, or grant protected-operation authority.
Validation: 167 focused manager, discovery, chat and Lark tests; Ruff; mypy; changed-file public-boundary scan; a synthetic real-CLI grant/scope/revoke counterfactual; and risk-based premerge (19/19 passed, no skips or holds). Exact-scope quality receipt
cqr_6b1c580234f12e633375is valid. The public CLI is the affected configuration entry point; the shipped frontend and Lark message flow already consume the underlying policy and need no separate code change for this operator grant. This closes the operator configuration gap; actual Agent execution, receiver adoption and result return to the original conversation remain separate end-to-end acceptance work.