Skip to content

Conversation

@vobradovich
Copy link
Member

No description provided.

@vobradovich vobradovich self-assigned this Jan 14, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @vobradovich, 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 overhauls the internal routing and metadata handling within the sails-rs framework. The primary goal is to enhance the robustness and clarity of how services and programs dispatch calls by transitioning from flexible but less structured string-based routes to a more explicit and type-safe system using unique interface and entry identifiers. This foundational change streamlines the underlying mechanics of method invocation and event emission, preparing the framework for more advanced features and improved maintainability.

Highlights

  • Routing Mechanism Refactoring: The core routing mechanism for program and service macros has been refactored to use InterfaceId, entry_id (u16), and route_idx (u8) instead of string-based routes (&[u8]).
  • SailsEvent Trait Enhancement: The SailsEvent trait now includes an entry_id method, and event encoding has been updated to incorporate SailsMessageHeader for more structured event data.
  • InvocationIo Trait Update: The InvocationIo trait has been modified to utilize INTERFACE_ID and ENTRY_ID constants for decoding and encoding parameters, replacing the previous ROUTE and ASYNC constants.
  • Service Metadata Structure: The ServiceMeta trait now uses a BaseServiceMeta struct for defining base services, and new helper functions (count_base_services, interface_ids, etc.) have been added to sails_idl_meta for managing service metadata.
  • Extensive Test and Example Updates: Numerous example applications and test snapshots across the repository have been updated to align with the new routing and metadata structures, demonstrating the broad impact and integration of these changes.
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.

@vobradovich vobradovich requested a review from m62624 January 14, 2026 11:50
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 a significant and valuable refactoring of the program and service routing mechanism, moving from string-based routes to a more robust and type-safe system based on InterfaceId. The changes are extensive, touching macros, core logic, and examples, and appear to be well-executed. My review has identified a few areas for improvement, including a typo in a public constant, some commented-out tests that should be re-enabled to prevent regressions, a misleading test name, and some dead code in generated snapshots. Addressing these points will help ensure the quality and maintainability of this new feature.


#[test]
fn message_header_try_read_fails_insufficient_bytes() {
fn message_header_try_read_fails_invalid_magic() {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The test message_header_try_read_fails_insufficient_bytes was renamed to message_header_try_read_fails_invalid_magic. However, the test case let bytes = [0x47, 0x4D, 1, 15, 1, 2, 3, 4, 5, 6, 7, 8, 210, 4]; has a length of 14, which is less than MINIMAL_HLEN (16). The try_read_bytes function first checks for length, so it will fail with Insufficient bytes for header. The test name is misleading. It should probably be ..._insufficient_bytes or the test case should be updated to test for invalid magic bytes with sufficient length.

Comment on lines 199 to +203
if let Ok(sig) = TryInto::<[u8; 4]>::try_into(&input[..4]) {
if let Some(idx) = __METHOD_SIGS.iter().position(|s| s == &sig) {
let (route, method) = __METHOD_ROUTES[idx];
let (interface_id, entry_id, route_idx) = __METHOD_ROUTES[idx];
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The generated handle function contains an if let block that seems to be a leftover from a previous implementation. The variables interface_id, entry_id, and route_idx are declared but not used, making this dead code. This should be removed from the macro that generates this code to improve clarity.

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.

3 participants