# Status Implementation Tables - Complete Reference

**Date:** December 3, 2025

---

## 🎯 KEYWORDS MODULE

### Backend Model
**File:** `/backend/igny8_core/business/planning/models.py`

| Field | Type | Choices | Default | Required | Description |
|-------|------|---------|---------|----------|-------------|
| `status` | CharField(50) | `new`, `mapped` | `new` | ✅ Yes | Workflow status |
| `disabled` | BooleanField | - | `False` | ✅ Yes | Filter control (exclude from processes) |

---

### Frontend Table Column
**File:** `/frontend/src/config/pages/keywords.config.tsx` (Lines ~230-248)

| Status Value | Badge Color | Badge Label | Display When |
|--------------|-------------|-------------|--------------|
| `new` | Amber/Yellow | New | Keyword not yet clustered |
| `mapped` | Green | Mapped | Keyword assigned to cluster |
| *(disabled=true)* | Red/Gray | Disabled | User manually disabled (optional display) |

---

### Frontend Filter Dropdown
**File:** `/frontend/src/config/pages/keywords.config.tsx` (Lines ~310-318)

| Filter Type | Options | Default | Description |
|-------------|---------|---------|-------------|
| Status Select | `new`, `mapped` | All | Workflow status filter |
| Disabled Checkbox | Show/Hide disabled | Hide disabled | Filter control |

---

### Frontend Form Fields
**File:** `/frontend/src/config/pages/keywords.config.tsx` (Lines ~560-570)

| Field | Type | Options | Default | Required | Editable |
|-------|------|---------|---------|----------|----------|
| Status | Select | `new`, `mapped` | `new` | ✅ Yes | ✅ Yes |
| Disabled | Checkbox | true/false | `false` | ❌ No | ✅ Yes |

---

## 🎯 CLUSTERS MODULE

### Backend Model
**File:** `/backend/igny8_core/business/planning/models.py`

| Field | Type | Choices | Default | Required | Description |
|-------|------|---------|---------|----------|-------------|
| `status` | CharField(50) | `new`, `mapped` | `new` | ✅ Yes | Workflow status |
| `disabled` | BooleanField | - | `False` | ✅ Yes | Filter control (exclude from processes) |

---

### Frontend Table Column
**File:** `/frontend/src/config/pages/clusters.config.tsx` (Lines ~190-200)

| Status Value | Badge Color | Badge Label | Display When |
|--------------|-------------|-------------|--------------|
| `new` | Amber/Yellow | New | Cluster created, no ideas generated yet |
| `mapped` | Green | Mapped | Ideas generated from cluster |
| *(disabled=true)* | Red/Gray | Disabled | User manually disabled (optional display) |

---

### Frontend Filter Dropdown
**File:** `/frontend/src/config/pages/clusters.config.tsx` (Lines ~240-253)

| Filter Type | Options | Default | Description |
|-------------|---------|---------|-------------|
| Status Select | `new`, `mapped` | All | Workflow status filter |
| Disabled Checkbox | Show/Hide disabled | Hide disabled | Filter control |

---

### Frontend Form Fields
**File:** `/frontend/src/config/pages/clusters.config.tsx` (Lines ~405-418)

| Field | Type | Options | Default | Required | Editable |
|-------|------|---------|---------|----------|----------|
| Status | Select | `new`, `mapped` | `new` | ✅ Yes | ✅ Yes |
| Disabled | Checkbox | true/false | `false` | ❌ No | ✅ Yes |

---

## 🎯 IDEAS MODULE

### Backend Model
**File:** `/backend/igny8_core/business/planning/models.py`

| Field | Type | Choices | Default | Required | Description |
|-------|------|---------|---------|----------|-------------|
| `status` | CharField(50) | `new`, `queued`, `completed` | `new` | ✅ Yes | Workflow status |
| `disabled` | BooleanField | - | `False` | ✅ Yes | Filter control (exclude from processes) |

---

### Frontend Table Column
**File:** `/frontend/src/config/pages/ideas.config.tsx` (Lines ~170-185)

| Status Value | Badge Color | Badge Label | Display When |
|--------------|-------------|-------------|--------------|
| `new` | Amber/Yellow | New | Idea generated, not queued yet |
| `queued` | Blue | Queued | Task created in Writer module |
| `completed` | Green | Completed | Content generated (Task completed) |
| *(disabled=true)* | Red/Gray | Disabled | User manually disabled (optional display) |

---

### Frontend Filter Dropdown
**File:** `/frontend/src/config/pages/ideas.config.tsx` (Lines ~218-228)

