Skip to content

flatbuffers: Add opt-in buffer identification mechanism#174

Open
OliverHeilwagen wants to merge 4 commits into
eclipse-score:mainfrom
etas-contrib:flatbuffers_common_buffer_identification
Open

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

Conversation

@OliverHeilwagen

@OliverHeilwagen OliverHeilwagen commented May 5, 2026

Copy link
Copy Markdown
Contributor

resolves #128

@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown

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

Comment thread score/flatbuffers/bazel/tools.bzl
@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
@OliverHeilwagen OliverHeilwagen force-pushed the flatbuffers_common_buffer_identification branch from f68dbf7 to d51fc10 Compare June 3, 2026 13:52
Comment thread score/flatbuffers/test/version_reader_test.cpp
Comment thread score/flatbuffers/details/buffer_version_info.cpp
Comment thread score/flatbuffers/buffer_version_info.hpp
Comment thread score/flatbuffers/details/version_reader.cpp Outdated
Comment thread score/flatbuffers/details/version_reader.cpp Outdated
Comment thread score/flatbuffers/details/version_reader.cpp Outdated
Comment thread score/flatbuffers/version_reader.hpp Outdated
Comment thread score/flatbuffers/test/serialize_buffer_rules/BUILD
@OliverHeilwagen OliverHeilwagen marked this pull request as ready for review June 18, 2026 14:22
Comment thread examples/integration/flatbuffers/config_usecase/BUILD
Comment thread score/flatbuffers/test/version_reader_test.cpp
Comment thread score/flatbuffers/test/version_reader_test.cpp
@4og

4og commented Jun 18, 2026

Copy link
Copy Markdown
Member

@OliverHeilwagen, can you please update the branch in you fork to the latest baselibs main?

@OliverHeilwagen OliverHeilwagen force-pushed the flatbuffers_common_buffer_identification branch from f403a19 to 15b6cbb Compare June 19, 2026 06:48
Comment thread MODULE.bazel
## Configure the python toolchain

bazel_dep(name = "rules_python", version = "1.8.3", dev_dependency = True)
bazel_dep(name = "rules_python", version = "1.8.3")

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
This was found by the black-box testing.
It is necessary for the inject_buffer_version (py_binary) which will only be build for the host environment.

The alternative to just export the python file and expect a python installation on the host, is from my point of view not valid.

Atm i don't have concerns with switching rules_python to non dev, it should behave like the other rules_*.
The consuming module is allowed to override the toolchain (python use_extension).

@OliverHeilwagen OliverHeilwagen force-pushed the flatbuffers_common_buffer_identification branch from 002c65b to 402d91b Compare June 25, 2026 07:19
@OliverHeilwagen OliverHeilwagen force-pushed the flatbuffers_common_buffer_identification branch from 402d91b to c11756d Compare June 25, 2026 07:32
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
- Added unit tests for BufferVersionInfo, I/VersionReader, ErrorCode,
  idl_parser
Add example for versioned configuration and extend generate_cpp
documentation.

- Add flatbuffers config example demo_config_versioned, which
  showcases usage of a configuration with version information.
- Rename base configuration example to demo_config.
- Extend generate_cpp documentation to explain how included schemas
  are handled during the code generation.
- Extend library flatbufferutils by buffer_version_generated_bare
  to enable access to common buffer_version_generated.h used for
  common version identification.
Introduces major/minor version injection into FlatBuffer binary
configuration files at build time, enabling universal buffer
identification at runtime.

- Move score/flatbuffers/examples to examples/integration/flatbuffers
- Change rules_python to a normal dependency
@OliverHeilwagen OliverHeilwagen force-pushed the flatbuffers_common_buffer_identification branch from c11756d to 2a9bf95 Compare July 3, 2026 06:46
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

5 participants