Skip to content

refactor(todos): extract completion-validation orchestration into a bounded module - #3209

Merged
huangruiteng merged 1 commit into
huangruiteng:mainfrom
NIU-123370:refactor/extract-completion-validation
Aug 15, 2026
Merged

refactor(todos): extract completion-validation orchestration into a bounded module#3209
huangruiteng merged 1 commit into
huangruiteng:mainfrom
NIU-123370:refactor/extract-completion-validation

Conversation

@NIU-123370

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #3142, landing the P2 flagged in its review: extract the completion-validation orchestration out of loopx/todos.py into a bounded module.

  • New 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.py delegates to the new module — call sites and receipt semantics unchanged; the file goes 2316 → 2165 lines.
  • tests/control_plane/test_todo_completion_validation.py only updates imports.
  • Canary baseline ratchets loopx/todos.py lines 2167 → 2165 (re-verified against current main 64c0448c after 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 passed
  • pytest tests/canary/ (incl. maintainability ratchet) — 20 passed
  • all todo-related suites (14 files) — 149 passed
  • mypy on the new module — 0 errors; loopx/todos.py carries the same 4 pre-existing errors as main (zero new)

Refs #3142 (follow-up to #3082).

…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 huangruiteng left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

评审结论:通过(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 转绿后即可合并。

@huangruiteng
huangruiteng merged commit 2b88065 into huangruiteng:main Aug 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants