[PR #1186] [MERGED] secure_chat harness: steps end on a barrier, players leave one at a time #3400

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

📋 Pull Request Information

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

Base: main ← Head: fix/secure-chat-leave-order


📝 Commits (1)

  • 3aa36f9 secure_chat harness: steps end on a barrier, players leave one at a time

📊 Changes

2 files changed (+77 additions, -5 deletions)

View changed files

📝 mods/horizon/src/test/java/dev/horizonlab/parity/SecureChatClient.java (+68 -4)
📝 tools/test_secure_chat_parity.py (+9 -1)

📄 Description

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

What

This fixes three races in the secure_chat harness. Nothing in Horizon was wrong in any of them.

  • Step bleed. Steps ended on a fixed 1.5 s sleep. On a slow run, a chat landed in the next step, and so did its broadcast, which vanilla queues as a later task. Each step now also ends on a barrier: every connected client sends random value 1..2 twice and waits for the answer. Only the sender gets that answer, and it is left out of the transcript. The old 1..1 fails in vanilla (range too small), so it can't be the barrier.
  • Leave order. The client closed every socket at once, so the server logged <name> lost connection in whatever order its network threads saw the closed connections; Alice and Carol swapped places. The players still connected now leave one at a time. Each waits until it has been told that the previous player left (PlayerList.remove broadcasts that after logging). The harness then waits for Carol's line before stopping the server.
  • Kick reason in the log. A player the server kicks (Bob, Mallory) is logged as lost connection: <reason>. Vanilla sometimes logs Disconnected instead, when its network thread closes the connection before disconnect(reason) runs. The reason sent is still compared exactly, in the transcript's <name> disconnected {...} line, so only the log line stops comparing it, and only for kicked players.

Why

This is flakes-1 flake 3: "fails while its log says the two sides are identical". The diffs were those swapped lines, a step's last lines landing in the next step, and Mallory lost connection: Disconnected against Invalid signature for profile public key.

How tested

  • tools/parity.py secure_chat --repeat 12 --fresh -j 4 --hosts "" on the desktop, while the dedicated_server and world_spawn proofs ran alongside: 12 of 12 passed (41.6 min).
  • Earlier proofs with only some of the fixes failed in each of the three ways above.
  • No Rust is touched. The Java client is compiled by the harness.

Needs Ludovic

Nothing.

🤖 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/1186 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/secure-chat-leave-order` --- ### 📝 Commits (1) - [`3aa36f9`](https://github.com/horizon-rust/horizon/commit/3aa36f95ab18ee9d13decccf79aa8cfe9f15c380) secure_chat harness: steps end on a barrier, players leave one at a time ### 📊 Changes **2 files changed** (+77 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/SecureChatClient.java` (+68 -4) 📝 `tools/test_secure_chat_parity.py` (+9 -1) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What This fixes three races in the secure_chat harness. Nothing in Horizon was wrong in any of them. - **Step bleed.** Steps ended on a fixed 1.5 s sleep. On a slow run, a chat landed in the next step, and so did its broadcast, which vanilla queues as a later task. Each step now also ends on a barrier: every connected client sends `random value 1..2` twice and waits for the answer. Only the sender gets that answer, and it is left out of the transcript. The old `1..1` fails in vanilla (range too small), so it can't be the barrier. - **Leave order.** The client closed every socket at once, so the server logged `<name> lost connection` in whatever order its network threads saw the closed connections; Alice and Carol swapped places. The players still connected now leave one at a time. Each waits until it has been told that the previous player left (`PlayerList.remove` broadcasts that after logging). The harness then waits for Carol's line before stopping the server. - **Kick reason in the log.** A player the server kicks (Bob, Mallory) is logged as `lost connection: <reason>`. Vanilla sometimes logs `Disconnected` instead, when its network thread closes the connection before `disconnect(reason)` runs. The reason sent is still compared exactly, in the transcript's `<name> disconnected {...}` line, so only the log line stops comparing it, and only for kicked players. ## Why This is flakes-1 flake 3: "fails while its log says the two sides are identical". The diffs were those swapped lines, a step's last lines landing in the next step, and `Mallory lost connection: Disconnected` against `Invalid signature for profile public key.` ## How tested - `tools/parity.py secure_chat --repeat 12 --fresh -j 4 --hosts ""` on the desktop, while the dedicated_server and world_spawn proofs ran alongside: **12 of 12 passed** (41.6 min). - Earlier proofs with only some of the fixes failed in each of the three ways above. - No Rust is touched. The Java client is compiled by the harness. ## Needs Ludovic Nothing. 🤖 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:09:16 +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#3400
No description provided.