| Filter Type | Options | Default | Description |
|-------------|---------|---------|-------------|
| Status Select | `new`, `queued`, `completed` | All | Workflow status filter |
| Disabled Checkbox | Show/Hide disabled | Hide disabled | Filter control |

---

### Frontend Form Fields
**File:** `/frontend/src/config/pages/ideas.config.tsx` (Lines ~372-385)

| Field | Type | Options | Default | Required | Editable |
|-------|------|---------|---------|----------|----------|
| Status | Select | `new`, `queued`, `completed` | `new` | ✅ Yes | ✅ Yes |
| Disabled | Checkbox | true/false | `false` | ❌ No | ✅ Yes |

---

---

# 🔄 STATUS TRANSITION TABLES

## KEYWORDS Status Transitions

| Current Status | Trigger/Action | Next Status | Auto/Manual | Updated By |
|----------------|----------------|-------------|-------------|------------|
| `new` | AI auto_cluster runs | `mapped` | 🤖 Auto | `auto_cluster.py` Line 297 |
| `new` | User manually assigns to cluster | `mapped` | 👤 Manual | User form edit |
| `new` | User toggles disabled | *(stays new)* + `disabled=true` | 👤 Manual | User form edit |
| `mapped` | User toggles disabled | *(stays mapped)* + `disabled=true` | 👤 Manual | User form edit |
| *(any)* | User re-enables | *(stays same)* + `disabled=false` | 👤 Manual | User form edit |

**Workflow Path:**
```
new ──[auto_cluster AI]──> mapped
 │
 └──[user toggle disabled]──> (status unchanged, disabled flag set)
```

---

## CLUSTERS Status Transitions

| Current Status | Trigger/Action | Next Status | Auto/Manual | Updated By |
|----------------|----------------|-------------|-------------|------------|
| `new` | AI generate_ideas runs | `mapped` | 🤖 Auto | `generate_ideas.py` (new code) |
| `new` | User manually creates ideas | `mapped` | 👤 Manual | User workflow |
| `new` | User toggles disabled | *(stays new)* + `disabled=true` | 👤 Manual | User form edit |
| `mapped` | User toggles disabled | *(stays mapped)* + `disabled=true` | 👤 Manual | User form edit |
| *(any)* | User re-enables | *(stays same)* + `disabled=false` | 👤 Manual | User form edit |

**Workflow Path:**
```
new ──[generate_ideas AI]──> mapped
 │
 └──[user toggle disabled]──> (status unchanged, disabled flag set)
```

---

## IDEAS Status Transitions

| Current Status | Trigger/Action | Next Status | Auto/Manual | Updated By |
|----------------|----------------|-------------|-------------|------------|
| `new` | User bulk-queues ideas to writer | `queued` | 👤 Manual | `views.py` Line 1084 |
| `queued` | Writer AI generates content | `completed` | 🤖 Auto | `generate_content.py` Line 318 (syncs from Task) |
| `queued` | Task status becomes 'completed' | `completed` | 🤖 Auto | Auto-sync from Task.status |
| `new` | User toggles disabled | *(stays new)* + `disabled=true` | 👤 Manual | User form edit |
| `queued` | User toggles disabled | *(stays queued)* + `disabled=true` | 👤 Manual | User form edit |
| `completed` | User toggles disabled | *(stays completed)* + `disabled=true` | 👤 Manual | User form edit |
| *(any)* | User re-enables | *(stays same)* + `disabled=false` | 👤 Manual | User form edit |

**Workflow Path:**
```
new ──[user bulk_queue]──> queued ──[generate_content AI]──> completed
 │                            │                                   │
 └──[user toggle disabled]────┴───────────[user toggle]──────────┘
    (status unchanged, disabled flag set)
```

---

---

# 📊 COMBINED STATUS OVERVIEW

## All Modules - Status Values

| Module | Workflow Statuses | Filter Status | Total Unique Values |
|--------|-------------------|---------------|---------------------|
| **Keywords** | `new`, `mapped` | `disabled` (boolean) | 2 status + 1 flag |
| **Clusters** | `new`, `mapped` | `disabled` (boolean) | 2 status + 1 flag |
| **Ideas** | `new`, `queued`, `completed` | `disabled` (boolean) | 3 status + 1 flag |

---

## Process Inclusion Matrix

