Skip to content

#195 support for etl std byte as byte type#231

Merged
tzijnge merged 27 commits intomainfrom
#195-support-for-etl-std-byte-as-byte-type
Apr 14, 2026
Merged

#195 support for etl std byte as byte type#231
tzijnge merged 27 commits intomainfrom
#195-support-for-etl-std-byte-as-byte-type

Conversation

@tzijnge
Copy link
Copy Markdown
Owner

@tzijnge tzijnge commented Mar 30, 2026

❇️ @coderabbitai

Description

Fixes issue #195

Summary by CodeRabbit

  • New Features

    • Configurable C++ byte type via a new byte_type setting (supports uint8_t, int8_t, char, char8_t, etl::byte, std::byte, etc.).
    • Definition overlays with deep-merge semantics and a new merge workflow/CLI command to apply one-or-more YAML overlays.
  • Documentation

    • Expanded docs for byte_type, overlay format, merge strategies, examples, and tool usage.
  • Refactor

    • Unified definition-loading API for consistent overlay handling.
  • Tests

    • Extensive tests added/updated for byte types and overlay merge behavior.

Type

  • feature
  • bugfix
  • doc
  • removal
  • misc

tzijnge added 4 commits March 28, 2026 13:19
* introducing lrpc::byte iso LRPC_BYTE_TYPE
* Added tests for encoding/decoding etl::byte and std::byte in EtlRwExtensions.hpp. By virtue of etl::byte and std::byte being an enum class, this was already supported, but there were no tests
* Added test file for etl::byte
* Added byte_type settings
* Fix default byte type in tests
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds configurable C++ byte types via a new lrpc::byte alias and byte_type setting, implements a DefinitionLoader with multi-document YAML overlay merge semantics, updates codegen/export/runtime to be byte-type aware, and expands docs/tests (including a comprehensive overlay-merge test suite).

Changes

