Skip to content

fix(runtime): disable Wasm tier-up for Node TS runners on Linux x86_64 - #9212

Open
loopx-agent wants to merge 2 commits into
mainfrom
codex/fix-linux-x86-wasm-stdio-20261121
Open

loopx-agent wants to merge 2 commits into
mainfrom
codex/fix-linux-x86-wasm-stdio-20261121

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Summary

  • Add node_typescript_flags() in loopx/control_plane/runtime/node_probe.py returning ("--liftoff-only", "--no-wasm-tier-up", "--no-wasm-dynamic-tiering") on Linux x86_64/amd64 (empty tuple on other platforms/architectures).
  • Wire *node_typescript_flags() into Node --experimental-strip-types invocation sites across loopx/control_plane/ (TCP + stdio effect runtime, host process transport, delegation preview, remote authority probe, scheduler ack, state recovery), loopx/entrypoint.py, loopx/extensions/turn_host.py, and loopx/usage_ping.py.
  • Root cause: On Linux x86_64 Node v24.21.0 running Amaro's Wasm-based --experimental-strip-types compiler, V8 Wasm dynamic tiering crashes inside ThreadIsolation::StartOfJitAllocationAt (Runtime_WasmTriggerTierUp -> StackFrameIterator::Advance -> GcSafeFindCodeForInnerPointer). Disabling Wasm tier-up + dynamic tiering (--liftoff-only --no-wasm-tier-up --no-wasm-dynamic-tiering) eliminates the crash without modifying the pinned node binary.
  • Add unit coverage in tests/control_plane/test_effect_runtime_node_probe.py and align CLI argv expectations in tests/control_plane/test_source_cli_entrypoint.py.

Verification

  • Mac (origin/main worktree):
    • pytest -q tests/control_plane/test_effect_runtime_node_probe.py tests/control_plane/test_effect_runtime_compile_cache.py tests/control_plane/test_effect_runtime_listener_startup.py tests/control_plane/test_source_cli_entrypoint.py: 88 passed
    • pytest -q benchmark/tests/test_proxy_order.py benchmark/tests/test_shared_codex_runtime.py benchmark/tests/test_task_entry.py: 184 passed, 126 skipped
    • pytest -q tests/capabilities/test_provider_gateway_proxy.py tests/control_plane/test_benchmark_planning_batch.py: 9 passed (test_original_task_entry.py failed pre-existing 10/10 identically on unmodified origin/main d28ec76f42)
    • ruff check on all 12 changed files: All checks passed!
    • mypy --follow-imports=silent on 9 typed files: Success: no issues found in 9 source files (excluding delegation_preview_transport.py, which has 13 preexisting untyped lines outside the diff)
    • loopx check --scan-path ... on all 12 changed files: ok=true, errors=0, public_boundary_scan.ok=true
    • loopx canary premerge --from-git-diff --git-diff-base origin/main: gate.status=passed (direct_checks 4/4, python_compile 1/1, catalog_canaries 10/10, risk_profile_smokes 8/8)
  • Debian 13 x86_64 VM (node v24.21.0, untouched binary):
    • Standalone loopx todo plan over stdio: 10/10 passed (vs 2/3 bare, 5/8 --wasm-jitless)
    • test_benchmark_planning_batch.py (file/sqlite x fresh/lost-response): 4 passed

Add node_typescript_flags() in loopx.control_plane.runtime.node_probe and wire it into all Node --experimental-strip-types launch paths. On Linux x86_64/amd64, disabling TurboFan Wasm tier-up and dynamic tiering (--liftoff-only --no-wasm-tier-up --no-wasm-dynamic-tiering) prevents fatal V8 ThreadIsolation JIT range crashes during Amaro TypeScript stripping under Node 24.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

Reviewer: model_agent · Gemini · Google DeepMind · self_reported

English verdict: REQUEST_CHANGES

动机 / Motivation

