|
| 1 | +# SLP Report Failure Tolerance Implementation Plan |
| 2 | + |
| 3 | +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. |
| 4 | +
|
| 5 | +**Goal:** Prevent Minecraft SLP ping/player-list failures from breaking daemon instance report refresh. |
| 6 | + |
| 7 | +**Architecture:** Treat Minecraft server-list ping as best-effort report enrichment. `SlpClient.GetStatusModern` should stop after an invalid status payload instead of reusing a failed connection for latency, and daemon Minecraft report generation should convert non-cancellation SLP failures into an empty player list. |
| 8 | + |
| 9 | +**Tech Stack:** C# 14, .NET 10, System.Net.Sockets, xUnit protocol tests. |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## File Structure |
| 14 | + |
| 15 | +- Modify: `MCServerLauncher.Common/Network/SlpClient.cs` |
| 16 | + - Owns modern Minecraft SLP status and latency probing. |
| 17 | +- Modify: `MCServerLauncher.Daemon/Management/Minecraft/MinecraftInstance.cs` |
| 18 | + - Owns Minecraft-specific report enrichment for online players. |
| 19 | +- Create: `MCServerLauncher.ProtocolTests/SlpClientFailureToleranceTests.cs` |
| 20 | + - Verifies invalid SLP status payloads return `null` without a follow-up latency write. |
| 21 | + |
| 22 | +## Task 1: Add SLP Failure Regression Test |
| 23 | + |
| 24 | +- [x] **Step 1: Write the failing test** |
| 25 | + |
| 26 | +Create `MCServerLauncher.ProtocolTests/SlpClientFailureToleranceTests.cs` with a loopback `TcpListener` that accepts the status request, sends an invalid/empty status response, then closes the connection. Assert `SlpClient.GetStatusModern` returns `null` instead of throwing. |
| 27 | + |
| 28 | +- [x] **Step 2: Run test to verify it fails** |
| 29 | + |
| 30 | +Run: |
| 31 | + |
| 32 | +```powershell |
| 33 | +dotnet test MCServerLauncher.ProtocolTests/MCServerLauncher.ProtocolTests.csproj -c Release --filter "FullyQualifiedName~SlpClientFailureToleranceTests" |
| 34 | +``` |
| 35 | + |
| 36 | +Expected before implementation: FAIL due `IOException` when the client tries to write the latency packet after invalid status. |
| 37 | + |
| 38 | +- [x] **Step 3: Implement minimal common-layer fix** |
| 39 | + |
| 40 | +In `SlpClient.GetStatusModern`, return `null` immediately when `GetSlpAsync` returns `null`; only call `GetLatencyAsync` after a valid status payload. |
| 41 | + |
| 42 | +- [x] **Step 4: Add daemon-side defense** |
| 43 | + |
| 44 | +In `MinecraftInstance.GetServerPlayersAsync`, let caller-requested cancellation propagate and catch other SLP/report enrichment exceptions as an empty player list. |
| 45 | + |
| 46 | +- [x] **Step 5: Verify focused test** |
| 47 | + |
| 48 | +Run: |
| 49 | + |
| 50 | +```powershell |
| 51 | +dotnet test MCServerLauncher.ProtocolTests/MCServerLauncher.ProtocolTests.csproj -c Release --filter "FullyQualifiedName~SlpClientFailureToleranceTests" |
| 52 | +``` |
| 53 | + |
| 54 | +Expected after implementation: PASS. |
| 55 | + |
| 56 | +- [x] **Step 6: Verify relevant project and hygiene** |
| 57 | + |
| 58 | +Run: |
| 59 | + |
| 60 | +```powershell |
| 61 | +dotnet build MCServerLauncher.Daemon/MCServerLauncher.Daemon.csproj /m:1 |
| 62 | +dotnet test MCServerLauncher.ProtocolTests/MCServerLauncher.ProtocolTests.csproj -c Release --no-build |
| 63 | +git diff --check |
| 64 | +``` |
| 65 | + |
| 66 | +Expected: commands exit 0. |
| 67 | + |
| 68 | +## Changelog |
| 69 | + |
| 70 | +- Added regression coverage for invalid Minecraft SLP status responses closing before latency ping. |
| 71 | +- Updated modern SLP probing to stop after invalid status payloads. |
| 72 | +- Hardened Minecraft instance report enrichment so player-list probe failures do not fail `GetAllReports`. |
0 commit comments