Skip to content

feat: add Nexus integration - #768

Open
xepozz wants to merge 36 commits into
masterfrom
nexus-new
Open

xepozz wants to merge 36 commits into
masterfrom
nexus-new

Conversation

@xepozz

@xepozz xepozz commented Jun 23, 2026 •

Copy link
Copy Markdown
Collaborator

Comment thread src/Workflow/NexusOperationOptions.php Resolved
/**
* Description of the workflow that backs a Nexus operation.
*/
final class WorkflowHandle

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I was a little confused by the naming here as it felt a bit like this was a reference to a running workflow, but it's actually the input to a start workflow call.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This mirrors java's io.temporal.nexus.WorkflowHandle naming
If you think that we should rename it, please suggest alternatives

Comment thread src/Internal/Nexus/NexusTaskHandler.php Resolved
Comment thread src/Internal/Nexus/NexusTaskHandler.php Resolved
xepozz added 2 commits July 10, 2026 09:23
…n timeouts

Address PR #768 review:
- deadlineFromHeaders parses Request-Timeout only (operation timeout is the
  total budget, left in forwarded headers); applied to cancel context too
- add scheduleToStart and startToClose timeouts to NexusOperationOptions
xepozz added a commit that referenced this pull request Jul 10, 2026
…n timeouts

Address PR #768 review:
- deadlineFromHeaders parses Request-Timeout only (operation timeout is the
  total budget, left in forwarded headers); applied to cancel context too
- add scheduleToStart and startToClose timeouts to NexusOperationOptions
xepozz added 4 commits July 14, 2026 00:22
Nexus post-merge cleanup:
- Remove comment-rule violations from branch-added Nexus files; expand
  abbreviations ($u/$m -> $uriParts/$pathMatches, etc.).
- Home the shared endpoint/service override on
  ExecuteNexusOperationInput::effectiveOptions(), dropping the duplicated
  effectiveNexusOptions()/effectiveOptions() helpers.
- Unify the empty endpoint/service error paths: drop the raw assert() and
  constructor validation so NexusOperationStub::assertOperationParams() is
  the single source of truth.
Task 5 — fix the NexusOperationStub start-handshake rejection: extract
handleFromStarted() and, when the started-promise rejects, consume the
result-promise so its rejection is not left unhandled. Add regression tests
covering both the rejection surfacing and the no-leak guarantee.

