[PR #5329] [MERGED] horizon-server: vanilla's management protocol, its transport (JSON-RPC over a WebSocket) #6214

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

📋 Pull Request Information

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

Base: main ← Head: server-admin/management-transport


📝 Commits (1)

  • 65a8b2a horizon-server: vanilla's management protocol, its transport (JSON-RPC over a WebSocket)

📊 Changes

13 files changed (+1317 additions, -10 deletions)

View changed files

📝 Cargo.lock (+3 -0)
📝 crates/horizon-server/Cargo.toml (+5 -0)
📝 crates/horizon-server/src/http.rs (+12 -7)
📝 crates/horizon-server/src/main.rs (+3 -0)
➕ crates/horizon-server/src/management.rs (+564 -0)
➕ crates/horizon-server/src/management_schema.rs (+196 -0)
📝 crates/horizon-server/src/supervisor.rs (+7 -0)
➕ crates/horizon-server/src/websocket.rs (+217 -0)
📝 docs/api/server.md (+6 -0)
📝 docs/hosting.md (+20 -0)
📝 docs/server.md (+12 -3)
📝 tests/test_game_home.py (+1 -0)
➕ tools/test_management_protocol_parity.py (+271 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Roadmap server-admin, part 6a: vanilla's management protocol (JSON-RPC over a WebSocket, the management-server-* keys in server.properties), its transport. With it, tools written for a vanilla 26.3 server can connect to a Horizon server. This PR adds the transport and rpc.discover. The methods follow in 6b, stacked on this PR.

  • The supervisor serves the protocol (management.rs), so it keeps answering while the game restarts. The WebSocket (websocket.rs) uses std only, like http.rs: RFC 6455 accept key, masked client frames, continuation frames aggregated up to 64 KiB as vanilla's WebSocketFrameAggregator(65536), ping/pong, close echo.
  • Authentication follows AuthenticationHandler:
    • Authorization: Bearer <secret>;
    • or Sec-WebSocket-Protocol: minecraft-v1,<secret>, from an Origin listed in management-server-allowed-origins.
    • The 401 bodies are vanilla's (Missing API key, Invalid API key, Origin Not Allowed).
  • Settings follow vanilla:
    • Without management-server-secret, a 40-character secret is generated and written to server.toml [properties].
    • A secret that isn't 40 alphanumerics stops the start with vanilla's message.
    • TLS is on by default (as in vanilla) and isn't built yet, so the server refuses to start until it gets management-server-tls-enabled = false. A later PR adds TLS.
  • JSON-RPC follows Connection:
    • errors -32700 to -32603 with vanilla's messages;
    • notifications get no reply; "id": null does;
    • a batch gets one reply per request;
    • by-name or one-element-array params; method names parsed as identifiers (minecraft: by default);
    • the pre-init check comes before the params check.
  • rpc.discover returns vanilla's OpenRPC document. management_schema.rs holds 89 methods and 14 schemas, generated from the data generator's json-rpc-api-schema.json. Every other method answers an internal error saying it isn't in Horizon yet.
  • Off by default (management-server-enabled=false, as in vanilla). It binds localhost unless the owner sets management-server-host.

Parity harness. tools/test_management_protocol_parity.py starts vanilla 26.3's dedicated server and Horizon's with the same keys and sends both the same 15 messages and 4 handshakes. It compares the answers (20 exchanges), and compares rpc.discover with the report. Vanilla's own notifications (server/started, saving, saved) can arrive between replies; the harness sets them aside until a later PR sends them too. Passed against the real 26.3 server on the Mac mini.

Size: +1317 −10, over the 500-line guideline. Most of it is:

  • ~250 lines of tests;
  • the 271-line harness;
  • the 196-line generated schema table.

The protocol code itself is management.rs (≈330 lines without tests) and websocket.rs (≈150).

Docs: docs/hosting.md (new section "Tools written for vanilla's management protocol"), docs/server.md section 8, docs/api/server.md.

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at b8cf85f8c). The full run would have run 278 harnesses, because Cargo.lock changed (sha1, base64, horizon-core for horizon-server), so CI's parity job runs them. pr_ready's workspace test step stopped without printing a result, so I ran the touched crate by hand.

Check Result
Scope ⚠️ 13 files, +1317 −10 (see above)
Cargo.lock ⚠️ changed: sha1, base64 and horizon-core added to horizon-server (all three already in the lock)
Public tree ✅
Python tests ❌ 1 error: test_perf_bench.test_table_distinguishes_missing_scene_load_from_zero. It fails the same way on main at b8cf85f8c and is unrelated to this PR. test_game_home passes with the harness listed in EXEMPT
rustfmt ✅ (16 s)
clippy ✅ (5 min 16 s)
tests: horizon-server (cargo test --locked -p horizon-server) ✅ 77 passed
Parity ➖ --quick; test_management_protocol_parity.py passed by hand (20 exchanges)

🤖 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/5329 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `server-admin/management-transport` --- ### 📝 Commits (1) - [`65a8b2a`](https://github.com/horizon-rust/horizon/commit/65a8b2aff0699437923a13cff45c7c745d4657cd) horizon-server: vanilla's management protocol, its transport (JSON-RPC over a WebSocket) ### 📊 Changes **13 files changed** (+1317 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+3 -0) 📝 `crates/horizon-server/Cargo.toml` (+5 -0) 📝 `crates/horizon-server/src/http.rs` (+12 -7) 📝 `crates/horizon-server/src/main.rs` (+3 -0) ➕ `crates/horizon-server/src/management.rs` (+564 -0) ➕ `crates/horizon-server/src/management_schema.rs` (+196 -0) 📝 `crates/horizon-server/src/supervisor.rs` (+7 -0) ➕ `crates/horizon-server/src/websocket.rs` (+217 -0) 📝 `docs/api/server.md` (+6 -0) 📝 `docs/hosting.md` (+20 -0) 📝 `docs/server.md` (+12 -3) 📝 `tests/test_game_home.py` (+1 -0) ➕ `tools/test_management_protocol_parity.py` (+271 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Roadmap `server-admin`, part 6a: vanilla's management protocol (JSON-RPC over a WebSocket, the `management-server-*` keys in server.properties), its transport. With it, tools written for a vanilla 26.3 server can connect to a Horizon server. This PR adds the transport and `rpc.discover`. The methods follow in 6b, stacked on this PR. - The supervisor serves the protocol (`management.rs`), so it keeps answering while the game restarts. The WebSocket (`websocket.rs`) uses std only, like `http.rs`: RFC 6455 accept key, masked client frames, continuation frames aggregated up to 64 KiB as vanilla's `WebSocketFrameAggregator(65536)`, ping/pong, close echo. - Authentication follows `AuthenticationHandler`: - `Authorization: Bearer <secret>`; - or `Sec-WebSocket-Protocol: minecraft-v1,<secret>`, from an Origin listed in `management-server-allowed-origins`. - The 401 bodies are vanilla's (`Missing API key`, `Invalid API key`, `Origin Not Allowed`). - Settings follow vanilla: - Without `management-server-secret`, a 40-character secret is generated and written to server.toml `[properties]`. - A secret that isn't 40 alphanumerics stops the start with vanilla's message. - TLS is on by default (as in vanilla) and isn't built yet, so the server refuses to start until it gets `management-server-tls-enabled = false`. A later PR adds TLS. - JSON-RPC follows `Connection`: - errors -32700 to -32603 with vanilla's messages; - notifications get no reply; `"id": null` does; - a batch gets one reply per request; - by-name or one-element-array params; method names parsed as identifiers (`minecraft:` by default); - the pre-init check comes before the params check. - `rpc.discover` returns vanilla's OpenRPC document. `management_schema.rs` holds 89 methods and 14 schemas, generated from the data generator's `json-rpc-api-schema.json`. Every other method answers an internal error saying it isn't in Horizon yet. - Off by default (`management-server-enabled=false`, as in vanilla). It binds `localhost` unless the owner sets `management-server-host`. **Parity harness.** `tools/test_management_protocol_parity.py` starts vanilla 26.3's dedicated server and Horizon's with the same keys and sends both the same 15 messages and 4 handshakes. It compares the answers (20 exchanges), and compares `rpc.discover` with the report. Vanilla's own notifications (`server/started`, `saving`, `saved`) can arrive between replies; the harness sets them aside until a later PR sends them too. Passed against the real 26.3 server on the Mac mini. Size: +1317 −10, over the 500-line guideline. Most of it is: - ~250 lines of tests; - the 271-line harness; - the 196-line generated schema table. The protocol code itself is `management.rs` (≈330 lines without tests) and `websocket.rs` (≈150). Docs: docs/hosting.md (new section "Tools written for vanilla's management protocol"), docs/server.md section 8, docs/api/server.md. **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at b8cf85f8c). The full run would have run 278 harnesses, because Cargo.lock changed (sha1, base64, horizon-core for horizon-server), so CI's parity job runs them. pr_ready's workspace test step stopped without printing a result, so I ran the touched crate by hand. | Check | Result | | --- | --- | | Scope | ⚠️ 13 files, +1317 −10 (see above) | | Cargo.lock | ⚠️ changed: `sha1`, `base64` and `horizon-core` added to horizon-server (all three already in the lock) | | Public tree | ✅ | | Python tests | ❌ 1 error: `test_perf_bench.test_table_distinguishes_missing_scene_load_from_zero`. It fails the same way on main at b8cf85f8c and is unrelated to this PR. `test_game_home` passes with the harness listed in EXEMPT | | rustfmt | ✅ (16 s) | | clippy | ✅ (5 min 16 s) | | tests: horizon-server (`cargo test --locked -p horizon-server`) | ✅ 77 passed | | Parity | ➖ `--quick`; `test_management_protocol_parity.py` passed by hand (20 exchanges) | 🤖 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:57 +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#6214
No description provided.