针对 9212@4783afaf6be3ffb52f7e07e5101efd279b3fa083(exact head 4783afaf6be3ffb52f7e07e5101efd279b3fa083):运行在 Linux x86_64/amd64(特别是 QEMU/TCG 或开启 Linux PKU)上的操作者与自动化 Goal/Turn 调度器在执行 loopx CLI、Effect runtime、调度器随访或 ZCode Goal 宿主机时会触发该问题。修改前所有 Node 24 直接执行 TypeScript 的子进程都会开启 TurboFan Wasm 分层编译从而在 V8 ThreadIsolation 阶段崩溃并中断任务;修改后 10 个已接入的 Python 启动点在 Linux x86_64 上自动附加 --liftoff-only --no-wasm-tier-up --no-wasm-dynamic-tiering(非 Linux 平台保持空元组),但通过安装态 POSIX CLI 入口(scripts/loopx:74)触发的原生调度器随访仍漏传这些标志。

本 PR 在效果上集中封装了 node_typescript_flags() 并保护了 9 个 Python 模块中的 10 处启动点且保持 macOS/Windows/arm64 零变化,但未覆盖绕过 Python 的主 POSIX 启动器 scripts/loopx:74 以及 zcode_goal_mode、semantics/production.py 与 control_plane/testing/ 入口。本 PR 不修改 Node 版本探测、Windows PowerShell 启动器 scripts/loopx.ps1、Worker.execArgv(已实测 Node 会拒绝在 Worker execArgv 中传递进程级 Wasm 标志)或纯文档示例。

改动思路 / Approach

本 PR 在 loopx/control_plane/runtime/node_probe.py 引入 node_typescript_flags(*, system=None, machine=None),仅在 linux + x86_64|amd64 条件下返回 --liftoff-only --no-wasm-tier-up --no-wasm-dynamic-tiering,其余平台返回 (),从而在不污染全局 NODE_OPTIONS 的前提下为子进程定向注入 V8 稳态参数。

node_probe.node_typescript_flags() 作为单一平台判定边界归属合理,非 Linux 平台返回空元组零开销,且 effect_runtime_compile_cache.ts 的 Worker 会安全继承主进程 V8 初始化配置而不能在 Worker execArgv 中传入进程级 Wasm 标志。我们在本地 Node v24.21.0 中实测证实,给 new Worker(..., { execArgv }) 显式传入这 3 个标志会同步抛出 Initiated Worker with invalid execArgv flags,因此保留 effect_runtime_compile_cache.ts:86 不改是正确的。

关于当前边界:已建立清晰的核心判定函数与 10 处 Python 启动点,但作为全路径修复仍遗漏 POSIX 启动器 scripts/loopx:74、zcode_goal_mode、semantics/production.py 与 control_plane/testing/ 入口,需补齐上述调用链与跨平台验证后再合入。

具体改动 / Changes

