Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ffi): Update IR stream protocol version handling in preparation for releasing the kv-pair IR stream format: #573

Merged
merged 10 commits into from
Nov 7, 2024

Conversation

LinZhihao-723
Copy link
Member

@LinZhihao-723 LinZhihao-723 commented Nov 7, 2024

  • Bump the IR stream protocol version to 0.1.0 for the kv-pair IR stream format.
  • Treat the previous IR stream format's versions as backwards compatible.
  • Differentiate between backwards-compatible and supported versions during validation.

Description

This PR formally updates the version protocol to mark released versions as 0.1.0 for the key-value pair IR format.
Also, to support backward compatibility and not break the existing old IR format serialization/deserialization method, we add support for version validation for IR version v0.0.0, 0.0.1 and 0.0.2, which is the unstructured IR format. It also updates the old serialization methods to stick to the latest compatible version (0.0.2) to differentiate with the key-value pair IR format.
This PR also introduces a minimum supported version to invalidate any version larger than 0.0.2 and smaller than 0.1.0, since we don't want to support any compatibility to these versions we never formally released.
However, after realizing the current version validation function is broken since it's doing purely string comprising, we replace the validation function with hardcoded values instead. The proper implementation should be deferred to future PRs.

Validation performed

  • Add new unit tests to ensure the version validation works as expected.
  • Ensure the existing unit tests all passed, meaning that both old IR serializer/deserializer and key-value pair IR serializer/deserializer still work with the correct version numbers.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced protocol version validation for improved error handling.
    • Updated metadata handling in serialization processes.
    • Introduced a strongly typed enum class for protocol error codes to enhance type safety.
  • Bug Fixes

    • Streamlined error handling in deserialization processes for consistency.
    • Improved clarity in error reporting for protocol version validation.
  • Tests

    • Refined test cases for protocol version validation and log event deserialization to ensure comprehensive coverage and clarity.

Copy link
Contributor

coderabbitai bot commented Nov 7, 2024

Walkthrough

The pull request introduces significant updates to the Deserializer, Serializer, and related methods within the clp::ffi::ir_stream namespace. Key changes include enhancements to protocol version validation, improvements in error handling, and adjustments to metadata versioning. The Deserializer now employs a dynamic validation method, while the Serializer modifies its metadata handling. Additionally, the validate_protocol_version function has been refined for better compatibility checks. These changes collectively enhance the robustness and clarity of the deserialization and serialization processes.

Changes

File Path Change Summary
components/core/src/clp/ffi/ir_stream/Deserializer.hpp Modified create and deserialize_next_ir_unit method signatures; updated error handling and validation processes.
components/core/src/clp/ffi/ir_stream/Serializer.cpp Updated metadata version value in the create method; no changes to method signatures or control flow.
components/core/src/clp/ffi/ir_stream/decoding_methods.cpp Enhanced validate_protocol_version function; updated signature and improved error handling for version validation.
components/core/src/clp/ffi/ir_stream/decoding_methods.hpp Converted IRProtocolErrorCode enum to a strongly typed enum class; updated function signature and documentation.
components/core/src/clp/ffi/ir_stream/encoding_methods.cpp Changed assignment of VersionKey in metadata to LatestBackwardCompatibleVersion.
components/core/src/clp/ffi/ir_stream/protocol_constants.hpp Updated version constants; added LatestBackwardCompatibleVersion, removed BetaVersionValue.
components/core/src/clp/ir/LogEventDeserializer.cpp Modified error handling in create method to check against new protocol error codes; streamlined error reporting.
components/core/tests/test-ir_encoding_methods.cpp Adjusted expected outcomes for protocol version validation tests; refined test cases for deserialization edge cases.

Possibly related PRs

Suggested reviewers

  • kirkrodrigues
  • davidlion

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0cf884a and 05cd153.

