Skip to content

Commit 113cc6b

Browse files
deploy: b3e82fe
1 parent 8ff30b5 commit 113cc6b

172 files changed

Lines changed: 340 additions & 619 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2.0/llms-full.txt

Lines changed: 1 addition & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -868,18 +868,13 @@ Per-call options take highest priority, then activity class properties, then the
868868

869869
# Starting Workflows
870870

871-
To start a workflow, create a workflow instance and then call the `start()` method on it. The `start()` method splits public instance identity from run identity.
871+
To start a workflow, create a workflow instance and then call the `start()` method on it.
872872

873873
```php
874874
use Workflow\V2\WorkflowStub;
875875

876876
$workflow = WorkflowStub::make(MyWorkflow::class);
877-
878-
$instanceId = $workflow->id(); // Public workflow instance id
879-
880877
$workflow->start();
881-
882-
$runId = $workflow->runId(); // Active run id after start is accepted
883878
```
884879

885880
Once a workflow has been started, it will be executed asynchronously by a queue worker. The `start()` method returns immediately and does not block the current request.
@@ -892,23 +887,6 @@ use Workflow\V2\WorkflowStub;
892887
$workflow = WorkflowStub::load($id);
893888
```
894889

895-
## Instance and Run Identity
896-
897-
- `id()` is the stable public workflow instance id.
898-
- Caller-supplied instance ids must currently be non-empty URL-safe strings up to 191 characters using only letters, numbers, `.`, `_`, `-`, and `:`.
899-
- `runId()` is the current run id for that instance.
900-
- `load($instanceId)` keeps the stub instance-centric, while `loadRun($runId)` selects one concrete run explicitly.
901-
- `make()` durably reserves the public workflow instance id immediately, before the first start command is accepted.
902-
- `status()` returns `reserved` while that durable reservation exists but no run has started yet.
903-
- `make(MyWorkflow::class, 'order-123')` creates or reloads the same durable reservation through the public instance id itself, so repeated callers can address one logical workflow instance without creating duplicate rows.
904-
- `start()` accepts the first start command, creates the first run, records typed `StartAccepted` and `WorkflowStarted` history events, and schedules the initial workflow task.
905-
- `start()` can also receive `StartOptions::withVisibility(...)->withMemo(...)` as its final argument to attach operator-facing `business_key`, exact-match string `visibility_labels`, and returned-only `memo` metadata. `business_key` and `visibility_labels` flow into the instance, run, run summary, typed start history, selected-run detail, and history export. `memo` flows into the instance, run, typed start history, selected-run detail, and history export, and it is carried into later `continueAsNew()` runs.
906-
- `summary()` returns the current run summary projection when one exists.
907-
- `refresh()` reloads the current instance and resolves the newest durable run for that instance from storage.
908-
- `continueAsNew()` keeps that same instance id but advances `runId()` to the newest run after `refresh()`.
909-
- `completed()`, `failed()`, `cancelled()`, and `terminated()` are convenience helpers for terminal run states.
910-
- Instance-targeted `load($instanceId)` and current-run commands resolve the newest durable run in the instance chain instead of trusting only the mutable current-run pointer, so continue-as-new chains stay addressable even if that column drifts.
911-
912890
## Start Options
913891

914892
```php
@@ -935,32 +913,6 @@ $workflow->start(
935913
);
936914
```
937915

938-
Visibility labels are exact-match strings for operator filtering in Waterline, not a high-volume analytics payload. Label keys use letters, numbers, `.`, `_`, `-`, and `:`, up to 64 characters. Label values and `business_key` are non-empty strings up to 191 characters.
939-
940-
`memo` is JSON-like metadata for selected-run detail and history export, not a list-filter or run-summary search field. Top-level and nested memo object keys must be non-empty strings up to 64 characters, and memo values may be scalars, `null`, arrays, or nested objects.
941-
942-
### Search Attributes
943-
944-
Search attributes are indexed scalar metadata for operator filtering and fleet visibility. Unlike memo, search attributes are surfaced in run list views and can be used for visibility filtering in Waterline:
945-
946-
```php
947-
$workflow->start(
948-
$orderId,
949-
StartOptions::withVisibility(
950-
businessKey: 'order-123',
951-
labels: ['tenant' => 'acme'],
952-
)->withSearchAttributes([
953-
'priority' => 'high',
954-
'status' => 'pending',
955-
'amount' => '99.50',
956-
]),
957-
);
958-
```
959-
960-
Search attribute keys follow the same rules as visibility label keys: letters, numbers, `.`, `_`, `-`, and `:`, up to 64 characters. Values must be scalars or `null`. Boolean values are cast to `"1"` or `"0"`, and `null` values are silently dropped. Empty string values after casting are also dropped.
961-
962-
Search attributes can be upserted during workflow execution using `upsertSearchAttributes()`, which merges the new attributes into the existing set.
963-
964916
### Execution and Run Timeouts
965917

966918
`StartOptions` also supports execution-level and run-level timeouts:
@@ -979,97 +931,6 @@ $workflow->start(
979931

980932
Both timeouts must be at least 1 second. Pass `null` (the default) to leave the timeout unlimited.
981933

982-
## Workflow Type
983-
984-
The durable `workflow_type` for that instance comes from either:
985-
986-
- a `#[Type('...')]` attribute on the workflow class, or
987-
- a config registration under `workflows.v2.types.workflows`
988-
989-
Example config registration when you do not want to annotate the class directly:
990-
991-
```php
992-
// config/workflows.php
993-
'v2' => [
994-
'types' => [
995-
'workflows' => [
996-
'billing.invoice-sync' => App\Workflows\InvoiceSyncWorkflow::class,
997-
],
998-
'activities' => [
999-
'payments.capture' => App\Activities\CapturePaymentActivity::class,
1000-
],
1001-
],
1002-
],
1003-
```
1004-
1005-
That same config map is also the fallback path when a worker needs to resolve a stored durable type after a PHP class rename. Keep the durable type key stable, update the map to the new class, and the runtime can continue loading the run without rewriting the public instance id.
1006-
1007-
When that fallback is used on a reserved start or on `continueAsNew()`, the newly written run is now normalized onto the resolved class before it is stored. That means the next run's `workflow_class` and snapped signal or update contract no longer stay stuck on the stale PHP FQCN once the durable type key has been remapped.
1008-
1009-
## Cancellation and Termination
1010-
1011-
The same stub can close an in-flight run explicitly:
1012-
1013-
```php
1014-
$workflow = WorkflowStub::load($instanceId);
1015-
1016-
$workflow->cancel(); // marks the current run as cancelled
1017-
$workflow->terminate(); // marks the current run as terminated
1018-
```
1019-
1020-
Both methods target the current run for that instance, return a typed command result, and persist durable command history before the run summary is updated. If the command cannot be applied, `cancel()` and `terminate()` throw a `LogicException`.
1021-
1022-
Use `attemptCancel()` or `attemptTerminate()` when you want the outcome without an exception:
1023-
1024-
```php
1025-
$workflow = WorkflowStub::load($instanceId);
1026-
1027-
$result = $workflow->attemptCancel();
1028-
// or $result = $workflow->attemptTerminate();
1029-
1030-
$result->commandId(); // Durable terminal command id
1031-
$result->commandSequence(); // Durable command order within the selected run
1032-
$result->instanceId(); // Public workflow instance id
1033-
$result->runId(); // Current run id, or null if the instance never started
1034-
$result->requestedRunId(); // Explicitly selected run id, or null for instance-targeted commands
1035-
$result->resolvedRunId(); // Run the engine actually resolved for this command
1036-
$result->targetScope(); // "instance" or "run"
1037-
$result->workflowType(); // Durable workflow type key for the targeted instance
1038-
$result->status(); // "accepted" or "rejected"
1039-
$result->accepted(); // true or false
1040-
$result->outcome(); // "cancelled", "terminated", "rejected_not_started", "rejected_not_active", or "rejected_not_current"
1041-
$result->rejectionReason(); // null, "instance_not_started", "run_not_active", or "selected_run_not_current"
1042-
```
1043-
1044-
If you want to target one selected run explicitly, load it by run id:
1045-
1046-
```php
1047-
$selectedRun = WorkflowStub::loadRun($runId);
1048-
1049-
$selectedRun->currentRunId(); // current run for the instance
1050-
$selectedRun->currentRunIsSelected(); // whether this selected run is still current
1051-
1052-
$result = $selectedRun->attemptCancel();
1053-
```
1054-
1055-
That run-targeted command stays durable even when the selected run is historical. In that case the engine rejects it with `targetScope() === 'run'`, `outcome() === 'rejected_not_current'`, and `rejectionReason() === 'selected_run_not_current'`, while `requestedRunId()` keeps the rejected historical run and `resolvedRunId()` points at the current run that should be addressed next.
1056-
1057-
## Webhook Routes
1058-
1059-
The same engine-level commands are exposed to external callers through webhook routes:
1060-
1061-
```text
1062-
POST /webhooks/instances/{workflowId}/runs/{runId}/updates/{update}
1063-
POST /webhooks/instances/{workflowId}/runs/{runId}/cancel
1064-
POST /webhooks/instances/{workflowId}/runs/{runId}/terminate
1065-
POST /webhooks/instances/{workflowId}/updates/{update}
1066-
POST /webhooks/instances/{workflowId}/cancel
1067-
POST /webhooks/instances/{workflowId}/terminate
1068-
```
1069-
1070-
The instance routes expect the public instance id and always resolve the current active run at apply time. The run routes expect both the public instance id and one selected run id. Accepted update, cancel, and terminate webhook calls return HTTP `200`. Rejected update, cancel, and terminate webhook calls usually return HTTP `409` with the same `outcome` and `rejection_reason` values shown above, while unknown update methods return HTTP `404` with `outcome = rejected_unknown_update`.
1071-
The JSON field names are `workflow_type`, `command_status`, `target_scope`, `requested_run_id`, and `resolved_run_id`, which correspond to `workflowType()`, `status()`, `targetScope()`, `requestedRunId()`, and `resolvedRunId()` on the PHP command result. Run-targeted webhook calls return `target_scope = run` and reject historical selections with `outcome = rejected_not_current` plus `rejection_reason = selected_run_not_current`, keeping the rejected run in `requested_run_id` and the current run in `resolved_run_id`.
1072-
1073934
## Attempt Start
1074935

