Task automation
Task automation lets an organization turn task events into repeatable work rules. A rule watches a task change or a schedule, checks the task against optional conditions, and then updates task fields or sends notices while keeping a run history.
Automation model
An automation rule belongs to one organization and runs in its saved order. It can apply to the whole organization or to a project or team, and it can be enabled or disabled without deleting its definition. The task-automation server owns rule evaluation and task changes, while the UI plugin gives managers a settings screen for the same organization-level rules.
The rule has three parts:
- Trigger: the event that starts evaluation, such as task creation, assignment, a status change, a passed due date, a closed linked issue or pull request, all sub-tasks becoming done, or a sub-task reopening. A closed-link rule can also require a pull request to be merged.
- Conditions: tests that must all pass. With no conditions, the rule applies after its trigger matches.
- Actions: ordered changes to status, priority, assignees or labels, plus notices to the task assignees.
Rules may use built-in templates as starting points. A template can require later input or an external integration before it is useful. The editor keeps a rule that needs organization values switched off until a manager completes it.
References: packages/…/task-automation-rule.entity.ts• L9-55 packages/…/triggers.ts• L24-40 packages/…/rule-validation.ts• L47-71 packages/…/en.json• L79-95
Change-driven execution
The server turns committed task activity into a small change event that automation can understand. It keeps only changes that can start a rule, such as a real status transition or a newly added assignee, and sends the event through the outbox so task work is not rolled back when automation delivery fails.
The event carries tenant and organization scope. It also carries the automation chain when an action changes a task, so later runs can detect a loop. The consumer validates that the event payload matches its envelope before it passes the event to the engine.
This diagram shows how a task write becomes an automation run.
flowchart LR
A[Task write] --> B[Activity fact]
B --> C[Change capture]
C --> D[Task automation outbox event]
D --> E[Event consumer]
E --> F[Trigger matching]
F --> G[Rule runner]
G --> H[Task update or notice]
H --> I[Activity and later events]
I --> J[Loop guard]
The event path is best effort after the task write commits. A missed capture loses the automation reaction for that change, but it does not fail the task save. Repeated delivery is safe because each rule claims a run once for an event key.
References: packages/…/task-automation-event.consumer.ts• L19-29 packages/…/task-automation-event.consumer.ts• L61-83 packages/…/task-automation-engine.service.ts• L32-71 packages/…/task-automation-runner.service.ts• L73-83
Closed-link execution
The server also turns an integration report about a linked issue or pull request into an automation event. It accepts the report only when it identifies a task, organization, provider and external item, and it acts on the linked task rather than on the integration record.
The server records each closed link before it publishes the event. This makes a provider redelivery, a second API instance, or the same link closing again after a reopen safe. A merged pull request has a separate merge claim, so a pull request that first closes without merging can later trigger rules that require a merge. Rules without that option run on the first close only.
The closed-link flow is coordinated as follows:
- An integration reports a closed issue or pull request.
- The server confirms that the task belongs to the reported tenant and organization and that a link rule is enabled.
- The server claims the close, and the merge when the report is a merged pull request.
- A new claim adds one event to the task's event partition.
- The consumer applies matching link rules. A repeated claim adds no event.
References: packages/…/task-automation-link-closed.capture.ts• L17-32 packages/…/link-closed.ts• L31-85 packages/…/task-automation-link-closure.entity.ts• L9-29 packages/…/task-automation-link-closure.store.ts• L24-29
Conditions and actions
Conditions describe the state a task must have when the rule runs. They can test status or status category, open or done state, priority, labels, assignment, sub-task state and title text. The engine evaluates every condition and records each result so a dry run and a history entry can explain why a rule did or did not apply.
Actions are evaluated in their saved order. Each later action sees the values planned by earlier actions, which lets one rule build a single task update from several steps. The plan reports changes, unchanged values and invalid organization references separately, so one bad action does not hide the result of the others.
The available action effects are:
- Set a named status or the first status in a status category.
- Set a named priority.
- Add or replace assignees.
- Add or remove labels.
- Send a message to the task's current assignees.
The writer applies task changes through the normal task update path. This keeps activity records, notifications, integrations and real-time updates consistent with a user-made task change. Notices use the Inbox when it is available and otherwise use platform notifications.
References: packages/…/rule-validation.ts• L73-177 packages/…/task-automation-engine.service.ts• L190-207 packages/…/task-automation-runner.service.ts• L146-244 packages/…/task-automations-ui.helpers.ts• L43-84
Rule safeguards
The runner reads the task again before it claims a run. It checks organization, project and team scope, then applies conditions and actions to that current snapshot. A task lock prevents concurrent runs from overwriting full assignee or label lists.
The run record gives each rule and event a unique identity. This prevents duplicate work when a message is delivered more than once. The runner also stops automation chains that exceed the allowed depth, stops repeated task changes inside the rate window, and records partial work when one update or notice fails.
Run outcomes show the reason a rule ended:
| Outcome | Meaning |
|---|---|
APPLIED | At least one update or notice succeeded. |
PARTIAL | Work succeeded but one or more actions failed. |
NO_CHANGE | The rule matched but had no new update or notice. |
CONDITIONS_NOT_MET | The trigger matched but a condition failed. |
LOOP_GUARD or RATE_LIMITED | Safety limits blocked the work. |
FAILED | The run could not apply its planned work. |
References: packages/…/task-automation-runner.service.ts• L96-128 packages/…/task-automation-runner.service.ts• L136-248 packages/…/task-automation-event.consumer.ts• L19-29
Persistence and scheduling
The server stores rule definitions and run history as organization-scoped data. A rule stores its trigger settings, conditions and actions as one logical definition. A run stores the event identity, trigger, outcome, depth and details. Deleting a rule also deletes its run history, while a run can remain after its task is deleted.
Closed-link claims are separate organization-scoped records. Their unique task-and-link identity preserves the fact that a close was already handed to automation. The claim and outbox event are committed together, so a failed event write does not consume the close.
Due-date rules use a scheduled sweep rather than a task-change event. One sweep holds a shared lock, checks open tasks in a bounded recent window, and reads the full window in due-date order while skipping due dates that the rule already reported. It processes at most one batch of new runs per rule, so older unprocessed work waits for a later sweep without blocking newer due tasks. A busy task is left for a later sweep, and each run uses the task and due date as its event key. Under MikroORM, each sweep run gets its own request context for task writes.
References: packages/…/task-automation-rule.entity.ts• L16-55 packages/…/task-automation-link-closure.entity.ts• L9-29 packages/…/1791000009110-CreateTaskAutomationLinkClosureTable.ts• L31-71 packages/…/task-automation-migrations.ts• L1-10 packages/…/task-automation-due-sweep.service.ts• L18-37 packages/…/task-automation-due-sweep.service.ts• L56-118
Permissions and organization scope
Task automation is an organization management feature. Every server route and read query requires TASK_AUTOMATION_MANAGE, and the server checks the caller's tenant and organization before it reads or changes a rule. Rule references such as projects, teams, statuses, priorities, employees and labels must belong to the same organization or be valid shared defaults.
The feature is optional at deployment level. When GAUZY_TASK_AUTOMATIONS_ENABLED is not exactly true, the server does not load its routes, schema, tables, schedules or permission grant. When it is enabled, the migration grants management access to the built-in super-admin, admin and manager roles unless a tenant has made a deliberate permission choice.
References: packages/…/task-automation.controller.ts• L27-36 packages/…/task-automation.resolver.ts• L26-35 packages/…/task-automation-rule.service.ts• L57-81 packages/…/task-automation-rule.service.ts• L279-363 packages/…/task-automations.plugin.ts• L13-18 packages/…/1791000007820-SeedTaskAutomationRolePermissions.ts• L6-27
Configuration screens
The UI plugin adds Settings → Automations for a signed-in user who can manage task automations. It first checks whether the server exposes the feature. A disabled server or a user without permission keeps the menu entry hidden, while a temporary server failure is retried.
The screen lets an organization:
- List rules in execution order and switch them on or off.
- Move rules up or down or drag them into a new order.
- Create a blank rule or start from a built-in template.
- Set a project or team scope and choose a trigger.
- Limit a status trigger by its previous or new statuses.
- Limit a closed-link trigger to merged pull requests.
- Add conditions and ordered actions with organization directories as choices.
- Run a dry test against a task without writing changes.
- View recent run outcomes and details.
- Delete a rule and its history.
The editor uses the selected organization's projects, teams, statuses, priorities, employees and labels. When a rule is narrowed to a project or team, the screen also offers the scoped status and priority choices needed to configure that rule. It keeps saved values visible even when a current directory response does not include them.
References: packages/…/automations-page.component.html• L30-81 packages/…/automations-page.component.html• L85-190 packages/…/automation-editor.component.html• L75-141 packages/…/automation-editor.component.html• L143-334 packages/…/task-automations-ui.helpers.ts• L188-264
Related pages
Task automation is part of the broader collaboration suite. Its plugin and event behavior also relates to collaboration plugins and real-time workflows, Jira integration, and plugin architecture.
API surfaces
The settings screen uses the task-automation REST API for rule changes, templates, dry runs and run history. The server also exposes read-only rule, template and run queries through GraphQL when the GraphQL feature is enabled. Both surfaces use the same organization scope and service behavior.
The main REST operations are:
| Operation | Purpose |
|---|---|
| Rule list and detail | Read organization rules and optional project or team filters. |
| Create, update and delete | Manage rule definitions and their enabled state. |
| Reorder | Change the order in which matching rules run. |
| Test | Show trigger, condition and action results without writing. |
| Runs | Read recent outcomes for one rule. |
References: packages/…/task-automation.controller.ts• L44-120 packages/…/task-automation.schema.ts• L13-76 packages/…/task-automations-api.service.ts• L26-82
Change checklist
When these files or sections are changed, remember to consider these:
- Keep trigger, condition and action values aligned between the shared contract, server validation, engine behavior and editor choices.
- Keep event capture fields aligned with trigger matching, especially status IDs, status values and assignee lists.
- Preserve the run event-key contract when changing delivery, due-date sweeps or retry behavior.
- Preserve the closed-link identity and merge-claim rules when changing provider events or link triggers.
- Keep the server permission and feature switch behavior aligned with UI availability checks.
- Keep the dry-run result and run-history meaning aligned with action outcomes or safety limits.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Automation event has a malformed payload or wrong tenant or organization | The consumer drops it and no rule runs | Payload parsing and envelope scope checks |
| Task update creates a new automation event chain | Rules can trigger each other repeatedly | Chain depth, loop marker and rate limits |
| Same event is delivered again | The rule could repeat its task update or notice | Unique rule/event run key and idempotent Inbox notice identity |
| Same closed link is reported again | The link rule could run more than once for one close | Unique task-and-link closure claim |
| Rule names a deleted or foreign organization value | The rule cannot be saved or its action can fail | Reference checks at save and action validation at run time |
| Due-date sweep runs while another process is sweeping | Duplicate scans or overlapping writes could occur | Shared sweep lock and per-task lock |
| A due task is busy with another automation run | Its due-date work waits for the next sweep | Retry-later result leaves its event key unfinished |
| Automation update or notice fails after a run is claimed | The source event is not re-run for that rule | Run history records FAILED or PARTIAL with details |
| Feature flag is off or management permission is absent | The UI entry is hidden and API access is refused | Availability probe and server guards |
Key files
| File | Why to read it |
|---|---|
| packages/…/task-automation-engine.service.ts | Connects delivered events, matching rules and dry-run behavior. |
| packages/…/task-automation-runner.service.ts | Shows scope checks, safety limits, action application and outcomes. |
| packages/…/triggers.ts | Defines event types and the task a trigger acts on. |
| packages/…/rule-validation.ts | Defines valid rule shapes and the values that rules may name. |
| packages/…/task-automation-link-closed.capture.ts | Connects integration link closures to the automation event flow. |
| packages/…/task-automation-link-closure.entity.ts | Defines the durable claim for a closed task link. |
| packages/…/task-automation-link-closure.store.ts | Coordinates one-time link claims with event publication. |
| packages/…/task-automation-event.consumer.ts | Validates and dispatches automation events. |
| packages/…/task-automation-due-sweep.service.ts | Coordinates due-date scans, paging, retry-later behavior and one run context per task. |
| packages/…/task-automation-rule.entity.ts | Defines the persisted organization rule. |
| packages/…/task-automation.schema.ts | Describes the read model exposed through GraphQL. |
| packages/…/automations-page.component.html | Shows rule ordering, templates, tests and history. |
| packages/…/automation-editor.component.html | Shows the configuration choices for triggers, conditions and actions. |
| packages/…/task-automations-ui.helpers.ts | Maps saved rules and templates to the editor and API input. |