diff --git a/scripts/ci/run-replay-regression-fixture.php b/scripts/ci/run-replay-regression-fixture.php index 521bfefb..744be589 100644 --- a/scripts/ci/run-replay-regression-fixture.php +++ b/scripts/ci/run-replay-regression-fixture.php @@ -952,6 +952,7 @@ private static function workflow(string $workflowType): callable } return match ($workflowType) { + 'golden.ordered-condition' => self::workflow('golden.signal'), 'golden.signal-occurrence-unavailable', 'golden.signal-occurrence-deferred' => self::workflow('golden.signal'), 'golden.telemetry-context' => static function (WorkflowContext $context): array { $result = $context->activity('golden.greet', ['Ada']); @@ -1493,6 +1494,7 @@ private static function workerTaskAttributes(array $fixture): array return array_intersect_key($workerTask, array_flip([ 'resume_source_kind', 'resume_source_id', 'workflow_signal_id', 'workflow_command_id', 'signal_name', + 'condition_wait_pending_input_sequence', ])); } diff --git a/src/Worker.php b/src/Worker.php index ad80dee9..3a8347e4 100644 --- a/src/Worker.php +++ b/src/Worker.php @@ -51,6 +51,7 @@ use DurableWorkflow\Worker\QueryTaskAuthority; use DurableWorkflow\Worker\Replayer; use DurableWorkflow\Worker\ReplayResult; +use DurableWorkflow\Worker\ConditionInputOrder; use DurableWorkflow\Worker\ScopedActivityCancellationObserved; use DurableWorkflow\Worker\WorkflowClaimAborted; use DurableWorkflow\Worker\WorkflowClaimDeferred; @@ -956,6 +957,7 @@ private function registerWithRetry(): ?array 'query_tasks', 'workflow_updates', 'durable_history_replay', + ConditionInputOrder::CAPABILITY, 'grouped_condition_wait_replay', 'workflow_entry_arguments_validation', 'graceful_shutdown', @@ -2179,6 +2181,12 @@ private function executeWorkflowTask(array $task): void } $this->completionPipeline?->join(); $this->assertPipelineAuthority(); + if ($commands === [] && array_key_exists(ConditionInputOrder::PENDING_INPUT, $task)) { + $this->client->failWorkflowTask($taskId, $leaseOwner, $attempt, + 'Workflow task waiting for scheduled history.', 'WorkflowTaskWaitingForHistory'); + + return; + } $this->assertWorkflowMemoUpdatesAvailable($commands); $this->assertServiceOperationsAvailable($commands); $this->assertChildStartTurnAvailable($commands); diff --git a/src/Worker/ConditionInputOrder.php b/src/Worker/ConditionInputOrder.php new file mode 100644 index 00000000..10cbda18 --- /dev/null +++ b/src/Worker/ConditionInputOrder.php @@ -0,0 +1,208 @@ + */ + private array $waits = []; + + /** @var list */ + private array $appliedPositions = []; + + /** @var array */ + private array $competingSelections = []; + + /** @param list> $history */ + public function __construct(array $history) + { + $receipts = []; + $terminals = []; + foreach ($history as $event) { + $type = $event['event_type'] ?? $event['type'] ?? null; + $payload = is_array($event['payload'] ?? null) ? $event['payload'] : []; + $sequence = $event['sequence'] ?? null; + if (is_int($sequence) && in_array($type, ['ChildRunCompleted', 'ChildRunFailed', 'ChildRunCancelled', 'ChildRunTerminated'], true)) { + $terminals[$sequence] = [$event['id'] ?? $event['event_id'] ?? null, $type]; + } + if ($type === 'SelectionCandidateReady') { + $group = $payload['selection_group_id'] ?? null; + $position = $payload['resolution_event_sequence'] ?? null; + $terminalId = $payload['resolution_event_id'] ?? null; + if (!is_string($group) || $group === '' || isset($this->competingSelections[$group]) + || !is_int($position) || $position < 1 || !is_int($sequence) || $position >= $sequence + || !is_string($terminalId) || $terminalId === '' + || ($terminals[$position] ?? null) !== [$terminalId, $payload['resolution_event_type'] ?? null]) { + throw $this->mismatch(); + } + $this->competingSelections[$group] = ['id' => $terminalId, 'sequence' => $position]; + } + $commandId = $event['workflow_command_id'] ?? $payload['workflow_command_id'] ?? null; + if (is_int($sequence) && $sequence > 0 && is_string($commandId) && $commandId !== '') { + if ($type === 'SignalReceived' || $type === 'UpdateAccepted') { + $receipts[$type][$commandId] ??= $sequence; + } elseif ($type === 'SignalApplied' || $type === 'UpdateApplied') { + $receiptType = $type === 'SignalApplied' ? 'SignalReceived' : 'UpdateAccepted'; + if (isset($receipts[$receiptType][$commandId])) { + $this->appliedPositions[] = $receipts[$receiptType][$commandId]; + } + } + } + $wait = $payload['condition_wait_id'] ?? null; + if (!is_string($wait) || $wait === '') { + continue; + } + if ($type === 'ConditionWaitOpened' && self::marked($payload)) { + if (!is_int($sequence) || $sequence < 1 || isset($this->waits[$wait])) { + throw $this->mismatch(); + } + $this->waits[$wait] = ['open' => $sequence, 'schedule' => null, 'timer' => null, 'fire' => null]; + continue; + } + $opening = $this->waits[$wait] ?? null; + if ($opening === null) { + continue; + } + if ($type === 'TimerScheduled') { + $timer = $payload['timer_id'] ?? null; + if (!self::marked($payload) || ($payload['timer_kind'] ?? null) !== 'condition_timeout' + || !is_int($sequence) || $sequence <= $opening['open'] || $opening['schedule'] !== null + || !is_string($timer) || $timer === '') { + throw $this->mismatch(); + } + $this->waits[$wait]['schedule'] = $sequence; + $this->waits[$wait]['timer'] = $timer; + } elseif ($type === 'TimerFired') { + if (!self::marked($payload) || ($payload['timer_kind'] ?? null) !== 'condition_timeout' + || ($payload['timer_id'] ?? null) !== $opening['timer'] || $opening['schedule'] === null + || !is_int($sequence) || $sequence <= $opening['schedule'] || $opening['fire'] !== null) { + throw $this->mismatch(); + } + $this->waits[$wait]['fire'] = $sequence; + } elseif ($type === 'ConditionWaitSatisfied' || $type === 'ConditionWaitTimedOut') { + $fire = $opening['fire']; + $receipt = $payload['input_receipt_sequence'] ?? null; + if (!self::marked($payload) || ($payload['timer_fired_sequence'] ?? null) !== $fire + || !is_int($sequence) || $sequence <= ($fire ?? $opening['open']) + || ($receipt !== null && (!is_int($receipt) || $receipt < 1 || $receipt >= $sequence)) + || ($type === 'ConditionWaitTimedOut' && ($fire === null || $receipt !== null)) + || ($type === 'ConditionWaitSatisfied' && $fire !== null && ($receipt === null || $receipt >= $fire))) { + throw $this->mismatch(); + } + } + } + foreach ($this->waits as $wait) { + if ($wait['schedule'] === null) { + throw $this->mismatch(); + } + } + sort($this->appliedPositions, SORT_NUMERIC); + } + + /** @param array $payload */ + public static function marked(array $payload): bool + { + return ($payload[self::CAPABILITY] ?? null) === self::ORDER; + } + + public function has(?string $id): bool + { + return $id !== null && isset($this->waits[$id]); + } + + /** + * @param array $task + * @return array|null + */ + public function decide( + string $id, + array $task, + WorkflowContext $context, + WorkflowCommand $command, + ?string $selectionGroup = null, + ): ?array + { + if (!array_key_exists(self::PENDING_INPUT, $task)) { + throw new WorkflowClaimDeferred('condition_input_snapshot_missing: ordered condition replay requires the original worker snapshot.'); + } + $pending = $task[self::PENDING_INPUT]; + if ($pending !== null && (!is_int($pending) || $pending < 1)) { + throw $this->mismatch(); + } + $wait = $this->waits[$id]; + $fire = $wait['fire']; + $candidate = $selectionGroup === null ? null : ($this->competingSelections[$selectionGroup] ?? null); + $terminal = min($fire ?? PHP_INT_MAX, $candidate['sequence'] ?? PHP_INT_MAX); + $limit = min($pending ?? PHP_INT_MAX, $terminal); + $prefix = []; + $entryReceipt = null; + foreach ($this->appliedPositions as $receipt) { + if ($receipt > $wait['open'] || $receipt >= $limit) { + break; + } + $prefix[$receipt] = true; + $entryReceipt = $receipt; + } + $result = ['type' => 'resolve_condition_wait', 'condition_wait_id' => $id]; + $error = null; + $evaluate = static function (array $view) use ($context, $command, &$error): bool { + try { + $error = null; + + return $context->withConditionInputReceipts($view, $command->conditionSatisfied(...)); + } catch (Throwable $failure) { + $error = $failure; + + return false; + } + }; + if ($evaluate($prefix) && ($entryReceipt !== null || $fire === null)) { + return $result + ['satisfied' => true] + ($entryReceipt === null ? [] : ['input_receipt_sequence' => $entryReceipt]); + } + foreach ($this->appliedPositions as $receipt) { + if ($receipt >= $limit) { + break; + } + if (isset($prefix[$receipt])) { + continue; + } + $prefix[$receipt] = true; + if ($evaluate($prefix)) { + return $result + ['satisfied' => true, 'input_receipt_sequence' => $receipt]; + } + } + if ($pending === null || $pending >= $terminal) { + if ($error !== null) { + throw $error; + } + if ($candidate !== null && $candidate['sequence'] === $terminal) { + return $result + ['satisfied' => false, 'competing_resolution_event_id' => $candidate['id']]; + } + if ($fire !== null) { + return $result + ['satisfied' => false]; + } + } + + return null; + } + + private function mismatch(): NonDeterministicWorkflow + { + return new NonDeterministicWorkflow('Ordered condition history does not match its original timer and receipt boundary.', + reason: 'condition_input_order_mismatch'); + } +} diff --git a/src/Worker/Replayer.php b/src/Worker/Replayer.php index 31ca04a4..3f0621f7 100644 --- a/src/Worker/Replayer.php +++ b/src/Worker/Replayer.php @@ -230,6 +230,8 @@ public function replay( // sdk-php#434: the applied-only signal marker is transparent to the // authored command sequence; only its position selects the view. $appliedSignals = AppliedSignals::fromHistory($history, $task); + $orderedConditions = new ConditionInputOrder($history); + $authorOrderedConditions = ($task[ConditionInputOrder::AUTHORING] ?? null) === true; $signalMarkerSequences = []; $steps = array_values(array_filter($steps, static function (array $step) use (&$signalMarkerSequences): bool { if ($step['shape'] === 'version_marker' && $step['detail'] === AppliedSignals::CHANGE_ID) { @@ -533,6 +535,10 @@ public function replay( ...$metadata, 'parallel_group_path' => $path, ]); + if ($suspended->mode === 'select' && $command->type === 'open_condition_wait' + && $authorOrderedConditions) { + $command = $this->anchorNewConditionChain($command, true); + } if (($encodingFailure = $this->appendWorkflowCommand( $commands, $command, @@ -565,6 +571,18 @@ public function replay( $history, $cancellation, $context, $cancellationConsumed); } if ($command->type === 'open_condition_wait') { + $waitId = $this->stringValue($step['condition_wait_id'] ?? null); + if ($waitId !== null && $orderedConditions->has($waitId)) { + $groupId = $path[0]['parallel_group_id'] ?? ''; + if (!isset($selectionResolutions[$groupId])) { + $decision = $orderedConditions->decide($waitId, $task, $context, $command, $groupId); + if ($decision !== null) { + $commands[] = $decision; + } + } + $pending = true; + continue; + } if ($command->conditionSatisfied()) { $results[$offset] = true; continue; @@ -963,6 +981,16 @@ public function replay( $suspended = $this->resumeExecution($execution, $businessReplayClock, $step['value'], $step); continue; } + $waitId = $this->stringValue($step['condition_wait_id'] ?? null); + if ($waitId !== null && $orderedConditions->has($waitId)) { + $decision = $orderedConditions->decide($waitId, $task, $context, $suspended); + if ($decision === null) { + return $this->result($commands, $context); + } + $commands[] = $decision; + $suspended = $this->resumeExecution($execution, $businessReplayClock, $decision['satisfied']); + continue; + } $satisfied = $appliedSignals->live(static fn (): bool => $suspended->conditionSatisfied()); if (($encodingFailure = $this->recordAppliedSignalMarker($appliedSignals, $commands, $nextSequence, $taskQueue, $context)) !== null) { return $encodingFailure; @@ -1055,7 +1083,7 @@ public function replay( continue; } if ($suspended->type === 'open_condition_wait') { - $suspended = $this->anchorNewConditionChain($suspended); + $suspended = $this->anchorNewConditionChain($suspended, $authorOrderedConditions); } if (($encodingFailure = $this->appendWorkflowCommand( $commands, @@ -1662,18 +1690,19 @@ private function recordedConditionDeadlinePolicy(array $payload, int $sequence): * the authored timeout; timeout_seconds stays the replay input (#269). * Grouped waits keep their authored per-open timeout. */ - private function anchorNewConditionChain(WorkflowCommand $command): WorkflowCommand + private function anchorNewConditionChain(WorkflowCommand $command, bool $authorOrderedConditions): WorkflowCommand { $timeout = $command->attributes['timeout_seconds'] ?? null; if (!$this->conditionOccurrenceDeadline || !is_int($timeout) || !is_string($command->attributes['condition_wait_occurrence_id'] ?? null) - || array_key_exists('parallel_group_path', $command->attributes)) { + || (!$authorOrderedConditions && array_key_exists('parallel_group_path', $command->attributes))) { return $command; } return $command->withAttributes([ 'deadline_policy' => self::CONDITION_DEADLINE_POLICY, 'condition_wait_timeout_budget_seconds' => $timeout, + ...($authorOrderedConditions ? [ConditionInputOrder::CAPABILITY => ConditionInputOrder::ORDER] : []), ]); } @@ -2127,6 +2156,9 @@ private function recordedSteps(array $history, bool $preserveConditionReopens, C } } elseif ($type === 'TimerFired') { if (($payload['timer_kind'] ?? null) === 'condition_timeout') { + if (ConditionInputOrder::marked($payload)) { + continue; + } $conditionStepKey = $this->conditionStepKey($payload, $conditionStepsByWaitId); if ($conditionStepKey !== null && isset($steps[$conditionStepKey]) diff --git a/src/Worker/WorkflowContext.php b/src/Worker/WorkflowContext.php index 8d26de6c..40b6606c 100644 --- a/src/Worker/WorkflowContext.php +++ b/src/Worker/WorkflowContext.php @@ -80,6 +80,25 @@ private static function scheduleOccurrence(string $value): ?DateTimeImmutable public const MAX_PARALLEL_OPERATIONS = 1000; + /** @var array|null */ + private ?array $conditionInputReceipts = null; + + /** + * @internal Limit only a condition predicate's observations to the applied input prefix. + * @param array $receipts + * @param Closure(): bool $predicate + */ + public function withConditionInputReceipts(array $receipts, Closure $predicate): bool + { + $previous = $this->conditionInputReceipts; + $this->conditionInputReceipts = $receipts; + try { + return $predicate(); + } finally { + $this->conditionInputReceipts = $previous; + } + } + /** * Call a registered service through a durable workflow command, without HTTP in workflow code. * The default waits for completion. Set wait_for=accepted to receive the original acceptance. @@ -981,11 +1000,12 @@ private function receivedSignals(string $signalName, ?AppliedSignals $applied): foreach ($this->history as $order => $event) { $payload = isset($event['payload']) && is_array($event['payload']) ? $event['payload'] : []; if (($event['event_type'] ?? $event['type'] ?? null) === 'SignalReceived' - && ($payload['signal_name'] ?? null) === $signalName) { + && ($payload['signal_name'] ?? null) === $signalName + && $this->includesConditionReceipt($event)) { $received[$order] = $payload; } } - if ($applied !== null) { + if ($applied !== null && $this->conditionInputReceipts === null) { $received = array_intersect_key($received, $applied->select(array_map( static fn (array $payload): array => ['event_type' => 'SignalReceived', 'payload' => $payload], $received))); } @@ -1005,7 +1025,8 @@ public function updates(string $updateName): array $updates = []; $seen = []; foreach ($this->history as $event) { - if (!in_array($event['event_type'] ?? $event['type'] ?? null, ['UpdateAccepted', 'UpdateApplied'], true)) { + if (!in_array($event['event_type'] ?? $event['type'] ?? null, ['UpdateAccepted', 'UpdateApplied'], true) + || !$this->includesConditionReceipt($event)) { continue; } $payload = isset($event['payload']) && is_array($event['payload']) ? $event['payload'] : []; @@ -1027,6 +1048,15 @@ public function updates(string $updateName): array return $updates; } + /** @param array $event */ + private function includesConditionReceipt(array $event): bool + { + $sequence = $event['sequence'] ?? null; + + return $this->conditionInputReceipts === null + || (is_int($sequence) && isset($this->conditionInputReceipts[$sequence])); + } + private function loadMessageStreamMessages(): void { $seenPositions = []; diff --git a/tests/ConditionWaitOrderedInputTest.php b/tests/ConditionWaitOrderedInputTest.php new file mode 100644 index 00000000..39de857c --- /dev/null +++ b/tests/ConditionWaitOrderedInputTest.php @@ -0,0 +1,66 @@ +waitCondition(static function () use ($context): bool { + $signals = $context->signals('approval'); + + return $signals !== [] && end($signals)[0] === true; + }, key: 'approval', timeout: 2); + }; + $worker = new Replayer($codec); + $worker->useConditionOccurrenceDeadline(true); + $legacyOpening = $worker->replay($workflow, [], [], 'test')->commands[0]; + self::assertArrayNotHasKey('condition_wait_input_order', $legacyOpening); + $opening = $worker->replay($workflow, [], [], 'test', ['condition_wait_input_order_authoring' => true])->commands[0]; + self::assertSame('open_condition_wait', $opening['type']); + self::assertSame('durable_receipt_order', $opening['condition_wait_input_order']); + unset($opening['type']); + $opening += ['sequence' => 1, 'condition_wait_id' => 'approval-wait']; + $timer = $opening + ['timer_id' => 'original-timer', 'timer_kind' => 'condition_timeout', 'delay_seconds' => 2]; + $event = static fn (int $sequence, string $type, array $payload): array => [ + 'sequence' => $sequence, 'event_type' => $type, 'payload' => $payload, + 'recorded_at' => '2026-11-23T22:00:00Z', + ]; + $approval = ['workflow_command_id' => 'approve', 'signal_name' => 'approval']; + $withdrawal = ['workflow_command_id' => 'withdraw', 'signal_name' => 'approval']; + $history = [ + $event(3, 'ConditionWaitOpened', $opening), + $event(4, 'TimerScheduled', $timer), + $event(5, 'SignalReceived', $approval + ['arguments' => ['codec' => 'avro', 'blob' => $codec->encode([true])]]), + $event(6, 'SignalReceived', $withdrawal + ['arguments' => ['codec' => 'avro', 'blob' => $codec->encode([false])]]), + $event(7, 'TimerFired', $timer), + ]; + $pending = $worker->replay($workflow, $history, [], 'test', ['condition_wait_pending_input_sequence' => 5]); + self::assertSame([], $pending->commands); + + $history[] = $event(8, 'SignalApplied', $approval); + $history[] = $event(9, 'SignalApplied', $withdrawal); + $resolved = $worker->replay($workflow, $history, [], 'test', ['condition_wait_pending_input_sequence' => null]); + self::assertSame([ + 'type' => 'resolve_condition_wait', 'condition_wait_id' => 'approval-wait', 'satisfied' => true, + 'input_receipt_sequence' => 5, + ], $resolved->commands[0]); + self::assertTrue($codec->decodeEnvelope($resolved->commands[1]['result'])); + + $history[] = $event(10, 'ConditionWaitSatisfied', $opening + [ + 'input_receipt_sequence' => 5, 'timer_fired_sequence' => 7, 'timer_id' => 'original-timer', + ]); + $replayed = (new Replayer($codec))->replay($workflow, $history, [], 'test'); + self::assertSame(['complete_workflow'], array_column($replayed->commands, 'type')); + self::assertTrue($codec->decodeEnvelope($replayed->commands[0]['result'])); + } +} diff --git a/tests/Support/ReplayRegressionFixture.php b/tests/Support/ReplayRegressionFixture.php index 93f6e455..fe1fcf40 100644 --- a/tests/Support/ReplayRegressionFixture.php +++ b/tests/Support/ReplayRegressionFixture.php @@ -232,7 +232,10 @@ public static function execute(array $fixture): array throw new RuntimeException("{$identity}.worker_task must be an object."); } // The resume context a signal-delivering task carries (sdk-php#434). - foreach (['resume_source_kind', 'resume_source_id', 'workflow_signal_id', 'workflow_command_id', 'signal_name'] as $field) { + foreach ([ + 'resume_source_kind', 'resume_source_id', 'workflow_signal_id', 'workflow_command_id', 'signal_name', + 'condition_wait_pending_input_sequence', + ] as $field) { if (array_key_exists($field, $workerTask)) { $task[$field] = $workerTask[$field]; } @@ -525,6 +528,7 @@ private static function occurrenceDeadlineAdvertised(string $workflowType, array private static function workflow(string $workflowType): callable { return match ($workflowType) { + 'golden.ordered-condition' => self::workflow('golden.signal'), 'golden.signal-occurrence-unavailable', 'golden.signal-occurrence-deferred' => self::workflow('golden.signal'), 'golden.telemetry-context' => static function (WorkflowContext $context): array { $result = $context->activity('golden.greet', ['Ada']); diff --git a/tests/WorkerAuthoringTest.php b/tests/WorkerAuthoringTest.php index 553acf03..595a8e2d 100644 --- a/tests/WorkerAuthoringTest.php +++ b/tests/WorkerAuthoringTest.php @@ -172,6 +172,7 @@ public function testHighLevelWorkerAdvertisesTheCompleteManagedCapabilitySet(): 'query_tasks', 'workflow_updates', 'durable_history_replay', + 'condition_wait_input_order', 'grouped_condition_wait_replay', 'workflow_entry_arguments_validation', 'graceful_shutdown', diff --git a/tests/fixtures/replay-regressions/ordered-condition-early-signal-after-timer.json b/tests/fixtures/replay-regressions/ordered-condition-early-signal-after-timer.json new file mode 100644 index 00000000..bde2337f --- /dev/null +++ b/tests/fixtures/replay-regressions/ordered-condition-early-signal-after-timer.json @@ -0,0 +1,105 @@ +{ + "$schema": "https://raw.githubusercontent.com/durable-workflow/.github/main/regression-corpus/evidence-schema.json", + "fixture_schema": "durable-workflow.replay-regression/v1", + "id": "php-ordered-condition-early-signal-after-timer", + "protocol_version": "1.20", + "bindings": [ + "php" + ], + "workflow": { + "type": "golden.ordered-condition", + "input": [ + "condition:signal" + ], + "payload_codec": "avro" + }, + "worker_task": { + "condition_wait_pending_input_sequence": null + }, + "history": [ + { + "sequence": 3, + "event_type": "ConditionWaitOpened", + "payload": { + "condition_key": "approval", + "timeout_seconds": 30, + "condition_wait_input_order": "durable_receipt_order", + "deadline_policy": "occurrence", + "condition_wait_timeout_budget_seconds": 30, + "condition_wait_id": "approval-wait", + "sequence": 1, + "condition_wait_occurrence_id": "php:condition-wait:0" + } + }, + { + "sequence": 4, + "event_type": "TimerScheduled", + "payload": { + "condition_key": "approval", + "timeout_seconds": 30, + "condition_wait_input_order": "durable_receipt_order", + "deadline_policy": "occurrence", + "condition_wait_timeout_budget_seconds": 30, + "condition_wait_id": "approval-wait", + "sequence": 1, + "timer_id": "approval-timer", + "timer_kind": "condition_timeout", + "delay_seconds": 30, + "condition_wait_occurrence_id": "php:condition-wait:0" + } + }, + { + "sequence": 5, + "event_type": "SignalReceived", + "payload": { + "workflow_command_id": "receipt-approve", + "signal_name": "approve", + "arguments": { + "codec": "avro", + "blob": "wwHioz3/VYAiNwwCAgEA" + } + } + }, + { + "sequence": 6, + "event_type": "TimerFired", + "payload": { + "condition_key": "approval", + "timeout_seconds": 30, + "condition_wait_input_order": "durable_receipt_order", + "deadline_policy": "occurrence", + "condition_wait_timeout_budget_seconds": 30, + "condition_wait_id": "approval-wait", + "sequence": 1, + "timer_id": "approval-timer", + "timer_kind": "condition_timeout", + "delay_seconds": 30, + "condition_wait_occurrence_id": "php:condition-wait:0" + } + }, + { + "sequence": 7, + "event_type": "SignalApplied", + "payload": { + "workflow_command_id": "receipt-approve", + "signal_name": "approve" + } + } + ], + "expected": { + "command_sequence": [ + { + "type": "resolve_condition_wait", + "condition_wait_id": "approval-wait", + "satisfied": true, + "input_receipt_sequence": 5 + }, + { + "type": "complete_workflow", + "result": { + "satisfied": true + } + } + ] + } +}