small / swoole-workflow
BPMN 2.0 workflows with Small ORM and Swoole execution
Requires
- php: >=8.4
- ext-dom: *
- ext-libxml: *
- ext-swoole: *
- small/collection: ^4.1
- small/swoole-entity-manager-core: ^3.3.1
- small/swoole-entity-manager-strates: ^1.0.2
- small/swoole-events: ^2.0
- small/swoole-patterns: ^26.1.1
- symfony/yaml: ^7.4 || ^8.0
Requires (Dev)
- pestphp/pest: ^4.0
- phpstan/phpstan: ^2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-24 21:30:06 UTC
README
Status: experimental BPMN 2.0.2 execution engine; tested executable subset, not an OMG-conformant implementation or a production-ready BPMN platform.
small/swoole-workflow is a PHP library for importing BPMN process definitions, executing token transitions, and persisting durable Swoole worker state with Small ORM and MySQL. It does not provide an HTTP server, graphical process editor, automatic deployment service or general BPMN model interchange.
The authoritative feature matrix is BPMN execution coverage. For the advanced execution milestones, see Lot 5, Lot 6 correlated runtime, Lot 7 correlated extensions, native BPMN voter, and business position recovery. Do not infer support for an entire BPMN element from an individual supported subset.
What is implemented
| Area | Supported, bounded execution subset |
|---|---|
| Definitions and token interpreter | Secure BPMN XML parsing; immutable definition versions; pinned instance versions; root and selected embedded/subprocess scopes |
| Activities | Service, manual, human and handler-backed send tasks; inbound receive tasks; durable completion and replay fencing. Correlated userTask waiting jobs and a native read-only BPMN voter (integration qualification pending) |
| Gateways | Legacy: XOR/default, parallel, bounded OR, N-of-M complex and serialized feedback. Lot 6 opt-in root runtime: correlated AND, dynamic OR, N-of-N complex joins and bounded overlapping feedback loops |
| Events | Explicit root message/signal starts, instantiating receive tasks, exclusive event gateways; selected correlated noninterrupting message/signal boundaries and automatic one-shot timers |
| Subprocesses | Regular and nested scoped execution; bounded indexed multi-instance bodies and XOR paths; opt-in correlated engine now supports bounded embedded scopes, dynamic MI cardinality snapshots, acyclic AND/XOR MI subprocess graphs and interrupting/noninterrupting boundaries |
| Cross-process calls | Version-pinned root/scoped concurrent acyclic calls, explicit child BPMN error codes, interrupting typed/catch-all call boundaries, parent wake-up, fencing and recovery |
| Compensation | Durable LIFO journal, transaction cancellation and targeted/untargeted throws; bounded linked-child correlated inverses and ordered external inverses through an at-least-once transactional outbox |
| Delivery and durability | Small ORM PersistThread transactions, UUIDv7, MySQL jobs/leases, retry fencing and transactional outbox; Lot 6 adds a versioned token-lineage ledger and immutable job-correlation receipts |
These statements describe supported subfeatures, not full BPMN conformance. The legacy count-based runtime still rejects overlapping cyclic activations. The separate Lot 6 runtime supports bounded root correlated gateway generations and ordinary nested embedded subprocesses and bounded MI parent joins, including validated AND/XOR graphs, but not unstructured dynamic loops, automatic external-event subscription discovery, general compensation boundaries or general instantiating gateways. A separate opt-in, linked-terminal-child compensation API is available; general remote error routing still uses the legacy engine.
Current qualification checkpoint
On 17 November 2026 the isolated sandbox passed 443 Pest tests (3,177 assertions), PHPStan at maximum level, schema and architecture checks, 5 Lot 6 MySQL scenarios and 2 targeted Lot 5 regressions. These results do not replace the complete GitLab CI or merged source coverage for the exact release revision.
On 18 November 2026, the extended local sandbox (including called-process error catches, external inverses and recent correlated scope changes) passed 454 Pest tests (3,219 assertions), PHPStan at maximum level, architecture and schema checks, and targeted real-MySQL cross-process/compensation/regression smoke tests. Complete GitLab pipeline qualification remains required.
Requirements
- PHP 8.4 or later and the Swoole extension (Docker development image: Swoole 6.2.4).
- MySQL 8.4 for the documented persistent acceptance environment.
- Docker Engine + Compose v2, or a compatible Podman Compose installation, for local development.
- PHP dependencies as defined by
composer.jsonandcomposer.lock. Small Entity Manager is the database access layer; Doctrine is not used.
Run locally
The Compose environment is for development and disposable testing only:
docker compose up --build -d
docker compose exec app composer install --no-interaction
docker compose exec app composer quality
docker compose exec app composer test
docker compose exec app php bin/check-architecture.php
docker compose exec app php bin/check-schema.php
docker compose exec app php tests/Support/run-database-smoke.php lot5-instantiating-events-orm-smoke.php
docker compose down -v deletes test volumes; never connect these smoke tests or their schema reset scripts to production data. See Docker development and validation and release gates.
Programming model
The pure interpreter can inspect and settle an imported process without accessing MySQL:
use Small\SwooleWorkflow\Application\UseCase\ExecuteTokensUseCase;
use Small\SwooleWorkflow\Application\UseCase\ScheduleActivitiesUseCase;
use Small\SwooleWorkflow\Infrastructure\Driver\BpmnXmlParserDriver;
$definition = (new BpmnXmlParserDriver())->parse($xml);
$tokens = new ExecuteTokensUseCase();
$scheduler = new ScheduleActivitiesUseCase($tokens);
$marking = $scheduler->settle($definition, $tokens->initial($definition));
$readyActivities = $scheduler->ready($definition, $marking);
Persistent execution requires an application-configured Small ORM connection provider, immutable published definitions, the durable scheduler and supervised Swoole workers. The embedding application owns authentication, business handlers, expression evaluators and external delivery idempotence.
Key ingress contracts in infrastructure/Service/:
| API | Contract |
|---|---|
OrmMessageStartService::start() | One version-pinned root message start or instantiating receive; returns false for exact replay |
OrmMessageStartService::startSignal() | One version-pinned root signal start |
OrmMessageStartService::startGateway() | Explicit winner of an instantiating exclusive message/signal gateway |
OrmSignalFanoutService::publish() | Explicit list of up to 128 targets, each with its own retry-stable receipt; not one atomic broadcast |
OrmProcessOrchestrator::schedule() and ::complete() | Persistent scheduling and lease-fenced transitions |
OrmInstanceRecovery::recover() | Reconcile running instances and pinned child calls after restart |
BpmnStatePositionResolver::resolve() | Scan registered application state voters and return one valid, UNPERSISTED correlated root token; application owns recovery transaction |
Root event-based starts are not implicitly activated by ordinary process creation. External callbacks and the outbox have at-least-once delivery semantics; downstream consumers must deduplicate. See cross-process errors and external compensation.
Quality and current verification
As verified in an isolated development sandbox on 17 November 2026, commit 92b8d111:
- Pest: 434 passed, 3,130 assertions.
- Real MySQL 8.4: 11 Lot 5 scenarios plus 12 selected historical regressions passed. This is not the complete database CI matrix.
- PHPStan: no errors; eight designated unit-critical infrastructure components: 100% of their statements.
- Architecture and schema preflight: passed.
The complete GitLab pipeline #2878 was not yet reported successful at the documentation checkpoint. The most recent historical combined coverage measurement is not a valid current-head percentage until coverage-combined finishes. Do not confuse unit-only coverage with the combined Pest + MySQL figure.
See validation and release gates for the reproducible checks and outstanding CI gate.
Documentation
| Guide | Purpose |
|---|---|
| BPMN conformance matrix | Authoritative executable feature-by-feature boundaries and intentionally unsupported combinations |
| Lot 6 activation correlation | UUIDv7 generation ledger, ORM CAS and remaining worker integration |
| Lot 5 execution and qualification | Advanced execution guarantees, 11 MySQL scenarios, remaining work |
| Lot 4 reliability | Previously qualified reliability baseline |
| Validation and release | Commands, quality gates, CI, coverage and deployment limitations |
| Docker development | Local stack, test DB isolation and CI image troubleshooting |
| Native BPMN voter | Correlated userTask vote, mandatory permission policy plus composable application business rules (AND), and exact job/token identities (write integration pending) |
| Business position recovery | State-position voter registry selects a single BPMN root token; failures throw a dedicated exception with ambiguous BPMN candidates, choose() selects an explicitly revalidated candidate; application persists the token with revision, lease and authorization checks (database qualification pending) |
| Historical human tasks | Legacy userTask requester and migration boundary |
| Adapter architecture | Small ORM and domain/infrastructure boundaries |
| Historical implementation notes | Former long README, preserved for traceability but not normative |
Full BPMN 2.0.2 standard: OMG specification. License: MIT.