Skip to content

Suppress Windows console windows for console-subsystem children (#9430) - #9435

Open
LIHUA919 wants to merge 3 commits into
loopx-project:mainfrom
LIHUA919:codex/win-console-no-window-9430
Open

LIHUA919 wants to merge 3 commits into
loopx-project:mainfrom
LIHUA919:codex/win-console-no-window-9430

Conversation

@LIHUA919

@LIHUA919 LIHUA919 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #9430

Problem

On Windows, loopx flashes black console windows while running, and the detached usage observer intermittently fails with error 2147942632 (0x800700E8) (Win32 232, ERROR_NO_DATA, "The pipe is being closed") when launching python.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. The 0x800700E8 failure 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:

Site Child Change
loopx/control_plane/runtime/node_probe.py probe_node node CREATE_NO_WINDOW via shared helper
loopx/control_plane/effect_runtime.py _start_runtime Popen node (long-lived runtime host) CREATE_NO_WINDOW via shared helper
loopx/usage_ping.py control() node CREATE_NO_WINDOW via shared helper
loopx/usage_ping.py _detach() node / loopx.usage_goal Flags already correct (DETACHED_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:

Site Child Change
loopx/registry.py run_git (todo/status readback probes) git 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) git CREATE_NO_WINDOW
loopx/control_plane/todos/completion_validation.py _git_workspace_is_clean git CREATE_NO_WINDOW
loopx/control_plane/goals/planning_batch.py CliPlanningBatchBackend._call loopx CLI CREATE_NO_WINDOW
loopx/control_plane/status/goal_source.py _run declared source command / ssh CREATE_NO_WINDOW
loopx/control_plane/runtime/validation_command.py _direct_validation caller-declared validator CREATE_NO_WINDOW (the supervised POSIX flock path is POSIX-only by design and untouched)
loopx/control_plane/quota/scheduler_ack.py _run_native_followup node (heartbeat follow-up) CREATE_NO_WINDOW
loopx/entrypoint.py Windows native follow-up re-exec node CREATE_NO_WINDOW (Windows-only branch)
loopx/control_plane/heartbeat/installed_prompt_update.py prompt sync loopx CLI CREATE_NO_WINDOW
loopx/control_plane/turn_driver/host_process_transport.py bridge Popen node CREATE_NO_WINDOW
loopx/control_plane/turn_driver/codex_stdio.py StdioNativeGoalTransport.spawn host process CREATE_NO_WINDOW
loopx/control_plane/turn_driver/command_validation.py turn validator validator command CREATE_NO_WINDOW
loopx/control_plane/turn_driver/codex_execution_preparation.py _default_runner launcher CREATE_NO_WINDOW
loopx/control_plane/state_recovery_io.py _audit_owners node recovery worker CREATE_NO_WINDOW

TypeScript hosts that spawn console children and were missing the existing windowsHide precedent (host_process.ts, zcode_goal_mode/*, effect_runtime_snapshot.ts already had it):

Site Child Change
loopx/pi_goal_mode/loopx-goal.ts (2 execFile sites) loopx CLI windowsHide: true
loopx/control_plane/coordination/shadow_drain_files.ts python shadow-lock host windowsHide: true
loopx/control_plane/capabilities/explore_research_terminal.ts python snapshot host windowsHide: true
loopx/control_plane/coordination/nokv_jsonl_transport.ts default factory NoKV helper windowsHide: true

Implementation

  • One shared helper no_console_creationflags() in loopx/extensions/process_runtime.py: returns subprocess.CREATE_NO_WINDOW only 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 returns 0 (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.
  • Console query: the parent counts as attached when either GetConsoleCP() or GetConsoleWindow() 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.
  • The helper is imported lazily at each call site (in-function or via the existing _PROCESS_RUNTIME_EXPORTS lazy reexport in validation_command.py) so the repo's cold-import contracts (tests/test_process_runtime_loading.py: loopx.contract, loopx.doctor_git, validation_command, host_bridge_transport must not load the process transport at import) keep holding.
  • _detach() keeps DETACHED_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.
  • DETACHED_PROCESS and CREATE_NO_WINDOW are mutually exclusive creation flags; no site combines them.

Windows-only default-behavior disclosure

The behavioral change is Windows-only, and on Windows it is confined to a console-less parent: 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 running loopx in PowerShell or cmd) and all other platforms pass creationflags=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), and stdio_transport.py (POSIX-only by design).

Test evidence (all on macOS)

  • New tests/test_child_console_suppression.py (30 tests): each site's spawn options (creationflags equals the helper value on POSIX; equals CREATE_NO_WINDOW under an emulated Windows os.name on a console-less parent, via a module-scoped proxy that also answers the console query), the registry's composed CREATE_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_attached truth table (both queries failing → not attached, either succeeding → attached); the reported site with an attached parent passing creationflags == 0 and redirecting nothing, and with a console-less parent passing the flag; a redirected receipt on a console-less host still arriving through capture_output=True.
  • tests/extensions/test_process_runtime.py: helper computation (0 off Windows, 0x08000000 emulated on a console-less parent, 0 without the constant, 0 on an attached parent, 0 and no exception when the console query is unanswerable).
  • Touched-module suites: 1143 passed / 0 failed across usage_ping/usage_goal, registry, effect_runtime node probe, scheduler_ack, completion validation (4 files + MCP), planning batch, goal source, execution preparation, workspace guard, state recovery, leased host process, host launch authority, process runtime (4 files), entrypoint and core distribution contract tests.
  • TypeScript: npm run typecheck:control-plane clean; node test suites for the touched TS modules (nokv transport, shadow drain, explore research execution): 421 passed. loopx/pi_goal_mode/loopx-goal.ts is 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 check on all touched files: clean.
  • After merging current main 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 (two test_effect_runtime_equivalence.py cases first failed only because this worktree's local origin/main ref was eight days stale — they load origin/main:…effect_runtime.py as their baseline and pass 10/10 once the ref is refreshed; _uses_stdio_runtime comes 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.
  • Pre-existing failures unrelated to this change: tests/control_plane/test_native_user_completion_update.py (12 parametrizations, HTTP 404s) fail identically on pristine main at the merge base (verified in a throwaway worktree).

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 loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Comment thread loopx/entrypoint.py
return subprocess.call(native_argv)

from .extensions.process_runtime import no_console_creationflags
return subprocess.call(native_argv, creationflags=no_console_creationflags())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] 用户在附有控制台的 Windows PowerShell 或 cmd 中直接执行生成的 scheduler-ack-current 或 scheduler-fail-current。这个启动点无条件应用 CREATE_NO_WINDOW,也没有转发 stdout。Win32 由此去掉子进程继承的控制台,调度器写入 stdout 的回执可能从终端消失,父进程仍只接收退出码。保留前台调度分支的控制台继承,仅在无控制台宿主使用抑制参数,或显式转发可读的 stdout/stderr。补一项 Windows 前台回执和无控制台重定向回执对照。 Win32 进程创建语义

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@LIHUA919

Copy link
Copy Markdown
Contributor Author

@/tmp/ci-attribution.md

@BigDataDZ BigDataDZ left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

独立复核(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_v0 JSON,退出码 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 上有完整结果之前,我不给批准。

@mergify

mergify Bot commented Nov 27, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @LIHUA919.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

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 HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 27, 2026
@loopx-agent

Copy link
Copy Markdown
Collaborator

@LIHUA919 Thanks for taking this on, and thanks @BigDataDZ for the native Windows readback. I checked the current GitHub refs: a local git merge-tree --write-tree of main at 63c7c487 and the PR head at 83bbed02 completed cleanly, with the Pi change carried into the relocated loopx/hosts/pi/loopx-goal.ts. GitHub still reports a conflict. Merging the current upstream main into your PR branch looks like a viable way to refresh it while preserving your commits. Please confirm GitHub's status on the updated head.

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 _handle. These are the concrete follow-ups to the Windows 10 results. If the updated head leaves the detached-observer pipe case or Windows Terminal/ConPTY untested, please call that out in the PR.

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>
@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 28, 2026
@LIHUA919

Copy link
Copy Markdown
Contributor Author

Addressed on b35624d7b (one DCO-signed commit on top of 74a33c350, a signed merge of current main 811c1a1f6; the six files touched by both sides merged cleanly, so the stale CONFLICTING label is gone).

Thank you for running this on real Windows — the measurement settles the question, and the P2 is confirmed: the foreground follow-up at entrypoint.py:155 lost its receipt on an attached parent.

What changed

no_console_creationflags() now returns CREATE_NO_WINDOW only when the parent has no console. Your measurement gives the rule: Windows allocates a new console for a child only in that case. A child of an attached process inherits its console and opens no window, and there the helper returns 0 — so the child keeps the console its receipt is read on. This is done in the helper rather than at the single site: on an attached parent every Python site is now exactly on its previous behavior, and the PR's behavior change is confined to the console-less host the issue reports. A future site that forgets to redirect its streams is safe the same way.

  • Console query: attached when either GetConsoleCP() or GetConsoleWindow() 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.
  • Unanswerable query: if the query itself cannot run (ctypes unavailable), the host counts as attached and the helper returns 0. The query only refines the options and must never break a spawn. The existing helper tests caught this: under an emulated Windows name with no console query provided, the first version raised instead of returning.
  • TypeScript sites: all five talk to their child through pipes (stdio: "pipe" / execFile capture), consistent with your finding that entrypoint.py:155 is the only site that does not redirect.

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 CREATE_NO_WINDOW row (no console).

What I did not verify

I 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 134217728

and your own loopx.entrypoint.main call for scheduler-ack-current in PowerShell should print the nine loopx_scheduler_host_followup_error_v0 lines again.

Tests (host-agnostic, macOS)

  • Helper, three hosts parameterized: POSIX → 0; Windows console-less → CREATE_NO_WINDOW; Windows attached → 0.
  • _console_attached truth table: both queries failing → not attached; either succeeding → attached.
  • The reported site: attached parent → the entrypoint.py:155 call passes creationflags == 0 and redirects nothing; console-less parent → CREATE_NO_WINDOW.
  • Redirected receipt on a console-less host: usage_ping.control() passes the flag and capture_output=True, so the pipe still carries the reply.
  • Unanswerable console query (ctypes unavailable) → 0, no exception.
  • tests/test_child_console_suppression.py + tests/extensions/test_process_runtime.py: 95 passed / 1 skipped (96 collected).
  • Touched-module suites after the main merge (51 files): 1355 passed / 0 failed / 8 skipped. Two test_effect_runtime_equivalence.py cases first failed only because this worktree's local origin/main ref was eight days stale — they load origin/main:…effect_runtime.py as their baseline — and pass 10/10 once the ref is refreshed.
  • loopx canary premerge --from-git-diff --git-diff-base 811c1a1f6: 18 checks passed, 0 failures.

Correction to my earlier CI note

My 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 83bbed022 the six Python test-shard jobs were red too. Their logs show no failing assertion: shard 1 ended 3758 passed, 189 skipped … in 3253.12s against a session_deadline of 3251.7s, i.e. a budget overrun of about a second with every case finished. It is not caused by this change: on Linux the helper returns 0 before any console query, and main's own last three Python Tests runs are red the same way and worse (shard 1 on main run 46099466649: 4 failed, 4449 passed, interrupted at the deadline with 4632 of 7308 cases finished). I still cannot rerun jobs (fork PR, admin needed).

This branch has not been deployed

No deployments
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.

Windows: black console windows flash during goal start (console children launched without CREATE_NO_WINDOW)

3 participants