Skip to content

fix: sesame: look ahead for window releases#1099

Open
richardapeters wants to merge 9 commits intomainfrom
feature/sesame-release-window
Open

fix: sesame: look ahead for window releases#1099
richardapeters wants to merge 9 commits intomainfrom
feature/sesame-release-window

Conversation

@richardapeters
Copy link
Collaborator

No description provided.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Thanks for your first PR. We really appreciate it!

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Dependency Review

The following issues were found:
  • ✅ 0 vulnerable package(s)
  • ✅ 0 package(s) with incompatible licenses
  • ✅ 0 package(s) with invalid SPDX license definitions
  • ⚠️ 33 package(s) with unknown licenses.
See the Details below.

Snapshot Warnings

⚠️: The number of snapshots compared for the base SHA (0) and the head SHA (1) do not match. You may see unexpected additions in the diff.
Consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

License Issues

infra/syntax/CMakeLists.txt

PackageVersionLicenseIssue Type
zeux/pugixmlef856bf975f4b1909af1b40ed3d7e28af9263d95NullUnknown License
zeux/pugixmlef856bf975f4b1909af1b40ed3d7e28af9263d95NullUnknown License
zeux/pugixmlef856bf975f4b1909af1b40ed3d7e28af9263d95NullUnknown License

osal/freertos/CMakeLists.txt

PackageVersionLicenseIssue Type
freertos/freertos-kerneldef7d2df2b0506d3d249334974f51e427c17a41cNullUnknown License
freertos/freertos-kerneldef7d2df2b0506d3d249334974f51e427c17a41cNullUnknown License
freertos/freertos-kerneldef7d2df2b0506d3d249334974f51e427c17a41cNullUnknown License

external/crypto/micro-ecc/CMakeLists.txt

PackageVersionLicenseIssue Type
kmackay/micro-ecc24c60e243580c7868f4334a1ba3123481fe1aa48NullUnknown License
kmackay/micro-ecc24c60e243580c7868f4334a1ba3123481fe1aa48NullUnknown License
kmackay/micro-ecc24c60e243580c7868f4334a1ba3123481fe1aa48NullUnknown License

external/args/CMakeLists.txt

PackageVersionLicenseIssue Type
taywee/args114200a9ad5fe06c8dea76e15d92325695cf3e34NullUnknown License
taywee/args114200a9ad5fe06c8dea76e15d92325695cf3e34NullUnknown License
taywee/args114200a9ad5fe06c8dea76e15d92325695cf3e34NullUnknown License

external/crypto/mbedtls/CMakeLists.txt

PackageVersionLicenseIssue Type
mbed-tls/mbedtls107ea89daaefb9867ea9121002fbbdf926780e98NullUnknown License
mbed-tls/mbedtls107ea89daaefb9867ea9121002fbbdf926780e98NullUnknown License
mbed-tls/mbedtls107ea89daaefb9867ea9121002fbbdf926780e98NullUnknown License

external/protobuf/CMakeLists.txt

PackageVersionLicenseIssue Type
protocolbuffers/protobufedaa823d8b36a8656d7b2b9241b7d0bfe50af878NullUnknown License
protocolbuffers/protobufedaa823d8b36a8656d7b2b9241b7d0bfe50af878NullUnknown License
protocolbuffers/protobufedaa823d8b36a8656d7b2b9241b7d0bfe50af878NullUnknown License

cmake/emil_test_helpers.cmake

PackageVersionLicenseIssue Type
google/googletestv1.14.0NullUnknown License
google/googletestv1.14.0NullUnknown License
google/googletestv1.14.0NullUnknown License

external/crypto/tiny-aes128/CMakeLists.txt

PackageVersionLicenseIssue Type
kokke/tiny-aes-c7e42e693288bdf22d8e677da94248115168211b9NullUnknown License
kokke/tiny-aes-c7e42e693288bdf22d8e677da94248115168211b9NullUnknown License
kokke/tiny-aes-c7e42e693288bdf22d8e677da94248115168211b9NullUnknown License

