elsa-core/src/modules/Elsa.Workflows.Core/Activities
Sipke Schoorstra 74fc891350
feat(core): let a container withdraw work it scheduled but must not run (#7967)
A container that schedules a child and then decides the child must not run
had no way to withdraw it. `IActivityScheduler` exposed no removal operation,
and `CancelActivityAsync` no-opped on a context whose status was `Pending`,
so a container could tear a branch down and still have an activity from that
branch execute afterwards, side effects and all. Fixes #7943.

- `IActivityScheduler.RemoveWhere` removes work items and keeps the order the
  survivors would have been taken in; implemented in both the FIFO and LIFO
  schedulers.
- `CancelActivityAsync` (both the public extension and the internal one used
  when a container completes) cancels `Pending` contexts as well as running
  ones, and withdraws the work item that would have started the cancelled
  activity plus the items it had scheduled for children with no context yet.

Withdrawal is a real removal rather than a terminal status honoured at dequeue
time, because the scheduler is also read: `Flowchart.HasPendingWork` inspects
it to decide whether it may complete, and the work item list is extracted into
the persisted workflow state — a withdrawn-but-queued item would be persisted
and rehydrated with a fresh context after a suspend/resume.

`StateMachine` had hand-rolled the same operation to drop competing triggers by
clearing the scheduler and re-scheduling everything else; it now calls
`RemoveWhere`. `Elsa.Bpmn` no longer needs to refuse a teardown whose subtree
still has queued work, so `BpmnWorkTeardown` drops the `NotSupportedException`
and records the teardown reason on the torn-down activity's journal instead.

BREAKING: `IActivityScheduler` gains a member; external implementations must
add `RemoveWhere`.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 23:29:46 +02:00
..
Flowchart Refactor: Overhauls workflow JSON type serialization (#7549) 2026-05-31 11:09:39 +02:00
StateMachine feat(core): let a container withdraw work it scheduled but must not run (#7967) 2026-08-20 23:29:46 +02:00
Break.cs Replace default! with null! for better nullability safety 2025-05-25 19:26:38 +02:00
Complete.cs Replace default! with null! for better nullability safety 2025-05-25 19:26:38 +02:00
Composite.cs Replace default! with null! for better nullability safety 2025-05-25 19:26:38 +02:00
Container.cs Replace default! with null! for better nullability safety 2025-05-25 19:26:38 +02:00
Correlate.cs Replace default! with null! for better nullability safety 2025-05-25 19:26:38 +02:00
DynamicActivity.cs
End.cs Replace default! with null! for better nullability safety 2025-05-25 19:26:38 +02:00
Fault.cs
Finish.cs Adds ILoggerFactory support to converters (#7153) 2025-12-19 21:54:20 +01:00
For.cs Improves Fork activity and break signal handling (#7104) 2025-11-25 19:29:02 +01:00
ForEach.cs
ForEachT.cs Addresses warnings and enforces null safety (#7050) 2025-11-12 15:53:23 +01:00
Fork.cs Improves Fork activity and break signal handling (#7104) 2025-11-25 19:29:02 +01:00
If.cs Replace default! with null! for better nullability safety 2025-05-25 19:26:38 +02:00
Inline.cs
NotFoundActivity.cs Replace default! with null! for better nullability safety 2025-05-25 19:26:38 +02:00
Parallel.cs Adds activity execution call stack support (#7271) 2026-02-24 15:23:59 +01:00
ParallelForEach.cs
ParallelForEachT.cs Add unit and integration tests for ParallelForEach activity covering behavior with different item types, fault handling, and scenario-specific conditions (#7120) 2025-11-27 20:58:58 +01:00
ReadLine.cs Replace default! with null! for better nullability safety 2025-05-25 19:26:38 +02:00
Sequence.cs Adds activity execution call stack support (#7271) 2026-02-24 15:23:59 +01:00
SetName.cs
SetVariable.cs Update src/modules/Elsa.Workflows.Core/Activities/SetVariable.cs 2025-10-09 09:40:01 +02:00
Start.cs Replace default! with null! for better nullability safety 2025-05-25 19:26:38 +02:00
Switch.cs Fix Switch activity behavior and add testing utilities for RunWorkflowResult and improve (#7151) 2025-12-19 17:05:12 +01:00
While.cs Adds activity execution call stack support (#7271) 2026-02-24 15:23:59 +01:00
Workflow.cs
WriteLine.cs Replace default! with null! for better nullability safety 2025-05-25 19:26:38 +02:00