From c5678ce8776bc601be42bdcfcc075f53e4834c90 Mon Sep 17 00:00:00 2001 From: Josh Creek <8179928+jcreek@users.noreply.github.com> Date: Tue, 1 Sep 2026 08:24:33 +0100 Subject: [PATCH] fix: pass Godot 4.7 multiplayer test suite --- Game/scripts/control_plane_client.gd | 2 +- Game/scripts/matchmaking_state.gd | 10 +++++----- Game/scripts/server_config.gd | 2 +- Game/tests/cases/test_matchmaking_state.gd | 9 +++++---- multiplayer-todo.md | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Game/scripts/control_plane_client.gd b/Game/scripts/control_plane_client.gd index 63969bcc..93907ce1 100644 --- a/Game/scripts/control_plane_client.gd +++ b/Game/scripts/control_plane_client.gd @@ -340,7 +340,7 @@ func _handle_websocket_packet(packet: PackedByteArray) -> void: _on_resync_required(String(event["resource_id"])) -func _valid_websocket_event(event: Dictionary) -> bool: +static func _valid_websocket_event(event: Dictionary) -> bool: if not event.has("event") or not event["event"] is String or String(event["event"]).is_empty(): return false if not event.has("revision") or not (event["revision"] is int or event["revision"] is float): diff --git a/Game/scripts/matchmaking_state.gd b/Game/scripts/matchmaking_state.gd index 52443e87..919ab656 100644 --- a/Game/scripts/matchmaking_state.gd +++ b/Game/scripts/matchmaking_state.gd @@ -45,21 +45,21 @@ func begin_queue(new_ticket_id: String, new_playlist: String) -> bool: func apply_ticket_update(update: Dictionary) -> bool: if not _has_string(update, "ticket_id") or not update.has("revision") or not update.has("state"): - return _request_resync(ticket_id) + return _request_resync(self.ticket_id) if ticket_id.is_empty() or String(update["ticket_id"]) != ticket_id: - return _request_resync(ticket_id) + return _request_resync(self.ticket_id) var incoming_revision := int(update["revision"]) if incoming_revision < revision: return false if incoming_revision == revision: if _ticket_differs(update): - return _request_resync(ticket_id) + return _request_resync(self.ticket_id) return true if incoming_revision > revision + 1: - return _request_resync(ticket_id) + return _request_resync(self.ticket_id) var incoming_state := String(update["state"]) if not _is_ticket_state(incoming_state): - return _request_resync(ticket_id) + return _request_resync(self.ticket_id) revision = incoming_revision phase = incoming_state if update.has("playlist"): diff --git a/Game/scripts/server_config.gd b/Game/scripts/server_config.gd index f5d4fba7..14a61eb7 100644 --- a/Game/scripts/server_config.gd +++ b/Game/scripts/server_config.gd @@ -262,7 +262,7 @@ func _validate() -> void: errors.append("--arena-rotation must be sequential or random, got '%s'" % rotation) if bool(values["allocated-mode"]): for key in ["match-id", "server-id", "playlist-version", "client-build", "assignment-expiry-unix", "server-image-digest", "transport", "region"]: - if String(values[key]).is_empty(): + if str(values[key]).is_empty(): errors.append("--allocated-mode requires --%s" % key) if int(values["assignment-expiry-unix"]) <= int(Time.get_unix_time_from_system()): errors.append("--assignment-expiry-unix must be in the future") diff --git a/Game/tests/cases/test_matchmaking_state.gd b/Game/tests/cases/test_matchmaking_state.gd index 440848e2..4d176cf4 100644 --- a/Game/tests/cases/test_matchmaking_state.gd +++ b/Game/tests/cases/test_matchmaking_state.gd @@ -13,11 +13,12 @@ func test_ticket_projection_accepts_ordered_updates_and_exposes_cancel() -> void func test_ticket_projection_rejects_gap_and_wrong_ticket_without_mutation() -> void: var state := MatchmakingState.new() - state.begin_queue("ticket-1", "casual") - var resync_id := "" - state.resync_required.connect(func(id: String) -> void: resync_id = id) + assert_true(state.begin_queue("ticket-1", "casual"), "queue setup succeeds") + assert_eq(state.ticket_id, "ticket-1", "queue setup retains ticket identity") + var resync_ids: Array[String] = [""] + state.resync_required.connect(func(id: String) -> void: resync_ids[0] = id) assert_true(not state.apply_ticket_update({"ticket_id": "ticket-2", "revision": 1, "state": "PROPOSED"}), "another player's ticket is rejected") - assert_eq(resync_id, "ticket-1", "wrong resource requests recovery for current ticket") + assert_eq(resync_ids[0], "ticket-1", "wrong resource requests recovery for current ticket") assert_eq(state.phase, MatchmakingState.QUEUED, "invalid update cannot mutate phase") assert_true(state.needs_resync, "invalid identity is visible to recovery") diff --git a/multiplayer-todo.md b/multiplayer-todo.md index d761bb0d..6b14bc9a 100644 --- a/multiplayer-todo.md +++ b/multiplayer-todo.md @@ -1227,7 +1227,7 @@ the local/CI/community transport, not a silent production fallback. | # | Task | Acceptance | |---|---|---| | 8.39 `[D:8.3,8.14,8.17]` | **IN PROGRESS.** `MatchmakingState` now projects queue → proposal → allocation/process-ready/assignment-ready/connect/live plus terminal failure states; autoload `ControlPlaneClient` provides authenticated queue create/recovery/heartbeat/cancel and proposal response requests with idempotency/revision headers; `matchmaking.tscn`/`matchmaking.gd` expose the state and authoritative actions from the main menu; authenticated proposal recovery now reconciles missed proposal events and expires them at read time; the Go API publishes targeted authenticated revisioned queue/proposal/assignment events and the Godot client consumes state/proposal/assignment events, fetching the authoritative assignment after assignment readiness; the API can now use the durable participant-scoped proposal provider for both recovery and accept/decline mutations | `test_matchmaking_state.gd`, `test_control_plane_client.gd`, `test_matchmaking_ui.gd`, `TestProposalRecoveryIsParticipantScopedAndExpiresAtReadBoundary`, `TestAuthenticatedWebSocketDeliversOnlyTargetedRevisionedEvents`, `TestStateChangingAPIActionsPublishTargetedEvents`, `TestProposalRecoveryUsesDurableBackendAndRemainsParticipantScoped` and store proposal SQL tests reject stale/gapped/conflicting updates, validate endpoint/token/payload normalization, preserve idempotent duplicates, and guarantee visible phase/terminal copy; wiring durable allocation events into the outbox, wait/latency explanations and Godot runtime verification remain | -| 8.40 `[D:8.3,8.14]` | **IN PROGRESS.** Pure Go revisioned replica reducer rejects gaps for REST resync, makes duplicate/out-of-order events idempotent, and resumes from the authoritative snapshot revision; authenticated queue-ticket recovery now has an owner-checked REST read; Godot client projection persists non-secret ticket/proposal state, forces authoritative recovery after restart, and can replay a lost queue-create response with the original ticket/idempotency key; the Go API now exposes an authenticated `/v1/events` WebSocket with bounded per-player queues, strict upgrade/vocabulary validation and REST-resync-safe slow-client failure; Godot `ControlPlaneClient` can connect to the stream using Godot 4.7's handshake-header API, consume validated events, automatically reconnect with bounded backoff, and trigger REST recovery on projection gaps and stream return; `OutboxDispatcher` now provides ordered at-least-once delivery after durable commit; assignment recovery events carry the durable assignment revision without leaking it into REST JSON | `server/domain/sync.go`, `server/api/events.go`, `server/api/service.go`, `server/store/outbox.go`, `service_test.go`, `outbox_test.go`, `matchmaking_state.gd` and `control_plane_client.gd` cover gap, snapshot, replay, same-revision conflict, owner-only ticket recovery, expired-ticket terminal handling, malformed restart snapshots, API-level duplicate-create replay/conflict, authenticated handshake/key rejection, targeted event delivery, exactly-once slow-subscriber closure, invalid-event rejection, delivery-before-ack failure ordering and assignment event/response revision separation; wiring the dispatcher to a production WebSocket/Redis worker and live Godot test-runner execution remain | +| 8.40 `[D:8.3,8.14]` | **IN PROGRESS.** Pure Go revisioned replica reducer rejects gaps for REST resync, makes duplicate/out-of-order events idempotent, and resumes from the authoritative snapshot revision; authenticated queue-ticket recovery now has an owner-checked REST read; Godot client projection persists non-secret ticket/proposal state, forces authoritative recovery after restart, and can replay a lost queue-create response with the original ticket/idempotency key; the Go API now exposes an authenticated `/v1/events` WebSocket with bounded per-player queues, strict upgrade/vocabulary validation and REST-resync-safe slow-client failure; Godot `ControlPlaneClient` can connect to the stream using Godot 4.7's handshake-header API, consume validated events, automatically reconnect with bounded backoff, and trigger REST recovery on projection gaps and stream return; `OutboxDispatcher` now provides ordered at-least-once delivery after durable commit; assignment recovery events carry the durable assignment revision without leaking it into REST JSON | `server/domain/sync.go`, `server/api/events.go`, `server/api/service.go`, `server/store/outbox.go`, `service_test.go`, `outbox_test.go`, `matchmaking_state.gd` and `control_plane_client.gd` cover gap, snapshot, replay, same-revision conflict, owner-only ticket recovery, expired-ticket terminal handling, malformed restart snapshots, API-level duplicate-create replay/conflict, authenticated handshake/key rejection, targeted event delivery, exactly-once slow-subscriber closure, invalid-event rejection, delivery-before-ack failure ordering and assignment event/response revision separation; Godot 4.7.1 headless project parse and 142-test unit harness pass with compatibility rendering; wiring the dispatcher to a production WebSocket/Redis worker and live multi-process control-plane/game verification remain | | 8.41 `[D:7.8,8.9,8.31,8.40]` | **IN PROGRESS.** Authenticated `GET /v1/assignments/{matchId}` now exposes only a validated, player-scoped assignment view including the hosted endpoint; Godot `AssignmentState`/`ControlPlaneClient.fetch_assignment()` bind the response to the authenticated player, recheck expiry, validate and retain the endpoint, preserve explicit transport/slot/join authorisation and do not connect before assignment-ready; migration 0002 and the Go store adapter now persist/recover the complete player-scoped assignment projection with conflict-safe identical replay; `AssignmentProviderFromStore` wires that durable projection into the API injection point; `SaveAssignments` publishes a complete signed roster atomically instead of allowing partial player visibility; `SaveVerifiedAssignmentRoster` rechecks signed claims before deriving player rows | `server/api/service.go`, `store_adapters.go`, `service_test.go`, `assignment_state.gd`, `test_assignment_state.gd`, `server/contracts/v1/openapi.json`, `server/migrations/0002_assignments.sql` and `server/store/assignment_sql.go` cover participant/identity/expiry/shape/transport/endpoint boundaries, player-scoped schema keys, expiry-filtered reads, assignment upsert conflict handling, atomic batch validation and signed-claim binding; direct client connect caller, SDR relay-ticket installation, `hello` join-authorisation wiring, fencing integration and live Godot/PostgreSQL verification remain | | 8.42 `[D:8.22,8.23,8.24,8.40]` | **IN PROGRESS.** `RankedProfileState` and `ControlPlaneClient.fetch_ranked_profile()` expose the backend-authoritative rating/RD/volatility/games/tier/provisional/season view; matchmaking UI displays provisional/tier status without client-side rating math | `test_control_plane_client.gd` validates profile shape, numeric safety and provisional display; ranked profile fetch/display, committed revision after reconnect, abandon status and season countdown remain dependent on live auth/backend events and Godot runtime verification | | 8.43 `[D:8.39,8.40,8.41]` | **IN PROGRESS.** Matchmaking client now distinguishes expired queue recovery, session expiry, missing records and retryable control-plane outages; a 401 clears the in-memory token, emits `session_expired` and disables retry until a new session is configured; terminal messages remain visible and active searches are not falsely failed on transient errors | `MatchmakingState` and `ControlPlaneClient` tests cover explicit expiry and the existing terminal/retry-safe state paths; decline, version mismatch, regional outage retry UI, failed reconnect, duplicate-action recovery and live Godot verification remain |