User task workflow capabilities
User Tasks let a workflow pause for human work, present that work through a secure task queue, and continue with a typed outcome. The capability owns the task life cycle and workflow link while the host owns people, groups, sign-in, policy, and delivery services.
Human-task capability
The User Task capability connects a blocking workflow activity to a task that people can find and complete. It supports work queues, controlled access to task data, forms, deadlines, guest work, and workflow outcomes without requiring Elsa to own a user directory.
Task activity
The UserTask activity defines the human step in a workflow. At run time it evaluates the task context, assignment rules, actions, optional form, timing rules, and guest invitation rules, then waits for a governed response.
Task definition and outcome
The activity exposes safe work context such as a title, summary, reference, tags, task type, priority, and due time. It can also carry protected instructions and task data. A task has one or more stable action keys, and the selected key becomes part of the workflow result.
An optional form provider supplies a provider-neutral form description. The form is fixed to a version when the task starts. A worker's response is checked and normalized against that version before Elsa gives it to the workflow. A task without a form accepts an action only and does not accept arbitrary response data.
The activity returns the task ID, selected outcome, validated response data, and configured completion details to later workflow steps. Timeout and Cancelled are reserved outcomes for system timeout and manager cancellation rather than worker-selected actions.
References: src/…/UserTask.cs• L16-20 src/…/UserTask.cs• L24-47 src/…/UserTask.cs• L58-119 src/…/UserTaskModels.cs• L176-223
Workflow suspension and task projection
The workflow remains the source of truth for whether the human step is waiting and whether it has resumed. The task queue is a durable projection of that workflow state, which lets task queries be indexed and secured without changing the workflow engine's bookmark behavior.
Bookmark projection
When the activity reaches the human step, it creates a dedicated User Task bookmark. The bookmark carries a materialized task definition and the workflow context needed to create the task record. The task projection is created only after the workflow bookmark commit succeeds, so an uncommitted workflow cannot expose a task.
Projection is safe to repeat. The materialization and bookmark identity prevent duplicate task records when a commit notification is delivered more than once. The task repository keeps those identity checks within the tenant boundary. A short delay can exist between workflow commit and task visibility because projection follows the workflow commit.
References: src/…/UserTask.cs• L88-110 src/…/UserTaskBookmarkPersistedHandler.cs• L11-37 src/…/DefaultUserTaskProjectionService.cs• L8-20 src/…/InMemoryUserTaskRepository.cs• L112-123 doc/…/0027-project-user-tasks-from-committed-bookmarks.md• L9-17
Resumption and recovery
Completion, timeout, and cancellation first record a transitional task state. The system then sends one typed stimulus to the matching bookmark. When the bookmark is removed, the task becomes Completed, TimedOut, or Cancelled and the workflow has accepted the outcome.
A bounded recovery pass repairs gaps after a process or storage failure. It recreates missing projections from committed bookmarks, retries accepted outcomes whose stimulus was not delivered, and finalizes tasks whose bookmarks are gone. Ambiguous records remain visible for manager review instead of being silently removed.
References: src/…/DefaultUserTaskManager.cs• L288-367 src/…/DefaultUserTaskProjectionService.cs• L22-77 src/…/DefaultUserTaskReconciler.cs• L13-109 src/…/DefaultUserTaskWorkflowResumer.cs• L8-19
Assignment and access
Assignment decides who can claim or work on a task. Access always combines the module permission with a relationship to the task, so a permission by itself does not expose another person's work.
Participants and assignment
Participants are opaque, tenant-scoped references made from a provider, a type, and an external ID. The module can use a host's existing identity system, such as claims, a directory, or an external user store. It does not require an Elsa user or group record.
The default claims resolver turns the signed-in principal into the task actor. It reads the subject, tenant, provider, group, and permission claims that the host configures, then gives manager standing to an actor with the manager role or the task-supervise permission. This identity mapping supplies assignment and policy checks, while the task relationship still limits access to the work.
Tasks can name an assignee, candidate users, or candidate groups. Live group membership checks the current actor's group claims. Snapshot membership records group members when the task starts. Explicit exclusions take priority over ordinary assignment, while a manager override is an optional, reason-bearing action.
The requester gives context only. It does not receive task access. A task with no assignee, candidate, or invitation is Unassigned and remains a manager-only work item until someone routes it.
References: src/…/UserTaskModels.cs• L84-131 src/…/UserTaskModels.cs• L176-198 src/…/DefaultClaimsIdentityResolver.cs• L11-52 src/…/DefaultUserTaskManager.cs• L36-67 doc/…/0026-identity-neutral-user-task-participants.md• L9-21
Protected data and disclosure
Task summaries are safe queue data. They can include the title, summary, reference, tags, workflow context, status, priority, due state, and caller capabilities. Instructions, task data, forms, and completion data are protected and are not used for search.
Candidates can see enough summary to decide whether to claim work. The assignee can read protected content. Releasing the task removes that access at once. After the task closes, the completer and managers retain protected access while prior assignees receive only safe history. Masked form fields require a separate authorized and audited reveal request.
References: src/…/DefaultUserTaskAccessPolicy.cs• L1-200 src/…/UserTaskModelMapper.cs• L1-240 src/…/UserTaskModels.cs• L547-600 specs/…/identity-contract.md• L26-32
Guest invitations
Guest invitations let an external person complete one task without an Elsa account. The host supplies the invitation delivery and challenge services, while User Tasks controls the task scope, expiry, allowed actions, and revocation rules.
Invitation lifecycle
An authorized manager or workflow can issue an invitation from an action set already allowed by the activity. Each invitation expires at its configured bound, or earlier at the task due time. The module stores a hash of the one-time token and sends the raw token only through the delivery boundary.
Anonymous callers receive generic challenge and failure responses. Rate limiting applies to the caller rather than the token, which limits token probing. The first valid verification claims the open task, consumes the winning invitation, revokes sibling invitations, and creates a guest session.
Managers can revoke an invitation before or after it is consumed. Revocation also removes the session created by that invitation, so a live guest credential can be withdrawn.
References: src/…/DefaultUserTaskInvitationService.cs• L17-97 src/…/DefaultUserTaskInvitationService.cs• L100-152 src/…/DefaultUserTaskInvitationService.cs• L154-235 specs/…/invitations-contract.md• L1-17
Guest session
A guest session identifies exactly one task and carries a fixed allowlist of completion actions. The guest can read the permitted task view and complete it, but cannot release, reassign, invite, cancel, or manage work. The session expires at the earlier of its own lifetime and the invitation expiry, and all sessions end when the task reaches a terminal state.
The guest API uses the session credential as its authority. It does not place a task ID in the guest route, which prevents a guest from addressing another task through a modified URL. Guest views contain only fields the task explicitly marks as guest-visible.
References: src/…/UserTaskGuestSecurity.cs• L16-69 src/…/UserTaskGuestSecurity.cs• L205-241 src/…/UserTasksEndpoints.cs• L618-685 specs/…/rest-api.md• L55-64
Due dates and notifications
Due processing keeps human work visible when time passes. It marks open tasks overdue and can turn an overdue task into the reserved timeout outcome when the workflow enables that behavior.
Due-date processing
The due service scans tasks in bounded pages. For a task without timeout, the first successful scan marks it overdue and publishes one overdue notification; later scans do not publish duplicates. For a task with timeout enabled, the scan starts the normal asynchronous terminal path with action Timeout.
Due dates are UTC values. Workers and managers can also update priority and due time while the task is open. A due-date race with completion or cancellation is resolved by the task revision and the first accepted transition.
References: src/…/DefaultUserTaskDueService.cs• L8-73 src/…/DefaultUserTaskManager.cs• L370-431 src/…/UserTaskWorkers.cs• L61-86 src/…/UserTasksOptions.cs• L33-40
Lifecycle notifications
User Tasks publishes lifecycle notifications after state changes commit. They let hosts trigger email, escalation, webhook, or client refresh work without making those consumers part of the task core.
Notifications identify the tenant, task, status, revision, and safe change information. They do not carry instructions, task data, form values, completion payloads, invitation tokens, guest credentials, or provider-private data. The durable task event history provides an append-only audit record with the same safe-data boundary.
References: src/…/DefaultUserTaskNotificationSink.cs• L8-13 src/…/UserTaskModels.cs• L676-686 specs/…/runtime-contract.md• L321-327
Task APIs
The REST surface gives authenticated clients one contract for finding, reading, and acting on tasks. It exposes server-computed capabilities and keeps authorization, disclosure, validation, and concurrency decisions on the server.
Queue and task reads
Clients first read /user-tasks/capabilities to decide which navigation and actions to show. They then use /user-tasks for cursor-based queue queries and /user-tasks/{id} for a task detail view. Queue search uses safe fields only and supports assigned, available, history, manager-wide, and needs-attention scopes.
Task detail includes protected content only when the caller has the required relationship and permission. The repository applies tenant and relationship visibility before it counts, sorts, or pages queue results. Per-task capabilities include the current revision and allowed actions. A client must treat the capability response as guidance for rendering, not as a replacement for server authorization.
References: src/…/UserTasksEndpoints.cs• L82-175 src/…/UserTasksEndpoints.cs• L178-243 src/…/UserTaskModels.cs• L547-645 src/…/InMemoryUserTaskRepository.cs• L34-67 specs/…/rest-api.md• L5-39
Task commands
Clients can claim, release, assign, update priority or due time, complete, cancel, retry resolution, and manage invitations through /user-tasks. Claim, release, assignment, and scheduling changes complete as direct state changes. Completion, cancellation, and timeout return 202 after the system accepts an asynchronous workflow continuation.
Commands carry the task's expectedRevision. Repository updates use that revision as a compare-and-swap boundary, so only one competing change can win. Commands that can be retried also carry a client-created operationId. Reusing the same operation with the same request is safe. Reusing it with different content is a conflict. Clients observe terminal completion by reading the task again or responding to a lifecycle invalidation.
The API uses 404 to conceal tasks that exist but are not accessible, 409 for revision or state races, 422 for semantic input errors, and 429 for throttled anonymous invitation traffic. Error bodies use stable, display-safe codes and messages.
References: src/…/UserTasksEndpoints.cs• L246-420 src/…/DefaultUserTaskManager.cs• L234-368 src/…/UserTaskModels.cs• L433-465 specs/…/rest-api.md• L41-77
Client workbench
Elsa Studio is an optional client for the same task APIs. It provides assigned, available, history, all, and needs-attention views, then uses the server's action and disclosure projections to render task detail. Custom applications can use the REST contract without using Studio.
Task creation does not happen from the task list. A published workflow creates a task when its User Task activity runs. Designers configure the activity in the workflow designer, while workers and managers act on the resulting runtime task.
References: specs/…/studio-contract.md• L1-26 specs/…/studio-contract.md• L28-67 specs/…/studio-contract.md• L81-103 src/…/UserTask.cs• L16-20
Change checklist
When these files or sections are changed, remember to consider these:
- Keep activity action keys, reserved outcomes, form validation, and invitation action allowlists aligned. A mismatch can make a valid guest link or worker response unusable.
- Keep bookmark materialization, task projection keys, bookmark removal, and workflow stimuli aligned. A change to one side can create duplicate tasks or leave a workflow waiting after an accepted command.
- Keep participant reference shape, tenant scope, live or snapshot membership, exclusion rules, and host identity adapters aligned. A display or directory change must not change authorization semantics.
- Keep safe summaries, protected detail, reveal rules, audit events, notifications, and search fields aligned. Protected values must not cross into list results, URLs, logs, or lifecycle messages.
- Keep due scanning, timeout and cancellation transitions, operation idempotency, and lifecycle notification names aligned. Repeated scans must not create repeated terminal work or alerts.
- Keep guest invitation hashing, session scope, revocation, expiry, and anonymous API behavior aligned. A revoked invitation must not leave a usable session.
- Keep the task API revision, queue visibility and cursor rules, and operation contracts aligned with every client and with the durable storage providers described in User task persistence providers.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Task projection runs before the workflow bookmark commit | A task can appear for work that the workflow did not durably suspend | Project only from committed bookmark notifications and reconcile from the bookmark store |
| Completion uses an old revision or a competing terminal operation wins | The worker sees a conflict and the workflow receives only one terminal outcome | Require expectedRevision, use compare-and-swap, and keep terminal work transitional until bookmark removal |
| A candidate reads the task before claiming it | Protected instructions or form data can leak to an unauthorized worker | Return safe summaries to candidates and require protected access after assignment |
| A snapshot group cannot be enumerated | The task cannot safely prove candidate membership | Mark the task with a manager-only blocking health issue and allow resolution retry |
| A guest invitation is consumed and then revoked | A guest session could remain live if revocation covers only invitation state | Revoke sessions both before and after the invitation state change |
| An overdue scan runs repeatedly | Hosts can send duplicate overdue alerts or start duplicate timeout work | Record the overdue state or timeout operation idempotently before publishing or resuming |
| A client reuses an operation ID with different content | An old command can be confused with a new command | Hash the canonical request and return an idempotency conflict on mismatch |
Key files
| File | Why to read it |
|---|---|
| src/…/UserTask.cs | Defines the workflow-facing human step and its typed result. |
| src/…/DefaultUserTaskManager.cs | Shows the task life cycle, access checks, commands, forms, and asynchronous outcomes. |
| src/…/UserTaskBookmarkPersistedHandler.cs | Connects committed workflow bookmarks to task creation and bookmark removal. |
| src/…/DefaultUserTaskProjectionService.cs | Shows how projections become terminal after bookmark removal. |
| src/…/DefaultUserTaskReconciler.cs | Shows the recovery boundary for missing projections and stale workflow outcomes. |
| src/…/DefaultUserTaskInvitationService.cs | Defines invitation issue, verify, consume, sibling revoke, and guest-session creation. |
| src/…/UserTaskGuestSecurity.cs | Defines task-scoped guest credentials, rate limiting, and encrypted delivery handling. |
| src/…/DefaultClaimsIdentityResolver.cs | Maps host claims to task participants, groups, permissions, and manager standing. |
| src/…/DefaultUserTaskDueService.cs | Defines overdue marking and the optional timeout path. |
| src/…/UserTasksEndpoints.cs | Defines the authenticated, anonymous invitation, and guest REST surfaces. |
| src/…/UserTaskModels.cs | Defines task states, participants, outcomes, projections, capabilities, and lifecycle notifications. |
| src/…/InMemoryUserTaskRepository.cs | Illustrates tenant-scoped query visibility, projection idempotency, cursor paging, and revision-checked task changes. |
| docs/user-task-persistence.md | Explains the storage providers and their shared behavior for durable task state. |