lwip/lwip/CMakeLists.txt

PackageVersionLicenseIssue Type
lwip-tcpip/lwip77dcd25a72509eb83f72b033d219b1d40cd8eb95NullUnknown License
lwip-tcpip/lwip77dcd25a72509eb83f72b033d219b1d40cd8eb95NullUnknown License
lwip-tcpip/lwip77dcd25a72509eb83f72b033d219b1d40cd8eb95NullUnknown License

external/segger_rtt/CMakeLists.txt

PackageVersionLicenseIssue Type
seggermicro/rttff57c3d516ea59b0a2d4d5cafb33a48572b09c0bNullUnknown License
seggermicro/rttff57c3d516ea59b0a2d4d5cafb33a48572b09c0bNullUnknown License
seggermicro/rttff57c3d516ea59b0a2d4d5cafb33a48572b09c0bNullUnknown License

osal/threadx/CMakeLists.txt

PackageVersionLicenseIssue Type
eclipse-threadx/threadx06dabb0ad0403f59889ce85eeb3d48dbd9d3759bNullUnknown License
eclipse-threadx/threadx06dabb0ad0403f59889ce85eeb3d48dbd9d3759bNullUnknown License
eclipse-threadx/threadx06dabb0ad0403f59889ce85eeb3d48dbd9d3759bNullUnknown License

OpenSSF Scorecard

Scorecard details
PackageVersionScoreDetails
unknown/zeux/pugixml ef856bf975f4b1909af1b40ed3d7e28af9263d95 UnknownUnknown
unknown/freertos/freertos-kernel def7d2df2b0506d3d249334974f51e427c17a41c UnknownUnknown
unknown/kmackay/micro-ecc 24c60e243580c7868f4334a1ba3123481fe1aa48 UnknownUnknown
unknown/taywee/args 114200a9ad5fe06c8dea76e15d92325695cf3e34 UnknownUnknown
unknown/mbed-tls/mbedtls 107ea89daaefb9867ea9121002fbbdf926780e98 UnknownUnknown
unknown/protocolbuffers/protobuf edaa823d8b36a8656d7b2b9241b7d0bfe50af878 UnknownUnknown
unknown/google/googletest v1.14.0 UnknownUnknown
unknown/kokke/tiny-aes-c 7e42e693288bdf22d8e677da94248115168211b9 UnknownUnknown
unknown/lwip-tcpip/lwip 77dcd25a72509eb83f72b033d219b1d40cd8eb95 UnknownUnknown
unknown/seggermicro/rtt ff57c3d516ea59b0a2d4d5cafb33a48572b09c0b UnknownUnknown
unknown/eclipse-threadx/threadx 06dabb0ad0403f59889ce85eeb3d48dbd9d3759b UnknownUnknown
unknown/protocolbuffers/protobuf edaa823d8b36a8656d7b2b9241b7d0bfe50af878 UnknownUnknown
unknown/google/googletest v1.14.0 UnknownUnknown
unknown/eclipse-threadx/threadx 06dabb0ad0403f59889ce85eeb3d48dbd9d3759b UnknownUnknown
unknown/kokke/tiny-aes-c 7e42e693288bdf22d8e677da94248115168211b9 UnknownUnknown
unknown/lwip-tcpip/lwip 77dcd25a72509eb83f72b033d219b1d40cd8eb95 UnknownUnknown
unknown/taywee/args 114200a9ad5fe06c8dea76e15d92325695cf3e34 UnknownUnknown
unknown/mbed-tls/mbedtls 107ea89daaefb9867ea9121002fbbdf926780e98 UnknownUnknown
unknown/seggermicro/rtt ff57c3d516ea59b0a2d4d5cafb33a48572b09c0b UnknownUnknown
unknown/kmackay/micro-ecc 24c60e243580c7868f4334a1ba3123481fe1aa48 UnknownUnknown
unknown/freertos/freertos-kernel def7d2df2b0506d3d249334974f51e427c17a41c UnknownUnknown
unknown/zeux/pugixml ef856bf975f4b1909af1b40ed3d7e28af9263d95 UnknownUnknown
unknown/lwip-tcpip/lwip 77dcd25a72509eb83f72b033d219b1d40cd8eb95 UnknownUnknown
unknown/kokke/tiny-aes-c 7e42e693288bdf22d8e677da94248115168211b9 UnknownUnknown
unknown/protocolbuffers/protobuf edaa823d8b36a8656d7b2b9241b7d0bfe50af878 UnknownUnknown
unknown/seggermicro/rtt ff57c3d516ea59b0a2d4d5cafb33a48572b09c0b UnknownUnknown
unknown/eclipse-threadx/threadx 06dabb0ad0403f59889ce85eeb3d48dbd9d3759b UnknownUnknown
unknown/google/googletest v1.14.0 UnknownUnknown
unknown/taywee/args 114200a9ad5fe06c8dea76e15d92325695cf3e34 UnknownUnknown
unknown/mbed-tls/mbedtls 107ea89daaefb9867ea9121002fbbdf926780e98 UnknownUnknown
unknown/zeux/pugixml ef856bf975f4b1909af1b40ed3d7e28af9263d95 UnknownUnknown
unknown/kmackay/micro-ecc 24c60e243580c7868f4334a1ba3123481fe1aa48 UnknownUnknown
unknown/freertos/freertos-kernel def7d2df2b0506d3d249334974f51e427c17a41c UnknownUnknown