1075936
If you want the durable start-command identity or a non-throwing duplicate-start outcome, use `attemptStart()`:

404.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313

1414

1515
<link rel="search" type="application/opensearchdescription+xml" title="Durable Workflow" href="/opensearch.xml"><link rel="stylesheet" href="/assets/css/styles.5aeb371e.css">
16-
<link rel="preload" href="/assets/js/runtime~main.8d57d7ab.js" as="script">
16+
<link rel="preload" href="/assets/js/runtime~main.11c346cf.js" as="script">
1717
<link rel="preload" href="/assets/js/main.09bafa3b.js" as="script">
1818
</head>
1919
<body class="navigation-with-keyboard">
2020
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"dark")}()</script><div id="__docusaurus">
2121
<div role="region" aria-label="Skip to main content"><a class="skipToContent_fXgn" href="#docusaurus_skipToContent_fallback">Skip to main content</a></div><nav class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img src="/img/logo.svg" alt="Workflow Logo" class="themedImage_ToTc themedImage--light_HNdA"><img src="/img/logo.svg" alt="Workflow Logo" class="themedImage_ToTc themedImage--dark_i4oU"></div><b class="navbar__title text--truncate">Durable Workflow</b></a><a class="navbar__item navbar__link" href="/docs/installation/">Docs</a><div class="navbar__item dropdown dropdown--hoverable"><a class="navbar__link" aria-haspopup="true" aria-expanded="false" role="button" href="/docs/introduction/">1.x</a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/docs/2.0/introduction/">2.0</a></li><li><a class="dropdown__link" href="/docs/introduction/">1.x</a></li></ul></div><a class="navbar__item navbar__link" href="/blog/">Blog</a></div><div class="navbar__items navbar__items--right"><a href="https://github.com/durable-workflow/workflow" target="_blank" rel="noopener noreferrer" aria-label="Star Durable Workflow on GitHub" class="navbar-github-star-link navbar__item navbar__link" label="Star on GitHub"><svg aria-hidden="true" class="navbar-github-star-link__icon" viewBox="0 0 16 16"><path d="M8 0C3.58 0 0 3.58 0 8a8.01 8.01 0 0 0 5.47 7.59c.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.5-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82A7.56 7.56 0 0 1 8 4.76c.68 0 1.36.09 2 .27 1.53-1.03 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.28.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z"></path></svg><span class="navbar-github-star-link__count" title="GitHub stars">1.2K</span></a><a href="https://github.com/durable-workflow/workflow" target="_blank" rel="noopener noreferrer" aria-label="Star Durable Workflow on GitHub" class="navbar-github-star-link navbar__link navbar-github-star-link--mobile-topbar" label="Star on GitHub"><svg aria-hidden="true" class="navbar-github-star-link__icon" viewBox="0 0 16 16"><path d="M8 0C3.58 0 0 3.58 0 8a8.01 8.01 0 0 0 5.47 7.59c.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.5-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82A7.56 7.56 0 0 1 8 4.76c.68 0 1.36.09 2 .27 1.53-1.03 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.28.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z"></path></svg><span class="navbar-github-star-link__count" title="GitHub stars">1.2K</span></a><div class="toggle_vylO colorModeToggle_x44X"><button class="clean-btn toggleButton_gllP toggleButtonDisabled_aARS" type="button" disabled="" title="Switch between dark and light mode (currently dark mode)" aria-label="Switch between dark and light mode (currently dark mode)" aria-live="polite"><svg viewBox="0 0 24 24" width="24" height="24" class="lightToggleIcon_pyhR"><path fill="currentColor" d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"></path></svg><svg viewBox="0 0 24 24" width="24" height="24" class="darkToggleIcon_wfgR"><path fill="currentColor" d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"></path></svg></button></div><div class="searchBox_ZlJk"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"></span></button></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_z2l0"><main class="container margin-vert--xl"><div class="row"><div class="col col--6 col--offset-3"><h1 class="hero__title">Page Not Found</h1><p>We could not find what you were looking for.</p><p>Please contact the owner of the site that linked you to the original URL and let them know their link is broken.</p></div></div></main></div><div><footer class="footer footer--dark"><div class="container container-fluid"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">Docs</div><ul class="footer__items clean-list"><li class="footer__item"><a class="footer__link-item" href="/docs/introduction/">Introduction</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/installation/">Installation</a></li></ul></div><div class="col footer__col"><div class="footer__title">Community</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://discord.gg/xu5aDDpqVy" target="_blank" rel="noopener noreferrer" class="footer__link-item">Discord<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://x.com/DurableWorkflow" target="_blank" rel="noopener noreferrer" class="footer__link-item">X<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div><div class="col footer__col"><div class="footer__title">More</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://durable-workflow.com/llms-full.txt" target="_blank" rel="noopener noreferrer" class="footer__link-item">LLM Docs<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://packagist.org/packages/durable-workflow/workflow" target="_blank" rel="noopener noreferrer" class="footer__link-item">Packagist<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright">Copyright © 2026 <a href="https://durable-workflow.com">Durable Workflow</a>.</div></div></div></footer></div></div>
22-
<script src="/assets/js/runtime~main.8d57d7ab.js"></script>
22+
<script src="/assets/js/runtime~main.11c346cf.js"></script>
2323
<script src="/assets/js/main.09bafa3b.js"></script>
2424
</body>
2525
</html>
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)