feat: implement automation workflow feature#249
Open
pikann wants to merge 2 commits into
Open
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.
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.