Skip to content

Enforce no-Envelope contract for adapters and serializers#307

Closed
vjik wants to merge 1 commit into
masterfrom
no-envelope
Closed

Enforce no-Envelope contract for adapters and serializers#307
vjik wants to merge 1 commit into
masterfrom
no-envelope

Conversation

@vjik

@vjik vjik commented Jun 11, 2026

Copy link
Copy Markdown
Member
Q A
Is bugfix?
New feature?
Breaks BC? ✔️
Tests pass? ✔️

@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (97efb0c) to head (d75ad90).

Files with missing lines Patch % Lines
src/Middleware/Push/AdapterPushHandler.php 0.00% 2 Missing ⚠️
src/Message/JsonMessageSerializer.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             master    #307   +/-   ##
========================================
  Coverage      0.00%   0.00%           
  Complexity      330     330           
========================================
  Files            49      49           
  Lines           909     908    -1     
========================================
+ Misses          909     908    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

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 enforces a “no-Envelope input” contract for adapters and the JSON serializer by shifting envelope-carried data into message metadata, and by updating docs/tests to reflect the new contract (BC-breaking).

Changes:

  • Update unit tests and benchmarks to use withMetadata() instead of stacking Envelope wrappers.
  • Make JsonMessageSerializer::serialize() always record message-class as the concrete message class (no envelope unwrapping logic).
  • Update adapter/serializer interface documentation to state that inputs are never Envelope instances; add push-path unwrapping in AdapterPushHandler.

Reviewed changes

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

Show a summary per file
File Description
tests/Unit/Message/JsonMessageSerializerTest.php Updates serializer tests to use metadata instead of envelopes; adds assertions for preserved metadata.
tests/Benchmark/QueueBench.php Updates benchmark “consume mapping” fixture to serialize metadata directly instead of envelopes.
src/Middleware/Push/AdapterPushHandler.php Unwraps envelopes before calling the adapter’s push() method.
src/Message/MessageSerializerInterface.php Documents the no-Envelope input contract for serializers.
src/Message/JsonMessageSerializer.php Removes envelope-specific class resolution when serializing.
src/Adapter/AdapterInterface.php Documents the no-Envelope input contract for adapters and handler callbacks.

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

Comment on lines +22 to +24
return $this->adapter->push(
$message instanceof Envelope ? $message->getMessage() : $message,
);
Comment on lines +18 to +23
* Processes all messages that are currently in the queue. The message passed to the handler callback
* is guaranteed to not be an {@see Envelope} instance, only a plain {@see MessageInterface} with
* merged metadata from any wrapping envelopes.
*
* @param callable $handlerCallback The handler which will handle messages (never an {@see Envelope} instance).
* Returns `false` if it cannot continue handling messages.
Comment on lines +40 to +45
* Adds a message to the queue. The message is guaranteed to not be an {@see Envelope} instance,
* only a plain {@see MessageInterface} with merged metadata from any wrapping envelopes.
*
* @param MessageInterface $message The message to push. Never an {@see Envelope} instance.
* @return MessageInterface The message with any modifications made by the adapter. May be wrapped in
* an {@see Envelope} to carry additional metadata.
Comment on lines +52 to +57
* Listens to the queue and passes messages to the given handler as they become available.
* The message passed to the handler callback is guaranteed to not be an {@see Envelope} instance,
* only a plain {@see MessageInterface} with merged metadata from any wrapping envelopes.
*
* @param callable $handlerCallback The handler which will handle messages (never an {@see Envelope} instance).
* Returns `false` if it cannot continue handling messages.
Comment on lines +183 to 185
$message = (new TestMessage())
->withMetadata(['id' => 1]);
$serializer = $this->createSerializer();
@vjik vjik closed this Jun 11, 2026
@vjik vjik deleted the no-envelope branch June 11, 2026 07:53
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