[PR #2114] [MERGED] parity: server harnesses wait on the server's clock, not on sleeps #4016

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

📋 Pull Request Information

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

Base: main ← Head: fix/harness-await-flakes


📝 Commits (2)

  • 34d8d94 parity: server harnesses wait on the server's clock and replies, not on sleeps
  • 5d04a5b Merge remote-tracking branch 'origin/main' into fix/harness-await-flakes

📊 Changes

5 files changed (+225 additions, -86 deletions)

View changed files

📝 mods/horizon/src/test/java/dev/horizonlab/parity/KnockbackClient.java (+40 -1)
📝 tools/test_dedicated_server_parity.py (+14 -1)
📝 tools/test_locator_bar_parity.py (+67 -35)
📝 tools/test_server_dimension_players_parity.py (+20 -28)
📝 tools/test_server_knockback_parity.py (+84 -21)

📄 Description

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

What

The server harnesses server_knockback, locator_bar, server_dimension_players (and every harness that goes through locator_bar.one_player: cursor_death, hardcore_respawn, pearl_death) no longer end a step with a wall-clock sleep. A step ends the way server_player_targets already does it: every script line has run (a sync round trip), the server's game clock has advanced N ticks, and each client holds what the server sent (a last sync). A server that stalls under load still gets all its ticks inside the step, so its packets are filed under the right step. dedicated_server waits for the player's leaving before /list instead of sleep 1.

Why

Parity jobs cost 30-70 min and one flaky harness makes the merger stop a PR and rerun the whole job (#1996, #1765: server_knockback; also dedicated_server, locator_bar, server_dimension_players). #1997 fixed server_ops_feedback the same way.

How

  • tools/test_dedicated_server_parity.py: wait_ticks(server, n) (the server's game clock, via the console's time query gametime, like settle); /list waits for "Tester left the game".
  • tools/test_locator_bar_parity.py: a Client class (the LocatorBarClient process: tell, sync, wait, end); run_side and one_player use it. The client's existing sync command is the round trip.
  • tools/test_server_dimension_players_parity.py: the same; the half-step still is kept (sync, 50 ticks, still, sync, 50 ticks).
  • tools/test_server_knockback_parity.py + KnockbackClient.java (gets the same sync command): ticks N, and for the frozen section frozen (the clock reads the same twice), tickstep (one /tick step that has run: the clock moved) and hit (a frozen server still ticks its players, so a hit lands in Alice's next tick, not when the packet arrives; the mob's motion, asked from the console, says when it has). The one gap that is an upper bound (the two hits of pvp-cooldown) stays a 0.2 s sleep: a stalled server gets fewer ticks in it, which keeps the second hit inside the hurt cooldown.

The oracle's transcript does not change: the compared lines of vanilla's knockback run are identical before and after (21 cases, 442 lines).

Proof

I stalled the server of each harness (SIGSTOP/SIGCONT of its own PID, for a random 0.5-1.5x of the stall length every ~gap seconds), the old and the new harness side by side:

Harness Stall / gap Old (origin/main) New
server_knockback 0.5 s / 3 s (~120 stalls) FAILED: 9 of 21 cases differ (one-sample shifts, the hit not landed at its first data get) passed 5 of 5 (118-136 stalls each)
locator_bar 2.5 s / 5 s FAILED (blue-team, moves-without packets filed under the wrong step) passed (1 run, and the 0.5 s / 3 s stalls before)
server_dimension_players 5.5 s / 10 s FAILED (Alice added in bob-back-again instead of the step before) passed (1 run, and the 0.5 s / 3 s stalls before)

Without stalls the old and new knockback harnesses both pass 5 of 5 (the Mac mini at load 40+, in two of the rounds with 24 busy loops added), so a stall is what the flake needs, as in CI.

dedicated_server: the /list race (the server had not handled the client's leaving after 1 s) is fixed by reading; I could not make the old version fail on it. Under 2 s stalls even the new one failed in the Java client's own wall-clock steps (VanillaProtocolClient's 1.5 s stepAt timers: a play-respawn entity and a furnace content packet came in another shape). That machine is a follow-up, not part of this PR.

Self-check

pr_ready (on origin/main 57c5f8129, before the merge of main below): Public tree pass; Parity: 20 affected, 20 passed (56 min). Python tests: 2 errors in tests/test_parity_runner.py / tests/test_rust_parity.py, which this PR does not touch: macOS's /private/var temp-dir symlink, and java not found (exit 127) in the runner test's environment.
After merging main (b66861c72): server_dimension_players (50 lines identical, with main's new bob-retarget steps) and dedicated_server (602 lines identical) rerun and pass.

🤖 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/2114 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/harness-await-flakes` --- ### 📝 Commits (2) - [`34d8d94`](https://github.com/horizon-rust/horizon/commit/34d8d94022e0deaa84f27f4c6108804434f601da) parity: server harnesses wait on the server's clock and replies, not on sleeps - [`5d04a5b`](https://github.com/horizon-rust/horizon/commit/5d04a5bee8ce45cf09ef969c4ba5ef09ff23c935) Merge remote-tracking branch 'origin/main' into fix/harness-await-flakes ### 📊 Changes **5 files changed** (+225 additions, -86 deletions) <details> <summary>View changed files</summary> 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/KnockbackClient.java` (+40 -1) 📝 `tools/test_dedicated_server_parity.py` (+14 -1) 📝 `tools/test_locator_bar_parity.py` (+67 -35) 📝 `tools/test_server_dimension_players_parity.py` (+20 -28) 📝 `tools/test_server_knockback_parity.py` (+84 -21) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What The server harnesses `server_knockback`, `locator_bar`, `server_dimension_players` (and every harness that goes through `locator_bar.one_player`: `cursor_death`, `hardcore_respawn`, `pearl_death`) no longer end a step with a wall-clock `sleep`. A step ends the way `server_player_targets` already does it: every script line has run (a `sync` round trip), the server's game clock has advanced N ticks, and each client holds what the server sent (a last `sync`). A server that stalls under load still gets all its ticks inside the step, so its packets are filed under the right step. `dedicated_server` waits for the player's leaving before `/list` instead of `sleep 1`. ## Why Parity jobs cost 30-70 min and one flaky harness makes the merger stop a PR and rerun the whole job (#1996, #1765: `server_knockback`; also `dedicated_server`, `locator_bar`, `server_dimension_players`). #1997 fixed `server_ops_feedback` the same way. ## How - `tools/test_dedicated_server_parity.py`: `wait_ticks(server, n)` (the server's game clock, via the console's `time query gametime`, like `settle`); `/list` waits for "Tester left the game". - `tools/test_locator_bar_parity.py`: a `Client` class (the LocatorBarClient process: `tell`, `sync`, `wait`, `end`); `run_side` and `one_player` use it. The client's existing `sync` command is the round trip. - `tools/test_server_dimension_players_parity.py`: the same; the half-step `still` is kept (sync, 50 ticks, `still`, sync, 50 ticks). - `tools/test_server_knockback_parity.py` + `KnockbackClient.java` (gets the same `sync` command): `ticks N`, and for the frozen section `frozen` (the clock reads the same twice), `tickstep` (one `/tick step` that has run: the clock moved) and `hit` (a frozen server still ticks its players, so a hit lands in Alice's next tick, not when the packet arrives; the mob's motion, asked from the console, says when it has). The one gap that is an upper bound (the two hits of `pvp-cooldown`) stays a 0.2 s sleep: a stalled server gets fewer ticks in it, which keeps the second hit inside the hurt cooldown. The oracle's transcript does not change: the compared lines of vanilla's knockback run are identical before and after (21 cases, 442 lines). ## Proof I stalled the server of each harness (SIGSTOP/SIGCONT of its own PID, for a random 0.5-1.5x of the stall length every ~gap seconds), the old and the new harness side by side: | Harness | Stall / gap | Old (origin/main) | New | | --- | --- | --- | --- | | server_knockback | 0.5 s / 3 s (~120 stalls) | FAILED: 9 of 21 cases differ (one-sample shifts, the hit not landed at its first `data get`) | passed 5 of 5 (118-136 stalls each) | | locator_bar | 2.5 s / 5 s | FAILED (`blue-team`, `moves-without` packets filed under the wrong step) | passed (1 run, and the 0.5 s / 3 s stalls before) | | server_dimension_players | 5.5 s / 10 s | FAILED (`Alice` added in `bob-back-again` instead of the step before) | passed (1 run, and the 0.5 s / 3 s stalls before) | Without stalls the old and new knockback harnesses both pass 5 of 5 (the Mac mini at load 40+, in two of the rounds with 24 busy loops added), so a stall is what the flake needs, as in CI. `dedicated_server`: the `/list` race (the server had not handled the client's leaving after 1 s) is fixed by reading; I could not make the old version fail on it. Under 2 s stalls even the new one failed in the Java client's own wall-clock steps (`VanillaProtocolClient`'s 1.5 s `stepAt` timers: a `play-respawn` entity and a furnace `content` packet came in another shape). That machine is a follow-up, not part of this PR. ## Self-check pr_ready (on origin/main 57c5f8129, before the merge of main below): Public tree pass; Parity: 20 affected, 20 passed (56 min). Python tests: 2 errors in `tests/test_parity_runner.py` / `tests/test_rust_parity.py`, which this PR does not touch: macOS's `/private/var` temp-dir symlink, and `java` not found (exit 127) in the runner test's environment. After merging main (b66861c72): `server_dimension_players` (50 lines identical, with main's new bob-retarget steps) and `dedicated_server` (602 lines identical) rerun and pass. 🤖 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:14:03 +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#4016
No description provided.