[PR #7121] [MERGED] horizon-server: management protocol notifications, server/started and server/stopping #7353

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7121
Author: @Akirabane
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: feat/management-notifications


📝 Commits (1)

  • f193527 horizon-server: the management protocol pushes notifications, starting with server/started and server/stopping

📊 Changes

6 files changed (+230 additions, -8 deletions)

View changed files

📝 crates/horizon-server/src/api.rs (+3 -0)
📝 crates/horizon-server/src/management.rs (+209 -3)
📝 crates/horizon-server/src/supervisor.rs (+7 -0)
📝 docs/api/server.md (+3 -2)
📝 docs/server.md (+5 -1)
📝 tools/test_management_protocol_parity.py (+3 -2)

📄 Description

🤖 Opened by both Akirabane's AI agent (Claude Code), and Akirabane Himself after his review.

Refs #7118 (step 1 of 4).

What was wrong

Vanilla 26.3's management protocol pushes notifications to every connected client (JsonRpcNotificationService). Horizon serves the protocol but never sent one, so a client that only listens (a panel, a bot) learns nothing about the server starting or stopping.

What changed

  • management.rs: the supervisor keeps the connections that have upgraded (Clients, on Shared) and a queue with one thread that writes each notification to all of them. The game's output pump and the supervisor only push on the queue, so a slow client never holds the game's stdout. A notification is a JSON-RPC request without an id, with its one parameter in an array, as JsonRPCUtils.createRequest writes it ({"jsonrpc":"2.0","method":"minecraft:notification/server/started"}).
  • server/started: at the game's Done line. Vanilla sends it in DedicatedServer.initServer, after Done and after the GS4 and RCON listeners start; Horizon's listeners belong to the supervisor, so Done is the closest point it sees.
  • server/stopping: when the supervisor begins a stop or a restart, or when the game's own stop logs Stopping server. Vanilla sends it first of all in DedicatedServer.stopServer, before MinecraftServer.stopServer logs that line. One per run of the game, whichever of the two comes first.
  • Docs: docs/server.md section 8, docs/api/server.md; the parity script's docstring.

Vanilla classes followed: net.minecraft.server.jsonrpc.JsonRpcNotificationService, JsonRPCUtils.createRequest, ManagementServer (connections), OutgoingRpcMethod$Notification, net.minecraft.server.dedicated.DedicatedServer (initServer, stopServer).

How it was checked

  • Three new unit tests in management.rs: two clients on real sockets both get the exact frames (started, stopping once per run, a notification with a parameter), a client that leaves is dropped from the registry, every notification sent is one rpc.discover lists, and with no management server a notification goes nowhere.
  • cargo test -p horizon-server management: 12 passed. cargo fmt and cargo clippy -p horizon-server --all-targets -- -D warnings are clean.

Not tested: no run against a real vanilla server (tools/test_management_protocol_parity.py runs on the maintainers' machines; it still sets the notifications aside and now records their names in its report), no real server with a client connected, and tools/pr_ready.py was not run (only the three commands above, on the one crate this touches).

Next

Step 2 of #7118: server/saving, server/saved, players/joined, players/left.


🔄 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/7121 **Author:** [@Akirabane](https://github.com/Akirabane) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/management-notifications` --- ### 📝 Commits (1) - [`f193527`](https://github.com/horizon-rust/horizon/commit/f193527cdc4e87d478587d69caeb30047a297ce5) horizon-server: the management protocol pushes notifications, starting with server/started and server/stopping ### 📊 Changes **6 files changed** (+230 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-server/src/api.rs` (+3 -0) 📝 `crates/horizon-server/src/management.rs` (+209 -3) 📝 `crates/horizon-server/src/supervisor.rs` (+7 -0) 📝 `docs/api/server.md` (+3 -2) 📝 `docs/server.md` (+5 -1) 📝 `tools/test_management_protocol_parity.py` (+3 -2) </details> ### 📄 Description > 🤖 Opened by both Akirabane's AI agent (Claude Code), and Akirabane Himself after his review. Refs #7118 (step 1 of 4). ## What was wrong Vanilla 26.3's management protocol pushes notifications to every connected client (`JsonRpcNotificationService`). Horizon serves the protocol but never sent one, so a client that only listens (a panel, a bot) learns nothing about the server starting or stopping. ## What changed - `management.rs`: the supervisor keeps the connections that have upgraded (`Clients`, on `Shared`) and a queue with one thread that writes each notification to all of them. The game's output pump and the supervisor only push on the queue, so a slow client never holds the game's stdout. A notification is a JSON-RPC request without an `id`, with its one parameter in an array, as `JsonRPCUtils.createRequest` writes it (`{"jsonrpc":"2.0","method":"minecraft:notification/server/started"}`). - `server/started`: at the game's `Done` line. Vanilla sends it in `DedicatedServer.initServer`, after `Done` and after the GS4 and RCON listeners start; Horizon's listeners belong to the supervisor, so `Done` is the closest point it sees. - `server/stopping`: when the supervisor begins a stop or a restart, or when the game's own `stop` logs `Stopping server`. Vanilla sends it first of all in `DedicatedServer.stopServer`, before `MinecraftServer.stopServer` logs that line. One per run of the game, whichever of the two comes first. - Docs: `docs/server.md` section 8, `docs/api/server.md`; the parity script's docstring. Vanilla classes followed: `net.minecraft.server.jsonrpc.JsonRpcNotificationService`, `JsonRPCUtils.createRequest`, `ManagementServer` (`connections`), `OutgoingRpcMethod$Notification`, `net.minecraft.server.dedicated.DedicatedServer` (`initServer`, `stopServer`). ## How it was checked - Three new unit tests in `management.rs`: two clients on real sockets both get the exact frames (`started`, `stopping` once per run, a notification with a parameter), a client that leaves is dropped from the registry, every notification sent is one `rpc.discover` lists, and with no management server a notification goes nowhere. - `cargo test -p horizon-server management`: 12 passed. `cargo fmt` and `cargo clippy -p horizon-server --all-targets -- -D warnings` are clean. Not tested: no run against a real vanilla server (`tools/test_management_protocol_parity.py` runs on the maintainers' machines; it still sets the notifications aside and now records their names in its report), no real server with a client connected, and `tools/pr_ready.py` was not run (only the three commands above, on the one crate this touches). ## Next Step 2 of #7118: `server/saving`, `server/saved`, `players/joined`, `players/left`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:38:11 +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#7353
No description provided.