{
  "feature": "task-management",
  "version": "1.0.0",
  "description": "Task lifecycle management with kanban board, subtask hierarchies, dependency tracking, priority-based scheduling, and workload balancing across assignees.\n",
  "category": "workflow",
  "tags": [
    "tasks",
    "kanban",
    "project-management",
    "subtasks",
    "dependencies",
    "workload"
  ],
  "actors": [
    {
      "id": "reporter",
      "name": "Reporter",
      "type": "human",
      "description": "Creates tasks and tracks their progress"
    },
    {
      "id": "assignee",
      "name": "Assignee",
      "type": "human",
      "description": "Works on assigned tasks and updates status"
    },
    {
      "id": "reviewer",
      "name": "Reviewer",
      "type": "human",
      "description": "Reviews completed work before marking tasks done"
    },
    {
      "id": "system",
      "name": "Task Engine",
      "type": "system",
      "description": "Handles overdue detection, auto-assignment, and dependency resolution"
    }
  ],
  "fields": [
    {
      "name": "title",
      "type": "text",
      "required": true,
      "label": "Task Title",
      "placeholder": "Implement user authentication",
      "validation": [
        {
          "type": "required",
          "message": "Task title is required"
        },
        {
          "type": "maxLength",
          "value": 300,
          "message": "Title must be 300 characters or fewer"
        }
      ]
    },
    {
      "name": "description",
      "type": "rich_text",
      "required": false,
      "label": "Description",
      "placeholder": "Detailed description of the task..."
    },
    {
      "name": "assignee_id",
      "type": "text",
      "required": false,
      "label": "Assignee"
    },
    {
      "name": "reporter_id",
      "type": "text",
      "required": true,
      "label": "Reporter"
    },
    {
      "name": "status",
      "type": "select",
      "required": true,
      "label": "Status",
      "default": "todo",
      "options": [
        {
          "value": "todo",
          "label": "To Do"
        },
        {
          "value": "in_progress",
          "label": "In Progress"
        },
        {
          "value": "in_review",
          "label": "In Review"
        },
        {
          "value": "done",
          "label": "Done"
        },
        {
          "value": "blocked",
          "label": "Blocked"
        },
        {
          "value": "canceled",
          "label": "Canceled"
        }
      ]
    },
    {
      "name": "priority",
      "type": "select",
      "required": true,
      "label": "Priority",
      "default": "medium",
      "options": [
        {
          "value": "low",
          "label": "Low"
        },
        {
          "value": "medium",
          "label": "Medium"
        },
        {
          "value": "high",
          "label": "High"
        },
        {
          "value": "urgent",
          "label": "Urgent"
        }
      ]
    },
    {
      "name": "due_date",
      "type": "date",
      "required": false,
      "label": "Due Date"
    },
    {
      "name": "tags",
      "type": "json",
      "required": false,
      "label": "Tags"
    },
    {
      "name": "project_id",
      "type": "text",
      "required": false,
      "label": "Project"
    },
    {
      "name": "estimated_hours",
      "type": "number",
      "required": false,
      "label": "Estimated Hours",
      "validation": [
        {
          "type": "min",
          "value": 0,
          "message": "Estimated hours cannot be negative"
        }
      ]
    },
    {
      "name": "actual_hours",
      "type": "number",
      "required": false,
      "label": "Actual Hours",
      "validation": [
        {
          "type": "min",
          "value": 0,
          "message": "Actual hours cannot be negative"
        }
      ]
    },
    {
      "name": "parent_task_id",
      "type": "text",
      "required": false,
      "label": "Parent Task"
    },
    {
      "name": "blocked_by",
      "type": "json",
      "required": false,
      "label": "Blocked By"
    }
  ],
  "states": {
    "field": "status",
    "values": [
      {
        "name": "todo",
        "description": "Task is created but not yet started",
        "initial": true
      },
      {
        "name": "in_progress",
        "description": "Assignee is actively working on the task"
      },
      {
        "name": "in_review",
        "description": "Work is complete and awaiting reviewer approval"
      },
      {
        "name": "done",
        "description": "Task is fully completed and accepted",
        "terminal": true
      },
      {
        "name": "blocked",
        "description": "Task cannot proceed due to unresolved dependencies"
      },
      {
        "name": "canceled",
        "description": "Task was canceled and will not be completed",
        "terminal": true
      }
    ],
    "transitions": [
      {
        "from": "todo",
        "to": "in_progress",
        "actor": "assignee",
        "description": "Assignee starts working on the task"
      },
      {
        "from": "in_progress",
        "to": "in_review",
        "actor": "assignee",
        "description": "Assignee submits work for review"
      },
      {
        "from": "in_review",
        "to": "done",
        "actor": "reviewer",
        "description": "Reviewer approves the completed work"
      },
      {
        "from": "in_review",
        "to": "in_progress",
        "actor": "reviewer",
        "condition": "reviewer requests changes",
        "description": "Reviewer sends task back for rework"
      },
      {
        "from": "todo",
        "to": "blocked",
        "actor": "system",
        "condition": "blocked_by tasks are not all done",
        "description": "System detects unresolved dependencies"
      },
      {
        "from": "blocked",
        "to": "todo",
        "actor": "system",
        "condition": "all blocked_by tasks are done",
        "description": "Dependencies resolved, task unblocked"
      },
      {
        "from": "in_progress",
        "to": "blocked",
        "actor": "assignee",
        "description": "Assignee marks task as blocked"
      },
      {
        "from": "blocked",
        "to": "in_progress",
        "actor": "assignee",
        "condition": "blocker resolved",
        "description": "Assignee resumes work after blocker cleared"
      },
      {
        "from": "todo",
        "to": "canceled",
        "actor": "reporter",
        "description": "Reporter cancels the task before work begins"
      },
      {
        "from": "in_progress",
        "to": "canceled",
        "actor": "reporter",
        "description": "Reporter cancels the task during work"
      }
    ]
  },
  "rules": {
    "overdue_detection": {
      "description": "System checks tasks with a due_date against the current date. Tasks past their due date with status not in (done, canceled) are flagged as overdue and trigger a notification.\n"
    },
    "auto_assign": {
      "description": "When a task is created without an assignee and project-level auto-assign rules exist, the system assigns based on role matching, current workload, and round-robin rotation.\n"
    },
    "workload_balancing": {
      "description": "The system tracks each assignee's total estimated_hours for non-terminal tasks. Auto-assignment prefers the assignee with the lowest active workload.\n"
    },
    "dependency_tracking": {
      "description": "A task with blocked_by references cannot transition to in_progress until all referenced tasks reach done status. Circular dependencies are rejected at creation time.\n"
    },
    "subtask_rollup": {
      "description": "A parent task cannot be marked done until all its subtasks are in a terminal state (done or canceled). Progress percentage is computed from subtask completion ratio.\n"
    },
    "priority_escalation": {
      "description": "Urgent-priority tasks that remain in todo for more than 24 hours are escalated by notifying the project lead.\n"
    }
  },
  "outcomes": {
    "task_created": {
      "priority": 1,
      "given": [
        "reporter is authenticated",
        {
          "field": "title",
          "source": "input",
          "operator": "exists",
          "description": "Task title is provided"
        }
      ],
      "then": [
        {
          "action": "create_record",
          "type": "task",
          "target": "tasks",
          "description": "New task record created with default status todo"
        },
        {
          "action": "emit_event",
          "event": "task.created",
          "payload": [
            "task_id",
            "title",
            "reporter_id",
            "project_id"
          ]
        }
      ],
      "result": "Task created and visible on the kanban board",
      "error": "TASK_SUBTASKS_INCOMPLETE"
    },
    "task_assigned": {
      "priority": 2,
      "given": [
        "task exists and is not in a terminal state",
        {
          "field": "assignee_id",
          "source": "input",
          "operator": "exists",
          "description": "Assignee is specified"
        }
      ],
      "then": [
        {
          "action": "set_field",
          "target": "assignee_id",
          "value": "provided assignee_id"
        },
        {
          "action": "emit_event",
          "event": "task.assigned",
          "payload": [
            "task_id",
            "assignee_id",
            "reporter_id"
          ]
        },
        {
          "action": "notify",
          "channel": "in_app",
          "description": "Assignee notified of new task assignment"
        }
      ],
      "result": "Task assigned to the specified user",
      "error": "TASK_ALREADY_ASSIGNED"
    },
    "task_status_changed": {
      "priority": 3,
      "given": [
        "task exists",
        "requested status transition is valid per state machine",
        "actor has permission for this transition"
      ],
      "then": [
        {
          "action": "transition_state",
          "field": "status",
          "from": "current_status",
          "to": "new_status"
        },
        {
          "action": "emit_event",
          "event": "task.status_changed",
          "payload": [
            "task_id",
            "old_status",
            "new_status",
            "actor_id"
          ]
        }
      ],
      "result": "Task status updated and kanban board reflects the change"
    },
    "task_completed": {
      "priority": 4,
      "given": [
        "task is in in_review status",
        "reviewer approves the work",
        "all subtasks are in a terminal state"
      ],
      "then": [
        {
          "action": "transition_state",
          "field": "status",
          "from": "in_review",
          "to": "done"
        },
        {
          "action": "emit_event",
          "event": "task.completed",
          "payload": [
            "task_id",
            "assignee_id",
            "actual_hours",
            "completed_at"
          ]
        },
        {
          "action": "notify",
          "channel": "in_app",
          "description": "Reporter and assignee notified of task completion"
        }
      ],
      "result": "Task marked as done and removed from active board"
    },
    "task_overdue_detected": {
      "priority": 5,
      "given": [
        {
          "field": "due_date",
          "source": "db",
          "operator": "lt",
          "value": "now",
          "description": "Due date is in the past"
        },
        {
          "field": "status",
          "source": "db",
          "operator": "not_in",
          "value": [
            "done",
            "canceled"
          ],
          "description": "Task is still active"
        }
      ],
      "then": [
        {
          "action": "emit_event",
          "event": "task.overdue",
          "payload": [
            "task_id",
            "assignee_id",
            "due_date",
            "days_overdue"
          ]
        },
        {
          "action": "notify",
          "channel": "email",
          "description": "Assignee and reporter notified of overdue task"
        }
      ],
      "result": "Overdue task flagged and stakeholders notified"
    },
    "task_blocked_by_dependency": {
      "priority": 6,
      "given": [
        {
          "field": "blocked_by",
          "source": "db",
          "operator": "exists",
          "description": "Task has dependency references"
        },
        "at least one blocked_by task is not in done status"
      ],
      "then": [
        {
          "action": "transition_state",
          "field": "status",
          "from": "todo",
          "to": "blocked"
        },
        {
          "action": "emit_event",
          "event": "task.status_changed",
          "payload": [
            "task_id",
            "todo",
            "blocked",
            "system"
          ]
        }
      ],
      "result": "Task automatically blocked until dependencies resolve"
    },
    "invalid_transition": {
      "priority": 10,
      "error": "TASK_INVALID_TRANSITION",
      "given": [
        "requested status transition is not allowed by state machine"
      ],
      "then": [],
      "result": "Transition rejected with error message"
    },
    "circular_dependency_rejected": {
      "priority": 11,
      "error": "TASK_CIRCULAR_DEPENDENCY",
      "given": [
        "adding blocked_by reference would create a circular dependency"
      ],
      "then": [],
      "result": "Dependency rejected to prevent deadlock"
    }
  },
  "errors": [
    {
      "code": "TASK_NOT_FOUND",
      "message": "The requested task does not exist.",
      "status": 404
    },
    {
      "code": "TASK_INVALID_TRANSITION",
      "message": "The requested status transition is not allowed.",
      "status": 400
    },
    {
      "code": "TASK_CIRCULAR_DEPENDENCY",
      "message": "This dependency would create a circular reference.",
      "status": 400
    },
    {
      "code": "TASK_SUBTASKS_INCOMPLETE",
      "message": "Cannot complete task while subtasks are still active.",
      "status": 409
    },
    {
      "code": "TASK_ALREADY_ASSIGNED",
      "message": "This task is already assigned to another user.",
      "status": 409
    },
    {
      "code": "TASK_ACCESS_DENIED",
      "message": "You do not have permission to modify this task.",
      "status": 403
    }
  ],
  "events": [
    {
      "name": "task.created",
      "description": "A new task was created",
      "payload": [
        "task_id",
        "title",
        "reporter_id",
        "project_id"
      ]
    },
    {
      "name": "task.assigned",
      "description": "A task was assigned to a user",
      "payload": [
        "task_id",
        "assignee_id",
        "reporter_id"
      ]
    },
    {
      "name": "task.status_changed",
      "description": "A task transitioned to a new status",
      "payload": [
        "task_id",
        "old_status",
        "new_status",
        "actor_id"
      ]
    },
    {
      "name": "task.completed",
      "description": "A task was marked as done",
      "payload": [
        "task_id",
        "assignee_id",
        "actual_hours",
        "completed_at"
      ]
    },
    {
      "name": "task.overdue",
      "description": "A task passed its due date without completion",
      "payload": [
        "task_id",
        "assignee_id",
        "due_date",
        "days_overdue"
      ]
    }
  ],
  "related": [
    {
      "feature": "approval-chain",
      "type": "optional",
      "reason": "Tasks requiring sign-off can use the approval chain workflow"
    },
    {
      "feature": "scheduling-calendar",
      "type": "optional",
      "reason": "Task due dates and milestones can sync to calendar events"
    },
    {
      "feature": "bulk-operations",
      "type": "optional",
      "reason": "Bulk status updates or reassignment across multiple tasks"
    },
    {
      "feature": "state-machine",
      "type": "optional",
      "reason": "Task status transitions can be modeled as a configurable state machine"
    },
    {
      "feature": "email-notifications",
      "type": "recommended",
      "reason": "Notify assignees and reporters of task changes via email"
    },
    {
      "feature": "role-based-access",
      "type": "recommended",
      "reason": "Control who can create, assign, and transition tasks"
    }
  ],
  "agi": {
    "goals": [
      {
        "id": "reliable_task_management",
        "description": "Task lifecycle management with kanban board, subtask hierarchies, dependency tracking, priority-based scheduling, and workload balancing across assignees.\n",
        "success_metrics": [
          {
            "metric": "processing_time",
            "target": "< 5s",
            "measurement": "Time from request to completion"
          },
          {
            "metric": "success_rate",
            "target": ">= 99%",
            "measurement": "Successful operations divided by total attempts"
          }
        ],
        "constraints": [
          {
            "type": "performance",
            "description": "Must not block dependent workflows",
            "negotiable": true
          }
        ]
      }
    ],
    "autonomy": {
      "level": "semi_autonomous",
      "human_checkpoints": [
        "before transitioning to a terminal state"
      ],
      "escalation_triggers": [
        "error_rate > 5"
      ]
    },
    "safety": {
      "action_permissions": [
        {
          "action": "task_created",
          "permission": "supervised"
        },
        {
          "action": "task_assigned",
          "permission": "autonomous"
        },
        {
          "action": "task_status_changed",
          "permission": "supervised"
        },
        {
          "action": "task_completed",
          "permission": "autonomous"
        },
        {
          "action": "task_overdue_detected",
          "permission": "autonomous"
        },
        {
          "action": "task_blocked_by_dependency",
          "permission": "human_required"
        },
        {
          "action": "invalid_transition",
          "permission": "autonomous"
        },
        {
          "action": "circular_dependency_rejected",
          "permission": "supervised"
        }
      ]
    },
    "tradeoffs": [
      {
        "prefer": "reliability",
        "over": "speed",
        "reason": "workflow steps must complete correctly before proceeding"
      }
    ]
  }
}