[PR #5311] [MERGED] Windows: run lan_e2e and agent_control_e2e (junction fallback, no vscreen, horizon-ctl launch returns) #6201

Closed
opened 2026-11-03 06:15:48 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5311
Author: @mariuslozo-boop
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: tooling/windows-lan-e2e


📝 Commits (1)

  • 03ec7ec Windows: run lan_e2e and agent_control_e2e without symlink privilege or vscreen

📊 Changes

7 files changed (+124 additions, -6 deletions)

View changed files

📝 crates/horizon-client/src/bin/horizon-ctl/launch.rs (+3 -0)
📝 crates/horizon-threads/Cargo.toml (+1 -1)
📝 crates/horizon-threads/src/lib.rs (+50 -0)
📝 tests/test_lab.py (+53 -1)
📝 tools/agent_control_e2e.py (+3 -3)
📝 tools/lab.py (+13 -0)
📝 tools/lan_e2e.py (+1 -1)

📄 Description

🤖 Opened by mariuslozo-boop's AI agent (Claude Code, Claude Opus 5.5), not by mariuslozo-boop personally.

What and why

Fixes #5274. tools/lan_e2e.py (and tools/agent_control_e2e.py) couldn't run on Windows. This fixes the three blockers:

  1. Resources link without symlink privilege. The new lab.link_dir(target, link) makes a symbolic link, as before. On Windows, when that is refused with WinError 1314 (no Developer Mode, not an administrator), it makes a directory junction instead (mklink /J), which needs no privilege. shutil.rmtree removes a junction without touching its target, and a test checks that. Both harnesses' scratch homes use it. On Linux and macOS it is the same os.symlink call as before (target_is_directory only matters on Windows).
  2. No vscreen on Windows. agent_control_e2e.game_env now treats Windows like macOS (no virtual screen, plain lab.game_env) instead of running vscreen up, which raised FileNotFoundError.
  3. horizon-ctl launch returns when its output is captured. On Windows, std::process::Command starts the child with bInheritHandles, which hands it every inheritable handle of the parent, not only the three stdio handles it is given. horizon-ctl's own stdin/stdout/stderr are the caller's pipes and are inheritable. So the game held the write end of the harness's stdout pipe for its whole life, and subprocess.run(..., capture_output=True) waited for EOF until the game quit. Even after a timeout, Python kills horizon-ctl and keeps waiting on the pipe, which is how interrupted runs left horizon-client.exe behind. horizon-ctl now clears HANDLE_FLAG_INHERIT on its own standard handles right before it spawns the game (horizon_threads::keep_stdio_from_children, in horizon-threads because horizon-ctl forbids unsafe code). The game still gets its stdin/stdout/stderr (null and the log file), because Command duplicates the handles it passes. Linux and macOS are unchanged (#[cfg(windows)]): there the child's fds 0-2 are replaced and the rest are close-on-exec.

horizon-ctl ships beside the game, but this only changes which handles a game started by horizon-ctl launch inherits on Windows. Players see no change. An agent that runs horizon-ctl launch (or horizon-ctl mcp's launch) with piped output on Windows no longer has the game hold its pipes open.

Proof (Windows 11, Python 3.12, HORIZON_E2E_HEADLESS=1)

Before, on main:

$ python tools/lan_e2e.py --bin-dir target/main-bin --check creative_tools
  File "tools\lan_e2e.py", line 362, in __init__
    os.symlink(resources, self.work / '.local/horizon-client' / lab.VERSION)
OSError: [WinError 1314] A required privilege is not held by the client: 'D:\Horizon\.local\horizon-client\26.3' -> '...\hzlan-host-e7r8cg1e\.local\horizon-client\26.3'

$ python -c "import agent_control_e2e as a; a.game_env('lan-e2e')"     # DISPLAY unset
FileNotFoundError: [WinError 2] The system cannot find the file specified      # subprocess.run(['vscreen', 'up'])

# subprocess.run([ctl, '--socket', s, 'launch', '--offscreen', '--no-pause', ...], capture_output=True, timeout=150)
launch did NOT return within 220 s      # the game answered `state` meanwhile; run() only returned once the game was quit

After, on this branch (no shim):

# the same launch probe
launch returned after 5.7 s: {"ok":true,"pid":21064,...}
quit: {"ok":true}                       # no horizon-client.exe left running

$ python tools/lan_e2e.py --bin-dir target/fast --check creative_tools
[lan] creative_tools: PASS {'host': {'client': 'minecraft:stone', 'server': 'minecraft:stone', 'ordinary_tool': 'minecraft:air'}, 'guest': {...same}}
exit 0

$ python tools/lan_e2e.py --bin-dir target/fast --check chest --check clicks
[lan] chest: PASS {'open': {'guest': 1.0, 'host': 1.0}, 'closed': {'guest': 0.0, 'host': 0.0}}
[lan] clicks: FAIL AssertionError("the furnace holds {0: 'minecraft:raw_iron', 1: 'minecraft:coal', 2: 'minecraft:iron_ingot'}")

clicks gets past launch and every other step. It fails because the furnace finishes a smelt (200 ticks) before the check reopens it: between the two it polls screen 100+ times, one horizon-ctl process per call, which takes longer on this machine. That's the check's timing, not this change, so I left it alone. No horizon-client process was left after any of these runs.

Tests: tests/test_lab.py gains LinkDirTests (symlink where allowed; junction on Windows on WinError 1314; other errors and other systems still raise; rmtree of the scratch folder keeps the linked folder, run for real) and GameEnvScreenTests (macOS and Windows start no virtual screen, with subprocess.run mocked). horizon-threads gains a Windows-only test that stdout is no longer inheritable after the call.

Out of scope: tools/launcher_mcp_e2e.py also symlinks files (the binaries), which a junction can't replace. agent_control_e2e.py doesn't pass --offscreen on Windows yet, so its games open windows there.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

none

Other projects' code

none

Self-check

Check Result
Scope ✅ 7 files, +124 −6
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 504 passed (4 min 27 s)
rustfmt ✅ (27 s)
clippy ✅ (3 min 37 s)
tests: horizon-client, horizon-threads ❌ 1391 passed, 7 failed (10 min 47 s)
doc tests ✅ 0 passed (3 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ❌ 371 affected, (8 s)
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Notes on this local run (Windows 11; full output on request):

  • Parity ❌: the parity runner imports fcntl (Unix-only) in machine_slot, so it can't run on Windows. That's a local limitation, outside this PR. It picks 371 harnesses, presumably because of the horizon-threads Cargo.toml feature line (Win32_Foundation, Win32_System_Console for Windows only). No harness runs the new function, which only horizon-ctl calls.
  • tests ❌ 7 failed: all 7 are in --test lan_bot and fail identically on upstream/main 571ec1b76 on this machine (cargo test -p horizon-client --test lan_bot -- --test-threads=1: same 7, 6 pass). That test doesn't use horizon-ctl or the new function. Every other test of both crates passes, including the new horizon_threads::tests::standard_handles_stay_out_of_children.
  • Local environment: the Python tests ran from a clean venv, because this machine's system site-packages has an unrelated tests package that shadows the repository's tests/.
  • Label: pr_ready suggests a player-facing label because horizon-ctl's source changed. I meant to set skip-release (this fork account can't add labels, so please add it) because the game players run doesn't change; only horizon-ctl launch on Windows does, and only for its caller's pipes. Please change it if you see it differently.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/5311 **Author:** [@mariuslozo-boop](https://github.com/mariuslozo-boop) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `tooling/windows-lan-e2e` --- ### 📝 Commits (1) - [`03ec7ec`](https://github.com/horizon-rust/horizon/commit/03ec7ec551428f024885354a43fe722913a5e163) Windows: run lan_e2e and agent_control_e2e without symlink privilege or vscreen ### 📊 Changes **7 files changed** (+124 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/bin/horizon-ctl/launch.rs` (+3 -0) 📝 `crates/horizon-threads/Cargo.toml` (+1 -1) 📝 `crates/horizon-threads/src/lib.rs` (+50 -0) 📝 `tests/test_lab.py` (+53 -1) 📝 `tools/agent_control_e2e.py` (+3 -3) 📝 `tools/lab.py` (+13 -0) 📝 `tools/lan_e2e.py` (+1 -1) </details> ### 📄 Description > 🤖 Opened by mariuslozo-boop's AI agent (Claude Code, Claude Opus 5.5), not by mariuslozo-boop personally. ## What and why Fixes #5274. `tools/lan_e2e.py` (and `tools/agent_control_e2e.py`) couldn't run on Windows. This fixes the three blockers: 1. **Resources link without symlink privilege.** The new `lab.link_dir(target, link)` makes a symbolic link, as before. On Windows, when that is refused with WinError 1314 (no Developer Mode, not an administrator), it makes a directory junction instead (`mklink /J`), which needs no privilege. `shutil.rmtree` removes a junction without touching its target, and a test checks that. Both harnesses' scratch homes use it. On Linux and macOS it is the same `os.symlink` call as before (`target_is_directory` only matters on Windows). 2. **No `vscreen` on Windows.** `agent_control_e2e.game_env` now treats Windows like macOS (no virtual screen, plain `lab.game_env`) instead of running `vscreen up`, which raised `FileNotFoundError`. 3. **`horizon-ctl launch` returns when its output is captured.** On Windows, `std::process::Command` starts the child with `bInheritHandles`, which hands it *every* inheritable handle of the parent, not only the three stdio handles it is given. horizon-ctl's own stdin/stdout/stderr are the caller's pipes and are inheritable. So the game held the write end of the harness's stdout pipe for its whole life, and `subprocess.run(..., capture_output=True)` waited for EOF until the game quit. Even after a timeout, Python kills horizon-ctl and keeps waiting on the pipe, which is how interrupted runs left `horizon-client.exe` behind. horizon-ctl now clears `HANDLE_FLAG_INHERIT` on its own standard handles right before it spawns the game (`horizon_threads::keep_stdio_from_children`, in horizon-threads because horizon-ctl forbids unsafe code). The game still gets its stdin/stdout/stderr (null and the log file), because `Command` duplicates the handles it passes. Linux and macOS are unchanged (`#[cfg(windows)]`): there the child's fds 0-2 are replaced and the rest are close-on-exec. horizon-ctl ships beside the game, but this only changes which handles a game started by `horizon-ctl launch` inherits on Windows. Players see no change. An agent that runs `horizon-ctl launch` (or `horizon-ctl mcp`'s `launch`) with piped output on Windows no longer has the game hold its pipes open. ### Proof (Windows 11, Python 3.12, `HORIZON_E2E_HEADLESS=1`) Before, on main: ``` $ python tools/lan_e2e.py --bin-dir target/main-bin --check creative_tools File "tools\lan_e2e.py", line 362, in __init__ os.symlink(resources, self.work / '.local/horizon-client' / lab.VERSION) OSError: [WinError 1314] A required privilege is not held by the client: 'D:\Horizon\.local\horizon-client\26.3' -> '...\hzlan-host-e7r8cg1e\.local\horizon-client\26.3' $ python -c "import agent_control_e2e as a; a.game_env('lan-e2e')" # DISPLAY unset FileNotFoundError: [WinError 2] The system cannot find the file specified # subprocess.run(['vscreen', 'up']) # subprocess.run([ctl, '--socket', s, 'launch', '--offscreen', '--no-pause', ...], capture_output=True, timeout=150) launch did NOT return within 220 s # the game answered `state` meanwhile; run() only returned once the game was quit ``` After, on this branch (no shim): ``` # the same launch probe launch returned after 5.7 s: {"ok":true,"pid":21064,...} quit: {"ok":true} # no horizon-client.exe left running $ python tools/lan_e2e.py --bin-dir target/fast --check creative_tools [lan] creative_tools: PASS {'host': {'client': 'minecraft:stone', 'server': 'minecraft:stone', 'ordinary_tool': 'minecraft:air'}, 'guest': {...same}} exit 0 $ python tools/lan_e2e.py --bin-dir target/fast --check chest --check clicks [lan] chest: PASS {'open': {'guest': 1.0, 'host': 1.0}, 'closed': {'guest': 0.0, 'host': 0.0}} [lan] clicks: FAIL AssertionError("the furnace holds {0: 'minecraft:raw_iron', 1: 'minecraft:coal', 2: 'minecraft:iron_ingot'}") ``` `clicks` gets past launch and every other step. It fails because the furnace finishes a smelt (200 ticks) before the check reopens it: between the two it polls `screen` 100+ times, one horizon-ctl process per call, which takes longer on this machine. That's the check's timing, not this change, so I left it alone. No `horizon-client` process was left after any of these runs. Tests: `tests/test_lab.py` gains `LinkDirTests` (symlink where allowed; junction on Windows on WinError 1314; other errors and other systems still raise; `rmtree` of the scratch folder keeps the linked folder, run for real) and `GameEnvScreenTests` (macOS and Windows start no virtual screen, with `subprocess.run` mocked). horizon-threads gains a Windows-only test that stdout is no longer inheritable after the call. Out of scope: `tools/launcher_mcp_e2e.py` also symlinks files (the binaries), which a junction can't replace. `agent_control_e2e.py` doesn't pass `--offscreen` on Windows yet, so its games open windows there. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [x] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference none ## Other projects' code none ## Self-check | Check | Result | | --- | --- | | Scope | ✅ 7 files, +124 −6 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 504 passed (4 min 27 s) | | rustfmt | ✅ (27 s) | | clippy | ✅ (3 min 37 s) | | tests: horizon-client, horizon-threads | ❌ 1391 passed, 7 failed (10 min 47 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ❌ 371 affected, (8 s) | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Notes on this local run (Windows 11; full output on request): - **Parity ❌**: the parity runner imports `fcntl` (Unix-only) in `machine_slot`, so it can't run on Windows. That's a local limitation, outside this PR. It picks 371 harnesses, presumably because of the horizon-threads `Cargo.toml` feature line (`Win32_Foundation`, `Win32_System_Console` for Windows only). No harness runs the new function, which only horizon-ctl calls. - **tests ❌ 7 failed**: all 7 are in `--test lan_bot` and fail identically on upstream/main `571ec1b76` on this machine (`cargo test -p horizon-client --test lan_bot -- --test-threads=1`: same 7, 6 pass). That test doesn't use horizon-ctl or the new function. Every other test of both crates passes, including the new `horizon_threads::tests::standard_handles_stay_out_of_children`. - Local environment: the Python tests ran from a clean venv, because this machine's system site-packages has an unrelated `tests` package that shadows the repository's `tests/`. - Label: pr_ready suggests a player-facing label because horizon-ctl's source changed. I meant to set `skip-release` (this fork account can't add labels, so please add it) because the game players run doesn't change; only `horizon-ctl launch` on Windows does, and only for its caller's pipes. Please change it if you see it differently. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:15:48 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#6201
No description provided.