| Status | Auto-Cluster AI | Generate-Ideas AI | Bulk-Queue | Generate-Content AI | Dashboard Metrics |
|--------|-----------------|-------------------|------------|---------------------|-------------------|
| Keywords: `new` | ✅ Included | ❌ N/A | ❌ N/A | ❌ N/A | ✅ Counted |
| Keywords: `mapped` | ❌ Already clustered | ✅ Used for ideas | ❌ N/A | ❌ N/A | ✅ Counted |
| Keywords: `disabled=true` | ❌ Excluded | ❌ Excluded | ❌ N/A | ❌ N/A | ❌ Excluded |
| Clusters: `new` | ❌ N/A | ✅ Included | ❌ N/A | ❌ N/A | ✅ Counted |
| Clusters: `mapped` | ❌ N/A | ❌ Already has ideas | ✅ Ideas can queue | ❌ N/A | ✅ Counted |
| Clusters: `disabled=true` | ❌ N/A | ❌ Excluded | ❌ Excluded | ❌ N/A | ❌ Excluded |
| Ideas: `new` | ❌ N/A | ❌ N/A | ✅ Included | ❌ N/A | ✅ Counted |
| Ideas: `queued` | ❌ N/A | ❌ N/A | ❌ Already queued | ✅ Included | ✅ Counted |
| Ideas: `completed` | ❌ N/A | ❌ N/A | ❌ Already done | ❌ Already done | ✅ Counted |
| Ideas: `disabled=true` | ❌ N/A | ❌ N/A | ❌ Excluded | ❌ Excluded | ❌ Excluded |

---

---

# 🔄 DATA MIGRATION TRANSITION TABLE

## Keywords Migration

| Old Status | New Status | New Disabled Flag | Logic |
|------------|------------|-------------------|-------|
| `pending` | `new` | `false` | Direct mapping |
| `active` | `mapped` | `false` | Keyword was clustered |
| `archived` | `mapped` | `true` | Preserve data, mark as disabled |

**SQL Preview:**
```sql
-- Keywords migration
UPDATE igny8_keywords 
SET status = 'new', disabled = false 
WHERE status = 'pending';

UPDATE igny8_keywords 
SET status = 'mapped', disabled = false 
WHERE status = 'active';

UPDATE igny8_keywords 
SET status = 'mapped', disabled = true 
WHERE status = 'archived';
```

---

## Clusters Migration

| Old Status | New Status | New Disabled Flag | Logic |
|------------|------------|-------------------|-------|
| `active` (with ideas_count > 0) | `mapped` | `false` | Cluster has ideas |
| `active` (with ideas_count = 0) | `new` | `false` | Cluster has no ideas yet |
| *(no archived status exists)* | - | - | - |

**SQL Preview:**
```sql
-- Clusters migration
UPDATE igny8_clusters 
SET status = 'mapped', disabled = false 
WHERE ideas_count > 0;

UPDATE igny8_clusters 
SET status = 'new', disabled = false 
WHERE ideas_count = 0;
```

---

## Ideas Migration

| Old Status | New Status | New Disabled Flag | Logic |
|------------|------------|-------------------|-------|
| `new` | `new` | `false` | No change |
| `scheduled` | `queued` | `false` | Rename to match writer workflow |
| `published` | `completed` | `false` | Publishing is separate deployment |
| *(no archived status)* | - | - | - |

**SQL Preview:**
```sql
-- Ideas migration
UPDATE igny8_content_ideas 
SET status = 'new', disabled = false 
WHERE status = 'new';

UPDATE igny8_content_ideas 
SET status = 'queued', disabled = false 
WHERE status = 'scheduled';

UPDATE igny8_content_ideas 
SET status = 'completed', disabled = false 
WHERE status = 'published';
```

---

---

# 📋 SUMMARY COMPARISON TABLE

## Before vs After

| Module | Current Status Values | New Status Values | Current Filter | New Filter |
|--------|----------------------|-------------------|----------------|------------|
| **Keywords** | `pending`, `active`, `archived` | `new`, `mapped` | Status dropdown | Status dropdown + disabled checkbox |
| **Clusters** | `active` (hardcoded, no choices) | `new`, `mapped` | Status dropdown | Status dropdown + disabled checkbox |
| **Ideas** | `new`, `scheduled`, `published` | `new`, `queued`, `completed` | Status dropdown | Status dropdown + disabled checkbox |

---

## Status Count Changes

| Module | Before | After | Change |
|--------|--------|-------|--------|
| **Keywords** | 3 status values | 2 workflow + 1 boolean flag | -1 status (simplified) |
| **Clusters** | 1 hardcoded value | 2 workflow + 1 boolean flag | +1 status (proper choices) |
| **Ideas** | 3 status values | 3 workflow + 1 boolean flag | Same count (renamed) |

---

**END OF IMPLEMENTATION TABLES**
