1+ #!/usr/bin/env python3
2+ """Debug script for the 3 failing tasks"""
3+
4+ import os
5+ import sys
6+ from unittest .mock import Mock
7+
8+ sys .path .insert (0 , os .path .join (os .path .dirname (__file__ ), '..' ))
9+
10+ from src .task_executor import TaskExecutor
11+ from src .conversation_manager import ConversationManager
12+ from src .github_handler import GitHubHandler
13+
14+
15+ def test_review_technical_design ():
16+ """Debug REVIEW_TECHNICAL_DESIGN task"""
17+ print ("\n === Testing REVIEW_TECHNICAL_DESIGN ===" )
18+
19+ # Setup
20+ conv_mgr = Mock (spec = ConversationManager )
21+ conv_mgr .model_name = "test-model"
22+ github = Mock (spec = GitHubHandler )
23+
24+ # Mock responses
25+ github .get_file_content .return_value = "# Technical Design\n \n This is a test design document."
26+ conv_mgr .query_model .return_value = """Score: 8.5
27+
28+ Strengths:
29+ - Clear methodology
30+ - Novel approach
31+ - Good feasibility
32+
33+ Concerns:
34+ - Needs more evaluation metrics
35+ - Timeline seems aggressive
36+
37+ Recommendation: Accept
38+ Summary: Strong proposal with minor revisions needed."""
39+
40+ github .create_file .return_value = True
41+ github .get_issue_score .return_value = 5.0
42+ github .update_issue_score .return_value = True
43+
44+ executor = TaskExecutor (conv_mgr , github )
45+
46+ # Test with proper context
47+ context = {
48+ "design_path" : "technical_design_documents/test-proj/design.md" ,
49+ "project_id" : "test-proj" , # This was missing in the test!
50+ "issue_number" : 123
51+ }
52+
53+ result = executor .execute_task ("REVIEW_TECHNICAL_DESIGN" , context )
54+ print (f"Result: { result } " )
55+ print (f"Success: { result .get ('success' , False )} " )
56+ if not result .get ('success' ):
57+ print (f"Error: { result .get ('error' )} " )
58+ if 'raw_response' in result :
59+ print (f"Raw response: { result ['raw_response' ]} " )
60+
61+
62+ def test_update_readme_table ():
63+ """Debug UPDATE_README_TABLE task"""
64+ print ("\n === Testing UPDATE_README_TABLE ===" )
65+
66+ # Setup
67+ conv_mgr = Mock (spec = ConversationManager )
68+ conv_mgr .model_name = "test-model"
69+ github = Mock (spec = GitHubHandler )
70+
71+ # Mock responses
72+ github .get_file_content .return_value = """# README
73+
74+ ## Projects Table
75+
76+ | ID | Name | Status |
77+ |----|------|--------|
78+ | p1 | Project 1 | Active |
79+ """
80+
81+ conv_mgr .query_model .return_value = "| test-proj | Test Project | In Progress |"
82+ github .insert_table_row .return_value = True
83+
84+ executor = TaskExecutor (conv_mgr , github )
85+
86+ # Test with CORRECT parameter names
87+ context = {
88+ "file_path" : "README.md" , # Not readme_path
89+ "table_identifier" : "Projects Table" , # Not table_name
90+ "new_entry" : {"id" : "test-proj" , "name" : "Test Project" , "status" : "In Progress" } # Not new_row
91+ }
92+
93+ result = executor .execute_task ("UPDATE_README_TABLE" , context )
94+ print (f"Result: { result } " )
95+ print (f"Success: { result .get ('success' , False )} " )
96+ if not result .get ('success' ):
97+ print (f"Error: { result .get ('error' )} " )
98+
99+
100+ def test_fork_idea ():
101+ """Debug FORK_IDEA task"""
102+ print ("\n === Testing FORK_IDEA ===" )
103+
104+ # Setup
105+ conv_mgr = Mock (spec = ConversationManager )
106+ conv_mgr .model_name = "test-model"
107+ github = Mock (spec = GitHubHandler )
108+
109+ # Mock original issue
110+ original_issue = Mock ()
111+ original_issue .number = 123
112+ original_issue .title = "Original Research Idea"
113+ original_issue .body = """**Field**: Computer Science
114+ **Abstract**: This is the original idea
115+ **Approach**: Novel approach"""
116+
117+ github .get_issue .return_value = original_issue
118+
119+ # Mock model response with proper format
120+ conv_mgr .query_model .return_value = """Title: Variation 1 - Applied to Biology
121+ Field: Biology
122+ Idea: Apply the same technique to biological systems
123+ Abstract: Testing in biological context
124+ Approach: Adapted approach for bio
125+
126+ Title: Variation 2 - Different Method
127+ Field: Computer Science
128+ Idea: Use alternative algorithm for same problem
129+ Abstract: Different algorithmic approach
130+ Approach: New method
131+
132+ Title: Variation 3 - Extended Complexity
133+ Field: Computer Science
134+ Idea: Extend original with multi-modal inputs
135+ Abstract: Enhanced version with more features
136+ Approach: Extended framework"""
137+
138+ # Mock issue creation
139+ created_issue = Mock ()
140+ created_issue .number = 124
141+ github .create_issue .return_value = created_issue
142+
143+ executor = TaskExecutor (conv_mgr , github )
144+
145+ # Test with correct parameter name
146+ context = {
147+ "issue_number" : 123 # This is correct but was being called as parent_issue in test
148+ }
149+
150+ result = executor .execute_task ("FORK_IDEA" , context )
151+ print (f"Result: { result } " )
152+ print (f"Success: { result .get ('success' , False )} " )
153+ if not result .get ('success' ):
154+ print (f"Error: { result .get ('error' )} " )
155+ else :
156+ print (f"Created issues: { result .get ('forked_issues' , [])} " )
157+
158+
159+ def test_parse_issue_for_idea ():
160+ """Test the _parse_issue_for_idea helper"""
161+ print ("\n === Testing _parse_issue_for_idea helper ===" )
162+
163+ # Setup
164+ conv_mgr = Mock (spec = ConversationManager )
165+ github = Mock (spec = GitHubHandler )
166+ executor = TaskExecutor (conv_mgr , github )
167+
168+ # Test issue
169+ issue = Mock ()
170+ issue .title = "[Idea] Test Research Idea"
171+ issue .body = """**Field**: Computer Science
172+
173+ **Abstract**: This is a test abstract
174+
175+ **Approach**: Novel approach using AI
176+
177+ **Keywords**: AI, machine learning, research"""
178+
179+ result = executor ._parse_issue_for_idea (issue )
180+ print (f"Parsed result: { result } " )
181+
182+
183+ if __name__ == "__main__" :
184+ test_review_technical_design ()
185+ test_update_readme_table ()
186+ test_fork_idea ()
187+ test_parse_issue_for_idea ()
0 commit comments