Skip to content

flatbuffers: Add opt-in buffer identification mechanism#174

Draft
OliverHeilwagen wants to merge 2 commits into
eclipse-score:mainfrom
etas-contrib:flatbuffers_common_buffer_identification
Draft

flatbuffers: Add opt-in buffer identification mechanism#174
OliverHeilwagen wants to merge 2 commits into
eclipse-score:mainfrom
etas-contrib:flatbuffers_common_buffer_identification

Conversation

@OliverHeilwagen
Copy link
Copy Markdown
Contributor

@OliverHeilwagen OliverHeilwagen commented May 5, 2026

resolves #128

Todo:

  • Add missing Unit Test for buffer_version_info and version_reader.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

The created documentation from the pull request is available at: docu-html

doc = "Injects major/minor version fields into a JSON file for use with serialize_versioned_buffer.",
)

def serialize_versioned_buffer(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@4og @paulquiring
I introduced the following rules separately so we can have the major/minor version as mandatory rule parameter:

  • serialize_versioned_buffer
  • serialize_multiple_versioned_buffer

I am not so happy with the longer name but kept it for now to avoid breaking changes.
Since we are still early with the flatbuffers rollout we could do a breaking change of the rule name and have the following ones that should remain stable:

  • serialize_buffer
  • serialize_buffers (breaking former: serialize_multiple_buffers)
  • serialize_versioned_buffer
  • serialize_versioned_buffers

The buffer version have dedicated data and output parameters.
The buffers version have data_dict parameter (dictionary key: json data, value: output name).

Please let me know if you have any preferences.

@OliverHeilwagen OliverHeilwagen changed the title flatbuffers: Add starlark rules for versioned buffer serialization flatbuffers: Add opt-in buffer identification mechanism May 5, 2026
@OliverHeilwagen OliverHeilwagen force-pushed the flatbuffers_common_buffer_identification branch from 69ee405 to 14332c1 Compare May 5, 2026 16:03
@OliverHeilwagen OliverHeilwagen temporarily deployed to workflow-approval May 5, 2026 16:03 — with GitHub Actions Inactive
@OliverHeilwagen OliverHeilwagen temporarily deployed to workflow-approval May 5, 2026 16:03 — with GitHub Actions Inactive
@OliverHeilwagen OliverHeilwagen self-assigned this May 6, 2026
@OliverHeilwagen OliverHeilwagen force-pushed the flatbuffers_common_buffer_identification branch from 14332c1 to 44269a7 Compare May 6, 2026 09:30
@4og 4og added the comp-flatbuffers Related to score/flatbuffers component label May 15, 2026
@OliverHeilwagen OliverHeilwagen force-pushed the flatbuffers_common_buffer_identification branch from 44269a7 to f68dbf7 Compare May 20, 2026 10:20
Introduces major/minor version injection into FlatBuffer binary
configuration files at build time, enabling universal buffer
identification at runtime.

- New serialize_versioned_buffer and serialize_multiple_versioned_buffers
  Bazel macros that patch version fields into JSON before flatc serialization
- New inject_buffer_version.py script and Bazel rule that injects
  major/minor version into a JSON data file as a build action
- Added BufferVersion schema under score/flatbuffers/common as shared
  include for versioned schemas
- Added BufferVersionEnvelope schema under score/flatbuffers/common used
  internally to implement GetBufferVersion and VerifyBufferVersion without
  hardcoded vtable offsets
- Extended existing serialize_buffer, serialize_multiple_buffers,
  generate_cpp and generate_json_schema rules with an includes
  attribute to support schema include dependencies
- Added Starlark rule tests covering single/multiple versioned buffers
  and fault injection cases (out-of-range versions, wrong version_info
  placement)
Introduces IVersionReader and VersionReader to read and verify version
metadata from FlatBuffer binaries at runtime using the universal buffer
identification convention established by the BufferVersionEnvelope schema.

- New BufferVersionInfo value type holding a 4-char file identifier plus
  major_version and minor_version fields extracted from a conforming buffer
- New IVersionReader interface with GetVersion and VerifyVersion methods,
  supporting kExact and kMinorMinimum match modes
- New VersionReader concrete implementation backed by FlatBuffers Verifier
  for structural integrity checking before field access
- New ErrorCode error domain covering kNullDataPointer, kVerificationFailed,
  kVersionInfoNotPresent, and kVersionMismatch failure cases
- Updated buffer_version.fbs and buffer_version_envelope.fbs schemas to
  align with the new convention and added type_marker to enable misplacement
  check
- Added integration tests covering nominal reads, exact/minimum version
  matching, out-of-range versions, wrong-field placement, and null inputs
@OliverHeilwagen OliverHeilwagen force-pushed the flatbuffers_common_buffer_identification branch from f68dbf7 to d51fc10 Compare June 3, 2026 13:52

TEST_F(VersionReaderTest, GetVersionRejectsNullPointer)
{
RecordProperty("PartiallyVerifies", "comp_req__flatbuffers__buffer_identification");
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Check if process is considering multiple PartiallyVerifies as FullyVerifies, or if the test cases should already claim FullyVerifies.

@@ -0,0 +1,38 @@
/********************************************************************************
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Correct name to buffer_version_info.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-flatbuffers Related to score/flatbuffers component

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Define common mechanism for opt-in buffer identification

2 participants