Skip to content

fix(native): harden resolve all transport - #7217

Merged
matthewevans merged 2 commits into
mainfrom
fix/native-resolve-all-review-fixes
Aug 10, 2026
Merged

fix(native): harden resolve all transport#7217
matthewevans merged 2 commits into
mainfrom
fix/native-resolve-all-review-fixes

Conversation

@matthewevans

@matthewevans matthewevans commented Aug 10, 2026

Copy link
Copy Markdown
Member

Follow-up to #7215 addressing CodeRabbit review findings.

  • correlate Resolve All failures by request ID
  • retain a bounded engine-log tail in compact batch state updates
  • clean connection and spectator registries after terminal batch cleanup
  • keep native AI ownership in the authenticated server adapter

Validation: full pre-push suite (Rust lint/tests, card-data gates, frontend lint, protocol check, and TypeScript type-check).

Summary by CodeRabbit

  • New Features

    • Native AI Resolve All requests are now handled by the server.
    • Resolve All failures include the specific request and server-provided reason.
    • Final Resolve All engine log entries are shared with players and spectators, up to a capped limit.
  • Bug Fixes

    • Prevented unrelated errors or rejected actions from incorrectly completing Resolve All requests.
    • Improved cleanup after Resolve All completes or fails.

@matthewevans
matthewevans enabled auto-merge August 10, 2026 20:04
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 929b9054-7c84-4558-b845-fe51cfe29c90

📥 Commits

Reviewing files that changed from the base of the PR and between a184f32 and 9f83b80.

📒 Files selected for processing (3)
  • client/src/game/__tests__/dispatchResolveAll.test.ts
  • client/src/game/dispatch.ts
  • crates/phase-server/src/main.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • client/src/game/dispatch.ts
  • crates/phase-server/src/main.rs

📝 Walkthrough

Walkthrough

Resolve All now uses requester-correlated rejection frames, server-owned AI capability metadata, bounded engine-log delivery, and protocol version 29. Client dispatch and WebSocket handling preserve pending requests until the matching server response arrives.

Changes

Resolve All correlation and server-owned AI

Layer / File(s) Summary
Protocol 29 rejection contract
crates/server-core/src/protocol.rs, crates/lobby-broker/src/protocol.rs, scripts/check-protocol-version.mjs
Adds ServerMessage::ResolveAllRejected { request_id, reason } and updates protocol version checks to 29.
Server rejection and terminal delivery
crates/phase-server/src/main.rs
Sends requester-only Resolve All rejections, broadcasts the capped 128-entry log tail, and removes terminal connections and spectator registrations.
Client rejection correlation
client/src/adapter/types.ts, client/src/adapter/ws-adapter.ts, client/src/adapter/__tests__/ws-adapter.test.ts
Adds the server-owned AI capability and settles pending Resolve All requests only for matching ResolveAllRejected frames.
Server-owned AI dispatch
client/src/components/board/ActionButton.tsx, client/src/components/board/__tests__/ActionButton.test.tsx, client/src/game/dispatch.ts, client/src/game/__tests__/dispatchResolveAll.test.ts
Sends an empty AI-seat list for native AI, permits zero-seat resolution only for server-owned AI adapters, and surfaces resolution failures through notifications.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Player
  participant ActionButton
  participant WebSocketAdapter
  participant phase-server
  Player->>ActionButton: Start Resolve All
  ActionButton->>WebSocketAdapter: Send empty AI-seat list
  WebSocketAdapter->>phase-server: Resolve All request with request_id
  phase-server-->>WebSocketAdapter: Final state with bounded logs
  phase-server-->>WebSocketAdapter: ResolveAllRejected(request_id, reason) on failure
  WebSocketAdapter-->>Player: Resolve All result or matching rejection
Loading

Possibly related PRs

Suggested labels: bug

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: hardening the native Resolve All transport.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/native-resolve-all-review-fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@client/src/adapter/ws-adapter.ts`:
- Around line 1529-1534: Update dispatchResolveAll in
client/src/game/dispatch.ts to catch Resolve All rejections and route the error
through the existing game error presentation path, preserving the
server-provided rejection reason. Ensure callers such as ActionButton do not
need to await or catch the promise.

In `@crates/phase-server/src/main.rs`:
- Around line 4270-4289: Update the post-transition handling around
guard_state_snapshot_broadcast and prepare_full_terminal so failures after the
engine accepts the batch never send ResolveAllRejected. Reconcile the requester
using the committed state snapshot when delivery, persistence, or terminal
preparation fails, or make the transition and preparation atomic with rollback;
preserve ResolveAllRejected only for failures occurring before the state
transition commits.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 98a32741-dfbf-42f0-8424-cb352c17a040

📥 Commits

Reviewing files that changed from the base of the PR and between 15017c3 and a184f32.

📒 Files selected for processing (11)
  • client/src/adapter/__tests__/ws-adapter.test.ts
  • client/src/adapter/types.ts
  • client/src/adapter/ws-adapter.ts
  • client/src/components/board/ActionButton.tsx
  • client/src/components/board/__tests__/ActionButton.test.tsx
  • client/src/game/__tests__/dispatchResolveAll.test.ts
  • client/src/game/dispatch.ts
  • crates/lobby-broker/src/protocol.rs
  • crates/phase-server/src/main.rs
  • crates/server-core/src/protocol.rs
  • scripts/check-protocol-version.mjs

Comment thread client/src/adapter/ws-adapter.ts
Comment thread crates/phase-server/src/main.rs Outdated
@matthewevans
matthewevans added this pull request to the merge queue Aug 10, 2026
Merged via the queue into main with commit 8879b91 Aug 10, 2026
15 checks passed
@matthewevans
matthewevans deleted the fix/native-resolve-all-review-fixes branch August 10, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant