Skip to content

Conversation

@stmatengss
Copy link
Collaborator

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @stmatengss, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a critical version compatibility mechanism between the Mooncake client and server. It ensures that clients only connect to servers running a compatible version by performing an explicit version check during the connection establishment phase. This enhancement prevents potential runtime errors and unexpected behavior that could arise from mismatched client and server versions.

Highlights

  • Version Definition: A new header file, version.h, has been introduced to centrally define the Mooncake system's version string (initially "1.0.0") and provide a utility function to retrieve it.
  • RPC Service Modification: The ServiceReady RPC method in WrappedMasterService has been updated to return a std::string representing the server's version, instead of void.
  • Client-Server Version Checking: The MasterClient::Connect method now performs a version check. It retrieves the server's version via the ServiceReady RPC and compares it against the client's own version. If a mismatch is detected, the connection is rejected with an INVALID_VERSION error.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces version checking between the client and server, which is a crucial feature for maintaining compatibility and stability. The implementation is straightforward, with the server exposing its version via an RPC endpoint that the client checks upon connection. My feedback includes a suggestion to improve the version checking logic for better flexibility in future releases and a minor performance optimization to avoid unnecessary string copies.

Comment on lines +240 to +247
std::string server_version = result.value();
std::string client_version = GetMooncakeVersion();
if (server_version != client_version) {
LOG(ERROR) << "Version mismatch: server=" << server_version
<< " client=" << client_version;
timer.LogResponse("error_code=", ErrorCode::INVALID_VERSION);
return ErrorCode::INVALID_VERSION;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This version check implementation can be improved in two ways:

  1. Performance: result.value() and GetMooncakeVersion() both return references to strings, but they are being copied into server_version and client_version. You can avoid these unnecessary copies by using const std::string&.

  2. Flexibility: The current strict string comparison means any version change (even a patch for a bug fix) will be a breaking change, forcing all clients to upgrade. Consider implementing a more flexible check, like comparing only the major version number. This would allow for non-breaking updates on the server.

Here is a suggested implementation that addresses both points:

Suggested change
std::string server_version = result.value();
std::string client_version = GetMooncakeVersion();
if (server_version != client_version) {
LOG(ERROR) << "Version mismatch: server=" << server_version
<< " client=" << client_version;
timer.LogResponse("error_code=", ErrorCode::INVALID_VERSION);
return ErrorCode::INVALID_VERSION;
}
const std::string& server_version_str = result.value();
const std::string& client_version_str = GetMooncakeVersion();
// A simple way to check for major version compatibility.
// For a more robust solution, consider a dedicated version parsing utility.
auto get_major = [](const std::string& v_str) {
return v_str.substr(0, v_str.find('.'));
};
if (get_major(server_version_str) != get_major(client_version_str)) {
LOG(ERROR) << "Version mismatch: server=" << server_version_str
<< " client=" << client_version_str;
timer.LogResponse("error_code=", ErrorCode::INVALID_VERSION);
return ErrorCode::INVALID_VERSION;
}

@ykwd
Copy link
Collaborator

ykwd commented Nov 17, 2025

Thanks for the PR! I have two suggestions regarding the versioning logic:

  1. Consider extracting the version-related logic from CMakeLists.txt into a separate .cmake file.
    We will likely need to bump the version frequently, and keeping this logic in its own file would help keep the CMakeLists.txt history cleaner and easier to review.

  2. It would be helpful to add comments or documentation explaining when the version should be bumped.
    This will make the versioning policy clearer for future contributors and avoid inconsistent updates.

1 similar comment
@ykwd
Copy link
Collaborator

ykwd commented Nov 17, 2025

Thanks for the PR! I have two suggestions regarding the versioning logic:

  1. Consider extracting the version-related logic from CMakeLists.txt into a separate .cmake file.
    We will likely need to bump the version frequently, and keeping this logic in its own file would help keep the CMakeLists.txt history cleaner and easier to review.

  2. It would be helpful to add comments or documentation explaining when the version should be bumped.
    This will make the versioning policy clearer for future contributors and avoid inconsistent updates.

@stmatengss stmatengss force-pushed the add_version_check_rpc branch from c34ff19 to 36fecda Compare November 18, 2025 10:55
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.

2 participants