This manual explains what the current code does, how consumers integrate it, and what facts remain after failure. Workflow fits human approval, countersignature, conditional routing, escalation, and business-state coordination. It is not a general distributed transaction orchestrator and does not replace a Saga or Outbox.
1. Product fit
| Requirement | Guidance |
|---|---|
| Approval, rejection, transfer, multi-signature, and trail | Use Workflow |
| Tenant or office-specific approval versions | Use deployment bindings |
| A simple single-aggregate state machine | Prefer the domain aggregate |
| Cross-service compensation and exactly-once messaging | Design Saga/Outbox first |
| Full BPMN 2.0 XML interoperability | Not supported by this engine |
2. Reading map
| Goal | Chapter |
|---|---|
| Understand Framework, Platform, Host, and adapters | Architecture |
| Author executable nodes, edges, and assignees | Defining workflows |
| Use server schema, AOT metadata, revisioned drafts, and path simulation | Visual designer |
| Publish and understand real grayscale semantics | Deployment |
| Start, approve, reject, withdraw, and control | Running instances |
| Todo, done, candidates, read markers, and cache | Task management |
| Trail, archive, reports, and precision limits | History and analytics |
| Reconstruct legacy in-flight work | Migration and import |
| Recipients, templates, preferences, and failure | Notification pipeline |
| Routes and errors | API reference |
| Embed in another product | Standalone embedding |
3. Instance lifecycle
States come from the engine enum ProcessInstanceStatus: Running / Completed / Cancelled / Terminated / Suspended — there are no business-facing enum values like Withdrawn or Approved. The engine keeps a two-field model: Status carries the machine state above; a withdrawal maps to Cancelled while the string BusinessStatus records Draft / InProcess / Active, etc.; FlowState encodes the trail as node prefix plus tail letter (ABW = node B pending). Business code should test BusinessStatus == "Active" for “approved”, never an enum value.
Start snapshots DefinitionId, DefinitionVersion, TenantId, OfficeId, StarterId, and BusinessKey. TokenExecutor runs node behavior. UserTask creates work and suspends an Execution. Completion resumes the Execution, selects edges, updates FlowState/BusinessStatus, and appends an activity record.
4. Minimal business integration
public async Task<Result<string>> SubmitAsync( MatterIntake matter, string trustedUserId, string trustedTenantId, CancellationToken cancellationToken){ // Pre-submit rules stay owned by the MatterIntake aggregate: // parties complete, initial conflict check passed. if (!matter.CanSubmitForApproval()) return Result.Failure<string>("Matter.IntakeInvalid");
var started = await transitions.StartAsync( "matter-intake-approval", matter.MatterNo, "MatterIntake", trustedUserId, trustedTenantId, matter.OfficeId, new Dictionary<string, object?> { ["disputeAmount"] = matter.DisputeAmount, ["crossBorder"] = matter.IsCrossBorder }, cancellationToken);
// No client idempotency key exists; reconcile by business key after timeout. return started.IsSuccess ? Result.Success(started.Value.Id) : Result.Failure<string>(started.Error.Code);}5. Three distinct authorization layers
Layer one is HTTP authentication, rate limiting, and timeout. Layer two is IAuthorizedRequest module/resource/action authorization. Layer three is engine View/Operate/Manage data permission. Candidate membership assigns responsibility; it does not grant unrestricted access to the business object.
WorkflowPermissions strings are governance catalog facts (actual authorization comes from ResourceDescriptor and AuthorizationAction). The workflow.runtime feature is enforced: WorkflowRuntimeLicenseGuard evaluates it via ILicenseGate before every workflow write and every background job, fail-closed.
6. Meaning of success
- Transactional instance, execution, task, and trail writes completed.
- Notification persistence rides the same fact chain: the
INotificationChannelimplementation writes per-recipient inbox entries plus a CAP Outbox row and throws when any recipient fails; the dispatcher logs and rethrows. A committed command therefore proves notifications were persisted — external delivery stays asynchronous in the Notifications module. - Listener exceptions are no longer silently isolated: EventDispatcher logs and rethrows, failing the whole write. Custom listeners must be designed to transactional semantics.
- Timer processed count means iterated records, not successful actions.
- BatchComplete marks tasks completed without advancing the process.
7. Pre-production evidence
Exercise both ORMs, duplicate completion, parallel gateways, candidate refresh, cross-tenant denial, publish races, timer crash windows, notification and callback failure, interrupted import, archive orphans, large reports, and cache invalidation. Every drill needs a reproducible command, expected database state, alert, and recovery step.
8. Current implementation boundaries
workflow.runtime is now enforced before runtime writes and background jobs; it is no longer a catalog-only gap. The visual designer also has an end-to-end server schema, AOT business metadata, optimistic draft revisions, validation, simulation, and publication flow.
Boundaries that still need explicit acceptance include the legacy direct deployment endpoint not running the designer’s full validation, simulation previewing only one reachable path, browser crash snapshots being keyed by tenant plus definition key rather than user, and external delivery confirmation depending on the Notifications module’s Outbox consumer (standalone hosts rolling their own channel get whatever durability they build). Validate timer, import, archive, and concurrency SLOs against their current chapters and release-candidate tests rather than carrying forward an old blocker list.
9. Learning path
First use the visual designer to build a three-node approval and run save, validate, simulate, publish, start, and complete. Add an exclusive gateway, then parallel signatures, transfer, and timeout. Finally drill notification failure, concurrent completion, and interrupted import while inspecting Instance, Execution, Task, ActivityRecord, and TimerJob.
10. Source entry points
rg --files src/Framework/BitzOrcas.Workflow src/Platform/Workflow src/Hosts/BitzOrcas.Api/Endpoints/Workflowrg --files tests | rg 'Workflow|workflow'Chapter Navigation
- 01/11
Workflow Architecture and Core Concepts
Deep guide to layers, focused ports, execution model, command/query stores, transactions, concurrency, cache, tenancy, and host composition.
- 02/11
Defining and Designing Workflows
Current JSON DSL guide to nodes, edges, expressions, business binding, form fields, participants, multi-instance, timers, listeners, validation, and simulation.
- 03/11
Deployment, Versioning, and Rollback
Immutable snapshots, checksum reuse, office/tenant bindings, real grayscale semantics, cache invalidation, publish races, and release runbook.
- 04/11
Visual workflow designer
Current guide to the full-page designer, server schema, AOT business metadata, draft revisions, form-field policy, simulation paths, version scope, and permissions.
- 05/11
Running Workflow Instances
Start, complete, reject, withdraw, resubmit, handoff, control, multi-instance, transactions, concurrency, callbacks, and timer failure semantics.
- 06/11
Tasks, Candidates, and Todo Queries
Assigned/candidate union, data scope, query fallback, paging cost, detail authorization, idempotent read marker, candidate refresh, and cache.
- 07/11
History, Archive, and Analytics
Activity trail, instance and business timelines, archive transaction, report calculation, query-port fallback, precision limits, and operations evidence.
- 08/11
Migration, Start-at-Node, and Legacy Import
Choosing migration paths, mapping, preflight, current non-transactional/non-idempotent limits, batch recovery, applicant transfer, and acceptance runbook.
- 09/11
Workflow Notification Pipeline
Event dispatch, recipients, default templates, preferences, platform adapter, JobHost wiring, transactional failure semantics, and external delivery reconciliation.
- 10/11
Workflow HTTP API Reference
Current Definition, Runtime, Task, History, Report, and Management routes with authorization, rate limits, timeouts, and error semantics.
- 11/11
Embed Workflow Engine Standalone
Compose the engine outside BitzOrcas with correct persistence, query, permission, participant, service-task, notification, timer, cache, and operations boundaries.