> ## Documentation Index
> Fetch the complete documentation index at: https://mako-docs.devinagiffy.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Tasks Overview

> Understanding the task system in Hitler

## Task Flow

Hitler uses a **human-in-the-loop** task creation flow:

```
Natural Language → AI Parsing → Draft → Confirmation → Task
```

This ensures the AI never creates tasks autonomously.

## Task Drafts

When a task is created (via bot or API), it starts as a **draft**:

1. `POST /api/tasks/drafts` - Create a draft
2. `POST /api/tasks/drafts/:id/confirm` - Confirm → becomes real task
3. `DELETE /api/tasks/drafts/:id` - Reject → discarded

## Task Lifecycle

```mermaid theme={null}
graph LR
    A[Draft] -->|Confirm| B[Open]
    A -->|Reject| X[Discarded]
    B -->|Start Work| C[In Progress]
    C -->|Complete| D[Completed]
    B -->|Cancel| E[Cancelled]
    C -->|Cancel| E
```

## Task Properties

| Property         | Type     | Description                                     |
| ---------------- | -------- | ----------------------------------------------- |
| `id`             | UUID     | Unique identifier                               |
| `title`          | string   | Task title (max 200 chars)                      |
| `description`    | string   | Detailed description (optional, max 2000 chars) |
| `priority`       | integer  | 1 (highest) to 5 (lowest), default 3            |
| `status`         | enum     | `open`, `in_progress`, `completed`, `cancelled` |
| `dueDate`        | datetime | Optional deadline                               |
| `rawInput`       | string   | Original natural language (for AI learning)     |
| `userId`         | UUID     | Task owner                                      |
| `organizationId` | UUID     | Organization                                    |
| `createdAt`      | datetime | Creation timestamp                              |
| `updatedAt`      | datetime | Last update timestamp                           |

## Task Logs

Every task change is recorded:

```json theme={null}
{
  "id": "log-uuid",
  "taskId": "task-uuid",
  "action": "status_changed",
  "changes": {
    "status": { "from": "open", "to": "in_progress" }
  },
  "actorId": "user-uuid",
  "createdAt": "2024-01-15T10:30:00.000Z"
}
```

## Endpoints

| Method | Endpoint                    | Description                 |
| ------ | --------------------------- | --------------------------- |
| POST   | `/tasks/drafts`             | Create task draft           |
| GET    | `/tasks/drafts`             | List my pending drafts      |
| GET    | `/tasks/drafts/:id`         | Get draft by ID             |
| POST   | `/tasks/drafts/:id/confirm` | Confirm draft → create task |
| DELETE | `/tasks/drafts/:id`         | Reject draft                |
| GET    | `/tasks`                    | List my tasks               |
| GET    | `/tasks/organization`       | List org tasks (managers)   |
| GET    | `/tasks/stats`              | Get my statistics           |
| GET    | `/tasks/:id`                | Get task by ID              |
| PATCH  | `/tasks/:id`                | Update task                 |
| GET    | `/tasks/:id/logs`           | Get task event logs         |
