Repository navigation
Conversation
Windows allocates a visible conhost window for every console-subsystem child of a parent without a console, so the node, python and git helpers spawned throughout a goal start flash black windows on console-less hosts, and the detached usage observer intermittently surfaces ERROR_NO_DATA (0x800700E8) when its child exits before reading stdin. Add a shared no_console_creationflags() helper (CREATE_NO_WINDOW on Windows, 0 elsewhere) and apply it at the launch sites the CLI, goal/turn, quota and validation paths execute. Keep the detached observer's DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP flags and make its pipe-closed stdin write race non-fatal. TypeScript hosts that spawn python or loopx CLI children set windowsHide: true, matching the existing host_process and zcode_goal_mode precedent. Non-Windows behavior is byte-for-byte unchanged; the helper is imported lazily so cold import contracts stay cold. Fixes loopx-project#9430 Signed-off-by: Lihua <1017343802@qq.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
动机 / Motivation
Windows 无控制台宿主启动 Goal 时,短命的 Node、Python 和 Git 子进程会弹出控制台。Console-less startup 的验收包括回执。适用于已有 Windows CLI、Git 探测、Node 宿主、验证器、Python detached observer、Pi、NoKV 和 Research snapshot 子进程。
用户在附有控制台的 Windows PowerShell 或 cmd 中直接执行生成的 scheduler-ack-current 或 scheduler-fail-current。这个启动点无条件应用 CREATE_NO_WINDOW,也没有转发 stdout。Win32 由此去掉子进程继承的控制台,调度器写入 stdout 的回执可能从终端消失,父进程仍只接收退出码。
真实 macOS 子进程读取了完整 UTF-8 请求。子进程提前退出时,基线出现 BrokenPipeError,当前头安静返回。缺失程序在两侧均报告 FileNotFoundError,真实 Node 探测及 Usage Status 可用。 Windows 分支隔离夹具只证实了进程参数发生变化。Windows 控制台读回与闪窗实际表现仍需在 Windows 上执行。 问题 #9430
改动思路 / Approach
共享进程 transport 提供 Windows 创建标志。Node 侧使用现有 windowsHide 选项。Telemetry observer 保留脱离进程和 pipe 传输,单独处理提前关闭的 pipe。调度状态、校验、写入和持久回执由 TypeScript scheduler owner 处理。Python 与 Node 只改变创建子进程的 transport。
loopx.entrypoint.main → _native_scheduler_followup_argv → subprocess.call → heartbeat_followup_cli.ts。保留前台调度分支的控制台继承,仅在无控制台宿主使用抑制参数,或显式转发可读的 stdout/stderr。补一项 Windows 前台回执和无控制台重定向回执对照。
具体改动 / Changes
精确 head 83bbed0221d5722ab6344371cb1f4b5a36b2a5d3,分叉基线 b34f0e6157968251dedbd88552ccad34c4fdeef9。24 个文件,+601 / −9。生产改动复用按平台的创建参数并调用现有 transport。新增 482 行 Python 参数断言。
关键代码讲解
no_console_creationflags。Python 复用进程平台适配器,macOS 返回默认的 0。 源码entrypoint.main。原生调度入口等待子进程退出,发布回执依赖子进程的 stdout。 源码heartbeat_followup_cli.main。类型化调度结果和拒绝原因写入 stdout。 源码usage_ping._detach。保留现有进程分离和重定向,清理已断开的遥测输入。 源码NoKVJsonLinesTransport。默认 spawn 已使用显式 stdio pipe,现传入 windowsHide。 源码
对主干的风险 / Risks
[P2] 保留 Windows 前台调度命令的回执输出
用户在附有控制台的 Windows PowerShell 或 cmd 中直接执行生成的 scheduler-ack-current 或 scheduler-fail-current。当前入口用 subprocess.call(..., creationflags=CREATE_NO_WINDOW) 无条件启动 Node,既有 stdout 回执由 Node 直接写出。父进程只返回退出码。根据 Win32 创建标志和 CPython 的标准句柄设置规则,这会改变前台控制台继承,可能丢掉终端里的成功回执和拒绝原因。保留前台调度分支的控制台继承,仅在无控制台宿主使用抑制参数,或显式转发可读的 stdout/stderr。补一项 Windows 前台回执和无控制台重定向回执对照。 入口 · Win32 创建标志 · STARTUPINFO · CPython
语义与本地验证
Python 测试 600 项通过、8 项跳过,包含 56 项单独复跑的聚焦用例。TypeScript 测试 468 项通过。真实 CLI 在基线和当前 macOS 头均返回 invalid_scheduler_host_facts 和退出码 1。Windows emulation 仅记录到旧头无额外参数,当前头只有 CREATE_NO_WINDOW。 标准本地 premerge 的 18 项 smoke 有 1 项安装超时。该项在同一精确提交单独复跑通过,差异检查与编译也通过。 断管吞错分支在 macOS 同样生效,建议同步修正 PR 的平台影响说明。
我的整体评价 / Verdict
REQUEST_CHANGES。 建议保留后台节点抑制与遥测断管修复,补齐前台和无控制台两类 Windows 调度回执的 readback。
English verdict: REQUEST_CHANGES. Preserve the existing scheduler receipt on console-attached Windows launches while suppressing new consoles for the background launch path.
| return subprocess.call(native_argv) | ||
|
|
||
| from .extensions.process_runtime import no_console_creationflags | ||
| return subprocess.call(native_argv, creationflags=no_console_creationflags()) |
There was a problem hiding this comment.
[P2] 用户在附有控制台的 Windows PowerShell 或 cmd 中直接执行生成的 scheduler-ack-current 或 scheduler-fail-current。这个启动点无条件应用 CREATE_NO_WINDOW,也没有转发 stdout。Win32 由此去掉子进程继承的控制台,调度器写入 stdout 的回执可能从终端消失,父进程仍只接收退出码。保留前台调度分支的控制台继承,仅在无控制台宿主使用抑制参数,或显式转发可读的 stdout/stderr。补一项 Windows 前台回执和无控制台重定向回执对照。 Win32 进程创建语义
There was a problem hiding this comment.
Addressed on b35624d7b. The flag is no longer passed to an attached parent: no_console_creationflags() returns CREATE_NO_WINDOW only when the parent has no console, so the entrypoint.py:155 call keeps creationflags == 0 there and the scheduler child inherits the console its receipt is printed on. The fix, the host-agnostic tests, the unrun-on-Windows disclosure and a two-line check for both branches are in my comment above.
|
@/tmp/ci-attribution.md |
BigDataDZ
left a comment
There was a problem hiding this comment.
独立复核(native Windows 10,Python 3.12,Node 24.20)——未批准
精确核对 head:83bbed022,合并基点 b34f0e615。评审里"Windows 控制台读回与闪窗实际表现仍需在 Windows 上执行"这一项,我在真机上做了。
1. 抑制机制在真 Windows 上有效
父进程无控制台(GetConsoleWindow() 为 NULL,stdout 句柄为 NULL)时:
| 子进程启动方式 | 子进程是否拿到控制台 |
|---|---|
| 不加标志 | 拿到自己的新控制台(独立 HWND) |
CREATE_NO_WINDOW |
没有控制台 |
2. 前台回执丢失已实测确认,且是静默的(对应评审的 P2)
父进程附着在控制台上(即用户在 PowerShell / cmd 里执行)时,用 subprocess.call(argv) 与 subprocess.call(argv, creationflags=CREATE_NO_WINDOW) 各启动 Python 和 Node 子进程,不重定向标准流,然后读回控制台屏幕缓冲区:
| 子进程 / 启动方式 | 输出是否出现在控制台 | 子进程侧 |
|---|---|---|
| Python / 基线 | 是 | 写入成功 |
Python / CREATE_NO_WINDOW |
否(整个屏幕缓冲区里都没有,光标不动) | sys.stdout 非 None,print 与 os.write(1, …) 均返回成功 |
| Node / 基线 | 是 | 写入成功 |
Node / CREATE_NO_WINDOW |
否 | process.stdout.isTTY === true,console.log 与 fs.writeSync(1, …) 均返回成功 |
并在本 head 上直接调用真实的 loopx.entrypoint.main(quota scheduler-ack-current --scheduler-host-facts-chunk … --turn-instance-id …;基线通过让 no_console_creationflags 返回 0 来还原,与 main 的 subprocess.call(native_argv) 等价):
- 基线:终端上出现 9 行
loopx_scheduler_host_followup_error_v0JSON,退出码 1。 - 当前 head:终端上没有任何输出,只有退出码 1。
entrypoint.py:155 是本 PR 中唯一不重定向标准流的调用点(scheduler_ack.py 那处有 capture_output=True,不受影响)。复现只需在 PowerShell 里运行:
import subprocess, sys
child = "print('RECEIPT')"
subprocess.call([sys.executable, "-c", child]) # 打印 RECEIPT
subprocess.call([sys.executable, "-c", child], creationflags=subprocess.CREATE_NO_WINDOW) # 不打印任何内容修复方向:新控制台只在父进程没有控制台时才会被分配,所以这一处可以只在父进程无控制台时才加该标志;或者显式转发子进程的 stdout / stderr。实测数据支持前者:父进程有控制台且不加标志时,子进程共用父进程的控制台(同一 HWND),不产生新窗口,输出正常。我没有对打了补丁的变体做测试。
3. 本 PR 新增的测试在 native Windows 上失败
tests/test_child_console_suppression.py + tests/extensions/test_process_runtime.py → 55 passed / 28 skipped / 1 failed。失败的是 test_run_host_process_bridge_passes_no_console_creationflags:run_host_process 在 Windows 上会执行 WindowsHostJob.assign(proc)(读取 process._handle),而测试里的假 BridgeProcess 没有这个属性:
loopx\control_plane\turn_driver\windows_host_job.py:111: AttributeError: 'BridgeProcess' object has no attribute '_handle'
28 个 skipped 都是 POSIX 专用的进程组用例。
4. CI
6 个 test-shard 都不是干净的结论,需要分开看:
- 分片 1、2、3、5、6 撞到了 pytest 会话时限(
LOOPX_PYTEST_DEADLINE,约 3250 秒,exit 2),属未跑完。我没有确定时限超标是否与本 PR 有关。 - 在已跑完的用例里共有 11 个失败。其中
test_runtime_subprocess_utf8.py::test_shipped_runtime_pins_utf8_for_every_text_mode_subprocess_call我核实过:它在合并基点b34f0e615上就是红的(planning_batch._call当时没有encoding),main 已由 #9400 修好,rebase 后会消失,不是本 PR 引入。其余 10 个我没有归因。 - PR 下 11-25 12:28 的那条评论正文只有字面量
@/tmp/ci-attribution.md,看起来 CI 归因的文本没有被展开,没有发出来。
未验证
usage_ping._detach对0x800700E8断管竞态的处理。- 闪窗本身:我用"子进程是否获得控制台 / 窗口是否可见"作为可测的替代指标,并在实验中把窗口隐藏,没有观察真实的闪窗。
- 实验用的是经典 conhost 控制台(隐藏窗口,通过屏幕缓冲区读回);没有在 Windows Terminal / ConPTY 下验证。
- 没有 POSIX 运行。
在 2 和 3 处理完、且套件在该 head 上有完整结果之前,我不给批准。
|
This pull request has merge conflicts with Choose the remote for the base repository, not an out-of-date fork. git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEADFor a same-repository clone whose Keep the DCO |
|
@LIHUA919 Thanks for taking this on, and thanks @BigDataDZ for the native Windows readback. I checked the current GitHub refs: a local Could you include the foreground follow-up fix and the Windows bridge test fix in that update? The next native Windows pass should cover both launch modes: a parent without a console starts its child without a new window, and an attached terminal still receives the scheduler follow-up JSON and the child's exit status. Please also rerun the bridge test that failed when its test double lacked |
Bring the branch up to date before the review fix; all six files touched by both sides merged cleanly. Signed-off-by: Lihua <1017343802@qq.com>
The foreground follow-up (`loopx quota scheduler-ack-current`) launches the scheduler without redirecting its streams, so the scheduler's receipt is printed on the console the user is reading. On a parent attached to a console, CREATE_NO_WINDOW detaches the child from that console: the review measured the nine receipt lines vanish from PowerShell while every child write still reported success. Windows allocates a new console for a child only when the parent has none, so that is now the only case in which the flag is returned. A child of an attached process inherits its console and opens no window, and the helper reports 0, which leaves every spawn site exactly on its previous behavior. A host that cannot answer the console query counts as attached: the query only refines the options and must never break a spawn. Both outcomes now land on cells the review measured on Windows: attached without the flag keeps the receipt, console-less with the flag opens no window. Signed-off-by: Lihua <1017343802@qq.com>
|
Addressed on Thank you for running this on real Windows — the measurement settles the question, and the P2 is confirmed: the foreground follow-up at What changed
Both outcomes now land on cells you already measured: attached without the flag is your baseline (the child shares the parent's console HWND, no new window, output printed); console-less with the flag is your What I did not verifyI have not run this fix on Windows — I have no Windows host. The reasoning above rests on your two measured cells; the fix itself is untested on a real console. If you still have the Windows 10 machine, this checks both branches from one PowerShell prompt (the second line starts a detached child, i.e. a console-less parent): import subprocess, sys, loopx.extensions.process_runtime as pr
print("attached:", pr._parent_has_console(), pr.no_console_creationflags()) # expect True 0
code = ("import loopx.extensions.process_runtime as pr; "
"print('console-less:', pr._parent_has_console(), pr.no_console_creationflags())")
print(subprocess.run([sys.executable, "-c", code], capture_output=True, text=True,
creationflags=subprocess.DETACHED_PROCESS | 0x200).stdout.strip()) # expect False 134217728and your own Tests (host-agnostic, macOS)
Correction to my earlier CI noteMy previous comment attributed the red CI to two browser flakes only. That was incomplete — I had read the first lines of the check list. On |
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
动机 / Motivation
无控制台的 Windows 宿主启动大量短命子进程时会闪现控制台窗口。附着在控制台的用户仍要在前台收到 scheduler follow-up 的 JSON 和退出码。前一提交的真机结果已确认,在附着父进程上强加 CREATE_NO_WINDOW 会静默丢失回执。此轮核对修复是否保留这条回执,以及此前失败的 Windows bridge 测试是否已修好。原问题 · 上次 Windows 10 实测 · 仓库真实入口验证规则
改动思路 / Approach
把是否添加 CREATE_NO_WINDOW 留在 Python 共同的进程适配器。附着或无法回答的父进程传零,确认无控制台才启用该标志。Node 的管道调用点使用 windowsHide,保留原 stdio 配置。既有 Windows Job 仍负责把 bridge 纳入监管,测试夹具也需要保留这个独立边界。Win32 进程创建标志 · Windows 控制台句柄
具体改动 / Changes
关键代码讲解
验收项包括 WIN-CONSOLE-LESS、WIN-ATTACHED-RECEIPT、WIN-BRIDGE-TEST。
no_console_creationflags通过GetConsoleCP和GetConsoleWindow判断是否附着,entrypoint.main等待 Node 并返回状态。macOS 在基线与当前提交都经实际入口返回相同的invalid_scheduler_host_factsJSON 和退出码 1。两种 Windows 参数分支由单测覆盖,当前提交的真实 Windows 回执和无控制台启动待复验。run_host_process在 Windows 会先把子进程加入 Job,再发送请求。以桩提供成功的 Win32 内核调用,在 macOS 执行当前测试的 Windows 分支,复现BridgeProcess缺少_handle。实际失败发生在 Python 尝试读取句柄时,尚未调用 Win32 的AssignProcessToJobObject。usage_ping._detach将早退的写入或关闭失败降为 best effort。我在 macOS 用实际子进程复验,正常读取前后均成功,提前关闭时基线抛BrokenPipeError,当前提交正常返回。这个变化也适用于 POSIX,建议同步修正 PR 正文的 Windows-only 说明。
对主干的风险 / Risks
P2 先前的 Windows bridge 测试失败仍可复现。 当前夹具替换了 Popen,但未处理 WindowsHostJob.assign 所需的真实进程句柄。应在这项 spawn-options 单测里替换 Job I/O 边界并断言 assign 调用,或使用真实子进程。保留生产 Job 监管,再在当前提交的 Windows 上运行该用例与两种父进程形态的真实 CLI,核对 JSON 和退出码。触发点见测试夹具和实际 Job 分配。
语义与 CI 对齐
127 个目标 Python 测试通过、1 个跳过,429 个 Node 测试通过,Git diff 检查通过。上述 Win32 桩只复现当前夹具的失败,真机表现仍待核对。Windows Terminal / ConPTY 与实际 Win32 232 的断管路径也未验证。项目设置使用本地检查,远端 CI 留待仓库流程。
我的整体评价 / Verdict
保留变更请求。附着控制台的参数修正与已知真机结果吻合。当前提交仍保留原来会在 Windows 失败的夹具,且新提交还需要两种启动形态的真机读回。
English verdict: REQUEST_CHANGES at b35624d. The Windows bridge test still supplies a process without the required handle. Fix the fixture and verify both console modes through the native CLI on Windows.
… fixture The spawn-options test only exercised the POSIX launch branch; on the Windows branch run_host_process assigns the spawned process to a Host Job before writing any request, and assign reads the Popen handle the stub process never carried. Add a companion test that takes the real Windows branch on any host: the Job boundary is replaced (its module cannot load off Windows), the fixture process carries the handle assign reads, and the test asserts the assignment happened for this process alongside the console-less creation flags. Signed-off-by: Lihua <1017343802@qq.com>
|
Addressed on WIN-BRIDGE-TEST — the fixture now runs the real Windows branch. Your reproduction was right: the old stub replaced Disclosure corrected in the PR body — thank you for catching that WIN-ATTACHED-RECEIPT / WIN-CONSOLE-LESS — I cannot run these. I have no Windows host, so the two real-machine readbacks remain with whoever has one; the two-line check for both parent-console branches from my previous comment still stands, and your
|
|
Correction to my CI note above — please read this one instead. My statement that the shards showed "no failing assertion" and finished "every case" was wrong; I had read only shard 1's summary line. The full picture on
Practical consequence I want to state plainly: CI has not executed the majority of Python cases for this PR on either head, so local validation is the primary Python evidence: the two console-suppression files (96 passed / 1 skipped), the 51 touched-module test files (1355 passed / 0 failed / 8 skipped), the |
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
动机 / Motivation
无控制台的 Windows 宿主需要抑制子进程闪窗,附着到终端的用户仍需看到调度回执。上一轮确认现有 bridge 测试替换了真实子进程,却未提供 Windows Job 要读取的句柄。当前提交增加了模拟 Windows 分支的正向用例。旧用例仍会随测试集运行,并保留原来的失败。前次评审 · 旧头 Windows 10 观察
改动思路 / Approach
保留已有的根据父进程控制台状态选择创建标志。新测试在 Windows Job I/O 边界使用可观察的替身,确认 Job 收到被启动的 bridge。这个覆盖可以保留,原通用测试也需要在原生 Windows 走相同的可替换边界。
具体改动 / Changes
前一头 b35624d7b332760a588f20737a5d49992aaea5be 到现头只增加一个测试。相对基线 811c1a1f66652d3fc3b9830d467e14b45b7423c1,24 文件 +841/-9。核对 WIN-BRIDGE-TEST、WIN-ATTACHED-RECEIPT 和 WIN-CONSOLE-LESS。仓库真实入口验证规则
关键代码讲解
no_console_creationflags在确认 Windows 父进程没有控制台时传标志,在已附着或查询不可用时传零。macOS 上现头的真实调度入口与基线同样输出invalid_scheduler_host_factsJSON,并退出 1,隔离测试目录无写入。- 新的
test_run_host_process_bridge_windows_branch_assigns_job_and_passes_flag给测试进程提供_handle,同时替换 Job I/O,观察一次分配以及 console-less 启动参数。此测试通过。 - 原来的
test_run_host_process_bridge_passes_no_console_creationflags继续替换Popen,并照常在 Windows 进入真实WindowsHostJob.assign。该夹具没有句柄,也无 Windows 跳过条件或 Job 替换。
对主干的风险 / Risks
P2 原 bridge 测试继续产生同一 Windows 失败。 我对现头执行原用例,仅让其选择 Windows 平台分支,并用成功的 Win32 内核桩替换系统调用。代码在 Python 读取 BridgeProcess._handle 时抛出 AttributeError,还未调用 AssignProcessToJobObject。请统一两个 fixture 的 Job 隔离,或把旧用例明确限制在 POSIX,保留新的 Windows 分支用例。真实 Windows 上一次性复验这两个用例和两种启动形态。仍在执行的旧用例 · 新用例
语义与 CI 对齐
128 个目标 Python 测试通过、1 个跳过,429 个 Node 测试及 Git 差异检查通过。POSIX 早退断管现在正常返回,PR 正文已披露该跨平台变化。上次真实 Windows 测量对应旧提交,当前提交附着与无控制台入口的真机观察仍待完成。Windows Terminal / ConPTY 和 Win32 232 的实际断管也未验证。远端 CI 留待仓库流程。
我的整体评价 / Verdict
保留变更请求。新增测试验证了预期的 Job 分配和子进程参数。原用例依旧在 Windows 分支失败,需要修正原夹具并读回当前提交的真实控制台回执。
English verdict: REQUEST_CHANGES at d0ceb55. The new Windows companion test passes, but the original bridge test still supplies no process handle to WindowsHostJob.assign.
The original spawn-options test was left without a process handle or a Job boundary, so on a real Windows host running the suite it would enter WindowsHostJob.assign and fail reading the stub's missing handle — the companion test covered that branch, but only for itself. Unify the two fixtures: a shared handle-carrying bridge process and a shared recording Job stand-in (the real module cannot load off Windows). The original test installs the stand-in alongside its POSIX assertions — dormant wherever the Windows branch is not selected — and the companion test selects the Windows branch and asserts the assignment through the same boundary. Signed-off-by: Lihua <1017343802@qq.com>
|
Addressed on The two fixtures are unified — you were right that adding the companion left the original test failing on a real Windows host. Both bridge tests now share one fixture: a handle-carrying bridge process (the
So the suite is correct on any host: on POSIX both tests exercise the launch path they can reach; on Windows both route the Job assignment through the observable boundary, and neither stub process lacks the handle. Both files: 96 passed / 1 skipped on this host. WIN-ATTACHED-RECEIPT / WIN-CONSOLE-LESS remain with a Windows host — unchanged from my previous reply: I have none, the two-line both-branches check and the PowerShell
|
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
动机 / Motivation
在 Windows 上,从没有控制台的宿主启动 LoopX Goal 的用户会遇到子进程闪窗。此前的真实 Windows 评审还观察到,无条件使用进程创建标志会让已附着终端的用户丢失调度回执。当前头的原 bridge 用例在模拟 Windows 分支上已向 Job 分配一次有效句柄,原测试夹具问题已修复。当前头的原生 Windows 双形态和实际错误 232 仍待实测,本轮覆盖 macOS 实际调度与 Windows 测试分支。 上一轮精确提交评审
改动思路 / Approach
保留共享进程创建标志以及现有 Windows Job 和 Node 子进程代码,避免每个调用点维护自己的控制台识别规则。Python 调用方复用 Win32 控制台判定,TypeScript 调用方复用 Node 的 windowsHide,观测器的 stdin 竞态留在原有尽力而为的观测边界。 Python 进程适配器判定控制台和创建标志;Windows Job 保留进程监管;TypeScript 管道调用点使用 Node 的 windowsHide;调度入口仍读取真实子进程退出码。
先前 Windows 10 上观察到附着父进程无条件加 CREATE_NO_WINDOW 时漏掉前台回执;上一头的旧 BridgeProcess 缺 _handle,在 Win32 成功桩中尚未分配就失败。 当前头只改两项 bridge 测试的共享夹具。原测试强制进入 Win32 分支,可验证同一个带 _handle 的进程被分配到 Job 一次;原生附着与无控制台两条路径等待当前头读回。
具体改动 / Changes
复核的提交是 89b2ee47948c7e2ec325092edcdeb8a034a08492,目标基线是 811c1a1f66652d3fc3b9830d467e14b45b7423c1。24 个文件,增加 845 行,删除 9 行。
WIN-BRIDGE-TEST已实现。原用例和显式 Windows 用例使用同一夹具。WIN-ATTACHED-RECEIPT待验证。真实附着终端需记录 JSON 和退出码。WIN-CONSOLE-LESS待验证。真实无控制台宿主需观察是否抑制了子进程闪窗。 本仓库真实入口规则
关键代码讲解
main。 Windows 保留 Node 子进程的前台标准流和退出码传播,POSIX 仍由 execv 替换进程。 源码no_console_creationflags。 仅在确定 Windows 父进程无控制台时选 CREATE_NO_WINDOW,附着或查询不可用保持默认。 源码run_host_process。 在写入 bridge 请求前,将新子进程关联到既有的 Windows Job。 源码install_windows_job_stand_in。 两项 bridge 测试使用共同带句柄的进程和可检查的 Job 分配边界。 源码_detach。 保持分离进程创建配置,将已经启动的观测器关闭 stdin 所致写入失败隔离在观测路径。 源码
对主干的风险 / Risks
[P2] 当前头待验证两种 Windows 控制台的实际调度回执。 旧头原用例在成功 Win32 API 桩下缺 _handle,当前头的独立原用例模拟已通过。真实无控制台不闪窗和附着终端保留 JSON、退出码的验收仍缺,模拟 Job 或 CLI 单测不能观察它们。 请在当前头用 Windows 原生 Python 和 Node 分别从附着终端及无控制台父进程执行实际 scheduler-ack-current。记录 JSON 与退出码、子进程控制台状态,以及两条 bridge 用例的结果。 用 uv run --extra test python -m pytest -q tests/test_child_console_suppression.py 重跑 bridge 用例。另外,分离观测器吞掉已启动子进程关闭 stdin 导致的写入错误,在 POSIX 也生效。启动失败仍会报错。
173 项 Python 通过、1 项跳过,Ruff 和 Git diff 检查通过。原 bridge 的独立 Win32 分支模拟已回读一次 Job 分配。 本地 macOS 和模拟 Windows 分支已有证据。当前提交缺 Windows 实机的附着终端、无控制台宿主及 Win32 ERROR_NO_DATA 验证。没有查询远端 CI。
语义与 CI 对齐
与上一头相比 22 个生产文件逐字节不变。基线和上一头的真实 macOS Node 调度入口均发出 invalid_scheduler_host_facts JSON、退出码 1,隔离目录没有状态写入。当前头完整目标套件继续验证 POSIX 参数路径。 相关默认值和失败路径已纳入本地验证矩阵。远端 CI 未查询。
我的整体评价 / Verdict
长程效果方面,Goal 启动过程能否避免一连串闪窗仍取决于原生路径读回。用户体验方面,已消除测试夹具障碍,但前台回执本身仍需要在当前头上验证。 当前头只改两项 bridge 测试的共享夹具。原测试强制进入 Win32 分支,可验证同一个带 _handle 的进程被分配到 Job 一次;原生附着与无控制台两条路径等待当前头读回。 保留共享进程创建标志以及现有 Windows Job 和 Node 子进程代码,避免每个调用点维护自己的控制台识别规则。
REQUEST_CHANGES,原夹具发现已关闭,补齐当前提交的原生观测后即可针对剩余事项复审。
English verdict: REQUEST_CHANGES at 89b2ee4. the bridge fixture is fixed and its simulated Windows branch passes. Verify both attached-terminal receipts and console-less child startup on native Windows for this head.
|
Acknowledged on On the one remaining item, I have to state a hard limit: I have no Windows host. WIN-ATTACHED-RECEIPT and WIN-CONSOLE-LESS for this head cannot be observed from this machine, and as your review notes, simulated Job or CLI unit tests cannot stand in for them. Everything that can be prepared without the hardware is prepared:
Your round-1 review measured the previous head on real Windows 10, so the hardware is on your side: I'm asking you to run these on |
BigDataDZ
left a comment
There was a problem hiding this comment.
原生 Windows 复测(head 89b2ee479)——未批准
环境:Windows 10(19045),Python 3.12.10,Node 24.20.0。对照基线:main 811c1a1f6。
上一轮的两项(前台回执丢失、bridge 测试在 Windows 上失败)都已解决,ERROR_NO_DATA 的处理也验证了。剩一个小项(第 5 节)和未跑完的 CI,所以我仍不给批准。
1. 前台回执(WIN-ATTACHED-RECEIPT):通过
调用真实的 loopx.entrypoint.main,参数为 quota scheduler-ack-current --scheduler-host-facts-chunk … --turn-instance-id …:
| 父进程 | 辅助函数 _parent_has_console() / 返回的标志 |
传给 node 的标志 | 退出码 | 回执 |
|---|---|---|---|---|
| 有控制台,stdout 就是控制台 | True / 0 |
0 |
1 | 9 行 JSON 出现在控制台上 |
| 有控制台,stdout 重定向到管道 | True / 0 |
0 |
1 | JSON 经管道完整到达 |
| 无控制台 | False / 134217728 |
134217728 |
1 | 父进程没有 stdout |
回执内容是 loopx_scheduler_host_followup_error_v0(scheduler_followup_binding_missing)。上一轮的 head 83bbed022 在第一行是终端上没有任何输出。第一行是在为探针新建的隐藏控制台里测的(stdout 即该控制台),不是 PowerShell 窗口。
2. 无控制台宿主(WIN-CONSOLE-LESS):通过
- 第 1 节第三行的运行期间,约每 10 ms 枚举一次类名为
ConsoleWindowClass的可见顶层窗口(1156 ms 内 31 次):没有出现。 - 探测器的阳性对照:一个带新控制台的辅助进程(创建时隐藏,窗口移到屏幕外之后才显示)被检出,附着父进程和无控制台父进程里各验证一次。
- 把入口那条启动语句换成能自述的替身子进程:它的
GetConsoleWindow()为 NULL,没有窗口。
一个测量上的说明:CREATE_NO_WINDOW 的子进程仍然会带起一个 conhost.exe(实测它的父进程分别是 node.exe 和 python.exe),只是没有窗口。所以"出现 conhost"不能当作闪窗的证据。
3. bridge 测试对:通过
tests/test_child_console_suppression.py + tests/extensions/test_process_runtime.py → 69 passed / 0 failed / 28 skipped。跳过的是 27 个 POSIX 进程组用例和 1 个 "host is Windows" 用例。test_run_host_process_bridge_passes_no_console_creationflags 与 test_run_host_process_bridge_windows_branch_assigns_job_and_passes_flag 均通过。上一轮是 55 passed / 1 failed / 28 skipped。
4. ERROR_NO_DATA:通过
竞态本身是间歇性的,我用注入的方式让它确定发生:让 Popen 返回前延迟 400 ms,各跑 30 次。
OSError 逃出 _detach 的次数 |
正常返回 | |
|---|---|---|
main 811c1a1f6 |
4([Errno 22] Invalid argument) |
26 |
89b2ee479 |
0 | 30 |
另对已退出子进程的 stdin 管道直接调用 WriteFile,30 次全部返回 Win32 错误 232,即 HRESULT 0x800700E8,与 #9430 报告的错误码一致。
5. 一个新的小发现:本 PR 新增了 1 个 mypy 错误
loopx/extensions/process_runtime.py:37: error: Module has no attribute "WinDLL" [attr-defined]
本机按仓库配置加 --platform linux 运行:main 是 3834 个错误,本 head 是 3835 个(与 CI 一致);忽略行号后只多这一条。原因是 typeshed 只在 sys.platform == "win32" 下声明 ctypes.WinDLL,而新函数判断的是 os.name,mypy 不会据此收窄。在取 WinDLL 之前加 sys.platform 判断,或改用 getattr,应该就能消除。落在改动文件上的其余 148 个 mypy 错误与 main 逐条相同。
CI
该 head 上 kernel-contracts 失败,Python 分片和 windows-powershell 都被跳过,没有完整的 Python 套件结果。
未验证
- 真实的闪窗我没有观察,用的是"是否出现可见控制台窗口"和"子进程是否有控制台窗口"作为判据。
- 只测了调度入口这一条路径;Goal 启动流程里其余调用点在无控制台宿主上的表现没有逐个测。
- Windows Terminal / ConPTY。
- POSIX 运行。
在第 5 项处理完、且套件在该 head 上有完整结果之前,我不给批准。
|
补充测量(head 上一条评审覆盖了调度入口与 bridge 测试。这两条补的是评审与机器人回复里都点名的剩余面:无控制台宿主上的真实 Goal 启动流程(#9430 报告的场景),以及错误 232 的来源路径。全部在本机 Windows 10 上完成,每个轮次的窗口探测器都先通过阳性对照(屏幕外显示的隐藏控制台窗口被抓到)才采数。 流程一:Goal 启动序列(继承路径) 真实 file 权威夹具上,从无控制台父进程依次运行真实 CLI:
为什么 main 在这条路径上也不闪:顶层的 流程二:detached 观察器路径(这才是 #9430 的闪窗面)
两个方向合起来的结论:本 PR 修复的正是 detached 路径;继承路径则无论是否合并都不闪。#9430 报告的"启动一个 Goal 连续闪窗"与两者都相容——顶层 测量方式说明:闪窗判据为运行期间新出现的、类名 此前评审的结论不变:前台回执、bridge 测试对、ERROR_NO_DATA 三项在 |
The console query reads ctypes.WinDLL, which typeshed declares only under sys.platform == "win32". The helper selected Windows by os.name, which mypy does not narrow on, so the new function added one attr-defined error to a type-check that was otherwise identical to main (3835 against 3834), and the kernel-contracts job went red on it, skipping the Python shards. The query now returns "attached" before the import unless sys.platform is win32, which is where typeshed's declaration applies. Reachable behavior is unchanged: the helper already returned 0 off Windows, and on Windows the function proceeds to the same query. AttributeError leaves the except clause because WinDLL exists wherever the import is now reached. The unanswerable-query test emulates both platform markers so it still reaches the failing import, and a companion test proves the Win32 query is never entered off Windows. Signed-off-by: Lihua <1017343802@qq.com>
|
Thank you both — @BigDataDZ's native re-verification on Item 5 (the one new mypy error) — fixed on Verified the way you measured it — full
On "the suite has a complete result on this head" — one thing I cannot deliver from CI, and it is not this PR's doing. So the complete result for
Of the items you listed as unverified, the ones that remain are yours or the owner's to call: Windows Terminal / ConPTY, the remaining Goal-start call sites on a console-less host, and POSIX, where the only behavior change is the |
BigDataDZ
left a comment
There was a problem hiding this comment.
原生 Windows 复核(修复头 7844d66b5)——APPROVE
上一轮的第 5 项(ctypes.WinDLL 的 mypy 错误)已按第一种建议修复,本机用同一方法复核,并确认修复头的 Windows 行为与已验证的 89b2ee479 完全一致。
mypy 平价(本机复跑,非沿用作者数据)
python -m mypy --platform linux --no-incremental,行号归一后双向对比:main 811c1a1f6 = 3834 条,本 head = 3834 条,双向差异均为空。之前多出的 WinDLL 一条已消失。
Windows 行为平价(真实探测)
- 附着上下文:
_parent_has_console()→True,标志0;bridge 测试对 + process_runtime → 70 passed / 28 skipped / 0 failed(比上轮多 1 个通过 = 新增的非 Windows 早退伴随测试)。 - 真正的无控制台上下的(DETACHED 阶段进程,
GetConsoleWindow()为 NULL):helper →False / 134217728;真实loopx.entrypoint.main传给 node 的正是该标志,运行期间无可见控制台窗口。 - 一个测量教训,记录备查:我第一次复核时误用了会走
CREATE_NEW_CONSOLE的探针模式,阶段进程自带隐藏控制台,helper 如实报了True——那是正确行为,是我的探针用错了模式;换真正 detached 的模式后数值正确。
关于"该 head 上无完整套件结果"
我此前一直以此为由不给批准。经与作者核实并本机查证:main 自身的 kernel-contracts 就是红的(Python Tests run 46210676811 on 811c1a1f6,3834 个仓库级 mypy 错误),而工作流把 test-shard 与 windows-powershell 门控在它后面——当前 main 上的任何 PR 都不可能拿到完整的 Python 套件结果。这是仓库级状态,不是本 PR 的属性;在此条件下该条件无法满足,继续扣批准不增加任何安全性。本 PR 在本机可验证的一切(四项验收读数、Goal 流程、观察器路径、mypy 平价、修复头行为一致性)均已通过。
APPROVE。
Fixes #9430
Problem
On Windows,
loopxflashes black console windows while running, and the detached usage observer intermittently fails witherror 2147942632 (0x800700E8)(Win32 232,ERROR_NO_DATA, "The pipe is being closed") when launchingpython.exe -P -m loopx.usage_goal.Windows allocates a visible conhost window for every console-subsystem child (
node.exe,python.exe,git.exe) whose parent has no console. A single goal start from a console-less host (bootstrap, agent registration, requirement/todo writes, quota guards) runs dozens of such children. The0x800700E8failure is the detached-observer pipe race: a child that exits before reading (for example a suppressed observer) closes its stdin pipe first, and the parent's write then fails with ERROR_NO_DATA.Affected sites enumerated on current main
Reporter's v2.4.1 list, verified against this main:
loopx/control_plane/runtime/node_probe.pyprobe_nodeCREATE_NO_WINDOWvia shared helperloopx/control_plane/effect_runtime.py_start_runtimePopenCREATE_NO_WINDOWvia shared helperloopx/usage_ping.pycontrol()CREATE_NO_WINDOWvia shared helperloopx/usage_ping.py_detach()loopx.usage_goalDETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP, no console); the stdin write/close is now tolerant of the child-closed pipe (the 0x800700E8 race)Cross-check additions in the same goal-start/turn/quota flow on current main:
loopx/registry.pyrun_git(todo/status readback probes)CREATE_NEW_PROCESS_GROUP | CREATE_NO_WINDOW(group flag kept for tree termination)loopx/control_plane/agents/workspace_guard.py(2 git probes, agent registration)CREATE_NO_WINDOWloopx/control_plane/todos/completion_validation.py_git_workspace_is_cleanCREATE_NO_WINDOWloopx/control_plane/goals/planning_batch.pyCliPlanningBatchBackend._callCREATE_NO_WINDOWloopx/control_plane/status/goal_source.py_runCREATE_NO_WINDOWloopx/control_plane/runtime/validation_command.py_direct_validationCREATE_NO_WINDOW(the supervised POSIX flock path is POSIX-only by design and untouched)loopx/control_plane/quota/scheduler_ack.py_run_native_followupCREATE_NO_WINDOWloopx/entrypoint.pyWindows native follow-up re-execCREATE_NO_WINDOW(Windows-only branch)loopx/control_plane/heartbeat/installed_prompt_update.pyprompt syncCREATE_NO_WINDOWloopx/control_plane/turn_driver/host_process_transport.pybridge PopenCREATE_NO_WINDOWloopx/control_plane/turn_driver/codex_stdio.pyStdioNativeGoalTransport.spawnCREATE_NO_WINDOWloopx/control_plane/turn_driver/command_validation.pyturn validatorCREATE_NO_WINDOWloopx/control_plane/turn_driver/codex_execution_preparation.py_default_runnerCREATE_NO_WINDOWloopx/control_plane/state_recovery_io.py_audit_ownersCREATE_NO_WINDOWTypeScript hosts that spawn console children and were missing the existing
windowsHideprecedent (host_process.ts,zcode_goal_mode/*,effect_runtime_snapshot.tsalready had it):loopx/pi_goal_mode/loopx-goal.ts(2execFilesites)windowsHide: trueloopx/control_plane/coordination/shadow_drain_files.tswindowsHide: trueloopx/control_plane/capabilities/explore_research_terminal.tswindowsHide: trueloopx/control_plane/coordination/nokv_jsonl_transport.tsdefault factorywindowsHide: trueImplementation
no_console_creationflags()inloopx/extensions/process_runtime.py: returnssubprocess.CREATE_NO_WINDOWonly on Windows and only when the parent has no console, which is the one case in which Windows allocates a new console for a child. It returns0(subprocess's default) for an attached parent, on every other platform, and when the console query cannot be answered. A child of an attached parent inherits its console and opens no window, so every site keeps exactly its previous behavior there; passing the flag to an attached parent would instead detach the child from the console its output is read on. Non-Windows behavior is byte-for-byte unchanged.GetConsoleCP()orGetConsoleWindow()succeeds (a console-less process fails both). Any success counting as attached is the safe direction — the only cost of a wrong "attached" is an unsuppressed window, never a lost receipt._PROCESS_RUNTIME_EXPORTSlazy reexport invalidation_command.py) so the repo's cold-import contracts (tests/test_process_runtime_loading.py:loopx.contract,loopx.doctor_git,validation_command,host_bridge_transportmust not load the process transport at import) keep holding._detach()keepsDETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP(the observer is deliberately console-free) with fully redirected stdio (PIPE/DEVNULL/DEVNULL); the fix makes the parent's write-and-close non-fatal when the child wins the race, matching the documented best-effort telemetry contract. This one change is not Windows-only: on POSIX the same early child exit previously surfaced asBrokenPipeErrorfrom the write-and-close; it now returns normally (verified with real child processes on macOS: normal reads pass before and after; an early-closing child raised on the previous behavior and returns cleanly now).DETACHED_PROCESSandCREATE_NO_WINDOWare mutually exclusive creation flags; no site combines them.Windows-only default-behavior disclosure
The console-suppression change is Windows-only, and on Windows it is confined to a console-less parent (apart from the
_detach()write-and-close behavior above, which applies everywhere): children spawned by the listed sites no longer allocate a console host window there, and the detached observer's early-exit race no longer surfaces as an error. A parent attached to a console (a user runningloopxin PowerShell or cmd) and all other platforms passcreationflags=0/ omit the option, which is identical to the previous behavior.Windows verification status: the reviewer ran the previous head on a real Windows 10 host and measured that the suppression works (the child gets no console) and that the flag, applied unconditionally, silently removed the foreground receipt of the one site that does not redirect its streams (
loopx/entrypoint.py:155). That finding is what the attached-parent rule above fixes. The fix itself has not been run on Windows — I have no Windows host. It rests on the reviewer's two measured cells (attached without the flag keeps the receipt; console-less with the flag opens no window); a two-line check for both branches is in the review reply. The visible window and pipe behavior is otherwise owned by CI's Windows lanes; the host-agnostic tests below prove the flags are computed and passed on the spawn-option objects.Out of scope (follow-up candidates using the same helper)
Dev/CI tooling (
loopx/canary/**,loopx/control_plane/testing/**,benchmark_toolkit,experiments), capability adapters wrapping interactive external CLIs, MCP/collaboration daemon spawns (operation_wake,collaboration_mcp,remote_authority_gateway,delegation_preview_transport), SSH lifecycle transports, self-update/installer flows (already detached where relevant), andstdio_transport.py(POSIX-only by design).Test evidence (all on macOS)
tests/test_child_console_suppression.py(30 tests): each site's spawn options (creationflags equals the helper value on POSIX; equalsCREATE_NO_WINDOWunder an emulated Windowsos.nameon a console-less parent, via a module-scoped proxy that also answers the console query), the registry's composedCREATE_NEW_PROCESS_GROUP | CREATE_NO_WINDOW, the detached observer's Windows flags, and the pipe-closed write race staying non-fatal. Added for the attached-parent rule: the helper across three hosts (POSIX → 0, Windows console-less →CREATE_NO_WINDOW, Windows attached → 0); the_console_attachedtruth table (both queries failing → not attached, either succeeding → attached); the reported site with an attached parent passingcreationflags == 0and redirecting nothing, and with a console-less parent passing the flag; a redirected receipt on a console-less host still arriving throughcapture_output=True.tests/extensions/test_process_runtime.py: helper computation (0 off Windows,0x08000000emulated on a console-less parent, 0 without the constant, 0 on an attached parent, 0 and no exception when the console query is unanswerable).npm run typecheck:control-planeclean; node test suites for the touched TS modules (nokv transport, shadow drain, explore research execution): 421 passed.loopx/pi_goal_mode/loopx-goal.tsis outside the repo's tsconfig (host-provided dependencies); a direct tsc comparison shows the identical pre-existing error set before/after, i.e. no new type errors.ruff checkon all touched files: clean.811c1a1f6(74a33c350; all six files touched by both sides merged cleanly): the two test files above 95 passed / 1 skipped; the 51 test files of every touched module 1355 passed / 0 failed / 8 skipped (twotest_effect_runtime_equivalence.pycases first failed only because this worktree's localorigin/mainref was eight days stale — they loadorigin/main:…effect_runtime.pyas their baseline and pass 10/10 once the ref is refreshed;_uses_stdio_runtimecomes from main's feat(control-plane): allow the CLI Effect runtime to use stdio in restricted hosts #9140, not from this PR).uv run --extra test loopx canary premerge --from-git-diff --git-diff-base 811c1a1f6: 18 checks passed, 0 failures.tests/control_plane/test_native_user_completion_update.py(12 parametrizations, HTTP 404s) fail identically on pristinemainat the merge base (verified in a throwaway worktree).