Task 6 — test-convention drift across tests/Nexus and tests/Unit/Nexus:
expectExceptionMessageMatches -> full-message assertions, add missing
#[CoversClass], and strip stray test-body comments.
Task 7 — add tests/Arch/NexusDependencyTest.php enforcing that Nexus\*
depends only on Common/Exception/Workflow, with a verified exemption list
for the bridge types that legitimately reach Client\*/Internal\* (the
Handler/Internal dispatch subtree plus Nexus, Header, NexusOperationContext,
WorkflowHandle).
Task 8 — verified the ErrorType wire values against nexus-rpc/sdk-go: the
values are canonical, so no behavior change. Only document that Unknown is a
local decode fallback for unrecognized incoming types (never emitted on the
wire); every other case is a spec-defined value.
@xepozz
xepozz marked this pull request as ready for review July 20, 2026 18:41
@xepozz
xepozz requested review from a team, roxblnfk and wolfy-j as code owners July 20, 2026 18:41

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0d85d80b05

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +59 to 63
$context->getClient()->send(new CommandResponse(
command: self::COMMAND_VALIDATED,
options: ['id' => $updateId],
payloads: null,
failure: null,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve JSON-codec support for update responses

With the default JSON codec (WorkerFactory::createCodec() selects JsonCodec when RR_CODEC is unset), any workflow update now sends CommandResponse, but JsonCodec\Encoder has no CommandResponse branch and throws Unserializable command type ...CommandResponse. The previous UpdateResponse was the only type used here and was handled by the old protocol encoder; consequently update validation and completion fail for existing JSON-codec workers.

Useful? React with 👍 / 👎.

shanginn pushed a commit to shanginn/sdk-php that referenced this pull request Jul 30, 2026
…n timeouts

Address PR temporalio#768 review:
- deadlineFromHeaders parses Request-Timeout only (operation timeout is the
  total budget, left in forwarded headers); applied to cancel context too
- add scheduleToStart and startToClose timeouts to NexusOperationOptions
xepozz and others added 6 commits August 18, 2026 11:28
# Conflicts:
#	tests/Functional/ReplayerTestCase.php
#	tests/Unit/DTO/WorkflowOptionsTestCase.php
- drop caller-settable Nexus headers from the public stub API (interceptor
  input keeps them, matching sdk-go and sdk-java)
- reject the reserved __temporal_ prefix in service, operation and endpoint names
- map a generic WorkflowException to a BadRequest handler error
A failed operation now travels as an application failure typed OperationError
and a canceled one as a canceled failure, so a handler written in PHP is
indistinguishable from a Go or Java handler to any caller.
# Conflicts:
#	composer.json
#	testing/src/Environment.php
xepozz added 18 commits October 13, 2026 11:40
Keep the generic CommandResponse with the serialization context, and decode the RawValue worker info in the test.
Velox builds rr with the nexus plugin, the temporal CLI moves to a stable release, and the acceptance config loses the absolute log paths.
A container-resolved `[TestCase::class, 'workerOptions']` callable crashed the acceptance worker on spiral/core 3.14.9, and the temporal CLI is pinned to the 1.5 line.
# Conflicts:
#	.github/workflows/run-test-suite.yml
#	dload.xml
#	tests/Acceptance/ExecutionStartedSubscriber.php
…aster

RR no longer wraps the whole failure as the cause, as Go and Java do, so a direct HTTP caller gets no message for a causeless failure.
The release supersedes both temporary pins: it carries the Nexus merge and the
Lambda Runtime API.
RoadRunner 3.3.0 ships roadrunner-temporal v6.2.0 with Nexus, so the custom build is not necessary.
Revert cosmetic edits, debug helpers, the unused clock, zero-timer tests and Psalm stubs. Read the HTTP port of the test server from TEMPORAL_HTTP_PORT.
Remove comments and plan notes, merge duplicate tests, compare values exactly, and wait on real conditions in place of timers.
Comment thread docs/data-conversion/architecture.md Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please translate to EN

Comment thread CLAUDE.md Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

to AGENTS.md as standard, should we split LLM prepare vs this work? i see some mixup

Comment on lines +59 to +64
public function start(
string $operation,
array $args = [],
Type|string|\ReflectionClass|\ReflectionType|null $returnType = null,
array $nexusHeaders = [],
): PromiseInterface {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think this should run the interceptors?

Comment on lines +60 to +65
[
'badRequest' => [[NexusHandlerFailure::class, 'BAD_REQUEST']],
'internal' => [[NexusHandlerFailure::class, 'INTERNAL']],
'notFound' => [[NexusHandlerFailure::class, 'NOT_FOUND']],
'unauthorized' => [[NexusHandlerFailure::class, 'UNAUTHORIZED']],
'notRegistered' => [[NexusHandlerFailure::class, 'NOT_FOUND']],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems like there's an asymmetry between the caller and the handler here where the handler throws HandlerException and the caller receives NexusHandlerFailure which have different behaviors. For example isRetryable() is available on HandlerException but not on NexusHandlerFailure.

public function sayHello1(string $name): string;

#[AsyncOperation(output: 'string')]
public function sayHello2(string $name): WorkflowHandle;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A service interface should type check against the output type. So a caller workflow that uses this service should see that sayHello2 accepts and returns string and be unaware that the operation uses a workflow to back it.

This branch has not been deployed

No deployments
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.

4 participants