refactor(todos): extract completion-validation orchestration into a bounded module - #3209
Merged
huangruiteng merged 1 commit intoAug 15, 2026
Conversation
…ounded module Addresses the P2 follow-up from huangruiteng#3142's review: move the caller-approved completion-validation orchestration (read declared command -> run -> gate) out of the 2318-line loopx/todos.py and into a new bounded module, loopx/control_plane/todos/completion_validation.py. complete_goal_todo now calls a single run_completion_validation_gate(...) before acquiring the mutation lock; the gate, the pre-read, the runner, and the typed-failure receipt construction all live in the new module. No behavior change — this is a pure move (the privacy invariant, the outside-the-lock placement, the dry_run/terminal-replay skip, and the 20s timeout are all preserved). Effect: loopx/todos.py 2318 -> 2167 lines; canary ratchet baseline for loopx/todos.py ratcheted back 2318 -> 2167 accordingly. The new module follows its control_plane/todos/* siblings (not individually budgeted). Stacked on huangruiteng#3142 (branch based on feat/todo-completion-validation); rebase onto main and open as a standalone follow-up PR once huangruiteng#3142 merges.
huangruiteng
approved these changes
Aug 15, 2026
huangruiteng
left a comment
Owner
There was a problem hiding this comment.
评审结论:通过(Approve)
纯重构,无行为变更:#3142 review 标记的 P2 完成——把 loopx/todos.py 中的 completion-validation 编排(读取声明命令 → 在 goal repo workspace 运行 → 超时/缺 workspace/命令异常均返回隐私安全的 typed receipt → 失败阻断 completion)整体抽取到新模块 loopx/control_plane/todos/completion_validation.py,对外只暴露 run_completion_validation_gate。调用点与失败语义保持不变;loopx/todos.py 2318 → 2165 行,canary baseline 同步更新。
验证(exact head 38649e76d,独立 worktree):
pytest tests/control_plane/test_todo_completion_validation.py tests/canary/:27 passed(含 maintainability ratchet)git diff --check:无输出- 新模块与
loopx.todos导入正常 - GitHub Actions:build / dependency-review 通过;pytest 正在运行(评审时 pending)
无阻塞问题。CI pytest 转绿后即可合并。
This was referenced Aug 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #3142, landing the P2 flagged in its review: extract the completion-validation orchestration out of
loopx/todos.pyinto a bounded module.loopx/control_plane/todos/completion_validation.py(187 lines) holds the read → run → gate sequence behind a single public entry point,run_completion_validation_gate.loopx/todos.pydelegates to the new module — call sites and receipt semantics unchanged; the file goes 2316 → 2165 lines.tests/control_plane/test_todo_completion_validation.pyonly updates imports.loopx/todos.pylines 2167 → 2165 (re-verified against current main64c0448cafter re-basing; the −2 drift vs. the original stacked branch comes from main, not this change).Pure move — no behavior change.
Verification
pytest tests/control_plane/test_todo_completion_validation.py— 7 passedpytest tests/canary/(incl. maintainability ratchet) — 20 passedmypyon the new module — 0 errors;loopx/todos.pycarries the same 4 pre-existing errors as main (zero new)Refs #3142 (follow-up to #3082).