WorkflowForge Documentation
Build .NET workflows with clear guidance, focused examples, and a zero-dependency core.
Core Concepts
Understand foundries, smiths, operations, and lifecycle events.
Performance First
Benchmark-backed results with microsecond execution and minimal memory.
Extensions Ready
Logging, resilience, persistence, and observability without conflicts.
What is WorkflowForge?
WorkflowForge is a zero-dependency workflow orchestration framework for .NET. Twelve BenchmarkDotNet scenarios against Workflow Core and Elsa (same scripted logic) show microsecond-level medians and small heaps on our harness. Forge, foundry, and smith name the pieces so composition and tests read the same everywhere.
Key Features
- 2-583x faster than those libraries on the scenarios we measured (runtime and scenario matter).
- About 1-533x less memory in the same runs, case by case.
- Zero package dependencies on the core assembly; extensions are optional NuGet add-ons.
- Compensation hooks on every operation (saga-style rollback when you implement
RestoreAsync). - Thirteen packages total: one core, eleven extensions, plus
WorkflowForge.Testing.Resilience.PollyandLogging.Serilogisolate their third-party library with ILRepack. - Fluent builders, the industrial metaphor, and 37 samples that ramp from hello world to persistence and recovery.
The Industrial Metaphor
WorkflowForge names pieces with a simple industrial metaphor:
- The Forge (
WorkflowForgestatic class) is the entry point for building workflows. - Foundries (
IWorkflowFoundry) hold mutable state and services while operations run. - Smiths (
IWorkflowSmith) drive execution order, compensation, and lifecycle events. - Operations (
IWorkflowOperation) are the individual units of work in the graph.
Read it literally: data (raw material) moves through operations (tools) inside a foundry (workspace), while the smith (orchestrator) runs the sequence.
Quick Start
dotnet add package WorkflowForge
using WorkflowForge;
var workflow = WorkflowForge.CreateWorkflow("HelloWorld")
.AddOperation("SayHello", async (foundry, ct) => {
foundry.Logger.LogInformation("Hello, WorkflowForge!");
})
.Build();
using var smith = WorkflowForge.CreateSmith();
await smith.ForgeAsync(workflow);
Core Abstractions
IWorkflow
Complete workflow definition with operations and metadata.
public interface IWorkflow : IDisposable
{
Guid Id { get; }
string Name { get; }
string? Description { get; }
string Version { get; }
IReadOnlyList<IWorkflowOperation> Operations { get; }
}
IWorkflowFoundry
Execution environment providing context, logging, and services.
public interface IWorkflowFoundry :
IWorkflowExecutionContext,
IWorkflowMiddlewarePipeline,
IOperationLifecycleEvents,
IDisposable
{
Guid ExecutionId { get; }
IWorkflow? CurrentWorkflow { get; }
ConcurrentDictionary<string, object?> Properties { get; }
IFoundryServices Services { get; }
IWorkflowForgeLogger Logger { get; }
WorkflowForgeOptions Options { get; }
IServiceProvider? ServiceProvider { get; }
bool IsFrozen { get; }
}
Properties holds workflow data and is never auto-disposed. Services holds extension-owned
objects and is disposed when the foundry lease ends - see
Foundry lease and resource lifetime.
IWorkflowSmith
Orchestration engine executing workflows.
public interface IWorkflowSmith : IDisposable, IWorkflowLifecycleEvents, ICompensationLifecycleEvents
{
Task ForgeAsync(IWorkflow workflow, CancellationToken cancellationToken = default);
Task ForgeAsync(IWorkflow workflow, ConcurrentDictionary<string, object?> data, CancellationToken cancellationToken = default);
Task ForgeAsync(IWorkflow workflow, IWorkflowFoundry foundry, CancellationToken cancellationToken = default);
}
IWorkflowOperation
Individual executable operation within a workflow.
public interface IWorkflowOperation : IDisposable
{
Guid Id { get; }
string Name { get; }
Task<object?> ForgeAsync(object? inputData, IWorkflowFoundry foundry, CancellationToken cancellationToken = default);
Task RestoreAsync(object? outputData, IWorkflowFoundry foundry, CancellationToken cancellationToken = default);
}
Override RestoreAsync when you need compensation behavior. Compensation calls RestoreAsync on every completed operation; the base class default is a no-op, so operations that do not override it simply do nothing.
Extensions Ecosystem
WorkflowForge provides 13 packages (1 core + 11 extensions + 1 testing utility):
| Package | Purpose |
|---|---|
| Testing | Unit testing utilities with FakeWorkflowFoundry |
| DependencyInjection | Microsoft.Extensions.DependencyInjection integration |
| Serilog Logging | Structured logging integration |
| Resilience | Core retry abstractions |
| Polly Resilience | Circuit breakers, retries, timeout policies |
| Validation | Input validation with DataAnnotations |
| Audit Logging | Compliance & audit trails |
| Persistence | Workflow state storage |
| Persistence Recovery | Resume interrupted workflows |
| Performance Monitoring | Metrics & profiling |
| Health Checks | Application health monitoring |
| OpenTelemetry | Distributed tracing |
Dependency Isolation: The two extensions that bundle a third-party library — Resilience.Polly and Logging.Serilog — internalize it with ILRepack. Microsoft/System packages stay external and resolve normally.
Performance Highlights
Based on BenchmarkDotNet testing (12 scenarios, 10 iterations per job) against Workflow Core and Elsa Workflows:
Benchmark Comparison
| Runtime | Scenario | vs WorkflowCore | vs Elsa | Memory Advantage |
|---|---|---|---|---|
| .NET 10.0 | State Machine | 288x faster | 583x faster | 44-250x less |
| .NET 8.0 | State Machine | 231x faster | 555x faster | 45-252x less |
| .NET FX 4.8 | State Machine | 271x faster | N/A† | 53x less |
| .NET 10.0 | Concurrent (8 wf) | 183x faster | 382x faster | 20-123x less |
| .NET 8.0 | Concurrent (8 wf) | 138x faster | 387x faster | 20-124x less |
| .NET FX 4.8 | Concurrent (8 wf) | 267x faster | N/A† | 14x less |
† Elsa does not support .NET Framework 4.8. See Competitive Analysis for all 12 scenarios.
Test System: Windows 11 (25H2), .NET 8.0.24 / .NET 10.0.3 / .NET FX 4.8.1, BenchmarkDotNet v0.15.8, 10 iterations per job
Support & Community
- GitHub Repository: animatlabs/workflow-forge
- Issues: GitHub Issues
- License: MIT License
- Contributing: Contributing Guidelines
- Ko-fi: If this project helps you, consider supporting on Ko-fi