* Isolate background workflow dispatches from caller's cancellation token
When dispatching multiple child workflows, early child completions cancel the parent activity's token while dispatches are still in progress. This creates a race condition where remaining dispatches fail with OperationCanceledException.
* Make BackgroundWorkflowDispatcher & BackgroundStimulusDispatcher caller Cts-independent
* Initial plan
* Increase ActivityNodeId column max length from 450 to 1024 to fix truncation for deeply nested workflows
Add HasMaxLength(1024) for ActivityNodeId on ActivityExecutionRecord and
WorkflowExecutionLogRecord entities. Create V3_7 migrations for all 5
database providers (SqlServer, MySql, PostgreSql, Sqlite, Oracle).
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* Use NVARCHAR(MAX) and equivalent unlimited column types for ActivityNodeId
Update V3_6 migrations to change ActivityNodeId from fixed-length columns
to unlimited types: nvarchar(max) for SQL Server, longtext for MySQL,
NCLOB for Oracle. PostgreSQL (text) and SQLite (TEXT) already used
unlimited types. Drop ActivityNodeId indexes on both ActivityExecutionRecords
and WorkflowExecutionLogRecords tables since unlimited columns cannot be
indexed. Remove HasIndex for ActivityNodeId from Configurations.cs.
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* Add IF EXISTS guards to DropIndex calls in V3_6 migrations for all providers
Replace bare migrationBuilder.DropIndex() calls with provider-specific
conditional DDL to prevent errors when indexes have already been dropped:
- SQL Server: IF EXISTS (SELECT * FROM sys.indexes ...) pattern
- PostgreSQL: DROP INDEX IF EXISTS (native support)
- SQLite: DROP INDEX IF EXISTS (native support)
- MySQL: information_schema.statistics check with PREPARE/EXECUTE
- Oracle: PL/SQL BEGIN...EXCEPTION WHEN OTHERS (SQLCODE -1418)
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* Add comment explaining Oracle error code -1418 in migration
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* refactor(deps): use local CShells project refs
Replace CShells NuGet package references with direct project references to the local CShells source to enable developing and testing against local changes and simplify build integration across modules.
* Handle assembly load errors in feature discovery
Added error handling for assembly load failures in feature discovery to improve resilience. Also updated configuration for identity token options and removed unused service bus consumer dependencies. Simplified project structure by moving and cleaning up `Directory.Build.targets` files.
* Refactor configuration and service extension methods.
Moved `ShellSettingsExtensions` and `ShellConfiguration` to `CShells.Abstractions` for better modularity. Added new `ServiceCollectionFeatureExtensions` to improve options registration. Updated appsettings and references to support these changes.
* Introduce ManagementServiceCollectionExtensions to streamline activity and variable registration
Added `ManagementServiceCollectionExtensions` for registering Elsa activity types and variable descriptors, providing a modular and shell-feature-compatible approach to configuration. Updated relevant features to utilize these new extension methods, enhancing code modularity and reducing redundancy.
* Add resilience strategy registration to HTTP feature
Introduced `ResilienceServiceCollectionExtensions` to register resilience strategies within the `Elsa.Resilience.Core` module. Updated `HttpFeature` to incorporate resilience strategies, enhancing HTTP-related resilience configuration leveraging the new extension methods.
* Add new configuration options to JavaScriptFeature
Implemented multiple properties in `JavaScriptFeature` to enhance JavaScript execution: `AllowClrAccess`, `AllowConfigurationAccess`, `ScriptCacheTimeout`, `DisableWrappers`, and `DisableVariableCopying`. These additions enable more flexible and secure configuration of the Jint JavaScript engine.
* refactor(workflows): unify graph caching
Resolve workflow definitions first and store graphs under stable per-version-ID cache keys so different lookup paths share entries.
Centralize cache creation and change-token registration to remove duplicated caching logic.
Skip materializer-unavailable definitions to avoid caching null graphs and simplify flow.
* refactor(tests): centralize default IDs and materializer setup
Introduce constants for default definition and version IDs, and materializer name. Refactor tests to use these constants, streamline graph and definition resolution, and improve cache key creation by sharing logic across tests. Extend tests to check scenarios with unavailable materializers, ensuring caching only occurs for valid cases.
* extend(tests): enhance cache key verification in AutoUpdateTests
Added checks for both workflow definition and version cache keys in AutoUpdateTests to ensure comprehensive cache validation, improving test reliability and coverage.
* refactor(projects): update CShells project paths and solution configuration
Revised project reference paths in `Elsa.ModularServer.Web.csproj` for CShells projects and updated `Elsa.sln` to include new CShells projects, streamlining project organization and build configuration.
* Add `IWorkflowReferenceGraphBuilder` to `WorkflowManagementFeature`; rename `ResilienceShellFeature` to `ResilienceFeature`.
* Refactor `HttpFeature` to use `IMiddlewareShellFeature`, include `HttpWorkflowsMiddleware`, and update `HttpActivityOptions` defaults.
* Add `AddTypeAlias` and `AddVariableTypeAndAlias` extension methods to service collections
- Introduced `AddTypeAlias<T>` method in `ServiceCollectionExtensions.cs` for adding type aliases.
- Added `AddVariableTypeAndAlias<T>` method in `ManagementServiceCollectionExtensions.cs` to add variable types with aliases.
* Update CShells package versions to 0.0.11 and replace ProjectReferences with PackageReferences in project files
* Extract and copy metadata when activity type is not found in `ActivityJsonConverter`.
* Improve `ActivityJsonConverter`: Correct metadata extraction to read from NotFoundActivity wrapper.
* Reposition activity description and display text assignment to follow metadata extraction in `ActivityJsonConverter`.
* Update src/modules/Elsa.Workflows.Core/Serialization/Converters/ActivityJsonConverter.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Made two changes:
1. TriggerScheduler was returning a null for a payload, which would cause NullReferenceException, and this would break the populator which prevented other workflow definitions from being imported/published correctly.
2. The reloader was only executing a part of the actual loading logic, meaning that workflow definitions used as activities were not correcly resolved to the expected versions
* Update src/modules/Elsa.Scheduling/Services/DefaultTriggerScheduler.cs
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
---------
Co-authored-by: j03y-nxxbz <joey.barten@nexxbiz.io>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
* Add idempotency tests for trigger indexing and fix serialization mismatch in WorkflowTriggerEqualityComparer
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Refactor `WorkflowTriggerEqualityComparerTests`: streamline trigger creation with helper methods and extract serializer options to static fields for clarity.
* Enhance `WorkflowTriggerEqualityComparer`: add converters for enum, TimeSpan, and polymorphic objects in serializer options.
---------
Co-authored-by: Claude <noreply@anthropic.com>
* Adds activity execution call stack support
Implements a call stack mechanism to track the execution chain, enabling visibility into the invocation hierarchy.
Introduces new fields to scheduling models and runtime contexts to store call stack information.
Includes EF Core migrations for various database providers to support new columns in `ActivityExecutionRecords`.
Provides an API to query and reconstruct the call stack for a given activity execution.
* Refactor: Replace `PagedCallStackResult` with `Page<T>` for execution chain pagination
* Remove ambient scheduling scope logic and related methods
Simplifies scheduling logic by removing ambient scope mechanisms, refactoring scheduling context handling, and updating affected classes accordingly.
* Add `GetCallStackAsync` to `IActivityExecutionsApi` for querying activity execution call stack
* Add new properties to `ActivityExecutionRecord` for scheduling and execution tracking
Introduce fields for aggregated fault count, scheduling context, workflow instance details, and call stack depth to enhance execution monitoring and debugging capabilities.
* Add call stack visualization for activity executions
Introduced components and models to display a call stack for activity executions in the Workflow Instance Viewer. This includes UI elements for call stack rendering, error handling, and data integration with activity execution records.
* Remove obsolete ambient scheduling properties from WorkflowExecutionContext
* Fix infinite loop issues in activity execution chain traversal
Added cycle detection using a `HashSet` to prevent infinite loops when traversing activity execution chains in multiple storage implementations. Updated unit tests to validate correct handling of circular references and chain traversal.
* Refactor activity execution chain retrieval logic
Centralized the `GetExecutionChainAsync` method into an extension class to streamline and unify its implementation across stores. Removed redundant implementations from individual stores and updated interfaces to utilize the new extension method. This reduces code duplication and simplifies future maintenance.
* Add CallStackDepth property to activity contexts
Integrated the `CallStackDepth` property into `ActivityExecutionContext`, `ActivityExecutionContextState`, and related classes to track and manage the call stack depth of activity executions. Removed obsolete depth calculation logic to streamline the process.
* Add unit tests for call stack depth calculations and persistence
- Add `WorkflowExecutionContextTests` to verify correct calculation of call stack depth during activity execution.
- Add `WorkflowStateExtractorTests` to ensure call stack depth is preserved during state extraction and application.
* Update src/modules/Elsa.Workflows.Api/Endpoints/ActivityExecutions/GetCallStack/Endpoint.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update src/modules/Elsa.Workflows.Api/Endpoints/ActivityExecutions/GetCallStack/Endpoint.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Enhance activity execution handling with ID filter and task completion logic
- Implement `ActivityExecutionRecordFilter` for precise query matching by ID.
- Add await logic for task completion in command handler middleware.
* Add missing indexes for call stack columns in V3_7 migrations (#7250)
* Initial plan
* Add missing indexes for call stack columns in all provider migrations
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* Optimize migrations by creating columns with correct indexable types
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* Add unit tests for ActivityExecutionStoreExtensions
- Introduce tests for `GetExecutionChainAsync` covering scenarios of empty results, single records, multi-level chain traversal, workflow boundary constraints, pagination, and circular references.
* Refactor tests for `ActivityExecutionStoreExtensions`
- Replace mock setup with `CreateStore` helper for clean and clear test arrangements.
- Remove unused imports and clean up test setup for improved readability and maintenance.
* Remove unused imports from ActivityExecutionLogStore in Elsa.Persistence.EFCore module.
* Removes obsolete planning document
Removes the activity execution call stack planning document
as the feature has been implemented.
* Remove DefaultActivityExecutionMapperTests
- Deleted `DefaultActivityExecutionMapperTests.cs` as the test class is no longer in use and redundant.
* Address review feedback: Fix corrupted test, Oracle migrations, and call stack depth calculation (#7272)
* Initial plan
* Fix corrupted DefaultActivityExecutionMapperTests.cs test file
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* Fix Oracle migration snapshot to use NCLOB for large text fields
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* Optimize GetExecutionChainAsync to avoid loading all workflow instance records
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* Fix CallStackDepth calculation to support cross-workflow invocations
- Add SchedulingCallStackDepth to ActivityInvocationOptions
- Update WorkflowExecutionContext to use provided depth when scheduling context not found
- Remove problematic test that reveals pre-existing bug with duplicate contexts
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* Improve documentation for CallStackDepth calculation
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* Add WorkflowStateExtractor to ActivityTestFixture services
* Refactor `DefaultActivityExecutionMapperTests` with `ActivityTestFixture` and add project reference for shared testing utilities.
* Propagate SchedulingCallStackDepth through cross-workflow invocation chain (#7273)
* Initial plan
* Add SchedulingCallStackDepth propagation through cross-workflow invocation chain
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* Add unit tests for CallStackDepth propagation across workflow boundaries
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* Initial plan (#7274)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
* Reduce NVARCHAR2 column sizes in Oracle migrations to optimize storage and improve performance.
* Change column types to NCLOB for large text fields in Oracle migrations to enhance data storage capacity.
* Update GitHub Actions to use .NET 10.x and refactor setup classes for consistency
* Improve test project detection in GitHub Actions by handling non-csproj files and updating project sorting mechanism.
* Enhance GitHub Actions to display .NET environment info and enforce .NET 10 toolchain for test execution.
* Update GitHub Actions to use .NET SDK 10.0.1xx and enforce its usage for builds and tests.
* Refine GitHub Actions workflow by narrowing test project search to the `test/unit` directory and removing unnecessary script checks.
* Remove redundant build step from GitHub Actions workflow.
* Enhance GitHub Actions workflow by adding multiple test directories and handling ignored failed sources in .NET restore.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* Initial plan
* Add consumers API endpoint and enhance export with IncludeConsumingWorkflows option
- New endpoint: GET /workflow-definitions/{definitionId}/consumers
- Export request model: added IncludeConsumingWorkflows boolean property
- Export endpoint: recursive consumer discovery and inclusion in exports
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* Address greptile-apps feedback: fix double-fetch, remove redundant HashSet, add version comment, remove unused params
- Extract WriteZipResponseAsync helper to avoid double-fetching definitions from DB
- Remove redundant existingDefinitionIds HashSet in IncludeConsumersAsync
- Add XML doc comment documenting that consumers are resolved at VersionOptions.Latest
- Remove unused constructor parameters (workflowDefinitionService, variableDefinitionMapper)
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* Address greptile-apps round 2: 404 for unknown definitions, deterministic ZIP response, parallel BFS
- Consumers endpoint now returns 404 when the definition ID doesn't exist
- Single-workflow export always returns ZIP when includeConsumingWorkflows=true
- BFS traversal processes each frontier level concurrently via Task.WhenAll
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* Implement workflow reference graph feature
- Added `IWorkflowReferenceGraphBuilder` interface for building complete graphs of workflow references.
- Created `WorkflowReferenceGraph` and `WorkflowReferenceEdge` models.
- Implemented `WorkflowReferenceGraphBuilder` service for recursive graph building.
- Replaced previous workflow reference query logic with the new graph-based approach in consumers.
* Refactor workflow consumers to utilize recursive graph-based approach for retrieving consumer definitions.
* Enhance workflow export by adding support for including consuming workflows and update nullable default values across endpoints and models.
* Add WorkflowReferenceGraphOptions for depth and definition limit configuration
- Introduced `WorkflowReferenceGraphOptions` to configure max depth and definition limits for reference graph building.
- Updated `WorkflowManagementFeature` to support configuring these options.
- Enhanced `WorkflowReferenceGraphBuilder` to respect configuration limits during graph construction process.
* Refactor `WorkflowReferenceGraphBuilder` to utilize target-typed new expressions for cleaner code.
* Add Workflow Reference Graph tests and scenarios
Introduced JSON files for parent-child-grandchild workflow hierarchy tests and implemented unit tests for `WorkflowReferenceGraphBuilder`. Also added component tests for workflow export and consumers endpoint validation. Updated project configuration for workflow JSON to always copy to output directory.
* Include DefinitionId in exported workflow definition filenames for uniqueness.
* Remove unused models and constants from `WorkflowReferenceGraphTests`.
* Refactor `WorkflowReferenceGraphBuilderTests`: streamline test setup with `SetupGraph`, replace repeated assertions with helper methods.
* Deterministic ZIP export and 404 test coverage for consumers endpoint (#7312)
* Initial plan
* Fix deterministic ZIP export and add 404 test for consumers endpoint
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
Expanded contributing guidelines to emphasize clarity, discipline, and maintainability. Added sections on pull requests, bug reporting, and development workflow.
- Integrated tenant activation in `WorkflowTestFixture` to improve multitenancy support.
- Updated various package dependencies to latest versions for compatibility and performance improvements.
* Add integration tests for enumerables with projection to arrays
Introduce integration tests to verify the conversion of a Select-projected IEnumerable to an array using JavaScript execution. This includes creating new test cases, activities, and workflows to ensure the end-to-end process behaves as expected. Also refined type inference in `ExpressionExecutionContextExtensions` for projection operators.
* Remove unused newline in EnumerableProjectionTests
* Enhance `DefaultRegistriesPopulator`: add notification support for workflow definition reloads.
* Add unit tests for `DefaultRegistriesPopulator` to verify workflow definition reload notifications.
* Introduce role and user management services
- Add `CreateRoleResult` and `CreateUserResult` models for managing creation results.
- Implement `IRoleManager` and `IUserManager` interfaces and their service classes.
- Configure dependency injection for role and user managers.
- Refactor endpoints to use new manager interfaces.
* Remove IRoleStore dependency from Create endpoint
Revised appsettings.json to include a new "FastEndpoints" configuration block and updated CORS allowed origins. Modified IdentityFeature to bind IdentityTokenOptions directly to configuration for better integration.
- Implemented `CombinedPersistenceShellFeatureBase` for unified configuration of EF Core persistence components.
- Added `SharedPersistenceSettings` for shared configuration across multiple persistence shell features.
- Updated shell features for SQL Server, MySQL, PostgreSQL, SQLite, and Oracle to use a unified persistence approach.
- Refactored `PersistenceShellFeatureBase` to enable fallback to shared settings.