Repository navigation
refactor(chat): modularize todo_actions and eliminate Any annotations - #9470
loopx-agent wants to merge 1 commit into
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
把 Chat Todo 的创建、分配、Task Session 恢复和更新拆到有类型的同域模块,保持原 HTTP、CAS 回执及重入时序。 基线将创建、恢复、写入和投影都放在 ChatTodoActionMixin。Task Session 与 provider 结果多用动态字典传递。 在 Chat 中确认创建、分配、编辑、完成 Todo 或停止 Monitor 的用户,以及恢复挂起 Task 的现有运行时。
如果重构误把旧回执当新申请,会丢失有效恢复或重复业务写。投影未交付便确认成功会误报 Todo 当前状态。 基线与 Head 的实际 HTTP 观测相同。File 和 SQLite 上,预览不写,确认后创建一个 Todo 并分配给原 Agent。重放沿用同一收据。普通编辑提交后模拟投影中断,再次确认读回同一 operation 的 replayed 状态和已恢复的当前投影。 Python 3.12 下基线 173 项、Head 178 项定向测试通过。另独立完成两版各 2 组真实 File 和 SQLite HTTP 创建、分配、过时编辑和投影恢复。git diff --check 通过。 两版使用同一份静态 Chat 资源。HTTP handler 与 canonical provider 为精确工作树。Task 开始恢复测试使用受控执行器。实时模型执行、当前安装和远程 CI 未核验。 基线契约
改动思路 / Approach
该改动沿用 Chat POST /api/actions/preview → POST /api/actions/{id}/apply → canonical Todo 与当前投影。ChatTodoActionMixin 保留原调用形式,子模块继续调用原写入和状态所有者,将 proposal 及 receipt 解析与 provider 判定留在各自边界。 以已审阅的 provider revision、registry 指纹和 operation ID 约束新写入。按精确历史收据恢复已提交业务,经当前投影确认后交付回执。 复用 action_store 的 digest、ID 和类型校验。提交、权威状态与投影沿用现有实现,原有提案和回执无需迁移。
具体改动 / Changes
精确提交 c753f12,分叉基线 57c4c43。6 个文件,新增 2,413 行、删除 712 行。保留原门面,拆出创建、更新、Task 调度及 host 契约,新增 637 行契约测试。
关键代码讲解
-
apply_todo_create。保留原预览指纹、创建检查点、分配和幂等读回。 源码 -
confirmed_task_commit。提交 Task Turn 前重验 Goal、project、受领者和原租约。 源码 -
canonical_update_basis。连续两次 resolve 同一来源,比对 registry 与 source identity。 源码 -
apply_reviewed_todo_edit。保留更新 CAS、原 operation 回执及当前投影恢复。 源码 -
preserve-reviewed-cas-and-current-projection-retry(implemented)。已审阅命令按 provider 和 registry 的基线写入。业务已提交而展示未交付时,重试须恢复原 operation 并确认当前视图。
对主干的风险 / Risks
确认前插入另一 Todo 改变 provider head,两版均返回 HTTP 409、stale、无回执,canonical 状态保持。业务提交后的投影错误保留原 canonical_update_projection_pending,重放恢复同一结果。 重试若再次写入,投影故障会把原确认变成重复修改。隔离 HTTP 反例经过真实 canonical store。 保留原 source/CAS basis 与不可变 operation 收据,经当前 outbox 确认展示。
我的整体评价 / Verdict
APPROVE。 实际 File 和 SQLite 路径保持创建、写入拒绝、业务恢复与投影读回。 中断后凭原 operation 恢复业务结果和当前投影,避免重复 Todo 和用过期意图覆盖后续进展。
English verdict: APPROVE at c753f12. Exact-base/head File and SQLite HTTP runs preserve reviewed Todo creation, stale-preview rejection, and same-operation recovery after projection failure.
Delivery Brief
Anyannotations (54 -> 0) and modularizedloopx/chat/todo_actions.py(770 -> 243LOC) into cohesive Zero-Anyhelper modules without adding top-level compatibility shims or changing runtime behavior.class ChatTodoActionMixindefined insideloopx.chat.todo_actions(preservingChatTodoActionMixin.__module__ == "loopx.chat.todo_actions"andimportlib.util.find_spec("loopx.chat_todo_actions") is Nonepertests/test_chat_internal_module_layout.py).loopx/chat/todo_action_contracts.py(402LOC,0ASTAny): typed host/store/session/runtimeProtocols (ChatTodoActionHost,TodoActionServiceSelf,ActionStoreProtocol,TodoTurnLoaderProtocol,TodoSessionStoreProtocol,TodoRuntimeControllerProtocol,GoalCommitSubmitController), schema constants, option parsers (parse_reviewed_terminal_options,parse_reviewed_update_options), and narrow coercion helpers.loopx/chat/todo_action_tasks.py(493LOC,0ASTAny): task assignment CAS recovery (apply_created_todo_assignment), cross-runtime lock fence (confirmed_task_commit), task session/turn lookup and recovery (read_task_start,read_confirmed_task,pending_applied_task_receipt,project_task_dispatch,recover_applied_task,start_confirmed_task).loopx/chat/todo_action_create.py(295LOC,0ASTAny): legacy creation recovery (_recover_legacy_todo_source,_recover_created_todo_step), new review creation (_create_new_todo_step), assignment dispatch (_assign_created_todo), andapply_todo_create.loopx/chat/todo_action_updates.py(401LOC,0ASTAny):run_todo_update,run_gate_resolve,canonical_update_basis(preserving doubleresolve_chat_todo_sourceTOCTOU verification),apply_reviewed_todo_edit(preserving fail-closed malformed basis handling and error/projection recovery states), andapply_todo_update.loopx/chat/todo_actions.py(243 <= 550LOC,0ASTAny,max_span=23): thinChatTodoActionMixindelegation and_decision_readbackwrapper.tests/control_plane/test_chat_todo_actions_contract.py(637LOC,0ASTAny): AST/LOC/Zero-Any/Zero-ignore/layout-pin checks, parser/coercion unit bounds,pending_applied_task_receiptandproject_task_dispatchboundary checks,_canonical_update_basisTOCTOU and_apply_reviewed_todo_editerror-state recovery, and task-start/recovery negative paths.0# type: ignore,0# noqa,0local/private paths,module_metric_baseline.jsonuntouched,loopx/*.py == 112).Validation Summary
ruff checkon all 5 source modules +tests/control_plane/test_chat_todo_actions_contract.py: passed.mypy --strict --no-incremental --follow-imports=silenton all 5 source modules +loopx/chat/action_store_common.py+tests/control_plane/test_chat_todo_actions_contract.py:Success: no issues found in 7 source files(todo_actions.py:43 -> 0errors).[tool.mypy](17/17):Success: no issues found in 17 source files.mypy --no-incremental --follow-imports=silent:loopx/chat_actions.py0 -> 0errors,loopx/chat/monitor_actions.py16 -> 16,loopx/chat_server.py28 -> 28.npm run typecheck:control-planeclean;node --no-warnings --experimental-sqlite --experimental-strip-types --test tests/control_plane_ts/content_digest_single_owner.test.ts tests/control_plane_ts/action_review_plan.test.ts:38/38passed.python scripts/check_rfc_bilingual.py --base origin/main --head HEAD&git diff --check origin/main: passed.HOMEsmokes:semantic-vocabulary-drift-smoke.py,control-plane-maintainability-ratchet-smoke.py,control-plane-integrated-canary-smoke.py(file&sqlite),loopx-chat-actions-smoke.py,user-todo-review-material-smoke.pyall passed.57c4c43b52vs candidate onfile&sqlitefixtures):12/12keys matched (PARITY_DIFFS: {}).pytest:tests/control_plane/test_chat_todo_actions_contract.py+tests/test_chat_internal_module_layout.py:8 passedtests/control_plane/test_reviewed_terminal_actions.py(withloopx/web/chatassets linked):24 passedpytest -q -n 6 -rsacross 17 suites withoutloopx/web/chatassets):2,376 passed, 6 skipped(6 APFS non-UTF-8/root skips intest_git_path_display.py),4 failed(test_packaged_chat_http_recovers_terminal_action404on/chatbefore linkingloopx/web/chat; passed separately24/24with assets linked).loopx check(5checks,errors=0), Goal CQR (cqr_266a509729548cf01627,decision="pass",status="valid"), Goalcanary premerge --from-git-diff --git-diff-base origin/main(ok=true,5/5selected checks,manual_hold_count=0).