This commit is contained in:
IGNY8 VPS (Salman)
2025-12-03 14:20:14 +00:00
parent 544741fbe6
commit 30bbcb08a1
8 changed files with 3 additions and 57 deletions

View File

@@ -5,66 +5,12 @@
Based on the documentation and current implementation status, I've identified significant issues with the automation system and legacy SiteBuilder references that need systematic resolution.
---
## SECTION 1: udapte correct status, adn assoitae keywrods ot lcuster properly
Auto cluster AI function is currently setting status of clusters to active, and keywords are not mapped to clusters when run with automation. Update the original auto cluster AI function to use status new instead of active, and identify whether the keyword-to-cluster mapping issue is in the AI function or in the automation.
## SECTION 1: AUTO CLUSTER AI FUNCTION ISSUES
Actualy the orringal ai fucntion has both of this issue, once fixed tehn ai fucntion wil lwork fine and autoamtion also, will run better,
### Task 1.1: Fix Cluster Status Assignment in AutoClusterFunction
**Problem:** Clusters created by automation are assigned `status='active'` instead of proper status progression.
**Current Behavior (from code analysis):**
- Line 95 in `auto_cluster.py`: `Clusters.objects.get_or_create()` uses `defaults={'status': 'active'}`
- This bypasses the intended status flow: `new` → `mapped`
**Required Changes:**
1. Modify `save_output()` method in `AutoClusterFunction` (backend/igny8_core/ai/functions/auto_cluster.py)
2. Change cluster creation to use `status='new'` initially
3. After keyword mapping completes, update cluster status to `status='mapped'`
4. Ensure status progression aligns with automation pipeline expectations
**Verification Steps:**
- Create test with 10 keywords
- Run Stage 1 via automation
- Verify clusters have `status='new'` → then `status='mapped'`
- Confirm automation Stage 2 correctly queries for these clusters
---
### Task 1.2: Investigate Keywords Not Mapping to Clusters
**Problem:** Keywords processed through automation are not getting their `cluster_id` assigned correctly.
**Diagnostic Steps Required:**
1. Add detailed logging in `save_output()` method around line 100-110
2. Log each keyword's ID, text, and whether cluster match was found
3. Check if case-insensitive matching is working: `keyword_obj.keyword.lower() in [k.lower() for k in cluster_keywords]`
4. Verify `Keywords.seed_keyword.keyword` field is populated correctly
5. Check if AI response format matches expected structure: `{clusters: [{name, keywords: [], description}]}`
**Root Cause Analysis:**
- Examine parsed AI response structure
- Verify keyword text extraction from `Keywords` model via `seed_keyword` relationship
- Confirm database transaction commits are occurring
- Check for any filtering conditions excluding keywords
**Fix Implementation:**
1. If mismatch in keyword text format, normalize both sides before comparison
2. If seed_keyword relationship issue, fetch keyword text correctly
3. Add fallback matching using keyword ID if text matching fails
4. Ensure `keyword_obj.save()` is called within transaction
---
### Task 1.3: Distinguish Between Manual vs Automation Execution
**Problem:** AutoClusterFunction behaves the same whether called manually or via automation.
**Required Implementation:**
1. Add `execution_context` parameter to function payload: `{'ids': [...], 'execution_context': 'automation' | 'manual'}`
2. Pass context from `AutomationService.run_stage_1()` when calling AI function
3. In `save_output()`, adjust status assignments based on context:
- Manual: Keep current behavior (`status='active'`)
- Automation: Use progressive status (`'new'` → `'mapped'`)
4. Document context parameter in function metadata
---
## SECTION 2: LEGACY SITEBUILDER/BLUEPRINT REMOVAL