Workflow Instance Model
Summary
WorkflowInstance is the execution aggregate root. It pins a definition and version, owns tasks and actions, tracks the current stage and emits integration-relevant domain events.
Stored state
The instance stores tenant, definition/version identifiers, key, status, current step order, subject reference, initiator, serialized context, result and timestamps.
Owned records
Tasks represent work at opened stages. Actions provide an append-only record of Start, Approve, Reject, Delegate and Complete calls. Audit and timeline rows are separate infrastructure records written by command handlers.
Lifecycle methods
Start creates a Running instance and start action/event. OpenStage adds tasks. Approval mutates one task; rejection also terminates the instance; delegation reassigns a pending task; completion sets Approved result and emits completion.
Canonical versus compatibility
The aggregate and its DTO mapping are canonical runtime models. No compatibility instance class or alternate state machine was found.
Limitations
Cancelled is an enum value without an aggregate command. Rejection does not close sibling pending tasks. There is no concurrency token or explicit optimistic-concurrency handling.
Requires Confirmation
Sibling-task cleanup, cancellation semantics, retention and concurrency strategy require confirmation.
Source References
microservices/src/workflow-service/Domain/Workflow/WorkflowInstance.csmicroservices/src/workflow-service/Domain/Workflow/WorkflowDomainEvents.csmicroservices/src/workflow-service/Infrastructure/WorkflowDbContext.cs
Related Articles
See Also
Keywords
Workflow architecture, approval engine, Workflow Service, technical foundation.
Revision Information
- Status: Draft
- Last reviewed: 2026-07-20
- Next review: 2026-10-20