# Fusion Task Storage Structure

## Database Architecture

Fusion uses a hybrid storage architecture: structured metadata in SQLite, large blobs on the filesystem.

**Project database:** `.fusion/fusion.db` (SQLite with WAL mode)

**Filesystem blobs:**
```
.fusion/
├── fusion.db                # SQLite database (WAL mode)
├── config.json              # Board config + workflow steps
└── tasks/
    └── FN-001/
        ├── PROMPT.md        # Task specification (generated by triage AI)
        ├── agent.log        # Execution logs from the AI agent
        └── attachments/     # File attachments
            ├── screenshot.png
            └── data.json
```

## Task Metadata (in SQLite)

Key fields stored in the `tasks` table:

| Field | Type | Description |
|-------|------|-------------|
| `id` | string | Task ID (e.g., FN-001) |
| `title` | string? | Short title (optional, can be auto-generated) |
| `description` | string | Full task description |
| `column` | string | Current column: triage/todo/in-progress/in-review/done/archived |
| `status` | string? | Sub-status: failed, paused, awaiting-approval |
| `size` | string? | Size estimate: S, M, L |
| `reviewLevel` | number? | Review intensity: 0-3 |
| `currentStep` | number | Index of current execution step |
| `steps` | JSON | Array of step objects with name, status |
| `dependencies` | JSON | Array of task IDs this depends on |
| `log` | JSON | Array of log entries (action, outcome, timestamp) |
| `attachments` | JSON | Array of attachment metadata |
| `prInfo` | JSON? | GitHub PR info (number, url, state) |
| `issueInfo` | JSON? | GitHub issue info (number, url) |
| `modelProvider` | string? | Per-task executor model provider |
| `modelId` | string? | Per-task executor model ID |
| `validatorModelProvider` | string? | Per-task reviewer model provider |
| `validatorModelId` | string? | Per-task reviewer model ID |
| `enabledWorkflowSteps` | JSON | Array of workflow step IDs to run |
| `missionId` | string? | Linked mission ID |
| `sliceId` | string? | Linked slice ID |
| `paused` | boolean | Whether automation is paused |
| `createdAt` | string | ISO timestamp |
| `updatedAt` | string | ISO timestamp |

## PROMPT.md Specification Format

The AI triage agent generates this file with the following structure:

```markdown
# Task: FN-001 — Task Title

**Created:** 2026-03-31
**Size:** M

## Review Level: 2 (Plan and Code)

## Mission

What the task should accomplish.

## Dependencies

- FN-040 — Prerequisite task description

## Context to Read First

- `path/to/relevant/file.ts` — Why to read this file

## File Scope

- `src/components/LoginForm.tsx` (modified)
- `src/utils/validation.ts` (new)
- `tests/LoginForm.test.ts` (new)

## Steps

### Step 1: Research existing patterns
- [ ] Look at existing validation in SignupForm
- [ ] Identify the validation utility pattern

### Step 2: Implement email validation
- [ ] Add validation function
- [ ] Wire up to form submit

## Acceptance Criteria

- [ ] Email validation shows inline error
- [ ] Existing tests pass
- [ ] New validation has test coverage

## Do NOT

- Modify the API endpoints
- Change the form layout

## Testing Requirements

1. Unit tests for email validation function
2. Integration test for form submission with invalid email
```

## Config File

`.fusion/config.json` stores board settings and workflow step definitions:

```json
{
  "nextId": 42,
  "settings": {
    "maxConcurrent": 2,
    "autoMerge": true,
    "prCompletionMode": "direct"
  },
  "workflowSteps": [
    {
      "id": "WS-001",
      "name": "Documentation Review",
      "prompt": "Review the task changes...",
      "enabled": true,
      "defaultOn": true,
      "modelProvider": "anthropic",
      "modelId": "claude-sonnet-4-5"
    }
  ]
}
```

> **Note:** `maxConcurrent` applies to task-lane agents (triage, execution, merge) only. Utility AI workflows—planning mode, subtask breakdown, mission interviews, agent heartbeat/chat wake, and title summarization—run outside this limit on a dedicated control-plane lane.

## Global Settings

User-level settings at `~/.fusion/settings.json`:

```json
{
  "themeMode": "dark",
  "colorTheme": "default",
  "defaultProvider": "anthropic",
  "defaultModelId": "claude-sonnet-4-5",
  "ntfyEnabled": false
}
```

## Central Database (Multi-Project)

For multi-project setups: `~/.fusion/fusion-central.db`
- Project registry
- Unified activity feed
- Global concurrency management
