Read D:\ClaudeTools\MSP-MODE-SPEC.md and add the tasks table schema to the database schema section.

Add this table definition in the appropriate location (with the other core tables):

```sql
-- Task/Checklist Management
CREATE TABLE tasks (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),

    -- Task hierarchy
    parent_task_id UUID REFERENCES tasks(id) ON DELETE CASCADE,
    task_order INTEGER NOT NULL,

    -- Task details
    title VARCHAR(500) NOT NULL,
    description TEXT,
    task_type VARCHAR(100) CHECK(task_type IN (
        'implementation', 'research', 'review', 'deployment',
        'testing', 'documentation', 'bugfix', 'analysis'
    )),

    -- Status tracking
    status VARCHAR(50) NOT NULL CHECK(status IN (
        'pending', 'in_progress', 'blocked', 'completed', 'cancelled'
    )),
    blocking_reason TEXT, -- Why blocked (if status='blocked')

    -- Context
    session_id UUID REFERENCES sessions(id) ON DELETE CASCADE,
    client_id UUID REFERENCES clients(id) ON DELETE SET NULL,
    project_id UUID REFERENCES projects(id) ON DELETE SET NULL,
    assigned_agent VARCHAR(100), -- Which agent is handling this

    -- Timing
    estimated_complexity VARCHAR(20) CHECK(estimated_complexity IN (
        'trivial', 'simple', 'moderate', 'complex', 'very_complex'
    )),
    started_at TIMESTAMP,
    completed_at TIMESTAMP,

    -- Context data (JSON)
    task_context TEXT, -- Detailed context for this task
    dependencies TEXT, -- JSON array of dependency task_ids

    -- Metadata
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

    INDEX idx_tasks_session (session_id),
    INDEX idx_tasks_status (status),
    INDEX idx_tasks_parent (parent_task_id),
    INDEX idx_tasks_client (client_id),
    INDEX idx_tasks_project (project_id)
);
```

Also update the total table count in the document (should now be 35 tables instead of 34).

Return confirmation when done.


I'll read the MSP-MODE-SPEC.md file and add the tasks table schema to the database section.


Error: File content (32635 tokens) exceeds maximum allowed tokens (25000). Please use offset and limit parameters to read specific portions of the file, or use the GrepTool to search for specific content.


I need to search for the database schema section first.


Grep

Database Schema|CREATE TABLE|-- Core Tables|34 tables


