Skip to content

refactor(cli): extract todo completion owner - #3944

Closed
songoow wants to merge 1 commit into
loopx-project:mainfrom
songoow:codex/cli-todo-complete-owner
Closed

songoow wants to merge 1 commit into
loopx-project:mainfrom
songoow:codex/cli-todo-complete-owner

Conversation

@songoow

@songoow songoow commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • loopx/cli_commands/todo.py reached 1185 lines, above the 1098-line frozen budget in examples/cli-command-module-size-ownership-command-modularization-smoke.py, which is one of the shard-0 failures keeping Full Public Smokes red on main. Follow the smoke's own instruction and the turn_dsh_host.py precedent (fix(ci): repair public smoke regressions #3856): extract one cohesive command owner instead of raising the budget.
  • Move the loopx todo complete owner into loopx/cli_commands/todo_complete.py: the settlement-requirement and settlement-error rules, the turn-scoped settlement gate plus complete_goal_todo write (run_todo_complete), and the post-commit settlement readback and post-writeback hook dispatch (finalize_committed_todo_completion, TodoCompletionOutcome). handle_todo_command keeps subcommand dispatch, rollout-event append, and the runtime-shadow mirror, then hands the outcome to the finalizer, preserving the original ordering and payload mutation.
  • Moved code is mechanically identical apart from two helpers losing their private underscore (they are now the owner module's API) and the inline project/state-file expansion using the existing path_args mapping. No compatibility wrapper: the only importers were two tests, re-pointed to the new owner.
  • todo.py drops to 972 lines, inside the 1000-line default, so the frozen "todo.py": 1098 entry is retired (a tightening, not a raise). No CLI flags, outputs, or defaults change.
  • Disclosure of a remaining baseline failure: on current main the same smoke also fails on turn.py, which reached 1047 lines in fix(coordination): route the legacy todo write transaction through the effective runtime root #3904 with no frozen entry. This PR does not touch turn.py; whether to pin it or extract another owner is a maintainer decision.

Companion baseline PRs for the other shard failures: #3942 (goal configuration catalog smoke) and #3943 (concise help and manpage parity). Each is independent and can merge in any order.

Issue Or Task

  • Closes #
  • Contributor task ID: baseline repair for the red Full Public Smokes workflow on main (shard 0)

Validation

  • python3 -m py_compile loopx/cli_commands/todo.py loopx/cli_commands/todo_complete.py
  • python3 examples/cli-command-module-size-ownership-command-modularization-smoke.py -> todo.py budget satisfied; the only remaining assertion failure is the pre-existing turn.py 1047 > 1000 from fix(coordination): route the legacy todo write transaction through the effective runtime root #3904
  • characterization set green before and after the move: tests/test_cli_argument_diagnostics.py, tests/control_plane/test_quota_settlement.py, tests/control_plane/test_coordination_runtime_shadow_adapter.py, tests/test_cli_entrypoint.py, tests/test_goal_mode_mcp_completion_validation.py -> 174 passed
  • heartbeat-quota-flow, monitor-poll-writeback, task-lease-runtime, multi-agent-role-successor-todos, cli-control-plane-command-modularization smokes -> ok
  • python3 -m pytest tests -q -k "todo or cli or help" -> 1132 passed
  • loopx canary premerge --from-git-diff --git-diff-base <official main> -> 18/18 selected checks passed, 0 manual holds
  • git diff --check clean; commit carries the DCO trailer

Type of Change

  • Refactoring (no functional changes)

LoopX Area

  • Control plane (goals, todos, quota, scheduler, registry, runtime)

Technical Direction

  • Core control-plane hardening

  • Target base branch: main

  • Direction tracker or promotion unit: Full Public Smokes baseline

Boundary Checklist

  • I did not commit .loopx/, .codex/goals/, live ACTIVE_GOAL_STATE.md, credentials, private benchmark traces, verifier output, raw agent sessions, internal document links, or local machine paths.
  • I did not duplicate maintainer-owned benchmark work unless a maintainer split out a public issue for it.
  • I kept the change scoped to the linked issue/task.
  • Every commit includes a DCO Signed-off-by trailer (git commit -s).

`loopx/cli_commands/todo.py` had grown to 1185 lines, above the 1098-line
frozen budget in
`examples/cli-command-module-size-ownership-command-modularization-smoke.py`,
which turned the Full Public Smokes baseline red. Follow the smoke's own
instruction and the `turn_dsh_host.py` precedent (loopx-project#3856): extract one
cohesive command owner instead of raising the budget.

Move the `loopx todo complete` owner into
`loopx/cli_commands/todo_complete.py`: the settlement-requirement and
settlement-error rules, the turn-scoped settlement gate plus
`complete_goal_todo` write (`run_todo_complete`), and the post-commit
settlement readback and post-writeback hook dispatch
(`finalize_committed_todo_completion`). `handle_todo_command` keeps the
subcommand dispatch, rollout-event append, and runtime-shadow mirror; it
hands the completion outcome to the finalizer after those observers run,
preserving the original ordering and payload mutation. The moved code is
byte-identical apart from the two helpers losing their private underscore
(they are now the owner module's API) and the inline project/state-file
expansion being replaced by the equivalent `path_args` mapping.

Bounded future-facing pass: applied. `todo.py` drops to 972 lines, inside
the 1000-line default, so the frozen `"todo.py": 1098` budget entry is
retired rather than left as slack (a tighter budget, not a raise). No
compatibility wrapper: the only importers of the moved helpers were two
tests, updated to the new owner. No CLI flags, output, or defaults change.

Validation:
- python3 examples/cli-command-module-size-ownership-command-modularization-smoke.py -> ok
- python3 -m pytest tests/test_cli_argument_diagnostics.py
  tests/control_plane/test_quota_settlement.py
  tests/control_plane/test_coordination_runtime_shadow_adapter.py
  tests/test_cli_entrypoint.py tests/test_goal_mode_mcp_completion_validation.py
  -> 174 passed (same set green before the move)
- examples/control_plane/heartbeat-quota-flow-smoke.py,
  monitor-poll-writeback-smoke.py, task-lease-runtime-smoke.py,
  examples/multi-agent-role-successor-todos-smoke.py,
  examples/cli-control-plane-command-modularization-smoke.py -> all ok
- pyflakes clean on changed Python files (ruff not installed locally)

Signed-off-by: song <liusongstep@gmail.com>
(cherry picked from commit 766c562a32c3e157cdd90f6a129cef506d07dd05)
@songoow

songoow commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator Author

Closing to keep the review queue small. With turn.py also above the default budget after #3904, the module-size smoke stays red on main regardless of this extraction, so the pin-versus-extract decision belongs to maintainers first. The extraction is validated and stays available on codex/cli-todo-complete-owner (todo.py 1185 -> 972 lines, no behavior change) if that is the preferred path.

@songoow songoow closed this Sep 4, 2026
@songoow
songoow deleted the codex/cli-todo-complete-owner branch September 16, 2026 05:54
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.

1 participant