feat: implement automation workflow feature#249
Merged
Conversation
- Added WorkflowConsumer to handle task activity events and evaluate automation workflows. - Implemented logic for assigning tasks based on workflow status rules and transitions. - Created database migration for new workflows, nodes, status rules, transitions, and edges. - Enhanced notification consumer to include workflow-related notes when tasks are assigned. - Added tests for workflow consumer functionality, including task assignment and status change handling.
- Modify `TriggeredByMemberID` in `AgentConversationResponse` to be a pointer to allow nil values, representing cases where conversations are triggered by the system actor. - Update tests in `agent_service_test.go` to handle the new pointer type for `TriggeredByMemberID`. - Enhance `AgentHandler` to resolve member IDs from the authenticated user context, ensuring proper member identification for chat sessions. - Implement `resolveMemberID` method in `AgentHandler` to map user IDs to project member IDs. - Refactor `notification_consumer.go` to accommodate the new handling of `TriggeredByMemberID`, allowing for nil values when assignments are made by the automation workflow engine. - Introduce `evalCache` in `workflow_consumer.go` to optimize repeated repository lookups during task status changes. - Update SQL migration to allow `triggered_by_member_id` in `agent_conversations` to be nullable, reflecting the new logic for automation-triggered conversations. - Add comprehensive tests for the new functionality in `notification_consumer_test.go` and `workflow_consumer_test.go` to ensure correctness and prevent regression.
…ariable' Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
…ariable' Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
…onflict handling - Implement tests for deleting task statuses, ensuring proper handling when in use by workflows. - Add checks in workflow activation to prevent activation without status rules. - Introduce retry logic for concurrent status rule and transition creations to handle conflicts gracefully. - Update HTTP handlers to publish assignment changes using a unified event publishing method. - Enhance error handling in response presenter for various workflow and task-related errors. - Refactor workflow consumer to ensure workflows are checked for active status during event processing, preventing actions on archived workflows. - Add tests to verify behavior when workflows are archived mid-event processing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds automation workflows: a project-scoped dependency graph over existing tasks that automatically hands work off (to a human or an AI agent) as tasks move through statuses, instead of requiring someone to manually reassign every step. Delivered end-to-end — API + execution engine, a canvas-based builder in the web app, MCP tools so agents can manage workflows themselves, architecture docs, and unit/e2e test coverage.
How it works
A workflow is a directed graph of nodes (each wrapping one task) plus two shared, workflow-level lookup tables: status rules (status → assignee) and status transitions (status → next status, from which the workflow's single "done" status is derived). Two events drive automation:
Workflows are
draft(freely editable) →active(engine evaluates it, graph locked) →archived(ignored, revertible to draft). Full design writeup:docs/architecture/automation-workflows.md.Changes
API (
services/api)workflowdomain (internal/domain/workflow): entity, errors, repository/service interfaces.000018_add_automation_workflows.sql:workflows,workflow_nodes,workflow_status_rules,workflow_status_transitions,workflow_edges.activate/archive/revert-to-draft), nodes, status rules, status transitions, and edges under/projects/{projectId}/workflows, plus a read-only/tasks/{taskId}/workflowsfor the task-detail view.WorkflowConsumer(internal/worker/workflow_consumer.go): Redis-stream worker that evaluates the two automation events above and reassigns tasks accordingly.workflows.read/workflows.write/workflows.*permissions, wired into default project roles.NotificationConsumerandAgentService.TriggerTaskAssignedextended so an AI agent that gets auto-assigned by a workflow is told which workflow assigned it and what status to set next to keep the pipeline moving.WORKFLOW_*error codes and aworkflow.assignedactivity type (attributed to a fixed system-actor user) so the activity feed can show automation-driven reassignments.Web UI (
apps/web)/projects/:projectId/automation) and the canvas editor (/projects/:projectId/automation/:workflowId).workflow-canvas.tsx(graph builder),add-workflow-node-modal.tsx,workflow-status-rules-panel.tsx,workflow-status-transitions-panel.tsx.workflows-section.tsxadded to the task detail modal, showing which workflows a task belongs to and linking back to them.workflow-api.tsclient + query options.MCP server (
apps/mcp)workflow-client.ts+ 18 new tools (list/get/create/update/delete_workflow,activate/archive/revert_workflow_to_draft, node/status-rule/status-transition/edge add/remove) so an AI agent can build and manage automation workflows itself, not just be a target of them.workflows.read/workflows.writepermission entries per tool.Docs
docs/architecture/automation-workflows.md— core model, the two events, done-status derivation, AND-join semantics, loop safety, lifecycle, and data model.docs/architecture/overview.mdupdated to link to it.Also included
Testing
workflow_service_test.go,workflow_consumer_test.go.workflow_management_test.go(CRUD + lifecycle),workflow_automation_test.go(status-change reassignment, predecessor-done cascades, AND-join).workflow-tools.test.ts, plus updates to existing tool-suite tests for the new permission entries.