test(coordination): restore the reviewed-promotion CLI suite that main cannot collect - #5045
NIU-123370 wants to merge 1 commit into
Conversation
…ng test module Signed-off-by: NIU-123370 <191000457+NIU-123370@users.noreply.github.com>
huangruiteng
left a comment
There was a problem hiding this comment.
Exact head: 3bb561f. This review is against current origin/main 21ee4f0092e39b462296c8aa9cd115a258eea4ab, not remote CI or merge authorization.
动机
PR 旨在修复 reviewed-promotion CLI 测试因导入已删除的兄弟测试文件而不能收集的问题。这个问题值得解决,但当前主干已在 09fe7399d 更新同一个文件,必须先验证“main 仍不能收集”的前提是否存在。
改动思路
本 PR 把工作区创建、命令构造、环境配置和 CLI 启动辅助函数复制进测试文件,以消除旧导入。相比之下,最新主干已经使用 tests.control_plane.shadow_e2e_fixture 的共享夹具,并扩展了 provider/strategy 覆盖。两套辅助函数不应在同一文件冲突后并行维护。
具体改动
tests/control_plane/test_reviewed_promotion_cli.py 改为在文件中定义 _workspace、_command、_env、_cli,保留 4 个 CLI 用例;sys.executable 的选择是正确的。在本 PR exact head 独立运行该文件,4 passed(89.73s),说明旧基线上的收集问题可被这份补丁绕开。但最新主干同一文件已经独立收集 9 个用例,且实跑一条 source-drift 用例通过。
关键代码讲解
- 新的
_workspace和_cli在测试文件中复制端到端启动与解释器环境逻辑,和主干现有共享 fixture 重叠。 - 主干该文件已使用
shadow_e2e_fixture.REPO/workspace,测试 file/sqlite 与多种 cutover 策略;若把这份旧分支直接套上去,会发生文本冲突,手工错误解决还可能丢掉主干新增的覆盖。
对主干的风险
当前 PR 的目标前提已失效:origin/main 上执行 uv run --extra test python -m pytest --collect-only -q tests/control_plane/test_reviewed_promotion_cli.py 收集 9 项、无 ImportError;一条代表性真实 CLI 用例 33.55s 通过。GitHub 当前也标记为 CONFLICTING。这里不是“无关红 CI”,而是同一文件的主干演进已完成更宽的修复。最小处理是关闭/标记本 PR 被主干替代;如仍有未覆盖缺口,先指出可复现差异,再从最新主干只提交增量测试,并继续复用共享 fixture。
我的整体评价
exact head 在旧基线上可通过,但对当前主干已无可验证的新增仓库价值;重复辅助函数会增加未来维护成本,强行合并可能减少覆盖。没有产品运行时或用户入口改变,用户体验无直接变化;无需兼容性层。相关的未来友好重构在主干的共享 fixture 已实现,本 PR 不应另建平行夹具。请在最新主干确认新缺口后再提精简增量。
English verdict: REQUEST_CHANGES - current main already collects and runs broader reviewed-promotion coverage, while this exact head conflicts and duplicates the shared fixture.
|
确认前提已失效,按建议关闭。 我在 本 PR 只恢复 helper、不新增断言,而主干是 9 条(provider/strategy 扩臂)另加 |
|
复核结论:这条 PR 的前提确实已经失效,我同意「被主干替代」的处理,现在关闭。 在最新 main(
所以再留着只会在同一个文件上多养一套平行夹具,正如评审指出的:解冲突时还可能丢掉主干新增的覆盖。不做了。 两条同期实测、对别人可能有用的事实:
后续如果在这条线上发现最新 main 仍未覆盖的缺口,我会另开精简增量并复用共享夹具。(以上本地验证跑在检出对应 revision 的干净 worktree 上,用本机已准备好的 Python 环境,并把 Node 22.23.2 放在 PATH 前面以避开 |
Goal And Delivered Outcome
tests/control_plane/test_reviewed_promotion_cli.pycannot be collected on
main. Its line 12 imports_workspace,_cli,_command,_envandREPO_ROOTfromtests.control_plane.test_local_authority_shadow_cli_e2e, and the merge of#5011(1e21976d6, 2026-09-25 12:34 UTC) rewrote that module into theretired-setting CLI journey and dropped all five names — the pre-merge version
defines them at
REPO_ROOT/:21/:59/:74/:80, the current one has twotest functions and no helpers. The result is
ImportError: cannot import name '_workspace' from 'tests.control_plane.test_local_authority_shadow_cli_e2e', and a 230-linereal-CLI end-to-end suite — reviewed promotion cutover and recovery across both
the
fileandsqliteprovider arms, source-drift rejection, and thepolicy-override and missing-fence refusals — silently contributes nothing.
python -m pytest -q --co tests/control_plane/test_reviewed_promotion_cli.pyends in
no tests collected, 1 error; after, the same command reports4 tests collectedand the run is4 passed in 13.93s(theunitrowbelow). The helpers are restored verbatim from the pre-deletion version and
defined in the file that uses them, so no fixture content, CLI argument or
assertion changes — the only structural change is that this suite no longer
depends on a sibling test module's private helpers.
completed here, so no
Closes. Basemain.Scope And Continuation
The important negative finding is stated rather than glossed: the restored
suite passes on current
main, so the breakage hid no behavioral regressionand this PR restores coverage rather than reporting a defect in promotion
itself.
helpers in
tests/control_plane/shadow_e2e_fixture.py, which is already thedesignated shared owner ("Disposable public CLI fixtures…") and is imported by
five other files including the module this one used to import from. Deliberately
not done in this PR: that fixture's
workspace()pins the goal id togoal-e2e, always writescoordination.runtime_shadowinto the registry andalways bootstraps, while this suite needs a registry without a pre-configured
shadow (it drives
configure-goal --coordination-runtime-shadow-file --executeitself) and needs non-zero exit codes parsed as JSON. Reshaping afive-consumer fixture is the owner's call, so this diff keeps the repair
minimal and local rather than widening into that surface.
Validation
3bb561fc3unitpassedpython -m pytest -q tests/control_plane/test_reviewed_promotion_cli.py→4 passed in 13.93s(both provider arms:test_saved_plan_cutover_and_recovery_after_canonical_write_and_missing_legacy[file]and[sqlite], plus the source-drift and policy-override cases).unitpassedpython -m pytest -q tests/control_plane/test_local_authority_shadow_cli_e2e.py→2 passed— the module whose rewrite caused the breakage is untouched by this diff and still green.regression_paritypassedno tests collected, 1 error(ImportError: cannot import name '_workspace' …), and with this diff reverted the selection re-collects 0 tests. No assertion was weakened, added or skipped to reach green.staticpassedpython -m ruff check→ all checks passed;python -m ruff format --check→1 file already formatted.staticnot_applicablepython -m mypynot run:[tool.mypy] files=[…]enumerates 24 modules, none undertests/, and no product file changes here.end-to-end coverage of reviewed promotion through the installed CLI transport
and real local stores. Gaps named plainly: (1) the suite spawns the real CLI as
a subprocess and the
sqlitearm additionally runs the TypeScript providerthrough
node, so it depends on a Node new enough for the control plane; itwas run here with Node 22.23.2 and a locally installed Python 3.12 environment
(an editable install from another worktree on this machine) rather than
uv sync --extra test, andloopx.__file__was confirmed to resolve to thisworktree; (2) while running a wider selection
(
python -m pytest -q tests/control_plane -k "projection") one unrelatedfailure appears,
tests/control_plane/test_shared_goal_alignment.py::test_appending_one_event_rotates_the_projection_into_frontier_behind,which reproduces identically on an unmodified tree and is neither caused nor
fixed by this diff; (3) this PR does not add any new assertion about promotion
behavior — it only makes the existing ones run again.
Frontend / Visual Evidence
Type of Change
LoopX Area
Technical Direction
hardening — keeping reviewed-promotion end-to-end coverage actually running.
No roadmap S/G/R id claimed.
Shared-authority RFC fixture impact
generator changed.
dimensions; the impact is that the promotion cutover/recovery and
provider-parity arms of this suite are collected again.
file_v0provider for all four cases and thesqlite_v0provider for thecutover-and-recovery case, through the real CLI transport.
no promotion, routing or projection behavior; the restored tests exercise the
file and SQLite paths only, and PostgreSQL is not configured on this machine.
Boundary Checklist
.loopx/,.codex/goals/, and liveACTIVE_GOAL_STATE.md).none.Signed-off-bytrailer (git commit -s).