Skip to content

Conversation

@withinboredom
Copy link
Member

@withinboredom withinboredom commented Jul 31, 2025

Summary by CodeRabbit

  • New Features

    • You can now specify the expected result type when calling activities, sub-orchestrators, or waiting for external events, enabling automatic deserialization of results.
    • Improved type safety and clarity in orchestration context methods, including support for generic type annotations and variadic arguments.
  • Bug Fixes

    • Enhanced error handling with clearer exception messages when decoding orchestration status responses.
  • Style

    • Minor formatting improvements for code consistency.
  • Chores

    • Updated base Docker image for performance tests to PHP 8.4.

Signed-off-by: Robert Landers <landers.robert@gmail.com>
@coderabbitai
Copy link

coderabbitai bot commented Jul 31, 2025

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (2)
  • bin/composer.phar
  • bin/dphp

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce support for specifying and handling expected result types in orchestration futures. Method signatures in orchestration context classes and interfaces are updated to accept optional result type parameters and variadic arguments. The DurableFuture class now conditionally deserializes results based on the provided type. Additional improvements include enhanced type annotations, PHPDoc generics, code style consistency, improved error handling in JSON decoding, and updated test argument passing styles.

Changes

Cohort / File(s) Change Summary
DurableFuture Result Type & Deserialization
src/DurableFuture.php
DurableFuture constructor extended to accept an optional result type; getResult() conditionally deserializes the awaited result if type is provided; added imports for Serializer and LogicException; exception handling updated.
OrchestrationContext Method Signatures & Typing
src/OrchestrationContext.php
Updated method signatures (callActivity, createFuture, waitForExternalEvent, callSubOrchestrator) to support optional result types and variadic arguments; internal calls updated accordingly; formatting and code style improved.
Interface Type Safety & Generics
src/OrchestrationContextInterface.php
Method signatures updated to include optional result type parameters and variadic arguments; added template annotations for generics on waitAll and waitOne; improved PHPDoc for enhanced type hinting and clarity.
Testing Context Consistency & Formatting
src/Testing/DummyOrchestrationContext.php
Updated method signatures to match orchestration context changes; waitForExternalEvent accepts optional result type; added spaces after negation operators for readability; no changes to core logic or control flow.
Test Argument Passing Update
tests/Unit/OrchestrationHistoryTest.php
Modified test calls to callActivity to pass arguments as named parameter args with direct values instead of arrays; no changes to control flow or error handling.
Performance Test Argument Passing Update
tests/PerformanceTests/FanOutFanIn.php, tests/PerformanceTests/HelloCities/HelloSequence.php, tests/PerformanceTests/Sequence.php
Changed calls to callActivity to pass null for intermediate parameters and move arguments to variadic parameter position, replacing array argument style with variadic arguments.
Improved JSON Error Handling
src/RemoteOrchestrationClient.php
Wrapped JSON decoding in getStatus method with try-catch to catch JsonException and rethrow as RuntimeException with detailed message; added necessary imports for exception classes.
Docker Base Image Update
tests/PerformanceTests/Dockerfile
Updated base Docker image from php:8.3-zts to php:8.4-zts for performance tests environment.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant OrchestrationContext
    participant DurableFuture
    participant Serializer

    Caller->>OrchestrationContext: callActivity(name, returnType, ...args)
    OrchestrationContext->>DurableFuture: new DurableFuture(future, returnType)
    DurableFuture->>DurableFuture: getResult()
    alt returnType is provided
        DurableFuture->>Serializer: deserialize(awaitedResult, returnType)
        Serializer-->>DurableFuture: deserializedResult
        DurableFuture-->>Caller: deserializedResult
    else returnType is null
        DurableFuture-->>Caller: awaitedResult
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit hops through code anew,
With types and futures in its view.
Results now know what form to take,
Deserialized for safety’s sake.
Interfaces groomed, signatures neat—
These changes make the code complete!
🐇✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add/types

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Signed-off-by: Robert Landers <landers.robert@gmail.com>
Copy link

@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: 2

🔭 Outside diff range comments (1)
src/OrchestrationContext.php (1)

73-96: Fix missing RetryOptions handling in callActivity

The $retryOptions parameter in src/OrchestrationContext.php::callActivity is never used—retries aren’t being scheduled. To address this, either:

  • Implement retry logic by passing $retryOptions into your task scheduling (e.g. extend ScheduleTask::forName() or use a different scheduler method that accepts retry settings), or
  • Remove the unused $retryOptions parameter from both the interface and implementation if retries will not be supported here.

Locations to update:

  • src/OrchestrationContext.php (method callActivity)
  • src/OrchestrationContextInterface.php (parameter definition)
  • src/Testing/DummyOrchestrationContext.php (ensure dummy context signature matches)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a18fe4c and c5b30ac.

