loopx icon indicating copy to clipboard operation
loopx copied to clipboard

[Bug]: native Windows fails the canary premerge gate's own contract smoke (POSIX scripts/loopx shim exec)

Open JasonBuildAI opened this issue 1 month ago • 0 comments

Problem

On a native Windows host the repository's own required pre-merge gate (loopx canary premerge --from-git-diff, required by AGENTS.md before self-merge) fails its own contract smoke for nearly every control-plane diff, because examples/canary/premerge-validation-gate-smoke.py cannot run there: two of its checks execute the extensionless POSIX bash shim scripts/loopx directly, which Windows cannot start.

The two affected checks are different in kind:

  • assert_installed_wrapper_uses_bound_python_and_redirects_to_checkout copies scripts/loopx into a fake release root and executes it (line 364). It asserts POSIX-shim behavior (LOOPX_PYTHON binding and the canary premerge checkout redirect), which exists only in the shim.
  • assert_external_dirty_worktree_uses_caller_repo executes scripts/loopx in an external dirty worktree (lines 417 and 460). That contract is host-neutral: running the source CLI from an external checkout must resolve the caller's repository, not the release checkout.

Who is affected: any contributor or agent that runs the required gate from a Windows checkout. loopx/canary/premerge.py attaches the canary-runner profile to every control_plane change, and that profile selects python3 examples/canary/premerge-validation-gate-smoke.py, so the false failure appears for nearly every control-plane diff. The gate verdict then cannot be trusted on Windows until the operator hand-diffs the failure set against a clean baseline.

This is the same host-portability class that issue #6405 fixed for the pytest suite (shared host-aware launcher, explicit POSIX-only declarations, UTF-8 read pinning). It was explicitly recorded as a remaining, separately tracked defect by PR #6464's not_met row and slice boundary ("a POSIX shell shim for scripts/loopx is copied and executed on Windows").

Minimal reproduction

git checkout 81ff72b64
uv sync --extra test
uv run --extra test python examples/canary/premerge-validation-gate-smoke.py

On Windows 11, CPython 3.12, PowerShell, host code page cp936: exit code 1.

The same check is selected and reported as failed by the gate itself:

uv run --extra test loopx canary premerge --changed-file loopx/control_plane/work_items/interaction_contract.py --timeout-seconds 900 --format json --no-progress

The preview form shows the selection without executing checks:

uv run --extra test loopx canary premerge --changed-file loopx/control_plane/work_items/interaction_contract.py --no-execute

Expected behavior

The smoke should exercise the gate contract on every host the gate supports:

  • host-neutral checks launch the CLI through the launcher the host can actually run: scripts/loopx on POSIX hosts, and the shipped Windows entry scripts/loopx_entry.py (the entry scripts/loopx.ps1 and loopx/windows_install.py both delegate to, including its -I isolated launch and LOOPX_RELEASE_ROOT pin) on Windows;
  • checks that assert POSIX bash-shim behavior are declared POSIX-only, as tests/test_loopx_launcher_python_selection.py already declares its launcher contract;
  • CLI output reads pin encoding="utf-8", because loopx/entrypoint.py pins UTF-8 stdio and the host locale codec (cp936) fails on the CLI's own output.

Actual behavior

OSError: [WinError 193] %1 is not a valid Win32 application

raised at examples/canary/premerge-validation-gate-smoke.py:364 (and again in the external-worktree check), exit code 1.

Sanitized diagnostics

# direct run, before
$ python examples/canary/premerge-validation-gate-smoke.py
Traceback (most recent call last):
  File "examples/canary/premerge-validation-gate-smoke.py", line 575, in main
    assert_installed_wrapper_uses_bound_python_and_redirects_to_checkout()
  File "examples/canary/premerge-validation-gate-smoke.py", line 364, in assert_installed_wrapper_uses_bound_python_and_redirects_to_checkout
    completed = subprocess.run(
  ...
OSError: [WinError 193] %1 is not a valid Win32 application

# gate run, before (risk_profile_run selected check)
"command": "python3 examples/canary/premerge-validation-gate-smoke.py", "status": "failed", "returncode": 1

Unrelated local failures observed in the same gate run on this host, not part of this report: examples/canary/catalog-planner-smoke.py fails its temp-fixture cleanup (fixture cleanup failed; ... [WinError 5]), and examples/semantic-vocabulary-drift-smoke.py requires repository npm dev dependencies (npm ci --ignore-scripts).

Additional context

  • Continues #6405 (host-portability repair for the Python suite) and the deferred slice boundary of #6464.
  • A fix PR with host-aware launcher selection, a POSIX-only declaration for the shim-specific check, UTF-8 read pinning, and a native Windows lane step follows this issue.

AI disclosure: drafted with AI assistance under the direction and review of the repository account owner, from a reproduced run on a native Windows host.

JasonBuildAI avatar Oct 15 '26 17:10 JasonBuildAI