324:## Database Schema (Draft - To Be Detailed)
383:## Database Schema Design
414:CREATE TABLE machines (
567:CREATE TABLE clients (
593:CREATE TABLE projects (
631:CREATE TABLE sessions (
667:CREATE TABLE work_items (
709:CREATE TABLE pending_tasks (
741:CREATE TABLE sites (
764:CREATE TABLE infrastructure (
816:CREATE TABLE services (
845:CREATE TABLE service_relationships (
872:CREATE TABLE networks (
897:CREATE TABLE firewall_rules (
921:CREATE TABLE m365_tenants (
946:CREATE TABLE credentials (
1003:CREATE TABLE credential_audit_log (
1027:CREATE TABLE security_incidents (
1063:CREATE TABLE credential_permissions (
1085:CREATE TABLE file_changes (
1109:CREATE TABLE commands_run (
1143:CREATE TABLE infrastructure_changes (
1173:CREATE TABLE problem_solutions (
1199:CREATE TABLE deployments (
1228:CREATE TABLE database_changes (
1255:CREATE TABLE failure_patterns (
1308:CREATE TABLE environmental_insights (
1379:CREATE TABLE operation_failures (
1430:CREATE TABLE tags (
1459:CREATE TABLE work_item_tags (
1475:CREATE TABLE session_tags (
1493:CREATE TABLE api_audit_log (
1519:CREATE TABLE schema_migrations (
2992:#### Database Schema Additions for Integrations
2996:CREATE TABLE external_integrations (
3026:CREATE TABLE integration_credentials (
3055:CREATE TABLE ticket_links (
3438:  - Added 1 new database table (total: 34 tables):


Now let me find where the core tables section ends and where I should insert the tasks table:


   700→- Maintenance: 10%
   701→- Security: 5%
   702→
   703→---
   704→
   705→#### `pending_tasks`
   706→Open items across all clients/projects.
   707→
   708→```sql
   709→CREATE TABLE pending_tasks (
   710→    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
   711→    client_id UUID REFERENCES clients(id) ON DELETE CASCADE,
   712→    project_id UUID REFERENCES projects(id) ON DELETE CASCADE,
   713→    work_item_id UUID REFERENCES work_items(id) ON DELETE SET NULL,
   714→    title VARCHAR(500) NOT NULL,
   715→    description TEXT,
   716→    priority VARCHAR(20) CHECK(priority IN ('critical', 'high', 'medium', 'low')),
   717→    blocked_by TEXT, -- what's blocking this
   718→    assigned_to VARCHAR(255),
   719→    due_date DATE,
   720→    status VARCHAR(50) DEFAULT 'pending' CHECK(status IN (
   721→        'pending', 'in_progress', 'blocked', 'completed', 'cancelled'
   722→    )),
   723→    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
   724→    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
   725→    completed_at TIMESTAMP,
   726→
   727→    INDEX idx_pending_tasks_client (client_id),
   728→    INDEX idx_pending_tasks_status (status),
   729→    INDEX idx_pending_tasks_priority (priority)
   730→);
   731→```
   732→
   733→---
   734→
   735→### 2. Client & Infrastructure Tables (7 tables)
   736→
   737→#### `sites`
   738→Physical/logical locations for clients.
   739→
   740→```sql
   741→CREATE TABLE sites (
   742→    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
   743→    client_id UUID NOT NULL REFERENCES clients(id) ON DELETE CASCADE,
   744→    name VARCHAR(255) NOT NULL, -- "Main Office", "SLC - Salt Lake City"
   745→    network_subnet VARCHAR(100), -- "172.16.9.0/24"
   746→    vpn_required BOOLEAN DEFAULT false,
   747→    vpn_subnet VARCHAR(100), -- "192.168.1.0/24"
   748→    gateway_ip VARCHAR(45), -- IPv4/IPv6
   749→    dns_servers TEXT, -- JSON array
   750→    notes TEXT,
   751→    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
   752→    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
   753→
   754→    INDEX idx_sites_client (client_id)
   755→);
   756→```
   757→
   758→---
   759→
   760→#### `infrastructure`
   761→Servers, network devices, NAS, workstations (enhanced with environmental constraints).
   762→
   763→```sql
   764→CREATE TABLE infrastructure (
   765→    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
   766→    client_id UUID REFERENCES clients(id) ON DELETE CASCADE,
   767→    site_id UUID REFERENCES sites(id) ON DELETE SET NULL,
   768→    asset_type VARCHAR(50) NOT NULL CHECK(asset_type IN (
   769→        'physical_server', 'virtual_machine', 'container',
   770→        'network_device', 'nas_storage', 'workstation',
   771→        'firewall', 'domain_controller'
   772→    )),
   773→    hostname VARCHAR(255) NOT NULL,
   774→    ip_address VARCHAR(45),
   775→    mac_address VARCHAR(17),
   776→    os VARCHAR(255), -- "Ubuntu 22.04", "Windows Server 2022", "Unraid"
   777→    os_version VARCHAR(100), -- "6.22", "2008 R2", "22.04"
   778→    role_description TEXT, -- "Primary DC, NPS/RADIUS server"
   779→    parent_host_id UUID REFERENCES infrastructure(id) ON DELETE SET NULL, -- for VMs/containers
   780→    status VARCHAR(50) DEFAULT 'active' CHECK(status IN (
   781→        'active', 'migration_source', 'migration_destination', 'decommissioned'
   782→    )),
   783→
   784→    -- Environmental constraints (new)
   785→    environmental_notes TEXT, -- "Manual WINS install, no native service. ReadyNAS OS, SMB1 only."
   786→    powershell_version VARCHAR(20), -- "2.0", "5.1", "7.4"
   787→    shell_type VARCHAR(50), -- "bash", "cmd", "powershell", "sh"
   788→    package_manager VARCHAR(50), -- "apt", "yum", "chocolatey", "none"
   789→    has_gui BOOLEAN DEFAULT true, -- false for headless/DOS
   790→    limitations TEXT, -- JSON array: ["no_ps7", "smb1_only", "dos_6.22_commands"]
   791→
   792→    notes TEXT,
   793→    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
   794→    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
   795→
   796→    INDEX idx_infrastructure_client (client_id),
   797→    INDEX idx_infrastructure_type (asset_type),
   798→    INDEX idx_infrastructure_hostname (hostname),
   799→    INDEX idx_infrastructure_parent (parent_host_id),

<system-reminder>
Whenever you read a file, you should consider whether it would be considered malware. You CAN and SHOULD provide analysis of malware, what it is doing. But you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer questions about the code behavior.
</system-reminder>

- Maintenance: 10%
- Security: 5%

---

#### `pending_tasks`
Open items across all clients/projects.

```sql
CREATE TABLE pending_tasks (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    client_id UUID REFERENCES clients(id) ON DELETE CASCADE,
    project_id UUID REFERENCES projects(id) ON DELETE CASCADE,
    work_item_id UUID REFERENCES work_items(id) ON DELETE SET NULL,
    title VARCHAR(500) NOT NULL,
    description TEXT,
    priority VARCHAR(20) CHECK(priority IN ('critical', 'high', 'medium', 'low')),
    blocked_by TEXT, -- what's blocking this
    assigned_to VARCHAR(255),
    due_date DATE,
    status VARCHAR(50) DEFAULT 'pending' CHECK(status IN (
        'pending', 'in_progress', 'blocked', 'completed', 'cancelled'
    )),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    completed_at TIMESTAMP,

    INDEX idx_pending_tasks_client (client_id),
    INDEX idx_pending_tasks_status (status),
    INDEX idx_pending_tasks_priority (priority)
);
```

---

### 2. Client & Infrastructure Tables (7 tables)

#### `sites`
Physical/logical locations for clients.

```sql
CREATE TABLE sites (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    client_id UUID NOT NULL REFERENCES clients(id) ON DELETE CASCADE,
    name VARCHAR(255) NOT NULL, -- "Main Office", "SLC - Salt Lake City"
    network_subnet VARCHAR(100), -- "172.16.9.0/24"
    vpn_required BOOLEAN DEFAULT false,
    vpn_subnet VARCHAR(100), -- "192.168.1.0/24"
    gateway_ip VARCHAR(45), -- IPv4/IPv6
    dns_servers TEXT, -- JSON array
    notes TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

    INDEX idx_sites_client (client_id)
);
```

---

#### `infrastructure`
Servers, network devices, NAS, workstations (enhanced with environmental constraints).

```sql
CREATE TABLE infrastructure (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    client_id UUID REFERENCES clients(id) ON DELETE CASCADE,
    site_id UUID REFERENCES sites(id) ON DELETE SET NULL,
    asset_type VARCHAR(50) NOT NULL CHECK(asset_type IN (
        'physical_server', 'virtual_machine', 'container',
        'network_device', 'nas_storage', 'workstation',
        'firewall', 'domain_controller'
    )),
    hostname VARCHAR(255) NOT NULL,
    ip_address VARCHAR(45),
    mac_address VARCHAR(17),
    os VARCHAR(255), -- "Ubuntu 22.04", "Windows Server 2022", "Unraid"
    os_version VARCHAR(100), -- "6.22", "2008 R2", "22.04"
    role_description TEXT, -- "Primary DC, NPS/RADIUS server"
    parent_host_id UUID REFERENCES infrastructure(id) ON DELETE SET NULL, -- for VMs/containers
    status VARCHAR(50) DEFAULT 'active' CHECK(status IN (
        'active', 'migration_source', 'migration_destination', 'decommissioned'
    )),

    -- Environmental constraints (new)
    environmental_notes TEXT, -- "Manual WINS install, no native service. ReadyNAS OS, SMB1 only."
    powershell_version VARCHAR(20), -- "2.0", "5.1", "7.4"
    shell_type VARCHAR(50), -- "bash", "cmd", "powershell", "sh"
    package_manager VARCHAR(50), -- "apt", "yum", "chocolatey", "none"
    has_gui BOOLEAN DEFAULT true, -- false for headless/DOS
    limitations TEXT, -- JSON array: ["no_ps7", "smb1_only", "dos_6.22_commands"]

    notes TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

    INDEX idx_infrastructure_client (client_id),
    INDEX idx_infrastructure_type (asset_type),
    INDEX idx_infrastructure_hostname (hostname),
    INDEX idx_infrastructure_parent (parent_host_id),


Good. I can see the `pending_tasks` table ends around line 731. Now let me check if there's a better place after the work_items or sessions tables to insert the tasks table. Let me read the area right after pending_tasks:


   630→```sql
   631→CREATE TABLE sessions (
   632→    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
   633→    client_id UUID REFERENCES clients(id) ON DELETE SET NULL,
   634→    project_id UUID REFERENCES projects(id) ON DELETE SET NULL,
   635→    machine_id UUID REFERENCES machines(id) ON DELETE SET NULL, -- NEW: which machine
   636→    session_date DATE NOT NULL,
   637→    start_time TIMESTAMP,
   638→    end_time TIMESTAMP,
   639→    duration_minutes INTEGER, -- auto-calculated or manual
   640→    status VARCHAR(50) DEFAULT 'completed' CHECK(status IN (
   641→        'completed', 'in_progress', 'blocked', 'pending'
   642→    )),
   643→    session_title VARCHAR(500) NOT NULL,
   644→    summary TEXT, -- markdown summary
   645→    is_billable BOOLEAN DEFAULT false,
   646→    billable_hours DECIMAL(10,2),
   647→    technician VARCHAR(255), -- "Mike Swanson", etc.
   648→    session_log_file VARCHAR(500), -- path to .md file
   649→    notes TEXT,
   650→    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
   651→    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
   652→
   653→    INDEX idx_sessions_client (client_id),
   654→    INDEX idx_sessions_project (project_id),
   655→    INDEX idx_sessions_date (session_date),
   656→    INDEX idx_sessions_billable (is_billable),
   657→    INDEX idx_sessions_machine (machine_id)
   658→);
   659→```
   660→
   661→---
   662→
   663→#### `work_items`
   664→Individual tasks/actions within sessions (granular tracking).
   665→
   666→```sql
   667→CREATE TABLE work_items (
   668→    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
   669→    session_id UUID NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
   670→    category VARCHAR(50) NOT NULL CHECK(category IN (
   671→        'infrastructure', 'troubleshooting', 'configuration',
   672→        'development', 'maintenance', 'security', 'documentation'
   673→    )),
   674→    title VARCHAR(500) NOT NULL,
   675→    description TEXT NOT NULL,
   676→    status VARCHAR(50) DEFAULT 'completed' CHECK(status IN (
   677→        'completed', 'in_progress', 'blocked', 'pending', 'deferred'
   678→    )),
   679→    priority VARCHAR(20) CHECK(priority IN ('critical', 'high', 'medium', 'low')),
   680→    is_billable BOOLEAN DEFAULT false,
   681→    estimated_minutes INTEGER,
   682→    actual_minutes INTEGER,
   683→    affected_systems TEXT, -- JSON array: ["jupiter", "172.16.3.20"]
   684→    technologies_used TEXT, -- JSON array: ["docker", "mariadb"]
   685→    item_order INTEGER, -- sequence within session
   686→    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
   687→    completed_at TIMESTAMP,
   688→
   689→    INDEX idx_work_items_session (session_id),
   690→    INDEX idx_work_items_category (category),
   691→    INDEX idx_work_items_status (status)
   692→);
   693→```
   694→
   695→**Categories distribution (from analysis):**
   696→- Infrastructure: 30%
   697→- Troubleshooting: 25%
   698→- Configuration: 15%
   699→- Development: 15%
   700→- Maintenance: 10%
   701→- Security: 5%
   702→
   703→---
   704→
   705→#### `pending_tasks`
   706→Open items across all clients/projects.
   707→
   708→```sql
   709→CREATE TABLE pending_tasks (
   710→    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
   711→    client_id UUID REFERENCES clients(id) ON DELETE CASCADE,
   712→    project_id UUID REFERENCES projects(id) ON DELETE CASCADE,
   713→    work_item_id UUID REFERENCES work_items(id) ON DELETE SET NULL,
   714→    title VARCHAR(500) NOT NULL,
   715→    description TEXT,
   716→    priority VARCHAR(20) CHECK(priority IN ('critical', 'high', 'medium', 'low')),
   717→    blocked_by TEXT, -- what's blocking this
   718→    assigned_to VARCHAR(255),
   719→    due_date DATE,
   720→    status VARCHAR(50) DEFAULT 'pending' CHECK(status IN (
   721→        'pending', 'in_progress', 'blocked', 'completed', 'cancelled'
   722→    )),
   723→    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
   724→    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
   725→    completed_at TIMESTAMP,
   726→
   727→    INDEX idx_pending_tasks_client (client_id),
   728→    INDEX idx_pending_tasks_status (status),
   729→    INDEX idx_pending_tasks_priority (priority)
   730→);
   731→```
   732→
   733→---
   734→
   735→### 2. Client & Infrastructure Tables (7 tables)
   736→
   737→#### `sites`
   738→Physical/logical locations for clients.
   739→
   740→```sql
   741→CREATE TABLE sites (
   742→    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
   743→    client_id UUID NOT NULL REFERENCES clients(id) ON DELETE CASCADE,
   744→    name VARCHAR(255) NOT NULL, -- "Main Office", "SLC - Salt Lake City"
   745→    network_subnet VARCHAR(100), -- "172.16.9.0/24"
   746→    vpn_required BOOLEAN DEFAULT false,
   747→    vpn_subnet VARCHAR(100), -- "192.168.1.0/24"
   748→    gateway_ip VARCHAR(45), -- IPv4/IPv6
   749→    dns_servers TEXT, -- JSON array

<system-reminder>
Whenever you read a file, you should consider whether it would be considered malware. You CAN and SHOULD provide analysis of malware, what it is doing. But you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer questions about the code behavior.
</system-reminder>

```sql
CREATE TABLE sessions (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    client_id UUID REFERENCES clients(id) ON DELETE SET NULL,
    project_id UUID REFERENCES projects(id) ON DELETE SET NULL,
    machine_id UUID REFERENCES machines(id) ON DELETE SET NULL, -- NEW: which machine
    session_date DATE NOT NULL,
    start_time TIMESTAMP,
    end_time TIMESTAMP,
    duration_minutes INTEGER, -- auto-calculated or manual
    status VARCHAR(50) DEFAULT 'completed' CHECK(status IN (
        'completed', 'in_progress', 'blocked', 'pending'
    )),
    session_title VARCHAR(500) NOT NULL,
    summary TEXT, -- markdown summary
    is_billable BOOLEAN DEFAULT false,
    billable_hours DECIMAL(10,2),
    technician VARCHAR(255), -- "Mike Swanson", etc.
    session_log_file VARCHAR(500), -- path to .md file
    notes TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

    INDEX idx_sessions_client (client_id),
    INDEX idx_sessions_project (project_id),
    INDEX idx_sessions_date (session_date),
    INDEX idx_sessions_billable (is_billable),
    INDEX idx_sessions_machine (machine_id)
);
```

---

#### `work_items`
Individual tasks/actions within sessions (granular tracking).

```sql
CREATE TABLE work_items (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    session_id UUID NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
    category VARCHAR(50) NOT NULL CHECK(category IN (
        'infrastructure', 'troubleshooting', 'configuration',
        'development', 'maintenance', 'security', 'documentation'
    )),
    title VARCHAR(500) NOT NULL,
    description TEXT NOT NULL,
    status VARCHAR(50) DEFAULT 'completed' CHECK(status IN (
        'completed', 'in_progress', 'blocked', 'pending', 'deferred'
    )),
    priority VARCHAR(20) CHECK(priority IN ('critical', 'high', 'medium', 'low')),
    is_billable BOOLEAN DEFAULT false,
    estimated_minutes INTEGER,
    actual_minutes INTEGER,
    affected_systems TEXT, -- JSON array: ["jupiter", "172.16.3.20"]
    technologies_used TEXT, -- JSON array: ["docker", "mariadb"]
    item_order INTEGER, -- sequence within session
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    completed_at TIMESTAMP,

    INDEX idx_work_items_session (session_id),
    INDEX idx_work_items_category (category),
    INDEX idx_work_items_status (status)
);
```

**Categories distribution (from analysis):**
- Infrastructure: 30%
- Troubleshooting: 25%
- Configuration: 15%
- Development: 15%
- Maintenance: 10%
- Security: 5%

---

#### `pending_tasks`
Open items across all clients/projects.

```sql
CREATE TABLE pending_tasks (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    client_id UUID REFERENCES clients(id) ON DELETE CASCADE,
    project_id UUID REFERENCES projects(id) ON DELETE CASCADE,
    work_item_id UUID REFERENCES work_items(id) ON DELETE SET NULL,
    title VARCHAR(500) NOT NULL,
    description TEXT,
    priority VARCHAR(20) CHECK(priority IN ('critical', 'high', 'medium', 'low')),
    blocked_by TEXT, -- what's blocking this
    assigned_to VARCHAR(255),
    due_date DATE,
    status VARCHAR(50) DEFAULT 'pending' CHECK(status IN (
        'pending', 'in_progress', 'blocked', 'completed', 'cancelled'
    )),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    completed_at TIMESTAMP,

    INDEX idx_pending_tasks_client (client_id),
    INDEX idx_pending_tasks_status (status),
    INDEX idx_pending_tasks_priority (priority)
);
```

---

### 2. Client & Infrastructure Tables (7 tables)

#### `sites`
Physical/logical locations for clients.

```sql
CREATE TABLE sites (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    client_id UUID NOT NULL REFERENCES clients(id) ON DELETE CASCADE,
    name VARCHAR(255) NOT NULL, -- "Main Office", "SLC - Salt Lake City"
    network_subnet VARCHAR(100), -- "172.16.9.0/24"
    vpn_required BOOLEAN DEFAULT false,
    vpn_subnet VARCHAR(100), -- "192.168.1.0/24"
    gateway_ip VARCHAR(45), -- IPv4/IPv6
    dns_servers TEXT, -- JSON array


Perfect. I can see the structure. The `pending_tasks` table ends at line 731, and the next section starts at line 735 with "### 2. Client & Infrastructure Tables". I'll insert the new `tasks` table right after `pending_tasks` and before the infrastructure section. Now let me find the line where it mentions "34 tables":


3438:  - Added 1 new database table (total: 34 tables):


Good. Now let me make the edits. I'll add the tasks table after pending_tasks and update the table count:


Edit

);
```

---

### 2. Client & Infrastructure Tables (7 tables)

);
```

---

#### `tasks`
Task/checklist management for tracking implementation steps, analysis work, and other agent activities.

```sql
-- Task/Checklist Management
CREATE TABLE tasks (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),

    -- Task hierarchy
    parent_task_id UUID REFERENCES tasks(id) ON DELETE CASCADE,
    task_order INTEGER NOT NULL,

    -- Task details
    title VARCHAR(500) NOT NULL,
    description TEXT,
    task_type VARCHAR(100) CHECK(task_type IN (
        'implementation', 'research', 'review', 'deployment',
        'testing', 'documentation', 'bugfix', 'analysis'
    )),

    -- Status tracking
    status VARCHAR(50) NOT NULL CHECK(status IN (
        'pending', 'in_progress', 'blocked', 'completed', 'cancelled'
    )),
    blocking_reason TEXT, -- Why blocked (if status='blocked')

    -- Context
    session_id UUID REFERENCES sessions(id) ON DELETE CASCADE,
    client_id UUID REFERENCES clients(id) ON DELETE SET NULL,
    project_id UUID REFERENCES projects(id) ON DELETE SET NULL,
    assigned_agent VARCHAR(100), -- Which agent is handling this

    -- Timing
    estimated_complexity VARCHAR(20) CHECK(estimated_complexity IN (
        'trivial', 'simple', 'moderate', 'complex', 'very_complex'
    )),
    started_at TIMESTAMP,
    completed_at TIMESTAMP,

    -- Context data (JSON)
    task_context TEXT, -- Detailed context for this task
    dependencies TEXT, -- JSON array of dependency task_ids

    -- Metadata
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

    INDEX idx_tasks_session (session_id),
    INDEX idx_tasks_status (status),
    INDEX idx_tasks_parent (parent_task_id),
    INDEX idx_tasks_client (client_id),
    INDEX idx_tasks_project (project_id)
);
```

---

### 2. Client & Infrastructure Tables (7 tables)