Cohort / File(s) Summary
Settings & schema
src/lrpc/core/settings.py, src/lrpc/schema/lotusrpc-schema.json
Introduce byte_type (LrpcByteType) in RpcSettings with default "uint8_t" and accessor; extend JSON schema enum for allowed C++ byte representations.
Definition loader & overlay merge
src/lrpc/utils/load_definition.py, src/lrpc/utils/overlay_merge.py, src/lrpc/utils/__init__.py
Add DefinitionLoader (load base, apply multi-doc overlays via add_overlay, save_to, lrpc_def()), replace multiple loader entrypoints with load_lrpc_def, and implement merge_definition() with merge_strategy semantics and strict error handling.
C++ byte types & resource export
src/lrpc/resources/cpp/LrpcTypes.hpp, src/lrpc/resources/cpp/export.py, src/lrpc/resources/cpp/EtlRwExtensions.hpp, src/lrpc/resources/cpp/meta_service_file_writer.py
Replace macro LRPC_BYTE_TYPE with using byte = $byte_type; and lrpc::byte alias; make bytearray span use byte; make export accept byte_type and inject includes; update ETL read/write and generated meta-service slices to use lrpc::byte.
Codegen & constants
src/lrpc/codegen/constants.py, src/lrpc/resources/meta/meta.lrpc.yaml, src/lrpc/codegen/meta_service_file_writer.py
Emit bytearray constants and generated service definition_response(...) using lrpc::byte; meta resource document top-level now includes merge_strategy: add.
Core model & service parsing
src/lrpc/core/definition.py, src/lrpc/core/service.py
LrpcDef.__init__ now deep-copies input (raw_) to avoid mutating caller data; functions_before_streams made optional with default True and constructor reads via raw.get(...).
Client & CLI tooling
src/lrpc/client/lrpc_client.py, src/lrpc/tools/lrpcc/lrpcc.py, src/lrpc/tools/lrpcg/lrpcg.py
Switch callers to load_lrpc_def/DefinitionLoader; lrpcg accepts repeatable -ov/--overlay, applies overlays before generation, adds merge subcommand, and makes core export byte-type aware with --byte_type.
Exports/tests (C++ harness)
tests/cpp/CMakeLists.txt, tests/cpp/TestBytearray*.cpp, tests/cpp/TestBytearray.template.cpp, tests/cpp/TestEtlRwExtensions.cpp, tests/cpp/TestServer4.cpp, tests/cpp/TestUtils.hpp
Replace macro-driven byte-type tests with per-byte-type generated-header includes/executables; update tests to use lrpc::byte and new spans/arrays; add UnitTests_core interface target and per-byte-type test targets.
Python tests & utilities
tests/python/utilities.py, many tests/python/test_*.py, tests/python/test_overlay_merge.py
Add load_test_definition helper; replace legacy loader usage with load_lrpc_def; add comprehensive overlay-merge tests; update tests for new settings fields/defaults and loader behavior.
Testdata & embedded fixtures
tests/testdata/*, tests/embedded_definition/embedded_definition.py
Add per-byte-type overlay test YAMLs (TestBytearray_*) with merge_strategy: add and settings.byte_type; update TestRetrieveDefinition tx buffer size and embedded framing payloads.
Docs & changelog
docs/index.md, docs/reference.md, docs/tools.md, docs/binary.md, changes/195.feature.md
Document byte_type, lrpc::byte alias, overlay merge semantics/examples, lrpcg merge/overlay CLI usage; update bytearray alias docs and changelog entry.
Generated outputs/tests adjustments
src/lrpc/codegen/..., tests/python/test_meta_service_file_writer.py, tests/cpp/TestRetrieveDefinition.cpp, others
Update generated output expectations and tests to reflect lrpc::byte usage and adjusted transmit/size calculations (buffer sizes, compressed lengths, framing fields).

Sequence Diagram(s)

sequenceDiagram
    participant User as Caller
    participant Loader as DefinitionLoader
    participant Merge as merge_definition
    participant Validator as jsonschema
    participant Analyzer as SemanticAnalyzer
    participant Def as LrpcDef

    User->>Loader: __init__(base_definition, include_meta_def?)
    Loader->>Loader: load base (str|Path|TextIO)
    alt include_meta_def
        Loader->>Loader: load meta definition
        Loader->>Merge: merge_definition(current, meta)
    end
    loop overlays
        User->>Loader: add_overlay(overlay_source)
        Loader->>Loader: load all YAML docs
        Loader->>Merge: merge_definition(current, doc)
    end
    User->>Loader: lrpc_def()
    Loader->>Validator: jsonschema.validate(merged)
    Validator-->>Loader: valid
    Loader->>Analyzer: SemanticAnalyzer.analyze(merged)
    Analyzer-->>Loader: analysis OK
    Loader->>Def: LrpcDef(merged)  --deep copy & init
    Def-->>User: LrpcDef instance
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 2.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed Title is concise and directly summarizes the main feature: adding support for etl::byte and std::byte as byte type options.
Description check ✅ Passed Description follows the template structure with a description section (fixing issue #195) and correctly marks it as a feature. However, it lacks implementation details about the changes beyond the issue reference.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

Test Results

  2 files  ± 0    2 suites  ±0   20s ⏱️ -5s
666 tests  - 20  666 ✅  - 20  0 💤 ±0  0 ❌ ±0 
741 runs  +55  741 ✅ +55  0 💤 ±0  0 ❌ ±0 

Results for commit 9eb75bd. ± Comparison against base commit f23c6a2.

This pull request removes 91 and adds 71 tests. Note that renamed tests count towards both.
TestBytearray_char.array ‑ TestBytearray_char.array
TestBytearray_char.client_array ‑ TestBytearray_char.client_array
TestBytearray_char.client_custom ‑ TestBytearray_char.client_custom
TestBytearray_char.client_multiple ‑ TestBytearray_char.client_multiple
TestBytearray_char.client_optional ‑ TestBytearray_char.client_optional
TestBytearray_char.client_single ‑ TestBytearray_char.client_single
TestBytearray_char.custom ‑ TestBytearray_char.custom
TestBytearray_char.optional ‑ TestBytearray_char.optional
TestBytearray_char.param_return ‑ TestBytearray_char.param_return
TestBytearray_char.param_return_multiple ‑ TestBytearray_char.param_return_multiple
…
TestBytearray.array ‑ TestBytearray.array
TestBytearray.client_array ‑ TestBytearray.client_array
TestBytearray.client_custom ‑ TestBytearray.client_custom
TestBytearray.client_multiple ‑ TestBytearray.client_multiple
TestBytearray.client_optional ‑ TestBytearray.client_optional
TestBytearray.client_single ‑ TestBytearray.client_single
TestBytearray.custom ‑ TestBytearray.custom
TestBytearray.optional ‑ TestBytearray.optional
TestBytearray.param_return ‑ TestBytearray.param_return
TestBytearray.param_return_multiple ‑ TestBytearray.param_return_multiple
…

♻️ This comment has been updated with latest results.

tzijnge added 2 commits April 1, 2026 22:12
* Add news fragment
* Add support for overlays
* Add mergedeep dependency
Comment thread src/lrpc/tools/lrpcg/lrpcg.py Outdated
tzijnge added 2 commits April 6, 2026 19:28
* Raw definition dict is immutable
* Added overlay_merge
* Using TextIOWrapper iso TextIO
* Removed dependency on mergedeep
* lrpcg has single option for all types of overlays
* Some refactoring
Comment thread src/lrpc/utils/load_definition.py Outdated
Comment thread src/lrpc/utils/load_definition.py Outdated
Comment thread src/lrpc/utils/load_definition.py Outdated
Comment thread src/lrpc/resources/cpp/export.py Outdated
tzijnge added 4 commits April 13, 2026 11:04
* Added lrpcg merge
* load_definition.py has support for multiple YAML documents in one overlay.
* Overlays and meta service are loaded with normal yaml.safe_load functions as functions_before_streams is not applicable for them
* functions_before_streams is now optional for LrpcService
@tzijnge tzijnge marked this pull request as ready for review April 13, 2026 19:28
Copy link
Copy Markdown
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: 10

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/lrpc/codegen/meta_service_file_writer.py (1)

13-13: 🧹 Nitpick | 🔵 Trivial

Align span and take types to use consistent byte representation.

The generated code declares data as lrpc::span<const uint8_t> (line 13) but calls take<const lrpc::byte>() (line 22). Since CompressedDefinition is typed as lrpc::array<uint8_t, ...> and lrpc::byte is a configurable type ($byte_type), this creates a type mismatch when lrpc::byte differs from uint8_t (e.g., when configured as std::byte).

Update CompressedDefinition to use lrpc::byte instead of uint8_t for consistency, or verify the type conversion is safe across all supported byte type configurations.

tests/python/test_lrpc_client.py (1)

436-468: 🧹 Nitpick | 🔵 Trivial

Avoid hard-coded definition-hash literals in mismatch assertions.

Pinning "8d9f42cd4dba8846..." will cause avoidable test churn whenever the YAML changes. Compute the client-side hash prefix from lrpc_def.definition_hash() instead.

Proposed refactor
+        client_hash_prefix = f"{(lrpc_def.definition_hash() or '')[:16]}..."
         assert "Server mismatch detected. Details client vs server:" in caplog.messages
         assert f"LotusRPC version: {lrpc_version} vs {lrpc_version}" in caplog.messages
         assert "Definition version: [disabled] vs [disabled]" in caplog.messages
-        assert "Definition hash: 8d9f42cd4dba8846... vs [wrong hash]..." in caplog.messages
+        assert f"Definition hash: {client_hash_prefix} vs [wrong hash]..." in caplog.messages
...
-        assert "Definition hash: 8d9f42cd4dba8846... vs 8d9f42cd4dba8846..." in caplog.messages
+        assert f"Definition hash: {client_hash_prefix} vs {client_hash_prefix}" in caplog.messages
...
-        assert "Definition hash: 8d9f42cd4dba8846... vs 8d9f42cd4dba8846..." in caplog.messages
+        assert f"Definition hash: {client_hash_prefix} vs {client_hash_prefix}" in caplog.messages

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 08be6daf-043b-4ada-8878-fb9033351541

📥 Commits

Reviewing files that changed from the base of the PR and between f23c6a2 and 87fe2a0.

📒 Files selected for processing (57)
  • changes/195.feature.md
  • docs/index.md
  • docs/reference.md
  • docs/tools.md
  • src/lrpc/client/lrpc_client.py
  • src/lrpc/codegen/constants.py
  • src/lrpc/codegen/meta_service_file_writer.py
  • src/lrpc/core/definition.py
  • src/lrpc/core/service.py
  • src/lrpc/core/settings.py
  • src/lrpc/resources/cpp/EtlRwExtensions.hpp
  • src/lrpc/resources/cpp/LrpcTypes.hpp
  • src/lrpc/resources/cpp/export.py
  • src/lrpc/resources/meta/meta.lrpc.yaml
  • src/lrpc/schema/lotusrpc-schema.json
  • src/lrpc/tools/lrpcc/lrpcc.py
  • src/lrpc/tools/lrpcg/lrpcg.py
  • src/lrpc/utils/__init__.py
  • src/lrpc/utils/load_definition.py
  • src/lrpc/utils/overlay_merge.py
  • tests/cpp/CMakeLists.txt
  • tests/cpp/TestBytearray.template.cpp
  • tests/cpp/TestBytearray_char.cpp
  • tests/cpp/TestBytearray_char8_t.cpp
  • tests/cpp/TestBytearray_etl_byte.cpp
  • tests/cpp/TestBytearray_int8_t.cpp
  • tests/cpp/TestBytearray_signed_char.cpp
  • tests/cpp/TestBytearray_std_byte.cpp
  • tests/cpp/TestBytearray_uint8_t.cpp
  • tests/cpp/TestBytearray_unsigned_char.cpp
  • tests/cpp/TestEtlRwExtensions.cpp
  • tests/cpp/TestRetrieveDefinition.cpp
  • tests/cpp/TestServer4.cpp
  • tests/cpp/TestUtils.hpp
  • tests/embedded_definition/embedded_definition.py
  • tests/python/test_lrpc_client.py
  • tests/python/test_lrpc_decode.py
  • tests/python/test_lrpc_def.py
  • tests/python/test_lrpc_encode.py
  • tests/python/test_lrpc_encode_decode.py
  • tests/python/test_lrpc_service.py
  • tests/python/test_meta_service.py
  • tests/python/test_meta_service_file_writer.py
  • tests/python/test_overlay_merge.py
  • tests/python/test_rpc_settings.py
  • tests/python/test_schema.py
  • tests/python/utilities.py
  • tests/testdata/TestBytearray_char.lrpc.yaml
  • tests/testdata/TestBytearray_char8_t.lrpc.yaml
  • tests/testdata/TestBytearray_etl_byte.lrpc.yaml
  • tests/testdata/TestBytearray_int8_t.lrpc.yaml
  • tests/testdata/TestBytearray_signed_char.lrpc.yaml
  • tests/testdata/TestBytearray_std_byte.lrpc.yaml
  • tests/testdata/TestBytearray_uint8_t.lrpc.yaml
  • tests/testdata/TestBytearray_unsigned_char.lrpc.yaml
  • tests/testdata/TestRetrieveDefinition.lrpc.yaml
  • tests/testdata/test_lrpc_encode_decode.lrpc.yaml
💤 Files with no reviewable changes (1)
  • tests/cpp/TestUtils.hpp

Comment thread docs/reference.md Outdated
Comment thread docs/tools.md Outdated
Comment thread src/lrpc/resources/cpp/export.py Outdated
Comment thread src/lrpc/resources/cpp/LrpcTypes.hpp
Comment thread src/lrpc/schema/lotusrpc-schema.json
Comment thread src/lrpc/utils/load_definition.py Outdated
Comment thread src/lrpc/utils/load_definition.py Outdated
Comment thread tests/cpp/CMakeLists.txt
Comment thread tests/cpp/TestEtlRwExtensions.cpp Outdated
Comment thread tests/cpp/TestEtlRwExtensions.cpp
Copy link
Copy Markdown
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: 3

♻️ Duplicate comments (2)
docs/tools.md (1)

18-18: ⚠️ Potential issue | 🟡 Minor

Fix the anchor link to match the actual heading.

The link reference.md#definition-overlays uses singular "definition", but the heading in reference.md (line 243) is "Definitions overlays" (plural), which generates the anchor #definitions-overlays.

📝 Proposed fix
-Definition overlays can be specified with one or more `-ov` options. A single overlay may contain multiple [YAML documents](https://yaml.org/spec/1.2.2/#91-documents). For more information about definition overlays see [Definition overlays](reference.md#definition-overlays).
+Definition overlays can be specified with one or more `-ov` options. A single overlay may contain multiple [YAML documents](https://yaml.org/spec/1.2.2/#91-documents). For more information about definition overlays see [Definition overlays](reference.md#definitions-overlays).
docs/reference.md (1)

257-267: 🧹 Nitpick | 🔵 Trivial

Clarify add behavior for existing named composites.

The merge strategy table states that add requires "Item does not exist in base", but Example 1 shows merge_strategy: add being used to add a parameter to an existing function DoWork. This works because the strategy is inherited to child properties, but the documentation could be clearer that add on a named composite (like a function) will merge into the existing item rather than requiring it to be absent.

Consider adding a clarifying note:

When add is applied to a named composite that already exists in the base, the strategy is inherited to child properties, allowing new child items to be added.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a1df3ad5-4184-4a85-b85d-b7110476153c

📥 Commits

Reviewing files that changed from the base of the PR and between 87fe2a0 and b2454fc.

📒 Files selected for processing (8)
  • docs/binary.md
  • docs/reference.md
  • docs/tools.md
  • src/lrpc/resources/cpp/export.py
  • src/lrpc/utils/load_definition.py
  • tests/cpp/CMakeLists.txt
  • tests/cpp/TestEtlRwExtensions.cpp
  • tests/python/test_lrpc_client.py

Comment thread src/lrpc/resources/cpp/export.py Outdated
Comment thread tests/cpp/CMakeLists.txt
Comment thread tests/cpp/CMakeLists.txt Outdated
Copy link
Copy Markdown
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: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: bf138c31-86e8-4952-ac68-44807ca76327

📥 Commits

Reviewing files that changed from the base of the PR and between b2454fc and 7aa33a5.

📒 Files selected for processing (3)
  • docs/reference.md
  • src/lrpc/resources/cpp/export.py
  • tests/cpp/CMakeLists.txt

Comment thread docs/reference.md Outdated
Comment thread tests/cpp/CMakeLists.txt
Comment thread tests/cpp/CMakeLists.txt
Copy link
Copy Markdown
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.

♻️ Duplicate comments (1)
docs/reference.md (1)

257-262: ⚠️ Potential issue | 🟠 Major

Clarify the add precondition to resolve ambiguity.

The precondition table states that add requires "Item does not exist in base", but line 265 contradicts this by stating "Adding to a named composite merges properties into an existing item if the name matches." This creates confusion about when add can be used.

Example 1 demonstrates adding to an existing function DoWork, which violates the stated precondition but is explicitly allowed per line 265.

The precondition should distinguish between:

  • Basic items in lists: Must not exist in base
  • Named composites (services, functions, structs, etc.): Can exist; properties will merge into the existing item
📝 Suggested clarification
 | Strategy | Behavior                    | Precondition                |
 |----------|-----------------------------|-----------------------------|
-| add      | Add a property to base      | Item does not exist in base |
+| add      | Add a property to base      | Named composites: merges into existing item by name. Basic items: must not exist in base |
 | remove   | Remove a property from base | Item exists in base         |
 | replace  | Replace a property in base  | Item exists in base         |

Alternatively, add a footnote or expand the description to clarify this distinction more explicitly.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 542cd8cd-665b-4261-894d-2513eadfeccb

📥 Commits

Reviewing files that changed from the base of the PR and between 7aa33a5 and deff3fe.

📒 Files selected for processing (2)
  • docs/reference.md
  • tests/cpp/CMakeLists.txt

Copy link
Copy Markdown
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 info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4d8470bd-0d84-423f-b7b4-ab82e6e8c9cc

📥 Commits

Reviewing files that changed from the base of the PR and between deff3fe and d1dfa3f.

📒 Files selected for processing (1)
  • docs/reference.md

Comment thread docs/reference.md Outdated
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
94.7% Coverage on New Code (required ≥ 95%)

See analysis details on SonarQube Cloud

@tzijnge tzijnge merged commit 1c425ff into main Apr 14, 2026
46 of 47 checks passed
@tzijnge tzijnge deleted the #195-support-for-etl-std-byte-as-byte-type branch April 14, 2026 18:54
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