Skip to content

Populate min_version BrushFamily proto field.#511

Open
copybara-service[bot] wants to merge 1 commit intomainfrom
test_872916698
Open

Populate min_version BrushFamily proto field.#511
copybara-service[bot] wants to merge 1 commit intomainfrom
test_872916698

Conversation

@copybara-service
Copy link

@copybara-service copybara-service bot commented Feb 20, 2026

Populate min_version BrushFamily proto field.

Introduces code to calculate the minimum required version of Ink for a BrushFamily (and each part of a BrushFamily). The code is used during serialization to compute the value to store in the min_version field. During deserialization, the min_version field is used to determine if a BrushFamily is compatible with the current version of Ink; if it isn't, decoding it is aborted.

To ensure the code in the web of CalculateMinimumRequiredVersion functions lines up with expectations, protobuf options are used to build consistency check tests. CalculateMinimumRequiredVersion serves as the enforcement of the expectations set in the protobuf itself. The tests are:

  • A fuzz test to generate valid brush families and serialize them. Then, it checks the value in min_version against all the options set for the fields, messages, and enum values, to ensure it is equal to the highest value set for the relevant options. This ensures CalculateMinimumRequiredVersion is consistent with the protobuf options.
  • A test to iterate over all the messages, fields, and enum values in brush_family.proto, starting at the top-level BrushFamily message, and verify that they all have a relevant field_min_version, message_min_version, or enum_value_min_version set, and that this value set is less than or equal to the maximum compatible version (version::kMax).
  • A test to verify that decoding a proto::Version out of the acceptable range (higher than version::kMax, lower than version::kMin, any version with release < 1, any stable version with release != 1) will fail.
  • A test to verify that decoding a proto::Version with an unrecognized proto::Version::Cycle enum value will fail.
  • A test to verify that decoding a proto::BrushFamily with no value set for its min_version field will not fail, to ensure older brushes are still able to be loaded.

A more direct implementation, using reflection to examine the descriptors of the protobuf directly during serialization, was considered, but ultimately rejected. It would have required both static and runtime reflection, and increased libink.so size by ~2%.

@copybara-service copybara-service bot force-pushed the test_872916698 branch 4 times, most recently from 0a5e876 to 0d1a2eb Compare February 23, 2026 19:15
Introduces code to calculate the minimum required version of Ink for a BrushFamily (and each part of a BrushFamily). The code is used during serialization to compute the value to store in the `min_version` field. During deserialization, the `min_version` field is used to determine if a BrushFamily is compatible with the current version of Ink; if it isn't, decoding it is aborted.

To ensure the code in the web of `CalculateMinimumRequiredVersion` functions lines up with expectations, protobuf options are used to build consistency check tests. `CalculateMinimumRequiredVersion` serves as the enforcement of the expectations set in the protobuf itself. The tests are:
* A fuzz test to generate valid brush families and serialize them. Then, it checks the value in `min_version` against all the options set for the fields, messages, and enum values, to ensure it is equal to the highest value set for the relevant options. This ensures `CalculateMinimumRequiredVersion` is consistent with the protobuf options.
* A test to iterate over all the messages, fields, and enum values in `brush_family.proto`, starting at the top-level `BrushFamily` message, and verify that they all have a relevant `field_min_version`, `message_min_version`, or `enum_value_min_version` set, and that this value set is less than or equal to the maximum compatible version (`version::kMax`).
* A test to verify that decoding a `proto::Version` out of the acceptable range (higher than `version::kMax`, lower than `version::kMin`, any version with `release < 1`, any stable version with `release != 1`) will fail.
* A test to verify that decoding a `proto::Version` with an unrecognized `proto::Version::Cycle` enum value will fail.
* A test to verify that decoding a `proto::BrushFamily` with no value set for its `min_version` field will ***not*** fail, to ensure older brushes are still able to be loaded.

A more direct implementation, using reflection to examine the descriptors of the protobuf directly during serialization, was considered, but ultimately rejected. It would have required both static and runtime reflection, and increased `libink.so` size by ~2%.

PiperOrigin-RevId: 872916698
@copybara-service copybara-service bot changed the title Introduces code to calculate the minimum required version of Ink for a BrushFamily (and each part of a BrushFamily). The code is used during serialization to compute the value to store in the min_version field. During deserialization, the min_version field is used to determine if a BrushFamily is compatible with the current version of Ink; if it isn't, decoding it is aborted. Populate min_version BrushFamily proto field. Feb 25, 2026
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