From 4783afaf6be3ffb52f7e07e5101efd279b3fa083 Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Sun, 22 Nov 2026 00:27:49 +0800 Subject: [PATCH 1/2] fix(runtime): disable Wasm tier-up for Node TS runners on Linux x86_64 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> --- .../delegation_preview_transport.py | 9 ++- .../coordination/remote_authority_gateway.py | 3 +- loopx/control_plane/effect_runtime.py | 3 + loopx/control_plane/quota/scheduler_ack.py | 2 + loopx/control_plane/runtime/node_probe.py | 25 +++++++ loopx/control_plane/state_recovery_io.py | 2 + .../turn_driver/host_process_transport.py | 2 + loopx/entrypoint.py | 2 + loopx/extensions/turn_host.py | 10 ++- loopx/usage_ping.py | 10 ++- .../test_effect_runtime_node_probe.py | 68 +++++++++++++++++++ .../test_source_cli_entrypoint.py | 9 ++- 12 files changed, 138 insertions(+), 7 deletions(-) diff --git a/loopx/control_plane/collaboration/delegation_preview_transport.py b/loopx/control_plane/collaboration/delegation_preview_transport.py index bd082759ae..b7f9163a20 100644 --- a/loopx/control_plane/collaboration/delegation_preview_transport.py +++ b/loopx/control_plane/collaboration/delegation_preview_transport.py @@ -19,6 +19,7 @@ from typing import Any from ..effect_runtime import _node_executable +from ..runtime.node_probe import node_typescript_flags BRIDGE_CLOSE_TIMEOUT_SECONDS = 5.0 @@ -164,7 +165,13 @@ def preview(self, *, command: list[str], workspace: Path, release: Path, ) bridge = Path(__file__).with_name("delegation_preview_bridge.ts") self._process = subprocess.Popen( - [_node_executable(), "--no-warnings", "--experimental-strip-types", str(bridge)], + [ + _node_executable(), + "--no-warnings", + "--experimental-strip-types", + *node_typescript_flags(), + str(bridge), + ], env=environment, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True, encoding="utf-8", start_new_session=True, diff --git a/loopx/control_plane/coordination/remote_authority_gateway.py b/loopx/control_plane/coordination/remote_authority_gateway.py index a2c16ce0c0..de4fb29862 100644 --- a/loopx/control_plane/coordination/remote_authority_gateway.py +++ b/loopx/control_plane/coordination/remote_authority_gateway.py @@ -52,13 +52,14 @@ def check_remote_authority_gateway_status( if not credential: return {**projection, "status": "unavailable", "reason_code": "remote_authority_credential_required"} from ..effect_runtime import EffectRuntimeStartupError, _node_executable + from ..runtime.node_probe import node_typescript_flags try: # The user-owned registry supplies the origin and optional private CA. # Pass the credential and binding through the private pipe, not argv. bridge = Path(__file__).with_name("remote_authority_probe.ts") completed = subprocess.run( - [_node_executable(), "--no-warnings", "--experimental-strip-types", str(bridge)], + [_node_executable(), "--no-warnings", "--experimental-strip-types", *node_typescript_flags(), str(bridge)], input=json.dumps({ **{key: cfg[key] for key in _REQUIRED_BINDING}, "goal_id": goal_id, "credential": credential, "ca_file": cfg.get("ca_file"), diff --git a/loopx/control_plane/effect_runtime.py b/loopx/control_plane/effect_runtime.py index 1171723ee3..a323655161 100644 --- a/loopx/control_plane/effect_runtime.py +++ b/loopx/control_plane/effect_runtime.py @@ -32,6 +32,7 @@ MINIMUM_NODE_VERSION_TEXT as MINIMUM_NODE_VERSION_TEXT, STARTUP_READY_TIMEOUT_SECONDS as STARTUP_READY_TIMEOUT_SECONDS, node_probe_remediation, + node_typescript_flags as _node_typescript_flags, probe_node as _probe_node, ) from .content_digest import BARE_SHA256_PATTERN @@ -1324,6 +1325,7 @@ def _start_runtime(*, fingerprint: str, info_path: Path) -> dict[str, Any]: _node_executable(), "--no-warnings", "--experimental-strip-types", + *_node_typescript_flags(), "--import", # ESM specifiers require file URLs on Windows; encode # reserved path characters on every platform as well. @@ -1440,6 +1442,7 @@ def _start_stdio_runtime(fingerprint: str) -> _StdioRuntime: _node_executable(), "--no-warnings", "--experimental-strip-types", + *_node_typescript_flags(), str(_control_plane_root() / "effect_runtime_stdio.ts"), fingerprint, ], diff --git a/loopx/control_plane/quota/scheduler_ack.py b/loopx/control_plane/quota/scheduler_ack.py index b0dcba0df2..f78de83ff3 100644 --- a/loopx/control_plane/quota/scheduler_ack.py +++ b/loopx/control_plane/quota/scheduler_ack.py @@ -8,6 +8,7 @@ from pathlib import Path from ..effect_runtime import _node_executable +from ..runtime.node_probe import node_typescript_flags from ..runtime.time import now_local_iso from ..scheduler.state import ( CODEX_APP_STATEFUL_BACKOFF_STATE_KEY, @@ -217,6 +218,7 @@ def _run_native_followup( _node_executable(), "--no-warnings", "--experimental-strip-types", + *node_typescript_flags(), str( Path(__file__).resolve().parents[1] / "scheduler" diff --git a/loopx/control_plane/runtime/node_probe.py b/loopx/control_plane/runtime/node_probe.py index ae57291b9c..983c0e0416 100644 --- a/loopx/control_plane/runtime/node_probe.py +++ b/loopx/control_plane/runtime/node_probe.py @@ -6,15 +6,23 @@ """ from __future__ import annotations +import platform import re import shutil import subprocess +import sys from dataclasses import dataclass from enum import StrEnum MINIMUM_NODE_VERSION = (22, 22, 3) MINIMUM_NODE_VERSION_TEXT = ".".join(str(part) for part in MINIMUM_NODE_VERSION) STARTUP_READY_TIMEOUT_SECONDS = 15.0 +_LINUX_X86_MACHINES = frozenset({"x86_64", "amd64"}) +_LINUX_X86_TYPESCRIPT_V8_FLAGS = ( + "--liftoff-only", + "--no-wasm-tier-up", + "--no-wasm-dynamic-tiering", +) HOST_PERMISSION_RECOMMENDATION = ( "retry the same registry, Goal, Agent and Turn through host-approved " "local runtime access; do not enable optional capabilities, replace " @@ -135,3 +143,20 @@ def probe_node(*, timeout: float = STARTUP_READY_TIMEOUT_SECONDS) -> NodeProbe: if prerelease is not None: version_text += f"-{prerelease}" return NodeProbe(outcome, executable, version_text) + + +def node_typescript_flags( + *, + system: str | None = None, + machine: str | None = None, +) -> tuple[str, ...]: + """Return V8 Wasm baseline flags for Node TypeScript stripping on Linux x86_64. + + Under QEMU/TCG or Linux PKU environments Node's Amaro Wasm TypeScript + stripper can trap in V8 ThreadIsolation during TurboFan Wasm tier-up. + """ + resolved_system = (sys.platform if system is None else system).lower() + resolved_machine = (platform.machine() if machine is None else machine).lower() + if resolved_system.startswith("linux") and resolved_machine in _LINUX_X86_MACHINES: + return _LINUX_X86_TYPESCRIPT_V8_FLAGS + return () diff --git a/loopx/control_plane/state_recovery_io.py b/loopx/control_plane/state_recovery_io.py index ebe24345fc..731565ba9e 100644 --- a/loopx/control_plane/state_recovery_io.py +++ b/loopx/control_plane/state_recovery_io.py @@ -24,6 +24,7 @@ from typing import Any, BinaryIO, Iterator, NoReturn from .effect_runtime import _node_executable, effect_runtime_result, effect_runtime_request_scope +from .runtime.node_probe import node_typescript_flags MAX_ARCHIVE_BYTES = 128 * 1024 * 1024 MAX_EXPANDED_BYTES = 512 * 1024 * 1024 @@ -87,6 +88,7 @@ def _runtime(method: str, request: dict[str, Any]) -> dict[str, Any]: def _audit_owners(request: dict[str, Any]) -> dict[str, Any]: command = [_node_executable(), "--no-warnings", "--max-old-space-size=512", "--experimental-sqlite", "--experimental-strip-types", + *node_typescript_flags(), str(Path(__file__).with_name("state_recovery_worker.ts"))] try: completed = subprocess.run(command, input=json.dumps(request), text=True, encoding="utf-8", diff --git a/loopx/control_plane/turn_driver/host_process_transport.py b/loopx/control_plane/turn_driver/host_process_transport.py index 0b1e79869d..9a2309a580 100644 --- a/loopx/control_plane/turn_driver/host_process_transport.py +++ b/loopx/control_plane/turn_driver/host_process_transport.py @@ -15,6 +15,7 @@ from ...file_lock import lock_holder_host_label from ..effect_runtime import _node_executable +from ..runtime.node_probe import node_typescript_flags from .host_bridge_transport import GuardedHostBridge # Keep Python's Windows executable/batch launcher compatibility. No timeout, @@ -347,6 +348,7 @@ def run_host_process( _node_executable(), "--no-warnings", "--experimental-strip-types", + *node_typescript_flags(), str(bridge), *launch_arguments, ], diff --git a/loopx/entrypoint.py b/loopx/entrypoint.py index 9017b22404..3c2bf912b2 100644 --- a/loopx/entrypoint.py +++ b/loopx/entrypoint.py @@ -6,6 +6,7 @@ from pathlib import Path from . import __version__ +from .control_plane.runtime.node_probe import node_typescript_flags def pin_utf8_stdio() -> None: @@ -123,6 +124,7 @@ def _native_scheduler_followup_argv(raw_argv: list[str]) -> list[str] | None: node, "--no-warnings", "--experimental-strip-types", + *node_typescript_flags(), str(entry), *raw_argv, ] diff --git a/loopx/extensions/turn_host.py b/loopx/extensions/turn_host.py index a9657128ec..ff0726c203 100644 --- a/loopx/extensions/turn_host.py +++ b/loopx/extensions/turn_host.py @@ -10,6 +10,7 @@ from pathlib import Path from ..control_plane.effect_runtime import _node_executable +from ..control_plane.runtime.node_probe import node_typescript_flags from ..control_plane.goals.goal_ref_validation import exact_goal_ref from ..control_plane.turn_driver.executor import validate_loopx_turn_host_result from ..control_plane.turn_driver.host_candidate import ( @@ -37,4 +38,11 @@ def supervised_stdio_command(command: Sequence[str]) -> list[str]: if not command or any(not isinstance(arg, str) or "\0" in arg for arg in command) or not command[0]: raise ValueError("a stdio command argv is required") bridge = Path(__file__).resolve().parents[1] / "control_plane" / "turn_driver" / "host_stdio_bridge.ts" - return [_node_executable(), "--no-warnings", "--experimental-strip-types", str(bridge), *command] + return [ + _node_executable(), + "--no-warnings", + "--experimental-strip-types", + *node_typescript_flags(), + str(bridge), + *command, + ] diff --git a/loopx/usage_ping.py b/loopx/usage_ping.py index 6f05f9aa3f..9b468e8de2 100644 --- a/loopx/usage_ping.py +++ b/loopx/usage_ping.py @@ -15,6 +15,7 @@ from typing import Any from . import __version__ +from .control_plane.runtime.node_probe import node_typescript_flags from .paths import select_default_runtime_root STATE_FILENAME = "usage-ping.json" @@ -120,7 +121,14 @@ def _command() -> list[str]: raise UsageSettingsUnavailable(message="Usage settings require the supported Node.js runtime.") # Keep the Python sender's proxy behavior when moving I/O to Node. This # native flag is available in the repository's supported Node versions. - return [node, "--no-warnings", "--use-env-proxy", "--experimental-strip-types", str(_ENTRY)] + return [ + node, + "--no-warnings", + "--use-env-proxy", + "--experimental-strip-types", + *node_typescript_flags(), + str(_ENTRY), + ] def control(action: str, path: Path | None = None, **fields: Any) -> dict[str, Any]: diff --git a/tests/control_plane/test_effect_runtime_node_probe.py b/tests/control_plane/test_effect_runtime_node_probe.py index 9f500b2d90..058d979b08 100644 --- a/tests/control_plane/test_effect_runtime_node_probe.py +++ b/tests/control_plane/test_effect_runtime_node_probe.py @@ -296,3 +296,71 @@ def test_deep_readiness_second_probe_timeout_recovers_real_request(tmp_path, mon assert recovered["runtime_identity"]["sqlite_authority_qualified"] is True finally: assert effect_runtime.restart_effect_runtime()["stopped"] is True + + +@pytest.mark.parametrize( + ("system", "machine", "expected"), + [ + ("linux", "x86_64", ("--liftoff-only", "--no-wasm-tier-up", "--no-wasm-dynamic-tiering")), + ("linux", "AMD64", ("--liftoff-only", "--no-wasm-tier-up", "--no-wasm-dynamic-tiering")), + ("linux", "aarch64", ()), + ("darwin", "arm64", ()), + ("win32", "AMD64", ()), + ], +) +def test_node_typescript_flags_scopes_wasm_baseline_workaround_to_linux_x86_64( + system: str, + machine: str, + expected: tuple[str, ...], +) -> None: + assert node_probe.node_typescript_flags(system=system, machine=machine) == expected + + +def test_stdio_and_server_runtime_launch_include_linux_x86_wasm_flags(tmp_path: Path, monkeypatch) -> None: + monkeypatch.setattr(node_probe.sys, "platform", "linux") + monkeypatch.setattr(node_probe.platform, "machine", lambda: "x86_64") + monkeypatch.setattr(effect_runtime, "_node_executable", lambda: "node") + launched: list[list[str]] = [] + + class _FakePipe: + pid = 123 + + def close(self, **_kwargs) -> bool: + return True + + def fake_stdio(argv, _env): + launched.append(list(argv)) + return _FakePipe() + + monkeypatch.setattr(effect_runtime, "EffectRuntimeStdio", fake_stdio) + monkeypatch.setattr( + effect_runtime, + "_request_with_info", + lambda *_args, **_kwargs: { + "result": {"ready": True, "pid": 123, "fingerprint": "f" * 64, "runtime_identity": None}, + }, + ) + runtime = effect_runtime._start_stdio_runtime("f" * 64) + assert runtime.fingerprint == "f" * 64 + assert launched and launched[0][:6] == [ + "node", + "--no-warnings", + "--experimental-strip-types", + "--liftoff-only", + "--no-wasm-tier-up", + "--no-wasm-dynamic-tiering", + ] + assert Path(launched[0][6]).name == "effect_runtime_stdio.ts" + + server_launches: list[list[str]] = [] + observations = iter([None, {"ready": True}]) + monkeypatch.setattr(effect_runtime, "_read_info", lambda *_args, **_kwargs: next(observations)) + monkeypatch.setattr( + effect_runtime.subprocess, + "Popen", + lambda args, **_kwargs: server_launches.append(list(args)) or SimpleNamespace(poll=lambda: None), + ) + info = tmp_path / "runtime" / "runtime.json" + assert effect_runtime._start_runtime(fingerprint="f" * 64, info_path=info) == {"ready": True} + assert server_launches and server_launches[0][:6] == launched[0][:6] + assert "--import" in server_launches[0] diff --git a/tests/control_plane/test_source_cli_entrypoint.py b/tests/control_plane/test_source_cli_entrypoint.py index a35d501a01..9666c01499 100644 --- a/tests/control_plane/test_source_cli_entrypoint.py +++ b/tests/control_plane/test_source_cli_entrypoint.py @@ -135,10 +135,13 @@ def replace_process(executable, argv): result = run_entry(entry, native_argv(), setup=setup, assertions=""" assert len(seen) == 1 assert seen[0][0] == "/fixture/node" -assert seen[0][1][1:3] == ["--no-warnings", "--experimental-strip-types"] +from loopx.control_plane.runtime.node_probe import node_typescript_flags +expected_flags = list(node_typescript_flags()) +script_index = 3 + len(expected_flags) +assert seen[0][1][1:script_index] == ["--no-warnings", "--experimental-strip-types", *expected_flags] from pathlib import Path -assert Path(seen[0][1][3]).parts[-2:] == ("scheduler", "heartbeat_followup_cli.ts") -assert seen[0][1][4:] == sys.argv[1:] +assert Path(seen[0][1][script_index]).parts[-2:] == ("scheduler", "heartbeat_followup_cli.ts") +assert seen[0][1][script_index + 1:] == sys.argv[1:] assert "loopx.cli_runtime" not in sys.modules assert "loopx.cli" not in sys.modules """) From f0c184c7013cacf48993cbdc18e99ad79347c984 Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Sun, 22 Nov 2026 01:00:40 +0800 Subject: [PATCH 2/2] fix(runtime): apply Linux x86_64 Wasm baseline flags to launcher, zcode, semantics, and testing callers Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- loopx/control_plane/runtime/node_version.ts | 15 ++++ .../testing/authority_e2e_fixtures.py | 2 + .../testing/authority_e2e_ladder.py | 5 +- loopx/control_plane/testing/canary_harness.py | 12 ++- loopx/semantics/production.py | 5 +- loopx/zcode_goal_mode/bridge.py | 7 +- loopx/zcode_goal_mode/cli.ts | 5 +- scripts/dashboard-dev.sh | 10 ++- scripts/loopx | 10 ++- .../dashboard_node_runtime.test.ts | 17 +++++ tests/test_scheduler_native_launcher.py | 75 ++++++++++++++++++- 11 files changed, 153 insertions(+), 10 deletions(-) diff --git a/loopx/control_plane/runtime/node_version.ts b/loopx/control_plane/runtime/node_version.ts index 7bd7bd679e..9d7b109c7b 100644 --- a/loopx/control_plane/runtime/node_version.ts +++ b/loopx/control_plane/runtime/node_version.ts @@ -1,5 +1,10 @@ const MINIMUM_NODE_VERSION = [22, 22, 3] as const; const NODE_VERSION_PATTERN = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/; +const LINUX_X86_TYPESCRIPT_V8_FLAGS = [ + "--liftoff-only", + "--no-wasm-tier-up", + "--no-wasm-dynamic-tiering", +] as const; export function isSupportedNodeVersion(version: string): boolean { const match = NODE_VERSION_PATTERN.exec(version); @@ -12,3 +17,13 @@ export function isSupportedNodeVersion(version: string): boolean { } return match[4] === undefined; } + +export function nodeTypescriptFlags( + platform: string = process.platform, + arch: string = process.arch, +): string[] { + if (platform === "linux" && (arch === "x64" || arch === "amd64")) { + return [...LINUX_X86_TYPESCRIPT_V8_FLAGS]; + } + return []; +} diff --git a/loopx/control_plane/testing/authority_e2e_fixtures.py b/loopx/control_plane/testing/authority_e2e_fixtures.py index ca2aa94001..2e7c0d1ace 100644 --- a/loopx/control_plane/testing/authority_e2e_fixtures.py +++ b/loopx/control_plane/testing/authority_e2e_fixtures.py @@ -24,6 +24,7 @@ from ..coordination.coordination_state_contract_generated import ( LOCAL_AUTHORITY_SHADOW_CONFIG_SCHEMA, ) +from ..runtime.node_probe import node_typescript_flags REPO_ROOT = Path(__file__).resolve().parents[3] TS_READBACK_PROBE = Path("tests") / "control_plane_ts" / "authority_store_readback_probe.ts" @@ -541,6 +542,7 @@ def ts_readback( node, "--no-warnings", "--experimental-strip-types", + *node_typescript_flags(), str(REPO_ROOT / TS_READBACK_PROBE), "--directory", str(directory or workspace.shadow_directory), diff --git a/loopx/control_plane/testing/authority_e2e_ladder.py b/loopx/control_plane/testing/authority_e2e_ladder.py index 7f078be5c9..7c5b863153 100644 --- a/loopx/control_plane/testing/authority_e2e_ladder.py +++ b/loopx/control_plane/testing/authority_e2e_ladder.py @@ -31,6 +31,7 @@ QUALIFIED_NOKV_API_VERSION as QUALIFIED_NOKV_API_VERSION, QUALIFIED_NOKV_SDK_VERSION as QUALIFIED_NOKV_SDK_VERSION, ) +from ..runtime.node_probe import node_typescript_flags from .authority_e2e_row_support import ( AGENT_A, RowAssertionError, @@ -208,7 +209,7 @@ def _row_local_conformance(context: RowContext, provider: str) -> RowOutcome: return unverified("local_conformance_suite_missing") summary = tap_summary( [node, "--no-warnings", "--experimental-sqlite", "--experimental-strip-types", - "--test", "--test-reporter=tap", str(suite)], + *node_typescript_flags(), "--test", "--test-reporter=tap", str(suite)], env=context.environ, timeout=900, ) @@ -347,6 +348,7 @@ def _row_nokv_live_qualification(context: RowContext) -> RowOutcome: node, "--no-warnings", "--experimental-strip-types", + *node_typescript_flags(), str(REPO_ROOT / NOKV_QUALIFICATION_SCRIPT), "--execute-live", "--config-json", @@ -457,6 +459,7 @@ def _row_postgresql_conformance_live(context: RowContext) -> RowOutcome: node, "--no-warnings", "--experimental-strip-types", + *node_typescript_flags(), "--test", "--test-reporter=tap", str(PG_INTEGRATION_TEST), diff --git a/loopx/control_plane/testing/canary_harness.py b/loopx/control_plane/testing/canary_harness.py index 770959b540..9a7dc9a25f 100644 --- a/loopx/control_plane/testing/canary_harness.py +++ b/loopx/control_plane/testing/canary_harness.py @@ -8,6 +8,8 @@ from pathlib import Path from typing import Any, Iterable +from ..runtime.node_probe import node_typescript_flags + REPO_ROOT = Path(__file__).resolve().parents[3] @@ -302,7 +304,15 @@ def advance_fixture_authority( "process.stdout.write(JSON.stringify(result));" ) process = subprocess.run( - ["node", "--no-warnings", "--experimental-strip-types", "--input-type=module", "-e", script], + [ + "node", + "--no-warnings", + "--experimental-strip-types", + *node_typescript_flags(), + "--input-type=module", + "-e", + script, + ], input=json.dumps({"root": str(runtime_root), "goal": goal_id, "projection": projection, "operation_id": operation_id}), capture_output=True, text=True, encoding="utf-8", check=False, timeout=45, diff --git a/loopx/semantics/production.py b/loopx/semantics/production.py index 63f9caa3e7..b9de9370fb 100644 --- a/loopx/semantics/production.py +++ b/loopx/semantics/production.py @@ -8,6 +8,7 @@ import subprocess from typing import Any, Callable +from ..control_plane.runtime.node_probe import node_typescript_flags from .inventory import SourceFile from .python_production import Production, enum_members, scan_python_production @@ -292,7 +293,7 @@ def probe_settlement_binding_production(vocabulary: dict[str, Any]) -> list[Prod for count in (2, 3) for group in combinations(bindings, count)] probes.extend(conflicts) completed = subprocess.run( - ['node', '--no-warnings', '--experimental-strip-types', + ['node', '--no-warnings', '--experimental-strip-types', *node_typescript_flags(), str(root / 'scripts/settlement_binding_witness.mts')], input=json.dumps({'probes': probes}), capture_output=True, text=True, encoding='utf-8', check=False, @@ -337,7 +338,7 @@ def probe_quota_run_decision_production(vocabulary: dict[str, Any]) -> list[Prod root = Path(__file__).resolve().parents[2] try: completed = subprocess.run( - ['node', '--no-warnings', '--experimental-strip-types', + ['node', '--no-warnings', '--experimental-strip-types', *node_typescript_flags(), str(root / 'scripts/quota_run_decision_witness.mts')], input=json.dumps({'values': vocabulary['values']}), capture_output=True, text=True, encoding='utf-8', check=False, timeout=30, diff --git a/loopx/zcode_goal_mode/bridge.py b/loopx/zcode_goal_mode/bridge.py index 4cec542a58..8147578f02 100644 --- a/loopx/zcode_goal_mode/bridge.py +++ b/loopx/zcode_goal_mode/bridge.py @@ -17,6 +17,7 @@ from ..control_plane.goals.activation import goal_is_stopped from ..control_plane.goals.goal_ref_validation import exact_goal_ref, require_goal_id from ..control_plane.runtime.goal_project_route import resolve_goal_project_route +from ..control_plane.runtime.node_probe import node_typescript_flags from ..control_plane.projects.registry_codec import load_registry from ..host_loop_activation import normalize_agent_type from ..registry import registry_goals @@ -274,7 +275,11 @@ def zcode_goal_operation( request["task_body"] = _heartbeat_task(binding, loopx_command) if action in {"bind", "start", "resume"}: request["goal_basis"] = _goal_basis(binding) - payload = _run_json([node, "--experimental-strip-types", str(Path(__file__).with_name("cli.ts"))], project=binding["project"], request=request) + payload = _run_json( + [node, "--experimental-strip-types", *node_typescript_flags(), str(Path(__file__).with_name("cli.ts"))], + project=binding["project"], + request=request, + ) for key in ("goal_id", "goal_ref", "goal_creation_operation_id", "agent_id"): if key not in payload or payload[key] != binding[key]: raise ZCodeGoalBridgeError("ZCode readback did not match the exact Goal and Agent requested.", code="zcode_goal_invalid_readback", status=409) diff --git a/loopx/zcode_goal_mode/cli.ts b/loopx/zcode_goal_mode/cli.ts index e61392c360..29b837504f 100644 --- a/loopx/zcode_goal_mode/cli.ts +++ b/loopx/zcode_goal_mode/cli.ts @@ -11,6 +11,7 @@ import {ZCODE_GOAL_ACTIONS, isGoalBasis, sameBinding, ZCodeGoalError, safeFailur import {NativeGoalController, readState, atomicState, type BindingState} from "./runtime.ts"; import {ZCodeAppServer} from "./app-server.ts"; import {acquireFileMutationLock, releaseFileMutationLock, durableWriteJson} from "../control_plane/effect_runtime_io.ts"; +import {nodeTypescriptFlags} from "../control_plane/runtime/node_version.ts"; const MAX_INPUT = 64 * 1024; const MAX_RESPONSE = 1024 * 1024; @@ -153,7 +154,7 @@ async function serve(request: NativeRequest): Promise { const storage = request.state_path + ".host"; await mkdir(storage, {recursive: true, mode: 0o700}); const guardedCommand = [process.execPath, "--no-warnings", "--experimental-strip-types", - fileURLToPath(new URL("./guard.ts", import.meta.url)), "--", ...selected.cli_command]; + ...nodeTypescriptFlags(), fileURLToPath(new URL("./guard.ts", import.meta.url)), "--", ...selected.cli_command]; const host = new ZCodeAppServer(guardedCommand, selected.project, { ...process.env, ZCODE_STORAGE_DIR: storage, ZCODE_DATA_BASE_DIR: storage, ZCODE_SESSION_DB_PATH: join(storage, "sessions.db"), }, {guardian: true, onExit: () => {void shutdown();}}); @@ -272,7 +273,7 @@ async function dispatch(request: NativeRequest): Promise { if (!state && !request.cli_command) throw new ZCodeGoalError("ZCode CLI was not found"); await validate(request, ["pause", "stop"].includes(request.action)); const child = spawn(process.execPath, ["--no-warnings", "--experimental-strip-types", - fileURLToPath(import.meta.url), "--serve"], {cwd: request.project, detached: true, + ...nodeTypescriptFlags(), fileURLToPath(import.meta.url), "--serve"], {cwd: request.project, detached: true, windowsHide: true, stdio: ["pipe", "ignore", "ignore"], env: process.env}); child.on("error", () => {}); child.stdin!.end(JSON.stringify(request)); diff --git a/scripts/dashboard-dev.sh b/scripts/dashboard-dev.sh index c6a445ccf0..fdf7812394 100755 --- a/scripts/dashboard-dev.sh +++ b/scripts/dashboard-dev.sh @@ -18,7 +18,15 @@ if [[ "${LOOPX_ENABLE_GOAL_SUBAGENT_CONFIGURATION:-0}" = "1" ]]; then fi node_is_supported() { - "$1" --no-warnings --experimental-strip-types --input-type=module -e ' + local node_ts_flags=() + if [[ "$(uname -s 2>/dev/null || true)" == Linux* ]]; then + case "$(uname -m 2>/dev/null || true)" in + x86_64|amd64) + node_ts_flags=(--liftoff-only --no-wasm-tier-up --no-wasm-dynamic-tiering) + ;; + esac + fi + "$1" --no-warnings --experimental-strip-types ${node_ts_flags[@]+"${node_ts_flags[@]}"} --input-type=module -e ' import { pathToFileURL } from "node:url"; const { isSupportedNodeVersion } = await import(pathToFileURL(process.argv[1]).href); process.exit(isSupportedNodeVersion(process.versions.node) ? 0 : 1); diff --git a/scripts/loopx b/scripts/loopx index 57f5abd088..caf7d9b03a 100755 --- a/scripts/loopx +++ b/scripts/loopx @@ -71,7 +71,15 @@ if [[ "$loopx_command" == "quota" \ exit 2 fi export LOOPX_RELEASE_ROOT="$repo_root" - exec node --no-warnings --experimental-strip-types "$native_scheduler_entry" "$@" + node_ts_flags=() + if [[ "$(uname -s 2>/dev/null || true)" == Linux* ]]; then + case "$(uname -m 2>/dev/null || true)" in + x86_64|amd64) + node_ts_flags=(--liftoff-only --no-wasm-tier-up --no-wasm-dynamic-tiering) + ;; + esac + fi + exec node --no-warnings --experimental-strip-types ${node_ts_flags[@]+"${node_ts_flags[@]}"} "$native_scheduler_entry" "$@" fi # Codex host-match ACKs need the entrypoint's fresh App read before TS commit. diff --git a/tests/control_plane_ts/dashboard_node_runtime.test.ts b/tests/control_plane_ts/dashboard_node_runtime.test.ts index bf4100850f..5463c5632c 100644 --- a/tests/control_plane_ts/dashboard_node_runtime.test.ts +++ b/tests/control_plane_ts/dashboard_node_runtime.test.ts @@ -5,6 +5,7 @@ import {tmpdir} from "node:os"; import {dirname, join} from "node:path"; import test from "node:test"; import {fileURLToPath} from "node:url"; +import {nodeTypescriptFlags} from "../../loopx/control_plane/runtime/node_version.ts"; const root = fileURLToPath(new URL("../../", import.meta.url)); const contract = "loopx/control_plane/runtime/node_version.ts"; @@ -75,3 +76,19 @@ for (const [onPath, inNvm, allowed] of cases) { } }); } + +test("nodeTypescriptFlags returns V8 baseline Wasm flags only on Linux x86_64/amd64", () => { + assert.deepEqual(nodeTypescriptFlags("linux", "x64"), [ + "--liftoff-only", + "--no-wasm-tier-up", + "--no-wasm-dynamic-tiering", + ]); + assert.deepEqual(nodeTypescriptFlags("linux", "amd64"), [ + "--liftoff-only", + "--no-wasm-tier-up", + "--no-wasm-dynamic-tiering", + ]); + assert.deepEqual(nodeTypescriptFlags("linux", "arm64"), []); + assert.deepEqual(nodeTypescriptFlags("darwin", "arm64"), []); + assert.deepEqual(nodeTypescriptFlags("darwin", "x64"), []); +}); diff --git a/tests/test_scheduler_native_launcher.py b/tests/test_scheduler_native_launcher.py index d3a47d7aa7..2bd5f14e4d 100644 --- a/tests/test_scheduler_native_launcher.py +++ b/tests/test_scheduler_native_launcher.py @@ -14,6 +14,7 @@ write_cli_fixture, write_codex_heartbeat_fixture, ) +from loopx.control_plane.runtime.node_probe import node_typescript_flags from loopx.control_plane.testing.canary_harness import run_json_cli_result from tests.control_plane.canonical_authority_fixture import ( isolate_sqlite_runtime, @@ -71,9 +72,12 @@ def test_unix_launcher_process_replaces_python_for_exact_native_followup( assert completed.returncode == 0, completed.stderr lines = completed.stdout.splitlines() - assert lines[:3] == [ + expected_flags = list(node_typescript_flags()) + script_index = 2 + len(expected_flags) + assert lines[: script_index + 1] == [ "--no-warnings", "--experimental-strip-types", + *expected_flags, str( REPO_ROOT / "loopx" @@ -85,6 +89,75 @@ def test_unix_launcher_process_replaces_python_for_exact_native_followup( assert lines[-len(args) :] == args +@pytest.mark.skipif( + os.name == "nt", + reason="the POSIX source launcher runs only on POSIX hosts", +) +@pytest.mark.parametrize( + ("uname_s", "uname_m", "expected_v8_flags"), + [ + ("Linux", "x86_64", ["--liftoff-only", "--no-wasm-tier-up", "--no-wasm-dynamic-tiering"]), + ("Linux", "amd64", ["--liftoff-only", "--no-wasm-tier-up", "--no-wasm-dynamic-tiering"]), + ("Linux", "aarch64", []), + ("Darwin", "arm64", []), + ], +) +def test_unix_launcher_native_followup_passes_linux_x86_wasm_flags( + tmp_path: Path, + uname_s: str, + uname_m: str, + expected_v8_flags: list[str], +) -> None: + fake_bin = tmp_path / "bin" + fake_bin.mkdir() + (fake_bin / "node").write_text("#!/bin/sh\nprintf '%s\\n' \"$@\"\n", encoding="utf-8") + (fake_bin / "node").chmod(0o755) + (fake_bin / "uname").write_text( + f"#!/bin/sh\ncase \"$1\" in -s) echo {uname_s};; -m) echo {uname_m};; *) /usr/bin/uname \"$@\";; esac\n", + encoding="utf-8", + ) + (fake_bin / "uname").chmod(0o755) + env = { + **os.environ, + "PATH": str(fake_bin) + os.pathsep + os.environ.get("PATH", ""), + "LOOPX_PYTHON": str(tmp_path / "python-must-not-run"), + } + args = [ + "--format", + "json", + "--runtime-root", + str(tmp_path / "runtime"), + "quota", + "scheduler-ack-current", + "--goal-id", + "goal-native-launcher", + "--agent-id", + "agent-native-launcher", + "--scheduler-host-facts-chunk", + "facts", + "--turn-instance-id", + "turn-native-launcher", + "--execute", + ] + completed = subprocess.run( + [str(REPO_ROOT / "scripts" / "loopx"), *args], + check=False, + capture_output=True, + text=True, + env=env, + ) + assert completed.returncode == 0, completed.stderr + lines = completed.stdout.splitlines() + script_index = 2 + len(expected_v8_flags) + assert lines[: script_index + 1] == [ + "--no-warnings", + "--experimental-strip-types", + *expected_v8_flags, + str(REPO_ROOT / "loopx" / "control_plane" / "scheduler" / "heartbeat_followup_cli.ts"), + ] + assert lines[-len(args) :] == args + + @pytest.mark.skipif( os.name == "nt", reason="the POSIX source launcher runs only on POSIX hosts",