Scanned Files

  • cmake/emil_test_helpers.cmake
  • external/args/CMakeLists.txt
  • external/crypto/mbedtls/CMakeLists.txt
  • external/crypto/micro-ecc/CMakeLists.txt
  • external/crypto/tiny-aes128/CMakeLists.txt
  • external/protobuf/CMakeLists.txt
  • external/segger_rtt/CMakeLists.txt
  • infra/syntax/CMakeLists.txt
  • lwip/lwip/CMakeLists.txt
  • osal/freertos/CMakeLists.txt
  • osal/threadx/CMakeLists.txt

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

⚠️MegaLinter analysis: Success with warnings

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ ACTION actionlint 12 0 0 0.27s
✅ CPP clang-format 1054 6 0 0 6.26s
✅ DOCKERFILE hadolint 2 0 0 0.25s
✅ JSON jsonlint 7 0 0 0.15s
✅ JSON prettier 7 0 0 0 0.5s
⚠️ MARKDOWN markdownlint 6 0 4 0 1.12s
✅ MARKDOWN markdown-table-formatter 6 0 0 0 0.28s
✅ REPOSITORY checkov yes no no 17.66s
✅ REPOSITORY git_diff yes no no 0.04s
✅ REPOSITORY grype yes no no 33.48s
✅ REPOSITORY ls-lint yes no no 0.06s
✅ REPOSITORY secretlint yes no no 7.68s
✅ REPOSITORY syft yes no no 1.27s
✅ REPOSITORY trivy yes no no 5.29s
✅ REPOSITORY trivy-sbom yes no no 0.16s
✅ REPOSITORY trufflehog yes no no 2.38s
⚠️ SPELL lychee 139 1 0 37.75s
⚠️ YAML prettier 22 1 1 0 0.64s
✅ YAML v8r 22 0 0 6.2s
✅ YAML yamllint 22 0 0 0.63s

Detailed Issues

⚠️ SPELL / lychee - 1 error
[404] https://github.com/protocolbuffers/protobuf/releases/download/v$%7Bprotobuf_tag%7D/protoc-$%7Bprotobuf_version%7D-$%7Bos_postfix%7D.zip | Network error: Not Found
📝 Summary
---------------------
🔍 Total..........544
✅ Successful.....540
⏳ Timeouts.........0
🔀 Redirected.......0
👻 Excluded.........3
❓ Unknown..........0
🚫 Errors...........1

