[PR #1529] [MERGED] dedicated_server parity: the client re-sends its position as vanilla's does (fixes the 1-in-3 flake) #3564

Closed
opened 2026-11-03 04:10:27 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/ds-parity-flake


📝 Commits (1)

  • 574e3ca dedicated_server parity: the client re-sends its position as vanilla's does

📊 Changes

3 files changed (+54 additions, -7 deletions)

View changed files

📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaProtocolClient.java (+15 -0)
📝 tools/parity.py (+12 -2)
📝 tools/test_dedicated_server_parity.py (+27 -5)

📄 Description

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

What

tools/test_dedicated_server_parity.py failed about 1 CI run in 3 (#1426 run 39922795317, #1469 and #1466 before their reruns). Each failure was the same diff on Horizon's side, not a timeout. A passing run also takes about 195 s here:

-play-trade villager true
-play-trade open 1 minecraft:merchant {...}
-play-trade offers 1 2 1 true true | ...
+play-trade villager false

(from the three runs' parity-logs artifacts). The protocol client never got the villager it trades with.

Why

  • A server pairs a player with an entity only once the entity's chunk has been sent to that player. It checks again only when either of them moves (vanilla ChunkMap.move / TrackedEntity.updatePlayers; Horizon's lan::entity::Entities::tick does the same).
  • VanillaProtocolClient sent its position once, at the spawn teleport, and then never again.
  • Horizon places the guest at the end of tick P and sends the first chunk batch at P+2. The batch goes after the first tick's packets, in vanilla's order, which the harness compares. Normally the client answers ~13 ticks later, after the batch, so the villager is paired.
  • When a busy machine holds Horizon's tick thread back right after the join, the network thread has already queued the client's PosRot. Tick P+1 then handles it before the villager's chunk is sent, and with no later move the villager is never paired.
  • Vanilla's side passes because it ignores moves until PlayerLoaded, and the villager enters tracking only after its chunk has gone out.
  • The real 26.3 client re-sends its position every 20 ticks even standing still (LocalPlayer.sendPosition), with a ServerboundClientTickEnd every tick (Minecraft.tick). Against a real client, either server pairs the entity within a second. There is no player-facing bug, only a harness client less faithful than the game's.

How

  • VanillaProtocolClient: from the time it is loaded until its death, it sends ClientTickEnd + Pos (where it stands) every second, as the 26.3 client does. The tick end comes first because a server accepts one position per client tick. This applies to the dedicated-server flow only. The entity mode (server_entities, server_dragon) summons its scene after the chunks arrived and doesn't need it.
  • Failure output:
    • On a transcript diff, the harness adds the servers' and clients' warnings, errors, panics and disconnect reasons to its message.
    • When the client process fails, it shows the client log's tail.
    • tools/parity.py's summary prints the last 30 lines of the first 10 failing harnesses' logs, so CI shows why instead of only a path.

Proof (Mac mini, busy machine, 3 runs at once)

The Horizon side of the harness was run by a driver (not committed) that reuses the harness's run_side on the generated world:

original client fixed client
normal load 21/21 pass (no failure without a stall) 21/21 pass
tick thread stalled ~1.2 s right after the join (locate biome sent to the console on the "logged in" line), the CI condition 0/21 (play-trade villager false, CI's diff) 21/21

Debug timeline (temporary prints, not committed):

  • Normal run: placed at tick 268, first batch at 270, client's move at 281: paired.
  • Stalled run: the client's PosRot was queued during the stall and handled at P+1. The batch went out at P+2 and the villager was never sent.

Full harnesses with the fix, at the same time as the 21 runs above:

  • test_dedicated_server_parity.py 3/3 pass (601–603 transcript lines identical)
  • test_server_entities_parity.py pass
  • test_server_dragon_parity.py pass

No Rust changed, so fmt and clippy are unaffected.

Noticed, not changed

Horizon's Hub::move_player handles moves sent before ServerboundPlayerLoaded. Vanilla's handleMovePlayer drops them (hasClientLoaded). That's a separate divergence; changing it would move LAN behaviour and isn't needed here.

Needs Ludovic

Only the merge.

🤖 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/1529 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/23/2026 **Status:** ✅ Merged **Merged:** 10/24/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/ds-parity-flake` --- ### 📝 Commits (1) - [`574e3ca`](https://github.com/horizon-rust/horizon/commit/574e3ca567fcdbef23818e767ba1357345a0e199) dedicated_server parity: the client re-sends its position as vanilla's does ### 📊 Changes **3 files changed** (+54 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaProtocolClient.java` (+15 -0) 📝 `tools/parity.py` (+12 -2) 📝 `tools/test_dedicated_server_parity.py` (+27 -5) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What `tools/test_dedicated_server_parity.py` failed about 1 CI run in 3 (#1426 run 39922795317, #1469 and #1466 before their reruns). Each failure was the same diff on Horizon's side, not a timeout. A passing run also takes about 195 s here: ``` -play-trade villager true -play-trade open 1 minecraft:merchant {...} -play-trade offers 1 2 1 true true | ... +play-trade villager false ``` (from the three runs' `parity-logs` artifacts). The protocol client never got the villager it trades with. ## Why - A server pairs a player with an entity only once the entity's chunk has been sent to that player. It checks again only when either of them moves (vanilla `ChunkMap.move` / `TrackedEntity.updatePlayers`; Horizon's `lan::entity::Entities::tick` does the same). - `VanillaProtocolClient` sent its position once, at the spawn teleport, and then never again. - Horizon places the guest at the end of tick P and sends the first chunk batch at P+2. The batch goes after the first tick's packets, in vanilla's order, which the harness compares. Normally the client answers ~13 ticks later, after the batch, so the villager is paired. - When a busy machine holds Horizon's tick thread back right after the join, the network thread has already queued the client's PosRot. Tick P+1 then handles it before the villager's chunk is sent, and with no later move the villager is never paired. - Vanilla's side passes because it ignores moves until PlayerLoaded, and the villager enters tracking only after its chunk has gone out. - The real 26.3 client re-sends its position every 20 ticks even standing still (`LocalPlayer.sendPosition`), with a `ServerboundClientTickEnd` every tick (`Minecraft.tick`). Against a real client, either server pairs the entity within a second. There is no player-facing bug, only a harness client less faithful than the game's. ## How - **`VanillaProtocolClient`**: from the time it is loaded until its death, it sends `ClientTickEnd` + `Pos` (where it stands) every second, as the 26.3 client does. The tick end comes first because a server accepts one position per client tick. This applies to the dedicated-server flow only. The entity mode (`server_entities`, `server_dragon`) summons its scene after the chunks arrived and doesn't need it. - **Failure output**: - On a transcript diff, the harness adds the servers' and clients' warnings, errors, panics and disconnect reasons to its message. - When the client process fails, it shows the client log's tail. - `tools/parity.py`'s summary prints the last 30 lines of the first 10 failing harnesses' logs, so CI shows why instead of only a path. ## Proof (Mac mini, busy machine, 3 runs at once) The Horizon side of the harness was run by a driver (not committed) that reuses the harness's `run_side` on the generated world: | | original client | fixed client | |---|---|---| | normal load | 21/21 pass (no failure without a stall) | 21/21 pass | | tick thread stalled ~1.2 s right after the join (`locate biome` sent to the console on the "logged in" line), the CI condition | **0/21** (`play-trade villager false`, CI's diff) | **21/21** | Debug timeline (temporary prints, not committed): - Normal run: placed at tick 268, first batch at 270, client's move at 281: paired. - Stalled run: the client's PosRot was queued during the stall and handled at P+1. The batch went out at P+2 and the villager was never sent. Full harnesses with the fix, at the same time as the 21 runs above: - `test_dedicated_server_parity.py` 3/3 pass (601–603 transcript lines identical) - `test_server_entities_parity.py` pass - `test_server_dragon_parity.py` pass No Rust changed, so fmt and clippy are unaffected. ## Noticed, not changed Horizon's `Hub::move_player` handles moves sent before `ServerboundPlayerLoaded`. Vanilla's `handleMovePlayer` drops them (`hasClientLoaded`). That's a separate divergence; changing it would move LAN behaviour and isn't needed here. ## Needs Ludovic Only the merge. 🤖 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 04:10:27 +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#3564
No description provided.