[PR #5446] [MERGED] horizon-client: gameplay in the library, a thin executable #6293

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5446
Author: @Xmilon
Created: 10/31/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: native/api-mods


📝 Commits (10+)

  • e2d8520 Windows build: the windows-sys features boot_paint uses
  • 3888ac4 Native mods without mixins: API mods that never rebuild horizon-client
  • 0fb2575 boot_paint: AddFontMemResourceEx only reads the font count
  • af806fd Merge upstream/main into native/api-mods
  • 1e0fe9b Merge upstream/main; the game's unit tests keep their own process
  • 6085115 Merge main into #5446
  • 022306f refactor(client): keep the library split without the separate mod API
  • cd85269 docs: correct parity selection costs after the client split
  • a303d7d Merge upstream/main into the client library split
  • 2c78a5f Merge upstream/main before revising the client library layout

📊 Changes

117 files changed (+886 additions, -375 deletions)

View changed files

📝 .github/workflows/game-build.yml (+1 -1)
📝 AGENTS.md (+15 -8)
📝 Cargo.lock (+57 -0)
📝 Cargo.toml (+1 -0)
➕ crates/horizon-client-lib/Cargo.toml (+221 -0)
📝 crates/horizon-client/Cargo.toml (+14 -7)
📝 crates/horizon-client/examples/chunk_load_bench.rs (+1 -0)
📝 crates/horizon-client/examples/gameplay_decode_profile.rs (+1 -0)
📝 crates/horizon-client/examples/json_load_bench.rs (+1 -0)
📝 crates/horizon-client/examples/mod_port_probe.rs (+1 -0)
📝 crates/horizon-client/examples/model_library_bench.rs (+1 -0)
📝 crates/horizon-client/examples/model_states_bench.rs (+1 -0)
📝 crates/horizon-client/examples/old_world_fixture.rs (+1 -0)
📝 crates/horizon-client/examples/portal_scan_bench.rs (+1 -0)
📝 crates/horizon-client/examples/probe/main.rs (+1 -0)
📝 crates/horizon-client/examples/random_tick_eligibility_bench.rs (+1 -0)
📝 crates/horizon-client/examples/resource_memory.rs (+1 -0)
📝 crates/horizon-client/examples/save_batch_bench.rs (+1 -0)
📝 crates/horizon-client/examples/shared_json_startup_profile.rs (+1 -0)
📝 crates/horizon-client/examples/sprite_cache_parity.rs (+1 -0)

...and 80 more files

📄 Description

🤖 Opened by Xmilon's AI agent (Codex), not by Xmilon personally.

What and why

Separate gameplay from the client systems used by tools and parity probes, while keeping existing native-mod targets and game source paths stable. This revises the original split in response to the build-cost and native-staging review.

  • horizon-client owns the gameplay library, startup and thin horizon-client executable.
  • horizon-client-lib compiles the existing reusable sources, horizon-ctl, examples and core integration tests. Its manifest references existing source paths; gameplay is not a dependency. Gameplay re-exports its public modules so horizon_client::game::... mod targets and the game command stay unchanged.
  • Gameplay tests now live in the gameplay library test target, separate from reusable-library tests. The executable no longer contains a test-only copy of Game or blanket dead-code/import allowances.
  • Build, release, harness and contributor commands select the package that owns each target. Parity reachability supports explicit external target roots and extern-crate aliases; pr_ready maps shared source files to their actual owning package.
  • Pin horizon-mixins to ddd9700b21997c95d95ac6ee5ecafe3830cf622a, the merged fix for production cfg indexing (horizon-rust/horizon-mixins#17). The gameplay module is also unconditional in this layout.

The typed no-rebuild API remains Ari's separate #5638; this PR does not claim to deliver that interface. The build measurements below show no slowdown.

Kind

  • tooling: tools, CI, tests, harnesses

Players see no new feature; skip-release fits. No mod manifest/API format changes.

Vanilla reference

None: build organization only; gameplay logic is unchanged.

Other projects' code

No external implementation code copied. Validation uses the MIT-licensed horizon-mixins at ddd9700b21997c95d95ac6ee5ecafe3830cf622a and horizon-machine-sample at ab2fddb1bd0d5802974124318c033c877947f027; only the scratch sample's compatibility revision is changed to this PR's committed head.

Why this revision exists

Ludovic closed the first version because the split alone made builds slower, and levzzz's review named three things a maintainer would want before looking again. Here is each one, and where it stands at f2b508c4f.

1. Native mods couldn't stage (E_MODULE). The first version gated pub mod game with #[cfg(not(test))], and horizon-mixins didn't index cfg-gated modules. So a mod that injects into game.rs, like horizon-machine-sample, failed with E_MODULE: module destination must be an indexed Rust source file.
Now game is unconditional, and the mixins pin moves to ddd9700b (horizon-rust/horizon-mixins#17, its fix for cfg-gated modules). The machine sample stages (8 injections, 1 module), and the injected horizon-client lib and bin compile with no warnings (--no-default-features).

2. Builds got slower. Gameplay was compiled twice for the executable's tests (once in the lib, once as the bin's test copy). And every gameplay edit rebuilt horizon-ctl and the ~104 client probes, because they linked the lib that held gameplay.
Now the reusable client is its own crate, horizon-client-lib (crates/horizon-client-lib, sources still in crates/horizon-client/src). It holds horizon-ctl, the probes, the examples and the core integration tests, and it doesn't depend on gameplay. horizon-client is gameplay plus a thin executable on top of it. Gameplay compiles once, and nothing the probes build includes it.

3. Smaller points. The bin's test copy of Game is gone, and with it the #[allow(dead_code, unused_imports)] that hid warnings. cargo test -p horizon-client --lib runs game/'s tests again, hook_points_stay_hookable included. entry.rs:1 no longer mentions link modes that don't exist.

Build-cost measurements

The old 43 s → 77 s and 0.17 s → 12.5 s figures were for the first version and don't apply to this one.

Same-runner comparison: upstream main bb03a6b2e against 42a5981e9, two warmed-dependency samples per revision, cleaning only the client packages before the test build.

What main bb03a6b2e this PR
Client test build (the same set of test targets, --no-run) 104.9 s 103.3 s
horizon-ctl + probe rebuild after a comment edit in gameplay 0.22 s 0.217 s
Gameplay files in the probes' Cargo dep-info 0 0

No slowdown measured. That was the condition for reconsidering it.

A local check on Windows (16 CPUs) after a comment edit in game.rs agrees: horizon-ctl + client_probe + mod_port_probe recompile nothing (1.03 s, then 0.63 s), and only the gameplay crate itself rebuilds (7.32 s).

In practice

  • Gameplay edit, e.g. a line in crates/horizon-client/src/game/combat.rs: only horizon-client rebuilds. cargo build -p horizon-client-lib --bin horizon-ctl and the probes are already up to date. Before, this edit took ctl from 0.17 s to 12.5 s.
  • Parity selection for that edit stays the same as on main, because the probes' dep-info has no gameplay files. Check it by writing crates/horizon-client/src/game/combat.rs into a file, say changed.txt, then running python3 tools/parity.py --changed-files changed.txt --list.
  • Running the game tests: cargo test -p horizon-client --lib runs game/ (e.g. hook_points_stay_hookable). cargo test -p horizon-client-lib runs the reusable client's tests, which no longer compile gameplay.
  • Mods: named hooks and horizon_client::game::… targets keep their paths, so existing native mods and the machine sample need no change.

What changes for raw mixins

A raw mixin that targets a non-gameplay module by its crate path has to name the new crate:

- horizon_client::arrows::…
+ horizon_client_lib::arrows::…

Paths under horizon_client::game::… don't change. I haven't checked third-party mods for raw paths like this.

Self-check

At f2b508c4f, Windows, stable Rust:

  • cargo test -p horizon-client --lib: 498 passed, 0 failed, 3 ignored. f2b508c4f makes loot_table_load_stays_hookable read its source independent of line endings: it searched for "\n}\n", which a CRLF checkout (core.autocrlf=true) never contains, so it also failed on unchanged main on Windows.
  • cargo clippy -p horizon-client --lib --tests -- -D warnings clean; client and reusable-library Clippy (--lib --bins --tests --examples) passed at 42a5981e9.
  • Workspace rustfmt, diff checks and the public-tree check passed. 32 focused Python tests (check planning, parity roots and aliases, parity selection) passed.
  • The full Python suite has 7 failures that also fail on unchanged main bb03a6b2e (Windows symlink, socket, Git and path environment). They aren't claimed green locally.
  • Upstream CI on the new head is pending maintainer approval. No in-game test or new screenshots claimed.

Updated by Xmilon's AI agent (Claude Code, Claude Opus 5.5): the measurements, examples and self-check above.

Latest validation after review fixes

Current head includes the contributor's CRLF-safe loot-hook test fix and compatibility for both named and broad saved parity selections (--bins/--examples), external-source feature scans, and the interaction harness helper. Focused suites: 43 parity-runner tests (1 skip), 9 reachability tests, 2 helper tests, 23 check-planning tests passed. The package layout and benchmarked Rust code remain unchanged by these Python compatibility fixes.

Fork validation at 452910ffc: verify and launcher passed (jobs). The remaining private-resource/self-hosted parity jobs are not available on this fork and are not claimed passed. Upstream checks require maintainer approval. No in-game validation is claimed for the revised layout.

🤖 Generated with Codex
🤖 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/5446 **Author:** [@Xmilon](https://github.com/Xmilon) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `native/api-mods` --- ### 📝 Commits (10+) - [`e2d8520`](https://github.com/horizon-rust/horizon/commit/e2d852088b4ce1a18a76827bc871419088b1fdb6) Windows build: the windows-sys features boot_paint uses - [`3888ac4`](https://github.com/horizon-rust/horizon/commit/3888ac4613b876ea093d8dccd2e3a1b03c8f3c2d) Native mods without mixins: API mods that never rebuild horizon-client - [`0fb2575`](https://github.com/horizon-rust/horizon/commit/0fb25759e1c39c3447c9b8d1b81d331ba44646cf) boot_paint: AddFontMemResourceEx only reads the font count - [`af806fd`](https://github.com/horizon-rust/horizon/commit/af806fd1c344c9b4a1a2a192a47f17344d2c230d) Merge upstream/main into native/api-mods - [`1e0fe9b`](https://github.com/horizon-rust/horizon/commit/1e0fe9bb79f18205ca27885288a9803a1a124253) Merge upstream/main; the game's unit tests keep their own process - [`6085115`](https://github.com/horizon-rust/horizon/commit/60851159b2cbaa3a52cb58848d83b118173e6211) Merge main into #5446 - [`022306f`](https://github.com/horizon-rust/horizon/commit/022306f5d8f9507f6d688bbe99bcc7865af3300f) refactor(client): keep the library split without the separate mod API - [`cd85269`](https://github.com/horizon-rust/horizon/commit/cd85269d5931bb8a39ad3635c9276fa21652561d) docs: correct parity selection costs after the client split - [`a303d7d`](https://github.com/horizon-rust/horizon/commit/a303d7d105d73c3367dbe52cc8246634a3c42b87) Merge upstream/main into the client library split - [`2c78a5f`](https://github.com/horizon-rust/horizon/commit/2c78a5f1b0050b252e9cedc423a8621164610ab3) Merge upstream/main before revising the client library layout ### 📊 Changes **117 files changed** (+886 additions, -375 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/game-build.yml` (+1 -1) 📝 `AGENTS.md` (+15 -8) 📝 `Cargo.lock` (+57 -0) 📝 `Cargo.toml` (+1 -0) ➕ `crates/horizon-client-lib/Cargo.toml` (+221 -0) 📝 `crates/horizon-client/Cargo.toml` (+14 -7) 📝 `crates/horizon-client/examples/chunk_load_bench.rs` (+1 -0) 📝 `crates/horizon-client/examples/gameplay_decode_profile.rs` (+1 -0) 📝 `crates/horizon-client/examples/json_load_bench.rs` (+1 -0) 📝 `crates/horizon-client/examples/mod_port_probe.rs` (+1 -0) 📝 `crates/horizon-client/examples/model_library_bench.rs` (+1 -0) 📝 `crates/horizon-client/examples/model_states_bench.rs` (+1 -0) 📝 `crates/horizon-client/examples/old_world_fixture.rs` (+1 -0) 📝 `crates/horizon-client/examples/portal_scan_bench.rs` (+1 -0) 📝 `crates/horizon-client/examples/probe/main.rs` (+1 -0) 📝 `crates/horizon-client/examples/random_tick_eligibility_bench.rs` (+1 -0) 📝 `crates/horizon-client/examples/resource_memory.rs` (+1 -0) 📝 `crates/horizon-client/examples/save_batch_bench.rs` (+1 -0) 📝 `crates/horizon-client/examples/shared_json_startup_profile.rs` (+1 -0) 📝 `crates/horizon-client/examples/sprite_cache_parity.rs` (+1 -0) _...and 80 more files_ </details> ### 📄 Description > 🤖 Opened by Xmilon's AI agent (Codex), not by Xmilon personally. ## What and why Separate gameplay from the client systems used by tools and parity probes, while keeping existing native-mod targets and game source paths stable. This revises the original split in response to the build-cost and native-staging review. - `horizon-client` owns the gameplay library, startup and thin `horizon-client` executable. - `horizon-client-lib` compiles the existing reusable sources, `horizon-ctl`, examples and core integration tests. Its manifest references existing source paths; gameplay is not a dependency. Gameplay re-exports its public modules so `horizon_client::game::...` mod targets and the game command stay unchanged. - Gameplay tests now live in the gameplay library test target, separate from reusable-library tests. The executable no longer contains a test-only copy of Game or blanket dead-code/import allowances. - Build, release, harness and contributor commands select the package that owns each target. Parity reachability supports explicit external target roots and extern-crate aliases; pr_ready maps shared source files to their actual owning package. - Pin horizon-mixins to `ddd9700b21997c95d95ac6ee5ecafe3830cf622a`, the merged fix for production cfg indexing (horizon-rust/horizon-mixins#17). The gameplay module is also unconditional in this layout. The typed no-rebuild API remains Ari's separate #5638; this PR does not claim to deliver that interface. The build measurements below show no slowdown. ## Kind - [x] tooling: tools, CI, tests, harnesses Players see no new feature; `skip-release` fits. No mod manifest/API format changes. ## Vanilla reference None: build organization only; gameplay logic is unchanged. ## Other projects' code No external implementation code copied. Validation uses the MIT-licensed horizon-mixins at `ddd9700b21997c95d95ac6ee5ecafe3830cf622a` and horizon-machine-sample at `ab2fddb1bd0d5802974124318c033c877947f027`; only the scratch sample's compatibility revision is changed to this PR's committed head. ## Why this revision exists Ludovic closed the first version because the split alone made builds slower, and levzzz's review named three things a maintainer would want before looking again. Here is each one, and where it stands at `f2b508c4f`. **1. Native mods couldn't stage (`E_MODULE`).** The first version gated `pub mod game` with `#[cfg(not(test))]`, and horizon-mixins didn't index cfg-gated modules. So a mod that injects into `game.rs`, like [horizon-machine-sample](https://github.com/arismoko/horizon-machine-sample), failed with `E_MODULE: module destination must be an indexed Rust source file`. Now `game` is unconditional, and the mixins pin moves to `ddd9700b` (horizon-rust/horizon-mixins#17, its fix for cfg-gated modules). The machine sample stages (8 injections, 1 module), and the injected `horizon-client` lib and bin compile with no warnings (`--no-default-features`). **2. Builds got slower.** Gameplay was compiled twice for the executable's tests (once in the lib, once as the bin's test copy). And every gameplay edit rebuilt `horizon-ctl` and the ~104 client probes, because they linked the lib that held gameplay. Now the reusable client is its own crate, `horizon-client-lib` (`crates/horizon-client-lib`, sources still in `crates/horizon-client/src`). It holds `horizon-ctl`, the probes, the examples and the core integration tests, and it doesn't depend on gameplay. `horizon-client` is gameplay plus a thin executable on top of it. Gameplay compiles once, and nothing the probes build includes it. **3. Smaller points.** The bin's test copy of `Game` is gone, and with it the `#[allow(dead_code, unused_imports)]` that hid warnings. `cargo test -p horizon-client --lib` runs `game/`'s tests again, `hook_points_stay_hookable` included. `entry.rs:1` no longer mentions link modes that don't exist. ## Build-cost measurements The old 43 s → 77 s and 0.17 s → 12.5 s figures were for the first version and don't apply to this one. [Same-runner comparison](https://github.com/Xmilon/horizon/actions/runs/41300526828): upstream main `bb03a6b2e` against `42a5981e9`, two warmed-dependency samples per revision, cleaning only the client packages before the test build. | What | main `bb03a6b2e` | this PR | | --- | --- | --- | | Client test build (the same set of test targets, `--no-run`) | 104.9 s | 103.3 s | | `horizon-ctl` + probe rebuild after a comment edit in gameplay | 0.22 s | 0.217 s | | Gameplay files in the probes' Cargo dep-info | 0 | 0 | **No slowdown measured.** That was the condition for reconsidering it. A local check on Windows (16 CPUs) after a comment edit in `game.rs` agrees: `horizon-ctl` + `client_probe` + `mod_port_probe` recompile nothing (1.03 s, then 0.63 s), and only the gameplay crate itself rebuilds (7.32 s). ### In practice - **Gameplay edit**, e.g. a line in `crates/horizon-client/src/game/combat.rs`: only `horizon-client` rebuilds. `cargo build -p horizon-client-lib --bin horizon-ctl` and the probes are already up to date. Before, this edit took ctl from 0.17 s to 12.5 s. - **Parity selection** for that edit stays the same as on main, because the probes' dep-info has no gameplay files. Check it by writing `crates/horizon-client/src/game/combat.rs` into a file, say `changed.txt`, then running `python3 tools/parity.py --changed-files changed.txt --list`. - **Running the game tests:** `cargo test -p horizon-client --lib` runs `game/` (e.g. `hook_points_stay_hookable`). `cargo test -p horizon-client-lib` runs the reusable client's tests, which no longer compile gameplay. - **Mods:** named hooks and `horizon_client::game::…` targets keep their paths, so existing native mods and the machine sample need no change. ### What changes for raw mixins A raw mixin that targets a non-gameplay module by its crate path has to name the new crate: ```diff - horizon_client::arrows::… + horizon_client_lib::arrows::… ``` Paths under `horizon_client::game::…` don't change. I haven't checked third-party mods for raw paths like this. ## Self-check At `f2b508c4f`, Windows, stable Rust: - `cargo test -p horizon-client --lib`: 498 passed, 0 failed, 3 ignored. `f2b508c4f` makes `loot_table_load_stays_hookable` read its source independent of line endings: it searched for `"\n}\n"`, which a CRLF checkout (`core.autocrlf=true`) never contains, so it also failed on unchanged main on Windows. - `cargo clippy -p horizon-client --lib --tests -- -D warnings` clean; client and reusable-library Clippy (`--lib --bins --tests --examples`) passed at `42a5981e9`. - Workspace rustfmt, diff checks and the public-tree check passed. 32 focused Python tests (check planning, parity roots and aliases, parity selection) passed. - The full Python suite has 7 failures that also fail on unchanged main `bb03a6b2e` (Windows symlink, socket, Git and path environment). They aren't claimed green locally. - Upstream CI on the new head is pending maintainer approval. No in-game test or new screenshots claimed. _Updated by Xmilon's AI agent (Claude Code, Claude Opus 5.5): the measurements, examples and self-check above._ ## Latest validation after review fixes Current head includes the contributor's CRLF-safe loot-hook test fix and compatibility for both named and broad saved parity selections (`--bins`/`--examples`), external-source feature scans, and the interaction harness helper. Focused suites: 43 parity-runner tests (1 skip), 9 reachability tests, 2 helper tests, 23 check-planning tests passed. The package layout and benchmarked Rust code remain unchanged by these Python compatibility fixes. Fork validation at `452910ffc`: **verify and launcher passed** ([jobs](https://github.com/Xmilon/horizon/actions/runs/41301296052)). The remaining private-resource/self-hosted parity jobs are not available on this fork and are not claimed passed. Upstream checks require maintainer approval. No in-game validation is claimed for the revised layout. 🤖 Generated with [Codex](https://openai.com/codex/) 🤖 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:17:54 +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#6293
No description provided.