Errors in external/protoc/CMakeLists.txt
[404] https://github.com/protocolbuffers/protobuf/releases/download/v$%7Bprotobuf_tag%7D/protoc-$%7Bprotobuf_version%7D-$%7Bos_postfix%7D.zip | Network error: Not Found
⚠️ MARKDOWN / markdownlint - 4 errors
external/crypto/tiny-aes128/README.md:1 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "### Tiny AES128 in C"]
external/crypto/tiny-aes128/README.md:29 error MD046/code-block-style Code block style [Expected: fenced; Actual: indented]
external/crypto/tiny-aes128/README.md:39 error MD046/code-block-style Code block style [Expected: fenced; Actual: indented]
external/crypto/tiny-aes128/README.md:49 error MD046/code-block-style Code block style [Expected: fenced; Actual: indented]
⚠️ YAML / prettier - 1 error
[error] Explicitly specified pattern "documents/modules/ROOT/examples/clangformat.yaml" is a symbolic link.
.clusterfuzzlite/project.yaml 36ms (unchanged)
.github/dependabot.yml 20ms (unchanged)
.github/workflows/ci.yml 60ms (unchanged)
.github/workflows/dependency-scanner.yml 12ms (unchanged)
.github/workflows/documentation.yml 13ms (unchanged)
.github/workflows/fuzzing-batch.yml 6ms (unchanged)
.github/workflows/fuzzing-cron.yml 8ms (unchanged)
.github/workflows/fuzzing-pr.yml 8ms (unchanged)
.github/workflows/linting-formatting.yml 7ms (unchanged)
.github/workflows/release-please.yml 12ms (unchanged)
.github/workflows/security.yml 9ms (unchanged)
.github/workflows/social-interaction.yml 3ms (unchanged)
.github/workflows/static-analysis.yml 9ms (unchanged)
.github/workflows/validate-pr.yml 11ms (unchanged)
.ls-lint.yml 5ms
.mega-linter.yml 2ms (unchanged)
antora-playbook-branch.yml 3ms (unchanged)
antora-playbook-site.yml 5ms (unchanged)
documents/antora.yml 1ms (unchanged)
documents/supplemental-ui/ui.yml 1ms (unchanged)
mull.yml 2ms (unchanged)

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.3.0 --custom-flavor-setup --custom-flavor-linters ACTION_ACTIONLINT,CPP_CLANG_FORMAT,DOCKERFILE_HADOLINT,JSON_JSONLINT,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_GRYPE,REPOSITORY_LS_LINT,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,SPELL_LYCHEE,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is graciously provided by OX Security

@richardapeters richardapeters marked this pull request as ready for review February 6, 2026 12:53
@richardapeters richardapeters requested a review from a team as a code owner February 6, 2026 12:53
Copilot AI review requested due to automatic review settings February 6, 2026 12:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds "peek ahead" functionality to the Sesame protocol to look ahead for window releases and initialization requests before processing the current message. This prevents blocking scenarios where a message is being processed while window release messages are waiting.

Changes:

  • Adds PeekMessage method to process messages without consuming them from the buffer
  • Modifies SesameCobs to peek ahead at incoming data before extracting it
  • Updates SesameWindowed to handle peeked init and window release messages

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
services/util/Sesame.hpp Adds abstract PeekMessage method to SesameEncodedObserver interface
services/util/SesameCobs.hpp Adds member variables and method declarations for peek functionality
services/util/SesameCobs.cpp Implements peek-ahead logic to process messages without consuming buffer data
services/util/SesameWindowed.hpp Adds PeekMessage override and discardUntilInit flag
services/util/SesameWindowed.cpp Implements peek message handling for init and window release operations
services/util/test_doubles/SesameMock.hpp Adds mock method for PeekMessage
services/util/test/TestSesameCobs.cpp Updates tests to expect peek calls and removes unnecessary mock expectations
services/util/test/TestSesameWindowed.cpp Adds tests for peek functionality and updates existing tests to use peek methods
services/echo_console/Main.cpp Reorders includes to avoid Windows.h macro conflict with PeekMessage

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 71 to 73
stream >> infra::MakeRange(data);

