fix(goal): derive titles and reuse existing agent frontier - #3603
Conversation
…roject name Signed-off-by: 牛瑞博 <912906590@qq.com>
…odo authoring When start-goal --guided resolves to an existing agent that already owns an open, unblocked advancement todo, the guided transaction previously always appended plan_ranked_todos and write_ordered_todos, inviting duplicate or overlapping todos during an identity takeover. Inspect the durable active-state todo board for the resolved agent and project an explicit todo_delta (reuse_existing vs add_new): reuse_existing replaces the planning and todo addition steps with a continue_existing_frontier step that continues the agent's runnable todo; add_new keeps the existing planner-order path. - loopx/bootstrap_command_pack.py: add existing_runnable_todo_for_agent (parses active-state agent todos and returns the first open, unblocked todo claimed by the resolved agent), compute todo_delta in build_loopx_bootstrap_command_pack, expose it in the payload and compact projection, and make the guided ordered_steps conditional on it - examples/bootstrap-command-pack-smoke.py: cover reuse_existing frontier continuation, add_new fresh planning, and done-only (no runnable frontier) Closes huangruiteng#3586 Signed-off-by: 牛瑞博 <912906590@qq.com>
Signed-off-by: 牛瑞博 <912906590@qq.com>
Signed-off-by: 牛瑞博 <912906590@qq.com>
Signed-off-by: 牛瑞博 <912906590@qq.com>
Signed-off-by: 牛瑞博 <912906590@qq.com>
huangruiteng
left a comment
There was a problem hiding this comment.
详细中文评审
结论:REQUEST_CHANGES
评审 exact head: b9fd93075c06e4841a660e3e71a297ca9116367c
动机
这个 PR 同时修复两个 guided start 问题:一是让新 Goal 的公开展示名从用户目标文本派生,而不是退化为项目目录名;二是当解析出的 agent 已经拥有可执行的 advancement Todo 时,复用该 frontier,避免再次规划并写入重叠 Todo。两个目标都直接改善 /loopx <goal text> 的首次连接和接管体验,方向合理。
改动思路
展示名路径把 derive_goal_display_name 放在 bootstrap CLI 边界,使用现有 public_safe_compact_text;显式 --display-name 仍优先。frontier 路径新增 existing_runnable_todo_for_agent 读取 durable active state,再由 build_loopx_bootstrap_command_pack 投影 todo_delta=reuse_existing|add_new,最后 build_goal_todo_frontier_steps 决定生成 continue_existing_frontier,还是保留 plan_ranked_todos + write_ordered_todos。
期望正向路径:selected agent 有 status=open、task_class=advancement_task、且未被 gate/block 的 Todo → 复用其 todo id,不生成新 Todo。
期望负向路径:该 agent 只有 blocked/deferred Todo、continuous monitor、user action 或其他非 advancement 工作 → 不应把它当作可继续的 advancement frontier,仍应生成新的 advancement Todo 计划。
具体改动
exact base..head 为 6 个文件、+374/-35:生产代码约 +194/-35,durable bootstrap smoke +180。生产模块和调用点都已接入,不是 test-only scaffolding;但主要负向状态语义尚未被测试覆盖。
bootstrap.derive_goal_display_name:把 objective 压缩为 132 字符公开安全标题;bootstrap CLI 在没有显式 override 时调用它。existing_agent_frontier.existing_runnable_todo_for_agent:解析 active-state agent Todo 并选择 resolved agent 的候选,这是todo_delta的权威分类点,也是当前 blocker 所在。bootstrap_command_pack.build_loopx_bootstrap_command_pack:在 host identity 解析后读取候选,并把存在性直接映射为reuse_existing。existing_agent_frontier.build_goal_todo_frontier_steps:将 typed projection 翻译为 guided steps;reuse 分支删除 planner/write steps,add 分支保持旧行为。bootstrap_command_pack.build_start_goal_guided_packet:把 frontier steps 放进 connect/bind 之后、refresh/activation 之前,顺序合理。
对主干的风险
[P1] 仅凭“claimed 且未 done”会把 blocked Todo 或 monitor 误判成 runnable advancement frontier
- 触发条件: resolved agent 只有一个
status=blocked, task_class=advancement_task的 Todo,或只有一个status=open, task_class=continuous_monitor的 Todo。 - 代码路径:
existing_runnable_todo_for_agent遍历agent_todos.items,只检查item.get("done")、不存在于 parser projection 的item.get("blocking"),以及claimed_by;它没有检查 typedstatus或task_class。该 item 被返回后,build_loopx_bootstrap_command_pack在 839-843 行把todo_delta设为reuse_existing,build_goal_todo_frontier_steps随即只输出continue_existing_frontier。 - 错误结果: guided start 删除
plan_ranked_todos和write_ordered_todos,却把不可执行的 blocked Todo 或仅观察的 monitor 当作当前 advancement frontier;agent 会被重新送回阻塞/观察通道,用户的新目标没有可运行 Todo。 - 位置:
loopx/control_plane/goals/existing_agent_frontier.py:35-39。 - 最小修复: 复用现有 typed helpers,仅接受
todo_item_task_class(item) == TODO_TASK_CLASS_ADVANCEMENT且todo_item_is_actionable_open(item)的 item,再匹配claimed_by;不要新增 prose/substring 分类。 - 回归测试: 在现有 open advancement 正向用例之外,至少增加 blocked advancement 和 open continuous_monitor 两个负向用例,断言二者均得到
todo_delta=add_new,并保留 planner/write steps。
我独立运行了 examples/bootstrap-command-pack-smoke.py(通过)、changed-file ruff(通过)和 compileall(通过)。另外用 active-state parser 做了四组定向探针:open advancement 正确返回;deferred advancement 不返回;但 blocked advancement 和 open continuous_monitor 都被返回,直接复现上述 blocker。远端 DCO、dependency review、pytest、Windows、build 与 Sonar 全绿。当前 PR 仍为 mergeStateStatus=DIRTY;最新 main 的 bootstrap_command_pack.py 与 start_goal.py 均有内容冲突,即使 blocker 修复,也需要 rebase 后在新 exact head 重跑 required checks。
typed-state lens:todo_delta 本身是明确枚举值,没有 substring heuristic;问题是输入候选没有使用仓库已有的 typed task-class/status selector。domain-neutrality 和 guidance-vs-obligation 没有发现额外问题。展示名默认行为已由 smoke 明确覆盖;代码体量总体可接受,但建议把这组状态矩阵下沉成 focused test,使已很大的 bootstrap smoke 保持薄层集成验证。
我的整体评价
展示名路径和 guided-step 分层都清晰,frontier 复用也是值得合入的行为;相关 future-facing 边界已抽到 control_plane/goals,不需要更大重构。但当前唯一的分类函数没有实现自己声明的“open、unblocked、advancement”契约,会在真实 agent 同时拥有 monitor 或 blocked 工作时抑制新目标 Todo。这是核心行为 blocker。我请求修改;改用现有 typed selector、补齐两个负向用例并完成 current-main rebase 后即可重新评审。
English verdict: REQUEST_CHANGES for exact head b9fd93075c06e4841a660e3e71a297ca9116367c. The title derivation and projection architecture are sound, but existing_runnable_todo_for_agent accepts blocked advancement Todos and open continuous monitors because it never checks typed status/task class. Restrict reuse to actionable open advancement Todos, add the two negative cases, then rebase and rerun required checks.
|
agent review出来的p1没必要修,直接解决冲突合并吧 |
|
Re-reviewed against the updated head (b9fd930) — the
|
Address PR huangruiteng#3603 review (now-ing): - existing_runnable_todo_for_agent filtered on item.get("blocking"), a key the active-state todo parser never emits; blocked todos are modeled as status=blocked, so a blocked todo claimed by the agent could be projected as the runnable frontier. Filter on normalize_todo_status(item.get("status")) == TODO_STATUS_BLOCKED so the docstring promise (one open, unblocked todo) holds. - The frontier lookup inherited the parser default MAX_STATUS_TODOS_PER_ROLE item cap, so a claimed todo beyond the cap silently degraded reuse to add_new. Pass item_limit=None to scan the full agent todo list. - Attach add_new_command_template plus a bounded escape-hatch note to the reuse_existing frontier step so the executing model still has an in-packet path to author a replacement todo when the frontier turns terminal or stale at execution time. Extend examples/bootstrap-command-pack-smoke.py with regressions for the blocked-frontier skip, reuse beyond the default item cap, and the escape-hatch template on the reuse step. Validation: - examples/bootstrap-command-pack-smoke.py (pass; new regressions fail against the pre-fix code) - loopx check on changed files: 0 errors, 0 warnings - tests/test_slash_command_install.py + tests/test_pi_goal_mode.py: 52 passed - tests/control_plane -k "todo or goal": 721 passed Signed-off-by: cmyk-labs <263870852+cmyk-labs@users.noreply.github.com>
|
Thanks @now-ing — all three items addressed in
Validation:
|
Resolve conflicts from the 153-commit gap: - keep both display_name (PR) and runtime_root_arg (main) params - adopt build_goal_todo_frontier_steps for the todo frontier steps - render the todo add prefix via render_cli_command_prefix so --runtime-root survives in add_new_command_template - pass display_name through the host-surface selection call Signed-off-by: NIU-123370 <225205513+NIU-123370@users.noreply.github.com>
|
Reopened and rebased onto current The branch had been deleted from the fork; restored it from
Two regressions the mechanical resolution would have introduced, fixed in the merge commit:
Validation on the merge head (local venv, Python 3.12):
|
huangruiteng
left a comment
There was a problem hiding this comment.
详细中文评审
结论:REQUEST_CHANGES
评审 exact head: ef9e19f4742170d65fb3abd3461251abbe58fbf7
动机
这个 PR 修复 guided start 的两个真实缺口:从用户目标文本派生公开安全的 Goal 展示名,以及在接管既有 agent 时复用其当前 advancement frontier,避免重复规划和写入 Todo。方向正确,最新 head 也修复了上一轮指出的 blocked Todo 与默认列表截断问题。
改动思路
展示名由 bootstrap CLI 边界上的 derive_goal_display_name 统一派生,显式 --display-name 保持最高优先级。Todo 复用由 existing_runnable_todo_for_agent 从 durable active state 选择候选,再把结果投影成 todo_delta=reuse_existing|add_new;guided packet 据此生成 continue_existing_frontier,或保留 plan_ranked_todos 与 write_ordered_todos。这一分层符合现有 control-plane 边界。
具体改动
exact base..head 共 6 个文件、+498/-36。最新 head 已做到:使用 typed status=blocked 排除阻塞项;以 item_limit=None 扫描完整 Todo 列表;reuse step 携带 add-new escape hatch;main reconciliation 后仍保留 runtime_root。我运行了 bootstrap command-pack smoke(通过)、focused goal/slash 测试(50 passed)、git diff --check(通过),并复现 maintainability quality gate 的 3 个失败。
对主干的风险
[P1] open monitor 仍会被误判为可复用的 advancement frontier
existing_runnable_todo_for_agent 在 loopx/control_plane/goals/existing_agent_frontier.py:39-45 只排除了 done 与 typed blocked 项,然后按 claimed_by 返回第一个候选;它仍未校验 typed task_class=advancement_task。因此当 resolved agent 只有一个 open continuous_monitor Todo 时,函数会返回该 monitor,todo_delta 被设为 reuse_existing,guided packet 删除 planner/write steps,把用户的新推进目标送入观察通道。请复用现有 typed task-class helper,只接受 advancement Todo,并补一个 open continuous-monitor 负向回归用例,断言 todo_delta=add_new。
[P1] 本 PR 新增的模块复杂度债务使 required pytest gate 失败
本地执行 tests/canary/test_maintainability_ratchet.py 与 tests/control_plane/test_m6_quality_gates.py 得到 3 failed / 9 passed;三处失败都指向本 diff 修改的 loopx/bootstrap_command_pack.py:module_metric_budget 有 1 个 unreviewed finding。远端 pytest 也以相同的 3 个 maintainability-ratchet 失败结束。该失败由当前 diff 跨过模块预算触发,不是继承自 main,不能作为无关红灯跳过。请在现有 owner 边界内收敛/抽取本次新增逻辑,使 ratchet 重新通过;不要仅新增例外来掩盖增长。
typed-state lens:blocked 状态现在使用 typed normalizer,改善正确;但 frontier 的 task-class 仍缺少 typed gate。domain-neutrality、behavior-change disclosure、guidance-vs-obligation 没有发现额外 blocker。future-facing pass 已有合适的 control_plane/goals seam,不需要扩大重构;当前只需把分类契约补完整,并让 command-pack 模块回到维护预算内。
我的整体评价
展示名链路、reuse projection 与 escape hatch 的结构都值得保留,上一轮的两项状态/列表问题也已实质修复。但 exact head 仍会把 monitor 当作 advancement frontier,且 required pytest gate 因本 diff 引入的维护性债务失败,因此现在不能批准或合并。修复 typed task-class 选择、补 monitor 负向用例、收敛模块复杂度并让 required checks 全绿后,再按新 exact head 复审。
English verdict: REQUEST_CHANGES for exact head ef9e19f4742170d65fb3abd3461251abbe58fbf7. The latest head fixes blocked-Todo filtering and full-list scanning, but it still reuses an open continuous monitor because the frontier selector does not require typed task_class=advancement_task. The PR also introduces an unreviewed module_metric_budget finding in bootstrap_command_pack.py, causing three required pytest failures locally and remotely. Fix both blockers and rerun checks on the new exact head; do not merge this head.
Signed-off-by: 牛瑞博 <912906590@qq.com>
Signed-off-by: 牛瑞博 <912906590@qq.com> # Conflicts: # loopx/bootstrap_command_pack.py
huangruiteng
left a comment
There was a problem hiding this comment.
详细中文评审
结论:APPROVE
评审 exact head: e615152137f41a826da3b804ad79fbefc8f5b139
动机
这个 PR 修复 guided start 的两个真实缺口:从用户目标文本派生公开安全的 Goal 展示名,以及在接管既有 agent 时复用其当前可执行 advancement frontier,避免重复规划和写入 Todo。两项都直接改善 /loopx <goal text> 的首次连接与连续推进体验。
改动思路
展示名继续由 bootstrap 边界统一派生,显式 --display-name 保持最高优先级;默认派生标题不再重复写入生成命令。Todo 复用则集中在 start_goal_todo_delta.py:从 durable active state 扫描完整 Todo 集合,只接纳 actionable-open 的 advancement_task,再按 resolved agent 过滤 claim;无法证明存在 runnable frontier 时保持 fail-closed,回到正常规划和 authoring。
具体改动
exact base..head 共 7 个文件、单一主题。最新 head 已完成上一轮要求的两项修复:
existing_runnable_agent_frontier使用 typedtodo_item_is_actionable_open和TODO_TASK_CLASS_ADVANCEMENT;blocked、deferred、resume-blocked、blocker、continuous monitor 与 peer-claimed Todo 都不会进入可复用 frontier。parse_active_state_todos(..., item_limit=None)扫描完整列表,不会因默认展示上限漏掉后部的 actionable Todo。project_prompt.render_goal_start_bootstrap_command承担紧凑命令渲染,只有显式 override 才加入--display-name,避免从 objective 派生出的同一文本在命令中重复出现。- reuse 分支保留有界
add_new_command_templateescape hatch;默认仍是比较并复用 frontier,只有请求未覆盖时才新增 Todo。 - command-pack 模块增长已收敛到现有 owner 边界,维护性 ratchet 不再报新增债务。
对主干的风险
未发现仍需阻塞合入的问题。typed-state lens 已覆盖 open advancement 正向,以及 blocked/deferred/resume-blocked/blocker/monitor/peer-claimed 负向;分类不依赖 substring denylist。domain-neutrality、behavior-change disclosure 与 guidance-vs-obligation 均未发现问题。相关 future-facing pass 已完成:命令渲染下沉到 project_prompt.py,continuation 分类集中到 start_goal_todo_delta.py,没有引入第二套状态权威。
独立验证:
tests/test_slash_command_install.py、tests/test_pi_goal_mode.py、tests/control_plane/test_start_goal_compact_projection.py:110 passed;唯一未执行成功的 linked-worktree 用例在创建临时 git commit 时被本机工作时段全局 commit hook 拦截,与 PR 代码无关。tests/canary/test_maintainability_ratchet.py+tests/control_plane/test_m6_quality_gates.py:12 passed。- changed-file Ruff:通过。
- bootstrap command-pack smoke 的非 git-commit 路径及新增状态矩阵均由 focused tests 覆盖;完整 smoke 的临时 commit 同样仅被上述本机 hook 拦截。
- exact head 的远端 Sign-off、dependency review、pytest、build、Windows PowerShell 与 SonarCloud 均为 success。
我的整体评价
这个版本已把展示名默认行为、可复用 frontier 的 typed 语义、完整列表扫描和维护性边界一起收敛好。旧 blocker 均已实质修复,负向状态矩阵足够防止 monitor/blocked work 再次吞掉用户的新推进目标,当前 exact head 可以批准。批准不等于合并;本次只发布 review 结论。
English verdict: APPROVE for exact head e615152137f41a826da3b804ad79fbefc8f5b139. The prior blockers are resolved: reuse is restricted to actionable open advancement Todos, monitor/blocked/deferred/resume-blocked/blocker/peer-owned cases fail closed, full-list scanning avoids projection-cap misses, and derived display names are no longer duplicated in generated bootstrap commands. Focused behavior and maintainability gates pass, changed-file lint passes, and all required remote checks are green. Approval is review-only; no merge was performed.
Summary
/loopx <goal text>, while preserving an explicit--display-nameoverride.todo_delta: reuse_existingand continue that frontier instead of unconditionally planning and adding Todos.Issue Or Task
Validation
examples/bootstrap-command-pack-smoke.pyloopx checkon changed files (0 errors)tests/test_slash_command_install.py+tests/test_pi_goal_mode.py(49 passed)tests/test_host_loop_activation.py— 10 existing TraeX fixture/environment failures reproduced on clean base; 70 passed.Type of Change
LoopX Area
Technical Direction
mainBoundary Checklist
Signed-off-bytrailer.