Skip to content

Fix numeric WireCodec aliases, expose all listener failures, docs refresh - #31

Merged
rasuvaeff merged 2 commits into
masterfrom
fix/review-2026-11-20
Nov 20, 2026
Merged

rasuvaeff merged 2 commits into
masterfrom
fix/review-2026-11-20

Conversation

@rasuvaeff

@rasuvaeff rasuvaeff commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Fixes #21
Fixes #22
Fixes #27
Fixes #30

Release header: ## 0.4.0 — 2026-11-20 (new public class → minor).

Local: composer build green, composer rector clean, mutation (--with-uncovered, assertions off) MSI 3.24 pp over minMsi 90.

Summary by Sourcery

Improve listener failure reporting and numeric wire-alias compatibility while refreshing documentation and release metadata.

New Features:

  • Expose all termination-listener failures through the new public ListenerFailuresException API.
  • Accept numeric WireCodec aliases and preserve them through encode/decode and JSON round trips.

Bug Fixes:

  • Prevent numeric wire aliases from causing type errors.
  • Clarify and test the remaining-budget behavior of cancelled contexts.

Build:

  • Update the Infection development dependency to ^0.35.

Documentation:

  • Refresh English and Russian documentation with adapter packages, database and process support, cancelled-context budget semantics, listener failure aggregation, and the new derivations example.
  • Document the new public listener-failure exception and UsleepSleeper in llms.txt.

Tests:

  • Add coverage for aggregated listener failures, descendant cascade failures, empty failure lists, single-failure rethrowing, cancelled-context budgets, and numeric alias round trips.

Chores:

  • Release version 0.4.0 with updated changelog entries.

@sourcery-ai

sourcery-ai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

API

Expose multi-listener termination failures through the new public exception while preserving the existing message and previous-exception chain.

  • src/Internal/ContextState.php L7, L195
  • src/ListenerFailuresException.php L1-43

Accept numeric aliases in the public WireCodec configuration and retain them as strings for encoding and decoding.

  • src/WireCodec.php L30-34 (+5 small edits)

Configuration

Raise the Infection development dependency to the version used by the updated mutation-testing setup.

  • composer.json L23

Documentation

Refresh release notes and English and Russian documentation for the new exception, numeric aliases, cancelled-context budgets, adapters, and examples.

  • CHANGELOG.md L8-20
  • README.md L27-35, L121-125, L166-169 (+3 small edits)
  • README.ru.md L29-37, L125-130, L171-174 (+3 small edits)
  • llms.txt L72-78 (+3 small edits)

Tests

Verify aggregation and propagation of listener failures, cancelled-context budget reporting, and numeric-alias round trips.

  • tests/ContextLifecycleTest.php L141-194 (+3 small edits)
  • tests/ContextTest.php L189-203
  • tests/WireCodecTest.php L187-216

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6403de35-12fa-46d7-aa58-3cb7e7cf304c
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@sourcery-ai

sourcery-ai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Linked issues

Checked at commit ab35250

#21 Termination listener failures are lost: only the last error survives aggregation · 1 of 1 met

# Requirement Status Notes
1 Expose every listener failure through an @api ListenerFailuresException while preserving the RuntimeException type, message, and previous chain. ✅ Met ContextState now returns ListenerFailuresException for multiple failures; it exposes errors() and reconstructs the existing message and previous-chain shape.

#22 WireCodec throws TypeError on a numeric alias · 1 of 2 met

# Requirement Status Notes
1 Accept and round-trip numeric WireCodec aliases, with a numeric-alias test. ✅ Met WireCodec casts alias keys to strings for validation, stores aliases separately from PHP array keys, and adds encode/decode and JSON round-trip tests.
2 Handle numeric keys in context-http's Baggage::merge() without a TypeError. ❌ Not addressed The PR description says the Baggage::merge() part lives in context-http; this change only updates WireCodec.

#27 Document `remainingMs()` for a cancelled context and pin it with a test · 1 of 1 met

# Requirement Status Notes
1 Document cancelled-context remainingMs() behavior in both READMEs and pin it with a test without changing the value. ✅ Met Both READMEs describe the remainder before the deadline and 1.0 after it; a test covers both cases.

#30 README is out of date: database support, sibling packages, examples table · 4 of 4 met

# Requirement Status Notes
1 Refresh README.md and README.ru.md with the sibling packages and corrected database-support information. ✅ Met Both READMEs list the adapter packages and describe the context-db server-side timeout support.
2 List derivations.php in the examples table. ✅ Met The entry is in both README examples tables and in examples/README.md.
3 Mention UsleepSleeper in llms.txt. ✅ Met llms.txt mentions UsleepSleeper.
4 Raise infection/infection from ^0.33 to ^0.35. ✅ Met composer.json changes the development dependency to ^0.35.

@sourcery-ai sourcery-ai Bot 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.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/WireCodec.php" line_range="68" />
<code_context>

         $values = [];
-        foreach ($this->aliases as $alias => $class) {
+        foreach ($this->aliases as [$alias, $class]) {
             $value = $context->value($class);
             if ($value instanceof WireValue) {
</code_context>
<issue_to_address>
**Numeric aliases lose their names**

When the codec accepts a numeric alias and the encoded values are JSON-serialized, `encode()` assigns `$values[$alias]`, and PHP coerces numeric-string aliases to integer keys; JSON encoding then emits a list for sequential keys, while `WireFormat` promises string-keyed aliases. Consumers cannot resolve the alias names.

Preserve numeric aliases as JSON object properties and make `WireFormat` accurately describe the encoded values, or reject aliases that PHP coerces to integers.

Also at `src/WireCodec.php:39`, `src/WireCodec.php:48`.
</issue_to_address>

### Comment 2
<location path="src/ListenerFailuresException.php" line_range="20" />
<code_context>
+    /**
+     * @param non-empty-list<\Throwable> $errors
+     */
+    public function __construct(private readonly array $errors)
+    {
+        $chain = $this->errors[\count($this->errors) - 1];
</code_context>
<issue_to_address>
**Empty failure lists create invalid exceptions**

When a caller directly constructs `ListenerFailuresException` with an empty array, `__construct()` indexes the last element of the empty array, emitting an undefined-key warning, and `errors()` then returns an empty array despite its non-empty-list contract; warning-to-exception handlers abort construction.

Reject an empty errors array before indexing it.
</issue_to_address>

Sourcery assessment

Approval pending. 2 findings to address first.

Blocking findings: src/WireCodec.php:68, src/ListenerFailuresException.php:20


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/WireCodec.php Resolved
Comment thread src/ListenerFailuresException.php Resolved
@rasuvaeff

Copy link
Copy Markdown
Owner Author

Review follow-up: an empty failure list is now rejected with InvalidArgumentException (the type is list<Throwable>, documented never empty). Numeric aliases are kept (the issue's proposal): they stay int keys, decode() reads them back even after a JSON round trip that turned 0..n into a list (new test); the docblock tells non-PHP consumers to prefer non-numeric aliases.

@rasuvaeff
rasuvaeff merged commit 28307c5 into master Nov 20, 2026
12 checks passed
@rasuvaeff
rasuvaeff deleted the fix/review-2026-11-20 branch November 20, 2026 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant