feat(mma): Connect ExecutionEngine to ConductorEngine and Tech Lead

This commit is contained in:
2026-02-27 20:12:23 -05:00
parent 154957fe57
commit 2429b7c1b4
2 changed files with 70 additions and 66 deletions

View File

@@ -56,43 +56,29 @@ def generate_tickets(track_brief: str, module_skeletons: str) -> list[dict]:
# Restore old system prompt
ai_client.set_custom_system_prompt(old_system_prompt)
from dag_engine import TrackDAG
from models import Ticket
def topological_sort(tickets: list[dict]) -> list[dict]:
"""
Sorts a list of tickets based on their 'depends_on' field.
Raises ValueError if a circular dependency or missing internal dependency is detected.
"""
# 1. Map ID to ticket and build graph
# 1. Convert to Ticket objects for TrackDAG
ticket_objs = []
for t_data in tickets:
ticket_objs.append(Ticket.from_dict(t_data))
# 2. Use TrackDAG for validation and sorting
dag = TrackDAG(ticket_objs)
try:
sorted_ids = dag.topological_sort()
except ValueError as e:
raise ValueError(f"DAG Validation Error: {e}")
# 3. Return sorted dictionaries
ticket_map = {t['id']: t for t in tickets}
adj = {t['id']: [] for t in tickets}
in_degree = {t['id']: 0 for t in tickets}
for t in tickets:
for dep_id in t.get('depends_on', []):
if dep_id not in ticket_map:
raise ValueError(f"Missing dependency: Ticket '{t['id']}' depends on '{dep_id}', but '{dep_id}' is not in the ticket list.")
adj[dep_id].append(t['id'])
in_degree[t['id']] += 1
# 2. Find nodes with in-degree 0
queue = [t['id'] for t in tickets if in_degree[t['id']] == 0]
sorted_ids = []
# 3. Process queue
while queue:
u_id = queue.pop(0)
sorted_ids.append(u_id)
for v_id in adj[u_id]:
in_degree[v_id] -= 1
if in_degree[v_id] == 0:
queue.append(v_id)
# 4. Check for cycles
if len(sorted_ids) != len(tickets):
# Find which tickets are part of a cycle (or blocked by one)
remaining = [t_id for t_id in ticket_map if t_id not in sorted_ids]
raise ValueError(f"Circular dependency detected among tickets: {remaining}")
return [ticket_map[t_id] for t_id in sorted_ids]
return [ticket_map[tid] for tid in sorted_ids]
if __name__ == "__main__":
# Quick test if run directly