EXPECT_EQ(expected, data);
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The removal of the expectation for serial.Reader() returning emptyReader eliminates verification that the reader is properly reset after message receipt. This could allow bugs where the reader state persists incorrectly. Consider adding test coverage to verify reader state management after message processing.

Copilot uses AI. Check for mistakes.
TEST_F(SesameCobsTest, malformed_empty_message_is_discarded)
{
EXPECT_CALL(serial, Reader()).WillOnce(testing::ReturnRef(emptyReader)).RetiresOnSaturation();
ReceiveData(infra::ConstructBin()({ 0, 5, 0 }).Vector());
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The test for malformed empty messages no longer verifies the expected behavior of the reader state. With the removal of the EXPECT_CALL(serial, Reader()) expectation, there's no verification that the malformed message handling doesn't leave the reader in an inconsistent state. Add assertions to verify proper cleanup.

Copilot uses AI. Check for mistakes.
break;
auto dataSize = data.size();
ReceivedData(data);
receivePeekIndex -= dataSize - data.size();
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The calculation dataSize - data.size() is unclear without context. Consider extracting this into a named variable like consumedBytes or adding a comment explaining that this represents the amount of data consumed from the peek buffer.

Suggested change
receivePeekIndex -= dataSize - data.size();
auto consumedBytes = dataSize - data.size();
receivePeekIndex -= consumedBytes;

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings February 6, 2026 13:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


TEST_F(SesameCobsTest, receive_large_data)
{
ExpectPeekMessage(std::vector<uint8_t>(3, 3), 284);
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The peek message expectation creates a vector with 3 elements (all with value 3), but the full received message has 280 elements. This mismatch suggests the peek is only capturing the first 3 bytes due to the fixed size of receivedPeekMessage (max_size 3), which may not be the intended behavior for validating large messages.

Suggested change
ExpectPeekMessage(std::vector<uint8_t>(3, 3), 284);
ExpectPeekMessage(std::vector<uint8_t>(280, 3), 284);

Copilot uses AI. Check for mistakes.

TEST_F(SesameCobsTest, receive_interrupted_data)
{
ExpectPeekMessage({ 1, 2 }, 5);
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The peek message expects only 2 bytes { 1, 2 } but the full message contains { 1, 2 } (2 bytes as shown in the test), yet the encoded size is 5. This is inconsistent with other tests where peek captures fewer bytes than the full message, suggesting this might be testing truncation behavior that isn't clearly documented.

Copilot uses AI. Check for mistakes.

TEST_F(SesameCobsTest, receive_two_messages)
{
ExpectPeekMessage({ 1, 2, 3 }, 7);
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The first peek message expects { 1, 2, 3 } (3 bytes) but the actual message is { 1, 2, 3, 4 } (4 bytes). The second peek expects { 5, 6 } which matches the full message. This inconsistency in what peek captures (sometimes truncated, sometimes complete) needs clarification or the test expectations should match the actual peek behavior.

Suggested change
ExpectPeekMessage({ 1, 2, 3 }, 7);
ExpectPeekMessage({ 1, 2, 3, 4 }, 7);

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings February 6, 2026 14:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


if (messageSize != 0)
{
infra::LimitedStreamReaderWithRewinding::WithInput<infra::BoundedDequeInputStreamReader> reader(std::in_place, receivedPeekMessage, messageSize);
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The receivedPeekMessage deque has a max size of 3 bytes (line 93), but messageSize from currentPeekMessageSize can be larger than 3 (line 254 shows it accumulates all data.size()). This creates a mismatch where the reader is constructed with a size that exceeds the actual data available in the deque, which could lead to reading invalid data or undefined behavior.

Copilot uses AI. Check for mistakes.
Comment on lines +72 to 76
void PeekAndReceiveInitRequest(uint16_t availableWindow)
{
PeekInitRequest(availableWindow);
ReceiveInitRequest(availableWindow);
}
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The PeekAndReceiveInitRequest method calls ReceiveInitRequest, which internally calls PeekAndReceivePacket (line 69), resulting in the init request being peeked twice. This duplication may cause unexpected test behavior or make tests harder to understand.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings February 7, 2026 07:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 51 to +58
receivedMessage.clear();
receiveSizeEncoded = 0;
currentMessageSize = 0;
nextPeekOverhead = 1;
peekOverheadPositionIsPseudo = true;
receivedPeekMessage.clear();
receiveSizePeekEncoded = 0;
currentPeekMessageSize = 0;
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

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

receivePeekIndex is used to track how far peeking progressed (see DataReceived()), but it is not reset in Stop(). After stop/start cycles (or reusing the instance), peeking can start at a stale index and skip data. Reset receivePeekIndex (and any other peek cursor state) alongside the other peek-related fields in Stop().

Copilot uses AI. Check for mistakes.
Comment on lines +264 to +266
infra::LimitedStreamReaderWithRewinding::WithInput<infra::BoundedDequeInputStreamReader> reader(std::in_place, receivedPeekMessage, messageSize);
GetObserver().PeekMessage(reader, std::exchange(receiveSizePeekEncoded, 0));
receivedPeekMessage.clear();
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

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

receivedPeekMessage is capped to 3 bytes, but messageSize tracks the full decoded payload size. Constructing a reader with messageSize greater than the underlying stored bytes can misreport availability and can cause peek handlers to attempt to read beyond what is actually buffered. Consider constructing the peek reader with the actual buffered size (e.g., receivedPeekMessage.size()) or increasing the peek buffer to guarantee messageSize bytes are present.

Copilot uses AI. Check for mistakes.
virtual void SendMessageStreamAvailable(infra::SharedPtr<infra::StreamWriter>&& writer) = 0;
virtual void MessageSent(std::size_t encodedSize) = 0;
virtual void ReceivedMessage(infra::SharedPtr<infra::StreamReaderWithRewinding>&& reader, std::size_t encodedSize) = 0;
virtual void PeekMessage(infra::StreamReaderWithRewinding& reader, std::size_t encodedSize) = 0;
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

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

The new API name PeekMessage collides with the common Windows macro PeekMessage (as evidenced by the local #undef workaround added in services/echo_console/Main.cpp). This is likely to break other translation units depending on include order. Prefer renaming the API to a less collision-prone identifier (e.g., PeekReceivedMessage, InspectIncomingMessage, OnMessagePeek) rather than relying on per-file #undef fixes.

Suggested change
virtual void PeekMessage(infra::StreamReaderWithRewinding& reader, std::size_t encodedSize) = 0;
virtual void PeekReceivedMessage(infra::StreamReaderWithRewinding& reader, std::size_t encodedSize) = 0;

Copilot uses AI. Check for mistakes.
Comment on lines +54 to +61
EXPECT_CALL(observer, PeekMessage(testing::_, encodedSize)).WillOnce(testing::Invoke([this, expected](infra::StreamReaderWithRewinding& reader, uint16_t encodedSize)
{
infra::DataInputStream::WithErrorPolicy stream(reader);
std::vector<uint8_t> data(stream.Available(), 0);
stream >> infra::MakeRange(data);

EXPECT_EQ(expected, data);
}))
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

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

The lambda parameter type for encodedSize is uint16_t, while the mock signature (and the production API) uses std::size_t. This can introduce narrowing warnings or mismatches on platforms where size_t is wider. Use std::size_t in the lambda signature to match the API.

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 7, 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.

2 participants