Skip to content

Commit 47993f2

Browse files
deploy: eec6e09
1 parent d3b0858 commit 47993f2

269 files changed

Lines changed: 1402 additions & 1016 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: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5327,6 +5327,11 @@ Those overrides are not limited to reads or projection rebuilds. `WorkflowStub::
53275327

53285328
Keep custom subclasses schema-compatible with the built-in models. If a subclass also changes table names or other Eloquent conventions that the package models normally infer, override the affected relations on that subclass as well so `currentRun()`, `runs()`, and similar lookups stay aligned with your custom schema.
53295329

5330+
See the [Customization Matrix](./customization-matrix.md) for the frozen v2
5331+
support contract, including which overrides are safe as inherited subclasses,
5332+
which ones need explicit relation overrides, and how serializer, repository,
5333+
health, import, migration, and write-side behavior fit together.
5334+
53305335
## Payload Codec
53315336

53325337
v2 uses `avro` for new workflow payloads:
@@ -5691,12 +5696,168 @@ To ensure that your activities run on the same server so that they can share dat
56915696

56925697
In order to run a queue worker that only processes the `my_dedicated_queue` queue, you can use the `php artisan queue:work --queue=my_dedicated_queue` command. Alternatively, you can use Laravel Horizon to manage your queues. Horizon is a queue manager that provides a dashboard for monitoring the status of your queues and workers.
56935698

5699+
<!-- Source: docs/configuration/customization-matrix.md -->
5700+
5701+
# Customization Matrix
5702+
5703+
This page freezes the supported Durable Workflow v2 customization contract.
5704+
Use it when you need to move v2 durable models onto a different connection,
5705+
swap model subclasses, replace the PHP operator-observability repository, or
5706+
decide whether an older serializer setting is still valid during migration.
5707+
5708+
## Supported override matrix
5709+
5710+
| Surface | Supported contract | Notes |
5711+
| --- | --- | --- |
5712+
| `workflows.v2.instance_model` with a schema-compatible subclass that keeps the basename `WorkflowInstance` | Supported | Use this shape when you only need a different connection, casts, or app namespace. The inherited relations keep the package's `workflow_instance_id` foreign-key contract. |
5713+
| `workflows.v2.instance_model` with a table-swapped or basename-changing subclass | Supported with explicit relation overrides | Override `runs()`, `commands()`, and `updates()` so they keep `workflow_instance_id`. The package now validates this at boot and rejects inherited relation inference that would change those keys. `currentRun()` already pins `current_run_id` explicitly and does not need an override. |
5714+
| Other `workflows.v2.*_model` overrides (`run_model`, `task_model`, `history_event_model`, projections, schedules, activity rows, failures, messages, memos, search attributes, child calls) | Supported for schema-compatible subclasses | Keep the package column names, primary keys, and foreign keys. These relations already pin the keys they use, so table-swapped subclasses can stay on the inherited relation methods when the schema stays compatible. |
5715+
| Custom table names plus custom foreign-key column names | Unsupported | The v2 runtime and operator surfaces assume the package column and key names. If you change them, you are outside the supported contract. |
5716+
| `OperatorObservabilityRepository` replacement | Supported by container binding | Bind your implementation to `Workflow\V2\Contracts\OperatorObservabilityRepository`. This is a PHP runtime integration contract for Waterline and `WorkflowStub::historyExport()`, not a stable cross-language API. The repository receives package model objects. |
5717+
| `serializer` | Supported only for `avro` and legacy drain/import codecs | New v2 runs always use Avro semantics. `workflow-serializer-y` and `workflow-serializer-base64` remain valid only for finishing or importing v1 history that still needs PHP-native decoding. Custom serializer classes from v1 are unsupported in v2. |
5718+
| Health and doctor diagnostics | Supported | `php artisan workflow:v2:doctor` and Waterline v2 health/stats reflect the configured model classes and flag stale serializer settings as migration debt. |
5719+
| Package migrations on a non-default connection | Supported with published migrations | Auto-loaded package migrations run on Laravel's default connection. If your durable models use another connection, publish the migrations and set the migration `$connection` explicitly. |
5720+
| Core write-side runtime (`WorkflowStub::make()`, `load()`, task creation, current-run resolution) | Supported through the configured durable models | The runtime honors the configured `instance_model`, `run_model`, and `task_model`. Keep write-side tables schema-compatible with the package columns and keys. |
5721+
5722+
## Exact v2 model keys
5723+
5724+
The published `workflows.php` config exposes these durable model keys under
5725+
`workflows.v2`:
5726+
5727+
- `instance_model`
5728+
- `run_model`
5729+
- `history_event_model`
5730+
- `task_model`
5731+
- `command_model`
5732+
- `link_model`
5733+
- `activity_execution_model`
5734+
- `activity_attempt_model`
5735+
- `timer_model`
5736+
- `failure_model`
5737+
- `run_summary_model`
5738+
- `run_wait_model`
5739+
- `run_timeline_entry_model`
5740+
- `run_timer_entry_model`
5741+
- `run_lineage_entry_model`
5742+
- `schedule_model`
5743+
- `schedule_history_event_model`
5744+
5745+
Use subclasses of the package models for those keys. Keep the package's column
5746+
names and foreign keys unless a page in this docs set says otherwise.
5747+
5748+
## Instance-model override rule
5749+
5750+
The only current v2 override that needs extra relation work is
5751+
`workflows.v2.instance_model` when your subclass changes the inferred foreign
5752+
key away from `workflow_instance_id`.
5753+
5754+
Typical safe example:
5755+
5756+
```php
5757+
namespace App\Models\V2;
5758+
5759+
use Workflow\V2\Models\WorkflowInstance as BaseWorkflowInstance;
5760+
5761+
final class WorkflowInstance extends BaseWorkflowInstance
5762+
{
5763+
protected $connection = 'workflow';
5764+
}
5765+
```
5766+
5767+
Because the subclass basename is still `WorkflowInstance`, Eloquent keeps the
5768+
same inferred foreign key and the inherited relations remain aligned.
5769+
5770+
If you use a different basename or a table-swapped storage model, override the
5771+
affected relations explicitly:
5772+
5773+
```php
5774+
namespace App\Workflow\Storage;
5775+
5776+
use Illuminate\Database\Eloquent\Relations\HasMany;
5777+
use Workflow\V2\Models\WorkflowCommand;
5778+
use Workflow\V2\Models\WorkflowInstance as BaseWorkflowInstance;
5779+
use Workflow\V2\Models\WorkflowRun;
5780+
use Workflow\V2\Models\WorkflowUpdate;
5781+
use Workflow\V2\Support\ConfiguredV2Models;
5782+
5783+
final class TenantWorkflowInstance extends BaseWorkflowInstance
5784+
{
5785+
protected $table = 'tenant_workflow_instances';
5786+
5787+
public function runs(): HasMany
5788+
{
5789+
return $this->hasMany(
5790+
ConfiguredV2Models::resolve('run_model', WorkflowRun::class),
5791+
'workflow_instance_id',
5792+
);
5793+
}
5794+
5795+
public function commands(): HasMany
5796+
{
5797+
return $this->hasMany(
5798+
ConfiguredV2Models::resolve('command_model', WorkflowCommand::class),
5799+
'workflow_instance_id',
5800+
)->oldest('created_at');
5801+
}
5802+
5803+
public function updates(): HasMany
5804+
{
5805+
return $this->hasMany(
5806+
ConfiguredV2Models::resolve('update_model', WorkflowUpdate::class),
5807+
'workflow_instance_id',
5808+
)
5809+
->orderBy('command_sequence')
5810+
->oldest('accepted_at')
5811+
->oldest('created_at')
5812+
->oldest('id');
5813+
}
5814+
}
5815+
```
5816+
5817+
If those overrides are missing, package boot now fails fast instead of letting
5818+
the app drift onto inferred keys such as
5819+
`tenant_workflow_instance_id` or `custom_workflow_instance_id`.
5820+
5821+
## Serializer, import, and health rules
5822+
5823+
- Keep `serializer = 'avro'` for new v2 work.
5824+
- Use legacy codecs only while draining or importing v1 history that still
5825+
needs PHP-native payload decoding.
5826+
- Do not point v2 at removed custom serializer classes from v1.
5827+
- Run `php artisan workflow:v2:doctor` after upgrades and config changes. It is
5828+
the diagnostic surface that flags legacy serializer settings and other boot
5829+
readiness problems.
5830+
- Treat Waterline v2 health and stats as the operator-facing view of the same
5831+
durable model configuration.
5832+
5833+
## Migration and write-side rules
5834+
5835+
- The normal path is auto-loaded package migrations on the default connection.
5836+
- If your durable models use another connection, publish the migrations and set
5837+
the migration `$connection` so `php artisan migrate` targets the same
5838+
database as your configured model subclasses.
5839+
- Keep the package table names, primary keys, and foreign keys on every model
5840+
that participates in the runtime write path.
5841+
- The write path is not read-only customization: starts, loads, current-run
5842+
resolution, and task execution all use the configured durable models.
5843+
5844+
## Related Guides
5845+
5846+
- [Publishing Config](./publishing-config.md)
5847+
- [Database Connection](./database-connection.md)
5848+
- [Migration Guide](../migration.md)
5849+
- [Monitoring](../monitoring.md)
5850+
56945851
<!-- Source: docs/configuration/database-connection.md -->
56955852

56965853
# Database Connection
56975854

56985855
Here is an overview of the steps needed to customize the database connection used for the workflow v2 durable models. This is *only* required if you want to use a different database connection than the default connection you specified for your Laravel application.
56995856

5857+
For the full v2 override contract, including table-swapped subclasses,
5858+
serializer rules, repository replacement, health diagnostics, and migration
5859+
expectations, see the [Customization Matrix](./customization-matrix.md).
5860+
57005861
1. Create classes in your app models directory that extend the base v2 model classes
57015862
2. Set the desired `$connection` option in each class
57025863
3. Publish the workflow config file
@@ -5753,6 +5914,11 @@ Publish the workflow config file and update the `workflows.v2.*_model` bindings
57535914

57545915
The package resolves models through `Workflow\V2\Support\ConfiguredV2Models`, so any relation or query that hits a v2 model will transparently pick up the configured connection.
57555916

5917+
If you move beyond schema-compatible subclasses and change the inferred foreign
5918+
key of your custom `instance_model`, the package now validates that the
5919+
`runs()`, `commands()`, and `updates()` relations were overridden explicitly at
5920+
boot.
5921+
57565922
## Migrations
57575923

57585924
Workflow migrations are auto-loaded from the package (`WorkflowServiceProvider::loadMigrationsFrom`) and run against the default database connection. When you route the v2 tables at a non-default connection, publish the migrations with `php artisan vendor:publish --tag=migrations` and set `protected $connection = 'mysql';` on each published migration class so `php artisan migrate` runs them against the correct database.

0 commit comments

Comments
 (0)