fix(control-plane): align replan writeback agent scope - #3370
Conversation
Signed-off-by: huangruiteng <huangrt01@163.com>
huangruiteng
left a comment
There was a problem hiding this comment.
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
动机
这个 PR 要解决的状态错配是真实且重要的:quota 已经按当前 Agent 的身份过滤 Todo,而 semantic replan writeback 仍读取全局 Todo 摘要,导致属于其他 Agent 的用户动作错误地阻断当前 Agent。方向上应该让两条热路径复用同一套 typed agent-scope 规则,而不是靠文案或字符串判断。
改动思路
整体方案合理:复用 build_quota_agent_identity、select_quota_todo_summary 和现有 neutral classification,把 writeback 的 frontier 输入对齐 quota;旧 registry 没有 registered agents 时保留单 Agent fallback。规则仍是 typed state,控制面文案保持 domain-neutral,也明确改变的是多 Agent 作用域行为,不是把机器义务降级为 guidance。
具体改动
有一个必须修复的回归:qualify_replan_writeback 现在把 quota 压缩后的 agent_todos 传给 _obligation_was_created_by_current_completion。压缩摘要保留的是 frontier lanes(包括 recent_completed_advancement_items),但没有原始 items;而 causal exemption 只在 agent_todos["items"] 中查找本 Turn 刚完成的 Todo。因此 validated completion 创建的 successor obligation 不再被识别为“由当前 completion 产生”,同一事务会被错误地拒绝,host 甚至不会执行。
当前 exact head 上,新增/相关的 41 个测试通过,但仓库已有回归用例 tests/test_loopx_turn_driver.py::test_turn_run_once_cli_completes_selected_todo_after_validation 稳定失败;相同用例在 origin/main 通过。远端 pytest 也报告同一失败(3600 passed, 1 failed)。建议 frontier 继续使用 scoped quota summary,但 causal exemption 应读取经过 Agent 作用域约束、同时保留 completion identity 的 source item,或显式支持 recent_completed_advancement_items;并把这个既有 turn-driver 用例纳入本 PR 的 focused validation。
对主干的风险
当前风险是高于可合并阈值的运行时回归:正常的 turn run-once validated completion 会在 durable writeback 前失败,表现为 host_invoked=false、state_written=false、quota_spent=false。这会直接阻断主 Agent 的完成与后续 successor 结算。其余检查(sign-off、dependency review、build、Windows)通过,但不能覆盖这个语义回归。
我的整体评价
问题定义、作用域对齐和新增多 Agent 测试都很好,修改也保持了 typed/domain-neutral contract;但 completion causal exemption 被压缩摘要破坏是明确 blocker。修复后请同时重跑上述 turn-driver 回归、两个新增/修改测试文件以及标准 pre-merge canary,再重新请求 review。
English verdict: REQUEST_CHANGES — the agent-scoped quota alignment is sound, but passing the compact quota summary into the current-completion causal exemption drops the completed Todo identity and breaks validated turn run-once settlement on the exact PR head.
huangruiteng
left a comment
There was a problem hiding this comment.
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
精确评审版本:fa02b46b15e21956c5f5dcf5712f25901c0342fe。
动机
这个 PR 修复的状态错配真实且重要:quota 已按当前 Agent 的 typed identity 过滤 Todo,而 semantic replan writeback 仍读取全局 Todo 摘要,导致绑定给其他 Agent 的用户动作可能错误阻断当前 Agent。正确目标是让 quota 与 writeback 共享 agent-scope 语义,同时保持旧 registry 的单 Agent 兼容,以及 stale/mismatched obligation 的 fail-closed 行为。
改动思路
实现复用 build_quota_agent_identity、select_quota_todo_summary、select_quota_todo_source_items 和现有 neutral classification,把 writeback 的 frontier 输入对齐 quota。正向路径中,当前 Agent 只看自己可见的 user/agent Todo,其他 Agent 的 user action 不再覆盖当前 Agent 的 vision obligation;负向路径中,没有 registered agents 时回退到当前 Agent,旧目标仍按单 Agent 语义运行。方案没有新增字符串分类、领域特定控制面措辞或权限提升,behavior change 也在 PR 说明中明确披露。
具体改动
loopx/control_plane/work_items/semantic_replan_writeback.py:构造 quota agent identity,生成 scoped user/agent summaries,并把 source items、neutral classifications、registered agents 与 agent profile 传入 goal-frontier reducer。tests/control_plane/test_replan_semantic_action_behavior.py:新增单元级多 Agent 场景,证明绑定给 peer 的用户动作不会隐藏当前 Agent 的 obligation。tests/control_plane/test_refresh_state_replan_gate.py:新增真实 CLI dry-run 链路,证明 quota 产生的 obligation id 能被 todo successor 写入路径接受且不修改状态。
关键代码讲解
qualify_replan_writeback 的 frontier 输入改为 scoped quota summaries,这个方向正确;build_goal_frontier_projection_context_from_status 因而能在 quota 与写回两条路径上看到一致的 typed Agent 范围。问题出在 _obligation_was_created_by_current_completion:它的 causal exemption 只检查 agent_todos["items"] 中带有相同 todo_id、completion_turn_key 和 status=done 的行。PR 现在把 quota 压缩后的 agent_todos 传给它;该摘要保留 frontier lanes(包括 recent_completed_advancement_items),但不保留原始 items,所以当前 Turn 刚完成的 Todo 身份丢失。
结果是 validated completion 在同一事务内创建 successor obligation 后,不再被识别为“由当前 completion 产生”,writeback 被错误拒绝。建议 frontier 继续使用 scoped summary,但 causal exemption 应读取经过 Agent 作用域约束且保留 completion identity 的 source item,或显式检查 recent_completed_advancement_items,并增加当前 completion 的正负例覆盖。
对主干的风险
这是明确的运行时 blocker。精确 head 上,两个修改/新增测试文件与既有 turn-driver 回归合计运行时,41 个相关测试通过,但 tests/test_loopx_turn_driver.py::test_turn_run_once_cli_completes_selected_todo_after_validation 稳定失败;同一用例在 origin/main 通过。远端 pytest 也报告同一失败(3600 passed, 1 failed)。失败结果为 host_invoked=false、state_written=false、quota_spent=false,意味着正常 turn run-once 的 validated completion 会在 durable writeback 前被拦截。Sign-off、dependency review、build 与 Windows checks 通过,但不能抵消这个语义回归。
我的整体评价
问题定义、typed agent-scope 对齐、旧目标 fallback 和新增多 Agent 测试都值得保留,改动规模也与目标基本匹配;但 compact summary 破坏 completion causal exemption 会阻断主路径,因此当前 head 不可合并。修复后应重跑上述 turn-driver 回归、两个修改测试文件、完整 pytest 和标准 pre-merge canary,并在新 exact head 上重新评审。
English verdict: REQUEST_CHANGES at exact head fa02b46 — the scoped quota alignment is sound, but the compact summary drops the completed Todo identity required by the current-completion causal exemption and breaks validated turn run-once settlement.
Signed-off-by: huangruiteng <huangrt01@163.com>
…back Signed-off-by: huangruiteng <huangrt01@163.com>
|
Maintainer re-review at exact head 复审结论此前 blocker 已修复。PR 仍保留 quota 与 semantic replan writeback 的 typed Agent scope 对齐;当前 completion 的因果豁免不再读取丢失终态身份的压缩摘要,而是读取 active-state parser 的权威 pre-compaction Todo 行,并复用现有 Agent scope predicate。这样,合法的 validated completion 可以完成当前事务,而由它新产生的 successor obligation 留给下一次 decision;peer-owned Todo、错误 Todo id、错误 completion turn key 和混合 obligation 仍然 fail closed。 最终改动面
没有新增 substring/prose 分类、领域特定控制面措辞、权限扩张或静默默认行为变化。现有 typed ownership 与 frontier reducer 仍是规则权威。 验证
风险与合并判断这个修复只改变同一 Turn 刚完成 Todo 所产生 obligation 的精确因果判定;旧 obligation、peer-owned completion 和缺失 identity 仍被拒绝。覆盖同时证明了正向主路径和负向 ownership 边界,标准 control-plane canary 无 manual hold。GitHub required checks 全绿后,本 PR 可按 owner 授权 admin self-merge。 English verdict: the prior runtime blocker is resolved on the exact head. The completion exemption now uses authoritative completion identity plus the existing Agent-scope predicate, while the frontier remains quota-scoped. Focused tests, supported-interpreter full-suite reruns, type/lint/compile checks, public-boundary scan, exact-scope quality receipt, and 15/15 pre-merge canaries are sufficient for self-merge once remote required checks pass. |
What changed
Why
quota should-runandtodo add --replan-obligation-idreconstructed the same frontier through different inputs. Quota scoped user and agent Todos to the requested peer identity, while the Todo write-before-check consumed the global active-state summaries directly. An unrelated peer-bound user action could therefore make quota project an obligation while Todo creation reported that no open obligation existed.The write path now consumes the same existing identity/scoping components as quota instead of maintaining a second rule.
Impact
Bound replan successor creation now accepts the exact obligation projected by quota in multi-agent goals. Stale or mismatched obligation ids still fail before Todo mutation, and legacy goals without a registered peer set retain a single-agent identity fallback.
Validation
python -m pytest -q tests/control_plane/test_refresh_state_replan_gate.py tests/control_plane/test_replan_semantic_action_behavior.py— 41 passedpython -m pytest -q tests/control_plane/test_refresh_state_replan_gate.py tests/control_plane/test_replan_semantic_action_behavior.py::test_successor_dry_run_shares_quota_agent_scope_for_user_gates tests/control_plane/test_replan_semantic_action_behavior.py::test_model_can_create_and_bind_a_real_runnable_successor— 23 passed after rebaseloopx canary premerge --from-git-diff --tier standard— passed: 4 direct checks and 15 selected control-plane/canary smokes, no failures, warnings, or manual holdsgit diff --check origin/main...HEADDocumentation
No public protocol or user-facing command changed. The regression contract is captured in focused unit and real CLI tests.