Search by

small / swoole-workflow

small

BPMN 2.0 workflows with Small ORM and Swoole execution

dev-main 2026-11-24 21:30 UTC

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

AreaSupported, bounded execution subset
Definitions and token interpreterSecure BPMN XML parsing; immutable definition versions; pinned instance versions; root and selected embedded/subprocess scopes
ActivitiesService, 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)
GatewaysLegacy: 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
EventsExplicit root message/signal starts, instantiating receive tasks, exclusive event gateways; selected correlated noninterrupting message/signal boundaries and automatic one-shot timers
SubprocessesRegular 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 callsVersion-pinned root/scoped concurrent acyclic calls, explicit child BPMN error codes, interrupting typed/catch-all call boundaries, parent wake-up, fencing and recovery
CompensationDurable 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 durabilitySmall 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.json and composer.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/:

APIContract
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

GuidePurpose
BPMN conformance matrixAuthoritative executable feature-by-feature boundaries and intentionally unsupported combinations
Lot 6 activation correlationUUIDv7 generation ledger, ORM CAS and remaining worker integration
Lot 5 execution and qualificationAdvanced execution guarantees, 11 MySQL scenarios, remaining work
Lot 4 reliabilityPreviously qualified reliability baseline
Validation and releaseCommands, quality gates, CI, coverage and deployment limitations
Docker developmentLocal stack, test DB isolation and CI image troubleshooting
Native BPMN voterCorrelated userTask vote, mandatory permission policy plus composable application business rules (AND), and exact job/token identities (write integration pending)
Business position recoveryState-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 tasksLegacy userTask requester and migration boundary
Adapter architectureSmall ORM and domain/infrastructure boundaries
Historical implementation notesFormer long README, preserved for traceability but not normative

Full BPMN 2.0.2 standard: OMG specification. License: MIT.