From caf91babd5a3f0645c997971f117ac8e1dd361e0 Mon Sep 17 00:00:00 2001 From: Durable Workflow Date: Thu, 24 Sep 2026 16:08:19 +0000 Subject: [PATCH] fix: describe terminal workflow cancellation accurately --- docs/cli-reference.md | 2 +- src/Commands/WorkflowCommand/CancelCommand.php | 11 ++++++----- tests/Commands/WorkflowControlPlaneCommandTest.php | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/cli-reference.md b/docs/cli-reference.md index 146f620..ea90d5d 100644 --- a/docs/cli-reference.md +++ b/docs/cli-reference.md @@ -464,7 +464,7 @@ dw workflow:update order-123 approve --input='{"approver":"admin"}' dw bridge:webhook stripe --action=start_workflow --idempotency-key=stripe-event-1001 --target='{"workflow_type":"orders.fulfillment","task_queue":"external-workflows","business_key":"order-1001"}' --input='{"order_id":"order-1001"}' dw bridge:webhook pagerduty --action=signal_workflow --idempotency-key=pd-event-3003 --target='{"workflow_id":"wf-remediation-42","signal_name":"incident_escalated"}' --input='{"severity":"critical"}' --json -# Cancel a workflow (workflow code can observe and clean up) +# Close a workflow as cancelled (workflow code does not run cleanup) dw workflow:cancel order-123 --reason="Customer request" dw workflow:cancel --all-matching='customer-42' --yes --reason="Customer request" diff --git a/src/Commands/WorkflowCommand/CancelCommand.php b/src/Commands/WorkflowCommand/CancelCommand.php index 289d404..547ea25 100644 --- a/src/Commands/WorkflowCommand/CancelCommand.php +++ b/src/Commands/WorkflowCommand/CancelCommand.php @@ -23,10 +23,11 @@ protected function configure(): void { parent::configure(); $this->setName('workflow:cancel') - ->setDescription('Request cancellation of a workflow') + ->setDescription('Close a workflow as cancelled') ->setHelp(<<<'HELP' -Request cooperative cancellation. The workflow receives a cancellation -signal and has a chance to run its cancellation handlers. +Close the workflow run as cancelled immediately. Open tasks and timers are +cancelled; workflow code does not resume to run cleanup. Arrange compensation +before this command or use external reconciliation. Examples: @@ -79,7 +80,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return $this->renderJson($output, $result); } - $output->writeln('Cancellation requested'); + $output->writeln('Workflow cancelled'); $output->writeln(' Workflow ID: '.$result['workflow_id']); $this->writeNamespaceLine($output, $result); $output->writeln(' Outcome: '.$result['outcome']); @@ -178,7 +179,7 @@ private function executeBatchCancel(InputInterface $input, OutputInterface $outp return $this->renderBatchJson($output, $summary, $exitCode); } - $output->writeln(sprintf('Cancellation requested for %d workflow%s.', count($results), count($results) === 1 ? '' : 's')); + $output->writeln(sprintf('Cancelled %d workflow%s.', count($results), count($results) === 1 ? '' : 's')); $this->writeNamespaceLine($output, $summary); $output->writeln(sprintf(' Matched: %d', count($matches))); $output->writeln(sprintf(' Failed: %d', count($failures))); diff --git a/tests/Commands/WorkflowControlPlaneCommandTest.php b/tests/Commands/WorkflowControlPlaneCommandTest.php index bdeb30a..6f82bc7 100644 --- a/tests/Commands/WorkflowControlPlaneCommandTest.php +++ b/tests/Commands/WorkflowControlPlaneCommandTest.php @@ -210,7 +210,7 @@ public function test_cancel_command_batch_cancels_matching_workflows_after_confi $display = $tester->getDisplay(); self::assertStringContainsString('Cancel 2 workflows matching [customer-42]?', $display); - self::assertStringContainsString('Cancellation requested for 2 workflows.', $display); + self::assertStringContainsString('Cancelled 2 workflows.', $display); self::assertStringContainsString('Matched: 2', $display); self::assertStringContainsString('wf-1', $display); self::assertStringContainsString('wf-2', $display);