Repository navigation
test(windows): launch the source CLI through the shipped host entry - #6406
Conversation
Signed-off-by: JasonBuildAI <jasonbuildai@gmail.com>
On native Windows the public suite cannot exec the extensionless POSIX bash shim `scripts/loopx` (OSError WinError 193), `bash` resolves to the WSL relay, and one CLI text read uses the host locale codec on output the CLI pins to UTF-8. A shared helper (tests/source_cli.py) selects the host's real entry: `scripts/loopx_entry.py` on Windows -- the same entry loopx/windows_install.py and scripts/loopx.ps1 invoke -- and the bash shim on POSIX hosts. POSIX-only launcher assertions are declared POSIX-only instead of failing on Windows, and CLI text reads pin UTF-8. 14 files on Windows at 3300dfd: 45 failed, 372 passed before; 399 passed, 18 skipped after. Closes loopx-project#6405 Signed-off-by: JasonBuildAI <jasonbuildai@gmail.com>
Pin LOOPX_RELEASE_ROOT like the shipped launchers instead of inheriting an ambient value, pin UTF-8 on the two remaining launcher-output reads in the scheduler launcher tests, and add an end-to-end smoke that launches the real host entry (`--version`). Refs loopx-project#6405 Signed-off-by: JasonBuildAI <jasonbuildai@gmail.com>
fee76fc to
320762c
Compare
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent; gpt-6.1-sol; OpenAI; runtime_reported; reasoning_effort=xhigh.
Exact head: 320762c. Whole-PR review against 14112f3.
动机
在原生 Windows 上跑源码测试的贡献者,需要让测试真正启动该宿主可执行的 CLI。旧测试直接启动 POSIX bash shim;Windows 无法执行它,WSL relay 也不能代替已安装的 bash,按宿主默认编码读取 UTF-8 输出还会报解码错误。结果是 CLI 行为未得到检验,贡献者却要处理无关的启动失败。
此次将 30 处既有 CLI 调用集中到宿主入口 helper,保留原命令参数、cwd、env 和成功/失败断言,并声明真正的 POSIX 专用场景。独立 POSIX base/head 测试与实际 Python 隔离入口均通过,源码测试的可执行入口和既有检查语义得到保留。本次未在原生 Windows 或 PowerShell 宿主重跑,不把作者的 Windows 结果、分支模拟或本机 Python 入口验证当成该平台的独立验收;不启动 benchmark、外部模型或活动 Goal。
改动思路
复用产品已有的 Windows 启动链:sys.executable → -I → scripts/loopx_entry.py,明确设置当前 checkout 的 LOOPX_RELEASE_ROOT。POSIX 继续走原 bash shim;helper 提供原 cwd/text/capture_output 默认值及 UTF-8 解码,调用者仍保留 check 的决定。测试 fixture 只适配宿主启动与读取,不成为产品 CLI、评分或权限的新 owner。
这是一份有实际 30 处消费者的共享测试 helper,替代重复 subprocess 包装;现有 tests/control_plane/test_source_cli_entrypoint.py 检验的是 module/console 分支和 typed ownership,不是宿主 launcher 的选择,两个边界不同。相邻 windows_install/_entry_command 和 scripts/loopx.ps1 已核对,helper 的 Windows argv 与原产品 owner 一致。该 PR 边界是已有源码 CLI 测试的宿主适配,不修改已发布产品、控制面或 benchmark 的运行规则。
| 宿主或输入 | 入口与结果 |
|---|---|
| POSIX | 原 scripts/loopx,原参数与结果保持 |
| Windows 分支 | 当前解释器 -I 运行既有 loopx_entry.py,当前 root 覆盖过期环境 root |
| CLI 非零退出 | check=False 返回退出码;check=True 仍抛 CalledProcessError |
| POSIX 专用 launcher 场景 | 仅 nt 宿主跳过;其余平台继续检验 |
表格说明当前 head 的代码分支;Windows 分支的实际 Python 入口本次在 POSIX 执行,不能据此声称 Windows 内核或 PowerShell 已验证。
具体改动
全量 16 文件 +197/-219。tests/source_cli.py 的 source_cli_command(L28)选择 launcher;source_cli_env(L41)复制输入环境,并在 Windows 固定当前 root;run_source_cli(L51)保持 cwd、显式 check 和 subprocess 返回语义,默认读取 UTF-8。11 个 benchmark capability 测试文件与 Todo cadence 文件迁移 30 处调用,完整函数 AST 对照证明只删除被 helper 提供的 launcher/cwd/text/capture 包装,原 check=True/False、参数、断言和其他函数逻辑未改。
tests/test_loopx_launcher_python_selection.py 增加 nt-only 的 POSIX 声明;test_scheduler_native_launcher.py 只在 Windows 跳过 unix 分支,并固定三个原有输出读取位置的 UTF-8。tests/test_source_cli.py 用四个聚焦用例覆盖 Windows/POSIX 选择、过期 root、非 ASCII 输出和真实 host entry 启动。生产目录、依赖、CI 选择和原 benchmark 用例语义均未修改。
独立依据是 #6405 的 Expected behavior,按本次读取的当前 issue body 判断:宿主使用可执行的原有入口、POSIX 保留旧行为、POSIX 专用断言有明确范围、CLI 输出按 UTF-8 读取。Windows 入口同时对照上述 immutable base 的 shipped launcher,而非只对照新 helper 自己的返回值。
独立实际探针在非仓库 cwd 放置会报错的同名模块,并传入过期 root/PYTHONPATH:Windows 分支生成的 argv 与 windows_install owner 相同,实际 Python -I 子进程读回当前源码版本 1.4.0,未被环境或 cwd 模块截获。POSIX 原调用和新 helper 的完整 stdout/stderr/退出码相同;实际非法 CLI 参数仍返回 2 或按 check=True 抛异常。
对主干的风险
相同的原 14 文件在本机 immutable base 是 404 passed、13 skipped;当前加上四个 helper 用例是 408 passed、13 skipped。13 项均依赖本机没有的 pwsh,未作为通过项;与作者原生 Windows 的 399/18 是不同平台和选择,不能混算。风险 canary 的 4 项直接检查及 10 项选中检查通过,完整语义与维护性检查通过;没有获取或等待远端 CI。
风险集中于测试准入和 source root,而非新产品行为。用整函数 AST 与实际子进程检验防止把原失败断言改成成功;没有把 benchmark 本身跳过。Windows 环境 pin 是刻意与产品启动链对齐,POSIX 环境不增加该 pin。helper 只在 tests 内被消费,不安装新能力、写入真实配置或改变执行授权。
非阻塞建议: 后续可将 tests/test_source_cli.py 纳入现有 windows-powershell 的 curated 文件列表,使四项测试及真实 host-entry smoke 持续在 Windows CI 执行。目前该列表没有这些文件,作者也已明确披露;本 PR 已交付有用的本地贡献者测试修复,但不能声称新增 Windows CI 防护已生效。该建议不要求在此 PR 扩大到其他 Windows、TS 或 EdgeBench 任务。
我的整体评价
APPROVE。共享 helper 有 30 处真实消费者,减少重复维护并修复已演示的宿主入口问题;既有正负检查、POSIX 行为和输入环境隔离均有独立证据。原生 Windows/PowerShell 的本次独立运行缺口保留,当前无要求作者更改产品 runtime 的 blocker。
未来维护检查已应用:调用者集中到同一个测试入口,复用既有产品 owner,不再增加另一套 installer 或通用测试框架。同作者最近 30 个 PR 已检查;相邻 #6356、#6368、#6399 和 #6422 处理其他明确宿主或产品边界,没有发现重复同形 scaffold,未触发贡献限制。历史 RFC 经验对本测试修复不提供结论,只提示核验实际使用路径;不宣称模型采纳或长期收益。
English verdict: APPROVE — 320762c. All 30 migrated calls preserve their checks and assertions. POSIX base: 404 passed/13 pwsh skips; head: 408 passed/13 skips. The real isolated Python entry and ambient-root rejection are verified on POSIX; native Windows and PowerShell were not independently rerun. Consider adding the helper tests to the existing Windows CI selection.
Goal And Delivered Outcome
Outcome basis / optional anchor: Closes [Bug]: On native Windows the source-checkout test suite cannot launch the CLI (WinError 193 / WSL relay / locale decode) #6405 (reproduced: on native Windows the source-checkout suite cannot launch the CLI).
Goal/source and gap: the 14 affected files exec the extensionless POSIX bash shim
scripts/loopxviasubprocess.run, so on native Windows 45 tests fail (OSError: [WinError 193], the WSL relay's missing/bin/bash, or a cp936 read of the CLI's UTF-8-pinned output). CLI-behavior coverage in these files is lost for Windows contributors and CI.Observable before → after, with the validation row that proves it: same 14-file command on Windows at
3300dfdd2→45 failed, 372 passed in 229.91s; on this head →399 passed, 18 skipped in 366.76s(the 18 skips are the declared POSIX-only cases; see Validation rowregression_parity/integration).Issue/task and intended base: Closes [Bug]: On native Windows the source-checkout test suite cannot launch the CLI (WinError 193 / WSL relay / locale decode) #6405; base
main.Author Declaration
Implemented against
loopx/windows_install.pybuilds[python, "-I", scripts/loopx_entry.py, ...]andscripts/loopx.ps1delegates to it); POSIX-only guard precedent test(contract): keep the mode-000 read checks POSIX-only #6007; CLI UTF-8 stdio pinning fix(cli): pin the shipped CLI's own stdio to UTF-8 #6119. Revision:3300dfdd2.tests/source_cli.py(source_cli_command,source_cli_env,run_source_cli)399 passed, 18 skippedtests/source_cli.pytests/test_loopx_launcher_python_selection.py,tests/test_scheduler_native_launcher.pytests/test_scheduler_native_launcher.pyUnicodeDecodeError: 'gbk' codec ... byte 0xb7cases now passloopx/windows_install.py,scripts/loopx_entry.py,scripts/loopx.ps1) so the helper matches installed behavior; verified every migrated call keeps its originalchecksemantics (30 sites compared old vs new); left out product-code changes, new dependencies, and unrelated Windows failures. Review-driven follow-up commitfee76fc77pinsLOOPX_RELEASE_ROOTlike the shipped launchers instead of inheriting an ambient value, pins UTF-8 on the two remaining launcher-output reads, and adds the end-to-end--versionsmoke. Not verified locally: POSIX execution (no POSIX host here).Scope And Continuation
Validation
320762cad6908b7b5672a0640de1e815ed70c3e1(rebased onto latestmainat14112f36c; the 14-file Windows run was repeated on this head)staticpassedruff checkover all changed files:All checks passed!;git diff --checkcleanunitpasseduv run --extra test python -m pytest -q -p no:cacheprovider tests/test_source_cli.py→4 passed in 3.90s, including an end-to-end smoke that starts the real host entry (--version)integrationpassed399 passed, 18 skipped in 366.76s; tests exec the real CLI entry end-to-endregression_paritypassed3300dfdd2:45 failed, 372 passed in 229.91s; before-failure list recorded in #6405; total collected 417 both sidesmanualpassedmanualnot_runbashis a broken WSL relay). CI's ubuntu lane must confirm POSIX paritynt-scoped. Scope note: the requiredwindows-powershellCI lane runs a curated file list that does not include these files (.github/workflows/python-tests.yml), so the demonstrated benefit is the Windows developer loop and any job that runs the suite there; durable CI regression protection for the Windows branch would need a lane change and is left out of this PR.Frontend / Visual Evidence
Type of Change
LoopX Area
Technical Direction
Shared-authority RFC fixture impact
Boundary Checklist
.loopx/,.codex/goals/, and liveACTIVE_GOAL_STATE.md).none.Signed-off-bytrailer (git commit -s).