📒 Files selected for processing (4)
  • src/DurableFuture.php (1 hunks)
  • src/OrchestrationContext.php (10 hunks)
  • src/OrchestrationContextInterface.php (4 hunks)
  • src/Testing/DummyOrchestrationContext.php (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/Testing/DummyOrchestrationContext.php (3)
src/OrchestrationContextInterface.php (1)
  • waitForExternalEvent (140-140)
src/OrchestrationContext.php (1)
  • waitForExternalEvent (239-255)
src/DurableFuture.php (1)
  • DurableFuture (34-62)
src/OrchestrationContextInterface.php (3)
src/Testing/DummyOrchestrationContext.php (3)
  • callActivity (107-125)
  • waitForExternalEvent (263-270)
  • waitAll (357-368)
src/OrchestrationContext.php (3)
  • callActivity (73-96)
  • waitForExternalEvent (239-255)
  • waitAll (426-445)
src/DurableFuture.php (1)
  • DurableFuture (34-62)
🪛 PHPMD (2.15.0)
src/OrchestrationContext.php

73-73: Avoid unused parameters such as '$retryOptions'. (Unused Code Rules)

(UnusedFormalParameter)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Unit Tests - PHP
  • GitHub Check: build-docker
🔇 Additional comments (17)
src/Testing/DummyOrchestrationContext.php (4)

150-150: LGTM - Code style consistency improvement.

Adding space after the negation operator improves readability and maintains consistency with the formatting applied across the codebase.


263-270: LGTM - Proper implementation of typed result support.

The method signature correctly matches the updated interface, and the $resultType parameter is properly passed to the DurableFuture constructor to enable typed deserialization of external event results. The implementation maintains backward compatibility while supporting the new type safety features.


361-361: LGTM - Code style consistency improvement.

Consistent formatting with space after negation operator.


379-379: LGTM - Code style consistency improvement.

Consistent formatting with space after negation operator.

src/DurableFuture.php (4)

28-29: LGTM - Necessary imports for new functionality.

The Serializer import is required for the conditional deserialization feature, and importing LogicException is better practice than using the fully qualified name.


37-40: LGTM - Well-designed constructor enhancement.

The optional $resultType parameter maintains backward compatibility while enabling type-safe deserialization. The PHPDoc annotations correctly document the generic type relationship.


48-52: LGTM - Correct conditional deserialization implementation.

The logic correctly handles both cases: returning the raw result when no type is specified (maintaining backward compatibility) and deserializing to the specified type when provided. The implementation is clean and maintains the existing contract.


55-55: LGTM - Cleaner exception handling.

Using the imported LogicException class is better practice than the fully qualified name.

src/OrchestrationContext.php (6)

112-137: LGTM - Proper implementation of typed future creation.

The createFuture method correctly accepts and propagates the optional $resultType parameter to both DurableFuture constructor calls, enabling consistent typed deserialization across different execution paths.


79-84: LGTM - Improved code formatting.

Converting to arrow functions improves readability and consistency throughout the codebase.


119-119: LGTM - Code style consistency improvements.

Adding spaces after negation operators improves readability and maintains consistent formatting across the codebase.

Also applies to: 373-373, 460-460, 580-580


218-223: LGTM - Consistent arrow function formatting.

Arrow function conversion improves code consistency and readability.


239-255: LGTM - Proper implementation of typed external event waiting.

The method signature correctly implements the interface update, and the $resultType parameter is properly passed to the DurableFuture constructor to enable typed deserialization of external event data.


450-450: LGTM - Enhanced type documentation.

Adding the template annotation improves static analysis and IDE support for the generic type parameter.

src/OrchestrationContextInterface.php (3)

44-49: LGTM - Well-designed interface enhancement for type safety.

The method signature changes support type-safe activity results while maintaining backward compatibility. The parameter order (name, returnType, retryOptions, ...args) is logical, and the variadic arguments provide better flexibility than the previous array-based approach.


137-140: LGTM - Consistent interface enhancement for typed external events.

The method signature correctly supports typed deserialization of external event results, and both implementations (OrchestrationContext and DummyOrchestrationContext) properly implement this interface contract.


204-210: LGTM - Accurate generic type documentation.

The template annotations correctly document that waitOne accepts a DurableFuture<T> and returns the resolved result of type T.

Copy link

@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: 0

🧹 Nitpick comments (1)
src/Testing/DummyOrchestrationContext.php (1)

107-126: Method signature successfully updated for type safety.

The changes correctly align with the type safety objectives by adding $returnType parameter and using variadic arguments. The DurableFuture constructor call is properly updated to pass the return type.

However, the $retryOptions parameter is unused in this test implementation.

Consider removing the unused parameter or adding a comment explaining why it's kept for interface compliance:

 public function callActivity(
     string $name,
     ?string $returnType = null,
-    ?RetryOptions $retryOptions = null,
     mixed ...$args,
 ): DurableFuture {

Or add a comment:

 public function callActivity(
     string $name,
     ?string $returnType = null,
+    ?RetryOptions $retryOptions = null, // Kept for interface compliance, not used in test context
-    ?RetryOptions $retryOptions = null,
     mixed ...$args,
 ): DurableFuture {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c5b30ac and a3e2f38.

📒 Files selected for processing (1)
  • src/Testing/DummyOrchestrationContext.php (6 hunks)
🧰 Additional context used
🪛 PHPMD (2.15.0)
src/Testing/DummyOrchestrationContext.php

110-110: Avoid unused parameters such as '$retryOptions'. (Unused Code Rules)

(UnusedFormalParameter)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-docker
🔇 Additional comments (2)
src/Testing/DummyOrchestrationContext.php (2)

264-271: LGTM! Type safety enhancement applied correctly.

The method signature update and DurableFuture constructor call are consistent with the type safety objectives, enabling typed external event handling.


151-151: Good code style improvement.

Adding spaces after the negation operator improves readability and maintains consistent formatting throughout the codebase.

Also applies to: 362-362, 380-380

Signed-off-by: Robert Landers <landers.robert@gmail.com>
Signed-off-by: Robert Landers <landers.robert@gmail.com>
Signed-off-by: Robert Landers <landers.robert@gmail.com>
@codecov
Copy link

codecov bot commented Aug 1, 2025

Codecov Report

❌ Patch coverage is 72.72727% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.31%. Comparing base (a18fe4c) to head (690ec01).
⚠️ Report is 1 commits behind head on v2.

Files with missing lines Patch % Lines
src/RemoteOrchestrationClient.php 0.00% 3 Missing ⚠️
src/DurableFuture.php 60.00% 2 Missing ⚠️
src/OrchestrationContext.php 89.47% 2 Missing ⚠️
src/Testing/DummyOrchestrationContext.php 66.66% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                 v2     #151      +/-   ##
============================================
- Coverage     46.35%   46.31%   -0.04%     
- Complexity     1248     1250       +2     
============================================
  Files            99       99              
  Lines          3562     3565       +3     
============================================
  Hits           1651     1651              
- Misses         1911     1914       +3     

☔ View full report in Codecov by Sentry.
📢 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.

Copy link

@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: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b36bfba and 7858ac2.

📒 Files selected for processing (1)
  • tests/Unit/OrchestrationHistoryTest.php (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
tests/Unit/OrchestrationHistoryTest.php (3)
src/OrchestrationContextInterface.php (1)
  • callActivity (49-49)
src/Testing/DummyOrchestrationContext.php (2)
  • callActivity (107-126)
  • DummyOrchestrationContext (58-412)
src/Testing/ActivityMock.php (1)
  • ActivityMock (29-50)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Unit Tests - PHP
  • GitHub Check: build-docker

Signed-off-by: Robert Landers <landers.robert@gmail.com>
Copy link

@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: 0

🧹 Nitpick comments (1)
src/RemoteOrchestrationClient.php (1)

99-103: Enhanced error handling improves debugging capabilities.

The try-catch wrapper around json_decode provides better error context by including the raw response body in the error message and preserving the original JsonException. This aligns well with the PR's type safety objectives.

Consider these minor improvements:

-        } catch (JsonException $exception) {
-            throw new RuntimeException('Failed to decode JSON: ' . $body, previous: $exception);
+        } catch (JsonException $exception) {
+            throw new RuntimeException('Failed to decode JSON response: ' . $body, previous: $exception);

Note: Be aware that including the raw response body in error messages might expose sensitive information in logs. Consider truncating or sanitizing the body if it could contain sensitive data.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7858ac2 and e08d115.

📒 Files selected for processing (1)
  • src/RemoteOrchestrationClient.php (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build-docker
  • GitHub Check: Unit Tests - PHP
🔇 Additional comments (1)
src/RemoteOrchestrationClient.php (1)

38-38: LGTM! Proper exception imports added.

The JsonException and RuntimeException imports are correctly added and positioned alphabetically within the existing import block. These are necessary for the enhanced error handling in the getStatus method.

Also applies to: 40-40

Signed-off-by: Robert Landers <landers.robert@gmail.com>
@bottledcode bottledcode deleted a comment from github-actions bot Aug 1, 2025
@github-actions
Copy link

github-actions bot commented Aug 1, 2025

Performance Metrics

test time (s) memory usage
perf 15.93 102
Fan out/in 60.06 8

Performance Metrics

test time (s) memory usage
perf 46.45 174
Fan out/in 60.06 8

Performance Metrics

test time (s) memory usage
perf 15.76 102
Fan out/in 60.06 8

Signed-off-by: Robert Landers <landers.robert@gmail.com>
Signed-off-by: Robert Landers <landers.robert@gmail.com>
@withinboredom withinboredom merged commit 2d0e58f into v2 Aug 1, 2025
6 checks passed
@withinboredom withinboredom deleted the add/types branch August 1, 2025 21:11
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