本次共涉及 12 个文件(+138/-7),我们在独立只读 worktree 对提交头 4783afaf6be3ffb52f7e07e5101efd279b3fa083 完成全量审查:

  1. 已接入路径(10 个生产启动点 + 2 个测试文件):
    • node_probe.py 新增 node_typescript_flags();
    • 将 *node_typescript_flags() 接入 effect_runtime.py(TCP daemon 与 stdio runtime)、entrypoint.py(_native_scheduler_followup_argv)、quota/scheduler_ack.py、state_recovery_io.py、host_process_transport.py、delegation_preview_transport.py、remote_authority_gateway.py、extensions/turn_host.py 与 usage_ping.py。
  2. Blocking Finding 1(P1)— 主 POSIX CLI 启动器 scripts/loopx:74 绕过 Python 入口且漏传参数:
    • scripts/install-local.sh 安装后的 POSIX loopx CLI 直接软链至 scripts/loopx。其第 74 行在 Python 启动前拦截带收据绑定的 quota scheduler-ack-current 与 scheduler-fail-current 并直接 exec node --no-warnings --experimental-strip-types heartbeat_followup_cli.ts。使用模拟 uname -s=Linux / uname -m=x86_64 实跑复现,返回 argv_head=['--no-warnings', '--experimental-strip-types', '.../heartbeat_followup_cli.ts'],全部 3 个 V8 标志缺失;test_scheduler_native_launcher.py 也仍断言旧的 3 参数前缀。
    • 最小修复:在 scripts/loopx 第 74 行前判断 Linux + x86_64|amd64 并注入该 3 个标志,并更新 test_scheduler_native_launcher.py。
  3. Blocking Finding 2(P1)— 多处活动运行时、语义门禁与 E2E 启动点漏接:
    • loopx/zcode_goal_mode/bridge.py:277 与 cli.ts:155, 274(TS spawn(process.execPath, ...) 新建子进程不会继承这些 V8 标志)、loopx/semantics/production.py:295, 340(settlement_binding_witness.mts、quota_run_decision_witness.mts)以及 loopx/control_plane/testing/{canary_harness.py:305, authority_e2e_ladder.py:210,349,459, authority_e2e_fixtures.py:543} 均未加标志;同时建议顺手抽出共享 node_typescript_argv 辅助函数替代 10 处手写拼装。

对主干的风险 / Risks

在 macOS arm64 环境对 exact head 4783afaf6be3ffb52f7e07e5101efd279b3fa083 完成独立验证(wait_for_ci: false,未查/等待远端 CI):

  • tests/control_plane/test_effect_runtime_node_probe.py、test_source_cli_entrypoint.py 与 test_scheduler_native_launcher.py(-k "not launch_and_binds_or_slow"):89 passed, 13 skipped(13 个 skip 均为 macOS 无 PowerShell 所致);
  • 专项筛查(node_typescript or scheduler or strip_types or probe):56 passed, 13 skipped;test_usage_ping.py + test_cli_entrypoint.py:80 passed;test_control_plane_import_boundaries.py + probe:37 passed;
  • ruff check 与仓库配置 uv run --extra test python -m mypy 通过(Success: no issues found in 17 source files);loopx check --scan-path 全数 12 个改动文件 errors=0;Node v24.21.0 实测同时携带 --experimental-sqlite --use-env-proxy --experimental-strip-types --liftoff-only --no-wasm-tier-up --no-wasm-dynamic-tiering 启动输出 node-flags-ok。
  • 主干剩余风险:若在未补齐 scripts/loopx:74、ZCode、语义见证与 E2E 启动点前合入,Linux x86_64 已安装 CLI 的原生调度随访、zcode-goal 与 premerge 语义检查仍暴露在 V8 ThreadIsolation 崩溃风险下,且除 effect_runtime.py 外其余 8 个已改 Python 文件仍缺乏 linux/x86_64 模拟单测覆盖。

我的整体评价 / Verdict

node_typescript_flags() 机制本身边界清晰、非 Linux 平台零回归且 Worker.execArgv 语义处理得当;但因其核心前提“覆盖全部 --experimental-strip-types 启动路径”在安装态 POSIX 启动器 scripts/loopx:74 与 zcode_goal_mode / semantics/production.py / testing/ 上尚有明显断点并已在本地复现缺失,本次给出 REQUEST_CHANGES。

  • Visual Review:CLI/runtime Node process argv flag injection only; no rendered UI surface changed. Unverified Scope:Real Linux x86_64 QEMU/TCG crash reproduction is outside this macOS arm64 verification host; verified flag assembly, Node v24.21.0 CLI acceptance, Worker execArgv constraints, and scripts/loopx Linux x86_64 omission locally.
  • 后续建议:补齐 scripts/loopx:74、ZCode/semantics/testing 启动点并补充模拟 linux/x86_64 回归测试后,即可重新提交复核。

…de, semantics, and testing callers

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

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.

1 participant