📒 Files selected for processing (5)
  • components/core/src/clp/ffi/ir_stream/decoding_methods.cpp (2 hunks)
  • components/core/src/clp/ffi/ir_stream/decoding_methods.hpp (3 hunks)
  • components/core/src/clp/ffi/ir_stream/protocol_constants.hpp (2 hunks)
  • components/core/src/clp/ir/LogEventDeserializer.cpp (1 hunks)
  • components/core/tests/test-ir_encoding_methods.cpp (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • components/core/src/clp/ffi/ir_stream/decoding_methods.cpp
  • components/core/src/clp/ffi/ir_stream/decoding_methods.hpp
  • components/core/src/clp/ffi/ir_stream/protocol_constants.hpp
  • components/core/src/clp/ir/LogEventDeserializer.cpp
  • components/core/tests/test-ir_encoding_methods.cpp

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

auto validate_protocol_version(std::string_view protocol_version) -> IRProtocolErrorCode {
// These versions are hardcoded to support the IR protocol version that predates the key-value
// pair IR format.
constexpr std::array<std::string_view, 3> cBackwardCompatibleVersions{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want to include any backward compatible beta versions here?

Copy link
Member Author

Choose a reason for hiding this comment

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

For old IR format no.
For key-value IR format, we do support 0.1.0-beta.1. I added a util to strip the pre-release and only compare the version core.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Outside diff range and nitpick comments (7)
components/core/src/clp/ffi/ir_stream/protocol_constants.hpp (1)

17-18: Consider enhancing version compatibility documentation.

The comment about backward compatibility is helpful but could be more detailed. Consider adding documentation that explains:

  • The version range that's supported (0.0.2 to 0.1.0)
  • The differences between the unstructured and key-value pair IR formats

Here's a suggested enhancement:

-// This is used for IR stream format that predates the key-value pair IR format.
+/**
+ * Versions 0.0.0 through 0.0.2 represent the unstructured IR format.
+ * Version 0.1.0 introduces the key-value pair IR format.
+ * Versions between 0.0.2 and 0.1.0 are unsupported as they were never formally released.
+ */
components/core/src/clp/ir/LogEventDeserializer.cpp (1)

Line range hint 19-27: Consider adding detailed error logging.

While the error handling is well-structured, adding detailed error logging would help with debugging in production environments. Consider logging the specific error conditions and the actual values that caused them.

Here's a suggested improvement:

     if (ffi::ir_stream::IRErrorCode_Success != ir_error_code) {
         switch (ir_error_code) {
             case ffi::ir_stream::IRErrorCode_Incomplete_IR:
+                LOG_ERROR("Incomplete IR detected during deserialization");
                 return std::errc::result_out_of_range;
             case ffi::ir_stream::IRErrorCode_Corrupted_IR:
             default:
+                LOG_ERROR("Protocol error: IR corruption detected (error_code: {})", ir_error_code);
                 return std::errc::protocol_error;
         }
     }
components/core/src/clp/ffi/ir_stream/encoding_methods.cpp (1)

101-102: Well-structured approach to version management.

The implementation demonstrates good architectural practices:

  • Uses flexible JSON metadata structure
  • Maintains clear separation between encoding methods
  • Follows semantic versioning principles for the IR format protocol

Consider documenting the version compatibility matrix in the codebase to help future maintainers understand the version relationships.

components/core/src/clp/ffi/ir_stream/decoding_methods.hpp (2)

4-4: LGTM with minor naming suggestion!

The conversion to enum class with uint8_t as the underlying type improves type safety and memory efficiency. The new states effectively support the version differentiation requirements.

However, for naming consistency with other enum values, consider renaming Backward_Compatible to Backward_Compatibility or Backwards_Compatible.

 enum class IRProtocolErrorCode : uint8_t {
     Supported,
-    Backward_Compatible,
+    Backwards_Compatible,
     Too_Old,
     Too_New,
     Invalid,
 };

Also applies to: 24-30


24-30: Consider adding version constants and validation tests

To strengthen the version protocol implementation:

  1. Consider defining version constants (e.g., MIN_SUPPORTED_VERSION, CURRENT_VERSION) to centralize version management
  2. Ensure comprehensive unit tests cover all version validation scenarios, particularly around the 0.1.0 boundary
  3. Document the version compatibility matrix in a central location for future reference

Also applies to: 208-209

components/core/src/clp/ffi/ir_stream/decoding_methods.cpp (2)

488-489: Unnecessary static_cast in std::regex initialisation.

The static_cast<char const*> may be unnecessary if cProtocol::Metadata::VersionRegex is already of type char const*. Removing the cast can improve code clarity.

Apply this diff to simplify the code:

- std::regex const protocol_version_regex{
-         static_cast<char const*>(cProtocol::Metadata::VersionRegex)
- };
+ std::regex const protocol_version_regex{ cProtocol::Metadata::VersionRegex };

501-502: Redundant static_cast in std::string_view initialisation.

Similarly, the static_cast<char const*> may be redundant if cProtocol::Metadata::VersionValue is already char const*. Simplifying this can enhance readability.

Apply this diff:

- std::string_view const current_build_protocol_version{
-         static_cast<char const*>(cProtocol::Metadata::VersionValue)
- };
+ std::string_view const current_build_protocol_version{ cProtocol::Metadata::VersionValue };
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9f6a6ce and 2d85153.

📒 Files selected for processing (8)
  • components/core/src/clp/ffi/ir_stream/Deserializer.hpp (1 hunks)
  • components/core/src/clp/ffi/ir_stream/Serializer.cpp (1 hunks)
  • components/core/src/clp/ffi/ir_stream/decoding_methods.cpp (2 hunks)
  • components/core/src/clp/ffi/ir_stream/decoding_methods.hpp (3 hunks)
  • components/core/src/clp/ffi/ir_stream/encoding_methods.cpp (1 hunks)
  • components/core/src/clp/ffi/ir_stream/protocol_constants.hpp (1 hunks)
  • components/core/src/clp/ir/LogEventDeserializer.cpp (1 hunks)
  • components/core/tests/test-ir_encoding_methods.cpp (4 hunks)
✅ Files skipped from review due to trivial changes (1)
  • components/core/src/clp/ffi/ir_stream/Serializer.cpp
🧰 Additional context used
📓 Learnings (1)
components/core/src/clp/ffi/ir_stream/Deserializer.hpp (2)
Learnt from: LinZhihao-723
PR: y-scope/clp#549
File: components/core/src/clp/ffi/ir_stream/Deserializer.hpp:209-210
Timestamp: 2024-10-08T15:52:50.753Z
Learning: Until #486 is merged with customized error code support, introducing a layer from `IRErrorCode` to `std::errc` is unnecessary.
Learnt from: LinZhihao-723
PR: y-scope/clp#549
File: components/core/src/clp/ffi/ir_stream/Deserializer.hpp:209-210
Timestamp: 2024-10-01T07:59:15.290Z
Learning: Until #486 is merged with customized error code support, introducing a layer from `IRErrorCode` to `std::errc` is unnecessary.
🔇 Additional comments (11)
components/core/src/clp/ffi/ir_stream/protocol_constants.hpp (1)

15-18: Version constants align with PR objectives.

The version constants correctly implement the versioning strategy outlined in the PR objectives:

  • VersionValue set to "0.1.0" for the key-value pair IR format
  • MinimumSupportedVersionValue set to "0.1.0" to invalidate unreleased versions
  • LatestBackwardCompatibleVersionValue set to "0.0.2" for unstructured IR format support

Let's verify the version constants are used consistently:

✅ Verification successful

Let me search for the version validation logic to verify the changes.


Version constants are correctly implemented and validated

The version constants align with the implementation:

  • validate_protocol_version() correctly handles backward compatibility for versions "0.0.1" and "0.0.2"
  • The new version "0.1.0" represents the key-value pair IR format
  • Test cases verify proper validation of version strings
  • The version validation logic ensures compatibility between old and new formats
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify version constant usage across the codebase
# Expected: No hardcoded versions that conflict with these constants

# Search for version strings that might conflict with our constants
rg -g '!*.{md,txt}' -A 3 '"0\.[0-9]+\.[0-9]+"'

# Search for version validation logic
ast-grep --pattern 'validate_protocol_version($_)'

Length of output: 85394


Script:

#!/bin/bash
# Search for version validation implementation
rg -A 10 "validate_protocol_version" components/core/src/clp/ffi/ir_stream/

# Search for version-related test cases
rg -A 10 "TEST_CASE.*version" components/core/tests/test-ir_encoding_methods.cpp

Length of output: 3910

components/core/src/clp/ir/LogEventDeserializer.cpp (1)

45-48: LGTM! Verify version handling across the codebase.

The change to use IRProtocolErrorCode::Backward_Compatible aligns well with the PR's objective of maintaining backward compatibility with older IR formats.

Let's verify the version handling implementation:

✅ Verification successful

The shell script results reveal comprehensive version handling across the codebase. Let me verify the specific version constants and validation logic with one more search:


Version handling implementation is correctly aligned with backward compatibility requirements

The verification confirms that:

  • The change to use Backward_Compatible is properly implemented and aligns with the version handling strategy
  • Versions v0.0.0, 0.0.1, and 0.0.2 are explicitly defined as backward-compatible versions
  • The IRProtocolErrorCode enum correctly differentiates between Supported and Backward_Compatible states
  • Comprehensive test coverage exists for all version validation scenarios
  • The implementation properly handles version validation across different components
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the protocol version validation implementation
# Expected: Find all version-related constants and validation logic

# Search for version-related constants
echo "Searching for version constants..."
rg -A 2 "0\.0\.[0-2]|0\.1\.0" --type cpp

# Search for version validation logic
echo "Searching for version validation implementations..."
ast-grep --pattern 'validate_protocol_version($_)'

Length of output: 6835


Script:

#!/bin/bash
# Search for the validate_protocol_version implementation
echo "Searching for protocol version validation implementation..."
rg -A 10 "validate_protocol_version" --type cpp

# Search for IRProtocolErrorCode enum
echo "Searching for IRProtocolErrorCode definition..."
rg -A 5 "enum.*IRProtocolErrorCode" --type cpp

Length of output: 16970

components/core/src/clp/ffi/ir_stream/encoding_methods.cpp (2)

101-102: Verify version handling in both encoding methods.

Since both eight-byte and four-byte encoding methods share the same metadata structure, ensure that the version change is handled consistently in both deserialization paths.

Let's verify the deserialization handling:

#!/bin/bash
# Description: Verify version handling in deserialization paths
# Expected: Find corresponding deserialization logic for both encoding methods

# Search for deserialization logic in both encoding methods
echo "Searching for eight-byte encoding deserialization..."
ast-grep --pattern 'namespace eight_byte_encoding {
  $$$
  deserialize$_($$$) {
    $$$
  }
  $$$
}'

echo "Searching for four-byte encoding deserialization..."
ast-grep --pattern 'namespace four_byte_encoding {
  $$$
  deserialize$_($$$) {
    $$$
  }
  $$$
}'

101-102: The version update aligns with backward compatibility requirements.

The change to use LatestBackwardCompatibleVersionValue instead of VersionValue appropriately implements the version protocol update while maintaining backward compatibility with older IR formats.

Let's verify the version constants and their usage:

✅ Verification successful

Let me gather more specific information about the version constants and their usage.


Let me check the protocol constants header files to understand the version definitions.


Version update is correctly implemented for backward compatibility

The change to use LatestBackwardCompatibleVersionValue ("0.0.2") instead of VersionValue ("0.1.0") in the metadata is correct and properly maintains backward compatibility. The protocol constants header confirms that:

  • Current version is "0.1.0"
  • Minimum supported version is "0.1.0"
  • Latest backward compatible version is "0.0.2"

The implementation properly handles the version transition while maintaining support for older IR formats (v0.0.0 through v0.0.2).

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify version constants and their usage across the codebase
# Expected: Find definitions of version constants and their usage in serialization/deserialization

# Search for version-related constants
echo "Searching for version constants..."
rg "VersionValue|LatestBackwardCompatibleVersionValue" --type cpp

# Search for version validation usage
echo "Searching for version validation..."
rg "validate_protocol_version" --type cpp

Length of output: 434


Script:

#!/bin/bash
# Search for version-related constants in protocol headers
echo "Searching for version constants in protocol headers..."
fd -e hpp -e h "protocol" --exec rg -l "Version|version"

# Search for actual version string definitions
echo "Searching for version string definitions..."
rg "\"0\\.\\d+\\.\\d+\"" --type cpp --type hpp

# Search for metadata version key usage
echo "Searching for metadata version key usage..."
rg "Metadata::VersionKey" --type cpp

Length of output: 1824


Script:

#!/bin/bash
# Check protocol constants headers content
echo "Content of CLP protocol constants header:"
cat ./components/core/src/clp/ffi/ir_stream/protocol_constants.hpp

echo -e "\nContent of GLT protocol constants header:"
cat ./components/core/src/glt/ffi/ir_stream/protocol_constants.hpp

# Check version validation implementations
echo -e "\nSearching for version validation implementations:"
rg -A 5 "validate_protocol_version" --type cpp

Length of output: 15912

components/core/src/clp/ffi/ir_stream/decoding_methods.hpp (2)

198-205: Documentation updates look great!

The documentation clearly describes all possible return values and effectively communicates the distinction between supported versions and backward-compatible formats. This aligns well with the PR's objective of formalizing the version protocol.


208-209: Excellent function signature improvements!

The changes enhance safety and efficiency:

  • [[nodiscard]] ensures version validation results aren't accidentally ignored
  • string_view parameter optimizes string handling
  • Trailing return type syntax improves readability
components/core/src/clp/ffi/ir_stream/Deserializer.hpp (1)

157-158: LGTM!

The updated protocol version validation enhances maintainability and correctness.

components/core/src/clp/ffi/ir_stream/decoding_methods.cpp (1)

3-5: Appropriate inclusion of necessary headers.

The addition of <array>, <regex>, and <string_view> is appropriate, as these headers are required for the usage of std::array, std::regex, and std::string_view in the updated code.

components/core/tests/test-ir_encoding_methods.cpp (3)

633-634: LGTM: Version validation test for backward-compatible versions is correct

The test case correctly verifies that validate_protocol_version(version) returns IRProtocolErrorCode::Backward_Compatible for backward-compatible versions.


954-955: LGTM: Version validation check for backward-compatible versions

The test correctly asserts that validate_protocol_version(version) returns IRProtocolErrorCode::Backward_Compatible.


1104-1104: LGTM: Correct use of VersionValue in expected metadata

The expected_metadata is properly populated with cProtocol::Metadata::VersionValue, ensuring the version key matches the protocol's expected value.

components/core/src/clp/ffi/ir_stream/decoding_methods.cpp Outdated Show resolved Hide resolved
components/core/src/clp/ffi/ir_stream/decoding_methods.cpp Outdated Show resolved Hide resolved
components/core/src/clp/ffi/ir_stream/decoding_methods.cpp Outdated Show resolved Hide resolved
components/core/tests/test-ir_encoding_methods.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
components/core/src/clp/ffi/ir_stream/decoding_methods.cpp (2)

503-511: LGTM! Comprehensive semver core extraction.

The implementation correctly handles all semver components according to the specification. Consider adding unit tests to verify edge cases like versions with both pre-release and build metadata (e.g., "1.0.0-alpha+001").


528-548: Consider adding detailed documentation for minimum version validation.

While the logic is correct, the complexity of handling pre-release versions warrants additional documentation explaining the different cases and their rationale.

Add documentation above the minimum version check:

+    // Handle special cases for minimum supported versions:
+    // 1. If the version core is less than minimum supported, reject it
+    // 2. If version cores match but the given version has pre-release info:
+    //    a. Reject if minimum supported is a formal release
+    //    b. Compare full versions if minimum supported has pre-release info
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2d85153 and 7c00ec6.

📒 Files selected for processing (3)
  • components/core/src/clp/ffi/ir_stream/decoding_methods.cpp (2 hunks)
  • components/core/src/clp/ffi/ir_stream/protocol_constants.hpp (2 hunks)
  • components/core/tests/test-ir_encoding_methods.cpp (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • components/core/src/clp/ffi/ir_stream/protocol_constants.hpp
  • components/core/tests/test-ir_encoding_methods.cpp
🔇 Additional comments (4)
components/core/src/clp/ffi/ir_stream/decoding_methods.cpp (4)

3-5: LGTM! Required includes added appropriately.

The new includes support the version validation functionality with standard library components.


476-480: LGTM! Well-structured backward compatibility support.

The constexpr array efficiently defines the supported legacy versions. The implementation aligns with the PR objectives to support unstructured IR format versions.


487-498: LGTM! Robust version validation implementation.

The regex validation with proper type safety and error handling ensures version string correctness.


522-525: ⚠️ Potential issue

Fix potential version comparison issues.

The current string comparison of major versions could produce incorrect results when comparing versions with different digit counts (e.g., "2" vs "10"). Consider implementing numeric comparison.

Apply this diff:

-    if (get_major_version(curr_build_protocol_version_core)
-        > get_major_version(protocol_version_core))
+    if (std::stoi(get_major_version(curr_build_protocol_version_core))
+        > std::stoi(get_major_version(protocol_version_core)))

Likely invalid or redundant comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7c00ec6 and 0cf884a.

📒 Files selected for processing (5)
  • components/core/src/clp/ffi/ir_stream/decoding_methods.cpp (2 hunks)
  • components/core/src/clp/ffi/ir_stream/decoding_methods.hpp (3 hunks)
  • components/core/src/clp/ffi/ir_stream/encoding_methods.cpp (1 hunks)
  • components/core/src/clp/ffi/ir_stream/protocol_constants.hpp (2 hunks)
  • components/core/tests/test-ir_encoding_methods.cpp (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • components/core/src/clp/ffi/ir_stream/decoding_methods.hpp
  • components/core/src/clp/ffi/ir_stream/encoding_methods.cpp
  • components/core/src/clp/ffi/ir_stream/protocol_constants.hpp
  • components/core/tests/test-ir_encoding_methods.cpp
🔇 Additional comments (4)
components/core/src/clp/ffi/ir_stream/decoding_methods.cpp (4)

3-7: LGTM! Header includes are properly organized.

The new includes are necessary for the version validation functionality and follow the standard include ordering convention.


475-475: LGTM! Modern function declaration style.

The trailing return type syntax improves readability and consistency.


502-503: TODO comment is appropriate.

The TODO comment clearly indicates the temporary nature of the hardcoded versions and the planned improvement.


475-514: Add test cases for version comparison edge cases.

To ensure robust version validation, consider adding test cases for:

  • Beta versions (e.g., "0.1.0-beta.1")
  • Release candidates
  • Version with different number of components
  • Invalid version formats

components/core/src/clp/ffi/ir_stream/decoding_methods.cpp Outdated Show resolved Hide resolved
Copy link
Member

@kirkrodrigues kirkrodrigues left a comment

Choose a reason for hiding this comment

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

For the PR title & commit body, how about:

feat(ffi): Update IR stream protocol version handling in preparation for releasing the kv-pair IR stream format:
- Bump the IR stream protocol version to 0.1.0 for the kv-pair IR stream format.
- Treat the previous IR stream format's versions as backwards compatible.
- Differentiate between backwards-compatible and supported versions during validation.

@LinZhihao-723 LinZhihao-723 changed the title ffi: Update the IR version protocol to formally release version 0.1.0 for the key-value pair IR format; update the version validation method to differentiate supported versions from backward-compatible versions. feat(ffi): Update IR stream protocol version handling in preparation for releasing the kv-pair IR stream format: Nov 7, 2024
@LinZhihao-723 LinZhihao-723 merged commit 426cc3d into y-scope:main Nov 7, 2024
20 checks passed
LinZhihao-723 added a commit to LinZhihao-723/clp that referenced this pull request Nov 12, 2024
* ffi: Add support for serializing/deserializing auto-generated and user-generated schema tree node IDs. (y-scope#557)

Co-authored-by: kirkrodrigues <[email protected]>

* clp: Add missing C++ standard library includes in IR parsing files. (y-scope#561)

Co-authored-by: kirkrodrigues <[email protected]>

* log-viewer-webui: Update `yscope-log-viewer` to the latest version (which uses `clp-ffi-js`). (y-scope#562)

* package: Upgrade dependencies to resolve security issues. (y-scope#536)

* clp-s: Implement table packing (y-scope#466)

Co-authored-by: wraymo <[email protected]>
Co-authored-by: Kirk Rodrigues <[email protected]>
Co-authored-by: wraymo <[email protected]>

* log-viewer-webui: Update `yscope-log-viewer` to the latest version. (y-scope#565)

* ci: Switch GitHub macOS build workflow to use macos-13 (x86) and macos-14 (ARM) runners. (y-scope#566)

* core: Add support for user-defined HTTP headers in `NetworkReader`. (y-scope#568)

Co-authored-by: Lin Zhihao <[email protected]>
Co-authored-by: Xiaochong Wei <[email protected]>

* chore: Update to the latest version of yscope-dev-utils. (y-scope#574)

* build(core): Upgrade msgpack to v7.0.0. (y-scope#575)

* feat(ffi): Update IR stream protocol version handling in preparation for releasing the kv-pair IR stream format: (y-scope#573)

- Bump the IR stream protocol version to 0.1.0 for the kv-pair IR stream format.
- Treat the previous IR stream format's versions as backwards compatible.
- Differentiate between backwards-compatible and supported versions during validation.

Co-authored-by: kirkrodrigues <[email protected]>

* fix(taskfiles): Trim trailing slash from URL prefix in `download-and-extract-tar` (fixes y-scope#577). (y-scope#578)

* fix(ffi): Correct `clp::ffi::ir_stream::Deserializer::deserialize_next_ir_unit`'s return value when failing to read the next IR unit's type tag. (y-scope#579)

* fix(taskfiles): Update `yscope-log-viewer` sources in `log-viewer-webui-clients` sources list (fixes y-scope#576). (y-scope#580)

* fix(cmake): Add Homebrew path detection for `mariadb-connector-c` to fix macOS build failure. (y-scope#582)

Co-authored-by: kirkrodrigues <[email protected]>

* refactor(ffi): Make `get_schema_subtree_bitmap` a public method of `KeyValuePairLogEvent`. (y-scope#581)

* ci: Schedule GitHub workflows to daily run to detect failures due to upgraded dependencies or environments. (y-scope#583)

* docs: Update the required version of task. (y-scope#567)

* Add pr check workflow

---------

Co-authored-by: kirkrodrigues <[email protected]>
Co-authored-by: Junhao Liao <[email protected]>
Co-authored-by: Henry8192 <[email protected]>
Co-authored-by: Devin Gibson <[email protected]>
Co-authored-by: wraymo <[email protected]>
Co-authored-by: wraymo <[email protected]>
Co-authored-by: Xiaochong(Eddy) Wei <[email protected]>
Co-authored-by: Xiaochong Wei <[email protected]>
Co-authored-by: haiqi96 <[email protected]>
jackluo923 pushed a commit to jackluo923/clp that referenced this pull request Dec 4, 2024
…for releasing the kv-pair IR stream format: (y-scope#573)

- Bump the IR stream protocol version to 0.1.0 for the kv-pair IR stream format.
- Treat the previous IR stream format's versions as backwards compatible.
- Differentiate between backwards-compatible and supported versions during validation.

Co-authored-by: kirkrodrigues <[email protected]>
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